123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- <template>
- <view class="jpmain ">
- <u-navbar title="个人信息" title-color="#101010"></u-navbar>
-
- <u-popup v-model="showMessage" mode="bottom" border-radius="30" >
- <view class="showMessage">
- <view class="title">用户昵称</view>
- <view class="body">
- <u-input :customStyle="customStyle"
- placeholder="请填写用户昵称"
- v-model="nickName"></u-input>
- </view>
- <view class="botton">
- <u-button @click="showMessage=false" style="width: 35%;" shape="square" >取消</u-button>
-
- <u-button @click="updateName" style="width: 60%;" type="primary" shape="square" >确认</u-button>
- </view>
- </view>
- </u-popup>
- <u-keyboard ref="uKeyboard" @change="valChange" @backspace="backspace"
- :tips="carNumber?carNumber:'请输入车牌号'" @confirm="updateCarNumber()"
- mode="car" v-model="showCarNumber" :abc="abc" ></u-keyboard>
-
-
-
-
-
- <view class="body">
- <view class="page">
-
- <view class="page-content">
- <view class="item">
- <view class="title">
- 头像
- </view>
- <view class="goto " @click="uploadPhoto" >
- <view class="photo">
-
- <img class="img" :src="userInfo.headImg" v-if="userInfo.headImg" alt="">
- </view>
-
-
- <u-icon name="arrow-right" style="margin-left: 8rpx;" size="24" color="#BBBBBB"></u-icon>
- </view>
- </view>
-
- </view>
- </view>
-
- <view class="page">
- <view class="page-content">
- <!-- <view class="item">
- <view class="title">
- 用户昵称
- </view>
- <view class="goto" @click="showMessage=true,nickName=userInfo.nickName">
- {{userInfo.nickName?userInfo.nickName:'未设置'}}
- <u-icon name="arrow-right" style="margin-left: 8rpx;" size="24" color="#BBBBBB"></u-icon>
- </view>
- </view> -->
- <view class="item">
- <view class="title">
- 车牌号
-
- </view>
- <view class="goto" @click="carNumberBtn">
- {{userInfo.carNumber?userInfo.carNumber:'未设置'}}
- <u-icon name="arrow-right" style="margin-left: 8rpx;" size="24" color="#BBBBBB"></u-icon>
- </view>
- </view>
- <!-- <view class="item">
- <view class="title">
- 手机号码
- </view>
- <view class="goto">
- {{userInfo.phone}}
- </view>
- </view> -->
- </view>
- </view>
-
- <view class="page" @click="signOut">
-
- <view class="button">
- 退出账号
-
- </view>
- </view>
-
-
- <u-modal v-model="show1" @confirm="confirm" confirm-color="#FF3D00" :show-cancel-button="true" ref="uModal"
- :asyncClose="true" title="退出账号" content="是否退出当前账号?" :content-style="{color: '#333333'}"></u-modal>
-
- </view>
- </view>
- </template>
- <script>
- import * as API from '@/apis/pagejs/index.js'
-
- export default {
- components: {
-
- },
- data() {
- return {
- userInfo:{
- phone:"",
- headImg:"",
- carNumber:"",
- },
- showMessage:false,
- showCarNumber:false,
- carNumber:"",
- nickName:"",
- abc:false,
- show1:false,
- customStyle: {
- "border-radius": "50px",
- "background-color": 'rgba(242, 244, 246, 1)',
- padding: "5px 20px",
- margin: "5px 0 ",
-
- },
-
- }
- },
- onLoad() {
- this.userInfo = this.jphelp.getPersonInfo()
- },
- onReady() {
- this.$refs.refLogin.findByOpenId()
-
- },
- methods: {
- signOut() {
- this.show1 = true;
- },
- confirm() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- userApi.logout().then((res) => {
- uni.hideLoading();
- this.show1 = false;
- this.jphelp.logoff()
- uni.redirectTo({
- url: '/pages/login/login'
- })
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- carNumberBtn(){
-
- this.showCarNumber=1;
- this.carNumber=this.userInfo.carNumber;
- if(!this.carNumber){
- this.carNumber=""
- }
- this.valInit(1)
- },
-
- valInit(bl){
- if(bl){
- this.abc=this.carNumber.length>0
- }else{
- if(this.carNumber.length==1&&this.abc==false){
- this.abc=true
- }
- if(this.carNumber.length==0&&this.abc==true){
- this.abc=false
- }
- }
-
- },
- valChange(val){
-
- if(this.carNumber.length>=8){
- return
- }
- this.carNumber+=val
- this.valInit()
- this.$forceUpdate()
- },
- backspace(){
- //
- var value=this.carNumber
- if(value.length){
- value = value.substr(0, value.length - 1);
-
- }
- this.carNumber=value
- this.valInit()
-
-
- },
- updateCarNumber(){
- this.userInfo.carNumber=this.carNumber
- this.showCarNumber=false;
- this.updatePersonInformation()
- },
-
- updateName(){
- if(this.nickName){
- this.userInfo.nickName=this.nickName
- this.showMessage=false;
- this.updatePersonInformation()
- }else{
- this.showMessage=true;
- uni.showToast({
- title: "用户昵称不能为空",
- icon: "none"
- })
- }
-
- },
- updatePersonInformation(){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- if(!this.userInfo.nickName){
- this.userInfo.nickName=""
- }
- if(!this.userInfo.headImg){
- this.userInfo.headImg=""
- }
- if(!this.userInfo.carNumber){
- this.userInfo.carNumber=""
- }
- var obj={
- nickName:this.userInfo.nickName,
- headImg:this.userInfo.headImg,
- carNumber:this.userInfo.carNumber,
- }
-
- API.updatePersonInformation(obj).then((res) => {
-
- uni.hideLoading();
- this.$refs.refLogin.findByOpenId()
- }).catch(error => {
-
- uni.hideLoading();
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- findByOpenId(res){
- this.userInfo = this.jphelp.getPersonInfo()
-
- },
- saveRecordConfirmMethod(fileData) {
-
- var token = this.jphelp.getToken()
-
- uni.uploadFile({
- url: process.jphelp.BASE_URL + "uploadPicture", //仅为示例,非真实的接口地址
- filePath:fileData,
- header: {
- 'Authorization': token,
- //'Content-Type': 'multipart/form-data',
- 'X-Requested-With': 'XMLHttpRequest',
- // 'content-type': 'multipart/form-data'
- },
- name: 'photoFile',
- formData: {
- subFolder: "headimg"
- },
- success: (uploadFileRes) => {
-
-
- var obj = JSON.parse(uploadFileRes.data)
- //.log(obj);
- //this.src = obj.data;
- this.userInfo.headImg=obj.data;
- this.updatePersonInformation();
- // uni.hideLoading();
- }
- });
- },
- uploadPhoto() {
- let _self = this;
-
- const crop = {
- quality: 100,
- width: 600,
- height: 600,
- resize: true
- };
-
- // 上传图片
- uni.chooseImage({
- count: 1,
- crop,
- success: async (res) => {
- //(res);
- let tempFile = res.tempFiles[0];
-
- var filePath = res.tempFilePaths[0]
-
- let fileData = await new Promise((callback) => {
- uni.navigateTo({
- url: './cropImage?path=' + filePath +
- `&options=${JSON.stringify(crop)}`,
- animationType: "fade-in",
- events: {
- success: url => {
- callback(url)
- }
- }
- });
- })
-
- this.saveRecordConfirmMethod(fileData);
-
-
-
-
- }
- });
- },
- }
- }
- </script>
- <style>
- page {
- background-color: rgba(242, 244, 246, 1);
- }
- </style>
- <style scoped lang="scss">
- /* styles.css */
- .showMessage{
- padding: 40rpx 40rpx 60rpx 40rpx;
- .carNumber {
- background-color: #F2F4F6;
- padding: 5px 20px;
- margin: 5px 0 15px 0;
- height: 90rpx;
- display: flex;
- align-items: center;
- border-radius: 50px;
-
- }
- .carNumber1{
- color: #bcbcbc;
- }
-
-
- .title{
- color: rgba(16,16,16,1);
- font-size: 36rpx;
- margin-top: 32rpx;
-
- font-weight: bold;
- }
- .body{
- color: rgba(16,16,16,1);
- font-size: 32rpx;
- padding-bottom: 66rpx;
- }
- .botton{
- display: flex;
- justify-content: space-between;
- }
- }
- .body {
- padding: 32rpx;
- }
-
- .page {
- border-radius: 16rpx;
- background-color: rgba(255, 255, 255, 1);
- color: rgba(16, 16, 16, 1);
- padding:0 32rpx;
- margin-bottom: 32rpx;
- font-size: 32rpx;
- color: rgb(16, 16, 16);
-
- .page-content {
- .item:not(:last-child) {
- border-bottom:2rpx solid rgba(232,232,232,1);
- }
- .item {
- padding: 32rpx 0;
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: 32rpx;
- .title {
- display: flex;
- justify-content: space-between;
- display: flex;
- align-items: center;
- color: rgba(51,51,51,1);
-
-
- }
- .goto{
- display: flex;
- align-items: center;
- color: rgba(119,119,119,1);
-
- }
- .photo {
- border-radius: 50px;
- background-color: rgba(229, 229, 229, 1);
- height: 80rpx;
- width: 80rpx;
- overflow: hidden;
-
- .img {
- width: 100%;
- height: 100%;
- }
- }
- }
- }
- .button{
- text-align: center;
- color: red;
- padding: 32rpx 0;
- }
- }
- </style>
|