增加缓存代客下单商品以及布局信息

This commit is contained in:
YeMingfei666 2024-10-24 11:26:42 +08:00
parent a1770d596a
commit c19eb54d6d
4 changed files with 40 additions and 15 deletions

View File

@ -147,6 +147,27 @@ const model = {
return appCache.cacheGoods
}
},
// 缓存代客下单商品节点信息缓存
cacheGoodsNode: (val, isDelete = false) => {
if (isDelete) {
appCache.cacheGoodsNode = ""
return uni.removeStorageSync('cacheGoodsNode')
}
if (val) {
// 有值,为放置
appCache.cacheGoodsNode = val
uni.setStorageSync('cacheGoodsNode', val)
} else {
// 否则为获取
if (!appCache.cacheGoodsNode) {
//缓存取不到,获取应用本地信息
appCache.cacheGoodsNode = uni.getStorageSync('cacheGoodsNode')
}
return appCache.cacheGoodsNode
}
},
// 已经登录的用户记录
loggedInUser: (addUserName = null, removeUserName = null) => {
let key = "loggedInUserList"

View File

@ -38,14 +38,15 @@ export function getCart(params) {
* 已上架商品列表
* @returns
*/
export function getGoodsLists(params) {
export function getGoodsLists(params,showLoading=true) {
return request({
url: `/api/place/activate`,
method: "get",
params:{
shopId: uni.getStorageSync("shopId"),
...params
}
},
showLoading
});
}

View File

@ -183,7 +183,7 @@ function request(args) {
} = args
let headerObject = {}
// headerObject[appConfig.tokenKey] = storageManage.token()
console.log(showLoading);
return commonsProcess(showLoading, () => {
return uni.request(
Object.assign({

View File

@ -198,9 +198,9 @@
menuHeight: 0, //
menuItemHeight: 0, // item
itemId: '', // scroll-viewid
tabbar: [],
tabbar: storageManage.cacheGoods()||[],
menuItemPos: [],
arr: [],
arr: storageManage.cacheGoodsNode()||[],//
scrollRightTop: 0, // scroll-view
timer: null, //
topZhanwei: 136 + 24,
@ -288,6 +288,7 @@
})
data.tabbar = tabbar
storageManage.cacheGoods(data.tabbar)
getMenuItemTop()
}
@ -302,10 +303,10 @@
//
function getGoods(par = {
page: 0,
size: 300,
showLoading:data.tabbar.length<=0?true:false
size: 300
}) {
return Api.getGoodsLists(par)
const showLoading=data.tabbar.length<=0?true:false
return Api.getGoodsLists(par,showLoading)
}
//
async function getCart(par = {
@ -399,12 +400,14 @@
//
async function getTableInfo() {
const res = await $table.get({
qrcode: data.table.tableId
})
console.log(res);
if (res && res.content[0]) {
// data.table=res.content[0]
if(data.table.tableId){
const res = await $table.get({
qrcode: data.table.tableId
})
console.log(res);
if (res && res.content[0]) {
// data.table=res.content[0]
}
}
}
let $originGoods = []
@ -965,6 +968,7 @@
rects.forEach((rect) => {
// rects[0].top()
data.arr.push(rect.top - rects[0].top);
storageManage.cacheGoodsNode(data.arr)
resolve();
})
}).exec()
@ -1089,7 +1093,6 @@
// go.back()
// }, 1500)
// }
data.tabbar=storageManage.cacheGoods()
init()
})
</script>