oil-station/gasStation-uni/pagesMy/setup/index.vue

191 lines
4.3 KiB
Vue
Raw Normal View History

2023-11-27 09:24:16 +08:00
<template>
<view class="content">
<view class="container">
<view class="my-header">
2023-12-27 18:44:56 +08:00
<view class="my-icons" @click="goBack"> <uni-icons type="left" size="16"></uni-icons> </view>
2023-11-27 09:24:16 +08:00
<view class="my-text">设置</view>
<view class="my-icons"></view>
</view>
<!-- 顶部区域 -->
2023-12-27 18:44:56 +08:00
<button class="box-hang" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
2023-11-27 09:24:16 +08:00
<view class="">头像</view>
2023-12-27 18:44:56 +08:00
<view class="touxiang">
<image class="touxiang" v-if="user.avatar!='' && user.avatar!=null && user.avatar!=undefined" :src="baseUrl + user.avatar" mode=""></image>
<image class="touxiang" v-else src="@/static/imgs/myx.png" mode=""></image>
</view>
</button>
<view class="box-hang" @click="goEdit(0)">
2023-11-27 09:24:16 +08:00
<view class="">昵称</view>
2023-12-27 18:44:56 +08:00
<view class="dis">
<text v-if="user.name==''">未填写</text>
<text>{{user.name}}</text>
<uni-icons type="right" size="16"></uni-icons>
</view>
2023-11-27 09:24:16 +08:00
</view>
<view class="box-hang">
<view class="">手机号</view>
2023-12-27 18:44:56 +08:00
<view class="dis"> <text>{{user.mobile}}</text> <uni-icons type="right" size="16"></uni-icons> </view>
2023-11-27 09:24:16 +08:00
</view>
<view class="box-hang">
2023-12-27 18:44:56 +08:00
<view class="">会员号</view>
<view class="dis"> <text>{{user.userNo}}</text> <uni-icons type="right" size="16"></uni-icons> </view>
2023-11-27 09:24:16 +08:00
</view>
2023-12-27 18:44:56 +08:00
<view class="box-hang" @click="goEdit(2)">
2023-11-27 09:24:16 +08:00
<view class="">车牌号</view>
2023-12-27 18:44:56 +08:00
<view class="dis"> <text>{{user.carNo}}</text> <uni-icons type="right" size="16"></uni-icons> </view>
2023-11-27 09:24:16 +08:00
</view>
2023-12-27 18:44:56 +08:00
<!-- <view class="box-hang" @click="goEdit(3)">
2023-11-27 09:24:16 +08:00
<view class="">支付密码</view>
<view class="dis"> <text></text> <uni-icons type="right" size="16"></uni-icons> </view>
2023-12-27 18:44:56 +08:00
</view> -->
2023-11-27 09:24:16 +08:00
</view>
</view>
</template>
<script>
2023-12-27 18:44:56 +08:00
import request from "../../utils/request";
import upload from '@/utils/upload.js'
2023-11-27 09:24:16 +08:00
export default {
data() {
return {
title: '',
2023-12-27 18:44:56 +08:00
// 用户信息
user:{
// 用户头像
avatar:"",
},
// url信息
baseUrl: this.$baseUrl,
2023-11-27 09:24:16 +08:00
}
},
2023-12-27 18:44:56 +08:00
onShow() {
this.getUser()
},
2023-11-27 09:24:16 +08:00
components: {
},
methods: {
2023-12-27 18:44:56 +08:00
// 用户选择头像
onChooseAvatar(e){
let _this = this;
let tempFilePath = e.detail.avatarUrl //上传的图片地址
let maxSizeInBytes = 1024*1024 //限制大小
2023-12-29 16:50:44 +08:00
console.log(111)
2023-12-27 18:44:56 +08:00
uni.getFileInfo({
filePath:tempFilePath,
success(res) {
let fileSize = res.size
if (fileSize > maxSizeInBytes){
uni.showToast({
title:"请上传小于1MB的图片",
icon:"error"
})
return
}
console.log(tempFilePath)
// 将图片上传服务器
upload({
url: '/clientApi/file/upload',
filePath: tempFilePath,
}).then((res) => {
console.log('images', res.data.fileName);
_this.user.avatar = res.data.fileName
_this.editUser()
})
}
})
},
// 修改用户信息
editUser(){
request({
url: 'business/userManager/user/edit',
method: 'put',
data:this.user,
}).then(res => {
if (res.code == 200) {
this.getUser()
}
})
},
// 跳转修改页面
goEdit(val){
uni.navigateTo({
url: '/pagesMy/editUser/index?editType=' + val,
})
},
// 查询当前登录用户信息
getUser(){
request({
url: 'business/userManager/user/getUser',
method: 'get',
}).then(res => {
if (res.data != null && res.data != "" && res.data != undefined) {
this.user = res.data
}
})
},
goBack() {
2023-11-27 09:24:16 +08:00
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #f4f5f6;
}
.container {
width: 100%;
height: 100vh;
box-sizing: border-box;
padding-top: 88px;
}
.my-header {
width: 100%;
height: 88px;
background: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
color: #000;
box-sizing: border-box;
padding: 0px 15px;
padding-top: 40px;
.my-icons {
width: 20px;
}
position: fixed;
top: 0px;
}
.box-hang {
background-color: white;
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 15px 10px;
border-bottom: 1px solid #f4f5f6;
}
.touxiang {
2023-12-27 18:44:56 +08:00
width: 50px;
height: 50px;
2023-11-27 09:24:16 +08:00
border-radius: 50%;
overflow: hidden;
2023-12-27 18:44:56 +08:00
// background-color: #f4f5f6;
2023-11-27 09:24:16 +08:00
}
.dis {
color: #a69999;
}
</style>