jiuyiUniapp/jiuyi/pages/mine/set-up/index.vue

214 lines
4.8 KiB
Vue
Raw Normal View History

2024-12-18 15:46:27 +08:00
<template>
<!-- 设置页 -->
<view class="area plr30 f30 c333">
<view class="line rows ptb20 plr10">
<view class="avatar">
<image class="head-portrait wh80" :src="userinfo.userPortrait" mode="aspectFill" />
</view>
<view class="inkfo f1 ml20">
<view class="">{{userinfo.userNickname}}</view>
<view class="account mt10 c999 f26">账号{{userinfo.userAccount}}</view>
</view>
</view>
<template v-if="userinfo.userId">
<view class="line rows ptb20 plr10">
<view class="">绑定手机号</view>
<view class="f1 tar c666 f28">{{userinfo.userPhone}}</view>
</view>
<view class="line rows ptb20 plr10" @click="link('/pages/mine/real-name-authentication/index')">
<view class="">实名认证</view>
<view class="f1 tar">
<uni-icons type="right" />
</view>
</view>
<view class="line" v-if="imUserinfo.userID">
<picker :range="allowType" range-key="name" @change="handleAllowType" :value="allowTypeIndex">
<view class=" rows ptb20 plr10">
<view class="">好友验证方式</view>
<view class="value mlr20 f1 tar c666 f28">
{{allowType[allowTypeIndex].name}}
</view>
<uni-icons type="right" />
</view>
</picker>
</view>
<view class="line rows ptb20 plr10" @click="link('/pages/mine/teen')">
<view class="">青少年模式</view>
<view class="f1 tar">
<uni-icons type="right" />
</view>
</view>
</template>
<view class="line rows ptb20 plr10" @click="link(util.setUrl('/pages/index/article',{
id: 6,
}))">
<view class="">用户协议</view>
<uni-icons type="right" />
</view>
<view class="line rows ptb20 plr10" @click="link(util.setUrl('/pages/index/article',{
id: 1,
}))">
<view class="">隐私政策</view>
<uni-icons type="right" />
</view>
<!-- #ifdef APP -->
<view class="line rows ptb20 plr10">
<view class="">版本号</view>
<view class="c999 f28">{{appVersion}}</view>
</view>
<!-- #endif -->
</view>
<view class="fill" style="height: 240rpx;"></view>
<!-- 切换账号 退出登录 -->
<view class="footer bfff">
<view class="mtb30">
<view @click="checkLink('pages/mine/switch-accounts/index')" class="btn">切换账号</view>
</view>
<view class="mtb30">
<view @click="logOff" class="btn">退出登录</view>
</view>
</view>
</template>
<script setup>
import {
ref,
inject
} from 'vue'
import {
useStore
} from 'vuex'
import {
onLoad,
} from '@dcloudio/uni-app'
// 工具库
import util from '@/common/js/util.js'
// 腾讯云聊天
import TencentCloudChat from '@tencentcloud/chat';
const {
userinfo
} = useStore().state
// 添加好友方式
const allowType = [{
id: TencentCloudChat.TYPES.ALLOW_TYPE_ALLOW_ANY,
name: '允许任何人添加',
}, {
id: TencentCloudChat.TYPES.ALLOW_TYPE_NEED_CONFIRM,
name: '需要确认才能添加',
}, {
id: TencentCloudChat.TYPES.ALLOW_TYPE_DENY_ANY,
name: '不允许任何人添加 ',
}, ]
// 添加好友下标
const allowTypeIndex = ref(0)
// im用户信息
const imUserinfo = ref({})
// app版本号
const appVersion = ref(0)
onLoad(() => {
util.isLogin(() => {
// 获取添加好友方式
getAddType()
})
// #ifdef APP
let system = uni.getSystemInfoSync()
console.log('system', system)
appVersion.value = system.appVersion
// #endif
})
// 修改加好友方式
function handleAllowType(ev) {
const index = ev.detail.value
if (index === allowTypeIndex.value) return
allowTypeIndex.value = index
// 更新个人资料
updateMyProfile()
}
// 获取添加好友方式
function getAddType() {
//
uni.$chat.getMyProfile().then((rs) => {
const result = rs.data
imUserinfo.value = result
// 添加好友下标
allowTypeIndex.value = allowType.findIndex(node => node.id == result.allowType)
})
}
// 更细im个人资料
function updateMyProfile() {
// 修改个人标配资料
uni.$chat.updateMyProfile({
allowType: allowType[allowTypeIndex.value].id
})
}
// 跳转
function link(url) {
uni.navigateTo({
url,
})
}
// 退出登录
function logOff() {
alert({
title: '提示',
content: '确定退出登录?',
}).then(res => {
if (res.confirm) {
// 退出登录
logout(() => {
// checkLink('pages/login/loginPhone', 'reLaunch')
// #ifdef APP
plus.runtime.restart()
// #endif
})
}
})
}
</script>
<style lang="scss" scoped>
.area {
.line+.line {
border-top: 1px solid #eeeeee;
}
.head-portrait {
background: #999999;
border-radius: 50%;
margin-right: 20rpx;
}
.jy-mine-group {
display: flex;
flex-direction: column;
//至于屏幕底部 与屏幕等宽
width: 100%;
position: fixed;
.item {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 96rpx;
margin: 10rpx 0;
background: #ffffff;
}
}
}
</style>