Commit aca9f2f7 by jscat

nyx weapp: 页面优化

1. 统一community/fair的变量为entity
parent ace48180
// pages/activity/activity.js // pages/activity/activity.js
...@@ -60,22 +60,22 @@ Page({ ...@@ -60,22 +60,22 @@ Page({
//园区 //园区
activityType: "02-园区", activityType: "02-园区",
communities: [], entities: [], //包括fair和community
/* /*
园区所在的信息 集市/园区所在的信息
community_name, num_activity, num_like fair_name, community_name, num_activity, num_like
*/ */
communityInfos: {}, entityInfos: {},
curCommunity: 0, curEntity: 0,
}, },
switchCategory(e) { switchCategory(e) {
var _this = this; var _this = this;
var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0 var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
var curCommunity = _this.__data__.curCommunity var curEntity = _this.__data__.curEntity
var strAddress = app.globalData.defaultCity var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity] var strEntity = _this.__data__.entities[curEntity]
var strCategory = _this.__data__.category[curIndex].order var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch var strSearch = _this.__data__.strSearch
this.setData({ this.setData({
...@@ -196,18 +196,18 @@ Page({ ...@@ -196,18 +196,18 @@ Page({
// step5 new add jscat 20201008 载入园区列表 - local page // step5 new add jscat 20201008 载入园区列表 - local page
var strCity = app.globalData.defaultCity var strCity = app.globalData.defaultCity
var activityType = _this.__data__.activityType var activityType = _this.__data__.activityType
let promise_community = new Promise(function (resolve, reject) { let promise_entity = new Promise(function (resolve, reject) {
_this.getCommunities(strCity, activityType, resolve, reject); _this.getEntities(strCity, activityType, resolve, reject);
}) })
// step6 初始载入四个推荐的活动 - local page // step6 初始载入四个推荐的活动 - local page
promise_community.then( promise_entity.then(
function (value){ function (value){
console.log("===enter promise_community then_passed_" + value) console.log("===enter promise_entity then_passed_" + value)
_this.onGetActivities() _this.onGetActivities()
}, },
function (value){ function (value){
console.log("===enter promise_community then_failed_" + value) console.log("===enter promise_entity then_failed_" + value)
} }
) )
...@@ -273,18 +273,18 @@ Page({ ...@@ -273,18 +273,18 @@ Page({
{ {
var strCity = app.globalData.defaultCity var strCity = app.globalData.defaultCity
var activityType = _this.__data__.activityType var activityType = _this.__data__.activityType
let promise_community = new Promise(function (resolve, reject) { let promise_entity = new Promise(function (resolve, reject) {
_this.getCommunities(strCity, activityType, resolve, reject); _this.getEntities(strCity, activityType, resolve, reject);
}) })
// step6 初始载入四个推荐的活动 - local page // step6 初始载入四个推荐的活动 - local page
promise_community.then( promise_entity.then(
function (value){ function (value){
console.log("===enter promise_community then_passed_" + value) console.log("===enter promise_entity then_passed_" + value)
_this.onGetActivities() _this.onGetActivities()
}, },
function (value){ function (value){
console.log("===enter promise_community then_failed_" + value) console.log("===enter promise_entity then_failed_" + value)
} }
) )
...@@ -323,15 +323,15 @@ Page({ ...@@ -323,15 +323,15 @@ Page({
console.log('页面上拉触底') console.log('页面上拉触底')
var _this = this; var _this = this;
var curIndex = _this.__data__.curIndex var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity var curEntity = _this.__data__.curEntity
var strAddress = app.globalData.defaultCity var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity] var strEntity = _this.__data__.entities[curEntity]
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 isHideLoadMore = _this.__data__.isHideLoadMore; var isHideLoadMore = _this.__data__.isHideLoadMore;
var pageIndex = _this.__data__.pageIndex; var pageIndex = _this.__data__.pageIndex;
//控制逻辑, 在onClick之后或者onGetComment事件之后再允许下拉更新操作 //控制逻辑, 下拉更新操作
//判断是否已经全部加载完毕 //判断是否已经全部加载完毕
//没有则加载更多 //没有则加载更多
if (!isHideLoadMore) { if (!isHideLoadMore) {
...@@ -476,9 +476,9 @@ Page({ ...@@ -476,9 +476,9 @@ Page({
hideInput: function () { hideInput: function () {
var _this = this; var _this = this;
var curIndex = _this.__data__.curIndex var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity var curEntity = _this.__data__.curEntity
var strAddress = app.globalData.defaultCity var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity] var strEntity = _this.__data__.entities[curEntity]
var strCategory = _this.__data__.category[curIndex].order var strCategory = _this.__data__.category[curIndex].order
var strSearch = "" var strSearch = ""
...@@ -502,9 +502,9 @@ Page({ ...@@ -502,9 +502,9 @@ Page({
var _this = this; var _this = this;
var strSearch = e.detail.value var strSearch = e.detail.value
var curIndex = _this.__data__.curIndex var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity var curEntity = _this.__data__.curEntity
var strAddress = app.globalData.defaultCity var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity] var strEntity = _this.__data__.entities[curEntity]
var strCategory = _this.__data__.category[curIndex].order var strCategory = _this.__data__.category[curIndex].order
console.log("===input search text_" + strSearch) console.log("===input search text_" + strSearch)
...@@ -639,10 +639,10 @@ Page({ ...@@ -639,10 +639,10 @@ Page({
var _this = this; var _this = this;
var curIndex = _this.__data__.curIndex var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity var curEntity = _this.__data__.curEntity
var strAddress = app.globalData.defaultCity var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity] var strEntity = _this.__data__.entities[curEntity]
var strCategory = _this.__data__.category[curIndex].order var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch var strSearch = _this.__data__.strSearch
...@@ -654,18 +654,18 @@ Page({ ...@@ -654,18 +654,18 @@ Page({
/* /*
* 更换某一个memberInfo的地址信息 * 更换某一个memberInfo的地址信息
*/ */
onCommunityPicker: function (e) { onEntityPicker: function (e) {
var _this = this; var _this = this;
var curCommunity = e.detail.value var curEntity = e.detail.value
var switchId = app.globalData.switchId var switchId = app.globalData.switchId
var curIndex = switchId != ""? switchId : _this.__data__.curIndex var curIndex = switchId != ""? switchId : _this.__data__.curIndex
var strAddress = app.globalData.defaultCity var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity] var strEntity = _this.__data__.entities[curEntity]
var strCategory = _this.__data__.category[curIndex].order var strCategory = _this.__data__.category[curIndex].order
var strSearch = "" var strSearch = ""
this.setData({ this.setData({
curIndex, curCommunity, strSearch curIndex, curEntity, strSearch
}); });
app.globalData.switchId = "" app.globalData.switchId = ""
...@@ -674,8 +674,8 @@ Page({ ...@@ -674,8 +674,8 @@ Page({
}, },
// 获取Communities数据 limit 10 by cityName && activityType // 获取entities数据 limit 10 by cityName && activityType
getCommunities: function (cityName, activityType, resolve, reject) { getEntities: function (cityName, activityType, resolve, reject) {
var _this = this; var _this = this;
var query_url = '?activityType=' + activityType + '&cityName=' + cityName var query_url = '?activityType=' + activityType + '&cityName=' + cityName
...@@ -693,32 +693,41 @@ Page({ ...@@ -693,32 +693,41 @@ Page({
//表示HTTP请求成功 //表示HTTP请求成功
console.log(res.data); console.log(res.data);
var list = [] var list = []
var communities = [] var entities = []
for (var i = 0; i < res.data.data.length; i++) { for (var i = 0; i < res.data.data.length; i++) {
var result = {} var result = {}
result["activity_type"] = res.data.data[i].activityType result["activity_type"] = res.data.data[i].activityType
result["city_name"] = res.data.data[i].cityName result["city_name"] = res.data.data[i].cityName
result["fair_name"] = res.data.data[i].fairName
result["community_name"] = res.data.data[i].communityName result["community_name"] = res.data.data[i].communityName
result["num_entity"] = res.data.data[i].numEntity result["num_entity"] = res.data.data[i].numEntity
result["num_activity"] = res.data.data[i].numActivity result["num_activity"] = res.data.data[i].numActivity
result["num_like"] = res.data.data[i].numLike result["num_like"] = res.data.data[i].numLike
communities.push(res.data.data[i].communityName) if(_this.data.activityType == "01-集市")
{
entities.push(res.data.data[i].fairName)
}
else if(_this.data.activityType == "02-园区")
{
entities.push(res.data.data[i].communityName)
}
list.push(result) list.push(result)
} }
_this.setData({ _this.setData({
communities: communities, entities: entities,
communityInfos: list, entityInfos: list,
curCommunity: 0, curEntity: 0,
}) })
resolve("===getCommunities success") resolve("===getEntities success")
} }
}, },
fail: function (err) { fail: function (err) {
console.log("fail to getCommunities", err.errMsg) console.log("fail to getEntities", err.errMsg)
reject(new Error('failed to getCommunities')); reject(new Error('failed to getEntities'));
}, },
}) })
}, },
...@@ -728,13 +737,13 @@ Page({ ...@@ -728,13 +737,13 @@ Page({
var _this = this; var _this = this;
// 如果强制更新, 则不考虑_this.data.activities length是否为0 // 如果强制更新, 则不考虑_this.data.activities length是否为0
if( _this.__data__.communities.length > 0 ) if( _this.__data__.entities.length > 0 )
{ {
var switchId = app.globalData.switchId var switchId = app.globalData.switchId
var curIndex = switchId != ""? switchId : _this.__data__.curIndex var curIndex = switchId != ""? switchId : _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity var curEntity = _this.__data__.curEntity
var strAddress = app.globalData.defaultCity var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity] var strEntity = _this.__data__.entities[curEntity]
var strCategory = _this.__data__.category[curIndex].order var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch var strSearch = _this.__data__.strSearch
this.setData({ curIndex }); this.setData({ curIndex });
......
<wxs module="tutil" src="./../../utils/date.wxs"></wxs> <wxs module="tutil" src="./../../utils/date.wxs"></wxs>
...@@ -7,21 +7,21 @@ ...@@ -7,21 +7,21 @@
<!-- 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">
<picker mode="selector" range="{{communities}}" value="{{curCommunity}}" bindchange="onCommunityPicker" class='address_member'> <picker mode="selector" range="{{entities}}" value="{{curEntity}}" bindchange="onEntityPicker" class='address_member'>
<text>{{communities[curCommunity]}}</text> <text>{{entities[curEntity]}}</text>
<image src='../../icon/down.png' style='width: 40rpx;height: 40rpx;' class='selecrtImg'></image> <image src='../../icon/down.png' style='width: 40rpx;height: 40rpx;' class='selecrtImg'></image>
</picker> </picker>
<view class="weui-search-bar__form"> <view class="weui-search-bar__form">
<view class="weui-search-bar__box"> <view class="weui-search-bar__box">
<icon class="weui-icon-search_in-box" type="search" size="16"></icon> <icon class="weui-icon-search_in-box" type="search" size="16"></icon>
<input type="text" class="weui-search-bar__input" placeholder="发现{{communities[curCommunity]}}" value="{{inputVal}}" focus="{{inputShowed}}" bindconfirm="startSearch" /> <input type="text" class="weui-search-bar__input" placeholder="发现{{entities[curEntity]}}" value="{{inputVal}}" focus="{{inputShowed}}" bindconfirm="startSearch" />
<view class="weui-icon-clear" wx:if="{{inputVal.length > 0}}" bindtap="clearInput"> <view class="weui-icon-clear" wx:if="{{inputVal.length > 0}}" bindtap="clearInput">
<icon type="clear" size="16"></icon> <icon type="clear" size="16"></icon>
</view> </view>
</view> </view>
<label class="weui-search-bar__label" hidden="{{inputShowed}}" bindtap="showInput"> <label class="weui-search-bar__label" hidden="{{inputShowed}}" bindtap="showInput">
<icon class="weui-icon-search" type="search" size="16"></icon> <icon class="weui-icon-search" type="search" size="16"></icon>
<view class="weui-search-bar__text">发现{{communities[curCommunity]}}·感兴趣的活动</view> <view class="weui-search-bar__text">发现{{entities[curEntity]}}·感兴趣的活动</view>
</label> </label>
</view> </view>
<view class="weui-search-bar__cancel-btn" hidden="{{!inputShowed}}" bindtap="hideInput">取消 <view class="weui-search-bar__cancel-btn" hidden="{{!inputShowed}}" bindtap="hideInput">取消
...@@ -48,23 +48,23 @@ ...@@ -48,23 +48,23 @@
<!-- jscat20200816 添加活动日历 for convinience --> <!-- jscat20200816 添加活动日历 for convinience -->
<block> <block>
<view class="items"> <view class="items">
<navigator url="/pages/activity/activity-list/activity-list?entityName={{communities[curCommunity]}}&activityType={{activityType}}"> <navigator url="/pages/activity/activity-list/activity-list?entityName={{entities[curEntity]}}&activityType={{activityType}}">
<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;">本周活动: {{communityInfos[curCommunity].num_activity}}场</text> <text style="font-size:28rpx;">本周活动: {{entityInfos[curEntity].num_activity}}场</text>
</navigator> </navigator>
</view> </view>
</block> </block>
<block wx:if="{{communityInfos[curCommunity].num_entity > 1}}"> <block wx:if="{{entityInfos[curEntity].num_entity > 1}}">
<view class="items"> <view class="items">
<image src="../../icon/community/community.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image> <image src="../../icon/community/community.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
<text style="font-size:28rpx;">园区: {{communityInfos[curCommunity].num_entity}}个</text> <text style="font-size:28rpx;">园区: {{entityInfos[curEntity].num_entity}}个</text>
</view> </view>
</block> </block>
<view class="items"> <view class="items">
<image src="../../icon/activity/like.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image> <image src="../../icon/activity/like.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
<text style="font-size:28rpx;">热度: {{communityInfos[curCommunity].num_like}}点</text> <text style="font-size:28rpx;">热度: {{entityInfos[curEntity].num_like}}点</text>
</view> </view>
</view> </view>
......
// pages/user/user.js
// pages/user/user.js
Page({
/**
* 页面的初始数据
*/
data: {
strAddress: "",
strIntro: {},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this = this;
var strAddress = ""
if(options.strAddress != "" && options.strAddress != undefined)
{
strAddress = options.strAddress
}
var strIntro = {
"思南公馆": "思南公馆是中国上海市中心唯一一个以成片花园洋房的保留保护为宗旨的项目,坐拥51栋历史悠久的花园洋房,同时汇聚了独立式花园洋房、联立式花园洋房、带内院独立式花园洋房、联排式建筑、外廊式建筑、新式里弄、花园里弄、现代公寓等多种建筑样式 ,是上海近代居住类建筑的集中地。\n占地面积约5万平方米,总建筑面积近8万平方米,内设有精品酒店、酒店式公寓、企业公馆和商业区,与淮海路沿线的百年经典建筑、名人故居交相辉映,成为上海市中心集人文、历史和时尚底蕴于一身,最具特色的风景。",
"永平里":"永平里 (上海衡复历史文化风貌区之一)\n永平里,北临衡山路、南接永嘉路。内部建筑错落于其中,相互由道路和庭院形成整体贯通,成为连接衡山路和永嘉路的特别区域兼具历史风貌和现代欧式风格的步行街道。"
}
_this.setData({ strAddress, strIntro })
wx.setNavigationBarTitle({
title: '园区介绍',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
<view class="page">
<view class="page">
<view class="userInfo">
<view class="userDesc">
<span>{{strIntro[strAddress]}}</span>
</view>
</view>
</view>
.page{
.page{
height: 100vh;
background: #f5f8fa;
}
.userinfo{
width: 100%;
height: 450rpx;
background: rgb(185, 172, 155);
}
.head-img{
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
overflow: hidden;
padding-top: 30px;
}
.thumb{
width: 120rpx;
height: 120rpx;
border: 1px solid #ffffff;
border-radius: 50%;
overflow: hidden;
}
.name{
margin: 30rpx;
color: #ffffff;
}
.userMessage{
display: flex;
justify-content: center; /*子元素水平居中*/
align-items: center; /*子元素垂直居中*/
}
.messageBox{
width: 650rpx;
height: 150rpx;
}
.focus, .fans, .praise-collect{
width: 200rpx;
color: #ffffff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
overflow: hidden;
float: left;
}
.border{
color: #ffffff;
width: 20rpx;
height: 150rpx;
float: left;
}
.grade{
height: 70rpx;
color: #6d6d6d;
background: #ffffff;
display: flex;
justify-content: center; /*子元素水平居中*/
align-items: center; /*子元素垂直居中*/
}
.grade-icon{
width: 50rpx;
height: 50rpx;
margin-right: 10rpx;
}
.userDesc{
height: 120rpx;
color: #6d6d6d;
background: #ffffff;
}
.userDesc span{
margin-left: 30rpx;
}
// pages/activity/activity.js // pages/activity/activity.js
...@@ -59,26 +59,29 @@ Page({ ...@@ -59,26 +59,29 @@ Page({
qRCodeMsg: "", qRCodeMsg: "",
//园区 //园区
communities: [ activityType: "01-集市",
'思南公馆', entities: [], //包括fair和community
'永平里', /*
], 集市/园区所在的信息
fair_name, community_name, num_activity, num_like
curCommunity: 0, */
entityInfos: {},
curEntity: 0,
}, },
switchCategory(e) { switchCategory(e) {
var _this = this; var _this = this;
var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0 var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
var curCommunity = _this.__data__.curCommunity var curEntity = _this.__data__.curEntity
var strAddress = _this.__data__.communities[curCommunity] var strAddress = app.globalData.defaultCity
var strCategory = _this.__data__.category[curIndex].order var strEntity = _this.__data__.entities[curEntity]
var strSearch = _this.__data__.strSearch var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
this.setData({ this.setData({
curIndex: curIndex, curIndex: curIndex,
}) })
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch); _this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
}, },
// 搜索点击事件 // 搜索点击事件
entrySearch(e) { entrySearch(e) {
...@@ -190,25 +193,25 @@ Page({ ...@@ -190,25 +193,25 @@ Page({
} }
) )
// step5 初始载入四个推荐的活动 - local page // step5 new add jscat 20201008 载入园区列表 - local page
if(_this.__data__.activities.length == 0) var strCity = app.globalData.defaultCity
{ var activityType = _this.__data__.activityType
var switchId = app.globalData.switchId let promise_entity = new Promise(function (resolve, reject) {
var curIndex = switchId != ""? switchId : _this.__data__.curIndex _this.getEntities(strCity, activityType, resolve, reject);
var curCommunity = _this.__data__.curCommunity })
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
this.setData({
curIndex: curIndex,
});
app.globalData.switchId = ""
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch);
} // step6 初始载入四个推荐的活动 - local page
promise_entity.then(
function (value){
console.log("===enter promise_entity then_passed_" + value)
_this.onGetActivities()
},
function (value){
console.log("===enter promise_entity then_failed_" + value)
}
)
// step6 event 订阅, 主要接受activity-info.js里 emit 发送的消息 local page // step7 event 订阅, 主要接受activity-info.js里 emit 发送的消息 local page
event.on('LikeChanged', this, function(data) { event.on('LikeChanged', this, function(data) {
var activity_id = data['activity_id'] var activity_id = data['activity_id']
var num_like = data['num_like'] var num_like = data['num_like']
...@@ -226,7 +229,7 @@ Page({ ...@@ -226,7 +229,7 @@ Page({
}) })
}) })
// step7 窗口初始化 // step8 窗口初始化
var device = wx.getSystemInfoSync() var device = wx.getSystemInfoSync()
//self.device = app.globalData.myDevice //self.device = app.globalData.myDevice
// jscat miniprogram default width is 750rpx // jscat miniprogram default width is 750rpx
...@@ -242,7 +245,7 @@ Page({ ...@@ -242,7 +245,7 @@ Page({
}) })
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
title: '园区活动', title: '集市活动',
}) })
}, },
...@@ -266,6 +269,28 @@ Page({ ...@@ -266,6 +269,28 @@ Page({
county: defaultCounty county: defaultCounty
}) })
if(app.globalData.citySwitched == 1)
{
var strCity = app.globalData.defaultCity
var activityType = _this.__data__.activityType
let promise_entity = new Promise(function (resolve, reject) {
_this.getEntities(strCity, activityType, resolve, reject);
})
// step6 初始载入四个推荐的活动 - local page
promise_entity.then(
function (value){
console.log("===enter promise_entity then_passed_" + value)
_this.onGetActivities()
},
function (value){
console.log("===enter promise_entity then_failed_" + value)
}
)
app.globalData.citySwitched = 0
}
}, },
/** /**
...@@ -298,21 +323,22 @@ Page({ ...@@ -298,21 +323,22 @@ Page({
console.log('页面上拉触底') console.log('页面上拉触底')
var _this = this; var _this = this;
var curIndex = _this.__data__.curIndex var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity var curEntity = _this.__data__.curEntity
var strAddress = _this.__data__.communities[curCommunity] var strAddress = app.globalData.defaultCity
var strCategory = _this.__data__.category[curIndex].order var strEntity = _this.__data__.entities[curEntity]
var strSearch = _this.__data__.strSearch var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
var isHideLoadMore = _this.__data__.isHideLoadMore; var isHideLoadMore = _this.__data__.isHideLoadMore;
var pageIndex = _this.__data__.pageIndex; var pageIndex = _this.__data__.pageIndex;
//控制逻辑, 在onClick之后或者onGetComment事件之后再允许下拉更新操作 //控制逻辑, 下拉更新操作
//判断是否已经全部加载完毕 //判断是否已经全部加载完毕
//没有则加载更多 //没有则加载更多
if (!isHideLoadMore) { if (!isHideLoadMore) {
console.log('加载更多') console.log('加载更多')
setTimeout(() => { setTimeout(() => {
_this.getActivities(1, pageIndex, 4, strAddress, strCategory, strSearch); _this.getActivities(1, pageIndex, 4, strAddress, strEntity, strCategory, strSearch);
}, 1000) }, 1000)
} }
else { else {
...@@ -338,13 +364,16 @@ Page({ ...@@ -338,13 +364,16 @@ Page({
1. 搜索框, tag=strSearch + title=strSearch 1. 搜索框, tag=strSearch + title=strSearch
2. tab, tag=strSearch 2. tab, tag=strSearch
3. 新增的search tab, '搜索'tab的时候,需要转换为搜索的关键词(_this.__data__.strSearch) 3. 新增的search tab, '搜索'tab的时候,需要转换为搜索的关键词(_this.__data__.strSearch)
4. jscat 20201008 新增按照entity搜索(fair/community)
*/ */
getActivities: function (scrollType, pageNum, pageCount, strAddress, strCategory, strSearch) { getActivities: function (scrollType, pageNum, pageCount, strAddress, strEntity, strCategory, strSearch) {
var _this = this; var _this = this;
var activityType = _this.__data__.activityType
// 如果是"推荐"和"搜索",需要单独处理 // 如果是"推荐"和"搜索",需要单独处理
// '搜索'tab的时候, 需要转换为搜索的关键词(_this.__data__.strSearch) // '搜索'tab的时候, 需要转换为搜索的关键词(_this.__data__.strSearch)
var query_url = '&title=' + strSearch + '&orderType=' + strCategory + '&city=' + strAddress var query_url = '&title=' + strSearch + '&orderType=' + strCategory + '&city=' + strAddress
+ '&activityType=' + activityType + '&entityName=' + strEntity
var strUrl = config.activity_query_url + "?pageCount=" + pageCount var strUrl = config.activity_query_url + "?pageCount=" + pageCount
+ "&pageNum=" + pageNum + query_url + "&pageNum=" + pageNum + query_url
...@@ -447,17 +476,18 @@ Page({ ...@@ -447,17 +476,18 @@ Page({
hideInput: function () { hideInput: function () {
var _this = this; var _this = this;
var curIndex = _this.__data__.curIndex var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity var curEntity = _this.__data__.curEntity
var strAddress = _this.__data__.communities[curCommunity] var strAddress = app.globalData.defaultCity
var strCategory = _this.__data__.category[curIndex].order var strEntity = _this.__data__.entities[curEntity]
var strSearch = "" var strCategory = _this.__data__.category[curIndex].order
var strSearch = ""
this.setData({ this.setData({
strSearch: strSearch, strSearch: strSearch,
inputShowed: false, inputShowed: false,
}); });
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch); _this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
}, },
// * 删除输入字符串 // * 删除输入字符串
...@@ -470,13 +500,15 @@ Page({ ...@@ -470,13 +500,15 @@ Page({
// 开始搜索 // 开始搜索
startSearch: function (e) { startSearch: function (e) {
var _this = this; var _this = this;
var strSearch = e.detail.value var strSearch = e.detail.value
var curIndex = _this.__data__.curIndex var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity var curEntity = _this.__data__.curEntity
var strAddress = _this.__data__.communities[curCommunity] var strAddress = app.globalData.defaultCity
var strCategory = _this.__data__.category[curIndex].order var strEntity = _this.__data__.entities[curEntity]
var strCategory = _this.__data__.category[curIndex].order
console.log("===input search text_" + strSearch) console.log("===input search text_" + strSearch)
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch); _this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
_this.setData({ _this.setData({
strSearch: strSearch, strSearch: strSearch,
...@@ -605,37 +637,122 @@ Page({ ...@@ -605,37 +637,122 @@ Page({
// used by switchcity.js // used by switchcity.js
onUpdateData: function(){ onUpdateData: function(){
var _this = this; var _this = this;
var curIndex = _this.__data__.curIndex
var curEntity = _this.__data__.curEntity
var curIndex = _this.__data__.curIndex var strAddress = app.globalData.defaultCity
var curCommunity = _this.__data__.curCommunity var strEntity = _this.__data__.entities[curEntity]
var strAddress = _this.__data__.communities[curCommunity] var strCategory = _this.__data__.category[curIndex].order
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch var strSearch = _this.__data__.strSearch
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch);
console.log("===input search text_" + strSearch)
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
}, },
/* /*
* 更换某一个memberInfo的地址信息 * 更换某一个memberInfo的地址信息
*/ */
onCommunityPicker: function (e) { onEntityPicker: function (e) {
var _this = this; var _this = this;
var curCommunity = e.detail.value var curEntity = e.detail.value
var switchId = app.globalData.switchId var switchId = app.globalData.switchId
var curIndex = switchId != ""? switchId : _this.__data__.curIndex var curIndex = switchId != ""? switchId : _this.__data__.curIndex
var strAddress = _this.__data__.communities[curCommunity] var strAddress = app.globalData.defaultCity
var strCategory = _this.__data__.category[curIndex].order var strEntity = _this.__data__.entities[curEntity]
var strSearch = "" var strCategory = _this.__data__.category[curIndex].order
var strSearch = ""
this.setData({ this.setData({
curIndex, curCommunity, strSearch curIndex, curEntity, strSearch
}); });
app.globalData.switchId = "" app.globalData.switchId = ""
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch); console.log("===input search text_" + strSearch)
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
}, },
// 获取entities数据 limit 10 by cityName && activityType
getEntities: function (cityName, activityType, resolve, reject) {
var _this = this;
var query_url = '?activityType=' + activityType + '&cityName=' + cityName
var strUrl = config.activity_stat_query_url + query_url
config.debug == 1 ? console.log("===strUrl is: \"" + strUrl + "\"") : ""
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if (res.data.resultCode == 200) {
//表示HTTP请求成功
console.log(res.data);
var list = []
var entities = []
for (var i = 0; i < res.data.data.length; i++) {
var result = {}
result["activity_type"] = res.data.data[i].activityType
result["city_name"] = res.data.data[i].cityName
result["fair_name"] = res.data.data[i].fairName
result["community_name"] = res.data.data[i].communityName
result["num_entity"] = res.data.data[i].numEntity
result["num_activity"] = res.data.data[i].numActivity
result["num_like"] = res.data.data[i].numLike
if(_this.data.activityType == "01-集市")
{
entities.push(res.data.data[i].fairName)
}
else if(_this.data.activityType == "02-园区")
{
entities.push(res.data.data[i].communityName)
}
list.push(result)
}
_this.setData({
entities: entities,
entityInfos: list,
curEntity: 0,
})
resolve("===getEntities success")
}
},
fail: function (err) {
console.log("fail to getEntities", err.errMsg)
reject(new Error('failed to getEntities'));
},
})
},
// getActivities入口函数
onGetActivities: function(){
var _this = this;
// 如果强制更新, 则不考虑_this.data.activities length是否为0
if( _this.__data__.entities.length > 0 )
{
var switchId = app.globalData.switchId
var curIndex = switchId != ""? switchId : _this.__data__.curIndex
var curEntity = _this.__data__.curEntity
var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.entities[curEntity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
this.setData({ curIndex });
app.globalData.switchId = ""
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
}
},
}) })
......
<wxs module="tutil" src="./../../utils/date.wxs"></wxs> <wxs module="tutil" src="./../../utils/date.wxs"></wxs>
...@@ -7,21 +7,21 @@ ...@@ -7,21 +7,21 @@
<!-- 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">
<picker mode="selector" range="{{communities}}" value="{{curCommunity}}" bindchange="onCommunityPicker" class='address_member'> <picker mode="selector" range="{{entities}}" value="{{curEntity}}" bindchange="onEntityPicker" class='address_member'>
<text>{{communities[curCommunity]}}</text> <text>{{entities[curEntity]}}</text>
<image src='../../icon/down.png' style='width: 40rpx;height: 40rpx;' class='selecrtImg'></image> <image src='../../icon/down.png' style='width: 40rpx;height: 40rpx;' class='selecrtImg'></image>
</picker> </picker>
<view class="weui-search-bar__form"> <view class="weui-search-bar__form">
<view class="weui-search-bar__box"> <view class="weui-search-bar__box">
<icon class="weui-icon-search_in-box" type="search" size="16"></icon> <icon class="weui-icon-search_in-box" type="search" size="16"></icon>
<input type="text" class="weui-search-bar__input" placeholder="发现{{communities[curCommunity]}}" value="{{inputVal}}" focus="{{inputShowed}}" bindconfirm="startSearch" /> <input type="text" class="weui-search-bar__input" placeholder="发现{{entities[curEntity]}}" value="{{inputVal}}" focus="{{inputShowed}}" bindconfirm="startSearch" />
<view class="weui-icon-clear" wx:if="{{inputVal.length > 0}}" bindtap="clearInput"> <view class="weui-icon-clear" wx:if="{{inputVal.length > 0}}" bindtap="clearInput">
<icon type="clear" size="16"></icon> <icon type="clear" size="16"></icon>
</view> </view>
</view> </view>
<label class="weui-search-bar__label" hidden="{{inputShowed}}" bindtap="showInput"> <label class="weui-search-bar__label" hidden="{{inputShowed}}" bindtap="showInput">
<icon class="weui-icon-search" type="search" size="16"></icon> <icon class="weui-icon-search" type="search" size="16"></icon>
<view class="weui-search-bar__text">发现{{communities[curCommunity]}}·感兴趣的活动</view> <view class="weui-search-bar__text">发现{{entities[curEntity]}}·感兴趣的活动</view>
</label> </label>
</view> </view>
<view class="weui-search-bar__cancel-btn" hidden="{{!inputShowed}}" bindtap="hideInput">取消 <view class="weui-search-bar__cancel-btn" hidden="{{!inputShowed}}" bindtap="hideInput">取消
...@@ -48,19 +48,23 @@ ...@@ -48,19 +48,23 @@
<!-- jscat20200816 添加活动日历 for convinience --> <!-- jscat20200816 添加活动日历 for convinience -->
<block> <block>
<view class="items"> <view class="items">
<navigator url="/pages/activity/activity-list/activity-list?strAddress={{communities[curCommunity]}}"> <navigator url="/pages/activity/activity-list/activity-list?entityName={{entities[curEntity]}}&activityType={{activityType}}">
<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;">本周活动</text> <text style="font-size:28rpx;">本周活动: {{entityInfos[curEntity].num_activity}}场</text>
</navigator> </navigator>
</view> </view>
</block> </block>
<!-- todo 0828 我的活动暂时也不实现 --> <block wx:if="{{entityInfos[curEntity].num_entity > 1}}">
<view class="items"> <view class="items">
<navigator url="/pages/community/introduction/introduction?strAddress={{communities[curCommunity]}}"> <image src="../../icon/fair/fair.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;">集市: {{entityInfos[curEntity].num_entity}}个</text>
</navigator> </view>
<text>{{communities[curCommunity]}}介绍</text> </block>
<view class="items">
<image src="../../icon/activity/like.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
<text style="font-size:28rpx;">热度: {{entityInfos[curEntity].num_like}}点</text>
</view> </view>
</view> </view>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论