diff --git a/components/CouponWindow.vue b/components/CouponWindow.vue index 2517467..94ae022 100644 --- a/components/CouponWindow.vue +++ b/components/CouponWindow.vue @@ -29,7 +29,7 @@ import { mapGetters } from "vuex"; - import toLogin from "@/libs/login"; + import {handleLoginFailure} from "@/utils"; import { couponReceiveBatch } from "@/api/user"; @@ -52,7 +52,7 @@ methods: { checked() { const isLogin = this.isLogin; - if (!isLogin) return toLogin(); + if (!isLogin) return handleLoginFailure(); const ids = this.couponList.reduce((initial, coupon) => { initial.push(coupon.id); diff --git a/libs/login.js b/libs/login.js deleted file mode 100644 index e7c681a..0000000 --- a/libs/login.js +++ /dev/null @@ -1,52 +0,0 @@ -// import router from "../router"; -import store from "../store"; -import cookie from "@/utils/store/cookie"; -import { - isWeixin, - login, - replaceLogin, - getCurrentPageUrl, - getCurrentPageUrlWithArgs, - parseQuery, - replace, - handleQrCode -} from "@/utils"; - -export default function toLogin(push, backUrl) { - console.log('token失效,需要重新登录') - store.commit("LOGOUT"); - // 如果没有授权,走登录的接口重新授权 - // 授权获取失败会跳转到授权的接口 - console.log(store.getters.isAuthorization, '是否有登陆权限') - if (store.getters.isAuthorization) { - login() - return - } - console.log(store.getters.isAuthorizationPage, '判断是不是登录页面或者授权页面') - // 判断当前是不是已经在登录页面或者授权页,防止二次跳转 - if (store.getters.isAuthorizationPage || getCurrentPageUrl() == '/pages/user/Login/index') { - console.log('已经是登录页面或者授权页面,跳出方法') - return - } - - // 判断是不是扫描的砍价海报进来的 - if (getCurrentPageUrl() == 'pages/activity/DargainDetails/index' && handleQrCode()) { - console.log('是扫描的砍价海报进来的') - let url = handleQrCode(); - if (url) { - replaceLogin({ - redirect: `/${getCurrentPageUrl()}`, - id: url.bargainId, - partake: url.uid - }) - } else { - console.log('是扫描的砍价海报进来的,但是没有获取到参数') - replaceLogin() - } - } else { - console.log('无特殊情况,重新登录') - replaceLogin() - } - store.commit("UPDATE_AUTHORIZATION", false); - store.commit("UPDATE_AUTHORIZATIONPAGE", true); -} diff --git a/pages/Loading/index.vue b/pages/Loading/index.vue index 943f58f..42dc004 100644 --- a/pages/Loading/index.vue +++ b/pages/Loading/index.vue @@ -43,22 +43,23 @@ export default { } cookie.get("spread"); // this.toLaunch(); - if (this.$deviceType == 'app') { - // this.toLaunch(); - this.$yrouter.switchTab({ - path: '/pages/home/index', - }); - return + if (this.$deviceType == "app") { + // this.toLaunch(); + this.$yrouter.switchTab({ + path: "/pages/home/index" + }); + return; } - login({ - fail: () => { - this.toLaunch(); - } + login().finally(() => { + this.$yrouter.switchTab({ + path: "/pages/home/index" + }); }); }, methods: { ...mapActions(["changeAuthorization", "setUserInfo"]), toLaunch() { + console.log("loading home"); this.changeAuthorization(false); this.$yrouter.switchTab({ path: "/pages/home/index" diff --git a/pages/authorization/index.vue b/pages/authorization/index.vue index 880dc6d..29b8989 100644 --- a/pages/authorization/index.vue +++ b/pages/authorization/index.vue @@ -1,211 +1,255 @@ diff --git a/pages/order/MyOrder/index.vue b/pages/order/MyOrder/index.vue index f6a233f..2895e56 100644 --- a/pages/order/MyOrder/index.vue +++ b/pages/order/MyOrder/index.vue @@ -199,17 +199,19 @@ export default { DataFormat }, computed: mapGetters(["userInfo"]), - watch: { - $yroute(n) { - if (n.name === NAME) { - const type = parseInt(this.$yroute.query.type) || 0; - if (this.type !== type) { - this.changeType(type); - } - this.getOrderData(); - } - }, - type() {} + onShow: function() { + console.log(this) + this.type = parseInt(this.$yroute.query.type) || 0; + this.changeType(this.type); + this.getOrderData(); + this.getOrderList(); + }, + onHide: function() { + this.orderList = []; + this.page = 1; + this.limit = 20; + this.loaded = false; + this.loading = false; }, methods: { goLogistics(order) { @@ -308,11 +310,7 @@ export default { }, toPay() {} }, - mounted() { - this.type = parseInt(this.$yroute.query.type) || 0; - this.getOrderData(); - this.getOrderList(); - }, + mounted() {}, onReachBottom() { !this.loading && this.getOrderList(); } @@ -320,7 +318,6 @@ export default {