fix:更改数据存储方式

This commit is contained in:
Apple 2022-10-08 18:06:14 +08:00
parent b03a59eaa6
commit 7456a7ccd5
6 changed files with 55 additions and 55 deletions

View File

@ -286,9 +286,9 @@
created () {
this.getGoods();
let productConfig = JSON.parse(sessionStorage.getItem('product_list'));
document.title = sessionStorage.getItem('title');
this.isKey = sessionStorage.getItem('haskey');
let productConfig = JSON.parse(localStorage.getItem('product_list'));
document.title = localStorage.getItem('title');
this.isKey = localStorage.getItem('haskey');
this.describe = productConfig.describe;
this.viewConfig = productConfig
@ -331,13 +331,13 @@
//根据token获取商品信息
async getGoods () {
let self = this;
let showType = sessionStorage.getItem('showType');
let showType = localStorage.getItem('showType');
this.showType = showType;
let data = {
"last_product_id": sessionStorage.getItem('lastid') | 0,
"last_product_id": localStorage.getItem('lastid') | 0,
}
if (showType == 1) { //白名单
let tokenList = JSON.parse(sessionStorage.getItem('getTokenList'));
let tokenList = JSON.parse(localStorage.getItem('getTokenList'));
let goodsList = [];
for (item of tokenList) {
let goodsItem = [];
@ -355,7 +355,7 @@
this.popShow = true
if (res.code == -1) {
setTimeout(() => {
window.location.href = sessionStorage.getItem('white_link');
window.location.href = localStorage.getItem('white_link');
}, 3000);
}
}
@ -400,14 +400,14 @@
}
goodsArr.sort(objectArraySort('weight'))
self.swiperDataList = goodsArr;
sessionStorage.setItem('goodsCollection', JSON.stringify(goodsArr));
localStorage.setItem('goodsCollection', JSON.stringify(goodsArr));
self.goodsShow = goodsArr.length > 1;
sessionStorage.setItem('goodsCount', goodsArr.length);
localStorage.setItem('goodsCount', goodsArr.length);
if (goodsArr && goodsArr.length == 1 && goodsArr[0].available == 1) {
sessionStorage.setItem('goodsInfo', JSON.stringify(goodsArr[0]));
sessionStorage.setItem('key', goodsArr[0].key);
sessionStorage.setItem('token', goodsArr[0].token);
window.location.replace(goodsArr[0].type == 1 ? "./exchange.html" : "./index.html?id=" + sessionStorage.getItem('linkId'));
localStorage.setItem('goodsInfo', JSON.stringify(goodsArr[0]));
localStorage.setItem('key', goodsArr[0].key);
localStorage.setItem('token', goodsArr[0].token);
window.location.replace(goodsArr[0].type == 1 ? "./exchange.html" : "./index.html?id=" + localStorage.getItem('linkId'));
return false;
} else if (goodsArr && goodsArr.length >= 1) {
self.goodsNum = true;
@ -433,15 +433,15 @@
self.goodsNum = false;
}
} else { //兑换码
data.token = sessionStorage.getItem('token')
data.token = localStorage.getItem('token')
req.axiosPost('/key/products', data).then(res => {
if (res.code == 200) {
self.swiperDataList = res.data;
sessionStorage.setItem('goodsCollection', JSON.stringify(res.data));
sessionStorage.setItem('goodsCount', res.data.length);
localStorage.setItem('goodsCollection', JSON.stringify(res.data));
localStorage.setItem('goodsCount', res.data.length);
self.goodsShow = res.data.length > 1;
if (res.data && res.data.length == 1) {//单个商品直接进入详情页面
sessionStorage.setItem('goodsInfo', JSON.stringify(res.data[0]));
localStorage.setItem('goodsInfo', JSON.stringify(res.data[0]));
window.location.replace(res.data[0].type == 1 ? "./exchange.html" : "./reduce.html");
return false;
} else if (res.data && res.data.length >= 1) {
@ -471,14 +471,14 @@
this.popStatus = 3
this.popShow = true
if (res.code == -1) {
let haskey = sessionStorage.getItem('haskey');
let haskey = localStorage.getItem('haskey');
if (haskey) {
setTimeout(() => {
window.history.back();
}, 3000);
} else {
setTimeout(() => {
window.location.href = "./index.html?id=" + sessionStorage.getItem('linkId');
window.location.href = "./index.html?id=" + localStorage.getItem('linkId');
}, 3000);
}
}
@ -496,10 +496,10 @@
if (gstatus == 1) {
// 跳转商品详情页面
if (this.showType == 1) { //白名单
sessionStorage.setItem('token', row.token);
sessionStorage.setItem('key', row.key);
localStorage.setItem('token', row.token);
localStorage.setItem('key', row.key);
}
sessionStorage.setItem('goodsInfo', JSON.stringify(row));
localStorage.setItem('goodsInfo', JSON.stringify(row));
//type :1 兑换码 2:立减金
window.location.replace("./exchange.html");
} else {

View File

@ -217,14 +217,14 @@
},
created () {
document.title = sessionStorage.getItem('title');
let detailsConfig = JSON.parse(sessionStorage.getItem('product_detail'));
goodsCount = sessionStorage.getItem('goodsCount');
document.title = localStorage.getItem('title');
let detailsConfig = JSON.parse(localStorage.getItem('product_detail'));
goodsCount = localStorage.getItem('goodsCount');
this.backAble = goodsCount > 1;//多个商品才有返回
this.bgcolor = detailsConfig.button_color;
this.ftColor = detailsConfig.font_color;
this.describe = detailsConfig.describe;
goodsDetail = JSON.parse(sessionStorage.getItem('goodsInfo'));//商品详情
goodsDetail = JSON.parse(localStorage.getItem('goodsInfo'));//商品详情
this.goodsDetail = goodsDetail;//商品详情
let goodsInform = goodsDetail.entity; //商品信息
this.goodInfo = goodsInform;
@ -344,8 +344,8 @@
createdOrder (payType) {
let self = this;
let data = {
"token": sessionStorage.getItem('token'),
"key": sessionStorage.getItem('key'),
"token": localStorage.getItem('token'),
"key": localStorage.getItem('key'),
"code_batch_id": this.goodInfo.code_batch_id,
"goods_id": this.goodInfo.goods_id,
"account": this.account,
@ -365,7 +365,7 @@
}, 3000);
} else {
/*跳转起始页面*/
let entryLink = sessionStorage.getItem('entryLink');
let entryLink = localStorage.getItem('entryLink');
setTimeout(() => {
window.location.replace(entryLink);
}, 3000);

View File

@ -129,11 +129,11 @@
document.title = res.data.title;
self.plan_id = res.data.plan_id
this.pageType = res.data.page;
sessionStorage.setItem('title', res.data.title);
sessionStorage.setItem('product_list', JSON.stringify(res.data[this.typeList[res.data.page]].product_list));
sessionStorage.setItem('product_detail', JSON.stringify(res.data[this.typeList[res.data.page]].product_detail));
localStorage.setItem('title', res.data.title);
localStorage.setItem('product_list', JSON.stringify(res.data[this.typeList[res.data.page]].product_list));
localStorage.setItem('product_detail', JSON.stringify(res.data[this.typeList[res.data.page]].product_detail));
self.loading = false;
sessionStorage.setItem('linkId', linkId);
localStorage.setItem('linkId', linkId);
//是否携带token
if (keyCode) {
let data = {
@ -141,11 +141,11 @@
}
req.axiosPost('/key/loginFromLink', data).then(res => {
if (res.code == 200) {
sessionStorage.setItem('key', keyCode);
sessionStorage.setItem('token', res.data.token);
localStorage.setItem('key', keyCode);
localStorage.setItem('token', res.data.token);
sessionStorage.setItem('haskey', keyCode);
this.openDialog('正在加载商品...');
sessionStorage.setItem('entryLink', window.location.href);//存储起始页链接
localStorage.setItem('entryLink', window.location.href);//存储起始页链接
setTimeout(() => {
if (this.pageType === 4) {
window.location.href = './couponCollection.html';
@ -223,7 +223,7 @@
let data = {
"key": this.key,
"code": this.code,
"code_unique_str": sessionStorage.getItem('unique_str')
"code_unique_str": localStorage.getItem('unique_str')
}
req.axiosPost('/key/login', data).then(res => {
setTimeout(() => {
@ -231,10 +231,10 @@
}, 2000);
if (res.code == 200) {
sessionStorage.setItem('key', self.key);
sessionStorage.setItem('token', res.data.token);
localStorage.setItem('key', self.key);
localStorage.setItem('token', res.data.token);
this.openDialog('正在加载商品...');
sessionStorage.setItem('entryLink', window.location.href);//存储起始页链接
localStorage.setItem('entryLink', window.location.href);//存储起始页链接
setTimeout(() => {
if (this.pageType === 4) {
window.location.href = './couponCollection.html';
@ -258,10 +258,10 @@
self.disabledBtn = false;
}, 2000);
if (res.data.code == 200) {
sessionStorage.setItem('key', self.key);
sessionStorage.setItem('token', res.data.data);
sessionStorage.setItem('showType', 1);
sessionStorage.setItem('white_link', window.location.href);
localStorage.setItem('key', self.key);
localStorage.setItem('token', res.data.data);
localStorage.setItem('showType', 1);
localStorage.setItem('white_link', window.location.href);
let tokenArr = res.data.data;
let istoGoods = false;
for (item of tokenArr) {
@ -285,9 +285,9 @@
}).catch(err => { });
};
if (istoGoods) {
sessionStorage.setItem('getTokenList', JSON.stringify(getTokenList));
localStorage.setItem('getTokenList', JSON.stringify(getTokenList));
this.openDialog('正在加载商品...');
sessionStorage.setItem('entryLink', window.location.href);//存储起始页链接
localStorage.setItem('entryLink', window.location.href);//存储起始页链接
setTimeout(() => {
window.location.href = '../homepage.html';
}, 1000);

View File

@ -148,7 +148,7 @@
/* 请求数据 */
getCouponList () {
const key = sessionStorage.getItem('key')
const key = localStorage.getItem('key')
req.axiosGet('/key/coupon/list', {
key,
status: this.tabActive
@ -164,7 +164,7 @@
this.popShow = true
if (!this.popShow) {
/*跳转起始页面*/
let entryLink = sessionStorage.getItem('entryLink');
let entryLink = localStorage.getItem('entryLink');
setTimeout(() => {
window.location.replace(entryLink);
}, 3000);

View File

@ -106,7 +106,7 @@
created () {
this.getOrderList()
this.goodsCount = sessionStorage.getItem('goodsCount');
this.goodsCount = localStorage.getItem('goodsCount');
},
methods: {
@ -218,7 +218,7 @@
/* 请求订单数据 */
getOrderList () {
const key = sessionStorage.getItem('key')
const key = localStorage.getItem('key')
req.axiosGet(`/key/order/${key}`, { page: this.page, limit: this.limit }).then(({ data, code, message }) => {
if (code === -1) {
this.popFunction({ title: '温馨提示', text: message, status: 2, b_text: '我知道了', show: true })
@ -240,7 +240,7 @@
/*跳转起始页面*/
toPage () {
let entryLink = sessionStorage.getItem('entryLink');
let entryLink = localStorage.getItem('entryLink');
setTimeout(() => {
window.location.replace(entryLink);
}, 3000);

View File

@ -43,7 +43,7 @@
}
},
created () {
goodsCollection=JSON.parse(sessionStorage.getItem('goodsCollection'));
goodsCollection=JSON.parse(localStorage.getItem('goodsCollection'));
this.searchResult=goodsCollection;
},
mounted () {
@ -58,10 +58,10 @@
if (gstatus == 1) {
// 跳转商品详情页面
if (this.showType == 1) { //白名单
sessionStorage.setItem('token', row.token);
sessionStorage.setItem('key', row.key);
localStorage.setItem('token', row.token);
localStorage.setItem('key', row.key);
}
sessionStorage.setItem('goodsInfo', JSON.stringify(row));
localStorage.setItem('goodsInfo', JSON.stringify(row));
//type :1 兑换码 2:立减金
window.location.replace("./exchange.html");
}