From 78068d49c20a8b90db902d955f558af507eb8b96 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期四, 11 四月 2024 16:06:12 +0800 Subject: [PATCH] 各页面添加骨架屏 --- packageBookService/pages/bookServices/list/index.js | 78 +++++++++++++++++++-------------------- 1 files changed, 38 insertions(+), 40 deletions(-) diff --git a/packageBookService/pages/bookServices/list/index.js b/packageBookService/pages/bookServices/list/index.js index 6f9dd50..f57e643 100644 --- a/packageBookService/pages/bookServices/list/index.js +++ b/packageBookService/pages/bookServices/list/index.js @@ -1,5 +1,4 @@ const app = getApp(); -import { loginInfo } from "../../../../assets/js/login"; Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� @@ -22,12 +21,7 @@ bookList: [], stairList: { value: "", - options: [ - { - value: "", - label: "涓�绾�", - }, - ], + options: [], }, secondList: { value: [], @@ -40,8 +34,7 @@ }, sortList: { value: "default", - options: [ - { + options: [{ value: "default", label: "榛樿鎺掑簭", }, @@ -84,6 +77,7 @@ disabledNewForms: false, triggered: false, backTop: "", + isshowLoading: true }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 @@ -127,13 +121,11 @@ if (options.secondCode) { this.setData({ secondCode: options.secondCode, - pathList: [ - { - Path: options.secondCode, - Type: "*", - StoreRefCode: app.config.goodsStore, - }, - ], + pathList: [{ + Path: options.secondCode, + Type: "*", + StoreRefCode: app.config.goodsStore, + }, ], }); } // 鑾峰彇浜岀骇鍒嗙被 @@ -172,6 +164,7 @@ triggered: true, }); this.setData({ + isshowLoading: false, "pageCount.page": 1, }); this.getBookList(this.data.path); @@ -187,6 +180,7 @@ this.setData({ isMore: true, "pageCount.page": this.data.pageCount.page + 1, + isshowLoading: false }); this.getBookList(this.data.path); } @@ -228,12 +222,10 @@ }, }; app.MG.store.getStoreChannelList(query).then(async (res) => { - const options = [ - { - value: "", - label: "涓�绾�", - }, - ]; + const options = [{ + value: "", + label: "涓�绾у垎绫�", + }, ]; for (let index = 0; index < res.datas.length; index++) { const item = res.datas[index]; options.push({ @@ -361,10 +353,15 @@ return false; } this.setData({ - loading: true, noData: false, isRequesting: true, + disabledSecondList: false }); + if (this.data.isshowLoading) { + this.setData({ + loading: true + }) + } let sort; let pathObj = {}; if (this.data.pathList.length) { @@ -426,12 +423,10 @@ } const query = { ...pathObj, - filterList: [ - { - value: "Normal", - field: "state", - }, - ], + filterList: [{ + value: "Normal", + field: "state", + }, ], sort, paging: { start: 0, @@ -446,6 +441,11 @@ }, }; app.MG.store.getProductList(query).then((res) => { + if (!res.datas.length && !this.data.pathList.length) { + this.setData({ + disabledSecondList: true + }) + } this.setData({ bookList: res.datas, isMore: null, @@ -453,6 +453,7 @@ "pageCount.total": res.total, loading: false, isRequesting: false, + isshowLoading: true }); if (!res.datas.length) { this.setData({ @@ -471,11 +472,9 @@ }, // 涓�绾у垎绫诲垏鎹� onChangeStair(e) { - const path = e.detail.value.length - ? `${this.data.assortCheck.code}\\${e.detail.value}` - : this.data.assortCheck.code; - console.log(this.data.path); - + const path = e.detail.value.length ? + `${this.data.assortCheck.code}\\${e.detail.value}` : + this.data.assortCheck.code; this.setData({ backTop: "#assort-title", pathList: [], @@ -483,8 +482,8 @@ secondCode: "", path: path, "stairList.value": e.detail.value, + disabledSecondList: false }); - if (e.detail.value == "") { this.setData({ disabledSecondList: true, @@ -493,7 +492,6 @@ this.getSecondList(path); } this.getBookList(path); - console.log(this.data.disabledSecondList); }, // 浜岀骇鍒嗙被鍒囨崲 onChangeSecond(e) { @@ -603,7 +601,9 @@ }, // 璺宠浆鍥句功璇︽儏 goDetail(e) { - const { book } = e.currentTarget.dataset; + const { + book + } = e.currentTarget.dataset; wx.navigateTo({ url: `/packageBookService/pages/bookServices/detail/index?id=${book.id}&name=${book.name}`, }); @@ -615,15 +615,13 @@ this.getBookList(this.data.path); }, openDropdown() { - console.log("灞曞紑鍝�"); this.setData({ showDropdown: true, }); }, closeDropdown() { - console.log("鍏抽棴"); this.setData({ showDropdown: false, }); }, -}); +}); \ No newline at end of file -- Gitblit v1.9.1