优化验证码 以及跳转部分

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

View File

@ -56,7 +56,7 @@
<script>
import api from "@/config/api.js";
import storage from "@/utils/storage.js";
import uuid from "@/utils/uuid.modified.js";
const phone = uni.getSystemInfoSync();
const l = phone.screenWidth / 750;
export default {
@ -65,12 +65,7 @@ export default {
//
this.scHight = phone.screenHeight / 2 - 200 + "px";
this.getCode();
//
uni.$on("vert", (data) => {
this.vsr = data;
this.vsrtx = "点击进行验证";
this.getCode();
});
},
props: {
height: {
@ -136,10 +131,19 @@ export default {
this.hid = !this.hid;
}
},
error() {
this.vsr = false;
this.hid = false;
this.moveX = 0;
this.moveCode = 0;
},
//
getCode() {
this.col = "#b3afae";
this.hasImg = "图片加载中...";
if (!storage.getUuid()) {
storage.setUuid(uuid.v1());
}
uni.request({
url: api.common + "/slider/" + this.business,
header: {
@ -472,16 +476,10 @@ export default {
bottom: 70rpx;
}
.moneycolor {
color: #ea5002;
}
.margin-top {
margin-top: 20rpx;
}
@ -498,14 +496,10 @@ export default {
margin-left: 20rpx;
}
.margin-right {
margin-right: 20rpx;
}
.main-color {
color: #07d188;
}

View File

@ -4,10 +4,10 @@
*/
// 开发环境
const dev = {
common: "https://common-api.pickmall.cn",
buyer: "https://buyer-api.pickmall.cn",
// common: "http://192.168.0.109:8890",
// buyer: "http://192.168.0.109:8888",
// common: "https://common-api.pickmall.cn",
// buyer: "https://buyer-api.pickmall.cn",
common: "http://192.168.0.106:8890",
buyer: "http://192.168.0.106:8888",
};
// 生产环境
const prod = {

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 {
},
// onReadysetRulesonLoad
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;
}
},

View File

@ -81,18 +81,17 @@ export function checkBankno(bankno) {
*/
export function whetherNavigate(type = "default") {
let navigation = getCurrentPages()[getCurrentPages().length - (getCurrentPages().length ) ];
if (getCurrentPages().length > 1) {
if ((getCurrentPages().length - 2).route == "pages/passport/login") {
console.log(navigation, getCurrentPages());
if (navigation.route == "pages/passport/login") {
navigationToBack(type);
} else {
if (
!(getCurrentPages().length - 2).route ||
(getCurrentPages().length - 2).route == "undefined"
) {
if (!navigation.route || navigation.route == "undefined") {
navigationToBack(type);
} else {
uni.navigateBack({
delta: getCurrentPages().length - 2,
delta: getCurrentPages().length,
});
}
}

View File

@ -73,7 +73,7 @@ function cleanStorage() {
storage.setHasLogin(false);
storage.setAccessToken("");
storage.setRefreshToken("");
console.log("清空token")
console.log("清空token");
storage.setUuid("");
storage.setUserInfo({});
@ -121,7 +121,7 @@ http.interceptors.request.use(
config.params = params;
config.header.accessToken = accessToken;
/**
* jwt 因为安卓以及ios没有window的属性
* window.atob这个函数 base64编码的使用方法就是btoa而用于解码的使用方法是atob
@ -133,8 +133,11 @@ http.interceptors.request.use(
refresh();
} else {
if (
JSON.parse(atob(accessToken.split(".")[1].replace(/-/g, '+').replace(/_/g, '/'))).exp <
Math.round(new Date() / 1000)
JSON.parse(
atob(
accessToken.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")
)
).exp < Math.round(new Date() / 1000)
) {
refresh();
}
@ -144,6 +147,7 @@ http.interceptors.request.use(
...config.header,
uuid: storage.getUuid() || uuid.v1(),
};
console.log(config.header);
return config;
},
(config) => {
@ -151,7 +155,6 @@ http.interceptors.request.use(
}
);
async function refresh() {
// 本地储存的是过期token了重新获取
const getTokenResult = await refreshToken();