Commit 3f7ab116 by jscat

nyx update:

1. /live/live.wxml 更新sortType的bindtap
2. /switchcity.js 城市switch之后,更新updateTab函数
3. 城市switch之后, 通过onshow()函数同步/live/live和/activity/activity的数据显示问题
parent aefe14be
...@@ -57,7 +57,7 @@ Page({ ...@@ -57,7 +57,7 @@ Page({
//二维码信息 //二维码信息
qRCodeMsg: "", qRCodeMsg: "",
//活动类型 //活动类型 @by default "00-饮事" 20210308 00-饮事::01-集市::02-园区
activityType: "00-饮事", activityType: "00-饮事",
}, },
...@@ -253,13 +253,21 @@ Page({ ...@@ -253,13 +253,21 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
var _this = this;
var _this = this;
var city = _this.data.city
const { globalData: { defaultCity, defaultCounty } } = app const { globalData: { defaultCity, defaultCounty } } = app
this.setData({
city: defaultCity, if( city != defaultCity)
county: defaultCounty {
}) _this.setData({
city: defaultCity,
county: defaultCounty
})
console.log("onshowing")
    //调用数据初始化方法
_this.onGetActivities();
}
}, },
...@@ -602,15 +610,23 @@ Page({ ...@@ -602,15 +610,23 @@ Page({
// used by switchcity.js // used by switchcity.js
onUpdateData: function(){ onUpdateData: function(){
var _this = this; var _this = this;
var strCity = app.globalData.defaultCity _this.onGetActivities();
},
// 开始搜索
onGetActivities: function () {
var _this = this;
var strCity = _this.__data__.city
var curIndex = _this.__data__.curIndex var curIndex = _this.__data__.curIndex
var strCategory = _this.__data__.category[curIndex].order var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch var strSearch = _this.__data__.strSearch
var activityType = _this.__data__.activityType var activityType = _this.__data__.activityType
_this.getActivities(0, 1, 4, strCity, activityType, strCategory, strSearch); _this.getActivities(0, 1, 4, strCity, activityType, strCategory, strSearch);
}, },
}) })
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<!-- refer https://www.jb51.net/article/158292.htm --> <!-- refer https://www.jb51.net/article/158292.htm -->
<!-- refer https://github.com/cinoliu/-selectCity --> <!-- refer https://github.com/cinoliu/-selectCity -->
<view class="weui-search-bar"> <view class="weui-search-bar">
<navigator url="../switchcity/switchcity?city={{city}}&type=index"> <navigator url="../switchcity/switchcity?city={{city}}&type=tab">
<text>{{city}}</text> <text>{{city}}</text>
<image src='../../icon/down.png' style='width: 32rpx;height: 32rpx;' class='selecrtImg'></image> <image src='../../icon/down.png' style='width: 32rpx;height: 32rpx;' class='selecrtImg'></image>
</navigator> </navigator>
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
<!-- start key view --> <!-- start key view -->
<view class="page__hd" style="position:fixed; top:0;width: 100%;"> <view class="page__hd" style="position:fixed; top:0;width: 100%;">
<view class="tab-title"> <view class="tab-title">
<view class="{{selected=='@'?'border-tottom':'default'}}" id="@" bindtap="selected">话题榜</view> <view class="{{selected=='@'?'border-tottom':'default'}}" id="@" bindtap="selected">@热门话题</view>
<view class="{{selected=='#'?'border-tottom':'default'}}" id="#" bindtap="selected">活跃榜</view> <view class="{{selected=='#'?'border-tottom':'default'}}" id="#" bindtap="selected">活跃用户榜</view>
</view> </view>
<!-- start_of_tab-content --> <!-- start_of_tab-content -->
<scroll-view scroll-y="true" scroll-top="0"> <scroll-view scroll-y="true" scroll-top="0">
......
...@@ -42,8 +42,10 @@ Page({ ...@@ -42,8 +42,10 @@ Page({
//二维码信息 //二维码信息
qRCodeMsg: "", qRCodeMsg: "",
//现场类型 //现场类型 @NotUsed 20210308
liveType: "", liveType: "",
//排序类型 new added 20210308, 人气: "01", 热度: "02", 关注: "03"
sortType: "01",
lives: [ lives: [
// { // {
...@@ -68,6 +70,9 @@ Page({ ...@@ -68,6 +70,9 @@ Page({
// }, // },
], ],
//避免安卓手机的onShow()被触发两次(ios不会), jscat 20210308
hadOnShow: false,
}, },
// 搜索点击事件 // 搜索点击事件
...@@ -183,13 +188,8 @@ Page({ ...@@ -183,13 +188,8 @@ Page({
// step5 初始载入四个直播的活动 - local page // step5 初始载入四个直播的活动 - local page
if(_this.__data__.lives.length == 0) if(_this.__data__.lives.length == 0)
{ {
var strCity = _this.__data__.city _this.onGetLives();
var strSearch = _this.__data__.strSearch
var liveType = _this.__data__.liveType
_this.getLives(0, 1, 4, strCity, liveType, strSearch);
} }
// step6 窗口初始化 // step6 窗口初始化
...@@ -225,12 +225,19 @@ Page({ ...@@ -225,12 +225,19 @@ Page({
*/ */
onShow: function () { onShow: function () {
var _this = this; var _this = this;
var city = _this.data.city
const { globalData: { defaultCity, defaultCounty } } = app const { globalData: { defaultCity, defaultCounty } } = app
this.setData({
city: defaultCity, if( city != defaultCity)
county: defaultCounty {
}) _this.setData({
city: defaultCity,
county: defaultCounty
})
console.log("onshowing")
    //调用数据初始化方法
_this.onGetLives();
}
}, },
...@@ -533,13 +540,25 @@ Page({ ...@@ -533,13 +540,25 @@ Page({
// used by switchcity.js // used by switchcity.js
onUpdateData: function(){ onUpdateData: function(){
var _this = this; var _this = this;
_this.onGetLives();
var strCity = _this.__data__.city },
// 开始搜索
onGetLives: function (e) {
var _this = this;
var sortType = e == undefined ? _this.__data__.sortType : e.currentTarget.dataset.id
var strSearch = _this.__data__.strSearch var strSearch = _this.__data__.strSearch
var strCity = _this.__data__.city
var liveType = _this.__data__.liveType var liveType = _this.__data__.liveType
_this.getLives(0, 1, 4, strCity, liveType, strSearch); _this.getLives(0, 1, 4, strCity, liveType, strSearch);
},
_this.setData({
strSearch: strSearch,
sortType: sortType,
})
},
}) })
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<!-- refer https://www.jb51.net/article/158292.htm --> <!-- refer https://www.jb51.net/article/158292.htm -->
<!-- refer https://github.com/cinoliu/-selectCity --> <!-- refer https://github.com/cinoliu/-selectCity -->
<view class="weui-search-bar"> <view class="weui-search-bar">
<navigator url="../switchcity/switchcity?city={{city}}&type=index"> <navigator url="../switchcity/switchcity?city={{city}}&type=tab">
<text>{{city}}</text> <text>{{city}}</text>
<image src='../../icon/down.png' style='width: 32rpx;height: 32rpx;' class='selecrtImg'></image> <image src='../../icon/down.png' style='width: 32rpx;height: 32rpx;' class='selecrtImg'></image>
</navigator> </navigator>
...@@ -42,27 +42,21 @@ ...@@ -42,27 +42,21 @@
<view class="workbench"> <view class="workbench">
<view class="list"> <view class="list">
<block> <block>
<view class="items"> <view class="items" bindtap="onGetLives" data-id="01">
<navigator url="/pages/activity/activity-list/activity-list?city={{city}}"> <image src="../../icon/member/schedule.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
<image src="../../icon/member/schedule.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image> <text style="font-size:28rpx;">人气: 100</text>
<text style="font-size:28rpx;">人气: 100</text>
</navigator>
</view> </view>
</block> </block>
<!-- todo 0828 我的活动暂时也不实现 --> <!-- todo 0828 我的活动暂时也不实现 -->
<view class="items"> <view class="items" bindtap="onGetLives" data-id="02">
<navigator url="/pages/my/my-orders/my-orders"> <image src="../../icon/activity/order.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
<image src="../../icon/activity/order.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image> <text style="font-size:28rpx;">热度: 1.2k</text>
<text style="font-size:28rpx;">热度: 1.2k</text>
</navigator>
</view> </view>
<view class="items"> <view class="items" bindtap="onGetLives" data-id="03">
<navigator url="/pages/my/my-collects/my-collects"> <image src="../../icon/my/fav.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
<image src="../../icon/my/fav.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image> <text style="font-size:28rpx;">关注: 12.5k</text>
<text style="font-size:28rpx;">关注: 12.5k</text>
</navigator>
</view> </view>
</view> </view>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<!-- start key view --> <!-- start key view -->
<view class="page__hd" style="position:fixed; top:0;width: 100%;"> <view class="page__hd" style="position:fixed; top:0;width: 100%;">
<view class="tab-title"> <view class="tab-title">
<view class="{{selected=='@'?'border-tottom':'default'}}" id="@" bindtap="selected">热度话题榜</view> <view class="{{selected=='@'?'border-tottom':'default'}}" id="@" bindtap="selected">@热门话题</view>
<view class="{{selected=='#'?'border-tottom':'default'}}" id="#" bindtap="selected">活跃聊天室</view> <view class="{{selected=='#'?'border-tottom':'default'}}" id="#" bindtap="selected">活跃聊天室</view>
</view> </view>
<!-- start_of_tab-content --> <!-- start_of_tab-content -->
......
import { LETTERS, HOT_CITY_LIST } from '../../locale/citydata' import { LETTERS, HOT_CITY_LIST } from '../../locale/citydata'
import { commonMessage } from '../../locale/commonMessageZhCn' import { commonMessage } from '../../locale/commonMessageZhCn'
import { AutoPredictor } from '../../utils/autoPredictor' import { AutoPredictor } from '../../utils/autoPredictor'
import utils from '../../utils/utils' import utils from '../../utils/util_switchcity'
const { const {
isNotEmpty, isNotEmpty,
...@@ -124,31 +124,35 @@ Page({ ...@@ -124,31 +124,35 @@ Page({
// 返回首页 // 返回首页
var update_type = _this.__data__.update_type var update_type = _this.__data__.update_type
update_type == "index" ? _this.updateIndex() : _this.updateList() update_type == "tab" ? _this.updateTab() : _this.updateTo()
}, },
updateIndex: function(e){ //tab页面; jscat 20210308
var url = getIndexUrl() updateTab: function(e){
//var urlCurrent = "../live/live" //pass
var urlCurrent = "../../" + getCurrentPages()[0].route
wx.switchTab({ wx.switchTab({
url: url, url: urlCurrent,
success: function (e) { success: function (e) {
var page = getCurrentPages().pop(); var page = getCurrentPages()[0]
if (page == undefined || page == null) return; if (page == undefined || page == null) return;
// 更新页的数据 // 更新tab页的数据
page.onUpdateData(); page.onUpdateData();
} }
}) })
}, },
updateList: function(e) //子页面; 非Tab页面 not used and not tested, jscat 20210308
//因为子页面不应该直接设置city参数; 在/live/live 或者 /activity/activity设置
updateTo: function(e)
{ {
var url = getListUrl() var urlCurrent = getCurrentPages()[0].route
wx.redirectTo({ wx.redirectTo({
url: url, url: urlCurrent,
success: function (e) { success: function (e) {
// jscat 20200827 在activity-list页面的onload里更新 //jscat 20200827 在activity-list页面的onload里更新
// page.onLoad(); page.onLoad();
} }
}) })
}, },
......
import { CITY_LIST, CITY_NOT_FOUND } from '../locale/citydata' import { CITY_LIST, CITY_NOT_FOUND } from '../locale/citydata'
import utils from 'utils' import utils from 'util_switchcity'
const { isNotEmpty, isChinese, getSlicedName } = utils; const { isNotEmpty, isChinese, getSlicedName } = utils;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论