|
|
|
@ -1,6 +1,6 @@ |
|
|
|
// pages/agent/index/index.js
|
|
|
|
import util from "../../../utils/util" |
|
|
|
import { getFactoryPrice, hasActivity } from "../../../api/ztb" |
|
|
|
import { getFactoryPrice, getFactoryCity, hasActivity } from "../../../api/ztb" |
|
|
|
const event = require('../../../utils/event') |
|
|
|
const app = getApp() |
|
|
|
|
|
|
|
@ -9,22 +9,6 @@ Component({ |
|
|
|
addGlobalClass: true, |
|
|
|
multipleSlots: true |
|
|
|
}, |
|
|
|
properties: { |
|
|
|
cityList: { |
|
|
|
type: Array, |
|
|
|
value: [], |
|
|
|
observer: function(vals){ |
|
|
|
if(util.isEmpty(vals) || vals.length <= 0){ |
|
|
|
return |
|
|
|
} |
|
|
|
this.data.cityList = [{ cityId: '', cityName: '全部' }].concat(vals) |
|
|
|
for (let index = 0; index < this.data.cityList.length; index++) { |
|
|
|
this.data.tabList.push(this.data.cityList[index].cityName) |
|
|
|
} |
|
|
|
this.setData({ tabList: this.data.tabList, scrolled: this.data.cityList.length >= 5 }) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 页面的初始数据 |
|
|
|
*/ |
|
|
|
@ -37,6 +21,7 @@ Component({ |
|
|
|
finished: false, |
|
|
|
tabList: [], |
|
|
|
tabIndex: 0, |
|
|
|
cateList: [], |
|
|
|
scrolled: false, |
|
|
|
top: 0, |
|
|
|
orderList: [], |
|
|
|
@ -76,13 +61,13 @@ Component({ |
|
|
|
kg: app.globalData.kg, |
|
|
|
firstShow: true |
|
|
|
}) |
|
|
|
// this.fetchRegionList()
|
|
|
|
this.fetchRegionList() |
|
|
|
this.fetchPapersList() |
|
|
|
} |
|
|
|
this.data.firstShow = true |
|
|
|
}, |
|
|
|
onEvent: function (message) { |
|
|
|
console.log('mall>>index>>onEvent', message) |
|
|
|
console.log('agent>>fragment>>onEvent', message) |
|
|
|
if (message.what == 10 && app.globalData.isVIP == 1) { |
|
|
|
// this.setData({ token: app.globalData.token })
|
|
|
|
// this.onRefreshList()
|
|
|
|
@ -102,9 +87,19 @@ Component({ |
|
|
|
toAbility: function(){ |
|
|
|
util.navigateTo('/pages/agent/ability/index') |
|
|
|
}, |
|
|
|
fetchRegionList: function () { |
|
|
|
getFactoryCity().then(result => { |
|
|
|
this.triggerEvent("region", result.data) |
|
|
|
this.data.cateList = [{ cityId: '', cityName: '全部' }].concat(result.data) |
|
|
|
for (let index = 0; index < this.data.cateList.length; index++) { |
|
|
|
this.data.tabList.push(this.data.cateList[index].cityName) |
|
|
|
} |
|
|
|
this.setData({ tabList: this.data.tabList, scrolled: this.data.cateList.length >= 5 }) |
|
|
|
}) |
|
|
|
}, |
|
|
|
onCityChange: function({ detail }){ |
|
|
|
for (let index = 0; index < this.data.cityList.length; index++) { |
|
|
|
if(this.data.cityList[index].cityId == detail.cityId){ |
|
|
|
for (let index = 0; index < this.data.cateList.length; index++) { |
|
|
|
if(this.data.cateList[index].cityId == detail.cityId){ |
|
|
|
detail.index = index |
|
|
|
this.onTabChange({detail}) |
|
|
|
break |
|
|
|
@ -116,7 +111,7 @@ Component({ |
|
|
|
return |
|
|
|
} |
|
|
|
this.data.tabIndex = Number(detail.index) |
|
|
|
this.data.form.cityId = this.data.cityList[this.data.tabIndex].cityId |
|
|
|
this.data.form.cityId = this.data.cateList[this.data.tabIndex].cityId |
|
|
|
this.onRefreshList() |
|
|
|
}, |
|
|
|
// 下拉刷新...
|
|
|
|
|