优化验证码 以及跳转部分

This commit is contained in:
lemon橪
2021-07-07 15:59:48 +08:00
parent 346eb13d50
commit 8f942bf01e
6 changed files with 58 additions and 55 deletions

View File

@@ -1,5 +1,5 @@
<template>
<view class="wrapper">
<view class="wrapper" v-if="flage">
<div class='goods' v-if="selectedGoods">
<image class="goods-image" :src="selectedGoods.thumbnail" alt="">
<p class="goodsName">{{selectedGoods.goodsName}}</p>
@@ -72,6 +72,7 @@ import popupGoods from "./popup/goods"; //购物车商品的模块
export default {
data() {
return {
flage:false, //判断接口是否正常请求
addr: {
id: "",
},
@@ -138,7 +139,8 @@ export default {
// 实例化本页面
async init(sn, sku) {
let res = await getPinTuanShare(sn, sku);
if (res.data.success) {
if (res.data.success && res.data.result.promotionGoods) {
this.flage = true
this.data = res.data.result;
this.selectedGoods = res.data.result.promotionGoods;
let endTime = Date.parse(
@@ -175,12 +177,17 @@ export default {
// 获取当前商品是否已经购买
if (storage.getUserInfo().id) {
let isBuy = res.data.result.pintuanMemberVOS.filter((item) => {
return item.memberId == storage.getUserInfo().id;
});
isBuy.length != 0 ? (this.isBuy = true) : (this.isBuy = false);
}
} else {
uni.showToast({
title: '当前拼团单有误!请联系管理员重试',
duration: 2000,
icon:"none"
});
}
},
// 获取商品详情

View File

@@ -71,6 +71,7 @@ export default {
},
// 必须要在onReady生命周期setRules因为onLoad生命周期组件可能尚未创建完毕
mounted() {
// whetherNavigate();
this.$refs.validateCodeForm.setRules(this.codeRules);
/**
* 条件编译判断当前客户端类型
@@ -83,35 +84,33 @@ export default {
//#endif
},
watch: {
flage(val) {
async flage(val) {
if (val) {
if (this.$refs.uCode.canGetCode) {
// 向后端请求验证码
uni.showLoading({
title: "正在获取验证码",
});
sendMobile(this.codeForm.mobile)
.then((res) => {
uni.hideLoading();
// 这里此提示会被this.start()方法中的提示覆盖
if (res.data.success) {
this.$refs.uCode.start();
} else {
uni.showToast({
title: res.data.message,
duration: 2000,
icon: "none",
});
uni.navigateBack();
}
})
.catch((e) => {
this.flage = false;
this.codeFlag = true;
let res = await sendMobile(this.codeForm.mobile);
uni.hideLoading();
// 这里此提示会被this.start()方法中的提示覆盖
if (res.data.success) {
this.$refs.uCode.start();
} else {
uni.showToast({
title: res.data.message,
duration: 2000,
icon: "none",
});
this.flage = false;
}
} else {
this.$u.toast("请倒计时结束后再发送");
}
} else {
this.$refs.verification.hide();
}
},
},
@@ -217,10 +216,11 @@ export default {
title: "请输入正确手机号",
icon: "none",
});
return false;
}
if (!this.flage) {
this.$refs.verification.hide();
this.$refs.verification.error();
return false;
}
},