Browse Source

no message

featrue/v4.5
xpz2018 4 years ago
parent
commit
b7855d26a9
8 changed files with 48 additions and 48 deletions
  1. 1
      app.js
  2. 2
      pages/article/fragment/index.js
  3. 38
      pages/home/city-select/index.js
  4. 2
      pages/home/city-select/index.json
  5. 20
      pages/home/city-select/index.wxml
  6. 30
      pages/home/city-select/index.wxss
  7. 1
      pages/index/index.js
  8. 2
      pages/moment/fragment/index.js

1
app.js

@ -7,6 +7,7 @@ App({
version: 152, version: 152,
xAppId: '470236309865238528', xAppId: '470236309865238528',
nowLocation: null, nowLocation: null,
nowCity: null,
globalData: { globalData: {
userInfo: null, userInfo: null,
openId: null, openId: null,

2
pages/article/fragment/index.js

@ -87,7 +87,7 @@ Component({
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false }) this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false })
this.fetchAgentList() this.fetchAgentList()
} else if(message.what == 444){ } else if(message.what == 444){
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false, cityName: app.nowLocation.cityName })
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false, cityName: app.nowCity.cityName })
this.fetchAgentList() this.fetchAgentList()
} }
}, },

38
pages/home/city-select/index.js

@ -1,19 +1,20 @@
// pages/home/about/index.js // pages/home/about/index.js
const util = require('../../../utils/util') const util = require('../../../utils/util')
const event = require('../../../utils/event') const event = require('../../../utils/event')
const storage = require('../../../utils/storage')
const city = require("../../../utils/city.js") const city = require("../../../utils/city.js")
const app = getApp() const app = getApp()
var hotList = []
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
value: '', value: '',
height: app.globalData.fragmentHeight - 100, height: app.globalData.fragmentHeight - 100,
localCity:'',//当前定位城市
hotCity: ['北京', '上海', '广州', '深圳', '杭州', '长沙', '武汉', '厦门', '西安', '昆明', '成都', '重庆'], // 热门城市
localCity: null,//当前定位城市
hotCity: [], // 热门城市
lists:[],//城市列表 lists:[],//城市列表
searchResult:[],//查找列表 searchResult:[],//查找列表
titleHeight: 240, titleHeight: 240,
@ -30,8 +31,16 @@ Page({
var height = app.globalData.fragmentHeight - 100 var height = app.globalData.fragmentHeight - 100
this.data.indexHeight = height - 48 this.data.indexHeight = height - 48
var titleHeight = this.px2rpx(app.globalData.CustomBar) + 116 var titleHeight = this.px2rpx(app.globalData.CustomBar) + 116
var itemHeight = parseInt(this.data.indexHeight / 25)
this.setData({ height, itemHeight, indexHeight: this.data.indexHeight, titleHeight,lists: city.list })
var itemHeight = parseInt(this.data.indexHeight / 24)
var localCity = null
if(app.nowLocation && !util.isEmpty(app.nowLocation.cityName)){
localCity = app.nowLocation.cityName
}
var hotstring = storage.get('ztb-hot-list')
if(!util.isEmpty(hotstring)){
hotList = JSON.parse(hotstring)
}
this.setData({ height, itemHeight, indexHeight: this.data.indexHeight, titleHeight, localCity, lists: city.list, hotCity: hotList })
}, },
getInputValue(e){ getInputValue(e){
this.setData({ value:e.detail.value },()=>{ this.setData({ value:e.detail.value },()=>{
@ -89,11 +98,22 @@ Page({
} else { } else {
item = this.data.searchResult[e.currentTarget.dataset.index] item = this.data.searchResult[e.currentTarget.dataset.index]
} }
if(app.nowLocation) {
app.nowLocation.cityName = item.cityName.replace('市', '')
app.nowLocation.cityCode = item.code
if(app.nowCity) {
app.nowCity.cityName = item.cityName.replace('市', '')
app.nowCity.cityCode = item.code
} else { } else {
app.nowLocation = { cityName: item.cityName.replace('市', ''), cityCode: item.code }
app.nowCity = { cityName: item.cityName.replace('市', ''), cityCode: item.code }
}
var flag = false
for (let index = 0; index < hotList.length; index++) {
if(hotList[index].code == item.code){
flag = true
break
}
}
if(!flag){
hotList.push(item)
storage.put('ztb-hot-list', JSON.stringify(hotList))
} }
event.emit('EventMessage', { what: 444, desc: 'nowLocation' }) event.emit('EventMessage', { what: 444, desc: 'nowLocation' })
wx.navigateBack() wx.navigateBack()

2
pages/home/city-select/index.json

@ -1,5 +1,7 @@
{ {
"usingComponents": { "usingComponents": {
"wux-grids": "/components/grids/index",
"wux-grid": "/components/grid/index",
"free-input":"/components/free-input/index", "free-input":"/components/free-input/index",
"wux-cell": "/components/cell/index" "wux-cell": "/components/cell/index"
} }

20
pages/home/city-select/index.wxml

@ -14,18 +14,18 @@
</view> </view>
</view> </view>
<view wx:else> <view wx:else>
<view class="bg-white" style="padding: 0rpx 32rpx;">
<view class="text-gray text-sm">定位城市</view>
<view class="flex align-center" style="padding: 12rpx 0;">
<!-- <free-icon name="map-filling" size="20" color="#0081ff"></free-icon> -->
<text>{{localCity}}</text>
</view>
<view class="bg-white" style="padding: 8rpx 32rpx 16rpx 32rpx;" wx:if="{{localCity}}">
<view class="text-gray text-df">定位城市:{{localCity}}</view>
</view> </view>
<!-- 热门城市 --> <!-- 热门城市 -->
<view class="">
<view class="text-sm text-gray" style="padding: 12rpx 32rpx;">热门城市</view>
<view class="city-names bg-white">
<view class="city-name-item" wx:for="{{hotCity}}" wx:key="index" bindtap="lookItem" data-index="{{index}}">{{item}}</view>
<view wx:if="{{hotCity.length}}">
<view class="text-df text-gray" style="padding: 12rpx 32rpx;">热门城市</view>
<view class="bg-white" style="padding: 8rpx 60rpx 24rpx 16rpx;">
<wux-grids col="4" bordered="{{ false }}">
<wux-grid wx:for="{{hotCity}}" wx:key="index" hover-class="none">
<view class="city-name-item" bindtap="lookItem" data-index="{{index}}">{{item.cityName}}</view>
</wux-grid>
</wux-grids>
</view> </view>
</view> </view>
<!-- 列表 --> <!-- 列表 -->

30
pages/home/city-select/index.wxss

@ -30,40 +30,16 @@
} }
.city-names {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-content: space-between;
/* width: 630rpx; */
padding: 12rpx 90rpx 26rpx 30rpx;
}
.city-name-item { .city-name-item {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
width: 140rpx;
width: 150rpx;
height: 56rpx; height: 56rpx;
margin-top: 16rpx; margin-top: 16rpx;
/* border: solid 1rpx #ccc; */ /* border: solid 1rpx #ccc; */
border-radius: 28rpx;
font-size: 28rpx;
color: #333;
position: relative;
}
.city-name-item::before {
content: "";
position: absolute;
width: 200%;
height: 200%;
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scale(0.5, 0.5);
transform: scale(0.5, 0.5);
-webkit-box-sizing: border-box;
box-sizing: border-box;
left: 0;
top: 0;
border-radius: 56rpx; border-radius: 56rpx;
border: 1px solid #ccc; border: 1px solid #ccc;
font-size: 28rpx;
color: #333;
} }

1
pages/index/index.js

@ -91,6 +91,7 @@ Page({
success: function (res) { success: function (res) {
app.nowLocation.cityName = res.result.address_component.city.replace('市', '') app.nowLocation.cityName = res.result.address_component.city.replace('市', '')
app.nowLocation.cityCode = res.result.ad_info.city_code app.nowLocation.cityCode = res.result.ad_info.city_code
app.nowCity = { cityName: app.nowLocation.cityName, cityCode: app.nowLocation.cityCode }
that.setData({ cityName: app.nowLocation.cityName }) that.setData({ cityName: app.nowLocation.cityName })
that.locate = true that.locate = true
}, },

2
pages/moment/fragment/index.js

@ -63,7 +63,7 @@ Component({
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false }) this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false })
this.fetchAgentList() this.fetchAgentList()
} else if(message.what == 444){ } else if(message.what == 444){
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false, cityName: app.nowLocation.cityName })
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false, cityName: app.nowCity.cityName })
this.fetchAgentList() this.fetchAgentList()
} }
}, },

Loading…
Cancel
Save