jiuyiUniapp/jiuyi2/pages/mine/setting/setting.vue

277 lines
6.5 KiB
Vue
Raw Normal View History

2024-12-27 15:03:48 +08:00
<script setup>
import {
ref,
computed,
} 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 store = useStore()
// 用户信息
const userinfo = computed(() => {
let result = store.state.userinfo
return result
})
// 添加好友方式
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()
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 loginLink(url) {
util.isLogin().then(() => {
link(url)
}).catch(() => {
link('/pages/login/login')
})
}
// 跳转
function link(url) {
uni.navigateTo({
url,
})
}
// 退出登录
function logOff() {
util.alert({
title: '提示',
content: '确定退出登录?',
}).then(res => {
if (res.confirm) {
// 退出登录
util.logout(() => {
// checkLink('pages/login/loginPhone', 'reLaunch')
// #ifdef APP
plus.runtime.restart()
// #endif
})
}
})
}
</script>
2024-12-18 15:46:27 +08:00
<template>
<!-- 设置页 -->
<view class="app">
<view class="area">
<view class="line rows" @click="loginLink('/pages/mine/userinfo')">
<view class="avatar">
<image class="head-portrait wh80" :src="userinfo.userPortrait" mode="aspectFill" />
</view>
<view class="info f1 ml20">
<view class="">{{userinfo.userNickname}}</view>
<!-- <view class="account mt10 c999 f26">账号{{userinfo.account}}</view> -->
</view>
</view>
2024-12-29 19:06:34 +08:00
<template v-if="userinfo.id || 1">
2024-12-18 15:46:27 +08:00
<view class="line rows">
<view class="">修改账号</view>
<view class="f1 tar c999 f28">{{userinfo.account}}</view>
</view>
<view class="line rows">
<view class="">绑定手机号</view>
<view class="f1 tar c999 f28">{{userinfo.phoneNumber}}</view>
</view>
<view class="line rows" @click="link('/pages/mine/realname')">
<view class="key">实名认证</view>
<view class="col f1 ml20 tar c999 f28">
<view class="" v-if="userinfo.isRealName">已认证</view>
<view class="" v-else>未认证</view>
</view>
<uni-icons class="ml20" type="right" />
</view>
</template>
</view>
2024-12-27 15:03:48 +08:00
<template v-if="userinfo.id || 1">
2024-12-29 19:06:34 +08:00
<view class="area">
<view class="line rows" @click="link('/pages/mine/setting/usePay')">
2024-12-18 15:46:27 +08:00
<view class="">先用后付</view>
<uni-icons type="right" />
</view>
<view class="line rows">
<view class="">二级密码</view>
<uni-icons type="right" />
</view>
<view class="line rows">
<view class="">登录密码</view>
<uni-icons type="right" />
</view>
<view class="line rows">
<view class="">邮箱</view>
<uni-icons type="right" />
</view>
2024-12-29 19:06:34 +08:00
<view class="line rows ptb20 plr10" @click="link('/pages/mine/setting/teen')">
2024-12-18 15:46:27 +08:00
<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">
<view class="">好友验证方式</view>
<view class="value mlr20 f1 tar c666 f28">
{{allowType[allowTypeIndex].name}}
</view>
<uni-icons type="right" />
</view>
</picker>
</view>
</view>
</template>
<view class="area">
2024-12-27 15:03:48 +08:00
<view class="line rows" @click="link('/pages/mine/setting/safeCenter')">
2024-12-18 15:46:27 +08:00
<view class="">安全中心</view>
<uni-icons type="right" />
</view>
<!-- 支付宝 微信 -->
2024-12-29 19:06:34 +08:00
<view class="line rows" @click="link('/pages/mine/setting/binding')">
2024-12-18 15:46:27 +08:00
<view class="">我的绑定</view>
<uni-icons type="right" />
</view>
2024-12-27 15:03:48 +08:00
<view class="line rows" @click="link('/pages/mine/setting/bankCard')">
2024-12-18 15:46:27 +08:00
<view class="">我的银行卡</view>
<uni-icons type="right" />
</view>
<view class="line rows">
<view class="">意见反馈</view>
<uni-icons type="right" />
</view>
<view class="line rows">
<view class="">关于我们</view>
<uni-icons type="right" />
</view>
<view class="line rows" @click="link(util.setUrl('/pages/index/article',{id: 6,}))">
<view class="">用户协议</view>
<uni-icons type="right" />
</view>
<view class="line rows" @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="mtb30 c999">
<view class="mtb5">
<view @click="link('/pages/mine/switch-accounts/index')" class="btn">切换账号</view>
</view>
<view class="mtb5">
<view @click="logOff" class="btn">退出登录</view>
</view>
</view>
<view class="fill" style="height: 30rpx;"></view>
</view>
</template>
<style lang="scss" scoped>
//
.area {
margin: 30rpx;
padding: 0 30rpx;
color: #333;
font-size: 30rpx;
background-color: #fff;
border-radius: 20rpx;
.line {
padding: 20rpx 10rpx;
}
.line+.line {
border-top: 1px solid #eeeeee;
}
.head-portrait {
background: #999999;
border-radius: 50%;
margin-right: 20rpx;
}
}
</style>