|
|
@ -5,7 +5,6 @@ const event = require('../../../utils/event') |
|
|
const storage = require('../../../utils/storage') |
|
|
const storage = require('../../../utils/storage') |
|
|
const util = require('../../../utils/util') |
|
|
const util = require('../../../utils/util') |
|
|
const app = getApp() |
|
|
const app = getApp() |
|
|
var form = {sortBy: 0, pageNum: 1, pageSize: 10, categoryId: '', cityId: ''} |
|
|
|
|
|
var typeList = [] |
|
|
var typeList = [] |
|
|
|
|
|
|
|
|
Component({ |
|
|
Component({ |
|
|
@ -30,6 +29,7 @@ Component({ |
|
|
tabList: [], |
|
|
tabList: [], |
|
|
tabIndex: 0, |
|
|
tabIndex: 0, |
|
|
requesting: true, |
|
|
requesting: true, |
|
|
|
|
|
form : {sortBy: 0, pageNum: 1, pageSize: 10, categoryId: '', cityId: ''}, |
|
|
orderList: [], |
|
|
orderList: [], |
|
|
popover: false, |
|
|
popover: false, |
|
|
sortList: [ |
|
|
sortList: [ |
|
|
@ -57,13 +57,14 @@ Component({ |
|
|
getPreferList().then(result => { |
|
|
getPreferList().then(result => { |
|
|
this.setData({ momentList: result.data.records.slice(0, 3) }) |
|
|
this.setData({ momentList: result.data.records.slice(0, 3) }) |
|
|
}) |
|
|
}) |
|
|
|
|
|
typeList = [] |
|
|
getCategoryType().then(result => { |
|
|
getCategoryType().then(result => { |
|
|
typeList = result.data |
|
|
typeList = result.data |
|
|
var tabList = [] |
|
|
var tabList = [] |
|
|
for (let index = 0; index < typeList.length; index++) { |
|
|
for (let index = 0; index < typeList.length; index++) { |
|
|
tabList.push(typeList[index].categoryName) |
|
|
tabList.push(typeList[index].categoryName) |
|
|
} |
|
|
} |
|
|
form.categoryId = typeList[0].categoryId |
|
|
|
|
|
|
|
|
this.data.form.categoryId = typeList[0].categoryId |
|
|
this.setData({ tabList }) |
|
|
this.setData({ tabList }) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
@ -76,7 +77,7 @@ Component({ |
|
|
if(!this.data.bannerList.length){ |
|
|
if(!this.data.bannerList.length){ |
|
|
getBannerList(1).then(result => { |
|
|
getBannerList(1).then(result => { |
|
|
this.setData({ bannerList: result.data }) |
|
|
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) |
|
|
console.log('mall>>fragment>>onEvent', message) |
|
|
if(message.what == 888 && app.globalData.userInfo){ |
|
|
if(message.what == 888 && app.globalData.userInfo){ |
|
|
this.initLogin() |
|
|
this.initLogin() |
|
|
this.fetchAgentList() |
|
|
|
|
|
} else if(message.what == 444){ |
|
|
} 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() |
|
|
this.fetchAgentList() |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
@ -100,6 +100,7 @@ Component({ |
|
|
this.setData({ messageNumber: result.data.messageNumber + result.data.notificationNumber }) |
|
|
this.setData({ messageNumber: result.data.messageNumber + result.data.notificationNumber }) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
this.fetchAgentList() |
|
|
}, |
|
|
}, |
|
|
postInfo: function(e){ |
|
|
postInfo: function(e){ |
|
|
var item = this.data.momentList[e.currentTarget.dataset.index] |
|
|
var item = this.data.momentList[e.currentTarget.dataset.index] |
|
|
@ -123,6 +124,10 @@ Component({ |
|
|
util.navigateTo('/pages/html/message/index') |
|
|
util.navigateTo('/pages/html/message/index') |
|
|
} else if(e.currentTarget.id == 'search'){ |
|
|
} else if(e.currentTarget.id == 'search'){ |
|
|
wx.navigateTo({url: `/pages/mall/search-list/index?tab=1` }) |
|
|
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){ |
|
|
tapBanner: function(e){ |
|
|
@ -138,7 +143,7 @@ Component({ |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
this.data.tabIndex = Number(detail.index) |
|
|
this.data.tabIndex = Number(detail.index) |
|
|
form.categoryId = typeList[Number(detail.index)].categoryId |
|
|
|
|
|
|
|
|
this.data.form.categoryId = typeList[Number(detail.index)].categoryId |
|
|
this.fetchAgentList() |
|
|
this.fetchAgentList() |
|
|
}, |
|
|
}, |
|
|
topBubble: function(e){ |
|
|
topBubble: function(e){ |
|
|
@ -149,7 +154,7 @@ Component({ |
|
|
if(!util.isEmpty(e.currentTarget.dataset.index)){ |
|
|
if(!util.isEmpty(e.currentTarget.dataset.index)){ |
|
|
this.data.sortIndex = Number(e.currentTarget.dataset.index) |
|
|
this.data.sortIndex = Number(e.currentTarget.dataset.index) |
|
|
if(this.data.popover){ |
|
|
if(this.data.popover){ |
|
|
form.sortBy = this.data.sortIndex |
|
|
|
|
|
|
|
|
this.data.form.sortBy = this.data.sortIndex |
|
|
this.fetchAgentList() |
|
|
this.fetchAgentList() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -157,11 +162,19 @@ Component({ |
|
|
}, |
|
|
}, |
|
|
//*************************************************fetchAgentList************************************************//
|
|
|
//*************************************************fetchAgentList************************************************//
|
|
|
fetchAgentList: function () { |
|
|
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 |
|
|
return |
|
|
} |
|
|
} |
|
|
this.setData({ requesting: true, orderList: [] }) |
|
|
this.setData({ requesting: true, orderList: [] }) |
|
|
getMomentList(form).then(result => { |
|
|
|
|
|
|
|
|
getMomentList(this.data.form).then(result => { |
|
|
if (result.data.records.length) { |
|
|
if (result.data.records.length) { |
|
|
this.setData({ orderList: result.data.records, requesting: false }) |
|
|
this.setData({ orderList: result.data.records, requesting: false }) |
|
|
} else { |
|
|
} else { |
|
|
|