优化验证码 以及跳转部分
parent
346eb13d50
commit
8f942bf01e
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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"
|
||||
});
|
||||
}
|
||||
},
|
||||
// 获取商品详情
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue