index.vue 5.6 KB

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