<template>
|
<view>
|
<yk-authpup ref="authpup" type="top" @changeAuth="changeAuth" noticeTitle="便于您使用该功能上传您的照片用于核实身份场景中读取相册内容" permissionID="WRITE_EXTERNAL_STORAGE"></yk-authpup>
|
<yk-authpup ref="camears" type="top" @changeAuth="changeAuth2" noticeTitle="便于您使用该功能便于您拍摄上传用于核实身份场景" permissionID="CAMERA"></yk-authpup>
|
<view class="profile">
|
<view class="profile-item">
|
<text class="label">头像(点击更换)</text>
|
<view class="" @tap="setImg">
|
<image :src="$baseUrl + userInfo.avatar" mode=""></image>
|
</view>
|
</view>
|
<view class="profile-item">
|
<text class="label">姓名</text>
|
<view class="">
|
<input type="text" disabled v-model="userInfo.realname" placeholder="请输入姓名" />
|
</view>
|
</view>
|
<view class="profile-item">
|
<text class="label">手机号</text>
|
<view class="">
|
<input type="text" disabled v-model="userInfo.phone" placeholder="请输入手机号" />
|
</view>
|
</view>
|
<view class="profile-item">
|
<text class="label">身份证</text>
|
<view class="">
|
<input type="text" disabled v-model="userInfo.idcard" placeholder="请输入身份证" />
|
</view>
|
</view>
|
<!-- <view class="profile-item">
|
<text class="label">总余额</text>
|
<view class="">
|
<input type="text" disabled v-model="userInfo.edu" placeholder="请输入可用额度" />
|
</view>
|
</view>
|
<view class="profile-item">
|
<text class="label">可用余额</text>
|
<view class="">
|
<input type="text" disabled v-model="userInfo.const" placeholder="请输入已用额度" />
|
</view>
|
</view>
|
<view class="profile-item" v-if="Config.put_open == 2">
|
<text class="label">支付权益</text>
|
<view class="">
|
<switch @change="equityOpen" v-if="userInfo.equity_open == 1" checked color="#e3b400" style="transform:scale(0.7)"/>
|
<switch @change="equityOpen" v-else color="#e3b400" style="transform:scale(0.7)"/>
|
</view>
|
</view> -->
|
</view>
|
<view class="logout" @tap="logOut">退出登录</view>
|
<view class="logout red" @tap="logOff">注销账号</view>
|
<view class="Copyright">
|
<view class="">
|
<text @tap="agreeDialog1">《用户协议》</text>
|
<text>|</text>
|
<text @tap="agreeDialog2">《隐私政策》</text>
|
</view>
|
<view class="" @tap="goWebUrl('http://beian.miit.gov.cn')">APP备案号:{{Config.icp}}</view>
|
<view class="" @tap="goWebUrl('http://beian.miit.gov.cn')">Copyright © 乐陵力宇科技 All Rights Reserved.</view>
|
</view>
|
<agreePup ref="agreePup1" :gp="1" title="注册协议"></agreePup>
|
<agreePup ref="agreePup2" :gp="2" title="隐私政策"></agreePup>
|
</view>
|
</template>
|
|
<script>
|
import ykAuthpup from "@/components/yk-authpup/yk-authpup";
|
import agreePup from "@/components/agreePup/agreePup";
|
export default {
|
components: {
|
ykAuthpup,
|
agreePup,
|
},
|
data() {
|
return {
|
userInfo: uni.getStorageSync('user-info') ? JSON.parse(uni.getStorageSync('user-info')) : null,
|
Config: uni.getStorageSync('Config') ? JSON.parse(uni.getStorageSync('Config')) : null
|
}
|
},
|
onLoad() {
|
this.getConfig()
|
this.getUserInfo()
|
},
|
methods: {
|
goWebUrl (url) {
|
// #ifdef APP-PLUS
|
plus.runtime.openURL(url)
|
// #endif
|
},
|
agreeDialog1 (e) {
|
this.$refs.agreePup1.dialog = !this.$refs.agreePup1.dialog
|
},
|
agreeDialog2 (e) {
|
this.$refs.agreePup2.dialog = !this.$refs.agreePup2.dialog
|
},
|
getConfig () {
|
let t = this
|
t.$util.post('Index/getConfig').then(res => {
|
t.Config = res.data
|
})
|
},
|
getUserInfo () {
|
let t = this
|
t.$util.post('User/getUser').then(res => {
|
t.userInfo = res.data
|
let phone = res.data.phone.substring(0, 3) + '****' + res.data.phone.substring(7)
|
let idcard = res.data.idcard.substring(0, 6) + '****' + res.data.idcard.substring(14)
|
t.userInfo.phone = phone
|
t.userInfo.idcard = idcard
|
})
|
},
|
logOut () {
|
uni.setStorageSync('pig-token', null)
|
uni.setStorageSync('user-info', null)
|
uni.setStorageSync('choose-address',null)
|
uni.setStorageSync('choose-bank',null)
|
uni.showToast({
|
title: '退出成功',
|
icon: 'success'
|
})
|
setTimeout(() => {
|
uni.navigateTo({
|
url: '/pages/login/login'
|
})
|
}, 1500)
|
},
|
logOff () {
|
let t = this
|
uni.showModal({
|
title: '温馨提示',
|
content: '注销账号后该账号将无法再次注册,是否确认?',
|
success: function (res) {
|
if (res.confirm) {
|
t.$util.post('User/logOff').then(res => {
|
if(res.code == 1) {
|
uni.showToast({
|
title: res.msg || ''
|
})
|
setTimeout(() => {
|
uni.setStorageSync('lzsc-token', null)
|
uni.setStorageSync('user-info', null)
|
uni.navigateTo({
|
url: '/pages/login/login'
|
})
|
}, 1500)
|
} else {
|
uni.showToast({
|
title: res.msg || ''
|
})
|
}
|
})
|
}
|
}
|
})
|
},
|
equityOpen () {
|
let t = this
|
t.$util.post('User/setEquity').then(res => {
|
if(res.code == 1){
|
//更新用户信息缓存
|
uni.setStorageSync('user-info', JSON.stringify(res.data))
|
uni.showToast({
|
title: res.msg || '操作成功',
|
icon: 'success'
|
})
|
}
|
})
|
},
|
changeAuth () {
|
//这里是权限通过后执行自己的代码逻辑
|
if(uni.getSystemInfoSync().platform !='ios'){
|
this.$refs['camears'].open()
|
}
|
this.chooseImg()
|
},
|
changeAuth2(){
|
this.chooseImg()
|
},
|
setImg(){
|
if(uni.getSystemInfoSync().platform != 'ios'){
|
this.$refs['authpup'].open()
|
}else{
|
this.chooseImg()
|
}//调起自定义权限目的弹框,具体可看示例里面很详细
|
},
|
chooseImg () {
|
let t = this
|
uni.chooseImage({
|
count: 1, // 默认9
|
sizeType: ['original', 'compressed'],
|
success: (chooseImageRes) => {
|
let tempFilePaths = chooseImageRes.tempFilePaths
|
let token = uni.getStorageSync('lzsc-token')
|
let header = {
|
'Accept': 'application/json',
|
'authorization': token,
|
}
|
uni.showLoading({
|
title: '上传中..',
|
})
|
uni.uploadFile({
|
url: t.$baseUrl + '/api/user/setAvatar',
|
filePath: tempFilePaths[0],
|
header: header,
|
name: 'file',
|
success: (uploadFileRes) => {
|
uni.hideLoading()
|
let res = JSON.parse(uploadFileRes.data)
|
res = JSON.parse(t.$util.decryptDes(res.data))
|
t.userInfo.avatar = res.avatar
|
uni.setStorageSync('user-info', JSON.stringify(res))
|
}
|
})
|
}
|
})
|
},
|
}
|
}
|
</script>
|
|
<style>
|
@import url(/static/css/profile.css);
|
</style>
|