From ba84ea2bc77bfbc0f9052add0f90d0075a915249 Mon Sep 17 00:00:00 2001 From: rowger Date: Wed, 27 Sep 2023 09:05:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=97=A7=E6=8E=A5=E5=8F=A3=E6=94=B9?= =?UTF-8?q?=E4=B8=BAsdk=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/store/index.js | 50 ++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/im-uniapp/store/index.js b/im-uniapp/store/index.js index e29d112..de29e4e 100644 --- a/im-uniapp/store/index.js +++ b/im-uniapp/store/index.js @@ -7,6 +7,11 @@ Vue.use(Vuex) const store = new Vuex.Store({ // #endif + +import * as sdk from "@/common/imSdk/lim-sdk.js"; + +import lim from "@/common/imSdk/sdk-bridge.js"; + // #ifdef VUE3 import { createStore } from 'vuex' const store = createStore({ @@ -73,21 +78,18 @@ import { createStore } from 'vuex' }) }, get_UserInfo (context) { + // TODO 改用SDK的更新用户数据 return new Promise((resolve, reject) => { - http.request({ - url: '/my/getInfo', - success: (res) => { - if (res.data.code == 200) { - context.commit('update_UserInfo',JSON.stringify(res.data.data)) - resolve(res.data.data) - }else{ - reject(res.data) - } - }, - fail: (error) => { - reject(error) - } - }); + const userId = uni.getStorageSync("userId") + + lim.lim.im.getSingleUserInfo(userId).then((res)=>{ + if(res.code==200){ + context.commit('update_UserInfo',JSON.stringify(res.data)) + resolve(res.data) + }else{ + reject(res.data) + } + }) }) }, getchatDatalist(context) {//获取聊天数据列表 @@ -122,6 +124,7 @@ import { createStore } from 'vuex' uni.setStorageSync(context.state.userInfo.userId+'_'+'chatlistData', JSON.stringify(retdata)); }, createChatObj(context,data){ + var userId=data.userId var windowType=data.windowType //初始化聊天记录 @@ -138,11 +141,17 @@ import { createStore } from 'vuex' switch (windowType){ case 'SINGLE': - http.request({ - url: '/friend/info/'+userId, - complete:(res)=>{ - if (res.data.code == 200) { - var detail=res.data.data + // lim.lim.im.getSingleUserInfo(userId).then(res=>{ + // console.warn(res) + // }) + + lim.lim.im.getSingleUserInfo(userId).then((res)=>{ + console.log(res.data) + console.log(res.data) + console.log(res.data) + console.log(res.data) + if (res.code == 200) { + var detail=res.data data1[userId]={ fromInfo:{ nickName: detail.nickName, @@ -153,6 +162,7 @@ import { createStore } from 'vuex' groupInfo:{}, list:[] } + uni.setStorageSync(context.state.userInfo.userId+'_'+'chatData', JSON.stringify(data1)); // 创建记录 var msgList = { @@ -182,7 +192,7 @@ import { createStore } from 'vuex' }); } } - }); + ); break; case 'GROUP': http.request({