Browse Source

修复激活套餐页面提示显示不全 -zzx

zouzexu 7 months ago
parent
commit
4e6dd71f10
3 changed files with 66 additions and 45 deletions
  1. 62 44
      my/vipActivation/index.vue
  2. 3 0
      uni_modules/uview-ui/components/u-toast/u-toast.vue
  3. 1 1
      utils/request.js

+ 62 - 44
my/vipActivation/index.vue

@@ -8,11 +8,14 @@
 					<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>
+					<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" />
+				<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>
@@ -35,35 +38,46 @@
 				<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'
+	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:'',
+				expireTime: '',
 				redeemload: false,
 				activationList: [],
-				list:[],
-				userInfo:'',
-				setMealName:'',
-				vipQuery:{
-					phoneNum:'',
-					activationCode:'',
+				list: [],
+				userInfo: '',
+				setMealName: '',
+				vipQuery: {
+					phoneNum: '',
+					activationCode: '',
 				}
 			}
 		},
-		onShow() {
-		},
+		onShow() {},
 		onLoad() {
-			this.userInfo=JSON.parse(uni.getStorageSync('userInfo'))
-			this.vipQuery.phoneNum=this.userInfo.phoneNum
+			this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
+			this.vipQuery.phoneNum = this.userInfo.phoneNum
 			this.mealList()
 			this.get_activationList()
 			this.get_userinfo()
@@ -71,26 +85,26 @@
 
 		methods: {
 			// 用户信息
-			get_userinfo(){
-				refreshVip().then(res=>{
-					res.content.map((item)=>{
-						this.expireTime=timestampToDate(item.expirationTime)
+			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)
+			get_activationList() {
+				getActivationList().then(res => {
+					if (res.state == 'Success') {
+						res.content.content.map((item) => {
+							item.useTime = timestampToDate(item.useTime)
 						})
-						this.activationList=res.content.content
+						this.activationList = res.content.content
 					}
 				})
 			},
-			
+
 			// 二次确认
 			confirmActivation() {
 				let that = this
@@ -105,33 +119,37 @@
 					}
 				})
 			},
-			
+
 			// 兑换激活码
-			select_activationCode(){
-				selectActivationCode(this.vipQuery).then(res=>{
-					this.redeemload=false
-					if(res.state=='Success'){
+			select_activationCode() {
+				selectActivationCode(this.vipQuery).then(res => {
+					this.redeemload = false
+					if (res.state == 'Success') {
 						uni.showToast({
 							title: '激活成功',
 						});
-						this.vipQuery.activationCode=''
+						this.vipQuery.activationCode = ''
 						this.get_activationList()
-					}else{
-						uni.showToast({
-							title: res.content,
-						});
+					} else if(res.content=='该手机号已订购【惠生活优享会员】,请在会员到期后再使用激活码'){
+						this.$refs.uToast.show({
+							message:res.content
+						})
 					}
 				})
 			},
 
 			// 获取套餐类型
-			mealList(){
-				mealList({currentPage:1,pageSize:99,status:1}).then(res=>{
+			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.list.map(item => {
+							if (item.setMealCode == this.userInfo.setMealCode) {
 								this.setMealName = item.setMealName
 							}
 						})

+ 3 - 0
uni_modules/uview-ui/components/u-toast/u-toast.vue

@@ -255,6 +255,9 @@
 			}
 		}
 	}
+	.u-toast__content{
+		text-align: center;
+	}
 
 	.u-type-primary {
 		color: $u-toast-u-type-primary-color;

+ 1 - 1
utils/request.js

@@ -27,7 +27,7 @@ export let request = (options) => {
 								duration: 5000
 							})
 							// uni.hideLoading()
-						} else if (res.data.msg != '成功') { //接口返回报错
+						} else if (res.data.msg != '成功'&&res.data.content!='该手机号已订购【惠生活优享会员】,请在会员到期后再使用激活码') { //接口返回报错
 							setTimeout(()=>{
 								uni.showToast({
 									title: res.data.content || res.data.msg ||(res.data.exception && res.data.exception.message) || '请求失败',