Browse Source

upload

master
HolyKnightIX 1 year ago
parent
commit
7d892ac2a2
3 changed files with 45 additions and 44 deletions
  1. +35
    -35
      miniprogram/pages/chat/chat.js
  2. +6
    -5
      miniprogram/pages/chat/chat.less
  3. +4
    -4
      miniprogram/pages/chat/chat.wxml

+ 35
- 35
miniprogram/pages/chat/chat.js View File

@@ -27,8 +27,8 @@ Page({
onLoad() {
this.socketLink()
this.chatLimit()
this.msgSec('习大大')
this.msgSec('习大大')
this.msgSec('共产党')
this.msgSec('法轮功')
},

// 敏感词检测
@@ -36,14 +36,13 @@ Page({
const AccessToken = wx.getStorageSync('AccessToken')
const openId = wx.getStorageSync('openId')
const data = {
access_token: AccessToken,
content,
version: 2,
scene: 4,
openid: openId
}
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: {
"Content-Type": "application/json;charset=UTF-8",
},
@@ -247,25 +246,26 @@ Page({
}).exec();
},

// 2023-4-28,由于给text标签添加了user-select属性,弃用自定义复制按钮,以下注释代码即为
// 点击开始,在触发messageTouchEnd之前即为长按
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({
istouching: true,
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({
istouching: false,
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) {


+ 6
- 5
miniprogram/pages/chat/chat.less View File

@@ -207,19 +207,20 @@ page {

.inputBox {
display: inline-block;
width: 500rpx;
height: 60rpx;
width: 480rpx;
height: 70rpx;
line-height: 70rpx;
border-radius: 10rpx;
margin-right: 15rpx;
padding-left: 10rpx;
padding-left: 30rpx;
background-color: #ffffff;
}

.sendBtn {
display: inline-block;
width: 150rpx;
height: 60rpx;
line-height: 50rpx;
height: 70rpx;
line-height: 60rpx;
padding: 5rpx 0;
}
}

+ 4
- 4
miniprogram/pages/chat/chat.wxml View File

@@ -10,13 +10,13 @@
<image wx:if="{{item.id != 1}}" class="arrowWhite" src="../../asset/icon/arrowWhite.png" mode="heightFix" />

<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="text">复制</view>
<image class="arrowBlack" src="../../asset/icon/arrowBlack.png" mode="heightFix" />
</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 class="boxInside">
@@ -38,7 +38,7 @@

<view class="chatBox">
<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>
</view>
</view>

Loading…
Cancel
Save