Browse Source

no message

featrue/v4.5
xpz2018 4 years ago
parent
commit
b8ad776152
2 changed files with 28 additions and 44 deletions
  1. 58
      pages/mall/fragment/index.js
  2. 14
      pages/mall/fragment/index.wxml

58
pages/mall/fragment/index.js

@ -2,8 +2,10 @@
import { getFactoryPrice, getBannerList } from "../../../api/ztb"
import { getPreferList } from "../../../api/moment"
const event = require('../../../utils/event')
const storage = require('../../../utils/storage')
const util = require('../../../utils/util')
const app = getApp()
var form = {}
Component({
options: {
@ -21,19 +23,14 @@ Component({
*/
data: {
height: app.globalData.safeFragmentHeight - 100,
kg: app.globalData.kg,
firstShow: false,
banning: true,
bannerList: [],
momentList: [],
tabList: [ '黄纸', '白纸', '灰纸', '杂纸' ],
tabIndex: 0,
loading: true,
requesting: false,
finished: false,
form: { pageNum: 1 },
orderList: [1],
show: false,
orderList: [],
popover: false,
sortList: [
{sort: 1, text: '更新时间'},
{sort: 2, text: '价格升序'},
@ -57,7 +54,6 @@ Component({
if(!this.data.firstShow){
this.setData({
height: app.globalData.safeFragmentHeight - 100,
kg: app.globalData.kg,
StatusBar: app.globalData.StatusBar || 40,
customHeight: app.globalData.customHeight,
CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 80),
@ -69,25 +65,23 @@ Component({
this.fetchAgentList()
}
this.data.firstShow = true
var bannerstring = storage.get('ztb-banner-list')
if(!util.isEmpty(bannerstring)){
this.setData({ bannerList: JSON.parse(bannerstring) })
}
if(!this.data.bannerList.length){
getBannerList(1).then(result => {
this.setData({ bannerList: result.data })
}).catch(err => {
storage.put('ztb-banner-list', JSON.stringify(result.data))
})
}
},
onEvent: function (message) {
console.log('mall>>fragment>>onEvent', message)
if (message.what == 10 && app.globalData.isVIP == 1) {
// this.setData({ token: app.globalData.token })
// this.onRefreshList()
} else if(message.what == 1001){
this.setData({ kg: app.globalData.kg })
} else if(message.what == 888){
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false })
if(message.what == 888){
this.fetchAgentList()
} else if(message.what == 444){
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false, cityName: app.nowCity.cityName })
this.setData({ cityName: app.nowCity.cityName })
this.fetchAgentList()
}
},
@ -125,45 +119,37 @@ Component({
if(this.data.tabIndex == Number(detail.index)){
return
}
form.cateId = Number(detail.index)
this.fetchAgentList()
},
topBubble: function(e){
if(this.data.sortIndex == Number(e.currentTarget.dataset.index)){
this.setData({ show: !this.data.show })
this.setData({ popover: !this.data.popover })
return
}
if(!util.isEmpty(e.currentTarget.dataset.index)){
this.data.sortIndex = Number(e.currentTarget.dataset.index)
if(this.data.show){
if(this.data.popover){
form.sort = this.data.sortIndex
this.fetchAgentList()
}
}
this.setData({ show: !this.data.show, sortIndex: this.data.sortIndex })
this.setData({ popover: !this.data.popover, sortIndex: this.data.sortIndex })
},
//*************************************************fetchAgentList************************************************//
// 获取特价列表
fetchAgentList: function () {
if (this.data.requesting || this.data.finished) {
if (this.data.requesting) {
return
}
if (this.data.loading) {
this.data.requesting = true
} else {
this.setData({ requesting: true })
}
getFactoryPrice(this.data.form).then(result => {
this.setData({ requesting: true, orderList: [] })
getFactoryPrice(form).then(result => {
if (result.data.records.length) {
var respList = result.data.records
let nowList = `orderList[${this.data.orderList.length}]`
var num = result.data.current
var finished = result.data.current >= result.data.pages
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false })
this.setData({ orderList: result.data.records, requesting: false })
} else {
this.setData({ requesting: false, finished: true, loading: false })
this.setData({ requesting: false })
}
}).catch(err => {
//异常回调
this.setData({ requesting: false, finished: true, loading: false })
this.setData({ requesting: false })
})
}
}

14
pages/mall/fragment/index.wxml

@ -64,7 +64,7 @@
<text class="text-gray">排序</text>
<text class="cuIcon-triangledownfill" style="font-size:48rpx;padding-top: 4rpx;color: #ccc;"></text>
</view>
<bubble-popup show="{{show}}" mask="{{true}}" position="absolute" direction="top"
<bubble-popup show="{{popover}}" mask="{{true}}" position="absolute" direction="top"
width="240rpx" right="-18rpx" top="430rpx" translateY="-100%" triangleRight="30rpx" triangleTop="-22rpx" bind:close="topBubble">
<view wx:for="{{sortList}}" wx:key="index" class="tui-menu-item" data-index="{{index}}" catchtap="topBubble" style="color:{{index == sortIndex ? '#008AFF': '#555555' }}" id="taps">{{item.text}}</view>
</bubble-popup>
@ -79,15 +79,13 @@
<wux-skeleton-paragraph rounded rows="20" wux-class="case3-class" />
</view>
</wux-skeleton>
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex">
<view wx:for="{{pageItem}}" wx:key="index">
<view class="bg-white" style="padding: 0rpx 32rpx" wx:if="{{pageIndex != 0 || index != 0 }}">
<wux-divider show-text="{{ false }}"></wux-divider>
</view>
<information-item item="{{item}}"></information-item>
<view wx:for="{{orderList}}" wx:key="index">
<view class="bg-white" style="padding: 0rpx 32rpx" wx:if="{{index != 0 }}">
<wux-divider show-text="{{ false }}"></wux-divider>
</view>
<information-item item="{{item}}"></information-item>
</view>
<view class="flex flex-center" style="padding: 24rpx;">
<view class="flex flex-center" style="padding: 24rpx;" wx:if="{{orderList.length}}">
<wux-button id="moment" outline type="stable" size="small" bind:click="gridTap">查看更多行情</wux-button>
</view>
Loading…
Cancel
Save