@@ -27,8 +27,8 @@ Page({ | |||||
onLoad() { | onLoad() { | ||||
this.socketLink() | this.socketLink() | ||||
this.chatLimit() | this.chatLimit() | ||||
this.msgSec('习大大') | |||||
this.msgSec('习大大') | |||||
this.msgSec('共产党') | |||||
this.msgSec('法轮功') | |||||
}, | }, | ||||
// 敏感词检测 | // 敏感词检测 | ||||
@@ -36,14 +36,13 @@ Page({ | |||||
const AccessToken = wx.getStorageSync('AccessToken') | const AccessToken = wx.getStorageSync('AccessToken') | ||||
const openId = wx.getStorageSync('openId') | const openId = wx.getStorageSync('openId') | ||||
const data = { | const data = { | ||||
access_token: AccessToken, | |||||
content, | content, | ||||
version: 2, | version: 2, | ||||
scene: 4, | scene: 4, | ||||
openid: openId | openid: openId | ||||
} | } | ||||
wx.request({ | wx.request({ | ||||
url: 'https://api.weixin.qq.com/wxa/msg_sec_check?access_token=ACCESS_TOKEN', | |||||
url: `https://api.weixin.qq.com/wxa/msg_sec_check?access_token=${AccessToken}`, | |||||
header: { | header: { | ||||
"Content-Type": "application/json;charset=UTF-8", | "Content-Type": "application/json;charset=UTF-8", | ||||
}, | }, | ||||
@@ -247,25 +246,26 @@ Page({ | |||||
}).exec(); | }).exec(); | ||||
}, | }, | ||||
// 2023-4-28,由于给text标签添加了user-select属性,弃用自定义复制按钮,以下注释代码即为 | |||||
// 点击开始,在触发messageTouchEnd之前即为长按 | // 点击开始,在触发messageTouchEnd之前即为长按 | ||||
messageTouchStart(e) { | messageTouchStart(e) { | ||||
const timer = this.data.timer | |||||
const clearTimer = this.data.clearTimer | |||||
clearTimeout(timer) | |||||
clearTimeout(clearTimer) | |||||
this.setData({ | |||||
timer: null, | |||||
clearTimer: null, | |||||
}) | |||||
// const timer = this.data.timer | |||||
// const clearTimer = this.data.clearTimer | |||||
// clearTimeout(timer) | |||||
// clearTimeout(clearTimer) | |||||
// this.setData({ | |||||
// timer: null, | |||||
// clearTimer: null, | |||||
// }) | |||||
this.setData({ | this.setData({ | ||||
istouching: true, | istouching: true, | ||||
istouchingIndex: e.currentTarget.dataset.index, | istouchingIndex: e.currentTarget.dataset.index, | ||||
timer: setTimeout(() => { | |||||
this.setData({ | |||||
isHolding: true | |||||
}) | |||||
}, 200) | |||||
// timer: setTimeout(() => { | |||||
// this.setData({ | |||||
// isHolding: true | |||||
// }) | |||||
// }, 200) | |||||
}) | }) | ||||
}, | }, | ||||
@@ -274,28 +274,28 @@ Page({ | |||||
this.setData({ | this.setData({ | ||||
istouching: false, | istouching: false, | ||||
istouchingIndex: e.currentTarget.dataset.index, | istouchingIndex: e.currentTarget.dataset.index, | ||||
clearTimer: setTimeout(() => { | |||||
this.setData({ | |||||
isHolding: false | |||||
}) | |||||
}, 4000) | |||||
// clearTimer: setTimeout(() => { | |||||
// this.setData({ | |||||
// isHolding: false | |||||
// }) | |||||
// }, 4000) | |||||
}) | }) | ||||
const timer = this.data.timer | |||||
clearTimeout(timer) | |||||
// const timer = this.data.timer | |||||
// clearTimeout(timer) | |||||
}, | }, | ||||
// 复制信息 | // 复制信息 | ||||
copyMessage(e) { | |||||
if (!this.data.isHolding) return | |||||
const message = e.currentTarget.dataset.message | |||||
this.setData({ | |||||
isHolding: false | |||||
}) | |||||
const timer = this.data.timer | |||||
clearTimeout(timer) | |||||
this.setClipboardData(message) | |||||
}, | |||||
// copyMessage(e) { | |||||
// if (!this.data.isHolding) return | |||||
// const message = e.currentTarget.dataset.message | |||||
// this.setData({ | |||||
// isHolding: false | |||||
// }) | |||||
// const timer = this.data.timer | |||||
// clearTimeout(timer) | |||||
// this.setClipboardData(message) | |||||
// }, | |||||
// 监听聊天区域点击事件 | // 监听聊天区域点击事件 | ||||
contentWatch(e) { | contentWatch(e) { | ||||
@@ -207,19 +207,20 @@ page { | |||||
.inputBox { | .inputBox { | ||||
display: inline-block; | display: inline-block; | ||||
width: 500rpx; | |||||
height: 60rpx; | |||||
width: 480rpx; | |||||
height: 70rpx; | |||||
line-height: 70rpx; | |||||
border-radius: 10rpx; | border-radius: 10rpx; | ||||
margin-right: 15rpx; | margin-right: 15rpx; | ||||
padding-left: 10rpx; | |||||
padding-left: 30rpx; | |||||
background-color: #ffffff; | background-color: #ffffff; | ||||
} | } | ||||
.sendBtn { | .sendBtn { | ||||
display: inline-block; | display: inline-block; | ||||
width: 150rpx; | width: 150rpx; | ||||
height: 60rpx; | |||||
line-height: 50rpx; | |||||
height: 70rpx; | |||||
line-height: 60rpx; | |||||
padding: 5rpx 0; | padding: 5rpx 0; | ||||
} | } | ||||
} | } |
@@ -10,13 +10,13 @@ | |||||
<image wx:if="{{item.id != 1}}" class="arrowWhite" src="../../asset/icon/arrowWhite.png" mode="heightFix" /> | <image wx:if="{{item.id != 1}}" class="arrowWhite" src="../../asset/icon/arrowWhite.png" mode="heightFix" /> | ||||
<view class="{{item.id == 1 ? 'message right' : 'message left'}}"> | <view class="{{item.id == 1 ? 'message right' : 'message left'}}"> | ||||
<text>{{item.message}}</text> | |||||
<view wx:if="{{item.id == 1}}" id="copyBox" class="{{isHolding && istouchingIndex == index ? 'copyBoxRight active' : 'copyBoxRight'}}" bindtap="copyMessage" data-message="{{item.message}}"> | |||||
<text user-select="true">{{item.message}}</text> | |||||
<!-- <view wx:if="{{item.id == 1}}" id="copyBox" class="{{isHolding && istouchingIndex == index ? 'copyBoxRight active' : 'copyBoxRight'}}" bindtap="copyMessage" data-message="{{item.message}}"> | |||||
<view class="boxInside"> | <view class="boxInside"> | ||||
<view class="text">复制</view> | <view class="text">复制</view> | ||||
<image class="arrowBlack" src="../../asset/icon/arrowBlack.png" mode="heightFix" /> | <image class="arrowBlack" src="../../asset/icon/arrowBlack.png" mode="heightFix" /> | ||||
</view> | </view> | ||||
</view> | |||||
</view> --> | |||||
<view wx:if="{{item.id != 1}}" id="copyBox" class="{{isHolding && istouchingIndex == index ? 'copyBoxLeft active' : 'copyBoxLeft'}}" bindtap="copyMessage" data-message="{{item.message}}"> | <view wx:if="{{item.id != 1}}" id="copyBox" class="{{isHolding && istouchingIndex == index ? 'copyBoxLeft active' : 'copyBoxLeft'}}" bindtap="copyMessage" data-message="{{item.message}}"> | ||||
<view class="boxInside"> | <view class="boxInside"> | ||||
@@ -38,7 +38,7 @@ | |||||
<view class="chatBox"> | <view class="chatBox"> | ||||
<view class="boxOutside"> | <view class="boxOutside"> | ||||
<input class="inputBox" type="text" bindinput="input" value="{{message}}" placeholder="单次最多可输入{{saysContentLength}}字" /> | |||||
<input class="inputBox" type="text" bindinput="input" value="{{message}}" placeholder="单次最多可输入{{saysContentLength}}字" cursor-spacing="20" confirm-type="send" /> | |||||
<button class="sendBtn" type="primary" bindtap="send">发送</button> | <button class="sendBtn" type="primary" bindtap="send">发送</button> | ||||
</view> | </view> | ||||
</view> | </view> |