123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- <template>
- <view class="vip">
- <view style="height: 20rpx;"></view>
- <view class="topCard">
- <view class="vipInfo">
- <view class="left">
- <view class="ownVip">当前会员:<text>{{setMealName||'普通用户'}}</text></view>
- <view class="endTime">会员到期时间: {{expireTime||'--'}}</view>
- </view>
- <view class="right">
- <image slot="icon"
- src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/Jm8VtOGY6Bqg6cf0dd7cba21cff1cf57cd5a36effe8f.png/1.png"
- mode="widthFix"></image>
- </view>
- </view>
- <view class="inputBox">
- <input type="text" v-model="vipQuery.activationCode" placeholder="请输入激活码"
- placeholder-class="activationIpt" />
- <u-button type="error " :loading="redeemload" loadingSize="20" shape="circle" text="立即兑换"
- @click="confirmActivation"></u-button>
- </view>
- </view>
- <view class="listCard">
- <view class="listTitle">激活记录</view>
- <view class="listBox" v-if="activationList.length>0">
- <view class="list" v-for="(item,index) in activationList" :key="item.id">
- <view class="vipTitle">
- <view class="">{{item.planningName}}</view>
- <view class="">已激活</view>
- </view>
- <view class="listInfo">
- <view class="">激活码:<text>{{item.serialNumber}}</text></view>
- <view class="">激活时间: {{item.useTime}}</view>
- </view>
- </view>
- </view>
- <block v-else>
- <u-empty mode="data" textSize="20" iconSize="120" text="暂无激活记录"></u-empty>
- </block>
- </view>
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import {
- mealList
- } from '@/api/combo.js'
- import {
- refreshVip
- } from '@/api/common.js'
- import {
- selectActivationCode,
- getActivationList
- } from '@/api/vipActivation.js'
- import {
- levelImgName
- } from '@/utils/config.js'
- import {
- timestampToDate
- } from '@/utils/tool.js'
- export default {
- data() {
- return {
- expireTime: '',
- redeemload: false,
- activationList: [],
- list: [],
- userInfo: '',
- setMealName: '',
- vipQuery: {
- phoneNum: '',
- activationCode: '',
- }
- }
- },
- onShow() {},
- onLoad() {
- this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
- this.vipQuery.phoneNum = this.userInfo.phoneNum
- this.mealList()
- this.get_activationList()
- this.get_userinfo()
- },
- methods: {
- // 用户信息
- get_userinfo() {
- refreshVip().then(res => {
- res.content.map((item) => {
- this.expireTime = timestampToDate(item.expirationTime)
- })
- })
- },
- // 激活列表
- get_activationList() {
- getActivationList().then(res => {
- if (res.state == 'Success') {
- res.content.content.map((item) => {
- item.useTime = timestampToDate(item.useTime)
- })
- this.activationList = res.content.content
- }
- })
- },
- // 二次确认
- confirmActivation() {
- if(this.vipQuery.activationCode=='') {
- uni.showToast({
- title:'请输入激活码',
- icon:'none'
- })
- return
- }
- let that = this
- uni.showModal({
- title: '提示',
- content: '确认兑换当前激活码吗?',
- success(res) {
- if (res.confirm) {
- that.redeemload = true
- that.select_activationCode()
- }
- }
- })
- },
- // 兑换激活码
- select_activationCode() {
- selectActivationCode(this.vipQuery).then(res => {
- this.redeemload = false
- if (res.state == 'Success') {
- uni.showToast({
- title: '激活成功',
- });
- this.vipQuery.activationCode = ''
- this.get_activationList()
- } else{
- this.$refs.uToast.show({
- message:res.content
- })
- }
- })
- },
- // 获取套餐类型
- mealList() {
- mealList({
- currentPage: 1,
- pageSize: 99,
- status: 1
- }).then(res => {
- if (res.state == 'Success') {
- this.list = res.content.records
- // 判断当前会员类型
- this.list.map(item => {
- if (item.setMealCode == this.userInfo.setMealCode) {
- this.setMealName = item.setMealName
- }
- })
- }
- })
- },
- }
- }
- </script>
- <style lang="scss">
- .vip {
- height: 100vh;
- padding: 0 24rpx;
- background: #F9F9F9;
- .topCard {
- background: #fff;
- border-radius: 8rpx;
- padding: 20rpx;
- .vipInfo {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .left {
- .ownVip {
- font-size: 28rpx;
- color: #181818;
- font-weight: bold;
- &>text {
- margin-left: 10rpx;
- font-weight: bold;
- font-size: 36rpx;
- }
- }
- .endTime {
- margin-top: 20rpx;
- font-weight: normal;
- font-size: 24rpx;
- color: #AAAAAA;
- }
- }
- .right {
- &>image {
- width: 100rpx;
- }
- }
- }
- .inputBox {
- display: flex;
- align-items: center;
- border: #F9F9F9 4rpx solid;
- border-radius: 50rpx;
- padding: 6rpx;
- margin-top: 20rpx;
- &>input {
- margin-left: 8rpx;
- width: 1800rpx;
- }
- .activationIpt {
- font-size: 28rpx;
- color: #AAAAAA;
- }
- }
- }
- .listCard {
- background: #fff;
- border-radius: 8rpx;
- padding: 20rpx;
- margin-top: 20rpx;
- .listTitle {
- font-weight: bold;
- font-size: 28rpx;
- color: #222222;
- }
- .listBox {
- .list {
- border-bottom: 1rpx solid #F0F0F0;
- .vipTitle {
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-weight: bold;
- font-size: 32rpx;
- margin-top: 20rpx;
- &>view:first-child {
- color: #222222;
- }
- &>view:last-child {
- color: #FF4A39;
- }
- }
- .listInfo {
- margin-top: 20rpx;
- &>view:first-child {
- font-weight: normal;
- color: #222222;
- font-size: 24rpx;
- &>text {
- margin-left: 10rpx;
- color: #AAAAAA;
- }
- }
- &>view:last-child {
- height: 64rpx;
- line-height: 64rpx;
- font-size: 24rpx;
- font-weight: normal;
- color: #222222;
- }
- }
- }
- }
- }
- }
- </style>
|