baodeng_xcx/pages/my.vue
2025-05-17 08:42:24 +08:00

362 lines
9.2 KiB
Vue

<template>
<view class="page">
<u-navbar :is-back="false" title="我的" :border-bottom="false" back-icon-color="000" :background="bgc" title-color='#fff' title-size='36'
height='36' id="navbar">
</u-navbar>
<image class="bj" src="https://api.ccttiot.com/smartmeter/img/static/uLeHF2hmWdyk8KT1ESFj" mode="aspectFill"></image>
<view class="box">
<view class="top">
<button type="primary reverse" open-type="chooseAvatar" @chooseavatar="getimage">
<image :src="info.avatar" mode=""></image>
</button>
<!-- <view class="pic">
<image src="https://api.ccttiot.com/smartmeter/img/static/uhygDEgTWnL6P1uXlzVt" mode=""></image>
</view> -->
<!-- <view class="bianji" @click="btnbj">
编辑资料
</view> -->
<view class="bianji" style="background-color: transparent;">
</view>
</view>
<view class="name">
{{info.phonenumber == null ? '--' : info.phonenumber}}
<!-- <image src="https://lxnapi.ccttiot.com/smartmeter/img/static/uq55BqY493f606zzVUuX" mode=""></image> -->
</view>
<view class="qianm">
欢迎来到PICK ME UP
</view>
<view class="gongneng">
<!-- <view class="li">
<view class="one">
<image src="https://lxnapi.ccttiot.com/smartmeter/img/static/uDpdW1aK6GmY3pArseqW" mode=""></image> 积分兑换
</view>
<image class="jt" src="https://lxnapi.ccttiot.com/smartmeter/img/static/uo3VNhAA6YDvl6lt5kaY" mode=""></image>
</view>
<view class="li">
<view class="one">
<image src="https://lxnapi.ccttiot.com/smartmeter/img/static/uGJS2qdk4JKKLiPt7c9K" mode=""></image> 意见反馈
</view>
<image class="jt" src="https://lxnapi.ccttiot.com/smartmeter/img/static/uo3VNhAA6YDvl6lt5kaY" mode=""></image>
</view>
<view class="li">
<view class="one">
<image src="https://lxnapi.ccttiot.com/smartmeter/img/static/u2tbwMgaIqD7yVMLcE4G" mode=""></image> 我的黑名单
</view>
<image class="jt" src="https://lxnapi.ccttiot.com/smartmeter/img/static/uo3VNhAA6YDvl6lt5kaY" mode=""></image>
</view> -->
<view class="li" @click="btnpage(1)">
<view class="one">
<image src="https://lxnapi.ccttiot.com/smartmeter/img/static/uTHDjaexeftSQpdGsjSD" mode=""></image> 用户协议
</view>
<image class="jt" src="https://lxnapi.ccttiot.com/smartmeter/img/static/uo3VNhAA6YDvl6lt5kaY" mode=""></image>
</view>
<view class="li" @click="btnpage(2)">
<view class="one">
<image src="https://lxnapi.ccttiot.com/smartmeter/img/static/uHSoiXaQKLZF6yV6RzLp" mode=""></image> 隐私政策
</view>
<image class="jt" src="https://lxnapi.ccttiot.com/smartmeter/img/static/uo3VNhAA6YDvl6lt5kaY" mode=""></image>
</view>
<view class="li" @click="btnpage(3)">
<view class="one">
<image src="https://lxnapi.ccttiot.com/smartmeter/img/static/uQLSntg7FR7kPAn5h2MC" mode=""></image> 关于我们
</view>
<image class="jt" src="https://lxnapi.ccttiot.com/smartmeter/img/static/uo3VNhAA6YDvl6lt5kaY" mode=""></image>
</view>
<!-- <view class="li" @click="btnluru">
<view class="one">
<image src="https://lxnapi.ccttiot.com/smartmeter/img/static/uGJS2qdk4JKKLiPt7c9K" mode=""></image> 设备录入
</view>
<image class="jt" src="https://lxnapi.ccttiot.com/smartmeter/img/static/uo3VNhAA6YDvl6lt5kaY" mode=""></image>
</view> -->
<view class="li" @click="btntc" v-if="flag">
<view class="one">
<image src="https://lxnapi.ccttiot.com/smartmeter/img/static/u2tbwMgaIqD7yVMLcE4G" mode=""></image> 退出登录
</view>
<image class="jt" src="https://lxnapi.ccttiot.com/smartmeter/img/static/uo3VNhAA6YDvl6lt5kaY" mode=""></image>
</view>
</view>
<view class="gongzuotai" v-if="roles.length > 0" @click="btnshanghu">
工作台
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
bgc: {
backgroundColor: "",
},
flag:false,
roles:[],
info:{},
token:'',
userImgs:''
}
},
onShow() {
this.getinfo()
this.gettoken()
},
methods: {
// 更换头像
getimage(e){
let that = this
let math = 'static/' + that.$u.guid(20)
wx.uploadFile({
url: 'https://up-z2.qiniup.com',
name: 'file',
filePath: e.detail.avatarUrl,
formData: {
token: that.token, //后端返回的token
key: 'smartmeter/img/' + math
},
success: function(res) {
let str = JSON.parse(res.data)
console.log(str);
that.userImgs = 'https://api.ccttiot.com/' + str.key
console.log(that.userImgs)
that.getxiugai()
}
})
},
// 修改个人信息
getxiugai(){
let data = {
// userId:this.info.userId,
avatar:this.userImgs
}
this.$u.put(`/app/user/editInfo`,data).then(res => {
if (res.code == 200) {
uni.showToast({
title: '修改成功',
icon: 'success',
duration:2000
})
this.getinfo()
}else if(res.code == 401){
uni.showModal({
title: '提示',
content: '您当前暂未登录,需前去登录吗?',
success: function (res) {
if (res.confirm) {
uni.reLaunch({
url:'/pages/login/login'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
})
} else{
uni.showToast({
title: res.msg,
icon: 'none',
duration:2000
})
}
})
},
// 获取七牛云token
gettoken(){
this.$u.get(`/common/qiniuToken`).then(res => {
if (res.code == 200) {
this.token = res.data
}
})
},
getinfo(){
this.$u.get(`/getInfo`).then(res => {
if (res.code == 200) {
this.roles = res.roles
this.info = res.user
this.flag = true
}else if(res.code == 401){
this.flag = false
}
})
},
// 点击跳转各类协议
btnpage(num){
if(num == 1){ //用户协议
uni.navigateTo({
url:'/page_shanghu/about?tit=' + '用户协议' + '&type=1'
})
}else if(num == 2){ //隐私政策
uni.navigateTo({
url:'/page_shanghu/about?tit=' + '隐私政策' + '&type=2'
})
}else{ //关于我们
uni.navigateTo({
url:'/page_shanghu/about?tit=' + '关于我们' + '&type=3'
})
}
},
// 点击跳转到设备录入
btnluru(){
uni.navigateTo({
url:'/page_user/luru/index'
})
},
// 点击跳转到商户端
btnshanghu(){
uni.navigateTo({
url:'/page_shanghu/index'
})
},
// 点击跳转到编辑信息
btnbj(){
uni.navigateTo({
url:'/page_user/editxx'
})
},
// 点击退出登录
btntc(){
uni.showModal({
title: '提示',
content: '您确定要退出登录吗?',
success: function (res) {
if (res.confirm) {
uni.reLaunch({
url:'/pages/login/login'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
})
}
}
}
</script>
<style lang="scss">
page {
background-color: #fff;
}
.gongzuotai{
width: 160rpx;
height: 80rpx;
position: fixed;
top: 200rpx;
right:20rpx;
background-color: #010000;
color: #fff;
border-radius: 30rpx;
text-align: center;
line-height: 80rpx;
}
.bj{
width: 750rpx;
height: 574rpx;
position: fixed;
z-index: -1;
top: 0;
left: 0;
filter: blur(2px);
}
.box{
width: 750rpx;
height: 1082rpx;
background: #010000;
position: fixed;
bottom: 0;
left: 0;
border-radius: 30rpx 30rpx 0 0;
padding: 0 62rpx;
box-sizing: border-box;
.gongneng{
width: 644rpx;
max-height: 494rpx;
background: #0E0C0C;
border-radius: 20rpx 20rpx 20rpx 20rpx;
margin-top: 24rpx;
padding: 40rpx 46rpx;
padding-bottom: 10rpx !important;
box-sizing: border-box;
.li{
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 36rpx;
.one{
image{
width: 42rpx;
height: 42rpx;
margin-right: 28rpx;
}
display: flex;
align-items: center;
font-size: 28rpx;
color: #FFFFFF;
}
.jt{
width: 20rpx;
height: 20rpx;
}
}
}
.qianm{
font-size: 28rpx;
color: #9F9F9F;
margin-top: 24rpx;
}
.name{
font-size: 36rpx;
color: #FFFFFF;
display: flex;
align-items: center;
margin-top: 38rpx;
image{
width: 32rpx;
height: 32rpx;
margin-left: 28rpx;
}
}
.top{
display: flex;
justify-content: space-between;
button{
width: 150rpx;
height: 150rpx;
border-radius: 50%;
position: absolute;
top: -75rpx;
image{
width: 150rpx;
height: 150rpx;
border-radius: 50%;
position: absolute;
left: 0;
}
}
.pic{
image{
width: 150rpx;
height: 150rpx;
border-radius: 50%;
position: absolute;
top: -75rpx;
}
}
.bianji{
width: 150rpx;
height: 48rpx;
background: #FFE7EA;
border-radius: 31rpx 31rpx 31rpx 31rpx;
font-size: 26rpx;
color: #FF8998;
text-align: center;
padding-top: 6rpx;
box-sizing: border-box;
margin-top: 38rpx;
}
}
}
</style>