index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. if(this.vipQuery.activationCode=='') {
  107. uni.showToast({
  108. title:'请输入激活码',
  109. icon:'none'
  110. })
  111. return
  112. }
  113. let that = this
  114. uni.showModal({
  115. title: '提示',
  116. content: '确认兑换当前激活码吗?',
  117. success(res) {
  118. if (res.confirm) {
  119. that.redeemload = true
  120. that.select_activationCode()
  121. }
  122. }
  123. })
  124. },
  125. // 兑换激活码
  126. select_activationCode() {
  127. selectActivationCode(this.vipQuery).then(res => {
  128. this.redeemload = false
  129. if (res.state == 'Success') {
  130. uni.showToast({
  131. title: '激活成功',
  132. });
  133. this.vipQuery.activationCode = ''
  134. this.get_activationList()
  135. } else if(res.content=='该手机号已订购【惠生活优享会员】,请在会员到期后再使用激活码'){
  136. this.$refs.uToast.show({
  137. message:res.content
  138. })
  139. }
  140. })
  141. },
  142. // 获取套餐类型
  143. mealList() {
  144. mealList({
  145. currentPage: 1,
  146. pageSize: 99,
  147. status: 1
  148. }).then(res => {
  149. if (res.state == 'Success') {
  150. this.list = res.content.records
  151. // 判断当前会员类型
  152. this.list.map(item => {
  153. if (item.setMealCode == this.userInfo.setMealCode) {
  154. this.setMealName = item.setMealName
  155. }
  156. })
  157. }
  158. })
  159. },
  160. }
  161. }
  162. </script>
  163. <style lang="scss">
  164. .vip {
  165. height: 100vh;
  166. padding: 0 24rpx;
  167. background: #F9F9F9;
  168. .topCard {
  169. background: #fff;
  170. border-radius: 8rpx;
  171. padding: 20rpx;
  172. .vipInfo {
  173. display: flex;
  174. align-items: center;
  175. justify-content: space-between;
  176. .left {
  177. .ownVip {
  178. font-size: 28rpx;
  179. color: #181818;
  180. font-weight: bold;
  181. &>text {
  182. margin-left: 10rpx;
  183. font-weight: bold;
  184. font-size: 36rpx;
  185. }
  186. }
  187. .endTime {
  188. margin-top: 20rpx;
  189. font-weight: normal;
  190. font-size: 24rpx;
  191. color: #AAAAAA;
  192. }
  193. }
  194. .right {
  195. &>image {
  196. width: 100rpx;
  197. }
  198. }
  199. }
  200. .inputBox {
  201. display: flex;
  202. align-items: center;
  203. border: #F9F9F9 4rpx solid;
  204. border-radius: 50rpx;
  205. padding: 6rpx;
  206. margin-top: 20rpx;
  207. &>input {
  208. margin-left: 8rpx;
  209. width: 1800rpx;
  210. }
  211. .activationIpt {
  212. font-size: 28rpx;
  213. color: #AAAAAA;
  214. }
  215. }
  216. }
  217. .listCard {
  218. background: #fff;
  219. border-radius: 8rpx;
  220. padding: 20rpx;
  221. margin-top: 20rpx;
  222. .listTitle {
  223. font-weight: bold;
  224. font-size: 28rpx;
  225. color: #222222;
  226. }
  227. .listBox {
  228. .list {
  229. border-bottom: 1rpx solid #F0F0F0;
  230. .vipTitle {
  231. display: flex;
  232. align-items: center;
  233. justify-content: space-between;
  234. font-weight: bold;
  235. font-size: 32rpx;
  236. margin-top: 20rpx;
  237. &>view:first-child {
  238. color: #222222;
  239. }
  240. &>view:last-child {
  241. color: #FF4A39;
  242. }
  243. }
  244. .listInfo {
  245. margin-top: 20rpx;
  246. &>view:first-child {
  247. font-weight: normal;
  248. color: #222222;
  249. font-size: 24rpx;
  250. &>text {
  251. margin-left: 10rpx;
  252. color: #AAAAAA;
  253. }
  254. }
  255. &>view:last-child {
  256. height: 64rpx;
  257. line-height: 64rpx;
  258. font-size: 24rpx;
  259. font-weight: normal;
  260. color: #222222;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. </style>