Commit 22a10ea7 by jscat

nyx weapp: integration from nyx-dev

1. 新增园区和夜市功能
2. 新增活动类型字段
3. 统一community/fair的变量为entity
4. 解决集市页面(fair.wxml)当集市名称超过7的字符之后溢出的问题
5. 为活动类型添加checkField操作
parent 5ce9673d
//app.js
//app.js
......@@ -67,6 +67,7 @@ App({
photoTitle: "",
photoContent: "",
photoProduct: [],
photoCbs: [],
startDatetime: "",
endDatetime: "",
......@@ -77,6 +78,7 @@ App({
defaultCity: '上海',
defaultCounty: '静安区',
citySwitched: 0,
},
......
{
{
{
"pages": [
"pages": [
"pages/activity/activity",
"pages/community/community",
"pages/fair/fair",
"pages/mall/order/order",
"pages/activity/activity-list/activity-list",
"pages/my/my-members/my-members",
......@@ -35,16 +37,28 @@
"list": [
{
"pagePath": "pages/activity/activity",
"text": "活动",
"text": "饮事",
"iconPath": "./icon/my/activity.png",
"selectedIconPath": "./icon/my/activity.png"
},
{
"pagePath": "pages/fair/fair",
"text": "集市",
"iconPath": "./icon/fair/fair.png",
"selectedIconPath": "./icon/fair/fair.png"
},
{
"pagePath": "pages/member/activity-post/activity-post",
"text": "添加",
"iconPath": "./icon/add.png",
"selectedIconPath": "./icon/add.png"
},
},
{
"pagePath": "pages/community/community",
"text": "园区",
"iconPath": "./icon/community/community.png",
"selectedIconPath": "./icon/community/community.png"
},
{
"pagePath": "pages/my/my",
"text": "个人",
......
//config.js API全局域名配置
//config.js API全局域名配置
......@@ -3,7 +3,7 @@
// env = 0; //本地java测试,需要启动java后台
// env = 1; //阿里云服务器测试版本
// env = 2; //阿里云服务器生产版本
var env = 2;
var env = 1;
var debug = 0; //是否打印调试信息
var host_key = "https://fun.hisuhong.com";
......@@ -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/member/activity-post/activity-edit/activity-edit.js
// pages/member/activity-post/activity-edit/activity-edit.js
......@@ -25,6 +25,8 @@ Page({
// 城市模块
city: "",
entityName: "",
activityType: "",
// 分页加载部分
stride: 0,
......@@ -75,10 +77,17 @@ Page({
}
var city = app.globalData.defaultCity
var entityName = ""
var activityType = ""
if (options.city != "" && options.city != undefined )
{
city = options.city;
}
else if(options.entityName != "" && options.entityName != undefined)
{
entityName = options.entityName
activityType = options.activityType
}
wx.setNavigationBarTitle({
title: '活动列表',
......@@ -96,9 +105,11 @@ Page({
curDate: curDate,
endDate: endDate,
city: city,
entityName: entityName,
activityType: activityType,
});
_this.getActivitiesByPeriod(0, 1, stride, city, curDate, endDate);
_this.getActivitiesByPeriod(0, 1, stride, city, entityName, activityType, curDate, endDate);
}
......@@ -149,7 +160,9 @@ Page({
console.log('页面上拉触底')
var _this = this;
// var curIndex = _this.__data__.curIndex
// var strSearch = _this.__data__.category[curIndex].name
var city = _this.__data__.city
var entityName = _this.__data__.entityName
var activityType = _this.__data__.activityType
var isHideLoadMore = _this.__data__.isHideLoadMore;
var pageIndex = _this.__data__.pageIndex;
var stride = _this.__data__.stride;
......@@ -161,8 +174,7 @@ Page({
console.log('加载更多')
setTimeout(() => {
_this.getActivities(1, pageIndex, 4, strSearch);
_this.getActivitiesByPeriod(1, pageIndex, stride, city, curDate, endDate);
_this.getActivitiesByPeriod(1, pageIndex, stride, city, entityName, activityType, curDate, endDate);
}, 1000)
var bisHideLoadMoreType = true;
_this.setData({
......@@ -186,10 +198,10 @@ Page({
搜索逻辑:
1. 按照address_name和beginDate, endDate联合查询
*/
getActivitiesByPeriod : function (scrollType, pageNum, pageCount, city, beginDate, endDate) {
getActivitiesByPeriod : function (scrollType, pageNum, pageCount, city, entityName, activityType, beginDate, endDate) {
var _this = this;
var query_url = '&city=' + city + '&beginDate=' + beginDate + '&endDate=' + endDate
var query_url = '&city=' + city + '&title=' + entityName + '&activityType=' + activityType + '&entityName=' + entityName + '&beginDate=' + beginDate + '&endDate=' + endDate
var strUrl = config.activity_period_query_url + "?pageCount=" + pageCount
+ "&pageNum=" + pageNum + query_url
......
<!-- /page/post/edit/edit 添加分类的特点,以及自定义特点 -->
<!-- /page/post/edit/edit 添加分类的特点,以及自定义特点 -->
......@@ -4,13 +4,15 @@
<view class="page" style="height:100%;width:100%">
<view class="weui-search-bar">
<!-- <text>{{city}}</text>
<image src='../../../icon/down.png' style='width: 32rpx;height: 32rpx;' class='selecrtImg'></image> -->
<navigator url="../../switchcity/switchcity?city={{city}}&type=list">
<text>{{city}}</text>
<image src='../../../icon/down.png' style='width: 32rpx;height: 32rpx;' class='selecrtImg'></image>
</navigator>
<block wx:if="{{strSearch!=''}}">
<text>{{strSearch}}</text>
</block>
<block wx:else>
<navigator url="../../switchcity/switchcity?city={{city}}&type=list">
<text>{{city}}</text>
<image src='../../../icon/down.png' style='width: 32rpx;height: 32rpx;' class='selecrtImg'></image>
</navigator>
</block>
<view class="list-activity-number">
<label>
本周活动: {{num_activities-1}}场
......
// pages/activity/activity.js
// pages/activity/activity.js
......@@ -57,18 +57,22 @@ Page({
//二维码信息
qRCodeMsg: "",
//活动类型
activityType: "00-饮事",
},
switchCategory(e) {
var _this = this;
var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
var strCity = _this.__data__.city
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
var strCity = _this.__data__.city
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
var activityType = _this.__data__.activityType
this.setData({
curIndex: curIndex,
})
_this.getActivities(0, 1, 4, strCity, strCategory, strSearch);
_this.getActivities(0, 1, 4, strCity, activityType, strCategory, strSearch);
},
// 搜索点击事件
entrySearch(e) {
......@@ -189,12 +193,13 @@ Page({
var strCity = _this.__data__.city
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
var activityType = _this.__data__.activityType
this.setData({
curIndex: curIndex,
});
app.globalData.switchId = ""
_this.getActivities(0, 1, 4, strCity, strCategory, strSearch);
_this.getActivities(0, 1, 4, strCity, activityType, strCategory, strSearch);
}
......@@ -291,6 +296,8 @@ Page({
var strCity = _this.__data__.city
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
var activityType = _this.__data__.activityType
var isHideLoadMore = _this.__data__.isHideLoadMore;
var pageIndex = _this.__data__.pageIndex;
......@@ -301,7 +308,7 @@ Page({
console.log('加载更多')
setTimeout(() => {
_this.getActivities(1, pageIndex, 4, strCity, strCategory, strSearch);
_this.getActivities(1, pageIndex, 4, strCity, activityType, strCategory, strSearch);
}, 1000)
}
else {
......@@ -328,12 +335,13 @@ 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, strCity, activityType, strCategory, strSearch) {
var _this = this;
// 如果是"推荐"和"搜索",需要单独处理
// '搜索'tab的时候, 需要转换为搜索的关键词(_this.__data__.strSearch)
var query_url = '&title=' + strSearch + '&orderType=' + strCategory + '&city=' + strCity
+ '&activityType=' + activityType
var strUrl = config.activity_query_url + "?pageCount=" + pageCount
+ "&pageNum=" + pageNum + query_url
......@@ -438,6 +446,7 @@ Page({
var curIndex = _this.__data__.curIndex
var strCity = _this.__data__.city
var strCategory = _this.__data__.category[curIndex].order
var activityType = _this.__data__.activityType
var strSearch = ""
this.setData({
......@@ -445,7 +454,7 @@ Page({
inputShowed: false,
});
_this.getActivities(0, 1, 4, strCity, strCategory, strSearch);
_this.getActivities(0, 1, 4, strCity, activityType, strCategory, strSearch);
},
// * 删除输入字符串
......@@ -462,8 +471,9 @@ Page({
var curIndex = _this.__data__.curIndex
var strCity = _this.__data__.city
var strCategory = _this.__data__.category[curIndex].order
var activityType = _this.__data__.activityType
console.log("===input search text_" + strSearch)
_this.getActivities(0, 1, 4, strCity, strCategory, strSearch);
_this.getActivities(0, 1, 4, strCity, activityType, strCategory, strSearch);
_this.setData({
strSearch: strSearch,
......@@ -597,7 +607,8 @@ Page({
var curIndex = _this.__data__.curIndex
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
_this.getActivities(0, 1, 4, strCity, strCategory, strSearch);
var activityType = _this.__data__.activityType
_this.getActivities(0, 1, 4, strCity, activityType, strCategory, strSearch);
},
......
<wxs module="tutil" src="./../../utils/date.wxs"></wxs>
<wxs module="tutil" src="./../../utils/date.wxs"></wxs>
......@@ -67,7 +67,7 @@
<navigator url="/pages/my/my-orders/my-orders">
<image src="../../icon/activity/order.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
</navigator>
<text>我的预订</text>
<text style="font-size:28rpx;">我的预订</text>
</view>
</view>
......
// pages/activity/activity.js
// pages/activity/activity.js
const app = getApp()
var config = wx.getStorageSync("config");
var util = require('./../../utils/util.js')
var event = require('./../../utils/event.js')
//const { globalData: { defaultCity, defaultCounty } } = app
Page({
/**
* 页面的初始数据
*/
data: {
/* 用户信息及商家信息 */
nyxCode : "",
authStatus : "", // 授权状态: 00-未授权, 01-已授权
userInfo : {},
members : "", // 商家信息
member : {},
city: "",
county: "",
category: [ // 导航栏内容数据
{ name: '点赞', order : 'like' },
{ name: '价格', order : 'price' },
{ name: '最新', order : 'nearest' },
],
curIndex: 0, // 给选中的tab加粗
activities: [],
// {
// note_image: [ "https://1.jpg", "https://2.jpg"],
// title: "一天",
// like: 10,
// writer_name: "无敌花木兰",
// writer_image: "../../icon/icon_avatar3.png"
// },
//分页加载部分
isHideLoadMore: false,
pageIndex: 1, //分页搜索的page index
//页面格式
deviceRatio: 1,
navHeight: 0,
searchHeight: 0,
noteTop: 0,
noteHeight: 0,
//搜索模块
inputShowed: false, //初始文本框不显示内容
strSearch : "", //搜索的title字串
strAddress : "思南公馆", //搜索的address字串
inputVal : "", //输入字符串,主要用于页面显示
//二维码信息
qRCodeMsg: "",
//园区
activityType: "02-园区",
entities: [], //包括fair和community
/*
集市/园区所在的信息
fair_name, community_name, num_activity, num_like
*/
entityInfos: {},
curEntity: 0,
},
switchCategory(e) {
var _this = this;
var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
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: curIndex,
})
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
},
// 搜索点击事件
entrySearch(e) {
wx.navigateTo({
url: '../index/searchbar/searchbar',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this = this;
//入口页面,先确定nyxCode
/*step1 先确定用户信息 -- global page 需求 */
var nyxCode = wx.getStorageSync('nyxCode');
//step2 确定城市信息 -- local page 需求
var LatestCityList = wx.getStorageSync('LatestCityList') || []
if( LatestCityList.length > 0 )
{
var city = LatestCityList[0]["city"]
app.globalData.defaultCity = city
_this.setData({ city })
}
else
{
var city = app.globalData.defaultCity
_this.setData({ city })
}
//不存在
if (!nyxCode)
{
//注册新用户
console.log("===onLoad_regUser")
wx.clearStorageSync('nyxCode');
var nyxCode = "uid_" + util.wxuuid()
wx.setStorageSync('nyxCode', nyxCode);
app.globalData.nyxCode = nyxCode;
app.regUser(nyxCode); // nyxCode, userInfo, authStatus: storage, globalData
}
else //存在
{
//初始化数据
_this.setData({
nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'),
members : wx.getStorageSync('members'),
})
//更新用户信息
var strUrl = config.userinfo_query_url + "?userid=" + nyxCode
wx.setStorageSync('nyxCode', nyxCode);
app.globalData.nyxCode = nyxCode;
config.debug == 1 ? console.log("===getLatestUserInfo strUrl_" + strUrl) : 1
getData(strUrl, "").then(res => {
console.log(res.data)
if(res.data.length==0) //数据库不存在该用户(误删除或者测试数据已删除)
{
//以该id注册新用户
console.log("===onLoad_Update User Info")
app.regUser(nyxCode);
}
else
{
var list = res.data[0]
app.globalData.nyxCode = nyxCode;
wx.setStorageSync('nyxCode', nyxCode);
app.globalData.userInfo = list
wx.setStorageSync('userInfo', list)
console.log("==onLoad_userInfo success")
}
})
}
// step3 确定member信息, 写入 data.members
let promise_member = new Promise(function (resolve, reject) {
app.getMembers(0, 1, 20, resolve, reject);
})
promise_member.then(
function (value){
var members = wx.getStorageSync('members')
var member = wx.getStorageSync('member')
_this.setData({ member, members})
console.log("===enter promise_member then_passed_" + value)
},
function (value){
console.log("===enter promise_member then_failed_" + value)
},
);
// step4 数据载入页面, 初始化 - global page
// 初始载入'我已收藏'的清单, 存入storage
wx.setStorageSync('likeDictStorage', {})
let promise_like = new Promise(function (resolve, reject) {
app.getCollectsStorage(0, 1, 100, resolve, reject);
})
promise_like.then(
function (value){
console.log("===enter promise_like then_passed_" + value)
},
function (value){
console.log("===enter promise_like then_failed_" + value)
}
)
// step5 new add jscat 20201008 载入园区列表 - local page
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)
}
)
// 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']
var activities = _this.__data__.activities;
for(var i=0; i< activities.length; i++)
{
if(activity_id == activities[i]['activity_id'])
{
activities[i]['num_like'] = num_like
}
}
_this.setData({
activities: activities,
})
})
// step8 窗口初始化
var device = wx.getSystemInfoSync()
//self.device = app.globalData.myDevice
// jscat miniprogram default width is 750rpx
var deviceRatio = device.windowWidth / 750
var winWidth = device.windowWidth * deviceRatio
var noteHeight = device.windowHeight - (40 - 60)
_this.setData({
searchHeight: 40,
navHeight: 40,
noteTop : (40+40),
noteHeight: noteHeight,
deviceRatio: deviceRatio,
})
wx.setNavigationBarTitle({
title: '园区活动',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
var _this = this;
const { globalData: { defaultCity, defaultCounty } } = app
this.setData({
city: defaultCity,
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
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
event.remove('LikeChanged', this);
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log('页面上拉触底')
var _this = this;
var curIndex = _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
var isHideLoadMore = _this.__data__.isHideLoadMore;
var pageIndex = _this.__data__.pageIndex;
//控制逻辑, 下拉更新操作
//判断是否已经全部加载完毕
//没有则加载更多
if (!isHideLoadMore) {
console.log('加载更多')
setTimeout(() => {
_this.getActivities(1, pageIndex, 4, strAddress, strEntity, strCategory, strSearch);
}, 1000)
}
else {
console.log('没有更多')
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
/**
* 用户自定义函数
*
*/
// 获取Activities数据
// scrollType: 是否是翻页
/*
搜索逻辑:
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, 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
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 bisHideLoadMoreType = false;
if (res.data.data.length < pageCount) {
bisHideLoadMoreType = true;
}
for (var i = 0; i < res.data.data.length; i++) {
var index_id = i + _this.__data__.activities.length
var result = {}
result["activity_id"] = res.data.data[i].activityId
result["member_name"] = res.data.data[i].memberName
result["member_slogan"] = res.data.data[i].memberSlogan
result["member_id"] = res.data.data[i].memberId
result["member_status"] = res.data.data[i].memberStatus
result["member_logo"] = res.data.data[i].memberLogo
result["tag"] = res.data.data[i].tag
result["title"] = res.data.data[i].title
result["num_like"] = res.data.data[i].numLike
result["content"] = res.data.data[i].content
result["quiz"] = res.data.data[i].quiz
result["point"] = res.data.data[i].point
result["address_name"] = res.data.data[i].addressName
result["product_desc"] = res.data.data[i].productDesc
result["unit_price"] = res.data.data[i].unitPrice.toFixed(2)
result["note_image"] = res.data.data[i].noteImage.split("::")
var start_datetime = res.data.data[i].startDatetime
var end_datetime = res.data.data[i].endDatetime
result["start_datetime"] = start_datetime
result["end_datetime"] = end_datetime
var url_quiz = "../activity/quiz-info/quiz-info?"
+"activity_id="+result["activity_id"]
+"&index_id="+index_id
+"&note_image="+res.data.data[i].noteImage //传递原始string数据, List不正确
+"&title="+result["title"]
+"&content="+result["content"]
+"&quiz="+result["quiz"]
+"&point="+result["point"]
+"&member_id="+result["member_id"]
+"&member_name="+result["member_name"]
+"&member_slogan="+result["member_slogan"]
+"&member_logo="+result["member_logo"]
var url_activity = "../activity/activity-info/activity-info?"
+"activity_id="+result["activity_id"]
+"&index_id="+index_id
+"&note_image="+res.data.data[i].noteImage //传递原始string数据, List不正确
+"&title="+result["title"]
+"&content="+result["content"]
+"&address_name="+result["address_name"]
+"&unit_price="+result["unit_price"]
+"&product_desc="+result["product_desc"]
+"&member_id="+result["member_id"]
+"&member_name="+result["member_name"]
+"&member_slogan="+result["member_slogan"]
+"&member_logo="+result["member_logo"]
+"&start_datetime="+result["start_datetime"]
+"&end_datetime="+result["end_datetime"]
result["url"] = result["tag"]=='竞答'? url_quiz : url_activity
list.push(result)
}
//进行翻页设置(加载更多)
if (scrollType == 1) {
var activitiesList = _this.__data__.activities;
list = activitiesList.concat(list)
}
_this.setData({
activities: list,
pageIndex: pageNum + 1,
isHideLoadMore: bisHideLoadMoreType,
})
}
}
})
},
/* 搜索模块 */
// 使文本框进入可编辑状态
showInput: function () {
this.setData({
inputShowed: true //设置文本框可以输入内容
});
},
// 取消搜索
hideInput: function () {
var _this = this;
var curIndex = _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.setData({
strSearch: strSearch,
inputShowed: false,
});
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
},
// * 删除输入字符串
clearInput: function(){
this.setData({
inputVal: "",
});
},
// 开始搜索
startSearch: function (e) {
var _this = this;
var strSearch = e.detail.value
var curIndex = _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
console.log("===input search text_" + strSearch)
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
_this.setData({
strSearch: strSearch,
inputVal: strSearch,
})
},
/*
二维码信息:
1. 二维码生成: https://cli.im/
2. 二维码返回值:
charSet: "UTF-8"
errMsg: "scanCode:ok"
rawData: "b2hsa3cgaXMgYSBwaWc="
result: "ohlkw is a pig"
scanType: "QR_CODE"
二维码流程:
1. 生成流程:
1) user答完一个quiz,会生成一条记录tbl_match,
记录了如下参数:
- match_id: matchid_123
- member_id: memid_001
- user_id: uid_456
- 积分使用状态match_status(可用|不可用): 1|0
- 积分值match_point: 4.5
- 答题结果match_result: 9/10
- 答题时间create_datetime: 2020/07/30 12:00:00
- 更新时间update_datetime: 2020/07/30 12:00:00
- 积分时效状态(有效|无效)(暂不实现)
2. 扫码流程; javaapp只负责获取数据; weapp负责解析数据
1) 扫码获取记录id,发给服务器后台,
msg:
- "成功", 如果 存在 && 未使用,则置为 "已使用", match_id && match_status='01'
{
"resultCode": "200",
"totalCount": 1,
"resultMsg": "OK",
"data": [
{
"matchId": "mid_002",
"matchStatus": "01",
}
]
}
- "失败, 已使用二维码", 如果 存在 && 已使用, match_id && match_status='00'
{
"resultCode": "200",
"totalCount": 1,
"resultMsg": "OK",
"data": [
{
"matchId": "mid_001",
"matchStatus": "00",
}
]
}
- "失败, 无效二维码", 未查询到 !match_id
{
"resultCode": "200",
"totalCount": 0,
"resultMsg": "OK",
"data": []
}
*/
getQRCode: function(){
var _this = this;
wx.scanCode({ //扫描API
success: function(res){
console.log(res); //输出回调信息
_this.checkQRCode(res.result)
}
})
},
checkQRCode(qrcode_string){
var _this = this;
var strUrl = config.match_query_then_update_url + "?matchId="+qrcode_string
config.debug == 1?console.log("===checkQRCode strUrl "+strUrl):""
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if ( res.data.resultCode == 200 ) {
//表示query成功
console.log("qrcode查询完成");
console.log(res)
//得到matchId
var matchList = res.data.data;
var title = ""
if(matchList.length == 0)
{
title = "失败, 无效"
}
else if( matchList[0].matchStatus == '00' )
{
title = "失败,已使用"
}
else if( matchList[0].matchStatus == '01' )
{
title = "扫码成功"
}
console.log("title="+title)
wx.showToast({
title: title,
duration: 3000
})
}
},
fail : function(res)
{
console.log("failed")
}
})
},
// 刷新页面数据
// used by switchcity.js
onUpdateData: function(){
var _this = this;
var curIndex = _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
console.log("===input search text_" + strSearch)
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
},
/*
* 更换某一个memberInfo的地址信息
*/
onEntityPicker: function (e) {
var _this = this;
var curEntity = e.detail.value
var switchId = app.globalData.switchId
var curIndex = switchId != ""? switchId : _this.__data__.curIndex
var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.entities[curEntity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = ""
this.setData({
curIndex, curEntity, strSearch
});
app.globalData.switchId = ""
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);
}
},
})
//通过Promise方式为wx.request添加同步操作
const getData = (url, param) => {
return new Promise((resolve, reject) => {
wx.request({
url: url,
method: 'GET',
data: param,
success(res) {
resolve(res.data)
},
fail(err) {
reject(err)
}
})
})
}
{
{
"usingComponents": {}
}
\ No newline at end of file
<wxs module="tutil" src="./../../utils/date.wxs"></wxs>
<wxs module="tutil" src="./../../utils/date.wxs"></wxs>
<view class="page">
<!-- 搜索框 -->
<!--refer https://blog.csdn.net/weixin_44022446/article/details/86438015 -->
<!-- 2020/07/17 jscat 微信小程序城市选择及搜索功能的方法-->
<!-- refer https://www.jb51.net/article/158292.htm -->
<!-- refer https://github.com/cinoliu/-selectCity -->
<view class="weui-search-bar">
<picker mode="selector" range="{{entities}}" value="{{curEntity}}" bindchange="onEntityPicker" class='address_member'>
<text>{{tutil.formatSubString(entities[curEntity],7)}}</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="发现{{entities[curEntity]}}" 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">发现{{tutil.formatSubString(entities[curEntity],7)}}·感兴趣的活动</view>
</label>
</view>
<view class="weui-search-bar__cancel-btn" hidden="{{!inputShowed}}" bindtap="hideInput">取消
</view>
</view>
<view class="workbench">
<view class="list">
<!-- jscat todo 0828 以用户为主, 扫一扫暂时也不实现 -->
<!-- <view class="items">
<view bindtap="getQRCode">
<image src="../../icon/activity/scan.png"></image>
</view>
<text>扫一扫</text>
</view> -->
<!-- todo 0820 以活动为主, 积分暂时也不实现 -->
<!-- <view class="items">
<navigator url="/pages/my/my-points/my-points">
<image src="../../icon/activity/points.png"></image>
</navigator>
<text>积分</text>
</view> -->
<!-- todo 0728 热销暂时也不实现 -->
<!-- jscat20200816 添加活动日历 for convinience -->
<block>
<view class="items">
<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>
<text style="font-size:28rpx;">本周活动: {{entityInfos[curEntity].num_activity}}场</text>
</navigator>
</view>
</block>
<block wx:if="{{entityInfos[curEntity].num_entity > 1}}">
<view class="items">
<image src="../../icon/community/community.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
<text style="font-size:28rpx;">园区: {{entityInfos[curEntity].num_entity}}个</text>
</view>
</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 class="navBar" >
<scroll-view class="navBar-box" scroll-x="true" style="white-space: nowrap; display:flex ">
<view class="cate-list {{curIndex==index?'on':''}}" wx:for="{{category}}"
wx:key="{{item.id}}" data-id="{{item.id}}" data-index="{{index}}"
bindtap="switchCategory">{{item.name}}</view>
</scroll-view>
</view>
<!-- 文章列表 -->
<!--
title
unit_price
date
like
member_name 进店 >
-->
<!-- Content: refer to 有品·优惠券 + 点评(可使用) -->
<view class="coupon-list" wx:for="{{activities}}" wx:for-item="item" wx:key="{{index}}">
<view class="item stamp stamp01" style="192rpx;">
<!-- 商品信息 -->
<view class="note-row">
<navigator url='{{item.url}}&num_like={{item.num_like}}' >
<image class="writer-image" src="{{item.note_image[0]}}"/>
</navigator>
<view class="note-column">
<navigator url='{{item.url}}&num_like={{item.num_like}}' >
<!-- 商家信息 -->
<text>{{item.title}}</text>
<!-- 商品价格 -->
<span>
<view class="price-row">
<view class="sub-price">¥{{item.unit_price}}</view>
</view>
</span>
<!-- 活动日期 -->
<span class="desc">
{{tutil.formatDate_mdw_interval(item.start_datetime, item.end_datetime)}}
</span>
</navigator>
<!-- 活动点赞 -->
<!-- <span>{{tutil.formatNumberLike(item.num_like)}}</span> -->
<!-- 商家名称 -->
<view class="note-row align">
<view class="desc-member-left">{{item.member_name}}</view>
<!-- todo 店铺功能尚未实现 -->
<!-- <view class="desc-member-right">进店 ></view> -->
</view>
</view>
</view>
</view>
</view>
<!-- 加载更多 -->
<view class="weui-loadmore" hidden="{{isHideLoadMore}}">
<view class="weui-loading"></view>
<view class="weui-loadmore__tips">正在加载</view>
</view>
<view class="weui-loadmore" hidden="{{!isHideLoadMore}}">
<view class="weui-loadmore__tips">没有更多啦 {{'>'}}_{{'<'}} </view>
</view>
</view>
/*
/*
height: 100vh; 相对于视口(Layout Viewport)的高度; 视口被均分为100单位的vh
border-radius: 30px; 设置元素的外边框圆角
position: relative; 相对位置
em: 默认文字大小是16px, font-size: 16px; em是一个相对的大小; 1em=1*16=16px
结构: position -> margin -> ( border -> padding -> input )
position: 定位原则:子绝父相; absolute,绝对;relative,相对;fixed,固定,比如搜索框
display: inline 行内元素 不带空格 block 块级元素 带空格
margin: 上右下左 top right bottom :left
*/
.page{
/*height:100vh; 相对于视口(Layout Viewport)的高度; 视口被均分为100单位的vh */
background-color:#f5f8fa;
}
/* start of navbar navBar -> navBar-box -> cate-list -> cate-list.on */
.navBar{
height: 60rpx;
background: #fff;
border-top: 1px solid #fafafa;
}
.navBar-box{
width: 100%;
height: 60rpx;
}
.cate-list{
display: inline;
margin: 15rpx 22rpx;
text-align: center;
font-size: 32rpx;
color: #9d9d9d;
margin-left: 30rpx;
}
.navBar-box .cate-list.on {
color: #000000;
font-weight: bold;
}
/* end of navbar */
.placeholder{
margin: 0px;
text-align: center;
vertical-align: middle;
line-height: 2.3em;
color: rgba(0,0,0);
}
/* justify-content: center;(水平居中) align-items: center;(垂直居中) */
.justify{
justify-content: center;
}
.align{
align-items: center;
}
.border{
border: 3rpx solid #ccc;
border-radius: 0rpx;
padding: 10rpx;
}
.text{
font-size: 34rpx;
}
.selected{
color: #ff0000;
}
/* coupon css */
.coupon-list{width: 100%; margin: 0 auto}
.coupon-list .item{width: 100%; height: 300rpx;}
.coupon-list .item .float-li{width: 100%; height: 100%; border-right: 2rpx dashed rgba(255,255,255,.3)}
.coupon-list .item .float-li-right{width: 220rpx; padding-right: 20rpx; height:100%; color: #fff}
.coupon-left{position: relative}
.coupon-left .t{position: absolute; color: #fff}
.coupon-left .t1{width: 710rpx; display: flex; margin-left: 20rpx; margin-top: 20rpx; height: 160rpx; color: #fff}
.coupon-left .t1-left{width: 160rpx; font-size: 70rpx; font-weight: bold}
.coupon-left .t1-right{width: 520rpx; font-size: 50rpx; }
/* .coupon-left .t2{left: 20rpx; top:160rpx} */
.coupon-left .t2{width: 710rpx; display: flex; margin-left: 20rpx; margin-top: 0rpx; height: 50rpx; color: #fff}
.coupon-left .t2-left{width: 520rpx; }
.coupon-left .t2-right{width: 160rpx;}
.coupon-left .t3{width: 710rpx; display: flex; margin-left: 20rpx; margin-top: 0rpx; height: 50rpx; color: #fff}
.coupon-left .t3-left{width: 520rpx; }
.coupon-left .t3-right{width: 160rpx;}
.coupon-left .t3-right image{
width: 40rpx;
height: 40rpx;
font-size: 0;
}
.coupon-left .t4{width: 710rpx; display: flex; margin-left: 20rpx; margin-top: 0rpx; height: 50rpx; color: #fff}
.coupon-left .t4-left{width: 520rpx; }
.coupon-left .t4-right{width: 160rpx;}
.coupon-left .t4-right image{
width: 40rpx;
height: 40rpx;
font-size: 0;
}
.coupon-right .t{text-align: center}
.coupon-right .t1{font-size: 40rpx; padding: 30rpx 0 10rpx 0;}
.coupon-right .t3{padding-top:20rpx}
.coupon-right .t3 text{background: #fff; color: #333; border-radius: 7rpx; padding: 10rpx 40rpx}
.note{background: #faeab7}
.stamp{position:relative;overflow:hidden}
.stamp i{position: absolute;left: 20%;top: 90rpx;height: 500rpx;width: 700rpx;background-color: rgba(255,255,255,.15);transform: rotate(-30deg);
}
.stamp01{background:radial-gradient(rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 30rpx, #F39B00 30rpx);background-size:10rpx 10rpx;background-position:9rpx 3rpx; background: #FFFFFF}
/* 失效样式 */
.stamp06{background:radial-gradient(rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 30rpx, #e2e2e2 30rpx);background-size:10rpx 10rpx;background-position:9rpx 3rpx; background: #acacac
}
/* start - 小程序自定义弹框css */
/* 遮罩层 */
.mask{
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background: #000;
z-index: 9000;
opacity: 0.5;
}
/* 弹出层 */
.modalDlg{
width: 80%;
height: 540rpx;
position: fixed;
top: 240rpx;
left: 0;
right: 0;
z-index: 9999;
margin: 0 auto;
background-color: #fff;
border-radius:5px;
display: flex;
flex-direction: column;
align-items: center;
}
/* 弹出层里面的图片 */
/* 弹出层里面的文字 */
.title{
display: flex;
font-size: 38rpx;
color: #cccccc;
width: 80%;
height: 80rpx;
padding: 20rpx;
align-items: center;
justify-content: center;
}
.title-right{
display: flex;
height: 80rpx;
position: absolute;
align-items: center;
text-align: right;
font-size: 38rpx;
color: #cccccc;
padding: 20rpx;
right: 20rpx;
}
.title-right image{
width: 50rpx;
height: 50rpx;
font-size: 0;
}
/* 图片+文字 */
.weui-width{
width: 80%;
}
.placeholder-modal{
margin: 0px;
text-align: center;
vertical-align: middle;
line-height: 2.3em;
background-color: #fff;
}
/* 好友助力积分列表 */
.list-point{
width: 100%;
height: 2rpx;
background: #ccc;
font-size: 32rpx;
display: flex;
flex-direction: column;
/* align-items: center; */
left: 40rpx;
}
.list-point .text{
margin-left: 160rpx;
}
.title-right image{
width: 50rpx;
height: 50rpx;
font-size: 0;
}
/* barcode券码查看 */
.list-barcode{
width: 100%;
height: 2rpx;
background: #ccc;
font-size: 32rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.list-barcode .text{
align-items: center;
margin-left: 20rpx;
}
.list-barcode image{
overflow: visible;
width: 300rpx;
height: 300rpx;
}
/* 弹出层里面的按钮 */
.ok{
width: 100%;
height: 2rpx;
background: #ccc;
text-align: center;
font-size: 38rpx;
color: #666666;
}
/* end - 小程序自定义弹框css */
/* start 加载更多 */
.weui-loading {
margin: 0 5px;
width: 20px;
height: 20px;
display: inline-block;
vertical-align: middle;
-webkit-animation: weuiLoading 1s steps(12, end) infinite;
animation: weuiLoading 1s steps(12, end) infinite;
background: transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat;
background-size: 100%;
}
.weui-loadmore {
width: 65%;
margin: 1.5em auto;
line-height: 1.6em;
font-size: 14px;
text-align: center;
}
.weui-loadmore__tips {
display: inline-block;
vertical-align: middle;
}
/* end 加载更多*/
.note-info{
width: 100%;
/* position: fixed; */
border-radius: 5rpx;
float: left;
margin-top: 20rpx;
margin-bottom: 20rpx;
}
.note-member{
display: flex;
font-size: 32rpx;
margin-left: 5%;
margin-right: 5%;
margin-top: 0;
text-align:justify;
vertical-align: center;
}
.note-member .member-left{width: 520rpx; flex:1}
.note-member .member-right{width: 160rpx;justify-content: flex-end;display: flex;}
.note-member .member-right image{
width: 60rpx;
height: 60rpx;
font-size: 0;
}
.note-price{
color: #FF6600;
font-size: 16px;
margin-left: 5%;
margin-right: 5%;
margin-top: 0;
text-align:justify;
}
.note-content{
font-size: 16px;
/* 后期用于 '展开' 功能 */
/* overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical; */
margin-left: 5%;
margin-right: 4%;
margin-top: 20rpx;
text-align:justify;
}
.note-row{
width: 100%;
display: flex;
flex-direction: row;
}
.note-column{
display: flex;
flex-direction: column;
margin-left: 30rpx;
margin-right: 30rpx;
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;
margin-left: 30rpx;
margin-top: 10rpx;
}
.price-row{
display: flex;
flex-direction: row;
}
.sub-price{
color: #FF6600;
font-size: 34rpx;
margin-right: 5%;
margin-top: 0;
text-align:justify;
flex: 1;
font-weight: bold;
}
.sub-quantity{
display: flex;
font-size: 16px;
justify-content: flex-end;
}
/* refer to jd */
.desc {
font-size: 30rpx;
color: #a7a7a7;
}
.desc-member-left {
font-size: 30rpx;
color: #a7a7a7;
margin-right: 20rpx;
}
.desc-member-right {
font-size: 30rpx;
}
/* start of workbench*/
.workbench{
font-size: 32rpx;
background: #fff;
padding-bottom: 10rpx;
margin-bottom:10rpx;
padding-top: 5rpx;
margin-top:5rpx;
color: #333;
}
.workbench .title{
font-size: 32rpx;
padding: 20rpx 20rpx;
margin-bottom: 40rpx;
display: block;
}
.workbench .items{
width: 100rpx;
flex:1;
text-align: center;
}
.workbench .items image{
width: 60rpx;
height: 60rpx;
}
.workbench .items image.service-icon{
width: 50rpx;
height: 50rpx;
}
.workbench .items text{
display: block;
text-align: center;
margin-top: 0rpx;
margin-bottom: 0rpx;
}
.workbench .items text.top{
display: block;
text-align: center;
margin-bottom: 0rpx;
}
.workbench .items text.bottom{
display: block;
text-align: center;
margin-top: 0rpx;
}
.workbench .list{
display: flex;
flex-direction: row;
flex:1;
}
/* end of workbench*/
// pages/activity/activity.js
// pages/activity/activity.js
const app = getApp()
var config = wx.getStorageSync("config");
var util = require('./../../utils/util.js')
var event = require('./../../utils/event.js')
//const { globalData: { defaultCity, defaultCounty } } = app
Page({
/**
* 页面的初始数据
*/
data: {
/* 用户信息及商家信息 */
nyxCode : "",
authStatus : "", // 授权状态: 00-未授权, 01-已授权
userInfo : {},
members : "", // 商家信息
member : {},
city: "",
county: "",
category: [ // 导航栏内容数据
{ name: '点赞', order : 'like' },
{ name: '价格', order : 'price' },
{ name: '最新', order : 'nearest' },
],
curIndex: 0, // 给选中的tab加粗
activities: [],
// {
// note_image: [ "https://1.jpg", "https://2.jpg"],
// title: "一天",
// like: 10,
// writer_name: "无敌花木兰",
// writer_image: "../../icon/icon_avatar3.png"
// },
//分页加载部分
isHideLoadMore: false,
pageIndex: 1, //分页搜索的page index
//页面格式
deviceRatio: 1,
navHeight: 0,
searchHeight: 0,
noteTop: 0,
noteHeight: 0,
//搜索模块
inputShowed: false, //初始文本框不显示内容
strSearch : "", //搜索的title字串
strAddress : "思南公馆", //搜索的address字串
inputVal : "", //输入字符串,主要用于页面显示
//二维码信息
qRCodeMsg: "",
//园区
activityType: "01-集市",
entities: [], //包括fair和community
/*
集市/园区所在的信息
fair_name, community_name, num_activity, num_like
*/
entityInfos: {},
curEntity: 0,
},
switchCategory(e) {
var _this = this;
var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
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: curIndex,
})
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
},
// 搜索点击事件
entrySearch(e) {
wx.navigateTo({
url: '../index/searchbar/searchbar',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this = this;
//入口页面,先确定nyxCode
/*step1 先确定用户信息 -- global page 需求 */
var nyxCode = wx.getStorageSync('nyxCode');
//step2 确定城市信息 -- local page 需求
var LatestCityList = wx.getStorageSync('LatestCityList') || []
if( LatestCityList.length > 0 )
{
var city = LatestCityList[0]["city"]
app.globalData.defaultCity = city
_this.setData({ city })
}
else
{
var city = app.globalData.defaultCity
_this.setData({ city })
}
//不存在
if (!nyxCode)
{
//注册新用户
console.log("===onLoad_regUser")
wx.clearStorageSync('nyxCode');
var nyxCode = "uid_" + util.wxuuid()
wx.setStorageSync('nyxCode', nyxCode);
app.globalData.nyxCode = nyxCode;
app.regUser(nyxCode); // nyxCode, userInfo, authStatus: storage, globalData
}
else //存在
{
//初始化数据
_this.setData({
nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'),
members : wx.getStorageSync('members'),
})
//更新用户信息
var strUrl = config.userinfo_query_url + "?userid=" + nyxCode
wx.setStorageSync('nyxCode', nyxCode);
app.globalData.nyxCode = nyxCode;
config.debug == 1 ? console.log("===getLatestUserInfo strUrl_" + strUrl) : 1
getData(strUrl, "").then(res => {
console.log(res.data)
if(res.data.length==0) //数据库不存在该用户(误删除或者测试数据已删除)
{
//以该id注册新用户
console.log("===onLoad_Update User Info")
app.regUser(nyxCode);
}
else
{
var list = res.data[0]
app.globalData.nyxCode = nyxCode;
wx.setStorageSync('nyxCode', nyxCode);
app.globalData.userInfo = list
wx.setStorageSync('userInfo', list)
console.log("==onLoad_userInfo success")
}
})
}
// step3 确定member信息, 写入 data.members
let promise_member = new Promise(function (resolve, reject) {
app.getMembers(0, 1, 20, resolve, reject);
})
promise_member.then(
function (value){
var members = wx.getStorageSync('members')
var member = wx.getStorageSync('member')
_this.setData({ member, members})
console.log("===enter promise_member then_passed_" + value)
},
function (value){
console.log("===enter promise_member then_failed_" + value)
},
);
// step4 数据载入页面, 初始化 - global page
// 初始载入'我已收藏'的清单, 存入storage
wx.setStorageSync('likeDictStorage', {})
let promise_like = new Promise(function (resolve, reject) {
app.getCollectsStorage(0, 1, 100, resolve, reject);
})
promise_like.then(
function (value){
console.log("===enter promise_like then_passed_" + value)
},
function (value){
console.log("===enter promise_like then_failed_" + value)
}
)
// step5 new add jscat 20201008 载入园区列表 - local page
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)
}
)
// 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']
var activities = _this.__data__.activities;
for(var i=0; i< activities.length; i++)
{
if(activity_id == activities[i]['activity_id'])
{
activities[i]['num_like'] = num_like
}
}
_this.setData({
activities: activities,
})
})
// step8 窗口初始化
var device = wx.getSystemInfoSync()
//self.device = app.globalData.myDevice
// jscat miniprogram default width is 750rpx
var deviceRatio = device.windowWidth / 750
var winWidth = device.windowWidth * deviceRatio
var noteHeight = device.windowHeight - (40 - 60)
_this.setData({
searchHeight: 40,
navHeight: 40,
noteTop : (40+40),
noteHeight: noteHeight,
deviceRatio: deviceRatio,
})
wx.setNavigationBarTitle({
title: '集市活动',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
var _this = this;
const { globalData: { defaultCity, defaultCounty } } = app
this.setData({
city: defaultCity,
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
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
event.remove('LikeChanged', this);
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log('页面上拉触底')
var _this = this;
var curIndex = _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
var isHideLoadMore = _this.__data__.isHideLoadMore;
var pageIndex = _this.__data__.pageIndex;
//控制逻辑, 下拉更新操作
//判断是否已经全部加载完毕
//没有则加载更多
if (!isHideLoadMore) {
console.log('加载更多')
setTimeout(() => {
_this.getActivities(1, pageIndex, 4, strAddress, strEntity, strCategory, strSearch);
}, 1000)
}
else {
console.log('没有更多')
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
/**
* 用户自定义函数
*
*/
// 获取Activities数据
// scrollType: 是否是翻页
/*
搜索逻辑:
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, 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
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 bisHideLoadMoreType = false;
if (res.data.data.length < pageCount) {
bisHideLoadMoreType = true;
}
for (var i = 0; i < res.data.data.length; i++) {
var index_id = i + _this.__data__.activities.length
var result = {}
result["activity_id"] = res.data.data[i].activityId
result["member_name"] = res.data.data[i].memberName
result["member_slogan"] = res.data.data[i].memberSlogan
result["member_id"] = res.data.data[i].memberId
result["member_status"] = res.data.data[i].memberStatus
result["member_logo"] = res.data.data[i].memberLogo
result["tag"] = res.data.data[i].tag
result["title"] = res.data.data[i].title
result["num_like"] = res.data.data[i].numLike
result["content"] = res.data.data[i].content
result["quiz"] = res.data.data[i].quiz
result["point"] = res.data.data[i].point
result["address_name"] = res.data.data[i].addressName
result["product_desc"] = res.data.data[i].productDesc
result["unit_price"] = res.data.data[i].unitPrice.toFixed(2)
result["note_image"] = res.data.data[i].noteImage.split("::")
var start_datetime = res.data.data[i].startDatetime
var end_datetime = res.data.data[i].endDatetime
result["start_datetime"] = start_datetime
result["end_datetime"] = end_datetime
var url_quiz = "../activity/quiz-info/quiz-info?"
+"activity_id="+result["activity_id"]
+"&index_id="+index_id
+"&note_image="+res.data.data[i].noteImage //传递原始string数据, List不正确
+"&title="+result["title"]
+"&content="+result["content"]
+"&quiz="+result["quiz"]
+"&point="+result["point"]
+"&member_id="+result["member_id"]
+"&member_name="+result["member_name"]
+"&member_slogan="+result["member_slogan"]
+"&member_logo="+result["member_logo"]
var url_activity = "../activity/activity-info/activity-info?"
+"activity_id="+result["activity_id"]
+"&index_id="+index_id
+"&note_image="+res.data.data[i].noteImage //传递原始string数据, List不正确
+"&title="+result["title"]
+"&content="+result["content"]
+"&address_name="+result["address_name"]
+"&unit_price="+result["unit_price"]
+"&product_desc="+result["product_desc"]
+"&member_id="+result["member_id"]
+"&member_name="+result["member_name"]
+"&member_slogan="+result["member_slogan"]
+"&member_logo="+result["member_logo"]
+"&start_datetime="+result["start_datetime"]
+"&end_datetime="+result["end_datetime"]
result["url"] = result["tag"]=='竞答'? url_quiz : url_activity
list.push(result)
}
//进行翻页设置(加载更多)
if (scrollType == 1) {
var activitiesList = _this.__data__.activities;
list = activitiesList.concat(list)
}
_this.setData({
activities: list,
pageIndex: pageNum + 1,
isHideLoadMore: bisHideLoadMoreType,
})
}
}
})
},
/* 搜索模块 */
// 使文本框进入可编辑状态
showInput: function () {
this.setData({
inputShowed: true //设置文本框可以输入内容
});
},
// 取消搜索
hideInput: function () {
var _this = this;
var curIndex = _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.setData({
strSearch: strSearch,
inputShowed: false,
});
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
},
// * 删除输入字符串
clearInput: function(){
this.setData({
inputVal: "",
});
},
// 开始搜索
startSearch: function (e) {
var _this = this;
var strSearch = e.detail.value
var curIndex = _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
console.log("===input search text_" + strSearch)
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
_this.setData({
strSearch: strSearch,
inputVal: strSearch,
})
},
/*
二维码信息:
1. 二维码生成: https://cli.im/
2. 二维码返回值:
charSet: "UTF-8"
errMsg: "scanCode:ok"
rawData: "b2hsa3cgaXMgYSBwaWc="
result: "ohlkw is a pig"
scanType: "QR_CODE"
二维码流程:
1. 生成流程:
1) user答完一个quiz,会生成一条记录tbl_match,
记录了如下参数:
- match_id: matchid_123
- member_id: memid_001
- user_id: uid_456
- 积分使用状态match_status(可用|不可用): 1|0
- 积分值match_point: 4.5
- 答题结果match_result: 9/10
- 答题时间create_datetime: 2020/07/30 12:00:00
- 更新时间update_datetime: 2020/07/30 12:00:00
- 积分时效状态(有效|无效)(暂不实现)
2. 扫码流程; javaapp只负责获取数据; weapp负责解析数据
1) 扫码获取记录id,发给服务器后台,
msg:
- "成功", 如果 存在 && 未使用,则置为 "已使用", match_id && match_status='01'
{
"resultCode": "200",
"totalCount": 1,
"resultMsg": "OK",
"data": [
{
"matchId": "mid_002",
"matchStatus": "01",
}
]
}
- "失败, 已使用二维码", 如果 存在 && 已使用, match_id && match_status='00'
{
"resultCode": "200",
"totalCount": 1,
"resultMsg": "OK",
"data": [
{
"matchId": "mid_001",
"matchStatus": "00",
}
]
}
- "失败, 无效二维码", 未查询到 !match_id
{
"resultCode": "200",
"totalCount": 0,
"resultMsg": "OK",
"data": []
}
*/
getQRCode: function(){
var _this = this;
wx.scanCode({ //扫描API
success: function(res){
console.log(res); //输出回调信息
_this.checkQRCode(res.result)
}
})
},
checkQRCode(qrcode_string){
var _this = this;
var strUrl = config.match_query_then_update_url + "?matchId="+qrcode_string
config.debug == 1?console.log("===checkQRCode strUrl "+strUrl):""
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if ( res.data.resultCode == 200 ) {
//表示query成功
console.log("qrcode查询完成");
console.log(res)
//得到matchId
var matchList = res.data.data;
var title = ""
if(matchList.length == 0)
{
title = "失败, 无效"
}
else if( matchList[0].matchStatus == '00' )
{
title = "失败,已使用"
}
else if( matchList[0].matchStatus == '01' )
{
title = "扫码成功"
}
console.log("title="+title)
wx.showToast({
title: title,
duration: 3000
})
}
},
fail : function(res)
{
console.log("failed")
}
})
},
// 刷新页面数据
// used by switchcity.js
onUpdateData: function(){
var _this = this;
var curIndex = _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
console.log("===input search text_" + strSearch)
_this.getActivities(0, 1, 4, strAddress, strEntity, strCategory, strSearch);
},
/*
* 更换某一个memberInfo的地址信息
*/
onEntityPicker: function (e) {
var _this = this;
var curEntity = e.detail.value
var switchId = app.globalData.switchId
var curIndex = switchId != ""? switchId : _this.__data__.curIndex
var strAddress = app.globalData.defaultCity
var strEntity = _this.__data__.entities[curEntity]
var strCategory = _this.__data__.category[curIndex].order
var strSearch = ""
this.setData({
curIndex, curEntity, strSearch
});
app.globalData.switchId = ""
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);
}
},
})
//通过Promise方式为wx.request添加同步操作
const getData = (url, param) => {
return new Promise((resolve, reject) => {
wx.request({
url: url,
method: 'GET',
data: param,
success(res) {
resolve(res.data)
},
fail(err) {
reject(err)
}
})
})
}
{
{
"usingComponents": {}
}
\ No newline at end of file
<wxs module="tutil" src="./../../utils/date.wxs"></wxs>
<wxs module="tutil" src="./../../utils/date.wxs"></wxs>
<view class="page">
<!-- 搜索框 -->
<!--refer https://blog.csdn.net/weixin_44022446/article/details/86438015 -->
<!-- 2020/07/17 jscat 微信小程序城市选择及搜索功能的方法-->
<!-- refer https://www.jb51.net/article/158292.htm -->
<!-- refer https://github.com/cinoliu/-selectCity -->
<view class="weui-search-bar">
<picker mode="selector" range="{{entities}}" value="{{curEntity}}" bindchange="onEntityPicker" class='address_member'>
<text>{{tutil.formatSubString(entities[curEntity],7)}}</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="发现{{tutil.formatSubString(entities[curEntity],7)}}" 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">发现{{tutil.formatSubString(entities[curEntity],7)}}·感兴趣的活动</view>
</label>
</view>
<view class="weui-search-bar__cancel-btn" hidden="{{!inputShowed}}" bindtap="hideInput">取消
</view>
</view>
<view class="workbench">
<view class="list">
<!-- jscat todo 0828 以用户为主, 扫一扫暂时也不实现 -->
<!-- <view class="items">
<view bindtap="getQRCode">
<image src="../../icon/activity/scan.png"></image>
</view>
<text>扫一扫</text>
</view> -->
<!-- todo 0820 以活动为主, 积分暂时也不实现 -->
<!-- <view class="items">
<navigator url="/pages/my/my-points/my-points">
<image src="../../icon/activity/points.png"></image>
</navigator>
<text>积分</text>
</view> -->
<!-- todo 0728 热销暂时也不实现 -->
<!-- jscat20200816 添加活动日历 for convinience -->
<block>
<view class="items">
<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>
<text style="font-size:28rpx;">本周活动: {{entityInfos[curEntity].num_activity}}场</text>
</navigator>
</view>
</block>
<block wx:if="{{entityInfos[curEntity].num_entity > 1}}">
<view class="items">
<image src="../../icon/fair/fair.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
<text style="font-size:28rpx;">集市: {{entityInfos[curEntity].num_entity}}个</text>
</view>
</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 class="navBar" >
<scroll-view class="navBar-box" scroll-x="true" style="white-space: nowrap; display:flex ">
<view class="cate-list {{curIndex==index?'on':''}}" wx:for="{{category}}"
wx:key="{{item.id}}" data-id="{{item.id}}" data-index="{{index}}"
bindtap="switchCategory">{{item.name}}</view>
</scroll-view>
</view>
<!-- 文章列表 -->
<!--
title
unit_price
date
like
member_name 进店 >
-->
<!-- Content: refer to 有品·优惠券 + 点评(可使用) -->
<view class="coupon-list" wx:for="{{activities}}" wx:for-item="item" wx:key="{{index}}">
<view class="item stamp stamp01" style="192rpx;">
<!-- 商品信息 -->
<view class="note-row">
<navigator url='{{item.url}}&num_like={{item.num_like}}' >
<image class="writer-image" src="{{item.note_image[0]}}"/>
</navigator>
<view class="note-column">
<navigator url='{{item.url}}&num_like={{item.num_like}}' >
<!-- 商家信息 -->
<text>{{item.title}}</text>
<!-- 商品价格 -->
<span>
<view class="price-row">
<view class="sub-price">¥{{item.unit_price}}</view>
</view>
</span>
<!-- 活动日期 -->
<span class="desc">
{{tutil.formatDate_mdw_interval(item.start_datetime, item.end_datetime)}}
</span>
</navigator>
<!-- 活动点赞 -->
<!-- <span>{{tutil.formatNumberLike(item.num_like)}}</span> -->
<!-- 商家名称 -->
<view class="note-row align">
<view class="desc-member-left">{{item.member_name}}</view>
<!-- todo 店铺功能尚未实现 -->
<!-- <view class="desc-member-right">进店 ></view> -->
</view>
</view>
</view>
</view>
</view>
<!-- 加载更多 -->
<view class="weui-loadmore" hidden="{{isHideLoadMore}}">
<view class="weui-loading"></view>
<view class="weui-loadmore__tips">正在加载</view>
</view>
<view class="weui-loadmore" hidden="{{!isHideLoadMore}}">
<view class="weui-loadmore__tips">没有更多啦 {{'>'}}_{{'<'}} </view>
</view>
</view>
/*
/*
height: 100vh; 相对于视口(Layout Viewport)的高度; 视口被均分为100单位的vh
border-radius: 30px; 设置元素的外边框圆角
position: relative; 相对位置
em: 默认文字大小是16px, font-size: 16px; em是一个相对的大小; 1em=1*16=16px
结构: position -> margin -> ( border -> padding -> input )
position: 定位原则:子绝父相; absolute,绝对;relative,相对;fixed,固定,比如搜索框
display: inline 行内元素 不带空格 block 块级元素 带空格
margin: 上右下左 top right bottom :left
*/
.page{
/*height:100vh; 相对于视口(Layout Viewport)的高度; 视口被均分为100单位的vh */
background-color:#f5f8fa;
}
/* start of navbar navBar -> navBar-box -> cate-list -> cate-list.on */
.navBar{
height: 60rpx;
background: #fff;
border-top: 1px solid #fafafa;
}
.navBar-box{
width: 100%;
height: 60rpx;
}
.cate-list{
display: inline;
margin: 15rpx 22rpx;
text-align: center;
font-size: 32rpx;
color: #9d9d9d;
margin-left: 30rpx;
}
.navBar-box .cate-list.on {
color: #000000;
font-weight: bold;
}
/* end of navbar */
.placeholder{
margin: 0px;
text-align: center;
vertical-align: middle;
line-height: 2.3em;
color: rgba(0,0,0);
}
/* justify-content: center;(水平居中) align-items: center;(垂直居中) */
.justify{
justify-content: center;
}
.align{
align-items: center;
}
.border{
border: 3rpx solid #ccc;
border-radius: 0rpx;
padding: 10rpx;
}
.text{
font-size: 34rpx;
}
.selected{
color: #ff0000;
}
/* coupon css */
.coupon-list{width: 100%; margin: 0 auto}
.coupon-list .item{width: 100%; height: 300rpx;}
.coupon-list .item .float-li{width: 100%; height: 100%; border-right: 2rpx dashed rgba(255,255,255,.3)}
.coupon-list .item .float-li-right{width: 220rpx; padding-right: 20rpx; height:100%; color: #fff}
.coupon-left{position: relative}
.coupon-left .t{position: absolute; color: #fff}
.coupon-left .t1{width: 710rpx; display: flex; margin-left: 20rpx; margin-top: 20rpx; height: 160rpx; color: #fff}
.coupon-left .t1-left{width: 160rpx; font-size: 70rpx; font-weight: bold}
.coupon-left .t1-right{width: 520rpx; font-size: 50rpx; }
/* .coupon-left .t2{left: 20rpx; top:160rpx} */
.coupon-left .t2{width: 710rpx; display: flex; margin-left: 20rpx; margin-top: 0rpx; height: 50rpx; color: #fff}
.coupon-left .t2-left{width: 520rpx; }
.coupon-left .t2-right{width: 160rpx;}
.coupon-left .t3{width: 710rpx; display: flex; margin-left: 20rpx; margin-top: 0rpx; height: 50rpx; color: #fff}
.coupon-left .t3-left{width: 520rpx; }
.coupon-left .t3-right{width: 160rpx;}
.coupon-left .t3-right image{
width: 40rpx;
height: 40rpx;
font-size: 0;
}
.coupon-left .t4{width: 710rpx; display: flex; margin-left: 20rpx; margin-top: 0rpx; height: 50rpx; color: #fff}
.coupon-left .t4-left{width: 520rpx; }
.coupon-left .t4-right{width: 160rpx;}
.coupon-left .t4-right image{
width: 40rpx;
height: 40rpx;
font-size: 0;
}
.coupon-right .t{text-align: center}
.coupon-right .t1{font-size: 40rpx; padding: 30rpx 0 10rpx 0;}
.coupon-right .t3{padding-top:20rpx}
.coupon-right .t3 text{background: #fff; color: #333; border-radius: 7rpx; padding: 10rpx 40rpx}
.note{background: #faeab7}
.stamp{position:relative;overflow:hidden}
.stamp i{position: absolute;left: 20%;top: 90rpx;height: 500rpx;width: 700rpx;background-color: rgba(255,255,255,.15);transform: rotate(-30deg);
}
.stamp01{background:radial-gradient(rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 30rpx, #F39B00 30rpx);background-size:10rpx 10rpx;background-position:9rpx 3rpx; background: #FFFFFF}
/* 失效样式 */
.stamp06{background:radial-gradient(rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 30rpx, #e2e2e2 30rpx);background-size:10rpx 10rpx;background-position:9rpx 3rpx; background: #acacac
}
/* start - 小程序自定义弹框css */
/* 遮罩层 */
.mask{
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background: #000;
z-index: 9000;
opacity: 0.5;
}
/* 弹出层 */
.modalDlg{
width: 80%;
height: 540rpx;
position: fixed;
top: 240rpx;
left: 0;
right: 0;
z-index: 9999;
margin: 0 auto;
background-color: #fff;
border-radius:5px;
display: flex;
flex-direction: column;
align-items: center;
}
/* 弹出层里面的图片 */
/* 弹出层里面的文字 */
.title{
display: flex;
font-size: 38rpx;
color: #cccccc;
width: 80%;
height: 80rpx;
padding: 20rpx;
align-items: center;
justify-content: center;
}
.title-right{
display: flex;
height: 80rpx;
position: absolute;
align-items: center;
text-align: right;
font-size: 38rpx;
color: #cccccc;
padding: 20rpx;
right: 20rpx;
}
.title-right image{
width: 50rpx;
height: 50rpx;
font-size: 0;
}
/* 图片+文字 */
.weui-width{
width: 80%;
}
.placeholder-modal{
margin: 0px;
text-align: center;
vertical-align: middle;
line-height: 2.3em;
background-color: #fff;
}
/* 好友助力积分列表 */
.list-point{
width: 100%;
height: 2rpx;
background: #ccc;
font-size: 32rpx;
display: flex;
flex-direction: column;
/* align-items: center; */
left: 40rpx;
}
.list-point .text{
margin-left: 160rpx;
}
.title-right image{
width: 50rpx;
height: 50rpx;
font-size: 0;
}
/* barcode券码查看 */
.list-barcode{
width: 100%;
height: 2rpx;
background: #ccc;
font-size: 32rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.list-barcode .text{
align-items: center;
margin-left: 20rpx;
}
.list-barcode image{
overflow: visible;
width: 300rpx;
height: 300rpx;
}
/* 弹出层里面的按钮 */
.ok{
width: 100%;
height: 2rpx;
background: #ccc;
text-align: center;
font-size: 38rpx;
color: #666666;
}
/* end - 小程序自定义弹框css */
/* start 加载更多 */
.weui-loading {
margin: 0 5px;
width: 20px;
height: 20px;
display: inline-block;
vertical-align: middle;
-webkit-animation: weuiLoading 1s steps(12, end) infinite;
animation: weuiLoading 1s steps(12, end) infinite;
background: transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat;
background-size: 100%;
}
.weui-loadmore {
width: 65%;
margin: 1.5em auto;
line-height: 1.6em;
font-size: 14px;
text-align: center;
}
.weui-loadmore__tips {
display: inline-block;
vertical-align: middle;
}
/* end 加载更多*/
.note-info{
width: 100%;
/* position: fixed; */
border-radius: 5rpx;
float: left;
margin-top: 20rpx;
margin-bottom: 20rpx;
}
.note-member{
display: flex;
font-size: 32rpx;
margin-left: 5%;
margin-right: 5%;
margin-top: 0;
text-align:justify;
vertical-align: center;
}
.note-member .member-left{width: 520rpx; flex:1}
.note-member .member-right{width: 160rpx;justify-content: flex-end;display: flex;}
.note-member .member-right image{
width: 60rpx;
height: 60rpx;
font-size: 0;
}
.note-price{
color: #FF6600;
font-size: 16px;
margin-left: 5%;
margin-right: 5%;
margin-top: 0;
text-align:justify;
}
.note-content{
font-size: 16px;
/* 后期用于 '展开' 功能 */
/* overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical; */
margin-left: 5%;
margin-right: 4%;
margin-top: 20rpx;
text-align:justify;
}
.note-row{
width: 100%;
display: flex;
flex-direction: row;
}
.note-column{
display: flex;
flex-direction: column;
margin-left: 30rpx;
margin-right: 30rpx;
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;
margin-left: 30rpx;
margin-top: 10rpx;
}
.price-row{
display: flex;
flex-direction: row;
}
.sub-price{
color: #FF6600;
font-size: 34rpx;
margin-right: 5%;
margin-top: 0;
text-align:justify;
flex: 1;
font-weight: bold;
}
.sub-quantity{
display: flex;
font-size: 16px;
justify-content: flex-end;
}
/* refer to jd */
.desc {
font-size: 30rpx;
color: #a7a7a7;
}
.desc-member-left {
font-size: 30rpx;
color: #a7a7a7;
margin-right: 20rpx;
}
.desc-member-right {
font-size: 30rpx;
}
/* start of workbench*/
.workbench{
font-size: 32rpx;
background: #fff;
padding-bottom: 10rpx;
margin-bottom:10rpx;
padding-top: 5rpx;
margin-top:5rpx;
color: #333;
}
.workbench .title{
font-size: 32rpx;
padding: 20rpx 20rpx;
margin-bottom: 40rpx;
display: block;
}
.workbench .items{
width: 100rpx;
flex:1;
text-align: center;
}
.workbench .items image{
width: 60rpx;
height: 60rpx;
}
.workbench .items image.service-icon{
width: 50rpx;
height: 50rpx;
}
.workbench .items text{
display: block;
text-align: center;
margin-top: 0rpx;
margin-bottom: 0rpx;
}
.workbench .items text.top{
display: block;
text-align: center;
margin-bottom: 0rpx;
}
.workbench .items text.bottom{
display: block;
text-align: center;
margin-top: 0rpx;
}
.workbench .list{
display: flex;
flex-direction: row;
flex:1;
}
/* end of workbench*/
// pages/member/activity-post/activity-edit/activity-edit.js
// pages/member/activity-post/activity-edit/activity-edit.js
......@@ -19,6 +19,12 @@ Page({
attributeArray: ['活动类别', '价格', '库存'],
cbs: [
{name: '', type:'00-饮事', value:'饮事', holder:'饮事活动', checked: false},
{name: '', type:'01-集市', value:'集市', holder:'是否集市?', checked: false},
{name: '', type:'02-园区', value:'园区', holder:'是否园区?', checked: false},
],
},
......@@ -128,13 +134,53 @@ Page({
// 输入该组图片的标签
bindKeyTag(e) {
var _this = this;
_this.setData({
inputTag: e.detail.value
})
//全局赋值
app.globalData.postData.photoTag = e.detail.value
var cbs = _this.data.cbs
//js的e.currentTarget.id 对应wxml的 id="tab0"
//js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0"
var values = parseInt(e.currentTarget.id)
cbs[values].name = e.detail.value
this.setData({ cbs })
app.globalData.postData.photoCbs = cbs;
},
//点击checkbox
radioTap: function(e){
var _this = this
var cbs = _this.data.cbs
//js的e.currentTarget.id 对应wxml的 id="tab0"
//js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0"
var values = parseInt(e.currentTarget.id)
cbs[values].checked = cbs[values].checked == true ? false : true
cbs[values].holder = cbs[values].checked==true?cbs[values].value+'名称?':'是否'+cbs[values].value+'?'
this.setData({ cbs })
app.globalData.postData.photoCbs = cbs;
},
//点击input
inputTap: function(e){
var _this = this
var cbs = _this.data.cbs
//js的e.currentTarget.id 对应wxml的 id="tab0"
//js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0"
var values = parseInt(e.currentTarget.id)
cbs[values].checked = cbs[values].checked == true ? false : true
cbs[values].holder = cbs[values].checked==true?cbs[values].value+'名称?':'是否'+cbs[values].value+'?'
this.setData({ cbs })
app.globalData.postData.photoCbs = cbs;
},
bindKeyText(e){
var _this = this;
//js的e.currentTarget.id 对应wxml的 id="0"
......@@ -218,29 +264,46 @@ Page({
function checkField(){
var info = ""
//step1: 检查活动类别字段
var products = app.globalData.postData.photoProduct
for(var i=0; i<products.length; i++)
{
if(products[i].productDesc==undefined || products[i].productDesc=="")
{
info = "请输入第"+ i +"项活动类别"
wx.showModal({
content: info,
showCancel: false,
confirmText: '确认'
})
return false;
}
}
if(app.globalData.postData.photoTitle.length == 0)
//step2: 检查活动类型字段
var cbs = app.globalData.postData.photoCbs
//从1开始,因为'饮事'无需输入
for(var i=1; i<cbs.length; i++)
{
info = "请输入活动标题"
wx.showModal({
content: info,
showCancel: false,
confirmText: '确认'
})
return false;
//选中了checkbox, 然后没有类型
if(cbs[i].checked == true && cbs[i].name == "")
{
info = "请输入"+ cbs[i].value +"名称"
wx.showModal({
content: info,
showCancel: false,
confirmText: '确认'
})
return false;
}
}
else if(info!="")
//step3: 检查活动标题
if(app.globalData.postData.photoTitle.length == 0)
{
info = "请输入活动标题"
wx.showModal({
content: info,
showCancel: false,
......
<!-- /page/post/edit/edit 添加分类的特点,以及自定义特点 -->
<!-- /page/post/edit/edit 添加分类的特点,以及自定义特点 -->
......@@ -13,14 +13,35 @@
</view>
</view>
<!-- <view class="weui-cells__title">#添加亮点</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell ">
<view class="weui-cell__bd">
<input class="weui-input" bindinput="bindKeyTag" placeholder="请输入亮点" />
</view>
</view>
</view> -->
<view class="weui-cells__title">#添加活动类型</view>
<view class="weui-cells weui-cells_after-title" style="font-size:30rpx;">
<view style="display:flex; flex-direction: row;">
<label class="weui-cell" style="padding-right:6px;">
<view class="weui-cell__hd">
<checkbox value="0" id="0" checked="{{cbs[0].checked}}" bindtap="radioTap"/>
</view>
<view class="weui-cell__bd {{cbs[0].checked==false?'.check-box-off':''}}" style="width:120rpx" id="0" bindtap="inputTap">
饮事活动
</view>
</label>
<label class="weui-cell" style="padding-left:6px;padding-right:6px;">
<view class="weui-cell__hd">
<checkbox value="1" id="1" checked="{{cbs[1].checked}}" bindtap="radioTap"/>
</view>
<view class="weui-cell__bd {{cbs[1].checked==false?'.check-box-off':''}}">
<input class="weui-input" id="1" bindtap="inputTap" bindinput="bindKeyTag" placeholder="{{cbs[1].holder}}" value="{{cbs[1].name}}"/>
</view>
</label>
<label class="weui-cell" style="padding-left:6px;padding-right:6px;">
<view class="weui-cell__hd">
<checkbox value="2" id="2" checked="{{cbs[2].checked}}" bindtap="radioTap"/>
</view>
<view class="weui-cell__bd {{cbs[2].checked==false?'.check-box-off':''}}">
<input class="weui-input" id="2" bindtap="inputTap" bindinput="bindKeyTag" placeholder="{{cbs[2].holder}}" value="{{cbs[2].name}}"/>
</view>
</label>
</view>
</view>
<view style="display:flex; flex-direction: row;">
<view class="section" style="background: #fff;margin-top:32rpx;padding:32rpx;width:55%">
......
page{
page{
......@@ -91,4 +91,8 @@ page{
color: rgba(55, 134, 244, 1);
width: 100%;
word-break: normal;
}
\ No newline at end of file
}
.check-box-off {
color:rgba(0,0,0,0.6);
}
// pages/member/activity-post/activity-submit/activity-submit.js
// pages/member/activity-post/activity-submit/activity-submit.js
......@@ -332,7 +332,7 @@ Page({
},
success: res => {
if (res.statusCode == 200) {
console.log("=== oss getToken 返回值_", res.data)
console.log("=== oss getToken_" + dir +"_ done", res.data)
var dict = {
accessid: res.data.data.accessid,
policy: res.data.data.policy,
......@@ -388,7 +388,7 @@ Page({
},
//上传照片(阿里云)
uploadAli: function (tag, title, content, photoArr, product, startDatetime, endDatetime) {
uploadAli: function (tag, title, content, photoArr, product, activityType, fairName, communityName,startDatetime, endDatetime) {
var _this = this;
console.log("===uploadAli_data_tag: ",tag)
console.log("===uploadAli_data_title: ",title)
......@@ -447,7 +447,10 @@ Page({
}
var callback_param = {
'callbackUrl': strUrl,
'callbackBody': 'filename=${object}&size=${size}&mimeType=${mimeType}&height=${imageInfo.height}&width=${imageInfo.width}&tag=' + encodeURI(encodeURI(tag)) + '&title=' + encodeURI(encodeURI(title)) + '&content=' + encodeURI(encodeURI(content)) + '&image=' + image + '&userId=' + user_id + '&memberId=' + member_id + '&addressId=' + address_id + encodeURI (encodeURI(strParam)) + '&startDatetime=' + startDatetime + '&endDatetime=' + endDatetime,
'callbackBody': 'filename=${object}&size=${size}&mimeType=${mimeType}&height=${imageInfo.height}&width=${imageInfo.width}&tag=' + encodeURI(encodeURI(tag)) + '&title=' + encodeURI(encodeURI(title)) + '&content=' + encodeURI(encodeURI(content)) + '&image=' + image + '&userId=' + user_id + '&memberId=' + member_id + '&addressId=' + address_id + encodeURI (encodeURI(strParam)) + '&startDatetime=' + startDatetime + '&endDatetime=' + endDatetime
+ '&activityType=' + encodeURI(encodeURI(activityType))
+ '&fairName=' + encodeURI(encodeURI(fairName))
+ '&communityName=' + encodeURI(encodeURI(communityName)),
'callbackBodyType': "application/x-www-form-urlencoded",
}
var base64_callback_body = base64.encode(JSON.stringify(callback_param));
......@@ -490,8 +493,23 @@ Page({
var photoArr = app.globalData.postData.photoArray;
var tag = app.globalData.postData.photoTag
var product = app.globalData.postData.photoProduct
var cbs = app.globalData.postData.photoCbs
var startDatetime = app.globalData.postData.startDatetime
var endDatetime = app.globalData.postData.endDatetime
var list = []
var activityType = ""
var fairName = ""
var communityName = ""
for(var i=0; i<cbs.length; i++)
{
if(cbs[i].checked == true )
{
list.push(cbs[i].type)
}
}
activityType = list.join("::")
fairName = cbs[1].checked == true ? cbs[1].name : ""
communityName = cbs[2].checked == true ? cbs[2].name : ""
//时间戳
var expire = this.data.oss['userToken'].expire;
......@@ -507,13 +525,13 @@ Page({
promise_oss.then(
function (value) {
console.log("===enter promise_oss user_token then_pass")
_this.uploadAli(tag, title, content, photoArr, product, startDatetime, endDatetime)
_this.uploadAli(tag, title, content, photoArr, product, activityType, fairName, communityName, startDatetime, endDatetime)
});
}
else
{
_this.uploadAli(tag, title, content, photoArr, product, startDatetime, endDatetime)
_this.uploadAli(tag, title, content, photoArr, product, activityType, fairName, communityName,startDatetime, endDatetime)
}
},
......@@ -529,6 +547,7 @@ Page({
photoTitle: "",
photoContent: "",
photoProduct: [],
photoCbs: [],
startDatetime: "",
endDatetime: "",
}
......@@ -707,7 +726,7 @@ Page({
app.globalData.postData.photoArray = newFilePaths;
},
// 直接注册member
// 直接注册member, 如果已经上传成功了logo
// todo not finished jscat 20200902
onRegMember(resolve)
{
......@@ -715,6 +734,7 @@ Page({
var member_id = "mid_" + util.wxuuid()
app.globalData.member.member_id = member_id
var member_name = app.globalData.member.member_name
var member_city = app.globalData.member.member_city
var member_address = app.globalData.member.member_city + app.globalData.member.member_address
//即时更新member_address的值
app.globalData.member.member_address = member_address
......@@ -724,6 +744,7 @@ Page({
console.log("===this is onRegMember");
var query_url = '?userId=' + user_id + '&memberId=' + member_id + '&memberName=' + member_name
+ '&memberCity=' + member_city
+ '&memberAddress=' + member_address
+ '&memberSlogan=' + member_slogan
var strUrl = config.member_reg_url + query_url
......@@ -754,6 +775,7 @@ Page({
var address_id = "addid_" + util.wxuuid()
app.globalData.member.member_id = member_id
var member_name = app.globalData.member.member_name
var member_city = app.globalData.member.member_city
var member_address = app.globalData.member.member_city + app.globalData.member.member_address
//即时更新member_address的值
app.globalData.member.member_address = member_address
......@@ -777,17 +799,17 @@ Page({
promise_oss.then(
function (value) {
console.log("===enter promise_oss then_pass")
_this.uploadMember(member_id, address_id, member_name, member_address, member_slogan, logoArray, resolve, reject)
_this.uploadMember(member_id, address_id, member_name, member_city, member_address, member_slogan, logoArray, resolve, reject)
});
}
else
{
_this.uploadMember(member_id, address_id, member_name, member_address, member_slogan, logoArray, resolve, reject)
_this.uploadMember(member_id, address_id, member_name, member_city, member_address, member_slogan, logoArray, resolve, reject)
}
},
//上传商家信息到(阿里云)
uploadMember: function (member_id, address_id, member_name, member_address, member_slogan, logoArray, resolve, reject) {
uploadMember: function (member_id, address_id, member_name, member_city, member_address, member_slogan, logoArray, resolve, reject) {
var _this = this;
var pic = logoArray[0]
console.log(pic)
......@@ -826,6 +848,7 @@ Page({
app.globalData.member['address_id'] = address_id
app.globalData.member['member_id'] = member_id
app.globalData.member['member_name'] = member_name
app.globalData.member['member_city'] = member_city
app.globalData.member['member_address'] = member_address
app.globalData.member['member_slogan'] = member_slogan
......@@ -833,7 +856,7 @@ Page({
var strUrl = config.oss_member_callback_url
var callback_param = {
'callbackUrl': strUrl,
'callbackBody': 'filename=${object}&size=${size}&mimeType=${mimeType}&height=${imageInfo.height}&width=${imageInfo.width}&memberName=' + encodeURI(encodeURI(member_name)) + '&memberAddress=' + encodeURI(encodeURI(member_address)) + '&memberSlogan=' + encodeURI(encodeURI(member_slogan)) + '&image=' + member_logo + '&memberId=' + member_id + '&userId=' + user_id + '&addressId=' + address_id,
'callbackBody': 'filename=${object}&size=${size}&mimeType=${mimeType}&height=${imageInfo.height}&width=${imageInfo.width}&memberName=' + encodeURI(encodeURI(member_name)) + '&memberCity=' + encodeURI(encodeURI(member_city)) + '&memberAddress=' + encodeURI(encodeURI(member_address)) + '&memberSlogan=' + encodeURI(encodeURI(member_slogan)) + '&image=' + member_logo + '&memberId=' + member_id + '&userId=' + user_id + '&addressId=' + address_id,
'callbackBodyType': "application/x-www-form-urlencoded",
}
var base64_callback_body = base64.encode(JSON.stringify(callback_param));
......@@ -1023,6 +1046,7 @@ Page({
result['address_id'] = dict[i].addressId
result['address_status'] = dict[i].addressStatus
result['member_name'] = dict[i].memberName
result['member_city'] = dict[i].memberCity
result['member_address'] = dict[i].memberAddress
result['member_slogan'] = dict[i].memberSlogan
result['member_logo'] = dict[i].memberLogo
......
// pages/member/activity-post/activity-submit/activity-submit.js
// pages/member/activity-post/activity-submit/activity-submit.js
......@@ -109,6 +109,7 @@ Page({
memberInfo.address_id = ""
memberInfo.address_status = "00"
memberInfo.member_name = ""
memberInfo.member_city = ""
memberInfo.member_address = ""
memberInfo.member_slogan = "标语待完善中"
memberInfo.member_logo = ""
......@@ -420,7 +421,7 @@ Page({
var _this = this;
var memberInfo = _this.data.memberInfo
var query_url = '?memberId=' + memberInfo.member_id + '&memberAddress='+memberInfo.member_address
var query_url = '?memberId=' + memberInfo.member_id + '&memberCity='+memberInfo.member_city + '&memberAddress='+memberInfo.member_address
var strUrl = config.member_add_address_url + query_url
config.debug == 1 ? console.log("===strUrl is: \"" + strUrl + "\"") : ""
......
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 记录最近访问
......
var formatTime = function (date) {
var formatTime = function (date) {
......@@ -216,19 +216,31 @@ var formatAnswer = function (n) {
return answer
}
var formatSubString = function (str, n) {
// 输入 2020-02-04 19:33:00
// 返回 02-04
// console.log(str)
if(str != undefined && str != '')
{
str = str.toString().substring(0, n)
}
return str
}
module.exports = {
formatDate_ymd: formatDate_ymd,
formatDate_ymdw_today: formatDate_ymdw_today,
formatDate_ymdw_today_2: formatDate_ymdw_today_2,
formatDate_md: formatDate_md,
formatTime: formatTime,
formatNumber: formatNumber,
toFix: toFix,
formatAnswer: formatAnswer,
formatDate_md_week: formatDate_md_week,
formatNumberLike: formatNumberLike,
formatNumberPrice: formatNumberPrice,
formatDate_ymdw_today_interval: formatDate_ymdw_today_interval,
formatDate_hm_interval: formatDate_hm_interval,
formatDate_mdw_interval: formatDate_mdw_interval
formatDate_ymd: formatDate_ymd,
formatDate_ymdw_today: formatDate_ymdw_today,
formatDate_ymdw_today_2: formatDate_ymdw_today_2,
formatDate_md: formatDate_md,
formatTime: formatTime,
formatNumber: formatNumber,
toFix: toFix,
formatAnswer: formatAnswer,
formatDate_md_week: formatDate_md_week,
formatNumberLike: formatNumberLike,
formatNumberPrice: formatNumberPrice,
formatDate_ymdw_today_interval: formatDate_ymdw_today_interval,
formatDate_hm_interval: formatDate_hm_interval,
formatDate_mdw_interval: formatDate_mdw_interval,
formatSubString: formatSubString
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论