扫码加好友修复

This commit is contained in:
2022-01-28 10:12:37 +08:00
parent 572066de9a
commit 8e047408e2
4 changed files with 206 additions and 201 deletions

View File

@@ -104,7 +104,8 @@
callShow: false callShow: false
} }
}, },
onLoad(e) { onLoad(e) {
console.log(e);
this.targetId = e.targetId this.targetId = e.targetId
getFriendInfo(e.targetId).then(res => { getFriendInfo(e.targetId).then(res => {
this.userInfo = res this.userInfo = res
@@ -243,16 +244,14 @@
}) })
}, },
singleCall(e) { singleCall(e) {
CallLib.startSingleCall(this.targetId, e.type, ''); uni.showToast({
uni.redirectTo({ icon: 'none',
url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type, title: '功能正在开发中'
success: (err) => {
console.log('跳转视频通话成功');
},
fail: (err) => {
console.log('跳转视频页失败', err);
}
}) })
// CallLib.startSingleCall(this.targetId, e.type, '');
// uni.redirectTo({
// url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type
// })
} }
} }
} }

View File

@@ -1,183 +1,191 @@
<template> <template>
<view class="content"> <view class="content">
<!-- 用户信息 --> <!-- 用户信息 -->
<view class="info-flex"> <view class="info-flex">
<u-avatar <u-avatar :src="infoObj.portraitUrl" shape="square" size="50" bg-color="#fff"></u-avatar>
:src="infoObj.portraitUrl" <view class="info-text">
shape="square" <view class="nickname">{{infoObj.name}}</view>
size="50" <view class="address">地址{{infoObj.address}}</view>
bg-color="#fff" </view>
></u-avatar> </view>
<view class="info-text"> <!-- 用户身份 -->
<view class="nickname">{{infoObj.name}}</view> <view class="info-btns">
<view class="address">地址{{infoObj.address}}</view> <view class="item">
</view> <label>性别</label>
</view> <view class="text" v-if="infoObj.gender === 0">保密</view>
<!-- 用户身份 --> <view class="text" v-if="infoObj.gender === 1"></view>
<view class="info-btns"> <view class="text" v-if="infoObj.gender === 2"></view>
<view class="item"> </view>
<label>性别</label> <view class="item">
<view class="text" v-if="infoObj.gender === 0">保密</view> <label>HASH</label>
<view class="text" v-if="infoObj.gender === 1"></view> <view class="text">{{infoObj.hash}}</view>
<view class="text" v-if="infoObj.gender === 2"></view> </view>
</view> </view>
<view class="item"> <!-- 二维码 -->
<label>HASH</label> <view class="info-code">
<view class="text">{{infoObj.hash}}</view> <uqrcode class="info-code-src" :size="198" ref="uQRCode" :text="qrContent" />
</view> <view class="info-code-text">
</view> <view>ZH-HEALTH扫一扫上面的二维码</view>
<!-- 二维码 --> <view>添加我的好友</view>
<view class="info-code"> </view>
<uqrcode class="info-code-src" :size="198" ref="uQRCode" text="qrContent" /> </view>
<view class="info-code-text"> </view>
<view>ZH-HEALTH扫一扫上面的二维码</view> </template>
<view>添加我的好友</view>
</view> <script>
</view> import {
</view> getUserInfo
</template> } from '@/apis/interfaces/im'
export default {
<script> data() {
import { getUserInfo } from '@/apis/interfaces/im' return {
export default{ infoObj: {
data(){ userId: '',
return{ username: '',
infoObj: { name: '',
userId : '', address: '',
username : '', portraitUrl: '',
name : '', gender: 0,
address : '', hash: ''
portraitUrl : '', },
gender : 0, qrContent: 'ADDFRIEND|'
hash : '' }
}, },
qrContent: 'ADDFRIEND|' onLoad(e) {},
} mounted() {
}, getUserInfo(this.$Route.query.targetId).then(res => {
onLoad(e){ this.infoObj = res
console.log(e) this.qrContent += res.userId
})
}, },
mounted() { methods: {
getUserInfo(this.$Route.query.targetId).then(res => {
this.infoObj = res }
this.qrContent += res.userId }
console.log(this.infoObj) </script>
})
}, <style lang="scss" scoped>
methods: { .content {
background: $window-color;
} min-height: 100vh;
} padding-top: $padding;
</script> box-sizing: border-box;
<style lang="scss" scoped> .info-code {
.content{ background: white;
background: $window-color; margin: 0 $margin;
min-height: 100vh; border-radius: $radius;
padding-top: $padding; padding: $padding*3 $padding $padding;
box-sizing: border-box; text-align: center;
.info-code{
background: white; &-src {
margin: 0 $margin; display: inline-block;
border-radius: $radius; }
padding: $padding*3 $padding $padding;
text-align: center; &-text {
&-src{ text-align: center;
display: inline-block; color: $text-gray;
} font-size: $title-size-sm;
&-text{ line-height: 40rpx;
text-align: center; padding: $padding 0;
color: $text-gray; }
font-size: $title-size-sm; }
line-height: 40rpx;
padding: $padding 0; // 用户信息
} .info-flex {
} padding: $padding;
// 用户信息 margin: 0 $margin;
.info-flex{ display: flex;
padding: $padding; background: white;
margin: 0 $margin; border-radius: $radius;
display: flex;
background: white; .info-text {
border-radius: $radius; width: calc(100% - 50px);
.info-text{ padding-left: $padding;
width: calc(100% - 50px); box-sizing: border-box;
padding-left: $padding;
box-sizing: border-box; .nickname {
.nickname{ line-height: 30px;
line-height: 30px; font-size: $title-size + 6;
font-size: $title-size + 6; color: $text-color;
color: $text-color; text-align: left;
text-align: left; }
}
.address{ .address {
line-height: 20px; line-height: 20px;
font-size: $title-size-sm; font-size: $title-size-sm;
color: $text-gray; color: $text-gray;
text-align: left; text-align: left;
@extend .nowrap; @extend .nowrap;
} }
} }
} }
// footer // footer
.footer{ .footer {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
padding: $padding*2 $padding; padding: $padding*2 $padding;
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
.footer-item{
margin: 0 $margin/2; .footer-item {
.icon{ margin: 0 $margin/2;
background: $main-color;
width: 88rpx; .icon {
height: 88rpx; background: $main-color;
line-height: 88rpx; width: 88rpx;
display: inline-block; height: 88rpx;
border-radius: 50%; line-height: 88rpx;
.icon-u{ display: inline-block;
margin-top: calc((88rpx/2) - 13px); border-radius: 50%;
margin-left: calc((88rpx/2) - 13px);
} .icon-u {
} margin-top: calc((88rpx/2) - 13px);
.text{ margin-left: calc((88rpx/2) - 13px);
color: $main-color; }
font-size: $title-size-m; }
text-align: center;
padding-top: 10rpx; .text {
} color: $main-color;
} font-size: $title-size-m;
} text-align: center;
padding-top: 10rpx;
// btns }
.info-btns{ }
background: white; }
margin: $margin;
border-radius: $radius; // btns
.item{ .info-btns {
line-height: 100rpx; background: white;
border-bottom: solid 1rpx $border-color; margin: $margin;
display: flex; border-radius: $radius;
padding: 0 $padding;
justify-content: space-between; .item {
font-size: $title-size-lg; line-height: 100rpx;
&:last-child{ border-bottom: solid 1rpx $border-color;
border-bottom: none; display: flex;
} padding: 0 $padding;
label{ justify-content: space-between;
width: 200rpx; font-size: $title-size-lg;
}
.text{ &:last-child {
width: calc(100% - 200rpx); border-bottom: none;
color: $text-gray-m; }
text-align: right;
@extend .nowrap; label {
} width: 200rpx;
} }
}
.text {
width: calc(100% - 200rpx);
color: $text-gray-m;
text-align: right;
@extend .nowrap;
}
}
}
} }
</style> </style>

View File

@@ -56,7 +56,7 @@
{{item}} {{item}}
</view> </view>
</view> </view>
</view> </view>
</block> </block>
</view> </view>
<!-- 未登录 --> <!-- 未登录 -->
@@ -74,7 +74,9 @@
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index" import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
import im from '@/utils/im/index.js' import im from '@/utils/im/index.js'
import userAuth from '@/public/userAuth' import userAuth from '@/public/userAuth'
import { getImToken } from '@/apis/interfaces/im.js' import {
getImToken
} from '@/apis/interfaces/im.js'
export default { export default {
data() { data() {
return { return {
@@ -202,9 +204,6 @@
// 进入聊天的详情页面,清理未读消息数量 // 进入聊天的详情页面,清理未读消息数量
toDetail(item) { toDetail(item) {
this.hidePop() this.hidePop()
// uni.navigateTo({
// url: '/pages/im/private/call?targetId=' + item.targetId + '&mediaType=1'
// })
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/private/index?targetId=' + item.targetId + '&conversationType=' + item url: '/pages/im/private/index?targetId=' + item.targetId + '&conversationType=' + item
.conversationType .conversationType
@@ -229,10 +228,8 @@
scanQrCode() { scanQrCode() {
uni.scanCode({ uni.scanCode({
success: (res) => { success: (res) => {
// "result": "ADDFRIEND|10010",
if (res.scanType == 'QR_CODE') { if (res.scanType == 'QR_CODE') {
res.result.substr(0, 10) == 'ADDFRIEND|' res.result.substr(0, 10) == 'ADDFRIEND|'
// 跳转到添加好友页面
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/friends/info?targetId=' + res.result.substr(10) url: '/pages/im/friends/info?targetId=' + res.result.substr(10)
}) })

View File

@@ -8,7 +8,7 @@ import {
const initIm = (KEY) => { const initIm = (KEY) => {
RongIMLib.init(KEY) RongIMLib.init(KEY)
CallLib.init({}) CallLib.init()
addListeners() addListeners()
} }
@@ -89,7 +89,7 @@ function inArray(search, array) {
const addListeners = () => { const addListeners = () => {
// 添加连接状态监听函数 // 添加连接状态监听函数
RongIMLib.addConnectionStatusListener((res) => { RongIMLib.addConnectionStatusListener((res) => {
console.log('连接状态监', res.data.status); console.log('连接状态监', res.data.status);
store.dispatch('updateConnectionStatus', res.data.status) store.dispatch('updateConnectionStatus', res.data.status)
}) })
// 添加消息监听函数 // 添加消息监听函数
@@ -104,7 +104,8 @@ const addListeners = () => {
CallLib.onCallReceived(({ CallLib.onCallReceived(({
data data
}) => { }) => {
console.log('onCallReceived'); console.log('onCallReceived', data)
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/private/call?targetId=' + data.targetId + '&mediaType=' + url: '/pages/im/private/call?targetId=' + data.targetId + '&mediaType=' +
data.mediaType data.mediaType