Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
nyx
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
发现
nyx
Commits
8d728f61
Commit
8d728f61
authored
Nov 25, 2020
by
jscat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nyx weapp: 功能更新
1. 实现多播放窗口
parent
465d59c3
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
1585 行增加
和
688 行删除
+1585
-688
app/nyx-dev/app.json
+2
-2
app/nyx-dev/pages/live/live-info/live-info.js
+1119
-341
app/nyx-dev/pages/live/live-info/live-info.wxml
+91
-95
app/nyx-dev/pages/live/live-info/live-info.wxss
+326
-226
app/nyx-dev/pages/live/live.js
+19
-0
app/nyx-dev/pages/live/live.wxml
+19
-20
app/nyx-dev/pages/live/live.wxss
+7
-2
app/nyx-dev/pages/share/share.js
+2
-2
没有找到文件。
app/nyx-dev/app.json
查看文件 @
8d728f61
{
"pages"
:
[
"pages/activity/activity"
,
"pages/share/share"
,
"pages/live/live"
,
"pages/live/live-info/live-info"
,
"pages/activity/activity"
,
"pages/share/share"
,
"pages/mall/order/order"
,
"pages/activity/activity-list/activity-list"
,
"pages/my/my-members/my-members"
,
...
...
app/nyx-dev/pages/live/live-info/live-info.js
查看文件 @
8d728f61
// pages/activity/activity-info/activity-info.js
// pages/key/key.js
var
config
=
wx
.
getStorageSync
(
"config"
);
var
app
=
getApp
();
var
event
=
require
(
'./../../../utils/event.js'
)
var
util
=
require
(
'./../../../utils/util.js'
)
Page
({
/**
* 系统配置:主要用于置底页面设置 step1
*/
keyHeight
:
''
,
chatHeight
:
""
,
/**
* 页面的初始数据
*/
data
:
{
// 主要是公屏内容
autoplay
:
false
,
interval
:
3000
,
duration
:
1200
,
indicatorDots
:
true
,
emotionArr
:
[],
messageInputVal
:
''
,
emotionHost
:
null
,
nodes
:
[{
name
:
'img'
}],
// {
// nickName : "张三"",
// type: 'L',
// messageType: 'txt',
// con: '微软开发者大会',
// avater: '../../imgs/avater.jpg'
// },
messageList
:
[],
isMedia
:
false
,
isEmotion
:
false
,
isShowAdd
:
true
,
// socket
user_input_text
:
''
,
//用户输入文字
inputValue
:
''
,
returnValue
:
''
,
addImg
:
false
,
//格式示例数据,可为空
allContentList
:
[],
num
:
0
,
sid
:
"key"
,
chatUserInfo
:
{},
scrollTop
:
0
,
//头像点击参数
touchStart
:
0
,
touchEnd
:
0
,
touchTime
:
0
,
touchId
:
""
,
//榜单栏 jscat 2020/11/20
/*
榜单数据流: 1_server vs n_client
1) client: socket: 上传文字 @cincin #南沙, dict->string
2) client: weapp : dict->string, 调用server, 更新redis
3) server: jaapp : 解析并更新redis
4) server: socket: sendData to n_client
5) client: socket: receive , 更新 local rankData_raw, 更新list
6) client: weapp : 点击; rankData_raw -> list 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传值
*/
selected
:
'@'
,
likeUrl
:
"../../../icon/activity/like_selected.png"
,
// like图标的url
//directly to redis
rankData_raw_like
:
{
'@叁年间'
:
100
,
'@cincin'
:
40
,
'@rbar'
:
40
,
'@Piupiu'
:
40
,
"#六尾的大baby"
:
100
,
"#南沙"
:
39
,
"#小妹最乖哦"
:
3123
,
},
rankData
:
[
{
name
:
"@叁年间"
,
like
:
100
},
{
name
:
"@cincin"
,
like
:
40
}
],
//点赞模块
likeDictUpdate
:
{},
// 判断当前页面是否存在点赞操作
likeStatus
:
0
,
// 判断like图标的状态
likeUrl
:
"../../../icon/activity/like.png"
,
// like图标的url
bottom_val
:
0
,
pxToRpxScale
:
0
,
tabBarHeight
:
0
,
//swiper的高度
swiperViewHeight
:
0
streamer_name
:
""
,
},
...
...
@@ -44,18 +104,9 @@ Page({
*/
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
:
'活动详情'
,
})
console
.
log
(
'===onLoad, options_'
,
JSON
.
stringify
(
options
));
/
/step1: 初始化商家及用户数据
/
*step1 先确定用户信息 */
var
nyxCode
=
wx
.
getStorageSync
(
'nyxCode'
);
//不存在
if
(
!
nyxCode
)
...
...
@@ -63,332 +114,807 @@ Page({
//注册新用户
console
.
log
(
"===onLoad_regUser"
)
wx
.
clearStorageSync
(
'nyxCode'
);
var
nyxCode
=
"uid_"
+
util
.
wxuuid
()
nyxCode
=
"uid_"
+
util
.
wxuuid
()
wx
.
setStorageSync
(
'nyxCode'
,
nyxCode
);
app
.
globalData
.
nyxCode
=
nyxCode
;
app
.
regUser
(
nyxCode
);
// nyxCode, userInfo, authStatus: storage, globalData
app
.
regUser
(
nyxCode
);
}
else
//存在
{
//更新用户信息
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"
)
}
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
)
var
sid
=
_this
.
__data__
.
sid
var
streamer_name
=
_this
.
__data__
.
streamer_name
if
(
options
.
sid
!=
""
)
{
//同步更新likeStatus和likeUrl
var
likeStatus
=
1
var
likeUrl
=
"../../../icon/activity/like_selected.png"
sid
=
options
.
sid
;
streamer_name
=
options
.
streamer_name
;
}
_this
.
setData
({
sid
,
streamer_name
})
//初始化socket
if
(
app
.
globalData
.
socketTask
.
readyState
!=
1
&&
app
.
globalData
.
socketTask
.
readyState
!=
0
)
{
var
sid
=
_this
.
data
.
sid
if
(
sid
!=
undefined
&&
nyxCode
!=
undefined
&&
sid
!=
""
&&
nyxCode
!=
""
)
{
console
.
log
(
"===onLoad_initSocket"
)
app
.
initSocket
(
sid
,
nyxCode
,
"来到"
+
_this
.
data
.
streamer_name
+
"现场"
)
app
.
globalData
.
socketClose
=
false
}
}
wx
.
setNavigationBarTitle
({
title
:
"现场播放"
})
/**
* 系统配置:主要用于置底页面设置 step2
let h = 750 * res.windowHeight/res.windowWidth
*/
let
systemInfo
=
wx
.
getSystemInfoSync
()
// px转换到rpx的比例
let
pxToRpxScale
=
750
/
systemInfo
.
windowWidth
;
//获取设备高度,小程序自带的方法
var
windowHeight
=
systemInfo
.
windowHeight
;
var
keyHeight
=
windowHeight
*
0.3
keyHeight
=
16
*
3
+
8
*
(
3
+
2
)
// 16: font-size; 8: padding: 16rpx
var
chatHeight
=
windowHeight
-
keyHeight
-
60
// in px
_this
.
setData
({
keyHeight
:
keyHeight
*
pxToRpxScale
,
//in rpx for compatible
chatHeight
:
chatHeight
*
pxToRpxScale
,
// in rpx for compatible
})
// 状态栏的高度
let
ktxStatusHeight
=
systemInfo
.
statusBarHeight
*
pxToRpxScale
// 计算导航栏的高度
// 此高度基于右上角菜单在导航栏位置垂直居中计算得到
// ipx: 44
// ipx: height + (top - statusBarHeight) * 2;
var
navBarHeight
=
44
let
navigationHeight
=
navBarHeight
*
pxToRpxScale
// window的宽度
// let ktxWindowWidth = systemInfo.windowWidth * pxToRpxScale
// window的高度
let
ktxWindowHeight
=
systemInfo
.
windowHeight
*
pxToRpxScale
// 屏幕的高度
let
ktxScreentHeight
=
systemInfo
.
screenHeight
*
pxToRpxScale
// 底部tabBar的高度
let
tabBarHeight
=
ktxScreentHeight
-
ktxStatusHeight
-
navigationHeight
-
ktxWindowHeight
_this
.
setData
({
pxToRpxScale
,
tabBarHeight
})
//模拟表情数据
let
emotion
=
emotionFun
();
this
.
setData
({
emotionArr
:
emotion
,
emotionHost
:
app
.
globalData
.
emotionHost
})
//构建榜单数据
_this
.
onGetRedisLike
()
},
// 初始化socket, 监听socket
onShow
:
function
()
{
var
_this
=
this
;
//构建榜单数据
_this
.
onGetRedisLike
()
console
.
log
(
"===onShow_readyState_"
,
app
.
globalData
.
socketTask
.
readyState
)
var
uid
=
wx
.
getStorageSync
(
'nyxCode'
)
if
(
app
.
globalData
.
socketTask
.
readyState
!=
1
&&
app
.
globalData
.
socketTask
.
readyState
!=
0
&&
uid
!=
""
)
{
var
sid
=
_this
.
data
.
sid
if
(
sid
!=
undefined
&&
uid
!=
undefined
&&
sid
!=
""
&&
uid
!=
""
)
{
console
.
log
(
"===onShow_initSocket"
)
app
.
initSocket
(
sid
,
uid
,
"来到"
+
_this
.
data
.
streamer_name
+
"现场"
)
app
.
globalData
.
socketClose
=
false
}
}
// 最好放在onShow
app
.
globalData
.
socketTask
.
onOpen
(
function
(
res
)
{
console
.
log
(
'chat-onOpen webSocket连接已打开! readyState='
+
app
.
globalData
.
socketTask
.
readyState
)
//console.log("chat-open res_", res)
if
(
app
.
globalData
.
socketClose
)
{
app
.
closeSocket
();
}
else
{
app
.
globalData
.
socketOpen
=
true
;
// 发送答题积分消息
var
sendMsg
=
wx
.
getStorageSync
(
'sendMsg'
)
if
(
sendMsg
)
{
_this
.
sendSocketMessage
(
sendMsg
)
}
for
(
var
i
=
0
;
i
<
app
.
globalData
.
socketMsgQueue
.
length
;
i
++
)
{
_this
.
sendSocketMessage
(
app
.
globalData
.
socketMsgQueue
[
i
])
}
app
.
globalData
.
socketMsgQueue
=
[]
app
.
startHeartBeat
();
}
})
app
.
globalData
.
socketTask
.
onError
(
function
(
res
)
{
console
.
log
(
'chat-WebSocket连接错误! 错误信息'
,
res
)
})
/*
两种情形,注意区分
case1. 用户跳转到其他页面, 触发onHide, 则正式退出
case2. socket掉线,则需要重连
*/
app
.
globalData
.
socketTask
.
onClose
(
function
(
res
)
{
console
.
log
(
'chat-WebSocket连接已关闭! readyState='
+
app
.
globalData
.
socketTask
.
readyState
)
//对应case1
if
(
!
app
.
globalData
.
socketClose
)
{
clearTimeout
(
app
.
globalData
.
connectSocketTimeOut
)
app
.
globalData
.
connectSocketTimeOut
=
setTimeout
(()
=>
{
console
.
log
(
"===onClose_initSocket"
)
app
.
initSocket
(
_this
.
data
.
sid
,
app
.
globalData
.
nyxCode
,
"来到"
+
_this
.
data
.
streamer_name
+
"现场"
)
},
3000
);
}
})
app
.
globalData
.
socketTask
.
onMessage
(
onMessage
=>
{
//console.log('监听WebSocket接受到服务器的消息事件。服务器返回的消息', onMessage.data)
var
json
=
JSON
.
parse
(
onMessage
.
data
);
// uid
var
uid
=
json
[
"uid"
];
if
(
json
[
"cmd"
]
!=
"onHeart"
)
{
console
.
log
(
"===onMessage_json: "
,
json
)
var
strUrl
=
config
.
userinfo_query_url
+
"?userid="
+
uid
//tofix 这个地方特别容易出错
config
.
debug
==
1
?
console
.
log
(
"===onMessage getData strUrl_"
+
strUrl
)
:
1
getData
(
strUrl
,
""
).
then
(
res
=>
{
console
.
log
(
"===onMessage_res_"
,
res
)
var
list
=
{}
//成功返回,服务器没问题
if
(
res
.
resultCode
==
"200"
)
{
if
(
res
.
data
.
length
==
0
)
{
list
[
'userId'
]
=
uid
list
[
'nickName'
]
=
"匿名用户"
list
[
'avatarUrl'
]
=
"https://930-test-sh.oss-cn-shanghai.aliyuncs.com/u_image/icon_avatar1.png"
}
else
{
list
=
res
.
data
[
0
]
}
console
.
log
(
"===onMessage_chatUserInfo, "
,
list
)
_this
.
setData
({
likeStatus
:
likeStatus
,
likeUrl
:
likeUrl
,
chatUserInfo
:
list
})
_this
.
processData
(
json
)
}
console
.
log
(
"===enter promise_like then_passed_"
+
value
)
},
function
(
value
){
console
.
log
(
"===enter promise_like then_failed_"
+
value
)
else
{
console
.
log
(
"===onMessage, 系统错误"
)
}
)
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady
:
function
()
{
onReady
:
function
(){
var
_this
=
this
;
},
/*
*
* 生命周期函数--监听页面显示
/*
*/
onShow
:
function
()
{
//点击空白页,隐藏表情和图片选择
cancelShow
()
{
this
.
setData
({
isEmotion
:
false
,
isMedia
:
false
})
},
//打开媒体选择
openMedia
()
{
this
.
scrollBottom
();
this
.
setData
({
isMedia
:
!
this
.
data
.
isMedia
,
isEmotion
:
false
})
},
//打开表情选择
openEmotion
()
{
this
.
scrollBottom
();
this
.
setData
({
isEmotion
:
!
this
.
data
.
isEmotion
,
isMedia
:
false
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide
:
function
()
{
//选择表情
selectEmotion
(
e
)
{
let
inputEmotion
=
this
.
data
.
messageInputVal
.
concat
(
e
.
currentTarget
.
dataset
.
txt
);
this
.
setData
({
messageInputVal
:
inputEmotion
})
this
.
isShowAddFun
();
},
//删除输入的值
deleteVal
()
{
// console.log(this.data.messageInputVal.length)
let
newVal
=
this
.
data
.
messageInputVal
.
substring
(
0
,
this
.
data
.
messageInputVal
.
length
-
1
);
this
.
setData
({
messageInputVal
:
newVal
})
this
.
isShowAddFun
();
},
//分享(带参数),在onLoad接收参数
onShareAppMessage
:
function
()
{
return
{
title
:
'让有趣被发现'
,
path
:
'pages/key/key'
,
// 路径,传递参数到指定页面。
imageUrl
:
'../../icon/images/nyx.png'
//自定义分享封面
}
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
app
.
closeSocket
();
console
.
log
(
'===onUnload webSocket 连接关闭事件。'
)
},
//聚焦
inputFocus
:
function
(
e
)
{
console
.
log
(
e
)
var
_this
=
this
;
var
tabBarHeight
=
_this
.
__data__
.
tabBarHeight
var
pxToRpxScale
=
_this
.
__data__
.
pxToRpxScale
console
.
log
(
"===tabBarHeight"
,
tabBarHeight
)
console
.
log
(
"===pxToRpxScale"
,
pxToRpxScale
)
_this
.
setData
({
bottom_val
:
e
.
detail
.
height
==
0
?
0
:
e
.
detail
.
height
*
pxToRpxScale
-
tabBarHeight
})
},
inputBlur
:
function
(
e
){
console
.
log
(
e
)
var
_this
=
this
;
_this
.
setData
({
bottom_val
:
0
,
})
},
// 获取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
)
{
//发送消息
messageSend
:
function
()
{
let
self
=
this
;
let
messageVal
=
self
.
data
.
messageInputVal
;
if
(
!
messageVal
)
{
wx
.
showToast
({
title
:
'请输入内容'
,
icon
:
'none'
,
duration
:
2000
})
return
false
;
}
// step1: 更新数据库
_this
.
submitLike
(
userId
,
activityId
,
likeDictUpdate
[
activityId
])
//表情处理
var
reg
=
/
\[
.+
?\]
/g
;
let
newVal
=
messageVal
.
replace
(
reg
,
function
(
a
,
b
)
{
return
face
(
a
)
?
face
(
a
)
:
a
;
});
// step2: 通过eventBus影响订阅页(首页或者收藏页)的数据
var
data
=
{
'activity_id'
:
activityId
,
'num_like'
:
numLike
}
event
.
emit
(
'LikeChanged'
,
data
);
//发送的消息
let
objR
=
{
nickName
:
app
.
globalData
.
userInfo
.
nickName
,
type
:
'R'
,
messageType
:
'txt'
,
con
:
newVal
,
avater
:
app
.
globalData
.
userInfo
.
avatarUrl
,
};
let
messageArr
=
[];
messageArr
.
push
(
objR
);
let
newMessageArr
=
self
.
data
.
messageList
.
concat
(
messageArr
);
//判断公屏的文字是否合规
let
promise
=
app
.
onCheckText
(
newVal
)
//在本轮event loop(事件循环)运行完成之前,回调函数是不会被调用的
//then后的括号里应该是参数param
//https://www.cnblogs.com/qlongbg/p/11603328.html
promise
.
then
(
function
(
value
)
{
console
.
log
(
"===enter promise then_pass_"
+
value
)
self
.
submitToLike
(
messageVal
,
'txt'
)
self
.
submitTo
(
messageVal
,
'txt'
)
//更新数据(模拟请求历史数据)
self
.
setData
({
messageInputVal
:
""
,
messageList
:
newMessageArr
,
isEmotion
:
false
,
isMedia
:
false
,
isShowAdd
:
true
,
showSend
:
false
,
})
self
.
scrollBottom
();
},
function
(
value
)
{
console
.
log
(
"===enter promise then_failed_"
+
value
)
});
},
}
//使页面滚动到底部
//tofix 应该需要一些优化 jscat 2020/03/13
scrollBottom
:
function
()
{
// wx.createSelectorQuery().select('#wrapperCon').boundingClientRect(function (rect) {
// wx.pageScrollTo({
// scrollTop: rect.bottom * 1000 //加整数的目的是消息数量多的时候,解决滚动会出现不到底部,并且抖动的问题
// })
// }).exec();
this
.
setData
({
scrollTop
:
1000
*
10
// 这里我们的单对话区域最高1000,取了最大值,应该有方法取到精确的
});
},
//获取输入内容
messageInput
:
function
(
e
)
{
let
inputVal
=
e
.
detail
.
value
;
this
.
setData
({
messageInputVal
:
inputVal
})
this
.
isShowAddFun
();
},
//是否显示添加按钮
isShowAddFun
()
{
//如果有输入显示发送按钮,隐藏加号添加图片功能
if
(
this
.
data
.
messageInputVal
)
{
this
.
setData
({
isShowAdd
:
false
})
}
else
{
this
.
setData
({
isShowAdd
:
true
})
}
},
/**
* 页面相关事件处理函数--监听用户下拉动作
//选择图片, 审核图片, 上传图片
/*
目标: 顺序审核+上传; 错误才提示
流程
1. 上传server
2. 图片检测
resolve: 上传并返回地址
reject : showModal
*/
onPullDownRefresh
:
function
()
{
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);
checkAndUploadFiles
(
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);
checkAndUploadFiles
(
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
,
//所有要预览的图片
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
:
function
()
{
// 提交文字
submitTo
:
function
(
inputValue
,
type
)
{
let
_this
=
this
;
if
(
app
.
globalData
.
socketTask
.
readyState
==
1
)
{
// 如果打开了socket就发送数据给服务器
var
msg
=
JSON
.
stringify
({
'cmd'
:
'onData'
,
'uid'
:
app
.
globalData
.
nyxCode
,
'msg'
:
inputValue
,
'type'
:
type
,
// txt: 对应文字; img: 对应图片
})
_this
.
sendSocketMessage
(
msg
)
}
},
// 提交引用 Like
submitToLike
:
function
(
inputValue
,
type
)
{
let
_this
=
this
;
if
(
app
.
globalData
.
socketTask
.
readyState
==
1
)
{
// 如果打开了socket就发送数据给服务器
var
msg
=
JSON
.
stringify
({
'cmd'
:
'onLike'
,
'uid'
:
app
.
globalData
.
nyxCode
,
'msg'
:
inputValue
,
'type'
:
type
})
_this
.
sendSocketMessage
(
msg
)
_this
.
onUpdateRedisLike
(
inputValue
)
}
},
/**
* 用户分享
* 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"
]
+
"¬e_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
;
bindKeyInput
:
function
(
e
)
{
this
.
setData
({
inputValue
:
e
.
detail
.
value
})
},
/**
*
* 用户自定义函数 jscat 20200903
/*
mark: tabbar 切换之后触发onHide()
*/
//获取活动的具体子项; products
getProducts
(
activity_id
){
var
_this
=
this
;
onHide
:
function
()
{
app
.
closeSocket
();
console
.
log
(
'===onHide WebSocket 连接关闭'
)
},
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'
),
// 发送和接收 socket 消息
sendSocketMessage
:
function
(
msg
)
{
let
_this
=
this
return
new
Promise
((
resolve
,
reject
)
=>
{
app
.
sendSocketMessage
(
msg
)
app
.
globalData
.
callback
=
function
(
res
)
{
console
.
log
(
'===webSocket 收到服务器内容: '
,
res
)
resolve
(
res
)
}
})
},
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
)
//获取到了socket广播的消息 => 通过userid获取userInfo => 小程序端处理获取到的msg
processData
(
json
)
{
var
_this
=
this
;
/*
cmd==onOpen, text = "欢迎" + map.uid + "大厅"
cmd==onData, text = map.msg
if(chatUserinfo.nickName == app.globalData.userInfo.nickName) 不添加
*/
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"
]
nickName
=
"系统"
avater
=
"../../../icon/mall.png"
_this
.
processOpen
(
text
,
nickName
,
avater
)
}
_this
.
setData
({
products
})
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
,
type
)
}
else
if
(
json
[
"cmd"
]
==
"onLike"
)
{
text
=
json
[
"msg"
]
//https://www.runoob.com/jsref/jsref-obj-regexp.html
// js regex
//获取名字 name,
/*
1. 空格结尾或者没有空格
2. 不包括'@ '和'# '情况
3. #123 #123 这种情况要去掉
*/
var
reg
=
/
(
@|#
)\S
.+
?(\s
+|$
)
/g
;
let
newList
=
text
.
match
(
reg
);
if
(
newList
!=
null
)
{
var
str
=
uniqueList
(
newList
).
join
(
"::"
)
nickName
=
_this
.
data
.
chatUserInfo
.
nickName
avater
=
_this
.
data
.
chatUserInfo
.
avatarUrl
_this
.
processLike
(
str
,
nickName
,
avater
)
}
})
}
},
touchStart
:
function
(
e
){
var
_this
=
this
;
_this
.
setData
({
touchStart
:
e
.
timeStamp
})
},
touchstart_long
:
function
(
e
)
{
console
.
log
(
e
)
var
_this
=
this
;
var
dataId
=
e
.
currentTarget
.
dataset
.
id
_this
.
setData
({
touchStart
:
e
.
timeStamp
})
//长按头像1s, 显示 @nickName功能
setTimeout
(
function
()
{
console
.
log
(
"touchStart___"
+
_this
.
data
.
touchEnd
)
//if ( _this.data.touchEnd == 0 ) {
_this
.
setData
({
messageInputVal
:
_this
.
data
.
messageInputVal
+
"@"
+
dataId
+
" "
})
//}
//重置
_this
.
setData
({
touchEnd
:
0
})
console
.
log
(
"touchStart__reset___"
)
},
1000
)
},
touchEnd
:
function
(
e
){
var
_this
=
this
;
console
.
log
(
"touchEnd___"
+
e
.
timeStamp
)
_this
.
setData
({
touchEnd
:
e
.
timeStamp
})
},
pressTap
:
function
(
e
){
var
_this
=
this
;
//js的e.currentTarget.id 对应wxml的 id="tab0"
//js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0"
var
dataId
=
e
.
currentTarget
.
dataset
.
id
var
touchTime
=
_this
.
data
.
touchEnd
-
_this
.
data
.
touchStart
;
if
(
touchTime
>
1000
){
//自定义长按时长,单位为ms
wx
.
showModal
({
title
:
'提示'
,
content
:
'你已长按头像: '
+
dataId
,
success
:
function
(
res
){
if
(
res
.
confirm
){
console
.
log
(
"===="
)
}
}
})
}
},
//切换所选的类别
switchCategory
(
e
)
{
var
_this
=
this
;
var
curIndex
=
e
.
currentTarget
.
dataset
.
index
?
e
.
currentTarget
.
dataset
.
index
:
0
this
.
setData
({
curIndex
})
this
.
setData
({
curIndex
:
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
)
selected
:
function
(
e
)
{
var
_this
=
this
;
var
raw
=
_this
.
__data__
.
rankData_raw_like
//js的e.currentTarget.id 对应wxml的 id="tab0"
//js的e.currentTarget.dataSet.id 对应wxml的 data-id="tab0"
var
index
=
e
.
currentTarget
.
id
let
selected
=
index
==
'@'
?
'@'
:
"#"
this
.
setData
({
selected
})
_this
.
genRankData
(
raw
,
selected
)
},
//处理Like
processLike
:
function
(
text
,
nickName
,
avater
)
{
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
))
)
var
_this
=
this
;
var
raw
=
_this
.
__data__
.
rankData_raw_like
var
selected
=
_this
.
__data__
.
selected
//获取名字 name
//input: @叁年间::#南沙
//output: ['@叁年间', '#南沙']
let
newVal
=
text
.
split
(
"::"
)
for
(
let
i
=
0
;
i
<
newVal
.
length
;
i
++
)
{
if
(
raw
.
hasOwnProperty
(
newVal
[
i
]))
{
newScrollLeft
=
that
.
data
.
windowWidth
*
curImage
scrollLeft
=
newScrollLeft
raw
[
newVal
[
i
]]
=
parseInt
(
raw
[
newVal
[
i
]])
+
1
}
that
.
setData
({
scrollLeft
:
scrollLeft
,
curImage
:
curImage
,
//图片轮循的时候, 不同步更新价格 jscat 20200921
});
else
{
raw
[
newVal
[
i
]]
=
1
}
}
//更新数据(模拟请求历史数据)
_this
.
genRankData
(
raw
,
selected
)
},
//跳转到结算页 order.wxml
toBuy
:
function
(
e
)
{
//处理open的代码
processOpen
:
function
(
text
,
nickName
,
avater
)
{
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
//表情处理
var
reg
=
/
\[
.+
?\]
/g
;
let
newVal
=
text
.
replace
(
reg
,
function
(
a
,
b
)
{
return
face
(
a
)
?
face
(
a
)
:
a
;
});
//回复
let
objL
=
{
nickName
:
nickName
,
type
:
'L'
,
messageType
:
'txt'
,
con
:
newVal
,
avater
:
avater
,
};
let
messageArr
=
[];
//jscat 20200314 most important!
// 判断内容是否显示
// 1. 发送data,同时非自己
// 2. (自己登陆,不需要重复发送),
// 3. (竞答完成后,需要发送内容)
// 4. (别人登陆, 需要发送)
if
(
(
app
.
globalData
.
onOpenOp
.
key
!=
true
)
||
(
_this
.
data
.
chatUserInfo
.
userid
!=
app
.
globalData
.
nyxCode
)
)
{
messageArr
.
push
(
objL
);
}
app
.
globalData
.
onOpenOp
.
key
=
true
;
let
newMessageArr
=
_this
.
data
.
messageList
.
concat
(
messageArr
);
//更新数据(模拟请求历史数据)
_this
.
setData
({
messageInputVal
:
""
,
messageList
:
newMessageArr
,
isEmotion
:
false
,
isMedia
:
false
,
})
_this
.
scrollBottom
();
},
//跳转到结算页 order.wxml
toOrder
:
function
(
e
)
{
//处理info data, main func
/*
type: 'txt'|'img'
*/
processInfo
:
function
(
text
,
nickName
,
avater
,
type
)
{
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
//表情处理
var
reg
=
/
\[
.+
?\]
/g
;
let
newVal
=
text
.
replace
(
reg
,
function
(
a
,
b
)
{
return
face
(
a
)
?
face
(
a
)
:
a
;
});
},
//跳转到首页
toHome
:
function
(
e
)
{
wx
.
switchTab
({
url
:
"/pages/activity/activity"
});
//回复
let
objL
=
{
nickName
:
nickName
,
type
:
'L'
,
messageType
:
type
,
con
:
newVal
,
avater
:
avater
,
};
let
messageArr
=
[];
//jscat 20200314 most important!
// 判断内容是否显示
// 1. 发送data,同时非自己
// 2. (自己登陆,不需要重复发送),
// 3. (竞答完成后,需要发送内容)
// 4. (别人登陆, 需要发送)
if
(
(
_this
.
data
.
chatUserInfo
.
userid
!=
app
.
globalData
.
nyxCode
)
)
{
messageArr
.
push
(
objL
);
}
let
newMessageArr
=
_this
.
data
.
messageList
.
concat
(
messageArr
);
//更新数据(模拟请求历史数据)
_this
.
setData
({
messageInputVal
:
""
,
messageList
:
newMessageArr
,
isEmotion
:
false
,
isMedia
:
false
,
})
_this
.
scrollBottom
();
},
//点击clone后跳转至活动创建页面
// 数据通过app.globalData
// app.globalData.postData
// photoTag: "",
// photoTitle: "",
// photoContent: "",
// photoProduct: [],
// startDatetime: "",
// endDatetime: "",
onClickClone
:
function
(
e
)
{
genRankData
:
function
(
raw
,
rankType
)
{
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
});
//raw: dict, {"@叁年间":100, "#123":34}
//rankType: string, "@"
var
rankData
=
[]
var
res
=
Object
.
keys
(
raw
).
sort
(
function
(
a
,
b
){
return
raw
[
b
]
-
raw
[
a
];
});
for
(
var
key
in
res
)
{
if
(
res
[
key
][
0
]
==
rankType
)
{
var
dict
=
{}
var
key1
=
res
[
key
].
replace
(
rankType
,
""
)
dict
[
"name"
]
=
key1
dict
[
"like"
]
=
raw
[
res
[
key
]]
rankData
.
push
(
dict
)
}
}
_this
.
setData
({
rankData
})
},
submitLike
:
function
(
userId
,
activityId
,
op
)
{
updateRedisLike
:
function
(
strUrl
)
{
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'
,
...
...
@@ -396,88 +922,340 @@ Page({
'Cookie'
:
wx
.
getStorageSync
(
'cookieKey'
),
},
success
:
function
(
res
)
{
if
(
res
.
statusCode
==
200
)
{
//表示
查询
成功
console
.
log
(
res
.
data
);
if
(
res
.
data
.
resultCode
==
200
)
{
//表示
query
成功
console
.
log
(
"===updateRedisLike完成"
);
}
},
fail
:
function
(
res
)
{
console
.
log
(
"===updateRedisLike失败"
)
}
})
},
// 接收前端请求
onSubmitLike
:
function
(
e
)
{
//调用java接口, 同步更新redis的like数据
onUpdateRedisLike
:
function
(
text
)
{
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
)
var
reg
=
/
(
@|#
)\S
.+
?(\s
+|$
)
/g
;
let
newList
=
text
.
match
(
reg
);
if
(
newList
!=
null
)
{
//同步更新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
)
var
str
=
uniqueList
(
newList
).
join
(
"::"
).
replace
(
/#/g
,
"%23"
)
var
strUrl
=
config
.
redis_update_like_url
+
"?keyString="
+
str
config
.
debug
==
1
?
console
.
log
(
"===updateRedisLike strUrl "
+
strUrl
):
""
_this
.
updateRedisLike
(
strUrl
)
}
_this
.
setData
({
likeDictUpdate
:
likeDictUpdate
,
likeStatus
:
likeStatus
,
likeUrl
:
likeStatus
==
1
?
"../../../icon/activity/like_selected.png"
:
"../../../icon/activity/like.png"
,
activityInfo
:
activityInfo
,
},
//调用java接口, 同步查询redis的like数据
getRedisLike
:
function
(
strUrl
)
{
var
_this
=
this
;
wx
.
request
({
url
:
strUrl
,
method
:
'GET'
,
header
:
{
'Cookie'
:
wx
.
getStorageSync
(
'cookieKey'
),
},
success
:
function
(
res
)
{
if
(
res
.
data
.
resultCode
==
200
)
{
//表示query成功
console
.
log
(
"===updateRedisLike完成"
);
var
rankData_raw_like
=
res
.
data
.
data
_this
.
setData
({
rankData_raw_like
})
_this
.
genRankData
(
rankData_raw_like
,
'@'
)
}
},
fail
:
function
(
res
)
{
console
.
log
(
"===updateRedisLike失败"
)
}
})
},
//动态设置swiper的高度; jscat 20201012, obsolete
setSwiperHeight
:
function
()
{
let
that
=
this
//调用java接口, 同步get redis的like数据
onGetRedisLike
:
function
()
{
var
_this
=
this
;
wx
.
getSystemInfo
({
success
:
function
(
res
)
{
that
.
setData
({
windowHeight
:
res
.
windowHeight
,
});
}
});
// 根据文档中的介绍,先创建一个SelectorQuery对象实例
let
query
=
wx
.
createSelectorQuery
().
in
(
this
);
var
strUrl
=
config
.
redis_query_like_url
config
.
debug
==
1
?
console
.
log
(
"===getRedisLike strUrl "
+
strUrl
):
""
_this
.
getRedisLike
(
strUrl
)
query
.
select
(
'.image_view'
).
boundingClientRect
();
},
// 执行上面所指定的请求,结果会按照顺序存放于一个数组中,在callback的第一个参数中返回
query
.
exec
((
res
)
=>
{
//取出表头高度
let
headerHeight
=
res
[
0
].
height
;
// 计算出去除表头剩余的高度
let
swiperViewHeight
=
headerHeight
;
this
.
setData
({
swiperViewHeight
:
swiperViewHeight
});
});
})
//通过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
)
}
})
})
}
/**
* 采用递归的方式多文件上传
* imgPaths:需要上传的文件列表
* index:imgPaths开始上传的序号
*/
function
checkAndUploadFiles
(
self
,
imgPaths
,
index
)
{
var
strUrl
=
config
.
check_upload_pic_url
wx
.
uploadFile
({
url
:
strUrl
,
//上传的接口地址
filePath
:
imgPaths
[
index
],
//上传的图片(每次单张,一张张上传)
name
:
'file'
,
success
:
function
(
res
)
{
// resultCode: "200"
var
imgUrl
=
config
.
image_url
//成功,文件返回值存入成功列表
var
result
=
JSON
.
parse
(
res
.
data
);
if
(
result
&&
result
.
data
&&
result
.
data
.
errcode
==
'0'
)
{
console
.
log
(
'upload...'
,
result
.
data
);
//上传成功之后,可以做别的操作,例如发送消息,上传头像等。
let
objR
=
{
type
:
'R'
,
con
:
imgUrl
+
result
.
data
.
paths
[
0
],
messageType
:
'img'
,
avater
:
app
.
globalData
.
userInfo
.
avatarUrl
,
};
let
messageArr
=
[];
messageArr
.
push
(
objR
);
let
newMessageArr
=
self
.
data
.
messageList
.
concat
(
messageArr
);
self
.
submitTo
(
imgUrl
+
result
.
data
.
paths
[
0
],
'img'
)
//更新数据
self
.
setData
({
messageInputVal
:
""
,
messageList
:
newMessageArr
,
isEmotion
:
false
,
isMedia
:
false
})
}
else
{
if
(
result
.
data
.
errcode
==
'87014'
)
{
wx
.
hideLoading
();
var
num
=
parseInt
(
index
)
+
1
wx
.
showModal
({
content
:
'第'
+
num
+
'张图存在敏感内容, 请更换'
,
showCancel
:
false
,
confirmText
:
'明白了'
})
}
else
{
wx
.
hideLoading
();
wx
.
showModal
({
content
:
'系统错误,请稍后再试'
,
showCancel
:
false
,
confirmText
:
'明白了'
})
}
}
},
complete
:
function
(
e
)
{
index
++
;
//下一张
if
(
index
<
imgPaths
.
length
)
{
//递归调用,上传下一张
checkAndUploadFiles
(
self
,
imgPaths
,
index
);
}
}
})
}
})
\ No newline at end of file
/**
* 采用递归的方式多文件上传
* 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
()
{
let
emoArr
=
[
{
"name"
:
"Expression_1"
,
"text"
:
"[微笑]"
},
{
"name"
:
"Expression_2"
,
"text"
:
"[撇嘴]"
},
{
"name"
:
"Expression_3"
,
"text"
:
"[色]"
},
{
"name"
:
"Expression_4"
,
"text"
:
"[发呆]"
},
{
"name"
:
"Expression_5"
,
"text"
:
"[得意]"
},
{
"name"
:
"Expression_6"
,
"text"
:
"[流泪]"
},
{
"name"
:
"Expression_7"
,
"text"
:
"[害羞]"
},
{
"name"
:
"Expression_8"
,
"text"
:
"[闭嘴]"
},
{
"name"
:
"Expression_9"
,
"text"
:
"[睡]"
},
{
"name"
:
"Expression_10"
,
"text"
:
"[大哭]"
},
{
"name"
:
"Expression_11"
,
"text"
:
"[尴尬]"
},
{
"name"
:
"Expression_12"
,
"text"
:
"[发怒]"
},
{
"name"
:
"Expression_13"
,
"text"
:
"[调皮]"
},
{
"name"
:
"Expression_14"
,
"text"
:
"[呲牙]"
},
{
"name"
:
"Expression_15"
,
"text"
:
"[惊讶]"
},
{
"name"
:
"Expression_16"
,
"text"
:
"[难过]"
},
{
"name"
:
"Expression_17"
,
"text"
:
"[酷]"
},
{
"name"
:
"Expression_18"
,
"text"
:
"[冷汗]"
},
{
"name"
:
"Expression_19"
,
"text"
:
"[抓狂]"
},
{
"name"
:
"Expression_20"
,
"text"
:
"[吐]"
},
{
"name"
:
"Expression_21"
,
"text"
:
"[偷笑]"
},
{
"name"
:
"Expression_22"
,
"text"
:
"[愉快]"
},
{
"name"
:
"Expression_23"
,
"text"
:
"[白眼]"
},
{
"name"
:
"Expression_24"
,
"text"
:
"[傲慢]"
},
{
"name"
:
"Expression_25"
,
"text"
:
"[饥饿]"
},
{
"name"
:
"Expression_26"
,
"text"
:
"[困]"
},
{
"name"
:
"Expression_27"
,
"text"
:
"[恐惧]"
},
{
"name"
:
"Expression_28"
,
"text"
:
"[流汗]"
},
{
"name"
:
"Expression_29"
,
"text"
:
"[憨笑]"
},
{
"name"
:
"Expression_30"
,
"text"
:
"[悠闲]"
},
{
"name"
:
"Expression_31"
,
"text"
:
"[奋斗]"
},
{
"name"
:
"Expression_32"
,
"text"
:
"[咒骂]"
},
{
"name"
:
"Expression_33"
,
"text"
:
"[疑问]"
},
{
"name"
:
"Expression_34"
,
"text"
:
"[嘘]"
},
{
"name"
:
"Expression_35"
,
"text"
:
"[晕]"
},
{
"name"
:
"Expression_36"
,
"text"
:
"[疯了]"
},
{
"name"
:
"Expression_37"
,
"text"
:
"[衰]"
},
{
"name"
:
"Expression_38"
,
"text"
:
"[骷髅]"
},
{
"name"
:
"Expression_39"
,
"text"
:
"[敲打]"
},
{
"name"
:
"Expression_40"
,
"text"
:
"[再见]"
},
{
"name"
:
"Expression_41"
,
"text"
:
"[擦汗]"
},
{
"name"
:
"Expression_42"
,
"text"
:
"[抠鼻]"
},
{
"name"
:
"Expression_43"
,
"text"
:
"[鼓掌]"
},
{
"name"
:
"Expression_44"
,
"text"
:
"[糗大了]"
},
{
"name"
:
"Expression_45"
,
"text"
:
"[坏笑]"
},
{
"name"
:
"Expression_46"
,
"text"
:
"[左哼哼]"
},
{
"name"
:
"Expression_47"
,
"text"
:
"[右哼哼]"
},
{
"name"
:
"Expression_48"
,
"text"
:
"[哈欠]"
},
{
"name"
:
"Expression_49"
,
"text"
:
"[鄙视]"
},
{
"name"
:
"Expression_50"
,
"text"
:
"[委屈]"
},
{
"name"
:
"Expression_51"
,
"text"
:
"[快哭了]"
},
{
"name"
:
"Expression_52"
,
"text"
:
"[阴险]"
},
{
"name"
:
"Expression_53"
,
"text"
:
"[亲亲]"
},
{
"name"
:
"Expression_54"
,
"text"
:
"[吓]"
},
{
"name"
:
"Expression_55"
,
"text"
:
"[可怜]"
},
{
"name"
:
"Expression_56"
,
"text"
:
"[菜刀]"
},
{
"name"
:
"Expression_57"
,
"text"
:
"[西瓜]"
},
{
"name"
:
"Expression_58"
,
"text"
:
"[啤酒]"
},
{
"name"
:
"Expression_59"
,
"text"
:
"[篮球]"
},
{
"name"
:
"Expression_60"
,
"text"
:
"[乒乓]"
},
{
"name"
:
"Expression_61"
,
"text"
:
"[咖啡]"
},
{
"name"
:
"Expression_62"
,
"text"
:
"[饭]"
},
{
"name"
:
"Expression_63"
,
"text"
:
"[猪头]"
},
{
"name"
:
"Expression_64"
,
"text"
:
"[玫瑰]"
},
{
"name"
:
"Expression_65"
,
"text"
:
"[凋谢]"
},
{
"name"
:
"Expression_66"
,
"text"
:
"[嘴唇]"
},
{
"name"
:
"Expression_67"
,
"text"
:
"[爱心]"
},
{
"name"
:
"Expression_68"
,
"text"
:
"[心碎]"
},
{
"name"
:
"Expression_69"
,
"text"
:
"[蛋糕]"
},
{
"name"
:
"Expression_70"
,
"text"
:
"[闪电]"
},
{
"name"
:
"Expression_71"
,
"text"
:
"[炸弹]"
},
{
"name"
:
"Expression_72"
,
"text"
:
"[刀]"
},
{
"name"
:
"Expression_73"
,
"text"
:
"[足球]"
},
{
"name"
:
"Expression_74"
,
"text"
:
"[瓢虫]"
},
{
"name"
:
"Expression_75"
,
"text"
:
"[便便]"
},
{
"name"
:
"Expression_76"
,
"text"
:
"[月亮]"
},
{
"name"
:
"Expression_77"
,
"text"
:
"[太阳]"
},
{
"name"
:
"Expression_78"
,
"text"
:
"[礼物]"
},
{
"name"
:
"Expression_79"
,
"text"
:
"[拥抱]"
},
{
"name"
:
"Expression_80"
,
"text"
:
"[强]"
},
{
"name"
:
"Expression_81"
,
"text"
:
"[弱]"
},
{
"name"
:
"Expression_82"
,
"text"
:
"[握手]"
},
{
"name"
:
"Expression_83"
,
"text"
:
"[胜利]"
},
{
"name"
:
"Expression_84"
,
"text"
:
"[抱拳]"
},
{
"name"
:
"Expression_85"
,
"text"
:
"[勾引]"
},
{
"name"
:
"Expression_86"
,
"text"
:
"[拳头]"
},
{
"name"
:
"Expression_87"
,
"text"
:
"[差劲]"
},
{
"name"
:
"Expression_88"
,
"text"
:
"[爱你]"
},
{
"name"
:
"Expression_89"
,
"text"
:
"[NO]"
},
{
"name"
:
"Expression_90"
,
"text"
:
"[OK]"
},
{
"name"
:
"Expression_91"
,
"text"
:
"[爱情]"
},
{
"name"
:
"Expression_92"
,
"text"
:
"[飞吻]"
},
{
"name"
:
"Expression_93"
,
"text"
:
"[跳跳]"
},
{
"name"
:
"Expression_94"
,
"text"
:
"[发抖]"
},
{
"name"
:
"Expression_95"
,
"text"
:
"[怄火]"
},
{
"name"
:
"Expression_96"
,
"text"
:
"[转圈]"
},
{
"name"
:
"Expression_97"
,
"text"
:
"[磕头]"
},
{
"name"
:
"Expression_98"
,
"text"
:
"[回头]"
},
{
"name"
:
"Expression_99"
,
"text"
:
"[跳绳]"
},
{
"name"
:
"Expression_100"
,
"text"
:
"[投降]"
},
{
"name"
:
"Expression_101"
,
"text"
:
"[激动]"
},
{
"name"
:
"Expression_102"
,
"text"
:
"[街舞]"
},
{
"name"
:
"Expression_103"
,
"text"
:
"[献吻]"
},
{
"name"
:
"Expression_104"
,
"text"
:
"[左太极]"
},
{
"name"
:
"Expression_105"
,
"text"
:
"[右太极]"
}
];
return
emoArr
;
}
//表情转换
function
face
(
obj
)
{
let
emotion
=
emotionFun
();
let
emotionHost
=
"https://930-test-sh.oss-cn-shanghai.aliyuncs.com/emoji/"
;
let
face
=
{};
for
(
let
i
=
0
;
i
<
emotion
.
length
;
i
++
)
{
face
[
emotion
[
i
].
text
]
=
'<img src="'
+
emotionHost
+
emotion
[
i
].
name
+
'.png" style="widht:20px;height:20px;vertical-align: middle;"/>'
}
return
face
[
obj
];
}
function
uniqueList
(
arr
)
{
var
res
=
[];
var
json
=
{};
var
r
=
/
\s
+/g
;
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
){
var
str
=
arr
[
i
].
replace
(
r
,
''
)
if
(
!
json
[
str
]){
res
.
push
(
str
);
json
[
str
]
=
1
;
}
}
return
res
;
}
\ No newline at end of file
app/nyx-dev/pages/live/live-info/live-info.wxml
查看文件 @
8d728f61
<wxs module="tutil" src="./../../../utils/date.wxs"></wxs>
<!--pages/share/share.wxml-->
<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}}
<!-- start key view -->
<view class="page__hd" style="position:fixed; top:0;width: 750rpx;">
<view class="tab-title">
<view class="{{selected=='@'?'border-tottom':'default'}}" id="@" bindtap="selected">热度商家榜</view>
<view class="{{selected=='#'?'border-tottom':'default'}}" id="#" bindtap="selected">活跃主播榜</view>
</view>
<!-- start_of_tab-content -->
<scroll-view scroll-y="true" scroll-top="0">
<view class="tab-content" style="height:{{keyHeight}}rpx;">
<view class="rank-info" wx:for="{{rankData}}"
wx:key="{{item.id}}" data-id="{{item.id}}" data-index="{{index}}"
bindtap="switchCategory">
<view class="rank">
<view class="rank-left">{{item.name}}</view>
<view class="rank-right">
<view class="rank-row"><image src="{{likeUrl}}"></image> {{item.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>
</scroll-view>
<!-- end_of_tab-content -->
</view>
</view
>
<!--end key 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-->
<view style="height:{{chatHeight}}rpx;position:fixed; bottom:0;">
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd">{{streamer_name}}</view>
</view>
<scroll-view scroll-y="true" scroll-top="{{scrollTop}}" style="height:{{chatHeight-80}}rpx;position:fixed; bottom:0;">
<view class="wrapper {{isShowAdd?'media-padd':''}} {{isEmotion?'emotion-padd':''}}" id="wrapperCon" bindtap="cancelShow" >
<!-- 消息列表 -->
<view class="chat {{item.type=='L'?'chat-l':'chat-r'}}" wx:for="{{messageList}}" wx:for-item="item">
<!-- <view class="c-date">2019年3月23日 15:33</view> -->
<view class="message-list">
<view class="avater {{item.type=='R'?'avater-r':''}}">
<!-- refer https://www.jianshu.com/p/7ad22e35b556 -->
<image src='{{item.avater}}' bindtouchstart='touchstart_long' bindtouchend='touchEnd' data-id="{{item.nickName}}"></image>
<view class="{{item.type=='R'?'nick-name-r':'nick-name-l'}}" wx:if="{{item.type=='L'}}">{{item.nickName}}</view>
<view class="{{item.type=='R'?'nick-name-r':'nick-name-l'}}" wx:if="{{item.type=='R'}}">{{item.nickName}}</view>
</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 class="chat-con {{item.type=='L'?'chat-con-l':'chat-con-r'}} ">
<rich-text wx:if="{{item.messageType=='txt'}}" nodes="{{item.con}}"></rich-text>
<image class="message-img" mode="widthFix" bindtap="imagePreview" data-src="{{item.con}}" wx:if="{{item.messageType=='img'}}" src="{{item.con}}"></image>
</view>
<view class="note-content">
<text>内容: {{activityInfo.content}}</text>
</view>
</view>
</view>
</scroll-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 class="message-input" style="position:absolute; bottom:{{bottom_val}}rpx">
<input class="{{isShowAdd?'':'showSend'}}" placeholder="请输入内容" type="text" value="{{messageInputVal}}" cursor-spacing="20" bindinput='messageInput' confirm-type="send" bindconfirm="messageSend" bindfocus="inputFocus" bindblur="inputBlur" adjust-position="{{false}}" />
<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}}">
<swiper-item class="emotion-list">
<block wx:for-items="{{emotionArr}}" wx:key='index' wx:if="{{index<23}}">
<image bindtap="selectEmotion" data-txt="{{item.text}}" src="{{emotionHost+item.name}}.png" class="slide-image" />
</block>
<image src="../../../icon/chat/delete.png" bindtap="deleteVal" class="slide-image" />
</swiper-item>
<swiper-item class="emotion-list">
<block wx:for-items="{{emotionArr}}" wx:key='index' wx:if="{{index>=23&&index<46}}">
<image bindtap="selectEmotion" data-txt="{{item.text}}" src="{{emotionHost+item.name}}.png" class="slide-image" />
</block>
<image src="../../../icon/chat/delete.png" bindtap="deleteVal" class="slide-image" />
</swiper-item>
<swiper-item class="emotion-list">
<block wx:for-items="{{emotionArr}}" wx:key='index' wx:if="{{index>=46&&index<69}}">
<image bindtap="selectEmotion" data-txt="{{item.text}}" src="{{emotionHost+item.name}}.png" class="slide-image" />
</block>
<image src="../../../icon/chat/delete.png" bindtap="deleteVal" class="slide-image" />
</swiper-item>
<swiper-item class="emotion-list">
<block wx:for-items="{{emotionArr}}" wx:key='index' wx:if="{{index>=69&&index<92}}">
<image bindtap="selectEmotion" data-txt="{{item.text}}" src="{{emotionHost+item.name}}.png" class="slide-image" />
</block>
<image src="../../../icon/chat/delete.png" bindtap="deleteVal" class="slide-image" />
</swiper-item>
</swiper>
</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>
app/nyx-dev/pages/live/live-info/live-info.wxss
查看文件 @
8d728f61
.scroll-view_H{
position: relative;
width: 100%;
text-align: center;
transform: scale(1);
white-space: nowrap;
.page{
height: 100vh;
background: #F4F8FB;
}
.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); */
.weui-cell__hd {
font-size: 0;
}
.weui-cell__hd image {
width: 100rpx;
height: 100rpx;
margin-right: 18px;
margin-left: 5px;
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;
.weui-cell__ft_in-access {
padding-right:13px;
position:relative;
}
.note-column{
.userInfo{
width: 100%;
display: flex;
flex-direction: column;
margin-left: 30rpx;
align-items: center;
justify-content: center;
overflow: hidden;
}
.note-column-left{
width : 140rpx;
margin-left: 5%;
display: flex;
.thumb{
width: 120rpx;
height: 120rpx;
border-radius: 50%;
overflow: hidden;
}
.writer-image{
width: 140rpx;
height: 140rpx;
.name{
margin: 30rpx;
}
/* 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;
}
/* 公屏 */
/*轮播控件 - start*/
.bottom_placeholder {
position: relative;
width: 100%;
height: 160rpx;
line-height: 10rpx;
}
.home-swiper {
width: 100%;
height: 400rpx;
}
.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;
.slide-image {
width: 100%;
height: 100%;
}
.align{
align-items: center;
/*轮播控件 - end*/
.wrapper {
padding-top: 20rpx;
padding-bottom: 100rpx;
}
.list .items{
display: flex;
flex-direction: column;
text-align: center;
align-items: center;
.message-list {
margin: 10rpx 30rpx 30rpx;
}
.items image{
width: 60rpx;
height: 60rpx;
margin-top: 20rpx;
font-size: 0;
.chat {
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
box-sizing: border-box;
}
.chat-con {
padding: 20rpx;
border-radius: 8rpx;
font-size: 30rpx;
color: #333;
position: relative;
}
.items text{
/* display: block; */
text-align: center;
margin-top: 0rpx;
margin-bottom: 20rpx;
padding: 0rpx;
font-size: 28rpx;
/* left-message */
.chat-l {
align-items: flex-start;
}
.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;
*/
}
.avater {
width: 90rpx;
height: 90rpx;
position: relative;
}
.avater>image {
width: 100%;
height: 100%;
display: block;
border-radius: 10%;
}
.chat-con-l {
background-color: #fff;
margin-left: 120rpx;
margin-top: -50rpx;
}
.chat-con-l::after {
content: '';
border-width: 20rpx;
border-style: solid;
border-color: transparent #fff transparent transparent;
position: absolute;
top: 18rpx;
left: -28rpx;
}
/* right-message */
.chat-r {
align-items: flex-end;
}
.chat-con-r {
background-color: #7dca4a;
margin-right: 120rpx;
margin-top: 35rpx;
}
.chat-con-r::after {
content: '';
border-width: 20rpx;
border-style: solid;
border-color: transparent transparent transparent #7dca4a;
position: absolute;
top: 18rpx;
right: -28rpx;
}
.avater-r {
float: right;
}
/* input-message */
.message-input {
position: fixed;
bottom: 0;
width: 100%;
background-color: #efefef;
padding: 20rpx 0 0;
z-index: 99;
}
.message-input>input {
font-size: 30rpx;
border: solid #ddd 1rpx;
width: 71%;
min-height: 60rpx;
height: 100%;
margin-left: 20rpx;
padding: 5rpx 10rpx;
border-radius: 8rpx;
margin-bottom: 15rpx;
color: #333;
background-color: #fff;
}
.showSend{
width:65% !important;
}
.showAdd {
left:73% !important;
}
.message-input>button {
width: 100rpx;
height: 60rpx;
background-color: #7dca4a;
font-size: 28rpx;
color: #fff;
margin-top: -82rpx;
float: right;
margin-right: 20rpx;
padding: 0;
line-height: 60rpx;
}
.input-m {
width: 500rpx;
max-width: 500rpx;
height: 70rpx;
max-height: 70rpx;
border: solid red 1px;
margin-left: 80rpx;
position: relative;
display: inline-block;
top: -80rpx;
overflow-y: scroll;
background-color: #fff;
}
.c-date {
font-size: 26rpx;
color: #999;
padding: 10rpx 0 30rpx;
text-align: center;
width: 100%;
}
.message-input .input-img {
width: 60rpx;
height: 60rpx;
}
#rec {
position: absolute;
top: 26rpx;
left: 10rpx;
}
#face {
position: absolute;
top: 20rpx;
left: 80%;
}
#add {
position: absolute;
top: 20rpx;
left: 90%;
}
.nick-name-l {
position: absolute;
top: -2%;
left: 138%;
z-index: 2;
font-size: 24rpx;
color: #666;
width: 200rpx;
}
.nick-name-r {
position: absolute;
top: -10%;
right: -25%;
z-index: 2;
font-size: 24rpx;
color: #666;
width: 200rpx;
}
.media-img {
width: 120rpx;
height: 120rpx;
display: inline-block;
}
.media-box {
background-color: #f0f0f0;
border-top: solid #e1e1e1 1rpx;
}
.media-list {
width: 150rpx;
height: 150rpx;
padding: 10px;
text-align: center;
display: inline-block;
}
.media-list>view {
font-size: 26rpx;
color: #666;
}
.emotion-box {
background-color: #f0f0f0;
padding-bottom: 40rpx;
border-top: solid #e1e1e1 1rpx;
}
.emotion-list {
margin: 20rpx auto 0;
text-align: center;
}
.emotion-list>image {
width: 55rpx;
height: 55rpx;
margin: 15rpx 30rpx;
}
.emotion-padd {
padding-bottom: 77% !important;
}
.media-padd{
padding-bottom: 42% !important;
}
.message-img {
width: 300rpx;
height: 200rpx;
display: inline-block;
vertical-align: middle;
}
.tab-title{
height: 60rpx;
background: #fff;
border-top: 1px solid #fafafa;
padding: 16rpx;
line-height: 60rpx;
display:flex;
flex-direction: row;
}
.tab-title view{
flex:auto;
text-align:center;
}
.tab-content{
height: 60rpx;
background: #fff;
padding: 16rpx;
}
.rank-info{
background: #fff;
}
.border-tottom{
border-bottom:1rpx solid red;
}
.show{display:block;}
.hidden{display:none;}
/* rank-info */
.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: 12rpx;}
.rank-right{width: 50%; display: flex; padding-left:100rpx;}
.rank-right image{
width: 40rpx;
height: 40rpx;
font-size: 0;
}
.rank-row{
display: flex;
flex-direction: row;
}
\ No newline at end of file
app/nyx-dev/pages/live/live.js
查看文件 @
8d728f61
...
...
@@ -60,6 +60,25 @@ Page({
//活动类型
activityType
:
"00-饮事"
,
lives
:
[
{
sid
:
"134"
,
note_image
:
"https://930-test-sh.oss-cn-shanghai.aliyuncs.com/user-dir/wx72555e77d9e5cee2.o6zAJszSNHnFKy8FTV5dg-Z7XDzQ.WaSJaxPezrVxcdaf58fbf674e7d3be131826ff708fa6.jpg"
,
title
:
"巅峰赛第一"
,
num_watcher
:
1029
,
streamer_name
:
"Azz·口袋"
,
streamer_logo
:
"../../icon/icon_avatar3.png"
},
{
sid
:
"123"
,
note_image
:
"https://930-test-sh.oss-cn-shanghai.aliyuncs.com/user-dir/wx72555e77d9e5cee2.o6zAJszSNHnFKy8FTV5dg-Z7XDzQ.WaSJaxPezrVxcdaf58fbf674e7d3be131826ff708fa6.jpg"
,
title
:
"单排84-101 把把C 不混"
,
num_watcher
:
2040
,
streamer_name
:
"六尾【混子】"
,
streamer_logo
:
"../../icon/icon_avatar3.png"
},
],
},
switchCategory
(
e
)
{
...
...
app/nyx-dev/pages/live/live.wxml
查看文件 @
8d728f61
<wxs module="tutil" src="./../../utils/date.wxs"></wxs>
<!--
现场模快
需求重点: 谁看, 看什么,
需求目标: 专业+好玩
Req1-11_25
1. 现场标签: 图片, 名字, 在看人数, 主播
2. 搜索形式: 城市 + 搜索框(店名)
3. 展示形式: 我关注的人(id), 在看自动倒序()
4. 播放形式: 图文
-->
<view class="page">
<!-- 搜索框 -->
<!--refer https://blog.csdn.net/weixin_44022446/article/details/86438015 -->
...
...
@@ -74,13 +85,6 @@
</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>
<!-- 文章列表 -->
<!--
...
...
@@ -92,33 +96,28 @@
-->
<!-- Content: refer to 有品·优惠券 + 点评(可使用) -->
<view class="coupon-list" wx:for="{{
activiti
es}}" wx:for-item="item" wx:key="{{index}}">
<view class="item stamp stamp01"
style="192rpx;"
>
<view class="coupon-list" wx:for="{{
liv
es}}" wx:for-item="item" wx:key="{{index}}">
<view class="item stamp stamp01">
<!-- 商品信息 -->
<view class="note-row">
<navigator url='
{{item.url}}&num_like={{item.num_lik
e}}' >
<image class="writer-image" src="{{item.note_image
[0]
}}"/>
<navigator url='
live-info/live-info?sid={{item.sid}}&streamer_name={{item.streamer_nam
e}}' >
<image class="writer-image" src="{{item.note_image}}"/>
</navigator>
<view class="note-column">
<navigator url='
{{item.url}}&num_like={{item.num_lik
e}}' >
<navigator url='
live-info/live-info?sid={{item.sid}}&streamer_name={{item.streamer_nam
e}}' >
<!-- 商家信息 -->
<text>{{item.title}}</text>
<!-- 商品价格 -->
<span>
<view class="price-row">
<view class="sub-price">
¥{{item.unit_price}}
</view>
<view class="sub-price">
{{item.num_watcher}}人在看
</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>
<view class="desc-member-left">
<image src="{{item.note_image}}"/>{{item.streamer_name}}</view>
<!-- todo 店铺功能尚未实现 -->
<!-- <view class="desc-member-right">进店 ></view> -->
</view>
...
...
app/nyx-dev/pages/live/live.wxss
查看文件 @
8d728f61
...
...
@@ -66,8 +66,8 @@
}
/* coupon css */
.coupon-list{width: 100%; margin: 0 auto}
.coupon-list .item{width: 100%;
height: 300rpx;
}
.coupon-list{width: 100%; margin: 0 auto
; padding-top: 10rpx;
}
.coupon-list .item{width: 100%;}
.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}
...
...
@@ -384,6 +384,11 @@
color: #a7a7a7;
margin-right: 20rpx;
}
.desc-member-left image{
width: 40rpx;
height: 40rpx;
font-size: 0;
}
.desc-member-right {
font-size: 30rpx;
...
...
app/nyx-dev/pages/share/share.js
查看文件 @
8d728f61
...
...
@@ -48,7 +48,7 @@ Page({
//格式示例数据,可为空
allContentList
:
[],
num
:
0
,
sid
:
"
key
"
,
sid
:
"
mall
"
,
chatUserInfo
:
{},
scrollTop
:
0
,
...
...
@@ -379,7 +379,7 @@ Page({
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
//
app.closeSocket();
app
.
closeSocket
();
console
.
log
(
'===onUnload webSocket 连接关闭事件。'
)
},
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论