优化小程序登录跳转部分代码.新增全局条件编译跳转方法

This commit is contained in:
lemon橪
2021-08-17 11:53:56 +08:00
parent 3d1e175194
commit d76bab4b71
12 changed files with 68 additions and 41 deletions

View File

@@ -81,6 +81,7 @@ export default {
* 进入页面检测当前账户是否登录
*/
onShow() {
let that = this
if (this.$options.filters.isLogin("auth")) {
this.getAddressList();
} else {
@@ -90,9 +91,7 @@ export default {
confirmColor: this.$lightColor,
success: function (res) {
if (res.confirm) {
uni.navigateTo({
url: "/pages/passport/login",
});
that.$options.filters.navigateToLogin();
} else if (res.cancel) {
uni.navigateBack();
}

View File

@@ -36,9 +36,8 @@ export default {
duration: 3000,
title: "请先登录!",
});
uni.redirectTo({
url: "/pages/passport/login",
});
this.$options.filters.navigateToLogin("redirectTo");
}
},
methods: {

View File

@@ -59,9 +59,7 @@ export default {
storage.setAccessToken("");
storage.setRefreshToken("");
storage.setUserInfo({});
uni.redirectTo({
url: "/pages/passport/login",
});
this.$options.filters.navigateToLogin("redirectTo");
},
/**

View File

@@ -79,7 +79,11 @@ export default {
},
});
} else {
this.$api.msg("暂无发票可预览");
uni.showToast({
title: "暂无发票可预览",
duration: 2000,
icon: "none",
});
}
},
download() {
@@ -95,7 +99,11 @@ export default {
uni.saveFile({
tempFilePath: tempFilePath,
success: function (res) {
_this.$api.msg("发票已下载到" + res.savedFilePath);
uni.showToast({
title: "发票已下载到" + res.savedFilePath,
duration: 2000,
icon: "none",
});
},
});
}
@@ -103,7 +111,11 @@ export default {
});
});
} else {
this.$api.msg("暂无发票可下载");
uni.showToast({
title: "暂无发票可下载",
duration: 2000,
icon: "none",
});
}
},
},

View File

@@ -7,7 +7,7 @@
<u-form-item class="cell code" label-width="120" prop="code" label="验证码">
<div style="display:flex; with:100%;">
<u-input v-model="codeForm.code" placeholder="请输入验证码" />
<u-input maxlength="6" v-model="codeForm.code" placeholder="请输入验证码" />
<u-verification-code keep-running unique-key="page-login" :seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange"></u-verification-code>
<view @tap="getCode" class="text-tips">{{ tips }}</view>
</div>

View File

@@ -20,7 +20,7 @@
</view>
<view class="btns">
<button type="primary" bindtap="getUserProfile" @click="getUserProfile()" class="btn-auth">使用微信授权</button>
<button @click="backToHome" class="btn-callback">暂不登录</button>
<div @click="backToHome" class="btn-callback">暂不登录</div>
</view>
</div>
</view>
@@ -75,9 +75,9 @@ export default {
back() {
whetherNavigate("wx");
},
backToHome(){
backToHome() {
uni.switchTab({
url: `/pages/tabbar/home/index`
url: `/pages/tabbar/home/index`,
});
},
//获取用户信息
@@ -236,7 +236,7 @@ text.shop {
.btn-auth {
width: 92%;
margin: 0 auto 40rpx;
// border-radius: 100px;
border-radius: 100px;
animation: mymove 5s infinite;
-webkit-animation: mymove 5s infinite; /*Safari and Chrome*/
animation-direction: alternate; /*轮流反向播放动画。*/
@@ -247,8 +247,14 @@ text.shop {
-webkit-animation-timing-function: ease-in-out; /*动画的速度曲线*/
}
.btn-callback {
text-align: center;
font-size: 30rpx;
border: 1rpx solid #ededed;
height: 90rpx;
line-height: 90rpx;
border-radius: 100px;
width: 92%;
margin: 0 auto 100rpx;
margin: 0 auto;
}
.btns {

View File

@@ -321,9 +321,8 @@ export default {
duration: 3000,
title: "请先登录!",
});
uni.redirectTo({
url: "/pages/passport/login",
});
this.$options.filters.navigateToLogin("redirectTo");
return false;
}
receiveCoupons(item.id).then((res) => {

View File

@@ -129,7 +129,7 @@ export default {
userDetail() {
this.userInfo.id
? this.navigateTo("/pages/mine/set/personMsg")
: this.navigateTo("/pages/passport/login");
: this.$options.filters.navigateToLogin();;
},
async getUserOrderNum() {
uni.stopPullDownRefresh();