From 6ed604d1bcf85af60abe9cf745b1c378a807991f Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Fri, 10 Apr 2020 18:04:35 +0800 Subject: [PATCH] =?UTF-8?q?image=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/mall/order-info/index.js | 58 ++++++++++++++----------------- pages/mall/order-offer/index.wxml | 4 ++- pages/mall/order-offer/index.wxss | 8 +++++ pages/mall/search-list/index.wxml | 4 ++- pages/mall/search-list/index.wxss | 8 +++++ pages/mall/shops/index.js | 37 +++++++++++--------- pages/mall/shops/index.wxml | 19 +++++----- pages/mall/shops/index.wxss | 8 +++++ 8 files changed, 88 insertions(+), 58 deletions(-) diff --git a/pages/mall/order-info/index.js b/pages/mall/order-info/index.js index 78ed9f1..1fa152f 100644 --- a/pages/mall/order-info/index.js +++ b/pages/mall/order-info/index.js @@ -79,8 +79,8 @@ Page({ }); }, tagClick: function (e) { - var sukId = e.currentTarget.dataset.suk - var id = e.currentTarget.dataset.index + var sukId = e.currentTarget.dataset.suk// 对应的是一级列表的Id + var id = e.currentTarget.dataset.index// 对应的是二级列表的Id,相应是有价格计算的 var attributeList = this.data.orderInfo.attributeList for (let i = 0; i < attributeList.length; i++) { if (attributeList[i].id == sukId) { @@ -93,43 +93,35 @@ Page({ } } } - if (this.data.sukList.length == 0) { + this.setData({ + ['orderInfo.attributeList']: attributeList, + amount: null + }) + // 检查是否需要跟新,或者修改; + var push_flag = true + for (let index = 0; index < this.data.sukList.length; index++) { + const element = this.data.sukList[index]; + if (element.skuId == sukId) { + this.data.sukList[index].id = id + push_flag = false + break + } + } + if(push_flag){ this.data.sukList.push({ skuId: sukId, id: id }) - this.setData({ - ['orderInfo.attributeList']: attributeList - }) - } else { + } + if (this.data.sukList.length == this.data.orderInfo.attributeList.length) { + var match = {} for (let index = 0; index < this.data.sukList.length; index++) { const element = this.data.sukList[index]; - if (element.skuId == sukId) { - this.data.sukList[index].id = id - this.setData({ - ['orderInfo.attributeList']: attributeList - }) - return - } - } - this.data.sukList.push({ - skuId: sukId, - id: id - }) - this.setData({ - ['orderInfo.attributeList']: attributeList - }) - if (this.data.sukList.length == this.data.orderInfo.attributeList.length) { - var match = {} - for (let index = 0; index < this.data.sukList.length; index++) { - const element = this.data.sukList[index]; - match[element.skuId] = element.id - - } - this.data.skuJson = JSON.stringify(match) - this.data.skuJson = this.data.skuJson.substring(1, this.data.skuJson.length - 1) - this.onNumChange(null) + match[element.skuId] = element.id } + this.data.skuJson = JSON.stringify(match) + this.data.skuJson = this.data.skuJson.substring(1, this.data.skuJson.length - 1) + this.onNumChange(null) } }, // 数量变化的函数监听 @@ -152,6 +144,8 @@ Page({ this.data.form.unitPrice = Number(element.price) this.data.form.dividePrice = Number(element.dividePrice) this.data.form.skuId = element.id + console.log(element) + break } } // 如果查询到了价格,进行价格计算 diff --git a/pages/mall/order-offer/index.wxml b/pages/mall/order-offer/index.wxml index 59cec9c..e7f7784 100644 --- a/pages/mall/order-offer/index.wxml +++ b/pages/mall/order-offer/index.wxml @@ -28,7 +28,9 @@ - + + + {{form.name}} diff --git a/pages/mall/order-offer/index.wxss b/pages/mall/order-offer/index.wxss index 922f454..0e2bb31 100644 --- a/pages/mall/order-offer/index.wxss +++ b/pages/mall/order-offer/index.wxss @@ -74,4 +74,12 @@ button::after { border: none; +} + +.image-load { + width: 120rpx; + height: 120rpx; + display: flex; + align-items: center; + justify-content: center; } \ No newline at end of file diff --git a/pages/mall/search-list/index.wxml b/pages/mall/search-list/index.wxml index e533ec6..74c9c18 100644 --- a/pages/mall/search-list/index.wxml +++ b/pages/mall/search-list/index.wxml @@ -40,7 +40,9 @@ - + + + diff --git a/pages/mall/search-list/index.wxss b/pages/mall/search-list/index.wxss index 634c21f..f245c6e 100644 --- a/pages/mall/search-list/index.wxss +++ b/pages/mall/search-list/index.wxss @@ -84,3 +84,11 @@ color: rgba(153, 153, 153, 1); line-height: 14px; } + +.image-load { + width: 240rpx; + height: 240rpx; + display: flex; + align-items: center; + justify-content: center; +} diff --git a/pages/mall/shops/index.js b/pages/mall/shops/index.js index 847972d..f59893d 100644 --- a/pages/mall/shops/index.js +++ b/pages/mall/shops/index.js @@ -32,15 +32,16 @@ Page({ this.checkLogin() this.setData({ height: app.globalData.fragmentHeight, - CustomBar: app.globalData.CustomBar + CustomBar: app.globalData.CustomBar, + token: app.globalData.token }) event.on('EventMessage', this, this.onEvent) }, - + // 事件通知 onEvent: function (message) { - console.log('mall>>index>>onEvent', message) + console.log('shops>>index>>onEvent', message) if(message.what == 1 && util.isEmpty(this.data.token)){ - // this.setData({ token: app.globalData.token }) + this.setData({ token: app.globalData.token }) } }, /** @@ -48,33 +49,37 @@ Page({ */ onReady: function () { if (!this.data.firstShow) { - this.setData({ - token: app.globalData.token - }) this.fetchCheapList() this.fetchTaskList() } }, - + onRefreshList: function(){ + this.setData({ + cheapList: [], + taskList: [], + ['form.pageNum']: 1, + loading: true, + finished: false + }) + this.fetchCheapList() + this.fetchTaskList() + }, + // 获取特价列表 fetchCheapList: function () { request.get('/bxe-mall/product/cheapList').then(result => { //成功回调 this.setData({ loading: false, cheapList: result.data }) - }).catch(err => { //异常回调 this.setData({ loading: false }) util.showToast(err) }) }, - + // 获取团购列表 fetchTaskList: function () { if (this.data.requesting || this.data.finished) { return } - if (this.data.form.pageNum == 1 && this.data.taskList.length == 0) { - this.setData({ loading: true }) - } this.data.requesting = true // /product/cheapList特价产品列表 request.get('/bxe-mall/product/groupList', this.data.form).then(result => { @@ -98,20 +103,20 @@ Page({ util.showToast(err) }) }, - + // 进入搜索页 searchList: function (e) { wx.navigateTo({ url: '/pages/mall/search-list/index' }) }, - + // 查看团购Item lookGroupItem: function (e) { var item = this.data.taskList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] wx.navigateTo({ url: '/pages/mall/order-info/index?id=' + item.id }) }, - + // 查看特价Item lookCheapItem: function (e) { var item = this.data.cheapList[e.currentTarget.dataset.index] wx.navigateTo({ diff --git a/pages/mall/shops/index.wxml b/pages/mall/shops/index.wxml index 706c102..6d58f3e 100644 --- a/pages/mall/shops/index.wxml +++ b/pages/mall/shops/index.wxml @@ -96,10 +96,11 @@ 限时限量 售完即止 - - + + + + + {{item.name}} @@ -124,10 +125,12 @@ - - + + + + + + {{item.name}} diff --git a/pages/mall/shops/index.wxss b/pages/mall/shops/index.wxss index ffcf4b6..c6854dd 100644 --- a/pages/mall/shops/index.wxss +++ b/pages/mall/shops/index.wxss @@ -125,4 +125,12 @@ font-weight: 400; color: rgba(153, 153, 153, 1); line-height: 14px; +} + +.image-load { + width: 240rpx; + height: 240rpx; + display: flex; + align-items: center; + justify-content: center; } \ No newline at end of file