Commit 3b48ed94 by jscat

nyx weapp: 功能更新

1. 添加园区和园区活动query功能
parent a80d7bba
//app.js
//app.js
......@@ -77,6 +77,7 @@ App({
defaultCity: '上海',
defaultCounty: '静安区',
citySwitched: 0,
},
......
{
{
......@@ -43,7 +43,7 @@
},
{
"pagePath": "pages/fair/fair",
"text": "市",
"text": "市",
"iconPath": "./icon/fair/fair.png",
"selectedIconPath": "./icon/fair/fair.png"
},
......
//config.js API全局域名配置
//config.js API全局域名配置
......@@ -51,6 +51,7 @@ var config={
notes_query_url: host_key + "/api/nyx/post/query",
activity_query_url: host_key + "/api/nyx/activity/query",
activity_period_query_url: host_key + "/api/nyx/activity/query/period",
activity_stat_query_url: host_key + "/api/nyx/activity/stat/query",
order_detail_query_url: host_key + "/api/nyx/order/detail/query",
order_add_url: host_key + "/api/nyx/add/order",
match_query_url: host_key + "/api/nyx/match/query",
......
// pages/activity/activity.js
// pages/activity/activity.js
......@@ -59,11 +59,13 @@ Page({
qRCodeMsg: "",
//园区
communities: [
'思南公馆',
'永平里',
],
activityType: "02-园区",
communities: [],
/*
园区所在的信息
community_name, num_activity, num_like
*/
communityInfos: {},
curCommunity: 0,
},
......@@ -72,13 +74,14 @@ Page({
var _this = this;
var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
var curCommunity = _this.__data__.curCommunity
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
this.setData({
curIndex: curIndex,
})
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch);
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
},
// 搜索点击事件
entrySearch(e) {
......@@ -190,25 +193,25 @@ Page({
}
)
// step5 初始载入四个推荐的活动 - local page
if(_this.__data__.activities.length == 0)
{
var switchId = app.globalData.switchId
var curIndex = switchId != ""? switchId : _this.__data__.curIndex
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);
// step5 new add jscat 20201008 载入园区列表 - local page
var strCity = app.globalData.defaultCity
var activityType = _this.__data__.activityType
let promise_community = new Promise(function (resolve, reject) {
_this.getCommunities(strCity, activityType, resolve, reject);
})
}
// step6 初始载入四个推荐的活动 - local page
promise_community.then(
function (value){
console.log("===enter promise_community then_passed_" + value)
_this.onGetActivities()
},
function (value){
console.log("===enter promise_community 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) {
var activity_id = data['activity_id']
var num_like = data['num_like']
......@@ -226,7 +229,7 @@ Page({
})
})
// step7 窗口初始化
// step8 窗口初始化
var device = wx.getSystemInfoSync()
//self.device = app.globalData.myDevice
// jscat miniprogram default width is 750rpx
......@@ -266,6 +269,28 @@ Page({
county: defaultCounty
})
if(app.globalData.citySwitched == 1)
{
var strCity = app.globalData.defaultCity
var activityType = _this.__data__.activityType
let promise_community = new Promise(function (resolve, reject) {
_this.getCommunities(strCity, activityType, resolve, reject);
})
// step6 初始载入四个推荐的活动 - local page
promise_community.then(
function (value){
console.log("===enter promise_community then_passed_" + value)
_this.onGetActivities()
},
function (value){
console.log("===enter promise_community then_failed_" + value)
}
)
app.globalData.citySwitched = 0
}
},
/**
......@@ -299,9 +324,10 @@ Page({
var _this = this;
var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
var isHideLoadMore = _this.__data__.isHideLoadMore;
var pageIndex = _this.__data__.pageIndex;
......@@ -312,7 +338,7 @@ Page({
console.log('加载更多')
setTimeout(() => {
_this.getActivities(1, pageIndex, 4, strAddress, strCategory, strSearch);
_this.getActivities(1, pageIndex, 4, strAddress, strEntity, strCategory, strSearch);
}, 1000)
}
else {
......@@ -338,13 +364,16 @@ Page({
1. 搜索框, tag=strSearch + title=strSearch
2. tab, tag=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 activityType = _this.__data__.activityType
// 如果是"推荐"和"搜索",需要单独处理
// '搜索'tab的时候, 需要转换为搜索的关键词(_this.__data__.strSearch)
var query_url = '&title=' + strSearch + '&orderType=' + strCategory + '&city=' + strAddress
+ '&activityType=' + activityType + '&entityName=' + strEntity
var strUrl = config.activity_query_url + "?pageCount=" + pageCount
+ "&pageNum=" + pageNum + query_url
......@@ -448,16 +477,17 @@ Page({
var _this = this;
var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = ""
var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = ""
this.setData({
strSearch: strSearch,
inputShowed: false,
});
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch);
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
},
// * 删除输入字符串
......@@ -470,13 +500,15 @@ Page({
// 开始搜索
startSearch: function (e) {
var _this = this;
var strSearch = e.detail.value
var curIndex = _this.__data__.curIndex
var strSearch = e.detail.value
var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
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({
strSearch: strSearch,
......@@ -605,13 +637,17 @@ Page({
// used by switchcity.js
onUpdateData: function(){
var _this = this;
var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity
var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
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);
},
......@@ -624,18 +660,89 @@ Page({
var switchId = app.globalData.switchId
var curIndex = switchId != ""? switchId : _this.__data__.curIndex
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = ""
var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = ""
this.setData({
curIndex, curCommunity, strSearch
});
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);
},
// 获取Communities数据 limit 10 by cityName && activityType
getCommunities: 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 communities = []
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["community_name"] = res.data.data[i].communityName
result["num_activity"] = res.data.data[i].numActivity
result["num_like"] = res.data.data[i].numLike
communities.push(res.data.data[i].communityName)
list.push(result)
}
_this.setData({
communities: communities,
communityInfos: list,
curCommunity: 0,
})
resolve("===getCommunities success")
}
},
fail: function (err) {
console.log("fail to getCommunities", err.errMsg)
reject(new Error('failed to getCommunities'));
},
})
},
// getActivities入口函数
onGetActivities: function(){
var _this = this;
// 如果强制更新, 则不考虑_this.data.activities length是否为0
if( _this.__data__.communities.length > 0 )
{
var switchId = app.globalData.switchId
var curIndex = switchId != ""? switchId : _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity
var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.communities[curCommunity]
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);
}
},
})
......
// pages/activity/activity.js
// pages/activity/activity.js
......@@ -51,24 +51,34 @@ Page({
//搜索模块
inputShowed: false, //初始文本框不显示内容
strSearch : "", //搜索的字串
strSearch : "", //搜索的title字串
strAddress : "思南公馆", //搜索的address字串
inputVal : "", //输入字符串,主要用于页面显示
//二维码信息
qRCodeMsg: "",
//园区
communities: [
'思南公馆',
'永平里',
],
curCommunity: 0,
},
switchCategory(e) {
var _this = this;
var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
var strCity = _this.__data__.city
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,
})
_this.getActivities(0, 1, 4, strCity, strCategory, strSearch);
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch);
},
// 搜索点击事件
entrySearch(e) {
......@@ -180,13 +190,13 @@ Page({
}
)
// step5 初始载入四个推荐的活动 - local page
if(_this.__data__.activities.length == 0)
{
var switchId = app.globalData.switchId
var curIndex = switchId != ""? switchId : _this.__data__.curIndex
var strCity = _this.__data__.city
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({
......@@ -194,7 +204,7 @@ Page({
});
app.globalData.switchId = ""
_this.getActivities(0, 1, 4, strCity, strCategory, strSearch);
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch);
}
......@@ -288,7 +298,8 @@ Page({
console.log('页面上拉触底')
var _this = this;
var curIndex = _this.__data__.curIndex
var strCity = _this.__data__.city
var curCommunity = _this.__data__.curCommunity
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
var isHideLoadMore = _this.__data__.isHideLoadMore;
......@@ -301,7 +312,7 @@ Page({
console.log('加载更多')
setTimeout(() => {
_this.getActivities(1, pageIndex, 4, strCity, strCategory, strSearch);
_this.getActivities(1, pageIndex, 4, strAddress, strCategory, strSearch);
}, 1000)
}
else {
......@@ -328,12 +339,12 @@ Page({
2. tab, tag=strSearch
3. 新增的search tab, '搜索'tab的时候,需要转换为搜索的关键词(_this.__data__.strSearch)
*/
getActivities: function (scrollType, pageNum, pageCount, strCity, strCategory, strSearch) {
getActivities: function (scrollType, pageNum, pageCount, strAddress, strCategory, strSearch) {
var _this = this;
// 如果是"推荐"和"搜索",需要单独处理
// '搜索'tab的时候, 需要转换为搜索的关键词(_this.__data__.strSearch)
var query_url = '&title=' + strSearch + '&orderType=' + strCategory + '&city=' + strCity
var query_url = '&title=' + strSearch + '&orderType=' + strCategory + '&city=' + strAddress
var strUrl = config.activity_query_url + "?pageCount=" + pageCount
+ "&pageNum=" + pageNum + query_url
......@@ -436,7 +447,8 @@ Page({
hideInput: function () {
var _this = this;
var curIndex = _this.__data__.curIndex
var strCity = _this.__data__.city
var curCommunity = _this.__data__.curCommunity
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = ""
......@@ -445,7 +457,7 @@ Page({
inputShowed: false,
});
_this.getActivities(0, 1, 4, strCity, strCategory, strSearch);
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch);
},
// * 删除输入字符串
......@@ -460,10 +472,11 @@ Page({
var _this = this;
var strSearch = e.detail.value
var curIndex = _this.__data__.curIndex
var strCity = _this.__data__.city
var curCommunity = _this.__data__.curCommunity
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
console.log("===input search text_" + strSearch)
_this.getActivities(0, 1, 4, strCity, strCategory, strSearch);
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch);
_this.setData({
strSearch: strSearch,
......@@ -593,14 +606,37 @@ Page({
onUpdateData: function(){
var _this = this;
var strCity = app.globalData.defaultCity
var curIndex = _this.__data__.curIndex
var curCommunity = _this.__data__.curCommunity
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
_this.getActivities(0, 1, 4, strCity, strCategory, strSearch);
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch);
},
/*
* 更换某一个memberInfo的地址信息
*/
onCommunityPicker: function (e) {
var _this = this;
var curCommunity = e.detail.value
var switchId = app.globalData.switchId
var curIndex = switchId != ""? switchId : _this.__data__.curIndex
var strAddress = _this.__data__.communities[curCommunity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = ""
this.setData({
curIndex, curCommunity, strSearch
});
app.globalData.switchId = ""
_this.getActivities(0, 1, 4, strAddress, strCategory, strSearch);
},
})
//通过Promise方式为wx.request添加同步操作
......
<wxs module="tutil" src="./../../utils/date.wxs"></wxs>
<wxs module="tutil" src="./../../utils/date.wxs"></wxs>
......@@ -7,21 +7,21 @@
<!-- refer https://www.jb51.net/article/158292.htm -->
<!-- refer https://github.com/cinoliu/-selectCity -->
<view class="weui-search-bar">
<navigator url="../switchcity/switchcity?city={{city}}&type=index">
<text>{{city}}</text>
<image src='../../icon/down.png' style='width: 32rpx;height: 32rpx;' class='selecrtImg'></image>
</navigator>
<picker mode="selector" range="{{communities}}" value="{{curCommunity}}" bindchange="onCommunityPicker" class='address_member'>
<text>{{communities[curCommunity]}}</text>
<image src='../../icon/down.png' style='width: 40rpx;height: 40rpx;' class='selecrtImg'></image>
</picker>
<view class="weui-search-bar__form">
<view class="weui-search-bar__box">
<icon class="weui-icon-search_in-box" type="search" size="16"></icon>
<input type="text" class="weui-search-bar__input" placeholder="发现感兴趣的活动" value="{{inputVal}}" focus="{{inputShowed}}" bindconfirm="startSearch" />
<input type="text" class="weui-search-bar__input" placeholder="发现{{communities[curCommunity]}}" value="{{inputVal}}" focus="{{inputShowed}}" bindconfirm="startSearch" />
<view class="weui-icon-clear" wx:if="{{inputVal.length > 0}}" bindtap="clearInput">
<icon type="clear" size="16"></icon>
</view>
</view>
<label class="weui-search-bar__label" hidden="{{inputShowed}}" bindtap="showInput">
<icon class="weui-icon-search" type="search" size="16"></icon>
<view class="weui-search-bar__text">发现感兴趣的夜市活动</view>
<view class="weui-search-bar__text">发现{{communities[curCommunity]}}·感兴趣的活动</view>
</label>
</view>
<view class="weui-search-bar__cancel-btn" hidden="{{!inputShowed}}" bindtap="hideInput">取消
......@@ -48,26 +48,19 @@
<!-- jscat20200816 添加活动日历 for convinience -->
<block>
<view class="items">
<navigator url="/pages/activity/activity-list/activity-list?city={{city}}">
<navigator url="/pages/activity/activity-list/activity-list?strAddress={{communities[curCommunity]}}">
<image src="../../icon/member/schedule.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
<text style="font-size:28rpx;">本周活动</text>
</navigator>
</view>
</block>
<view class="items">
<navigator url="/pages/my/my-collects/my-collects">
<image src="../../icon/my/fav.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
<text style="font-size:28rpx;">我的收藏</text>
</navigator>
</view>
</block>
<!-- todo 0828 我的活动暂时也不实现 -->
<view class="items">
<navigator url="/pages/my/my-orders/my-orders">
<navigator url="/pages/community/introduction/introduction?strAddress={{communities[curCommunity]}}">
<image src="../../icon/activity/order.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
</navigator>
<text>我的预订</text>
<text>{{communities[curCommunity]}}介绍</text>
</view>
</view>
......@@ -102,7 +95,7 @@
<view class="note-column">
<navigator url='{{item.url}}&num_like={{item.num_like}}' >
<!-- 商家信息 -->
{{item.title}}
<text>{{item.title}}</text>
<!-- 商品价格 -->
<span>
<view class="price-row">
......
/*
/*
......@@ -335,6 +335,16 @@
width: 55%;
}
.note-column text{
/* 多行溢出省略 */
display: -webkit-box;
word-break: break-all;
-webkit-box-orient: vertical;
-webkit-line-clamp:2;
overflow: hidden;
text-overflow:ellipsis;
}
.writer-image{
width: 240rpx;
height: 240rpx;
......
import { LETTERS, HOT_CITY_LIST } from '../../locale/citydata'
import { LETTERS, HOT_CITY_LIST } from '../../locale/citydata'
......@@ -100,6 +100,7 @@ Page({
//直接更新app.globalData
appInstance.globalData.defaultCity = city
appInstance.globalData.defaultCounty = ''
appInstance.globalData.citySwitched = 1
// 同步更新storage记录
// start 记录最近访问
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论