From c948de4b4c93577a9f0f1664a408b53bb6e9dd60 Mon Sep 17 00:00:00 2001
From: xpz2018 <107107461@qq.com>
Date: Fri, 24 Sep 2021 16:27:15 +0800
Subject: [PATCH] no message
---
pages/agent/fragment/index.js | 39 +++++++++++++++--------------------
pages/index/index.js | 9 +++-----
pages/index/index.wxml | 2 +-
3 files changed, 21 insertions(+), 29 deletions(-)
diff --git a/pages/agent/fragment/index.js b/pages/agent/fragment/index.js
index 841c6c6..3fba2f4 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, 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()
},
// 下拉刷新...
diff --git a/pages/index/index.js b/pages/index/index.js
index f4d3ad8..0415f99 100644
--- a/pages/index/index.js
+++ b/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 })
diff --git a/pages/index/index.wxml b/pages/index/index.wxml
index 302a94c..f30b969 100644
--- a/pages/index/index.wxml
+++ b/pages/index/index.wxml
@@ -6,7 +6,7 @@
-
+