Commit 8a2edc15 by jscat

nyx weapp: 功能更新

1. 新增redis 更新/查询操作
2. input框focus时候,小键盘不会让页面弹起
parent 85e38785
......@@ -80,5 +80,7 @@ var config={
pay_callback_url: host_key + "/api/nyx/wx/pay/notify",
upload_url: host_key + "/api/nyx/upload/pic",
image_url: host_key + "/images/",
redis_update_like_url: host_key + "/api/nyx/redis/update/like",
redis_query_like_url: host_key + "/api/nyx/redis/search/like",
}
module.exports=config;
\ No newline at end of file
......@@ -91,6 +91,8 @@ Page({
like:40
}
],
bottom_val: 0,
},
......@@ -176,15 +178,19 @@ Page({
emotionHost: app.globalData.emotionHost
})
//构建榜单数据
var raw = _this.__data__.rankData_raw_like
_this.genRankData(raw, '@')
//构建榜单数据
_this.onGetRedisLike()
//var raw = _this.__data__.rankData_raw_like
//_this.genRankData(raw, '@')
},
// 初始化socket, 监听socket
onShow: function () {
var _this = this;
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 != "") {
......@@ -354,6 +360,22 @@ Page({
console.log('===onUnload webSocket 连接关闭事件。')
},
//聚焦
inputFocus:function(e)
{
console.log(e)
var _this = this;
_this.setData({
bottom_val: e.detail.height==0 ? 0 : e.detail.height - 80
})
},
inputBlur: function(e){
console.log(e)
var _this = this;
_this.setData({
bottom_val: 0
})
},
//发送消息
messageSend: function () {
......@@ -527,6 +549,7 @@ Page({
'type': type
})
_this.sendSocketMessage(msg)
_this.onUpdateRedisLike(inputValue)
}
},
......@@ -710,7 +733,7 @@ Page({
{
if(raw.hasOwnProperty(newVal[i]))
{
raw[newVal[i]] = raw[newVal[i]]+1
raw[newVal[i]] = parseInt(raw[newVal[i]])+1
}
else
{
......@@ -840,7 +863,86 @@ Page({
}
_this.setData({rankData })
}
},
updateRedisLike: 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完成");
}
},
fail : function(res)
{
console.log("===updateRedisLike失败")
}
})
},
//调用java接口, 同步更新redis的like数据
onUpdateRedisLike: function(text)
{
var _this = this;
var reg = /(@|#)\S.+?(\s+|$)/g;
let newList = text.match(reg);
if(newList != null)
{
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)
}
},
//调用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失败")
}
})
},
//调用java接口, 同步get redis的like数据
onGetRedisLike: function(){
var _this = this;
var strUrl = config.redis_query_like_url
config.debug == 1?console.log("===getRedisLike strUrl "+strUrl):""
_this.getRedisLike(strUrl)
},
})
......
<!--pages/share/share.wxml-->
<view class="page">
<!-- start key view -->
<view class="tab">
<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>
......@@ -54,8 +54,8 @@
</view>
<!-- 消息输入 -->
<view class="message-input">
<input class="{{isShowAdd?'':'showSend'}}" placeholder="请输入内容" type="text" value="{{messageInputVal}}" cursor-spacing="10" bindinput='messageInput' confirm-type="send" bindconfirm="messageSend" />
<view class="message-input" style="position:fixed; bottom:{{bottom_val}}px">
<input class="{{isShowAdd?'':'showSend'}}" placeholder="请输入内容" type="text" value="{{messageInputVal}}" cursor-spacing="10" 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>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论