Refactor(客服):接收传输使用uid字段

This commit is contained in:
lifizer
2024-07-05 18:19:18 +08:00
parent d1813f3dca
commit fc392a5e01
2 changed files with 32 additions and 43 deletions
+8 -16
View File
@@ -49,15 +49,14 @@
</template>
<script>
import {userUnionId} from "@/api/public";
import { mapGetters } from 'vuex'
export default {
name: "room",
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
token: null,
unionId: null,
uid: null,
userInfo: null,
storeId: null,
merName: null,
@@ -72,6 +71,7 @@ export default {
list: [], //消息列表
}
},
computed: mapGetters(['userInfo']),
onLoad(options) {
this.storeId = options.id;
this.merName = options.name;
@@ -82,7 +82,8 @@ export default {
}
this.token = uni.getStorageSync("login_status");
this.userInfo = uni.getStorageSync("userInfo");
this.getUnionId();
this.uid = this.userInfo.uid
this.connectSocketInit()
},
onUnload() {
if (this.socketOpen) {
@@ -90,15 +91,6 @@ export default {
}
},
methods: {
getUnionId() {
userUnionId().then(res => {
if (res.success) {
this.unionId = res.data;
this.connectSocketInit();
}
});
},
getUploadToken() {
let that = this;
@@ -136,7 +128,7 @@ export default {
let param = {
type: "msg",
user_type: 0,
unionid: that.unionId,
uid: that.uid,
username: that.userInfo.nickname,
header: that.userInfo.avatar,
room_id: that.roomId,
@@ -201,7 +193,7 @@ export default {
let param = {
type: "msg",
user_type: 0,
unionid: this.unionId,
uid: this.uid,
username: this.userInfo.nickname,
header: this.userInfo.avatar,
room_id: this.roomId,
@@ -217,7 +209,7 @@ export default {
let param = {
type: "join",
user_type: 0,
unionid: this.unionId,
uid: this.uid,
username: this.userInfo.nickname,
header: this.userInfo.avatar,
store_id: this.storeId
+24 -27
View File
@@ -1,17 +1,21 @@
<template>
<view class="common-roomLogs">
<view class="item flex" v-for="(item,index) in list" :key="index" @click="goRoom(item)"
v-if="list.length>0">
<image class="cover flex-0" :src="item.store_avatar || webUrl+'/20221114155314348118.png'"/>
<view>
<view class="flex jc-between ai-center">
<view class="name">{{ item.store_name }}</view>
<view class="datetime" v-if="item.last_msg">{{ item.last_msg.created_at }}</view>
<view v-if="list.length > 0">
<view
v-for="(item,index) in list"
:key="index" @click="goRoom(item)"
class="item flex"
>
<image class="cover flex-0" :src="item.store_avatar || webUrl+'/20221114155314348118.png'"/>
<view>
<view class="flex jc-between ai-center">
<view class="name">{{ item.store_name }}</view>
<view class="datetime" v-if="item.last_msg">{{ item.last_msg.created_at }}</view>
</view>
<view class="sub one-t" v-if="item.last_msg">{{ item.last_msg.msg_type===0?item.last_msg.msg_content:'[图片]' }}</view>
</view>
<view class="sub one-t" v-if="item.last_msg">{{ item.last_msg.msg_type===0?item.last_msg.msg_content:'[图片]' }}</view>
</view>
</view>
<view class="v4-nodata" v-if="list.length===0">
<image src="@/static/images/img_nodata.png" mode="scaleToFill"/>
<view class="text">暂无数据</view>
@@ -20,42 +24,35 @@
</template>
<script>
import {userUnionId} from "@/api/public";
import { mapGetters } from 'vuex'
export default {
name: "roomLogs",
name: 'RoomLogs',
data() {
return {
webUrl:this.$VUE_APP_RESOURCES_URL,
unionId: null,
uid: null,
list: []
}
},
computed: mapGetters(['userInfo']),
onShow() {
this.getUnionId();
this.uid = this.userInfo.uid
this.fetchList()
},
methods: {
goRoom(item) {
uni.navigateTo({url: `/pkg_common/views/room?id=${item.store_id}&name=${item.store_name}`})
},
getUnionId() {
userUnionId().then(res => {
if (res.success) {
this.unionId = res.data;
this.fetchList();
}
});
},
fetchList() {
const _this = this
uni.request({
url: this.$SERVICE_API_URL + "/customer-chat-list",
method: "POST",
data: {unionid: this.unionId},
url: _this.$SERVICE_API_URL + '/customer-chat-list',
method: 'POST',
data: {uid: _this.uid},
success: res => {
if (res.data.status_code === 200) {
this.list = res.data.content;
_this.list = res.data.content
}
}
})