fix: 修改存储方式

This commit is contained in:
zhangds 2024-04-25 11:53:31 +08:00
parent d00cece43b
commit 39be65d49d
2 changed files with 13 additions and 13 deletions

View File

@ -297,7 +297,7 @@
},
//根据token获取商品信息
async getGoods() {
sessionStorage.setItem('backShow', '');
localStorage.setItem('backShow', '');
let self = this;
let showType = localStorage.getItem('showType');
this.showType = showType;
@ -369,9 +369,9 @@
goodsArr.sort(objectArraySort('weight'));
self.swiperDataList = this.convertData(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]));
localStorage.setItem('goodsInfo', JSON.stringify(goodsArr[0]));
localStorage.setItem('key', goodsArr[0].key);
localStorage.setItem('token', goodsArr[0].token);
this.toPage(goodsArr[0]);
@ -410,13 +410,13 @@
req.axiosPost('/key/products', data).then(res => {
if (res.code == 200) {
self.swiperDataList = this.convertData(res.data);
sessionStorage.setItem('goodsCount', res.data.length);
localStorage.setItem('goodsCount', res.data.length);
self.goodsShow = res.data.length > 1;
if (res.data && res.data.length == 1) {//单个商品直接进入详情页面
const product = res.data[0];
/* 满足3个条件进入此判断 仅兑换一次 在线查看卡密商品 则卡密页面不能返回 */
if (product.restrict == 1 && product.type == 1 && product.entity.card_show == 2 && product.entity.product_type == 2) {
sessionStorage.setItem('backShow', 1);
localStorage.setItem('backShow', 1);
}
/* 满足3个条件进入此判断 仅兑换一次 已兑换 在线查看卡密商品 */
this.isToLook = product.exchange == 1 && product.restrict == 1 && product.type == 1 && product.entity.card_show == 2 && product.entity.product_type == 2;
@ -429,12 +429,12 @@
})
.then(({ data, code, }) => {
if (code === 200) {
sessionStorage.setItem('orderNumber', data[0].order_number);
localStorage.setItem('orderNumber', data[0].order_number);
window.location.replace('/orderDetails/cardOrder.html');
}
});
} else {
sessionStorage.setItem('goodsInfo', JSON.stringify(product));
localStorage.setItem('goodsInfo', JSON.stringify(product));
this.toPage(product);
return false;
}
@ -516,7 +516,7 @@
localStorage.setItem('token', row.token);
localStorage.setItem('key', row.key);
}
sessionStorage.setItem('goodsInfo', JSON.stringify(row));
localStorage.setItem('goodsInfo', JSON.stringify(row));
this.toPage(row);
} else {
this.maskshow = true;

View File

@ -175,7 +175,7 @@
created() {
document.title = localStorage.getItem('title');
/* 获取立减金信息*/
goodsDetail = JSON.parse(sessionStorage.getItem("goodsInfo"));
goodsDetail = JSON.parse(localStorage.getItem("goodsInfo"));
this.goodInfo = goodsDetail;
console.log(this.goodInfo)
/*默认显示*/
@ -183,7 +183,7 @@
// this.openErrorDialog(product_status(goodsDetail.available, goodsDetail));
// this.bindClick = true;
// }
goodsCount = sessionStorage.getItem('goodsCount') ? Number(sessionStorage.getItem('goodsCount')) : 0;
goodsCount = localStorage.getItem('goodsCount') ? Number(localStorage.getItem('goodsCount')) : 0;
this.backAble = goodsCount > 1;//多个商品才有返回
this.reduceInfo = goodsDetail.entity;
this.plaflam = goodsDetail.entity.channel;
@ -193,7 +193,7 @@
this.receive_time = goodsDetail.entity.time_limit;
/* 倒计时 */
const key_expiration_time = sessionStorage.getItem('key_expiration_time');
const key_expiration_time = localStorage.getItem('key_expiration_time');
if (key_expiration_time != 0) {
const cls = setInterval(() => {
const time = pageOutTime(key_expiration_time);
@ -251,7 +251,7 @@
req.axiosPost("/key/usage", data)
.then((res) => {
if (res.code == 200) {
sessionStorage.setItem("lastid", self.goodInfo.product_id);
localStorage.setItem("lastid", self.goodInfo.product_id);
this.orderId = res.data.order_number;
const ua = navigator.userAgent.toLowerCase();
// 第一步:是否是微信环境 -> 公众号授权
@ -294,7 +294,7 @@
if (res.code == 200) {
this.openErrorDialog('领取成功');
this.goodInfo.available = 9;
sessionStorage.setItem('goodInfo', JSON.stringify(this.goodInfo));
localStorage.setItem('goodInfo', JSON.stringify(this.goodInfo));
} else {
this.openErrorDialog(res.message);
}