Commit 7d0e5e2d by jscat

nyx weapp: 功能新增

1. 添加上传图片/显示功能
parent 215eece7
......@@ -4,6 +4,8 @@
"pages/community/community",
"pages/fair/fair",
"pages/share/share",
"pages/live/live",
"pages/live/live-info/live-info",
"pages/mall/order/order",
"pages/activity/activity-list/activity-list",
"pages/my/my-members/my-members",
......@@ -35,13 +37,13 @@
"color": "#a0a0a0",
"selectedColor": "#333333",
"backgroundColor": "#ffffff",
"list": [
"list": [
{
"pagePath": "pages/activity/activity",
"text": "活动",
"iconPath": "./icon/my/activity.png",
"selectedIconPath": "./icon/my/activity.png"
},
"pagePath": "pages/live/live",
"text": "现场",
"iconPath": "./icon/community/community.png",
"selectedIconPath": "./icon/community/community.png"
},
{
"pagePath": "pages/share/share",
"text": "大厅",
......@@ -55,11 +57,11 @@
"selectedIconPath": "./icon/add.png"
},
{
"pagePath": "pages/community/community",
"text": "园区",
"iconPath": "./icon/community/community.png",
"selectedIconPath": "./icon/community/community.png"
},
"pagePath": "pages/activity/activity",
"text": "活动",
"iconPath": "./icon/my/activity.png",
"selectedIconPath": "./icon/my/activity.png"
},
{
"pagePath": "pages/my/my",
"text": "个人",
......
......@@ -78,5 +78,7 @@ var config={
check_pic_url: host_key + "/api/nyx/wx/check/pic",
pay_url: host_key + "/api/nyx/wx/pay/orders",
pay_callback_url: host_key + "/api/nyx/wx/pay/notify",
upload_url: host_key + "/api/nyx/upload/pic",
image_url: host_key + "/images/",
}
module.exports=config;
\ No newline at end of file
// pages/activity/activity-info/activity-info.js
var config = wx.getStorageSync("config");
var app = getApp();
var event = require('./../../../utils/event.js')
Page({
/**
* 页面的初始数据
*/
data: {
/* 用户信息及商家信息 */
nyxCode : "",
authStatus : "", // 授权状态: 00-未授权, 01-已授权
userInfo : {},
members : [], // 商家信息
member: {}, // 默认商家信息
windowHeight: "",
windowWidth: "",
contentHeight: "",
scrollLeft: 0, //切换栏的滚动条位置
// 基础数据
curImage: 0, // 用于image switch, //图片轮循的时候, 不同步更新价格 jscat 20200921
curIndex: 0, // 给选中的tab加粗
activityInfo: {}, // 活动基础信息
products: [], // 活动类别详情
products_string : {}, //活动类别详情对应的string, 主要用于navigator传值
//点赞模块
likeDictUpdate: {}, // 判断当前页面是否存在点赞操作
likeStatus: 0, // 判断like图标的状态
likeUrl: "../../../icon/activity/like.png", // like图标的url
//swiper的高度
swiperViewHeight: 0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this = this;
var windowHeight = wx.getSystemInfoSync().windowHeight;//获取设备高度,小程序自带的方法
var windowWidth = wx.getSystemInfoSync().windowWidth;//获取设备高度,小程序自带的方法
this.setData({
windowHeight: windowHeight,
windowWidth: windowWidth,
contentHeight : windowHeight * 0.675,
})
wx.setNavigationBarTitle({
title: '活动详情',
})
//step1: 初始化商家及用户数据
var nyxCode = wx.getStorageSync('nyxCode');
//不存在
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'),
})
}
//step2: 获取上一页面传入的数据
var activityInfo = _this.__data__.activityInfo
if (Object.keys(activityInfo).length==0 && options.title != "")
{
activityInfo['activity_id'] = options.activity_id;
activityInfo['note_image'] = options.note_image.split("::");
activityInfo['title'] = options.title;
activityInfo['content'] = options.content;
activityInfo['num_like'] = options.num_like;
activityInfo['address_name'] = options.address_name;
activityInfo['product_desc'] = options.product_desc;
activityInfo['unit_price'] = parseFloat(options.unit_price).toFixed(2);
activityInfo['member_id'] = options.member_id;
activityInfo['member_name'] = options.member_name;
activityInfo['member_slogan'] = options.member_slogan;
activityInfo['start_datetime'] = options.start_datetime;
activityInfo['end_datetime'] = options.end_datetime;
activityInfo['member_logo'] = options.member_logo==""?'/icon/icon_avatar1.png':options.member_logo;
}
_this.setData({ activityInfo })
//step3: 获取products, 活动的具体类别
_this.getProducts(activityInfo['activity_id'])
// step4 确定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)
},
);
// step5 数据载入页面, 初始化
// 初始载入'我已收藏'的清单, 存入storage
let promise_like = new Promise(function (resolve, reject) {
app.getCollectsStorage(0, 1, 100, resolve, reject);
})
promise_like.then(
function (value){
var likeDictStorage = wx.getStorageSync('likeDictStorage')
if(likeDictStorage.hasOwnProperty([activityInfo['activity_id']])
&& likeDictStorage[activityInfo['activity_id']] == 1 )
{
//同步更新likeStatus和likeUrl
var likeStatus = 1
var likeUrl = "../../../icon/activity/like_selected.png"
_this.setData({
likeStatus: likeStatus,
likeUrl: likeUrl,
})
}
console.log("===enter promise_like then_passed_" + value)
},
function (value){
console.log("===enter promise_like then_failed_" + value)
}
)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
var _this = this;
// 获取likeDictUpdate
var likeDictUpdate = _this.__data__.likeDictUpdate
var userId = _this.__data__.nyxCode
var activityId = _this.__data__.activityInfo['activity_id']
var numLike = _this.__data__.activityInfo['num_like']
// 如果存在update操作, 则更新
if (likeDictUpdate.hasOwnProperty(activityId) && likeDictUpdate[activityId] != 0 ) {
// step1: 更新数据库
_this.submitLike(userId, activityId, likeDictUpdate[activityId])
// step2: 通过eventBus影响订阅页(首页或者收藏页)的数据
var data = {
'activity_id': activityId,
'num_like' : numLike
}
event.emit('LikeChanged', data);
}
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户分享
* 1. 点击右上角分享
* 2. 点击tab栏分享
*/
onShareAppMessage: function (options) {
var _this = this;
var url_activity = "/pages/activity/activity-info/activity-info?"
+"activity_id="+_this.data.activityInfo["activity_id"]
+"&note_image="+_this.data.activityInfo['note_image'].join("::")
+"&title="+_this.data.activityInfo["title"]
+"&content="+_this.data.activityInfo["content"]
+"&num_like="+_this.data.activityInfo['num_like']
+"&address_name="+_this.data.activityInfo["address_name"]
+"&member_id="+_this.data.activityInfo["member_id"]
+"&member_name="+_this.data.activityInfo["member_name"]
+"&member_slogan="+_this.data.activityInfo["member_slogan"]
+"&member_logo="+_this.data.activityInfo["member_logo"]
+"&start_datetime="+_this.data.activityInfo["start_datetime"]
+"&end_datetime="+_this.data.activityInfo["end_datetime"]
var shareObj = {
    title: "好友推荐: "+ _this.data.activityInfo['title'],
    path: url_activity, // 默认是当前页面,必须是以'/'开头的完整路径
    imageUrl: _this.data.activityInfo['note_image'][0]
}
// 来自页面内的按钮的转发
  if( options.from == 'button' ){
    // 此处可以修改 shareObj 中的内容
    shareObj.path = url_activity;
  }
return shareObj;
},
/**
*
* 用户自定义函数 jscat 20200903
*/
//获取活动的具体子项; products
getProducts(activity_id){
var _this = this;
var pageCount = 10
var pageNum = 1
var query_url = '&activityId=' + activity_id
var strUrl = config.product_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 products = []
var products_string = {}
for (var i = 0; i < res.data.data.length; i++) {
var result = {}
result["productId"] = res.data.data[i].productId
result["productDesc"] = res.data.data[i].productDesc
result["unitPrice"] = res.data.data[i].unitPrice.toFixed(2)
result["quantity"] = res.data.data[i].quantity
result["defaultStatus"] = res.data.data[i].defaultStatus
products.push(result)
}
_this.setData({ products })
}
}
})
},
//切换所选的类别
switchCategory(e) {
var _this = this;
var curIndex = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
this.setData({ curIndex })
},
//滑动获取选中商品 jscat 20201012, obsolete; 不在需要去选中商品
getSelectItem: function (e) {
var that = this;
var preCurImage = that.data.curImage;
var itemWidth = e.detail.scrollWidth / that.data.activityInfo.note_image.length;//每个商品的宽度
var scrollLeft = e.detail.scrollLeft;//滚动宽度
if(scrollLeft <= 0 )
{
scrollLeft = 0;
}
console.log("===scrollLeft_", scrollLeft)
var curImage = Math.round(scrollLeft / itemWidth);//通过Math.round方法对滚动大于一半的位置进行进位
var newScrollLeft = 0
// 目标: 始终让图片居中显示
if (curImage != preCurImage
|| (curImage == that.data.activityInfo.note_image.length - 1 && scrollLeft > that.data.windowWidth * (that.data.activityInfo.note_image.length - 1))
)
{
newScrollLeft = that.data.windowWidth * curImage
scrollLeft = newScrollLeft
}
that.setData({
scrollLeft : scrollLeft,
curImage : curImage, //图片轮循的时候, 不同步更新价格 jscat 20200921
});
},
//跳转到结算页 order.wxml
toBuy: function (e) {
var _this = this;
var products_string = JSON.stringify(_this.data.products);
var url = "/pages/mall/order/order?"
+ "&activity_id=" + _this.__data__.activityInfo["activity_id"]
+ "&productsstring=" + products_string
+ "&curIndex=" + _this.data.curIndex
wx.navigateTo({
url: url
});
},
//跳转到结算页 order.wxml
toOrder: function (e) {
var _this = this;
var products_string = JSON.stringify(_this.data.products);
var url = "/pages/mall/order/order?"
+ "&activity_id=" + _this.__data__.activityInfo["activity_id"]
+ "&products_string=" + products_string
+ "&product_image=" + _this.__data__.activityInfo['note_image'][0]
+ "&member_name=" + _this.__data__.activityInfo['member_name']
+ "&title=" + _this.__data__.activityInfo['title']
+ "&curIndex=" + _this.data.curIndex
wx.navigateTo({
url: url
});
},
//跳转到首页
toHome: function (e) {
wx.switchTab({
url: "/pages/activity/activity"
});
},
//点击clone后跳转至活动创建页面
// 数据通过app.globalData
// app.globalData.postData
// photoTag: "",
// photoTitle: "",
// photoContent: "",
// photoProduct: [],
// startDatetime: "",
// endDatetime: "",
onClickClone: function (e) {
var _this = this;
var url = "/pages/member/activity-post/activity-post"
// 构造数据
app.globalData.postData.startDatetime = _this.data.activityInfo["start_datetime"]
app.globalData.postData.endDatetime = _this.data.activityInfo["end_datetime"]
app.globalData.postData.photoTitle = _this.data.activityInfo["title"]
app.globalData.postData.photoContent = _this.data.activityInfo["content"]
app.globalData.postData.photoProduct = _this.data.products
wx.switchTab({
url: url
});
},
submitLike: function (userId, activityId, op) {
var _this = this;
var query_url = '?activityId=' + activityId + '&userId=' + userId
var strUrl = op == 1 ? config.collect_like_url + query_url : config.collect_like_del_url + query_url
config.debug == 1 ? console.log("===submitLike strUrl is: " + strUrl) : ""
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if (res.statusCode == 200) {
//表示查询成功
console.log(res.data);
}
}
})
},
// 接收前端请求
onSubmitLike: function (e) {
var _this = this;
let activityId = e.currentTarget.dataset.id; // 获取活动id
var activityInfo = _this.__data__.activityInfo
// storage.likeDictStorage 只负责前端显示
// data.likeDictUpdate 负责数据库操作
var likeStatus = 0
var likeDictUpdate = _this.__data__.likeDictUpdate
var likeDictStorage = wx.getStorageSync('likeDictStorage') || {}
// 添加操作, 一定是storage的值为0或者undefined
if (!likeDictStorage.hasOwnProperty(activityId) || likeDictStorage[activityId] == 0 ) {
// 同步更新likeDictStorage, likeDictUpdate和activityInfo, like+1
// 同步更新前端
activityInfo['num_like'] = parseInt(activityInfo['num_like']) + 1
likeDictStorage[activityId] = 1
likeStatus = 1
// 表示本页面有数据操作
likeDictUpdate[activityId] = likeDictUpdate.hasOwnProperty(activityId) ? likeDictUpdate[activityId] + 1 : 1
wx.setStorageSync('likeDictStorage', likeDictStorage)
}
// 删除操作, 一定是storage的值为1
else if(likeDictStorage.hasOwnProperty(activityId) && likeDictStorage[activityId] == 1 )
{
//同步更新likeDict和activityInfo, like-1
activityInfo['num_like'] = parseInt(activityInfo['num_like']) - 1
likeDictStorage[activityId] = 0
likeStatus = 0
likeDictUpdate[activityId] = likeDictUpdate.hasOwnProperty(activityId) ? likeDictUpdate[activityId] - 1 : -1
wx.setStorageSync('likeDictStorage', likeDictStorage)
}
_this.setData({
likeDictUpdate: likeDictUpdate,
likeStatus: likeStatus,
likeUrl:likeStatus==1?"../../../icon/activity/like_selected.png":"../../../icon/activity/like.png",
activityInfo: activityInfo,
})
},
//动态设置swiper的高度; jscat 20201012, obsolete
setSwiperHeight: function () {
let that = this
wx.getSystemInfo({
success: function(res) {
that.setData({
windowHeight: res.windowHeight,
});
}
});
// 根据文档中的介绍,先创建一个SelectorQuery对象实例
let query = wx.createSelectorQuery().in(this);
query.select('.image_view').boundingClientRect();
// 执行上面所指定的请求,结果会按照顺序存放于一个数组中,在callback的第一个参数中返回
query.exec((res) => {
//取出表头高度
let headerHeight = res[0].height;
// 计算出去除表头剩余的高度
let swiperViewHeight = headerHeight;
this.setData({
swiperViewHeight: swiperViewHeight
});
});
},
})
\ No newline at end of file
<wxs module="tutil" src="./../../../utils/date.wxs"></wxs>
<view class="page">
<!-- 图片 -->
<scroll-view class="scroll-view_H" scroll-x scroll-with-animation style="width: 100%;height: 100%;">
<block wx:for="{{activityInfo.note_image}}" wx:key="unique" wx:for-index="id" wx:for-item="item">
<view class="scroll_item">
<image src="{{item}}" mode="widthFix"/>
</view>
</block>
</scroll-view>
<!-- 文字内容 -->
<view class="note">
<view class="note-price" style="font-weight: bold">
<view class="clone">
<view class="clone-left">¥{{products[curIndex].unitPrice}}</view>
<!-- start 点赞 like -->
<block>
<view class="clone-right" bindtap="onSubmitLike" data-id='{{activityInfo.activity_id}}'>
<view class="note-column" style="font-size: 24rpx;font-weight:normal;color: #000;align-items:center">
<image src="{{likeUrl}}"></image>
{{activityInfo.num_like}}
</view>
</view>
</block>
<!-- end 点赞 like -->
<!-- start 克隆 -->
<block wx:if="{{members.length > 0}}">
<view class="clone-right" bindtap="onClickClone" data-id='{{activityInfo.activity_id}}'>
<view class="note-column" style="font-size: 24rpx;font-weight:normal;color: #000;align-items:center;margin-left: 10rpx;">
<image src="../../../icon/activity/clone.png"></image>
克隆
</view>
</view>
</block>
<!-- end 克隆 -->
</view>
</view>
<view class="note-content" style="display: flex; flex-direction: column">
<span>主题: {{activityInfo.title}}</span>
<span>类别:
<view class="cate-list {{curIndex==index?'on':''}}" wx:for="{{products}}"
wx:for-item="sub_item" wx:key="{{index}}" data-index="{{index}}" bindtap="switchCategory">
{{sub_item.productDesc}}
</view>
</span>
<!-- 日期 -->
<span>日期: {{tutil.formatDate_ymdw_today_interval(activityInfo.start_datetime, activityInfo.end_datetime)}}</span>
<!-- 时间 -->
<span>时间: {{tutil.formatDate_hm_interval(activityInfo.start_datetime, activityInfo.end_datetime)}}</span>
<span>地点: {{activityInfo.address_name}}</span>
</view>
<view class="note-content">
<text>内容: {{activityInfo.content}}</text>
</view>
</view>
<!-- 企业信息 -->
<view class="note-row">
<view class="note-column-left align justify">
<image class="writer-image" src="{{activityInfo.member_logo}}"/>
</view>
<view class="note-column" style="margin-right: 4%">
<span class="name">{{activityInfo.member_name}}</span>
<span class="name">{{activityInfo.member_slogan}}</span>
</view>
</view>
<view class="bottom_placeholder"></view>
<!-- start bottom-->
<!-- refer to https://www.jb51.net/article/129438.htm -->
<view class="page__bd">
<view class="weui-tabbar">
<view class="weui-tabbar__item" bindtap="toHome">
<view style="position: relative;display:inline-block;">
<image src="../../../icon/index.png" class="weui-tabbar__icon" style="width: 48rpx; height:48rpx"></image>
</view>
<view class="weui-tabbar__label">首页</view>
</view>
<view class="weui-tabbar__item">
<view style="position: relative;display:inline-block;">
<button class="share" open-type="share"></button>
<image src="../../../icon/activity/share.png" class="weui-tabbar__icon" style="width: 48rpx; height:48rpx"></image>
</view>
<view class="weui-tabbar__label">分享</view>
</view>
<!-- todo toBuy 因为现在还没跟商家谈妥 -->
<!-- <view class="weui-tabbar__item">
<view style="position: relative;display:inline-block;">
<button class="button-red" bindtap="toBuy">立即购买</button>
</view>
</view> -->
<!-- toOrder 仅仅是先预定 -->
<view class="weui-tabbar__item">
<view style="position: relative;display:inline-block;">
<button class="button-red" bindtap="toOrder">立即预定</button>
</view>
</view>
</view>
</view>
<!-- end bottom-->
</view>
.scroll-view_H{
position: relative;
width: 100%;
text-align: center;
transform: scale(1);
white-space: nowrap;
}
.scroll_item {
position: relative;
width: 100%;
height: 100%;
margin: 0;
transform-origin: 50% 0;
left: 0%;
display: inline-block;
/* border-radius: 20rpx !important ; */
overflow: hidden;
/* transform: scale(0.9); */
vertical-align: middle;
/* top: 0%; */
/* height: 72%; */
background-color: #fff;
}
.scroll_item:first-child{
margin: 0%;
left: 0;
}
.scroll_item:last-child{
margin: 0;
left: 0;
}
.scroll_item.selected{
/* transform: scale(0.9); */
border: solid 0px #ffcd54;
}
.scroll_item image {
width: 100%;
float: left;
margin-top: 0;
}
.note{
width: 100%;
/* position: fixed; */
background: #fff;
border-radius: 5rpx;
float: left;
margin-top: 20rpx;
margin-bottom: 20rpx;
}
.note-title{
font-size: 30rpx;
margin-left: 5%;
margin-right: 5%;
margin-top: 0;
text-align:justify;
}
.note-price{
font-size: 16px;
margin-left: 5%;
margin-right: 5%;
margin-top: 0;
text-align:justify;
color: #FF6600;
}
.note-content{
font-size: 32rpx;
/* 后期用于 '展开' 功能 */
/* 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;
margin-bottom: 30rpx;
margin-top: 30rpx;
}
.note-column{
display: flex;
flex-direction: column;
margin-left: 30rpx;
}
.note-column-left{
width : 140rpx;
margin-left: 5%;
display: flex;
}
.writer-image{
width: 140rpx;
height: 140rpx;
}
/* start bottom style */
.column {
display: flex;
flex-direction: column;
}
.row {
display: flex;
flex-direction: row;
align-items: center;
}
.bottom_line {
width: 100%;
height: 2rpx;
background: lightgray;
}
.bottom_placeholder {
position: relative;
width: 100%;
height: 160rpx;
line-height: 10rpx;
}
.bottom_total {
position: fixed;
display: flex;
flex-direction: column;
bottom: 0;
width: 100%;
height: 160rpx;
line-height: 10rpx;
background: white;
}
.button-red {
background-color: #f44336; /* 红色 */
font-size: 14px;
}
.button-brown {
background-color: #D1A96E; /* 红色 */
}
button {
color: white;
text-align: center;
font-size:32rpx;
height: 2.6em;
line-height: 2.6em;
}
.placeholder{
margin-left: 20rpx;
margin-right: 20rpx;
text-align: center;
/* vertical-align: middle; */
padding: 0 10px;
line-height: 2.3em;
color: rgba(0,0,0);
}
/* justify-content: center;(水平居中) align-items: center;(垂直居中) */
.justify{
justify-content: center;
}
.align{
align-items: center;
}
.list .items{
display: flex;
flex-direction: column;
text-align: center;
align-items: center;
}
.items image{
width: 60rpx;
height: 60rpx;
margin-top: 20rpx;
font-size: 0;
}
.items text{
/* display: block; */
text-align: center;
margin-top: 0rpx;
margin-bottom: 20rpx;
padding: 0rpx;
font-size: 28rpx;
}
.list{
display: flex;
flex-direction: row;
justify-content: space-between;
margin-left: 30rpx;
margin-right: 30rpx;
margin-top: 20rpx;
}
/* end bottom style */
/* 分享按钮 */
.share {
position: absolute;
background-size: 50rpx 50rpx;
opacity: 0;
border:none;
}
/* 克隆图片 */
.clone{width: 100%; display: flex; margin-top: 0rpx; align-items: center;}
.clone-left{width: 80%; }
.cloner-right{width: 20%;}
.clone-right image{
width: 40rpx;
height: 40rpx;
font-size: 0;
}
.weui-tabbar{
position:fixed;
bottom:0;
left:0;
right:0;
}
.cate-list{
display: inline;
/* margin: 15rpx 22rpx; */
text-align: center;
font-size: 32rpx;
/* color: #9d9d9d; */
background: #F4F4F4;
margin-right: 20rpx;
padding-right: 10rpx;
padding-top: 10rpx;
padding-bottom: 10rpx;
}
.cate-list.on {
color: #FF6600;
font-weight: bold;
/*
border:1px solid #FF6600;
border-radius: 6rpx;
*/
}
\ No newline at end of file
// pages/live/live.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 : "", //搜索的字串
inputVal : "", //输入字符串,主要用于页面显示
//二维码信息
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 activityType = _this.__data__.activityType
this.setData({
curIndex: curIndex,
})
_this.getActivities(0, 1, 4, strCity, activityType, 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 初始载入四个推荐的活动 - 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 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, activityType, strCategory, strSearch);
}
// step6 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,
})
})
// step7 窗口初始化
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
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
event.remove('LikeChanged', this);
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log('页面上拉触底')
var _this = this;
var curIndex = _this.__data__.curIndex
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;
//控制逻辑, 在onClick之后或者onGetComment事件之后再允许下拉更新操作
//判断是否已经全部加载完毕
//没有则加载更多
if (!isHideLoadMore) {
console.log('加载更多')
setTimeout(() => {
_this.getActivities(1, pageIndex, 4, strCity, activityType, 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)
*/
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
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 strCity = _this.__data__.city
var strCategory = _this.__data__.category[curIndex].order
var activityType = _this.__data__.activityType
var strSearch = ""
this.setData({
strSearch: strSearch,
inputShowed: false,
});
_this.getActivities(0, 1, 4, strCity, activityType, strCategory, strSearch);
},
// * 删除输入字符串
clearInput: function(){
this.setData({
inputVal: "",
});
},
// 开始搜索
startSearch: function (e) {
var _this = this;
var strSearch = e.detail.value
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, activityType, 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 strCity = app.globalData.defaultCity
var curIndex = _this.__data__.curIndex
var strCategory = _this.__data__.category[curIndex].order
var strSearch = _this.__data__.strSearch
var activityType = _this.__data__.activityType
_this.getActivities(0, 1, 4, strCity, activityType, 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>
<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">
<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>
<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" />
<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>
</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?city={{city}}">
<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>
<!-- todo 0828 我的活动暂时也不实现 -->
<view class="items">
<navigator url="/pages/my/my-orders/my-orders">
<image src="../../icon/activity/order.png" style="margin-top:10rpx; margin-bottom:-10rpx"></image>
<text style="font-size:28rpx;">我的预订</text>
</navigator>
</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*/
......@@ -38,7 +38,7 @@ Page({
messageList: [],
isMedia: false,
isEmotion: false,
isShowAdd: false,
isShowAdd: true,
// socket
user_input_text: '',//用户输入文字
......@@ -75,6 +75,8 @@ Page({
rankData_raw_like: {
'@叁年间' : 100,
'@cincin' : 40,
'@rbar' : 40,
'@Piupiu' : 40,
"#六尾的大baby": 100,
"#南沙": 39,
"#小妹最乖哦": 3123,
......@@ -159,7 +161,7 @@ Page({
*/
//获取设备高度,小程序自带的方法
var windowHeight = wx.getSystemInfoSync().windowHeight;
var keyHeight = windowHeight*0.4
var keyHeight = windowHeight*0.3
var chatHeight = windowHeight - keyHeight
_this.setData({
keyHeight: keyHeight,
......@@ -300,6 +302,14 @@ Page({
})
},
//打开媒体选择
openMedia() {
this.scrollBottom();
this.setData({
isMedia: !this.data.isMedia,
isEmotion: false
})
},
//打开表情选择
openEmotion() {
this.scrollBottom();
......@@ -315,7 +325,7 @@ Page({
this.setData({
messageInputVal: inputEmotion
})
//this.isShowAddFun();
this.isShowAddFun();
},
//删除输入的值
......@@ -325,7 +335,7 @@ Page({
this.setData({
messageInputVal: newVal
})
//this.isShowAddFun();
this.isShowAddFun();
},
//分享(带参数),在onLoad接收参数
......@@ -384,14 +394,16 @@ Page({
//https://www.cnblogs.com/qlongbg/p/11603328.html
promise.then(function (value) {
console.log("===enter promise then_pass_" + value)
self.submitToLike(messageVal)
self.submitTo(messageVal)
self.submitToLike(messageVal, 'txt')
self.submitTo(messageVal, 'txt')
//更新数据(模拟请求历史数据)
self.setData({
messageInputVal: "",
messageList: newMessageArr,
isEmotion: false,
isMedia: false
isMedia: false,
isShowAdd: true,
showSend: false,
})
self.scrollBottom();
},
......@@ -419,6 +431,7 @@ Page({
this.setData({
messageInputVal: inputVal
})
this.isShowAddFun();
},
//是否显示添加按钮
isShowAddFun() {
......@@ -434,8 +447,59 @@ Page({
}
},
//选择图片
selectImg() {
let self = this;
//默认选择完之后自动隐藏
self.setData({
isMedia: false
})
wx.chooseImage({
count: 3,
sizeType: ['original', 'compressed'],
sourceType: ['album'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
// console.log(tempFilePaths);
uploadFiles(self, tempFilePaths, 0);
}
})
},
//拍照
selectCamera() {
let self = this;
//默认选择完之后自动隐藏
self.setData({
isMedia: false
})
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths;
// console.log(tempFilePaths);
uploadFiles(self, tempFilePaths, 0);
}
})
},
//图片预览
imagePreview(e) {
//console.log(e.currentTarget.dataset.src);
let img = e.currentTarget.dataset.src;
let urlsArr = [];
urlsArr.push(img);
wx.previewImage({
current: img, //当前预览的图片
urls: urlsArr, //所有要预览的图片
})
},
// 提交文字
submitTo: function (inputValue) {
submitTo: function (inputValue, type) {
let _this = this;
if (app.globalData.socketTask.readyState == 1) {
......@@ -443,14 +507,15 @@ Page({
var msg = JSON.stringify({
'cmd': 'onData',
'uid': app.globalData.nyxCode,
'msg': inputValue
'msg': inputValue,
'type': type, // txt: 对应文字; img: 对应图片
})
_this.sendSocketMessage(msg)
}
},
// 提交引用 Like
submitToLike: function (inputValue) {
submitToLike: function (inputValue, type) {
let _this = this;
if (app.globalData.socketTask.readyState == 1) {
......@@ -458,7 +523,8 @@ Page({
var msg = JSON.stringify({
'cmd': 'onLike',
'uid': app.globalData.nyxCode,
'msg': inputValue
'msg': inputValue,
'type': type
})
_this.sendSocketMessage(msg)
}
......@@ -501,6 +567,7 @@ Page({
var text = ""
var nickName = ""
var avater = ""
var type = 'txt'
console.log("====chatUserInfo, ", _this.data.chatUserInfo)
if (json["cmd"] == "onOpen" || json["cmd"] == "onScore") {
text = " " + _this.data.chatUserInfo.nickName + " " +json["msg"]
......@@ -511,9 +578,10 @@ Page({
}
else if (json["cmd"] == "onData") {
text = json["msg"]
type = json["type"]
nickName = _this.data.chatUserInfo.nickName
avater = _this.data.chatUserInfo.avatarUrl
_this.processInfo(text, nickName, avater)
_this.processInfo(text, nickName, avater, type)
}
else if (json["cmd"] == "onLike")
{
......@@ -703,8 +771,11 @@ Page({
},
//处理info data
processInfo: function(text, nickName, avater)
//处理info data, main func
/*
type: 'txt'|'img'
*/
processInfo: function(text, nickName, avater, type)
{
var _this = this;
//表情处理
......@@ -717,7 +788,7 @@ Page({
let objL = {
nickName: nickName,
type: 'L',
messageType: 'txt',
messageType: type,
con: newVal,
avater: avater,
};
......@@ -791,6 +862,52 @@ const getData = (url, param) => {
})
}
/**
* 采用递归的方式多文件上传
* imgPaths:需要上传的文件列表
* index:imgPaths开始上传的序号
*/
function uploadFiles(self, imgPaths, index) {
var strUrl = config.upload_url
wx.uploadFile({
url: strUrl, //上传的接口地址
filePath: imgPaths[index], //上传的图片(每次单张,一张张上传)
name: 'file',
success: function (res) {
var imgUrl = config.image_url
//成功,文件返回值存入成功列表
if (res && res.data) {
var data = JSON.parse(res.data);
console.log('upload...', data.data);
//上传成功之后,可以做别的操作,例如发送消息,上传头像等。
let objR = {
type: 'R',
con: imgUrl + data.data[0],
messageType: 'img',
avater: app.globalData.userInfo.avatarUrl,
};
let messageArr = [];
messageArr.push(objR);
let newMessageArr = self.data.messageList.concat(messageArr);
self.submitTo(imgUrl + data.data[0], 'img')
//更新数据
self.setData({
messageInputVal: "",
messageList: newMessageArr,
isEmotion: false,
isMedia: false
})
}
},
complete: function (e) {
index++; //下一张
if (index < imgPaths.length) {
//递归调用,上传下一张
uploadFiles(self, imgPaths, index);
}
}
})
}
//表情文件
function emotionFun() {
......
......@@ -6,8 +6,10 @@
<view class="{{selected=='@'?'border-tottom':'default'}}" id="@" bindtap="selected">热度商家榜</view>
<view class="{{selected=='#'?'border-tottom':'default'}}" id="#" bindtap="selected">活跃主播榜</view>
</view>
<view class="tab-content" style="height:{{keyHeight-100}}px;">
<view class="selected1" wx:for="{{rankData}}"
<!-- start_of_tab-content -->
<scroll-view scroll-y="true" scroll-top="0">
<view class="tab-content" style="height:{{keyHeight-100}}px;">
<view class="rank-info" wx:for="{{rankData}}"
wx:key="{{item.id}}" data-id="{{item.id}}" data-index="{{index}}"
bindtap="switchCategory">
<view class="rank">
......@@ -16,8 +18,10 @@
<view class="rank-row"><image src="{{likeUrl}}"></image> {{item.like}}</view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
<!-- end_of_tab-content -->
</view>
<!--end key view -->
......@@ -52,8 +56,20 @@
<!-- 消息输入 -->
<view class="message-input">
<input class="{{isShowAdd?'':'showSend'}}" placeholder="请输入内容" type="text" value="{{messageInputVal}}" cursor-spacing="10" bindinput='messageInput' confirm-type="send" bindconfirm="messageSend" />
<button bindtap="messageSend">发送</button>
<button bindtap="messageSend" wx:if="{{!isShowAdd}}">发送</button>
<image mode="widthFix" class="input-img {{isShowAdd?'':'showAdd'}}" src='../../icon/chat/face1.png' id="face" bindtap="openEmotion"></image>
<image mode="widthFix" class="input-img" wx:if="{{isShowAdd}}" src='../../icon/chat/add1.png' id="add" bindtap="openMedia"></image>
<!-- 媒体文件选择 -->
<view class="media-box" wx:if="{{isMedia}}">
<view class="media-list" bindtap="selectImg">
<image mode="widthFix" class="media-img" src='../../icon/chat/img2.png'></image>
<view>相册图片</view>
</view>
<view class="media-list" bindtap="selectCamera">
<image mode="widthFix" class="media-img" src='../../icon/chat/cam2.png'></image>
<view>相机拍照</view>
</view>
</view>
<!-- 表情文件 -->
<view class="emotion-box" wx:if="{{isEmotion}}">
<swiper class="home-swiper" indicator-dots="true" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" indicator-dots="{{indicatorDots}}">
......
......@@ -319,6 +319,9 @@
background: #fff;
padding: 16rpx;
}
.rank-info{
background: #fff;
}
.border-tottom{
border-bottom:1rpx solid red;
}
......@@ -329,7 +332,7 @@
.rank{width: 100%; display: flex; margin-top: 0rpx; align-items: center;}
/* .rank-left{width: 50%; text-align: center;}
.rank-right{width: 50%; display: flex; justify-content: center;} */
.rank-left{width: 50%; padding-left:100rpx; margin-bottom: 10rpx;}
.rank-left{width: 50%; padding-left:100rpx; margin-bottom: 12rpx;}
.rank-right{width: 50%; display: flex; padding-left:100rpx;}
.rank-right image{
width: 40rpx;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论