增加缓存代客下单商品以及布局信息
This commit is contained in:
parent
a1770d596a
commit
c19eb54d6d
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -198,9 +198,9 @@
|
|||
menuHeight: 0, // 左边菜单的高度
|
||||
menuItemHeight: 0, // 左边菜单item的高度
|
||||
itemId: '', // 栏目右边scroll-view用于滚动的id
|
||||
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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue