Browse Source

no message

featrue/v4.5
xpz2018 4 years ago
parent
commit
d14e165a28
3 changed files with 23 additions and 16 deletions
  1. 36
      pages/agent/fragment/index.js
  2. 1
      pages/index/index.js
  3. 2
      pages/index/index.wxml

36
pages/agent/fragment/index.js

@ -1,6 +1,6 @@
// pages/agent/index/index.js // pages/agent/index/index.js
import util from "../../../utils/util" import util from "../../../utils/util"
import { getFactoryPrice, getFactoryCity, hasActivity } from "../../../api/ztb"
import { getFactoryPrice, hasActivity } from "../../../api/ztb"
const event = require('../../../utils/event') const event = require('../../../utils/event')
const app = getApp() const app = getApp()
@ -9,6 +9,22 @@ Component({
addGlobalClass: true, addGlobalClass: true,
multipleSlots: 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, finished: false,
tabList: [], tabList: [],
tabIndex: 0, tabIndex: 0,
cateList: [],
scrolled: false, scrolled: false,
top: 0, top: 0,
orderList: [], orderList: [],
@ -61,7 +76,7 @@ Component({
kg: app.globalData.kg, kg: app.globalData.kg,
firstShow: true firstShow: true
}) })
this.fetchRegionList()
// this.fetchRegionList()
this.fetchPapersList() this.fetchPapersList()
} }
this.data.firstShow = true this.data.firstShow = true
@ -87,18 +102,9 @@ Component({
toAbility: function(){ toAbility: function(){
util.navigateTo('/pages/agent/ability/index') 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 }){ 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 detail.index = index
this.onTabChange({detail}) this.onTabChange({detail})
break break
@ -110,7 +116,7 @@ Component({
return return
} }
this.data.tabIndex = Number(detail.index) 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() this.onRefreshList()
}, },
// 下拉刷新... // 下拉刷新...

1
pages/index/index.js

@ -26,6 +26,7 @@ Page({
landInfo: null, landInfo: null,
visible: false, visible: false,
show: false, show: false,
cityList: [],
historyList: [], historyList: [],
cityId: null, cityId: null,
visible2: false visible2: false

2
pages/index/index.wxml

@ -6,7 +6,7 @@
<moment id="{{TabList[1].value}}" city-name="{{cityName}}" bind:picker="onPicker"/> <moment id="{{TabList[1].value}}" city-name="{{cityName}}" bind:picker="onPicker"/>
</swiper-item> </swiper-item>
<swiper-item catchtouchmove="stopTouchMove"> <swiper-item catchtouchmove="stopTouchMove">
<agent id="{{TabList[2].value}}" bind:picker="onPicker"/>
<agent id="{{TabList[2].value}}" city-list="{{cityList}}" bind:picker="onPicker"/>
</swiper-item> </swiper-item>
<swiper-item catchtouchmove="stopTouchMove"> <swiper-item catchtouchmove="stopTouchMove">
<home id="{{TabList[3].value}}" /> <home id="{{TabList[3].value}}" />

Loading…
Cancel
Save