247 lines
6.4 KiB
Vue
247 lines
6.4 KiB
Vue
<template>
|
|
<view class="content">
|
|
<TopSafe></TopSafe>
|
|
<Header title="设置" />
|
|
<view class="setting-view">
|
|
<view class="item-list mt-24">
|
|
<view class="flex-r-lr item-box" @click="onHead(index)"
|
|
v-for="(item,index) in headList" :key="index"
|
|
:style="{borderWidth:index == headList.length - 1 ? '0' : '2rpx'}"
|
|
>
|
|
<text class="text-zu1 text-32">{{item.text}}</text>
|
|
<view class="flex-r-e" style="align-items: center;">
|
|
<image v-if="item.type == 'img'" :src="item.value" class="ava-img"></image>
|
|
<text class="text-zu text-32" v-if="item.type == 'text'">{{item.value}}</text>
|
|
<u-icon size="16" name="arrow-right" color="#666" style="margin-left:12rpx"></u-icon>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="item-list mt-24">
|
|
<view class="flex-r-lr item-box" @click="onBottom(index)"
|
|
v-for="(item,index) in bottomList" :key="index"
|
|
:style="{borderWidth:index == bottomList.length - 1 ? '0' : '2rpx'}"
|
|
>
|
|
<text class="text-zu1 text-32">{{item.text}}</text>
|
|
<view class="flex-r-e" style="align-items: center;">
|
|
<u-icon size="16" name="arrow-right" color="#666" style="margin-left:12rpx"></u-icon>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<MyBtn class="mt-48" @ok="onOutLogin" text="退出登录"></MyBtn>
|
|
</view>
|
|
<up-toast ref="uToastRef"></up-toast>
|
|
<!-- 腾讯电子签H5 → 集成到UniApp -->
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { getUserInfo,uploadAvatar } from '@/api/auth.js';
|
|
import { uploadImage, uploadImg } from '@/api/common.js';
|
|
import { IMG_TYPE } from '@/utils/enumUtils.js';
|
|
import { BASE_URL, Authorization } from '@/utils/config.js';
|
|
import { getStorageFun, TOKEN_NAME,clear } from '@/utils/auth.js';
|
|
import Header from '@/components/common/header.vue';
|
|
import TopSafe from '@/components/common/top-safe.nvue'
|
|
import MyBtn from '@/components/common/my-btn.vue'
|
|
import func from '@/utils/func.js';
|
|
|
|
export default {
|
|
components: { Header, TopSafe,MyBtn },
|
|
data() {
|
|
return {
|
|
type: false,
|
|
userInfo: null,
|
|
headList:[
|
|
{text:'头像',type:'img',value:''},
|
|
{text:'用户名称',type:'text',value:''},
|
|
],
|
|
bottomList:[
|
|
{text:'账号与安全'},
|
|
{text:'我的合同'},
|
|
{text:'资质照片'},
|
|
{text:'用户协议'},
|
|
{text:'隐私协议'},
|
|
{text:'售后保障协议'},
|
|
{text:'关于我们'},
|
|
]
|
|
};
|
|
},
|
|
onShow() {
|
|
this.init();
|
|
},
|
|
onLoad() {
|
|
// this.userinfo();
|
|
},
|
|
methods: {
|
|
init() {
|
|
this.userinfo()
|
|
},
|
|
onHead(index){
|
|
console.log('index',index)
|
|
let that = this;
|
|
if(index == 0){
|
|
uni.chooseImage({
|
|
count: 1, // 默认9,设置图片的数量
|
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
success: function (res) {
|
|
// 成功选择图片后
|
|
const filePath = res.tempFilePaths[0]; // 获取文件路径
|
|
that.uploadFile(filePath);
|
|
}
|
|
});
|
|
}else if(index == 1){
|
|
uni.navigateTo({
|
|
url:'/pages/rwa_package/setting/set-name'
|
|
})
|
|
}
|
|
},
|
|
uploadFile(url) {
|
|
uni.showLoading({
|
|
title: '图片上传中...',
|
|
})
|
|
const that = this;
|
|
const token = getStorageFun(TOKEN_NAME); // 获取token, 根据实际情况调整获取方式
|
|
// 成功则返回文件的本地临时文件路径
|
|
uni.uploadFile({
|
|
url: BASE_URL + uploadImg, // 替换为你的上传接口URL
|
|
filePath: url,
|
|
name: 'file',
|
|
formData: {
|
|
'type': IMG_TYPE.COMMON,
|
|
},
|
|
header: {
|
|
"Authorization": Authorization,
|
|
'HSM-AUTH': token ? token : '',
|
|
},
|
|
success: (uploadFileRes) => {
|
|
const data = JSON.parse(uploadFileRes.data);
|
|
if (data.bizcode === 100) {
|
|
that.setUploadAvatar(data.data.accessUrl);
|
|
} else {
|
|
uni.showToast({
|
|
title: '图片上传失败',
|
|
icon: 'none',
|
|
mask: true,
|
|
duration: 3000,
|
|
})
|
|
}
|
|
},
|
|
fail: (uploadFileErr) => {
|
|
uni.showToast({
|
|
title: '图片上传失败',
|
|
icon: 'none',
|
|
mask: true,
|
|
duration: 3000,
|
|
})
|
|
},
|
|
complete: (res) => {
|
|
// 请求完成以后做一些事情
|
|
uni.hideLoading();
|
|
}
|
|
});
|
|
},
|
|
setUploadAvatar(img){
|
|
let params = {
|
|
imgUrl:img
|
|
}
|
|
uploadAvatar(params).then(res=>{
|
|
if (res.bizcode === 100) {
|
|
this.$refs.uToastRef.show({
|
|
type: 'success',
|
|
message: "头像设置成功",
|
|
});
|
|
this.init();
|
|
} else {
|
|
this.$refs.uToastRef.show({
|
|
type: 'error',
|
|
message: "头像设置失败",
|
|
});
|
|
}
|
|
})
|
|
},
|
|
onOutLogin(){
|
|
clear();
|
|
uni.navigateTo({
|
|
url: '/pages/login_package/login/login'
|
|
})
|
|
},
|
|
onBottom(index){
|
|
let url = '';
|
|
switch(index){
|
|
case 0:
|
|
url = '/pages/rwa_package/setting/account-safe'
|
|
break;
|
|
case 1:
|
|
url = '/pages/rwa_package/dongjian/index'
|
|
break;
|
|
case 2:
|
|
url = '/pages/rwa_package/setting/zhaopian'
|
|
break;
|
|
case 3:
|
|
url = '/pages/mine_package/mine_user_agreement/mine_user_agreement'
|
|
break;
|
|
case 4:
|
|
url = '/pages/mine_package/mine_privacy_agreement/mine_privacy_agreement'
|
|
break;
|
|
case 5:
|
|
url = '/pages/mine_package/mine_product_agreement/mine_product_agreement'
|
|
break;
|
|
case 6:
|
|
url = '/pages/mine_package/mine_about_us/mine_about_us'
|
|
break;
|
|
}
|
|
if(url){
|
|
uni.navigateTo({
|
|
url:url
|
|
})
|
|
}
|
|
},
|
|
userinfo() {
|
|
getUserInfo().then(res => {
|
|
if (res.bizcode == 100) {
|
|
this.userInfo = res.data;
|
|
this.userInfo.avatarUrl = this.userInfo.avatarUrl ? this.userInfo.avatarUrl : 'https://cex-pub.s3.ap-southeast-1.amazonaws.com/static/default-avatar.png';
|
|
this.headList[0].value = this.userInfo.avatarUrl;
|
|
this.userInfo.nickname = this.userInfo.nickname ? this.userInfo.nickname : '暂未设置';
|
|
this.headList[1].value = this.userInfo.nickname;
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.setting-view {
|
|
width: 100%;
|
|
height: calc(100% - 88rpx - var(--status-bar-height));
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
overflow-y: auto;
|
|
padding: 0 32rpx;
|
|
box-sizing: border-box;
|
|
.item-list{
|
|
width:100%;
|
|
border-radius: 16rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background-color: #fff;
|
|
.item-box{
|
|
min-height:108rpx;
|
|
padding: 0 32rpx;
|
|
box-sizing: border-box;
|
|
align-items: center;
|
|
border-bottom:solid #EAEAEA;
|
|
.ava-img{
|
|
width:60rpx;
|
|
height:60rpx;
|
|
border-radius: 30rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|