diff --git a/pages/formate.wxs b/pages/formate.wxs index 117d58e..753a868 100644 --- a/pages/formate.wxs +++ b/pages/formate.wxs @@ -102,7 +102,22 @@ function formateDescripe(value) { } return '- -' } - +function formatePrice3(value, kg) { + if(isEmpty(value)){ + return '' + } + if (value || value !== 0) { + if(value < 0){ + value = -value + } + if(kg){ + return (parseFloat(value)).toFixed(3) + } else { + return (parseFloat(value) * 1000).toFixed(0) + } + } + return '' +} module.exports = { numberFormat: numberFormat, //暴露接口调用 numberFormat2: numberFormat2, //暴露接口调用 @@ -113,6 +128,7 @@ module.exports = { formateAmount: formateAmount, formatePrice: formatePrice, formatePrice2: formatePrice2, + formatePrice3: formatePrice3, substring: substring, forWeight: forWeight, formateDrice: formateDrice, diff --git a/pages/mall/fragment/index.js b/pages/mall/fragment/index.js index 6057abd..bc70083 100644 --- a/pages/mall/fragment/index.js +++ b/pages/mall/fragment/index.js @@ -5,7 +5,6 @@ const event = require('../../../utils/event') const storage = require('../../../utils/storage') const util = require('../../../utils/util') const app = getApp() -var form = {sortBy: 0, pageNum: 1, pageSize: 10, categoryId: '', cityId: ''} var typeList = [] Component({ @@ -30,6 +29,7 @@ Component({ tabList: [], tabIndex: 0, requesting: true, + form : {sortBy: 0, pageNum: 1, pageSize: 10, categoryId: '', cityId: ''}, orderList: [], popover: false, sortList: [ @@ -57,13 +57,14 @@ Component({ getPreferList().then(result => { this.setData({ momentList: result.data.records.slice(0, 3) }) }) + typeList = [] getCategoryType().then(result => { typeList = result.data var tabList = [] for (let index = 0; index < typeList.length; index++) { tabList.push(typeList[index].categoryName) } - form.categoryId = typeList[0].categoryId + this.data.form.categoryId = typeList[0].categoryId this.setData({ tabList }) }) } @@ -76,7 +77,7 @@ Component({ if(!this.data.bannerList.length){ getBannerList(1).then(result => { this.setData({ bannerList: result.data }) - storage.put('ztb-banner-list', JSON.stringify(result.data)) + storage.put('ztb-banner-list', JSON.stringify(result.data), 43200) }) } }, @@ -87,10 +88,9 @@ Component({ console.log('mall>>fragment>>onEvent', message) if(message.what == 888 && app.globalData.userInfo){ this.initLogin() - this.fetchAgentList() } else if(message.what == 444){ - form.cityId = app.nowCity.cityCode - this.setData({ cityName: app.nowCity.cityName }) + this.data.form.cityId = app.nowCity.cityCode + this.setData({ cityName: app.nowCity.cityName, ['form.cityId']: app.nowCity.cityCode }) this.fetchAgentList() } }, @@ -100,6 +100,7 @@ Component({ this.setData({ messageNumber: result.data.messageNumber + result.data.notificationNumber }) }) } + this.fetchAgentList() }, postInfo: function(e){ var item = this.data.momentList[e.currentTarget.dataset.index] @@ -123,6 +124,10 @@ Component({ util.navigateTo('/pages/html/message/index') } else if(e.currentTarget.id == 'search'){ wx.navigateTo({url: `/pages/mall/search-list/index?tab=1` }) + } else if(e.currentTarget.id == 'empty'){ + if(this.data.tabList.length && !this.data.form.cityId.length){ + wx.navigateTo({url: `/pages/home/city-select/index?type=1` }) + } } }, tapBanner: function(e){ @@ -138,7 +143,7 @@ Component({ return } this.data.tabIndex = Number(detail.index) - form.categoryId = typeList[Number(detail.index)].categoryId + this.data.form.categoryId = typeList[Number(detail.index)].categoryId this.fetchAgentList() }, topBubble: function(e){ @@ -149,7 +154,7 @@ Component({ if(!util.isEmpty(e.currentTarget.dataset.index)){ this.data.sortIndex = Number(e.currentTarget.dataset.index) if(this.data.popover){ - form.sortBy = this.data.sortIndex + this.data.form.sortBy = this.data.sortIndex this.fetchAgentList() } } @@ -157,11 +162,19 @@ Component({ }, //*************************************************fetchAgentList************************************************// fetchAgentList: function () { - if(util.isEmpty(form.categoryId)){ + if(util.isEmpty(this.data.form.categoryId)){ + this.setData({ requesting: false, orderList: [] }) + return + } + if(util.isEmpty(this.data.form.cityId)){ + this.setData({ requesting: false, orderList: [], ['form.cityId']: '' }) + return + } + if(this.data.requesting){ return } this.setData({ requesting: true, orderList: [] }) - getMomentList(form).then(result => { + getMomentList(this.data.form).then(result => { if (result.data.records.length) { this.setData({ orderList: result.data.records, requesting: false }) } else { diff --git a/pages/mall/fragment/index.wxml b/pages/mall/fragment/index.wxml index 508cc83..16e93f2 100644 --- a/pages/mall/fragment/index.wxml +++ b/pages/mall/fragment/index.wxml @@ -95,9 +95,9 @@ - + - 暂无数据 + {{(!form.cityId && tabList.length) ? '暂无定位城市,请选择一个所在城市' : '暂无数据'}} 查看更多行情 diff --git a/pages/ztbvip/index.wxml b/pages/ztbvip/index.wxml index 3c4403c..b69cf80 100644 --- a/pages/ztbvip/index.wxml +++ b/pages/ztbvip/index.wxml @@ -36,7 +36,7 @@ - {{item.days}}{{item.title}} + {{item.title}} {{item.realPrice}} 原价:¥{{item.bidPrice}} diff --git a/submodel/pages/goods/product-item/index.wxml b/submodel/pages/goods/product-item/index.wxml index e80b8d3..2623bf4 100644 --- a/submodel/pages/goods/product-item/index.wxml +++ b/submodel/pages/goods/product-item/index.wxml @@ -15,10 +15,11 @@ 起拍单价 - ¥{{formate.formatePrice(item.unitPrice, kg)}} - {{ kg? '元/KG' : '元/吨' }} - - 价格面议 + + ¥{{formate.formatePrice3(item.unitPrice, kg)}} + {{ kg? '元/KG' : '元/吨' }} + + 价格面议 {{item.description || ''}} diff --git a/submodel/pages/paper/detail/index.wxml b/submodel/pages/paper/detail/index.wxml index 6b63ee5..171cd65 100644 --- a/submodel/pages/paper/detail/index.wxml +++ b/submodel/pages/paper/detail/index.wxml @@ -37,13 +37,12 @@ - - ¥{{ formate.formatePrice(orderInfo.unitPrice, kg) }} + + ¥{{ formate.formatePrice3(orderInfo.unitPrice, kg) }} {{ kg? '元/KG' : '元/吨' }} - 价格面议 + wx:if="{{formate.formatePrice3(orderInfo.unitPrice, kg)!=''}}">{{ kg? '元/KG' : '元/吨' }} + 价格面议 {{orderInfo.secondCategoryName}} @@ -138,7 +137,7 @@ ¥{{amount}} - 立即购买 + 立即购买 {{offered?'修改':'立即'}}报价