Browse Source

修复菜单移动异常的bug

master
xsx 1 year ago
parent
commit
1e6df97d94
  1. 4
      im-uniapp/.env.js
  2. 13
      im-uniapp/components/chat-item/chat-item.vue
  3. 18
      im-uniapp/components/pop-menu/pop-menu.vue

4
im-uniapp/.env.js

@ -2,8 +2,8 @@
const ENV = "DEV"; const ENV = "DEV";
const UNI_APP = {} const UNI_APP = {}
if(ENV=="DEV"){ if(ENV=="DEV"){
UNI_APP.BASE_URL = "http://192.168.43.199:8888"; UNI_APP.BASE_URL = "http://127.0.0.1:8888";
UNI_APP.WS_URL = "ws://192.168.43.199:8878/im"; UNI_APP.WS_URL = "ws://127.0.0.1:8878/im";
// H5 走本地代理解决跨域问题 // H5 走本地代理解决跨域问题
// #ifdef H5 // #ifdef H5
UNI_APP.BASE_URL = "/api"; UNI_APP.BASE_URL = "/api";

13
im-uniapp/components/chat-item/chat-item.vue

@ -7,10 +7,10 @@
</view> </view>
<view class="chat-right"> <view class="chat-right">
<view class="chat-name"> <view class="chat-name">
<view class="chat-name-text"> <view class="chat-name-text">
<view>{{chat.showName}}</view> <view>{{chat.showName}}</view>
<uni-tag v-if="chat.type=='GROUP'" circle text="群" size="small"></uni-tag> <uni-tag v-if="chat.type=='GROUP'" circle text="群" size="small"></uni-tag>
</view> </view>
<view class="chat-time">{{$date.toTimeText(chat.lastSendTime,true)}}</view> <view class="chat-time">{{$date.toTimeText(chat.lastSendTime,true)}}</view>
</view> </view>
<view class="chat-content"> <view class="chat-content">
@ -135,12 +135,15 @@
align-items: center; align-items: center;
.uni-tag { .uni-tag {
text-align: center;
margin-left: 5rpx; margin-left: 5rpx;
background-color: #5a60d2;
border: 0; border: 0;
height: 30rpx; height: 30rpx;
line-height: 30rpx; line-height: 30rpx;
font-size: 20rpx; font-size: 20rpx;
padding: 1px 5px;
background-color: #de1c1c;
opacity: 0.8;
} }
} }

18
im-uniapp/components/pop-menu/pop-menu.vue

@ -1,10 +1,9 @@
<template> <template>
<view> <view>
<view @longpress.stop="onLongPress($event)" @touchmove="onTouchMove" @touchend="onTouchEnd"> <view @longpress.stop="onLongPress($event)" @touchmove="onTouchMove">
<slot></slot> <slot></slot>
</view> </view>
<view v-if="isShowMenu" class="pop-menu" @touchstart="onClose()" @contextmenu.prevent=""></view>
<view v-if="isShowMenu" class="pop-menu" @tap="onClose()" @contextmenu.prevent=""></view>
<view v-if="isShowMenu" class="menu" :style="menuStyle"> <view v-if="isShowMenu" class="menu" :style="menuStyle">
<view class="menu-item" v-for="(item) in items" :key="item.key" @click.prevent="onSelectMenu(item)"> <view class="menu-item" v-for="(item) in items" :key="item.key" @click.prevent="onSelectMenu(item)">
<uni-icons class="menu-icon" :type="item.icon" :style="itemStyle(item)" size="22"></uni-icons> <uni-icons class="menu-icon" :type="item.icon" :style="itemStyle(item)" size="22"></uni-icons>
@ -30,9 +29,6 @@
}, },
methods: { methods: {
onLongPress(e){ onLongPress(e){
if(this.isTouchMove){
return;
}
uni.getSystemInfo({ uni.getSystemInfo({
success: (res) => { success: (res) => {
let touches = e.touches[0]; let touches = e.touches[0];
@ -57,10 +53,7 @@
}) })
}, },
onTouchMove(){ onTouchMove(){
this.isTouchMove = true; this.onClose()
},
onTouchEnd(){
this.isTouchMove = false;
}, },
onSelectMenu(item) { onSelectMenu(item) {
this.$emit("select", item); this.$emit("select", item);
@ -89,9 +82,8 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: #333; background-color: #333;
z-index: 99; z-index: 999;
opacity: 0.5; opacity: 0.5;
} }
.menu { .menu {
@ -100,7 +92,7 @@
border-radius: 7px; border-radius: 7px;
overflow: hidden; overflow: hidden;
background-color: #f5f6ff; background-color: #f5f6ff;
z-index: 100; z-index: 1000;
.menu-item { .menu-item {
height: 25px; height: 25px;
min-width: 150rpx; min-width: 150rpx;

Loading…
Cancel
Save