优化小程序登录跳转部分代码.新增全局条件编译跳转方法
parent
3d1e175194
commit
d76bab4b71
19
main.js
19
main.js
|
@ -11,25 +11,11 @@ let btn = Vue.component("airBtn", airBtn); //全局注册
|
||||||
document.body.appendChild(new btn().$mount().$el);
|
document.body.appendChild(new btn().$mount().$el);
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Object.keys(filters).forEach((key) => {
|
Object.keys(filters).forEach((key) => {
|
||||||
Vue.filter(key, filters[key]);
|
Vue.filter(key, filters[key]);
|
||||||
});
|
});
|
||||||
|
|
||||||
const msg = (title, duration = 1500, mask = false, icon = "none") => {
|
// 引入Vuex
|
||||||
//统一提示方便全局修改
|
|
||||||
if (Boolean(title) === false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uni.showToast({
|
|
||||||
title,
|
|
||||||
duration,
|
|
||||||
mask,
|
|
||||||
icon,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
// 引入vuex
|
|
||||||
Vue.prototype.$store = store;
|
Vue.prototype.$store = store;
|
||||||
Vue.use(uView);
|
Vue.use(uView);
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
|
@ -37,8 +23,7 @@ Vue.config.productionTip = false;
|
||||||
Vue.prototype.$mainColor = "#ff3c2a";
|
Vue.prototype.$mainColor = "#ff3c2a";
|
||||||
// 高亮主题色
|
// 高亮主题色
|
||||||
Vue.prototype.$lightColor = "#ff6b35";
|
Vue.prototype.$lightColor = "#ff6b35";
|
||||||
// 可直接 this.$api调用
|
|
||||||
Vue.prototype.$api = { msg };
|
|
||||||
|
|
||||||
App.mpType = "app";
|
App.mpType = "app";
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
"name" : "lili商城",
|
"name" : "lili商城",
|
||||||
"appid" : "__UNI__C100675",
|
"appid" : "__UNI__C100675",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "4.0.28",
|
"versionName" : "4.0.29",
|
||||||
"versionCode" : 4000028,
|
"versionCode" : 4000029,
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
"app-plus" : {
|
"app-plus" : {
|
||||||
"compatible" : {
|
"compatible" : {
|
||||||
|
|
|
@ -81,6 +81,7 @@ export default {
|
||||||
* 进入页面检测当前账户是否登录
|
* 进入页面检测当前账户是否登录
|
||||||
*/
|
*/
|
||||||
onShow() {
|
onShow() {
|
||||||
|
let that = this
|
||||||
if (this.$options.filters.isLogin("auth")) {
|
if (this.$options.filters.isLogin("auth")) {
|
||||||
this.getAddressList();
|
this.getAddressList();
|
||||||
} else {
|
} else {
|
||||||
|
@ -90,9 +91,7 @@ export default {
|
||||||
confirmColor: this.$lightColor,
|
confirmColor: this.$lightColor,
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
uni.navigateTo({
|
that.$options.filters.navigateToLogin();
|
||||||
url: "/pages/passport/login",
|
|
||||||
});
|
|
||||||
} else if (res.cancel) {
|
} else if (res.cancel) {
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,8 @@ export default {
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
title: "请先登录!",
|
title: "请先登录!",
|
||||||
});
|
});
|
||||||
uni.redirectTo({
|
|
||||||
url: "/pages/passport/login",
|
this.$options.filters.navigateToLogin("redirectTo");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -59,9 +59,7 @@ export default {
|
||||||
storage.setAccessToken("");
|
storage.setAccessToken("");
|
||||||
storage.setRefreshToken("");
|
storage.setRefreshToken("");
|
||||||
storage.setUserInfo({});
|
storage.setUserInfo({});
|
||||||
uni.redirectTo({
|
this.$options.filters.navigateToLogin("redirectTo");
|
||||||
url: "/pages/passport/login",
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -79,7 +79,11 @@ export default {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.$api.msg("暂无发票可预览");
|
uni.showToast({
|
||||||
|
title: "暂无发票可预览",
|
||||||
|
duration: 2000,
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
download() {
|
download() {
|
||||||
|
@ -95,7 +99,11 @@ export default {
|
||||||
uni.saveFile({
|
uni.saveFile({
|
||||||
tempFilePath: tempFilePath,
|
tempFilePath: tempFilePath,
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
_this.$api.msg("发票已下载到" + res.savedFilePath);
|
uni.showToast({
|
||||||
|
title: "发票已下载到" + res.savedFilePath,
|
||||||
|
duration: 2000,
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -103,7 +111,11 @@ export default {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.$api.msg("暂无发票可下载");
|
uni.showToast({
|
||||||
|
title: "暂无发票可下载",
|
||||||
|
duration: 2000,
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<u-form-item class="cell code" label-width="120" prop="code" label="验证码">
|
<u-form-item class="cell code" label-width="120" prop="code" label="验证码">
|
||||||
<div style="display:flex; with:100%;">
|
<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>
|
<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>
|
<view @tap="getCode" class="text-tips">{{ tips }}</view>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="btns">
|
<view class="btns">
|
||||||
<button type="primary" bindtap="getUserProfile" @click="getUserProfile()" class="btn-auth">使用微信授权</button>
|
<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>
|
</view>
|
||||||
</div>
|
</div>
|
||||||
</view>
|
</view>
|
||||||
|
@ -77,7 +77,7 @@ export default {
|
||||||
},
|
},
|
||||||
backToHome() {
|
backToHome() {
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url: `/pages/tabbar/home/index`
|
url: `/pages/tabbar/home/index`,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//获取用户信息
|
//获取用户信息
|
||||||
|
@ -236,7 +236,7 @@ text.shop {
|
||||||
.btn-auth {
|
.btn-auth {
|
||||||
width: 92%;
|
width: 92%;
|
||||||
margin: 0 auto 40rpx;
|
margin: 0 auto 40rpx;
|
||||||
// border-radius: 100px;
|
border-radius: 100px;
|
||||||
animation: mymove 5s infinite;
|
animation: mymove 5s infinite;
|
||||||
-webkit-animation: mymove 5s infinite; /*Safari and Chrome*/
|
-webkit-animation: mymove 5s infinite; /*Safari and Chrome*/
|
||||||
animation-direction: alternate; /*轮流反向播放动画。*/
|
animation-direction: alternate; /*轮流反向播放动画。*/
|
||||||
|
@ -247,8 +247,14 @@ text.shop {
|
||||||
-webkit-animation-timing-function: ease-in-out; /*动画的速度曲线*/
|
-webkit-animation-timing-function: ease-in-out; /*动画的速度曲线*/
|
||||||
}
|
}
|
||||||
.btn-callback {
|
.btn-callback {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 30rpx;
|
||||||
|
border: 1rpx solid #ededed;
|
||||||
|
height: 90rpx;
|
||||||
|
line-height: 90rpx;
|
||||||
|
border-radius: 100px;
|
||||||
width: 92%;
|
width: 92%;
|
||||||
margin: 0 auto 100rpx;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btns {
|
.btns {
|
||||||
|
|
|
@ -321,9 +321,8 @@ export default {
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
title: "请先登录!",
|
title: "请先登录!",
|
||||||
});
|
});
|
||||||
uni.redirectTo({
|
|
||||||
url: "/pages/passport/login",
|
this.$options.filters.navigateToLogin("redirectTo");
|
||||||
});
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
receiveCoupons(item.id).then((res) => {
|
receiveCoupons(item.id).then((res) => {
|
||||||
|
|
|
@ -129,7 +129,7 @@ export default {
|
||||||
userDetail() {
|
userDetail() {
|
||||||
this.userInfo.id
|
this.userInfo.id
|
||||||
? this.navigateTo("/pages/mine/set/personMsg")
|
? this.navigateTo("/pages/mine/set/personMsg")
|
||||||
: this.navigateTo("/pages/passport/login");
|
: this.$options.filters.navigateToLogin();;
|
||||||
},
|
},
|
||||||
async getUserOrderNum() {
|
async getUserOrderNum() {
|
||||||
uni.stopPullDownRefresh();
|
uni.stopPullDownRefresh();
|
||||||
|
|
|
@ -117,6 +117,27 @@ export function getPages(val) {
|
||||||
return val ? currentPage : url;
|
return val ? currentPage : url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到登录页面
|
||||||
|
*/
|
||||||
|
export function navigateToLogin(type = "navigateTo") {
|
||||||
|
/**
|
||||||
|
* 此处进行条件编译判断
|
||||||
|
* 微信小程序跳转到微信小程序登录页面
|
||||||
|
* H5/App跳转到普通登录页面
|
||||||
|
*/
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
uni[type]({
|
||||||
|
url: "/pages/passport/wechatMPLogin",
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
// #ifndef MP-WEIXIN
|
||||||
|
uni[type]({
|
||||||
|
url: "/pages/passport/login",
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务状态列表
|
* 服务状态列表
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -77,9 +77,17 @@ function cleanStorage() {
|
||||||
storage.setUuid("");
|
storage.setUuid("");
|
||||||
storage.setUserInfo({});
|
storage.setUserInfo({});
|
||||||
|
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/passport/wechatMPLogin",
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifndef MP-WEIXIN
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/passport/login",
|
url: "/pages/passport/login",
|
||||||
});
|
});
|
||||||
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
let http = new Request();
|
let http = new Request();
|
||||||
|
|
Loading…
Reference in New Issue