Browse Source

修复分销和商品详情无法生成关系的问题

master
Gaoxs 5 years ago
parent
commit
c60e5fb5fd
  1. 10
      main.js
  2. 43
      pages/Loading/index.vue
  3. 15
      pages/activity/DargainDetails/index.vue
  4. 14
      pages/shop/GoodsCon/index.vue
  5. 7
      store/index.js
  6. 34
      utils/index.js
  7. 11
      utils/store/cookie.js

10
main.js

@ -38,14 +38,6 @@ Vue.prototype.$validator = function (rule) {
return new schema(rule);
};
// const CACHE_KEY = "clear_0.0.1";
// if (!cookie.has(CACHE_KEY)) {
// cookie.clearAll();
// cookie.set(CACHE_KEY, 1);
// }
Vue.config.productionTip = false
App.mpType = 'app'
Vue.prototype.$store = store
@ -128,7 +120,7 @@ import { isWeixin } from '@/utils'
const CACHE_KEY = "clear_0.0.1";
if (!cookie.has(CACHE_KEY)) {
cookie.clearAll();
cookie.clearAll()
cookie.set(CACHE_KEY, 1);
}

43
pages/Loading/index.vue

@ -48,36 +48,20 @@
} else if (spread === 0 || typeof spread !== "number") {
cookie.set("spread", urlSpread || 0);
}
if (this.$store.getters.token) {
this.toLaunch();
return;
}
}
// cookie.get("spread");
// if (this.$deviceType == "weixin") {
// let path = parseQuery().path
// console.log(this)
// if (path) {
// this.$yrouter.push({
// path
// });
// } else {
// if (this.$deviceType == "app" || this.$deviceType == "weixinh5") {
// this.$yrouter.switchTab({
// path: "/pages/home/index"
// });
// return;
// }
// return
// }
// this.toLaunch();
if (this.$deviceType == "app" || this.$deviceType == "weixinh5") {
// this.toLaunch();
this.$yrouter.switchTab({
path: "/pages/home/index"
});
if (this.$store.getters.token) {
// token
console.log('登录状态存在,直接进页面')
this.toLaunch();
return;
}
console.log('进行登录操作')
login().finally(() => {
this.$yrouter.switchTab({
path: "/pages/home/index"
@ -89,9 +73,18 @@
toLaunch() {
console.log("loading home");
this.changeAuthorization(false);
this.$yrouter.switchTab({
path: "/pages/home/index"
let redirect = cookie.get('redirect')
if (redirect) {
redirect = redirect.split('/pages')[1]
this.$yrouter.replace({
path: '/pages' + redirect,
});
cookie.remove('redirect');
} else {
this.$yrouter.replace({
path: '/pages/home/index',
});
}
}
}
};

15
pages/activity/DargainDetails/index.vue

@ -1,10 +1,11 @@
<template>
<view class="bargain on">
<!-- 在header上加 on 为请求支援 -->
<view :class="[bargainPartake != userInfo.uid ? 'wrapper bargain-box on user' : 'wrapper bargain-box user']" v-if="bargainPartake != userInfo.uid">
<view :class="[bargainPartake != userInfo.uid ? 'wrapper bargain-box on user' : 'wrapper bargain-box user']"
v-if="bargainUserInfo && bargainPartake != userInfo.uid">
<!-- <view class="people">{{ lookCount }}人查看 {{ shareCount }}人分享 {{ userCount }}人参与</view> -->
<!-- 帮助砍价帮砍成功-->
<view class="pictxt acea-row row-center-wrapper " >
<view class="pictxt acea-row row-center-wrapper ">
<div class="bargain-header">
<view class="pictrue">
<image :src="bargainUserInfo.avatar" />
@ -505,11 +506,17 @@
that.helpListStatus = res.data.length < that.limit;
that.helpListLoading = false;
that.page++;
if (res.data) {
that.bargainHelpList.push.apply(that.bargainHelpList, res.data);
}
})
.catch(res => {
.catch(err => {
console.log(err)
if(!err.msg){
return
}
uni.showToast({
title: res.msg,
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});

14
pages/shop/GoodsCon/index.vue

@ -303,8 +303,15 @@
computed: mapGetters(["isLogin", "location"]),
mounted: function () {
let url = handleQrCode();
if (url && url.productId) {
this.id = url.productId;
if (url && url.id) {
this.id = url.id;
var spread = cookie.get("spread");
let urlSpread = parseInt(url.spread);
if (!Number.isNaN(urlSpread) && spread !== urlSpread) {
cookie.set("spread", urlSpread || 0);
} else if (spread === 0 || typeof spread !== "number") {
cookie.set("spread", urlSpread || 0);
}
} else {
this.id = this._route.query.id;
}
@ -326,7 +333,8 @@
return {
title: this.storeInfo.storeName,
imageUrl: this.storeInfo.image,
path: "pages/shop/GoodsCon/index?id=" + this.storeInfo.id + "&spread=" + uni.getStorageSync("uid")+"&pageType=good&codeType=routine",
path: "pages/shop/GoodsCon/index?id=" + this.storeInfo.id + "&spread=" + uni.getStorageSync("uid") +
"&pageType=good&codeType=routine",
success(res) {
uni.showToast({
title: '分享成功'

7
store/index.js

@ -39,14 +39,7 @@ const vuexStore = new Vuex.Store({
console.log('清除数据')
state.token = null;
state.userInfo = null
let spread = cookie.get('spread')
let redirect = cookie.get('redirect')
let outTime = setTimeout(() => {
clearTimeout(outTime)
cookie.clearAll()
cookie.set('redirect', redirect)
cookie.set('spread', spread)
}, 100)
},
backgroundColor(state, color) {
state.color = color;

34
utils/index.js

@ -218,6 +218,7 @@ export const login = () => {
reLaunch({
path: '/pages' + redirect,
});
cookie.remove('redirect');
} else {
reLaunch({
path: '/pages/home/index',
@ -226,38 +227,16 @@ export const login = () => {
})
.catch(() => {
reject('当前运行环境为微信浏览器')
location.replace("/pages/home/index");
reLaunch({
path: '/pages/home/index',
});
});
} else {
// wechat().then(() => oAuth());
}
// if (!code) {
// toAuth("wxc061dee8806ff712")
// } else {
// // wechat().then(() => oAuth().then((code) => {
// // // const { code } = parseQuery()
// // auth(code)
// // .then(() => {
// // // location.replace(
// // // decodeURIComponent(decodeURIComponent(this.$route.params.url))
// // // );
// // location.href = decodeURIComponent(
// // decodeURIComponent(this.$route.params.url)
// // );
// // })
// // .catch(() => {
// // reject('当前运行环境为微信浏览器')
// // location.replace("/pages/home/index");
// // });
// // })).catch(error => {
// // console.log(error)
// // reject('自动登录失败')
// // });
// }
return
}
if (Vue.prototype.$deviceType == 'weixinh5') {
console.log('当前运行环境为H5')
reject('当前运行环境为H5')
return
}
@ -710,7 +689,8 @@ export const _router = {
push,
replace,
go,
back
back,
reLaunch
}

11
utils/store/cookie.js

@ -29,7 +29,16 @@ function remove(key) {
}
function clearAll() {
uni.clearStorage()
const res = uni.getStorageInfoSync();
res.keys.map((item) => {
if (item == 'redirect' || item == 'spread') {
return
}
remove(item)
})
console.log(res)
// debugger
// uni.clearStorageSync()
}
function _has(key) {

Loading…
Cancel
Save