diff --git a/pages/agent/fragment/index.js b/pages/agent/fragment/index.js index fb70ef9..841c6c6 100644 --- a/pages/agent/fragment/index.js +++ b/pages/agent/fragment/index.js @@ -1,6 +1,6 @@ // pages/agent/index/index.js import util from "../../../utils/util" -import { getFactoryPrice, getFactoryCity, hasActivity } from "../../../api/ztb" +import { getFactoryPrice, hasActivity } from "../../../api/ztb" const event = require('../../../utils/event') const app = getApp() @@ -9,6 +9,22 @@ 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 }) + } + } + }, /** * 页面的初始数据 */ @@ -21,7 +37,6 @@ Component({ finished: false, tabList: [], tabIndex: 0, - cateList: [], scrolled: false, top: 0, orderList: [], @@ -61,7 +76,7 @@ Component({ kg: app.globalData.kg, firstShow: true }) - this.fetchRegionList() + // this.fetchRegionList() this.fetchPapersList() } this.data.firstShow = true @@ -87,18 +102,9 @@ Component({ toAbility: function(){ util.navigateTo('/pages/agent/ability/index') }, - fetchRegionList: function () { - getFactoryCity().then(result => { - 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.cateList.length; index++) { - if(this.data.cateList[index].cityId == detail.cityId){ + for (let index = 0; index < this.data.cityList.length; index++) { + if(this.data.cityList[index].cityId == detail.cityId){ detail.index = index this.onTabChange({detail}) break @@ -110,7 +116,7 @@ Component({ return } this.data.tabIndex = Number(detail.index) - this.data.form.cityId = this.data.cateList[this.data.tabIndex].cityId + this.data.form.cityId = this.data.cityList[this.data.tabIndex].cityId this.onRefreshList() }, // 下拉刷新... diff --git a/pages/index/index.js b/pages/index/index.js index eac5f80..d9a407c 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -26,6 +26,7 @@ Page({ landInfo: null, visible: false, show: false, + cityList: [], historyList: [], cityId: null, visible2: false diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 03e31c4..e2bc44d 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -6,7 +6,7 @@ - +