diff --git a/jiuyi2/common/js/config.js b/jiuyi2/common/js/config.js index d9448b2f..4336ad84 100644 --- a/jiuyi2/common/js/config.js +++ b/jiuyi2/common/js/config.js @@ -7,6 +7,10 @@ const config = { // #endif // #ifndef H5 host: 'http://91f.xyz:8080', +<<<<<<< HEAD + // host: 'https://1a880cd5.r24.cpolar.top/', +======= +>>>>>>> 409f137e8990b13381bdbe7efca7eec9a3cfc89e // #endif // 支付方式配置 payType: { diff --git a/jiuyi2/common/js/util.js b/jiuyi2/common/js/util.js index c15d4db3..4be3b323 100644 --- a/jiuyi2/common/js/util.js +++ b/jiuyi2/common/js/util.js @@ -66,14 +66,14 @@ const util = { showCancel: obj.showCancel, cancelText: obj.cancelText, success: res => { - obj.success ? obj.success(res) : () => {} + obj.success ? obj.success(res) : () => { } resolve(res) }, fail: err => { - obj.fail ? obj.fail(err) : () => {} + obj.fail ? obj.fail(err) : () => { } reject(err) }, - complete: res => {} + complete: res => { } }) }) }, @@ -920,7 +920,7 @@ const util = { const file_suffix = util.config[{ 'file': 'file_suffix', 'audio': 'audio_suffix', - } [type]] + }[type]] let result = '' if (url) result = file_suffix.find(item => item.id === url.split('.').pop().toLowerCase()) return result @@ -1046,7 +1046,7 @@ const util = { obj.fail ? obj.fail('no data') : '' } break - // app支付 + // app支付 case "app": uni.requestPayment({ provider: "wxpay", @@ -1068,7 +1068,7 @@ const util = { break } break - // 支付宝支付 + // 支付宝支付 case "2": switch (obj.method) { // app支付 @@ -1093,7 +1093,7 @@ const util = { break } break - // 钱包支付 + // 钱包支付 case "4": obj.success ? obj.success(rs) : '' result_goto('success') @@ -1165,7 +1165,7 @@ const util = { util.alert("您拒绝了授权"); // 失败 - obj.fail ? obj.fail(res) : (res) => {}; + obj.fail ? obj.fail(res) : (res) => { }; }, complete() { // 结束 @@ -1365,11 +1365,11 @@ const util = { return new Promise((resolve, reject) => { // 是否在微信小程序限制范围内 if (!['scope.userInfo', 'scope.userLocation', 'scope.userLocationBackground', - 'scope.address', - 'scope.record', 'scope.writePhotosAlbum', 'scope.camera', - 'scope.invoice', - 'scope.invoiceTitle', 'scope.werun' - ].includes(obj.scope)) { + 'scope.address', + 'scope.record', 'scope.writePhotosAlbum', 'scope.camera', + 'scope.invoice', + 'scope.invoiceTitle', 'scope.werun' + ].includes(obj.scope)) { resolve({ msg: '不在限制范围内', }) @@ -1463,11 +1463,32 @@ const util = { userID: userinfo.id + '', userSig: imSig, }).then(rs => { + util.updateMyProfile(userinfo) console.log('im login success', rs) }) }) }, + // 更新im个人资料 + updateMyProfile(userinfo) { + // 验证sdk是否准备完毕 + let isReady = uni.$chat.isReady(); + if (!isReady) { + setTimeout(function () { + util.updateMyProfile(userinfo); + }, 800); + return + } + + let obj = { + nick: userinfo.userNickname, + avatar: userinfo.avatar + } + uni.$chat.updateMyProfile(obj).then(res => { + // console.log(res); + }) + }, + /** * 获取用户信息 * @param {Function} cb 回调函数 @@ -1728,7 +1749,7 @@ const util = { } }); }, - showToastAndRedirect(title, icon = 'none', fun = () => {}) { + showToastAndRedirect(title, icon = 'none', fun = () => { }) { uni.showToast({ title, icon, diff --git a/jiuyi2/components/news/msgList.vue b/jiuyi2/components/news/msgList.vue index 48b77f75..637dc962 100644 --- a/jiuyi2/components/news/msgList.vue +++ b/jiuyi2/components/news/msgList.vue @@ -111,6 +111,7 @@ function getList() { uni.$chat.getConversationList().then(rs => { let res = rs.data.conversationList + console.log(res); let arr = [] res.forEach(item => { let obj = {} @@ -172,16 +173,16 @@ function handleList(list) { list.forEach(item => { item.MsgTime = handleDate(item.MsgTime) - let type = item.Type == 1 ? `C2C${item.To_Account}` : `GROUP${item.GroupId}`; + let type = item.type == 'C2C' ? `C2C${item.To_Account}` : `GROUP${item.GroupId}`; uni.$chat.getConversationProfile(type).then(rs => { let res = rs.data.conversation; item.chatText = res.lastMessage.messageForShow; item.unreadCount = res.unreadCount; - if (item.Type == 1) { + if (item.type == 'C2C') { item.avatar = res.userProfile.avatar; item.name = res.userProfile.nick; - } else if (item.Type == 2) { + } else if (item.type == 'GROUP') { item.avatar = res.groupProfile.avatar; item.name = res.groupProfile.name; item.num = res.groupProfile.memberCount; @@ -255,7 +256,7 @@ function delMsg(item) { return } - let conversationId = item.Type == 1 ? `C2C${item.userID}` : `GROUP${item.groupID}`; + let conversationId = item.type == 'C2C' ? `C2C${item.userID}` : `GROUP${item.groupID}`; uni.$chat.deleteConversation(conversationId).then(rs => { getList() @@ -273,7 +274,7 @@ function setRead(item) { return } - let conversationId = item.Type == 1 ? `C2C${item.userID}` : `GROUP${item.groupID}`; + let conversationId = item.type == 'C2C' ? `C2C${item.userID}` : `GROUP${item.groupID}`; uni.$chat.setMessageRead({ conversationID: conversationId, }).then(rs => { diff --git a/jiuyi2/vite.config.js b/jiuyi2/vite.config.js index fc5535df..c88a2788 100644 --- a/jiuyi2/vite.config.js +++ b/jiuyi2/vite.config.js @@ -4,6 +4,10 @@ import { import uni from '@dcloudio/vite-plugin-uni'; let target = 'http://91f.xyz:8080' +<<<<<<< HEAD +// let target = 'https://1a880cd5.r24.cpolar.top/' +======= +>>>>>>> 409f137e8990b13381bdbe7efca7eec9a3cfc89e export default defineConfig({ plugins: [uni()],