diff --git a/commons/utils/storageManage.js b/commons/utils/storageManage.js index 1f573e7..27c5fdd 100644 --- a/commons/utils/storageManage.js +++ b/commons/utils/storageManage.js @@ -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" diff --git a/http/yskApi/Instead.js b/http/yskApi/Instead.js index 2b6731a..3221307 100644 --- a/http/yskApi/Instead.js +++ b/http/yskApi/Instead.js @@ -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 }); } diff --git a/http/yskApi/http.js b/http/yskApi/http.js index 3504d16..d06ec34 100644 --- a/http/yskApi/http.js +++ b/http/yskApi/http.js @@ -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({ diff --git a/pagesCreateOrder/index/index.vue b/pagesCreateOrder/index/index.vue index 53dc8da..4dd08f6 100644 --- a/pagesCreateOrder/index/index.vue +++ b/pagesCreateOrder/index/index.vue @@ -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() })