Browse Source

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

master
Gaoxs 5 years ago
parent
commit
c60e5fb5fd
  1. 12
      main.js
  2. 51
      pages/Loading/index.vue
  3. 19
      pages/activity/DargainDetails/index.vue
  4. 24
      pages/shop/GoodsCon/index.vue
  5. 9
      store/index.js
  6. 34
      utils/index.js
  7. 11
      utils/store/cookie.js

12
main.js

@ -38,14 +38,6 @@ Vue.prototype.$validator = function (rule) {
return new schema(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 Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
Vue.prototype.$store = store Vue.prototype.$store = store
@ -128,7 +120,7 @@ import { isWeixin } from '@/utils'
const CACHE_KEY = "clear_0.0.1"; const CACHE_KEY = "clear_0.0.1";
if (!cookie.has(CACHE_KEY)) { if (!cookie.has(CACHE_KEY)) {
cookie.clearAll(); cookie.clearAll()
cookie.set(CACHE_KEY, 1); cookie.set(CACHE_KEY, 1);
} }
@ -146,7 +138,7 @@ if (urlSpread !== undefined) {
// #endif // #endif
async function init() { async function init() {
// #ifdef H5 // #ifdef H5

51
pages/Loading/index.vue

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

19
pages/activity/DargainDetails/index.vue

@ -1,10 +1,11 @@
<template> <template>
<view class="bargain on"> <view class="bargain on">
<!-- 在header上加 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="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"> <div class="bargain-header">
<view class="pictrue"> <view class="pictrue">
<image :src="bargainUserInfo.avatar" /> <image :src="bargainUserInfo.avatar" />
@ -305,7 +306,7 @@
} else { } else {
that.bargainPartake = parseInt(this.partake); that.bargainPartake = parseInt(this.partake);
} }
that.getBargainHelpCountStart(); that.getBargainHelpCountStart();
that.getBargainDetail(); that.getBargainDetail();
that.getBargainShare(0); that.getBargainShare(0);
@ -505,11 +506,17 @@
that.helpListStatus = res.data.length < that.limit; that.helpListStatus = res.data.length < that.limit;
that.helpListLoading = false; that.helpListLoading = false;
that.page++; that.page++;
that.bargainHelpList.push.apply(that.bargainHelpList, res.data); if (res.data) {
that.bargainHelpList.push.apply(that.bargainHelpList, res.data);
}
}) })
.catch(res => { .catch(err => {
console.log(err)
if(!err.msg){
return
}
uni.showToast({ uni.showToast({
title: res.msg, title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none", icon: "none",
duration: 2000 duration: 2000
}); });

24
pages/shop/GoodsCon/index.vue

@ -303,8 +303,15 @@
computed: mapGetters(["isLogin", "location"]), computed: mapGetters(["isLogin", "location"]),
mounted: function () { mounted: function () {
let url = handleQrCode(); let url = handleQrCode();
if (url && url.productId) { if (url && url.id) {
this.id = url.productId; 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 { } else {
this.id = this._route.query.id; this.id = this._route.query.id;
} }
@ -326,7 +333,8 @@
return { return {
title: this.storeInfo.storeName, title: this.storeInfo.storeName,
imageUrl: this.storeInfo.image, 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) { success(res) {
uni.showToast({ uni.showToast({
title: '分享成功' title: '分享成功'
@ -593,7 +601,7 @@
// //
ChangeAttr: function (res) { ChangeAttr: function (res) {
// //
let productSelect = this.productValue[res.value]; let productSelect = this.productValue[res.value];
if (productSelect) { if (productSelect) {
this.attr.productAttr[res.indexw].index = res.indexn; this.attr.productAttr[res.indexw].index = res.indexn;
@ -754,10 +762,10 @@
configAppMessage configAppMessage
) )
.then((res) => { .then((res) => {
}) })
.catch((res) => { .catch((res) => {
if (res.is_ready) { if (res.is_ready) {
res.wx.updateAppMessageShareData(configAppMessage); res.wx.updateAppMessageShareData(configAppMessage);
res.wx.updateTimelineShareData(configAppMessage); res.wx.updateTimelineShareData(configAppMessage);
@ -776,10 +784,10 @@
configAppMessage configAppMessage
) )
.then((res) => { .then((res) => {
}) })
.catch((res) => { .catch((res) => {
if (res.is_ready) { if (res.is_ready) {
res.wx.updateAppMessageShareData(configAppMessage); res.wx.updateAppMessageShareData(configAppMessage);
res.wx.updateTimelineShareData(configAppMessage); res.wx.updateTimelineShareData(configAppMessage);

9
store/index.js

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

34
utils/index.js

@ -218,6 +218,7 @@ export const login = () => {
reLaunch({ reLaunch({
path: '/pages' + redirect, path: '/pages' + redirect,
}); });
cookie.remove('redirect');
} else { } else {
reLaunch({ reLaunch({
path: '/pages/home/index', path: '/pages/home/index',
@ -226,38 +227,16 @@ export const login = () => {
}) })
.catch(() => { .catch(() => {
reject('当前运行环境为微信浏览器') reject('当前运行环境为微信浏览器')
location.replace("/pages/home/index"); reLaunch({
path: '/pages/home/index',
});
}); });
} else { } 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 return
} }
if (Vue.prototype.$deviceType == 'weixinh5') { if (Vue.prototype.$deviceType == 'weixinh5') {
console.log('当前运行环境为H5')
reject('当前运行环境为H5') reject('当前运行环境为H5')
return return
} }
@ -710,7 +689,8 @@ export const _router = {
push, push,
replace, replace,
go, go,
back back,
reLaunch
} }

11
utils/store/cookie.js

@ -29,7 +29,16 @@ function remove(key) {
} }
function clearAll() { 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) { function _has(key) {

Loading…
Cancel
Save