Merge branch 'master' of https://git.yuzhankeji.cn/TmOct5/ZhHealth
This commit is contained in:
@@ -85,6 +85,15 @@ const pedingFriend = (recipient) => {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 好友申请数量
|
||||
*/
|
||||
const getPendingCount = () => {
|
||||
return request({
|
||||
url: 'im/friends/pending/count'
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
getImToken,
|
||||
deleteFriend,
|
||||
@@ -95,5 +104,6 @@ export {
|
||||
resolveFriend,
|
||||
rejectFriend,
|
||||
searchFriend,
|
||||
pedingFriend
|
||||
pedingFriend,
|
||||
getPendingCount
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
<view>
|
||||
<view class="friend-flex u-border-bottom" @click="toPending">
|
||||
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_01.png')"></u-avatar>
|
||||
<view class="name">新的朋友</view>
|
||||
<view class="name">
|
||||
新的朋友 ({{ pendingCount }})
|
||||
</view>
|
||||
</view>
|
||||
<view class="friend-flex" @click="showToast">
|
||||
<u-avatar class="cover" size="40" shape="square" :src="require('@/static/im/im_00.png')"></u-avatar>
|
||||
@@ -22,7 +24,8 @@
|
||||
<u-index-anchor :text="indexs[friend]" bgColor="#F3F6FB" height="20" size="12" color="#666">
|
||||
</u-index-anchor>
|
||||
<!-- #endif -->
|
||||
<view v-for="(friendItem, index) in item" :key="friendItem.userId" class="friend-flex u-border-bottom"
|
||||
<view v-for="(friendItem, index) in item" :key="friendItem.userId"
|
||||
class="friend-flex u-border-bottom"
|
||||
@click="$Router.push({ name: 'imFriendsInfo', params: { targetId: friendItem.userId } })">
|
||||
<block v-if="friendItem.portraitUrl != ''">
|
||||
<u-avatar class="cover" size="40" shape="square" :src="friendItem.portraitUrl || ''"
|
||||
@@ -47,24 +50,29 @@
|
||||
|
||||
<script>
|
||||
import {
|
||||
getFriends
|
||||
getFriends,
|
||||
getPendingCount
|
||||
} from '@/apis/interfaces/im';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
indexs: [],
|
||||
friends: []
|
||||
friends: [],
|
||||
pendingCount: 0
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
getFriends().then(res => {
|
||||
this.indexs = res.indexList;
|
||||
this.friends = res.itemArr;
|
||||
});
|
||||
this.indexs = res.indexList
|
||||
this.friends = res.itemArr
|
||||
})
|
||||
getPendingCount().then(res => {
|
||||
console.log(res);
|
||||
this.pendingCount = res
|
||||
})
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
// 扫码提示
|
||||
showToast() {
|
||||
uni.showToast({
|
||||
title: '群聊功能暂未开放,敬请期待',
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
}
|
||||
},
|
||||
onLoad(e) {
|
||||
console.log(e);
|
||||
this.targetId = e.targetId
|
||||
getFriendInfo(e.targetId).then(res => {
|
||||
this.userInfo = res
|
||||
@@ -243,16 +244,14 @@
|
||||
})
|
||||
},
|
||||
singleCall(e) {
|
||||
CallLib.startSingleCall(this.targetId, e.type, '');
|
||||
uni.redirectTo({
|
||||
url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type,
|
||||
success: (err) => {
|
||||
console.log('跳转视频通话成功');
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('跳转视频页失败', err);
|
||||
}
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '功能正在开发中'
|
||||
})
|
||||
// CallLib.startSingleCall(this.targetId, e.type, '');
|
||||
// uni.redirectTo({
|
||||
// url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type
|
||||
// })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,7 @@
|
||||
<view class="content">
|
||||
<!-- 用户信息 -->
|
||||
<view class="info-flex">
|
||||
<u-avatar
|
||||
:src="infoObj.portraitUrl"
|
||||
shape="square"
|
||||
size="50"
|
||||
bg-color="#fff"
|
||||
></u-avatar>
|
||||
<u-avatar :src="infoObj.portraitUrl" shape="square" size="50" bg-color="#fff"></u-avatar>
|
||||
<view class="info-text">
|
||||
<view class="nickname">{{infoObj.name}}</view>
|
||||
<view class="address">地址:{{infoObj.address}}</view>
|
||||
@@ -28,7 +23,7 @@
|
||||
</view>
|
||||
<!-- 二维码 -->
|
||||
<view class="info-code">
|
||||
<uqrcode class="info-code-src" :size="198" ref="uQRCode" text="qrContent" />
|
||||
<uqrcode class="info-code-src" :size="198" ref="uQRCode" :text="qrContent" />
|
||||
<view class="info-code-text">
|
||||
<view>ZH-HEALTH扫一扫上面的二维码</view>
|
||||
<view>添加我的好友</view>
|
||||
@@ -38,55 +33,56 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getUserInfo } from '@/apis/interfaces/im'
|
||||
export default{
|
||||
data(){
|
||||
return{
|
||||
infoObj: {
|
||||
userId : '',
|
||||
username : '',
|
||||
name : '',
|
||||
address : '',
|
||||
portraitUrl : '',
|
||||
gender : 0,
|
||||
hash : ''
|
||||
import {
|
||||
getUserInfo
|
||||
} from '@/apis/interfaces/im'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
infoObj: {
|
||||
userId: '',
|
||||
username: '',
|
||||
name: '',
|
||||
address: '',
|
||||
portraitUrl: '',
|
||||
gender: 0,
|
||||
hash: ''
|
||||
},
|
||||
qrContent: 'ADDFRIEND|'
|
||||
}
|
||||
},
|
||||
onLoad(e){
|
||||
console.log(e)
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
getUserInfo(this.$Route.query.targetId).then(res => {
|
||||
onLoad(e) {},
|
||||
mounted() {
|
||||
getUserInfo(this.$Route.query.targetId).then(res => {
|
||||
this.infoObj = res
|
||||
this.qrContent += res.userId
|
||||
console.log(this.infoObj)
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.content{
|
||||
.content {
|
||||
background: $window-color;
|
||||
min-height: 100vh;
|
||||
padding-top: $padding;
|
||||
box-sizing: border-box;
|
||||
.info-code{
|
||||
|
||||
.info-code {
|
||||
background: white;
|
||||
margin: 0 $margin;
|
||||
border-radius: $radius;
|
||||
padding: $padding*3 $padding $padding;
|
||||
text-align: center;
|
||||
&-src{
|
||||
|
||||
&-src {
|
||||
display: inline-block;
|
||||
}
|
||||
&-text{
|
||||
|
||||
&-text {
|
||||
text-align: center;
|
||||
color: $text-gray;
|
||||
font-size: $title-size-sm;
|
||||
@@ -94,24 +90,28 @@
|
||||
padding: $padding 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 用户信息
|
||||
.info-flex{
|
||||
.info-flex {
|
||||
padding: $padding;
|
||||
margin: 0 $margin;
|
||||
display: flex;
|
||||
background: white;
|
||||
border-radius: $radius;
|
||||
.info-text{
|
||||
|
||||
.info-text {
|
||||
width: calc(100% - 50px);
|
||||
padding-left: $padding;
|
||||
box-sizing: border-box;
|
||||
.nickname{
|
||||
|
||||
.nickname {
|
||||
line-height: 30px;
|
||||
font-size: $title-size + 6;
|
||||
color: $text-color;
|
||||
text-align: left;
|
||||
}
|
||||
.address{
|
||||
|
||||
.address {
|
||||
line-height: 20px;
|
||||
font-size: $title-size-sm;
|
||||
color: $text-gray;
|
||||
@@ -122,7 +122,7 @@
|
||||
}
|
||||
|
||||
// footer
|
||||
.footer{
|
||||
.footer {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
@@ -130,21 +130,25 @@
|
||||
padding: $padding*2 $padding;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
.footer-item{
|
||||
|
||||
.footer-item {
|
||||
margin: 0 $margin/2;
|
||||
.icon{
|
||||
|
||||
.icon {
|
||||
background: $main-color;
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
display: inline-block;
|
||||
border-radius: 50%;
|
||||
.icon-u{
|
||||
|
||||
.icon-u {
|
||||
margin-top: calc((88rpx/2) - 13px);
|
||||
margin-left: calc((88rpx/2) - 13px);
|
||||
}
|
||||
}
|
||||
.text{
|
||||
|
||||
.text {
|
||||
color: $main-color;
|
||||
font-size: $title-size-m;
|
||||
text-align: center;
|
||||
@@ -154,24 +158,28 @@
|
||||
}
|
||||
|
||||
// btns
|
||||
.info-btns{
|
||||
.info-btns {
|
||||
background: white;
|
||||
margin: $margin;
|
||||
border-radius: $radius;
|
||||
.item{
|
||||
|
||||
.item {
|
||||
line-height: 100rpx;
|
||||
border-bottom: solid 1rpx $border-color;
|
||||
display: flex;
|
||||
padding: 0 $padding;
|
||||
justify-content: space-between;
|
||||
font-size: $title-size-lg;
|
||||
&:last-child{
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
label{
|
||||
|
||||
label {
|
||||
width: 200rpx;
|
||||
}
|
||||
.text{
|
||||
|
||||
.text {
|
||||
width: calc(100% - 200rpx);
|
||||
color: $text-gray-m;
|
||||
text-align: right;
|
||||
|
||||
@@ -74,7 +74,9 @@
|
||||
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
|
||||
import im from '@/utils/im/index.js'
|
||||
import userAuth from '@/public/userAuth'
|
||||
import { getImToken } from '@/apis/interfaces/im.js'
|
||||
import {
|
||||
getImToken
|
||||
} from '@/apis/interfaces/im.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -99,13 +101,20 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
if (this.isShown) {
|
||||
uni.$on('onReceiveMessage', (msg) => {
|
||||
console.log(msg);
|
||||
this.getConversationList()
|
||||
})
|
||||
uni.$on('onConnectionStatusChange', (status) => {
|
||||
this.connection = status
|
||||
})
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
if (this.$store.state.token !== '') {
|
||||
getImToken().then(res => {
|
||||
im.connect(res.token, res.userInfo, () => {
|
||||
this.getConversationList()
|
||||
})
|
||||
})
|
||||
this.getConversationList()
|
||||
}
|
||||
this.isShown = true
|
||||
},
|
||||
@@ -127,16 +136,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$store.getters.newMessage': function(n, o) {
|
||||
if (this.isShown) {
|
||||
this.getConversationList()
|
||||
}
|
||||
},
|
||||
'$store.getters.connection': function(n, o) {
|
||||
this.connection = n
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
hidePop() {
|
||||
this.showPop = false
|
||||
@@ -202,9 +201,6 @@
|
||||
// 进入聊天的详情页面,清理未读消息数量
|
||||
toDetail(item) {
|
||||
this.hidePop()
|
||||
// uni.navigateTo({
|
||||
// url: '/pages/im/private/call?targetId=' + item.targetId + '&mediaType=1'
|
||||
// })
|
||||
uni.navigateTo({
|
||||
url: '/pages/im/private/index?targetId=' + item.targetId + '&conversationType=' + item
|
||||
.conversationType
|
||||
@@ -229,10 +225,8 @@
|
||||
scanQrCode() {
|
||||
uni.scanCode({
|
||||
success: (res) => {
|
||||
// "result": "ADDFRIEND|10010",
|
||||
if (res.scanType == 'QR_CODE') {
|
||||
res.result.substr(0, 10) == 'ADDFRIEND|'
|
||||
// 跳转到添加好友页面
|
||||
uni.navigateTo({
|
||||
url: '/pages/im/friends/info?targetId=' + res.result.substr(10)
|
||||
})
|
||||
|
||||
@@ -123,6 +123,18 @@
|
||||
console.log('------------------获取到了录音的临时路径---------------')
|
||||
console.log(res.tempFilePath)
|
||||
})
|
||||
// 简童收到新消息,判断是否是当前会话,更新会话内容
|
||||
uni.$on('onReceiveMessage', (msg) => {
|
||||
if (msg.targetId == this.targetId) {
|
||||
RongIMLib.clearMessagesUnreadStatus(msg.conversationType, msg.targetId, msg.sentTime)
|
||||
RongIMLib.sendReadReceiptMessage(msg.conversationType, msg.targetId, msg.sentTime)
|
||||
this.getMessageList()
|
||||
im.setNotifyBadge()
|
||||
}
|
||||
})
|
||||
},
|
||||
beforeDestroy() {
|
||||
uni.$off('onReceiveMessage')
|
||||
},
|
||||
onUnload() {
|
||||
RongIMLib.clearReadReceiptReceivedListener()
|
||||
@@ -146,16 +158,6 @@
|
||||
})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$store.getters.newMessage': function(msg) {
|
||||
if (msg.targetId == this.targetId) {
|
||||
RongIMLib.clearMessagesUnreadStatus(msg.conversationType, msg.targetId, msg.sentTime)
|
||||
RongIMLib.sendReadReceiptMessage(msg.conversationType, msg.targetId, msg.sentTime)
|
||||
this.getMessageList()
|
||||
im.setNotifyBadge()
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 播放语音消息
|
||||
onPlayMsg() {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
<view class="info-box">
|
||||
<image src="@/static/user/user_back.png" mode="aspectFill" />
|
||||
<view class="user-flex">
|
||||
<image class="cover" @click="$Router.push({ name: 'Setting' })" :src="userInfo.avatar || require('@/static/user/cover.png')" mode="aspectFill" />
|
||||
<image class="cover" @click="$Router.push({ name: 'Setting' })"
|
||||
:src="userInfo.avatar || require('@/static/user/cover.png')" mode="aspectFill" />
|
||||
<view class="user-content">
|
||||
<block v-if="$store.state.token != ''">
|
||||
<view class="name">{{ userInfo.nickname }}</view>
|
||||
@@ -21,10 +22,14 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="chainAddress" v-if="userInfo.chain_address">
|
||||
<u-icon labelPos="left" @click="copy(userInfo.chain_address)" labelSize="14" labelColor="#fff" :label="userInfo.chain_address.substr(0, 20)+'...'" space="10" :name="require('@/static/imgs/copy.png')" size="16" />
|
||||
<u-icon labelPos="left" @click="copy(userInfo.chain_address)" labelSize="14"
|
||||
labelColor="#fff" :label="userInfo.chain_address.substr(0, 20)+'...'" space="10"
|
||||
:name="require('@/static/imgs/copy.png')" size="16" />
|
||||
</view>
|
||||
</block>
|
||||
<block v-else><view class="name" @click="isLogin()">未登录</view></block>
|
||||
<block v-else>
|
||||
<view class="name" @click="isLogin()">未登录</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -36,7 +41,10 @@
|
||||
<image src="@/static/user/icon_06.png" mode="widthFix" />
|
||||
ZH会员
|
||||
</view>
|
||||
<view class="subtitle"><u-notice-bar :text="cardText" icon="" bgColor="" duration="3000" color="#fcc692" direction="column"></u-notice-bar></view>
|
||||
<view class="subtitle">
|
||||
<u-notice-bar :text="cardText" icon="" bgColor="" duration="3000" color="#fcc692" direction="column">
|
||||
</u-notice-bar>
|
||||
</view>
|
||||
<view class="btn" @click="openVip" v-if="userInfo.identity.length === 0">开通</view>
|
||||
</view>
|
||||
|
||||
@@ -121,352 +129,403 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { info } from '@/apis/interfaces/user';
|
||||
import userAuth from '@/public/userAuth';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
cardText: ['新用户首单即赠会员', '老用户专属验证开通会员'],
|
||||
userInfo: {
|
||||
nickname: '',
|
||||
avatar: '',
|
||||
identity: []
|
||||
}
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
this.getInfo();
|
||||
},
|
||||
methods: {
|
||||
// 用户信息
|
||||
getInfo() {
|
||||
if (this.$store.state.token === '') return;
|
||||
info()
|
||||
.then(res => {
|
||||
console.log(res);
|
||||
uni.setNavigationBarTitle({
|
||||
title: res.nickname
|
||||
});
|
||||
this.userInfo = res;
|
||||
console.log(res);
|
||||
})
|
||||
.catch(err => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
import {
|
||||
info
|
||||
} from '@/apis/interfaces/user';
|
||||
import userAuth from '@/public/userAuth';
|
||||
import im from '@/utils/im/index.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
cardText: ['新用户首单即赠会员', '老用户专属验证开通会员'],
|
||||
userInfo: {
|
||||
nickname: '',
|
||||
avatar: '',
|
||||
identity: []
|
||||
}
|
||||
};
|
||||
},
|
||||
// 开通会员
|
||||
openVip() {
|
||||
if (this.isLogin()) {
|
||||
uni.showActionSheet({
|
||||
itemList: ['我是新用户', '我是老用户'],
|
||||
success: res => {
|
||||
switch (res.tapIndex) {
|
||||
case 0:
|
||||
uni.showModal({
|
||||
title: '开通提示',
|
||||
content: '平台新用户完成首笔订单,即可获赠ZH健康会员',
|
||||
showCancel: false,
|
||||
cancelText: '去完成',
|
||||
success: res => {
|
||||
console.log(res);
|
||||
this.$Router.pushTab({ name: 'Store' });
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
uni.showToast({
|
||||
title: '老用户渠道暂未开放',
|
||||
icon: 'none'
|
||||
});
|
||||
break;
|
||||
onShow() {
|
||||
this.getInfo();
|
||||
},
|
||||
methods: {
|
||||
// 用户信息
|
||||
getInfo() {
|
||||
if (this.$store.state.token === '') return;
|
||||
info()
|
||||
.then(res => {
|
||||
console.log(res);
|
||||
uni.setNavigationBarTitle({
|
||||
title: res.nickname
|
||||
});
|
||||
this.userInfo = res;
|
||||
console.log(res);
|
||||
})
|
||||
.catch(err => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
},
|
||||
// 开通会员
|
||||
openVip() {
|
||||
if (this.isLogin()) {
|
||||
uni.showActionSheet({
|
||||
itemList: ['我是新用户', '我是老用户'],
|
||||
success: res => {
|
||||
switch (res.tapIndex) {
|
||||
case 0:
|
||||
uni.showModal({
|
||||
title: '开通提示',
|
||||
content: '平台新用户完成首笔订单,即可获赠ZH健康会员',
|
||||
showCancel: false,
|
||||
cancelText: '去完成',
|
||||
success: res => {
|
||||
console.log(res);
|
||||
this.$Router.pushTab({
|
||||
name: 'Store'
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
uni.showToast({
|
||||
title: '老用户渠道暂未开放',
|
||||
icon: 'none'
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
// 开通钱包
|
||||
onWallet() {
|
||||
if (this.isLogin()) {
|
||||
if (this.userInfo.is_wallet) this.$Router.push({
|
||||
name: 'WalletProperty'
|
||||
});
|
||||
else this.$Router.push({
|
||||
name: 'WalletAdd'
|
||||
});
|
||||
}
|
||||
},
|
||||
// 个人档案
|
||||
onFiles() {
|
||||
if (this.isLogin()) {
|
||||
if (!this.userInfo.has_record) {
|
||||
this.$Router.push({
|
||||
name: 'EssentialInfo'
|
||||
});
|
||||
return;
|
||||
}
|
||||
// this.$Router.push({ name: 'UserFiles',params:{id:this.userInfo.record_id} });
|
||||
uni.navigateTo({
|
||||
url: `/pages/user/files?id=${this.userInfo.record.record_id}`
|
||||
});
|
||||
}
|
||||
},
|
||||
// 按钮导航
|
||||
onBtn(name, params) {
|
||||
if (this.isLogin()) {
|
||||
this.$Router.push({
|
||||
name,
|
||||
params
|
||||
});
|
||||
}
|
||||
},
|
||||
// 检查登录
|
||||
isLogin() {
|
||||
if (this.$store.state.token === '') {
|
||||
const Auth = new userAuth();
|
||||
Auth.Login();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
// 退出登录
|
||||
logOut() {
|
||||
this.userInfo = {
|
||||
nickname: '',
|
||||
avatar: '',
|
||||
identity: []
|
||||
};
|
||||
this.$store.commit('setToken', '');
|
||||
// 断开IM链接
|
||||
im.disconnect()
|
||||
},
|
||||
copy(data) {
|
||||
uni.setClipboardData({
|
||||
data: data,
|
||||
success: function() {
|
||||
uni.showToast({
|
||||
title: '复制成功',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
// 开通钱包
|
||||
onWallet() {
|
||||
if (this.isLogin()) {
|
||||
if (this.userInfo.is_wallet) this.$Router.push({ name: 'WalletProperty' });
|
||||
else this.$Router.push({ name: 'WalletAdd' });
|
||||
}
|
||||
},
|
||||
// 个人档案
|
||||
onFiles() {
|
||||
if (this.isLogin()) {
|
||||
if (!this.userInfo.has_record) {
|
||||
this.$Router.push({ name: 'EssentialInfo' });
|
||||
return;
|
||||
}
|
||||
// this.$Router.push({ name: 'UserFiles',params:{id:this.userInfo.record_id} });
|
||||
uni.navigateTo({
|
||||
url: `/pages/user/files?id=${this.userInfo.record.record_id}`
|
||||
});
|
||||
}
|
||||
},
|
||||
// 按钮导航
|
||||
onBtn(name, params) {
|
||||
if (this.isLogin()) {
|
||||
this.$Router.push({ name, params });
|
||||
}
|
||||
},
|
||||
// 检查登录
|
||||
isLogin() {
|
||||
if (this.$store.state.token === '') {
|
||||
const Auth = new userAuth();
|
||||
Auth.Login();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
// 退出登录
|
||||
logOut() {
|
||||
this.userInfo = {
|
||||
nickname: '',
|
||||
avatar: '',
|
||||
identity: []
|
||||
};
|
||||
this.$store.commit('setToken', '');
|
||||
},
|
||||
copy(data){
|
||||
uni.setClipboardData({
|
||||
data: data,
|
||||
success: function () {
|
||||
uni.showToast({
|
||||
title:'复制成功',
|
||||
icon:'none'
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.content {
|
||||
background: $window-color;
|
||||
min-height: 100vh;
|
||||
}
|
||||
// 版权信息
|
||||
.footer-text {
|
||||
text-align: center;
|
||||
font-size: $title-size-sm;
|
||||
padding: $padding $padding $padding * 2;
|
||||
color: $text-gray-m;
|
||||
}
|
||||
// 用户信息
|
||||
.info-box {
|
||||
position: relative;
|
||||
background: linear-gradient(to right, #34ce98, #22aa98);
|
||||
color: white;
|
||||
@extend .ios-top;
|
||||
& > image {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
// z-index: 100;
|
||||
.content {
|
||||
background: $window-color;
|
||||
min-height: 100vh;
|
||||
}
|
||||
.user-flex {
|
||||
|
||||
// 版权信息
|
||||
.footer-text {
|
||||
text-align: center;
|
||||
font-size: $title-size-sm;
|
||||
padding: $padding $padding $padding * 2;
|
||||
color: $text-gray-m;
|
||||
}
|
||||
|
||||
// 用户信息
|
||||
.info-box {
|
||||
position: relative;
|
||||
padding: $padding * 2 $padding ($padding * 2 + 60);
|
||||
height: 128rpx;
|
||||
.cover {
|
||||
background: linear-gradient(to right, #34ce98, #22aa98);
|
||||
color: white;
|
||||
@extend .ios-top;
|
||||
|
||||
&>image {
|
||||
position: absolute;
|
||||
width: 128rpx;
|
||||
height: 128rpx;
|
||||
border-radius: 50%;
|
||||
border: solid 6rpx white;
|
||||
box-sizing: border-box;
|
||||
z-index: 100;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
// z-index: 100;
|
||||
}
|
||||
.user-content {
|
||||
padding-left: 158rpx;
|
||||
height: 128rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
|
||||
.user-flex {
|
||||
position: relative;
|
||||
.chainAddress {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
font-size: $title-size-m;
|
||||
padding-top: 10rpx;
|
||||
padding: $padding * 2 $padding ($padding * 2 + 60);
|
||||
height: 128rpx;
|
||||
|
||||
.cover {
|
||||
position: absolute;
|
||||
width: 128rpx;
|
||||
height: 128rpx;
|
||||
border-radius: 50%;
|
||||
border: solid 6rpx white;
|
||||
box-sizing: border-box;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.user-content {
|
||||
padding-left: 158rpx;
|
||||
height: 128rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
z-index: 200;
|
||||
}
|
||||
.name {
|
||||
line-height: 40rpx;
|
||||
font-weight: bold;
|
||||
font-size: $title-size + 8;
|
||||
@extend .nowrap;
|
||||
}
|
||||
.tabs {
|
||||
padding-top: 10rpx;
|
||||
&-item {
|
||||
background: rgba($color: #000000, $alpha: 0.3);
|
||||
font-size: $title-size-sm - 4;
|
||||
display: inline-block;
|
||||
line-height: 36rpx;
|
||||
padding: 0 20rpx;
|
||||
border-radius: 20rpx;
|
||||
image {
|
||||
width: 26rpx;
|
||||
height: 26rpx;
|
||||
vertical-align: middle;
|
||||
margin-bottom: 2rpx;
|
||||
margin-right: 8rpx;
|
||||
|
||||
.chainAddress {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
font-size: $title-size-m;
|
||||
padding-top: 10rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
position: relative;
|
||||
z-index: 200;
|
||||
}
|
||||
|
||||
.name {
|
||||
line-height: 40rpx;
|
||||
font-weight: bold;
|
||||
font-size: $title-size + 8;
|
||||
@extend .nowrap;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
padding-top: 10rpx;
|
||||
|
||||
&-item {
|
||||
background: rgba($color: #000000, $alpha: 0.3);
|
||||
font-size: $title-size-sm - 4;
|
||||
display: inline-block;
|
||||
line-height: 36rpx;
|
||||
padding: 0 20rpx;
|
||||
border-radius: 20rpx;
|
||||
|
||||
image {
|
||||
width: 26rpx;
|
||||
height: 26rpx;
|
||||
vertical-align: middle;
|
||||
margin-bottom: 2rpx;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 会员卡
|
||||
.vip-card {
|
||||
position: relative;
|
||||
margin: -60rpx $margin $margin;
|
||||
background: linear-gradient(to right bottom, #3e5364, #31364a);
|
||||
border-radius: $radius;
|
||||
box-sizing: border-box;
|
||||
color: #fcc692;
|
||||
padding: $padding ($padding + 170) $padding $padding;
|
||||
.title {
|
||||
font-weight: bold;
|
||||
font-size: $title-size-lg;
|
||||
line-height: 40rpx;
|
||||
image {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-right: 10rpx;
|
||||
vertical-align: middle;
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
}
|
||||
.subtitle {
|
||||
font-size: $title-size-sm;
|
||||
margin-top: 10rpx;
|
||||
.u-notice-bar {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
.btn {
|
||||
position: absolute;
|
||||
right: $margin;
|
||||
margin-top: -30rpx;
|
||||
top: 50%;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
background: linear-gradient(to right, #fce3c5, #fcc590);
|
||||
color: #31364a;
|
||||
font-weight: bold;
|
||||
width: 150rpx;
|
||||
text-align: center;
|
||||
font-size: $title-size-m;
|
||||
border-radius: 30rpx;
|
||||
}
|
||||
}
|
||||
// 订单信息
|
||||
.order-box {
|
||||
margin: $margin;
|
||||
background: white;
|
||||
border-radius: $radius;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
&-item {
|
||||
width: 25%;
|
||||
padding: $padding $padding/2;
|
||||
text-align: center;
|
||||
.icon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
vertical-align: top;
|
||||
}
|
||||
.title {
|
||||
font-size: $title-size-sm;
|
||||
margin-top: $margin/3;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 健康数据
|
||||
.health-flex {
|
||||
display: flex;
|
||||
margin: $margin ($margin - 10);
|
||||
&-item {
|
||||
margin: 0 10rpx;
|
||||
background: white;
|
||||
width: calc(50% - 20rpx);
|
||||
|
||||
// 会员卡
|
||||
.vip-card {
|
||||
position: relative;
|
||||
margin: -60rpx $margin $margin;
|
||||
background: linear-gradient(to right bottom, #3e5364, #31364a);
|
||||
border-radius: $radius;
|
||||
padding: $padding;
|
||||
box-sizing: border-box;
|
||||
color: #fcc692;
|
||||
padding: $padding ($padding + 170) $padding $padding;
|
||||
|
||||
.title {
|
||||
font-weight: bold;
|
||||
font-size: $title-size-lg;
|
||||
.icon {
|
||||
line-height: 40rpx;
|
||||
|
||||
image {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-right: 10rpx;
|
||||
vertical-align: middle;
|
||||
margin-left: 10rpx;
|
||||
margin-bottom: 2rpx;
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
}
|
||||
.num {
|
||||
font-weight: bold;
|
||||
font-size: $title-size + 10;
|
||||
padding: $padding/3 0;
|
||||
text {
|
||||
font-size: 70%;
|
||||
padding-left: 10rpx;
|
||||
}
|
||||
}
|
||||
.hith {
|
||||
|
||||
.subtitle {
|
||||
font-size: $title-size-sm;
|
||||
color: $text-gray;
|
||||
margin-top: 10rpx;
|
||||
|
||||
.u-notice-bar {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 模块
|
||||
.btns-box {
|
||||
background: white;
|
||||
margin: $margin;
|
||||
border-radius: $radius;
|
||||
&-item {
|
||||
position: relative;
|
||||
line-height: 90rpx;
|
||||
padding: $padding * 0.6 $padding;
|
||||
font-size: $title-size-lg;
|
||||
&::after {
|
||||
position: absolute;
|
||||
height: 1rpx;
|
||||
content: ' ';
|
||||
left: $margin;
|
||||
right: $margin;
|
||||
bottom: 0;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
&:last-child::after {
|
||||
display: none;
|
||||
}
|
||||
.forward {
|
||||
|
||||
.btn {
|
||||
position: absolute;
|
||||
right: $margin;
|
||||
}
|
||||
.icon {
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
vertical-align: middle;
|
||||
margin-right: $margin/2;
|
||||
margin-bottom: 8rpx;
|
||||
margin-top: -30rpx;
|
||||
top: 50%;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
background: linear-gradient(to right, #fce3c5, #fcc590);
|
||||
color: #31364a;
|
||||
font-weight: bold;
|
||||
width: 150rpx;
|
||||
text-align: center;
|
||||
font-size: $title-size-m;
|
||||
border-radius: 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
// 订单信息
|
||||
.order-box {
|
||||
margin: $margin;
|
||||
background: white;
|
||||
border-radius: $radius;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
&-item {
|
||||
width: 25%;
|
||||
padding: $padding $padding/2;
|
||||
text-align: center;
|
||||
|
||||
.icon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: $title-size-sm;
|
||||
margin-top: $margin/3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 健康数据
|
||||
.health-flex {
|
||||
display: flex;
|
||||
margin: $margin ($margin - 10);
|
||||
|
||||
&-item {
|
||||
margin: 0 10rpx;
|
||||
background: white;
|
||||
width: calc(50% - 20rpx);
|
||||
border-radius: $radius;
|
||||
padding: $padding;
|
||||
box-sizing: border-box;
|
||||
|
||||
.title {
|
||||
font-size: $title-size-lg;
|
||||
|
||||
.icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
vertical-align: middle;
|
||||
margin-left: 10rpx;
|
||||
margin-bottom: 2rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.num {
|
||||
font-weight: bold;
|
||||
font-size: $title-size + 10;
|
||||
padding: $padding/3 0;
|
||||
|
||||
text {
|
||||
font-size: 70%;
|
||||
padding-left: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.hith {
|
||||
font-size: $title-size-sm;
|
||||
color: $text-gray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 模块
|
||||
.btns-box {
|
||||
background: white;
|
||||
margin: $margin;
|
||||
border-radius: $radius;
|
||||
|
||||
&-item {
|
||||
position: relative;
|
||||
line-height: 90rpx;
|
||||
padding: $padding * 0.6 $padding;
|
||||
font-size: $title-size-lg;
|
||||
|
||||
&::after {
|
||||
position: absolute;
|
||||
height: 1rpx;
|
||||
content: ' ';
|
||||
left: $margin;
|
||||
right: $margin;
|
||||
bottom: 0;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
&:last-child::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.forward {
|
||||
position: absolute;
|
||||
right: $margin;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
vertical-align: middle;
|
||||
margin-right: $margin/2;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -5,111 +5,132 @@
|
||||
* moduleName: 登录
|
||||
*/
|
||||
|
||||
import { router } from '../router'
|
||||
import { keyAuth } from '../apis/interfaces/auth'
|
||||
import {
|
||||
router
|
||||
} from '../router'
|
||||
import {
|
||||
keyAuth
|
||||
} from '../apis/interfaces/auth'
|
||||
import store from '../store'
|
||||
import {
|
||||
getImToken
|
||||
} from '@/apis/interfaces/im.js'
|
||||
import im from '@/utils/im/index.js'
|
||||
|
||||
class userAuth {
|
||||
constructor() {
|
||||
this.univerfyConfig = {
|
||||
fullScreen: true,
|
||||
authButton: {
|
||||
'title': '一键登录',
|
||||
'normalColor': '#34CE98',
|
||||
'highlightColor': '#16b17a',
|
||||
'disabledColor': '#aae4cc',
|
||||
},
|
||||
otherLoginButton: {
|
||||
'title': '其他手机号码',
|
||||
'borderColor': '#34CE98',
|
||||
'textColor': '#34CE98'
|
||||
},
|
||||
privacyTerms: {
|
||||
'checkedImage': '/static/icon/checked-icon.png',
|
||||
'uncheckedImage': '/static/icon/unchecked-icon.png',
|
||||
'textColor': '#999',
|
||||
'termsColor': '#34CE98',
|
||||
'suffix': '并使用本机号码登录/注册',
|
||||
'privacyItems': [{
|
||||
'url': 'https://www.baidu.com',
|
||||
'title': '隐私协议'
|
||||
}, {
|
||||
'url': 'https://www.baidu.com',
|
||||
'title': '服务协议'
|
||||
}]
|
||||
},
|
||||
buttons: {
|
||||
'iconWidth': '45px',
|
||||
'list': [{
|
||||
"provider": '微信登录',
|
||||
"iconPath": '/static/icons/wechat.png',
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
// 预登录
|
||||
Login() {
|
||||
//#ifdef H5
|
||||
router.push({ name: 'Auth' })
|
||||
return
|
||||
//#endif
|
||||
constructor() {
|
||||
this.univerfyConfig = {
|
||||
fullScreen: true,
|
||||
authButton: {
|
||||
'title': '一键登录',
|
||||
'normalColor': '#34CE98',
|
||||
'highlightColor': '#16b17a',
|
||||
'disabledColor': '#aae4cc',
|
||||
},
|
||||
otherLoginButton: {
|
||||
'title': '其他手机号码',
|
||||
'borderColor': '#34CE98',
|
||||
'textColor': '#34CE98'
|
||||
},
|
||||
privacyTerms: {
|
||||
'checkedImage': '/static/icon/checked-icon.png',
|
||||
'uncheckedImage': '/static/icon/unchecked-icon.png',
|
||||
'textColor': '#999',
|
||||
'termsColor': '#34CE98',
|
||||
'suffix': '并使用本机号码登录/注册',
|
||||
'privacyItems': [{
|
||||
'url': 'https://www.baidu.com',
|
||||
'title': '隐私协议'
|
||||
}, {
|
||||
'url': 'https://www.baidu.com',
|
||||
'title': '服务协议'
|
||||
}]
|
||||
},
|
||||
buttons: {
|
||||
'iconWidth': '45px',
|
||||
'list': [{
|
||||
"provider": '微信登录',
|
||||
"iconPath": '/static/icons/wechat.png',
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
// 预登录
|
||||
Login() {
|
||||
//#ifdef H5
|
||||
router.push({
|
||||
name: 'Auth'
|
||||
})
|
||||
return
|
||||
//#endif
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
uni.preLogin({
|
||||
provider: 'univerify',
|
||||
success: res => {
|
||||
this.keyLogin().then(() => {
|
||||
resolve({
|
||||
auth: true
|
||||
})
|
||||
}).catch(errMsg => {
|
||||
reject(errMsg)
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
router.push({ name: 'Auth' })
|
||||
},
|
||||
complete() {
|
||||
uni.hideLoading()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
// 一键登录
|
||||
keyLogin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.login({
|
||||
provider: 'univerify',
|
||||
univerifyStyle: {
|
||||
...this.univerfyConfig
|
||||
},
|
||||
success: authResult => {
|
||||
keyAuth({
|
||||
access_token: authResult.authResult.access_token,
|
||||
openid: authResult.authResult.openid
|
||||
}).then(res => {
|
||||
uni.closeAuthView()
|
||||
store.commit('setToken', res.token_type + ' ' + res.access_token)
|
||||
resolve()
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
uni.closeAuthView()
|
||||
switch (err.code) {
|
||||
case 30002:
|
||||
router.push({ name: 'Auth', params: { keyPhone: 1 }})
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
uni.preLogin({
|
||||
provider: 'univerify',
|
||||
success: res => {
|
||||
this.keyLogin().then(() => {
|
||||
resolve({
|
||||
auth: true
|
||||
})
|
||||
}).catch(errMsg => {
|
||||
reject(errMsg)
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
router.push({
|
||||
name: 'Auth'
|
||||
})
|
||||
},
|
||||
complete() {
|
||||
uni.hideLoading()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
// 一键登录
|
||||
keyLogin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.login({
|
||||
provider: 'univerify',
|
||||
univerifyStyle: {
|
||||
...this.univerfyConfig
|
||||
},
|
||||
success: authResult => {
|
||||
keyAuth({
|
||||
access_token: authResult.authResult.access_token,
|
||||
openid: authResult.authResult.openid
|
||||
}).then(res => {
|
||||
uni.closeAuthView()
|
||||
store.commit('setToken', res.token_type + ' ' + res.access_token)
|
||||
// 在这里,登录成功,链接IM服务
|
||||
getImToken().then(res => {
|
||||
im.connect(res.token, res.userInfo)
|
||||
})
|
||||
resolve()
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
uni.closeAuthView()
|
||||
switch (err.code) {
|
||||
case 30002:
|
||||
router.push({
|
||||
name: 'Auth',
|
||||
params: {
|
||||
keyPhone: 1
|
||||
}
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default userAuth
|
||||
|
||||
@@ -2,19 +2,10 @@ import im from "@/utils/im/index.js"
|
||||
|
||||
export default {
|
||||
state: {
|
||||
newMsg: {},
|
||||
friends: {},
|
||||
sender: {},
|
||||
// IM连接状态,0是正常
|
||||
connection: 0
|
||||
},
|
||||
getters: {
|
||||
newMessage(state) {
|
||||
return state.newMsg
|
||||
},
|
||||
connection(state) {
|
||||
return state.connection
|
||||
},
|
||||
friends(state) {
|
||||
return state.friends
|
||||
},
|
||||
@@ -40,28 +31,14 @@ export default {
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
newMessage(state, msg) {
|
||||
Vue.set(state, 'newMsg', msg)
|
||||
},
|
||||
updateFriends(state, userInfo) {
|
||||
Vue.set(state.friends, userInfo.userId, userInfo)
|
||||
},
|
||||
SET_state_sender(state, userInfo) {
|
||||
state.sender = userInfo
|
||||
},
|
||||
SET_connection_status(state, status) {
|
||||
state.connection = status
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
updateConnectionStatus({commit}, status) {
|
||||
commit('SET_connection_status', status)
|
||||
},
|
||||
newMessage({
|
||||
commit
|
||||
}, msg) {
|
||||
commit('newMessage', msg)
|
||||
},
|
||||
setSenderInfo({
|
||||
commit
|
||||
}, userInfo) {
|
||||
|
||||
@@ -3,13 +3,20 @@ import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index'
|
||||
import store from '@/store/index.js'
|
||||
import {
|
||||
getFriends,
|
||||
getUserInfo
|
||||
getUserInfo,
|
||||
getImToken
|
||||
} from '@/apis/interfaces/im.js'
|
||||
|
||||
const initIm = (KEY) => {
|
||||
RongIMLib.init(KEY)
|
||||
CallLib.init({})
|
||||
CallLib.init()
|
||||
addListeners()
|
||||
// 初始化的时候 自动链接
|
||||
if (store.getters.getToken !== '') {
|
||||
getImToken().then(res => {
|
||||
connect(res.token, res.userInfo, () => {})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const setNotifyBadge = () => {
|
||||
@@ -19,6 +26,9 @@ const setNotifyBadge = () => {
|
||||
count
|
||||
}) => {
|
||||
if (code === 0) {
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.setBadgeNumber(count)
|
||||
// #endif
|
||||
if (count > 0) {
|
||||
uni.setTabBarBadge({
|
||||
index: 3,
|
||||
@@ -52,14 +62,25 @@ const connect = (token, userInfo, callback) => {
|
||||
const model = uni.model.friendModel
|
||||
|
||||
model.find((err, results) => {
|
||||
console.log('好友列表', results);
|
||||
results.map(item => {
|
||||
store.dispatch('updateFriends', item)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 断开链接
|
||||
*/
|
||||
const disconnect = () => {
|
||||
RongIMLib.disconnect()
|
||||
// 移除提醒数量
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.setBadgeNumber(0)
|
||||
// #endif
|
||||
uni.removeTabBarBadge({
|
||||
index: 3
|
||||
})
|
||||
}
|
||||
|
||||
// 允许通知的消息类型,触发更新消息列表操作
|
||||
@@ -89,8 +110,8 @@ function inArray(search, array) {
|
||||
const addListeners = () => {
|
||||
// 添加连接状态监听函数
|
||||
RongIMLib.addConnectionStatusListener((res) => {
|
||||
console.log('连接状态监', res.data.status);
|
||||
store.dispatch('updateConnectionStatus', res.data.status)
|
||||
console.log('连接状态监听', res.data.status);
|
||||
uni.$emit('onConnectionStatusChange', res.data.status)
|
||||
})
|
||||
// 添加消息监听函数
|
||||
RongIMLib.addReceiveMessageListener((res) => {
|
||||
@@ -104,7 +125,8 @@ const addListeners = () => {
|
||||
CallLib.onCallReceived(({
|
||||
data
|
||||
}) => {
|
||||
console.log('onCallReceived');
|
||||
console.log('onCallReceived', data)
|
||||
|
||||
uni.navigateTo({
|
||||
url: '/pages/im/private/call?targetId=' + data.targetId + '&mediaType=' +
|
||||
data.mediaType
|
||||
@@ -154,7 +176,8 @@ const newMessage = (msg) => {
|
||||
syncUserInfo(msg.targetId)
|
||||
}
|
||||
|
||||
store.dispatch('newMessage', msg)
|
||||
uni.$emit('onReceiveMessage', msg);
|
||||
// store.dispatch('newMessage', msg)
|
||||
}
|
||||
|
||||
function syncUserInfo(targetId) {
|
||||
|
||||
Reference in New Issue
Block a user