Browse Source

no message

featrue/v4.5
xpz2018 4 years ago
parent
commit
c948de4b4c
3 changed files with 21 additions and 29 deletions
  1. 39
      pages/agent/fragment/index.js
  2. 9
      pages/index/index.js
  3. 2
      pages/index/index.wxml

39
pages/agent/fragment/index.js

@ -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()
},
// 下拉刷新...

9
pages/index/index.js

@ -1,5 +1,5 @@
import { config, getUserInfo } from "../../api/user"
import { zconfig, loginToken, getBaseInfo, getPopupInfo, getFactoryCity } from "../../api/ztb"
import { zconfig, loginToken, getBaseInfo, getPopupInfo } from "../../api/ztb"
import { pconfig } from "../../api/payment"
import { mconfig } from "../../api/moment"
const util = require('../../utils/util')
@ -161,7 +161,6 @@ Page({
})
},
toIndex: function () {
this.fetchRegionList()
if (!app.globalData.token) {
wx.hideLoading()
this.defaultIndex()
@ -262,15 +261,13 @@ Page({
}
util.navigateTarget(this.data.landInfo.ruleRedirectInfo)
},
fetchRegionList: function () {
onRegionList: function({detail}){
var hotstring = storage.get('ztb-history-list')
var historyList = []
if(!util.isEmpty(hotstring)){
historyList = JSON.parse(hotstring)
}
getFactoryCity().then(result => {
this.setData({ cityList: result.data, historyList })
})
this.setData({ cityList: detail, historyList })
},
clickCity: function(e){
this.setData({cityId: e.currentTarget.dataset.id, visible2: false })

2
pages/index/index.wxml

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

Loading…
Cancel
Save