index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view class="vip">
  3. <view style="height: 20rpx;"></view>
  4. <view class="topCard">
  5. <view class="vipInfo">
  6. <view class="left">
  7. <view class="ownVip">当前会员:<text>{{setMealName||'普通用户'}}</text></view>
  8. <view class="endTime">会员到期时间: {{expireTime||'--'}}</view>
  9. </view>
  10. <view class="right">
  11. <image slot="icon"
  12. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/Jm8VtOGY6Bqg6cf0dd7cba21cff1cf57cd5a36effe8f.png/1.png"
  13. mode="widthFix"></image>
  14. </view>
  15. </view>
  16. <view class="inputBox">
  17. <input type="text" v-model="vipQuery.activationCode" placeholder="请输入激活码"
  18. placeholder-class="activationIpt" />
  19. <u-button type="error " :loading="redeemload" loadingSize="20" shape="circle" text="立即兑换"
  20. @click="confirmActivation"></u-button>
  21. </view>
  22. </view>
  23. <view class="listCard">
  24. <view class="listTitle">激活记录</view>
  25. <view class="listBox" v-if="activationList.length>0">
  26. <view class="list" v-for="(item,index) in activationList" :key="item.id">
  27. <view class="vipTitle">
  28. <view class="">{{item.planningName}}</view>
  29. <view class="">已激活</view>
  30. </view>
  31. <view class="listInfo">
  32. <view class="">激活码:<text>{{item.serialNumber}}</text></view>
  33. <view class="">激活时间: {{item.useTime}}</view>
  34. </view>
  35. </view>
  36. </view>
  37. <block v-else>
  38. <u-empty mode="data" textSize="20" iconSize="120" text="暂无激活记录"></u-empty>
  39. </block>
  40. </view>
  41. <u-toast ref="uToast"></u-toast>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. mealList
  47. } from '@/api/combo.js'
  48. import {
  49. refreshVip
  50. } from '@/api/common.js'
  51. import {
  52. selectActivationCode,
  53. getActivationList
  54. } from '@/api/vipActivation.js'
  55. import {
  56. levelImgName
  57. } from '@/utils/config.js'
  58. import {
  59. timestampToDate
  60. } from '@/utils/tool.js'
  61. export default {
  62. data() {
  63. return {
  64. expireTime: '',
  65. redeemload: false,
  66. activationList: [],
  67. list: [],
  68. userInfo: '',
  69. setMealName: '',
  70. vipQuery: {
  71. phoneNum: '',
  72. activationCode: '',
  73. }
  74. }
  75. },
  76. onShow() {},
  77. onLoad() {
  78. this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
  79. this.vipQuery.phoneNum = this.userInfo.phoneNum
  80. this.mealList()
  81. this.get_activationList()
  82. this.get_userinfo()
  83. },
  84. methods: {
  85. // 用户信息
  86. get_userinfo() {
  87. refreshVip().then(res => {
  88. res.content.map((item) => {
  89. this.expireTime = timestampToDate(item.expirationTime)
  90. })
  91. })
  92. },
  93. // 激活列表
  94. get_activationList() {
  95. getActivationList().then(res => {
  96. if (res.state == 'Success') {
  97. res.content.content.map((item) => {
  98. item.useTime = timestampToDate(item.useTime)
  99. })
  100. this.activationList = res.content.content
  101. }
  102. })
  103. },
  104. // 二次确认
  105. confirmActivation() {
  106. let that = this
  107. uni.showModal({
  108. title: '提示',
  109. content: '确认兑换当前激活码吗?',
  110. success(res) {
  111. if (res.confirm) {
  112. that.redeemload = true
  113. that.select_activationCode()
  114. }
  115. }
  116. })
  117. },
  118. // 兑换激活码
  119. select_activationCode() {
  120. selectActivationCode(this.vipQuery).then(res => {
  121. this.redeemload = false
  122. if (res.state == 'Success') {
  123. uni.showToast({
  124. title: '激活成功',
  125. });
  126. this.vipQuery.activationCode = ''
  127. this.get_activationList()
  128. } else if(res.content=='该手机号已订购【惠生活优享会员】,请在会员到期后再使用激活码'){
  129. this.$refs.uToast.show({
  130. message:res.content
  131. })
  132. }
  133. })
  134. },
  135. // 获取套餐类型
  136. mealList() {
  137. mealList({
  138. currentPage: 1,
  139. pageSize: 99,
  140. status: 1
  141. }).then(res => {
  142. if (res.state == 'Success') {
  143. this.list = res.content.records
  144. // 判断当前会员类型
  145. this.list.map(item => {
  146. if (item.setMealCode == this.userInfo.setMealCode) {
  147. this.setMealName = item.setMealName
  148. }
  149. })
  150. }
  151. })
  152. },
  153. }
  154. }
  155. </script>
  156. <style lang="scss">
  157. .vip {
  158. height: 100vh;
  159. padding: 0 24rpx;
  160. background: #F9F9F9;
  161. .topCard {
  162. background: #fff;
  163. border-radius: 8rpx;
  164. padding: 20rpx;
  165. .vipInfo {
  166. display: flex;
  167. align-items: center;
  168. justify-content: space-between;
  169. .left {
  170. .ownVip {
  171. font-size: 28rpx;
  172. color: #181818;
  173. font-weight: bold;
  174. &>text {
  175. margin-left: 10rpx;
  176. font-weight: bold;
  177. font-size: 36rpx;
  178. }
  179. }
  180. .endTime {
  181. margin-top: 20rpx;
  182. font-weight: normal;
  183. font-size: 24rpx;
  184. color: #AAAAAA;
  185. }
  186. }
  187. .right {
  188. &>image {
  189. width: 100rpx;
  190. }
  191. }
  192. }
  193. .inputBox {
  194. display: flex;
  195. align-items: center;
  196. border: #F9F9F9 4rpx solid;
  197. border-radius: 50rpx;
  198. padding: 6rpx;
  199. margin-top: 20rpx;
  200. &>input {
  201. margin-left: 8rpx;
  202. width: 1800rpx;
  203. }
  204. .activationIpt {
  205. font-size: 28rpx;
  206. color: #AAAAAA;
  207. }
  208. }
  209. }
  210. .listCard {
  211. background: #fff;
  212. border-radius: 8rpx;
  213. padding: 20rpx;
  214. margin-top: 20rpx;
  215. .listTitle {
  216. font-weight: bold;
  217. font-size: 28rpx;
  218. color: #222222;
  219. }
  220. .listBox {
  221. .list {
  222. border-bottom: 1rpx solid #F0F0F0;
  223. .vipTitle {
  224. display: flex;
  225. align-items: center;
  226. justify-content: space-between;
  227. font-weight: bold;
  228. font-size: 32rpx;
  229. margin-top: 20rpx;
  230. &>view:first-child {
  231. color: #222222;
  232. }
  233. &>view:last-child {
  234. color: #FF4A39;
  235. }
  236. }
  237. .listInfo {
  238. margin-top: 20rpx;
  239. &>view:first-child {
  240. font-weight: normal;
  241. color: #222222;
  242. font-size: 24rpx;
  243. &>text {
  244. margin-left: 10rpx;
  245. color: #AAAAAA;
  246. }
  247. }
  248. &>view:last-child {
  249. height: 64rpx;
  250. line-height: 64rpx;
  251. font-size: 24rpx;
  252. font-weight: normal;
  253. color: #222222;
  254. }
  255. }
  256. }
  257. }
  258. }
  259. }
  260. </style>