2024-02-21 17:43:11 +08:00
|
|
|
let app = getApp()
|
2024-03-13 15:14:37 +08:00
|
|
|
|
|
|
|
import {
|
2024-04-08 15:59:13 +08:00
|
|
|
userProfile,
|
|
|
|
getUserInfoRq
|
2024-03-13 15:14:37 +08:00
|
|
|
} from "../../../api/user/user.js"
|
|
|
|
|
2024-04-08 15:59:13 +08:00
|
|
|
|
2024-02-21 17:43:11 +08:00
|
|
|
Page({
|
|
|
|
|
2024-03-13 15:14:37 +08:00
|
|
|
data: {
|
|
|
|
sex: ['男', '女'],
|
|
|
|
sexindex: 0,
|
|
|
|
showDialog: false,
|
|
|
|
ifName: true,
|
|
|
|
DOMAIN_NAME: app.IMG_NAME,
|
|
|
|
park: [],
|
2024-04-08 15:59:13 +08:00
|
|
|
parkindex: 0,
|
|
|
|
parkName: '',
|
|
|
|
customerName: ''
|
2024-03-13 15:14:37 +08:00
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
2024-03-13 15:14:37 +08:00
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onShow(e) {
|
2024-04-08 15:59:13 +08:00
|
|
|
let _this = this;
|
|
|
|
let that = this
|
2024-02-21 17:43:11 +08:00
|
|
|
that.setData({
|
2024-03-13 15:14:37 +08:00
|
|
|
DOMAIN_NAME: app.img_Name
|
|
|
|
})
|
|
|
|
that.getList()
|
2024-04-08 15:59:13 +08:00
|
|
|
//
|
|
|
|
let userId = wx.getStorageSync('userId');
|
|
|
|
if (userId) {
|
|
|
|
getUserInfoRq(userId).then(res => {
|
|
|
|
console.log('getUserInfoRq', res);
|
|
|
|
let userDetail = res.data;
|
|
|
|
_this.setData({
|
|
|
|
customerName: userDetail.customerName,
|
|
|
|
parkName: wx.getStorageSync('parkName')
|
2024-03-13 15:14:37 +08:00
|
|
|
})
|
2024-04-08 15:59:13 +08:00
|
|
|
})
|
|
|
|
} else {
|
|
|
|
app.getlogin()
|
|
|
|
return
|
|
|
|
}
|
2024-03-13 15:14:37 +08:00
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
2024-04-08 15:59:13 +08:00
|
|
|
// 跳转园区
|
|
|
|
jumpPark() {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/index/parkList/parkList',
|
2024-02-21 17:43:11 +08:00
|
|
|
})
|
2024-03-13 15:14:37 +08:00
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
2024-03-13 15:14:37 +08:00
|
|
|
cancel() {
|
|
|
|
this.setData({
|
|
|
|
ifName: true
|
|
|
|
})
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
2024-03-13 15:14:37 +08:00
|
|
|
change(e) {
|
|
|
|
this.setData({
|
|
|
|
name: e.currentTarget.dataset.name,
|
|
|
|
ifName: false
|
|
|
|
})
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
2024-03-13 15:14:37 +08:00
|
|
|
setValue(e) {
|
|
|
|
if (this.data.name == '姓名') {
|
|
|
|
this.setData({
|
|
|
|
nickname: e.detail.value
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
post: e.detail.value
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
confirm() {
|
|
|
|
let that = this
|
|
|
|
if (this.data.name == '姓名') {
|
|
|
|
app.AjaxRequest('POST', {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + app.Getopenid()
|
|
|
|
}, '/user/profile/update', {
|
|
|
|
username: that.data.nickname
|
|
|
|
}, function (ret) {
|
|
|
|
that.setData({
|
|
|
|
ifName: true
|
|
|
|
})
|
|
|
|
that.getList()
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
app.AjaxRequest('POST', {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + app.Getopenid()
|
|
|
|
}, '/user/profile/update', {
|
|
|
|
post: that.data.post
|
|
|
|
}, function (ret) {
|
|
|
|
that.setData({
|
|
|
|
ifName: true
|
|
|
|
})
|
|
|
|
that.getList()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
2024-03-13 15:14:37 +08:00
|
|
|
// 性别选择
|
|
|
|
sexChange: function (e) {
|
|
|
|
let that = this
|
2024-02-21 17:43:11 +08:00
|
|
|
that.setData({
|
2024-03-13 15:14:37 +08:00
|
|
|
sexindex: e.detail.value
|
2024-02-21 17:43:11 +08:00
|
|
|
})
|
2024-03-13 15:14:37 +08:00
|
|
|
app.AjaxRequest('POST', {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + app.Getopenid()
|
|
|
|
}, '/user/profile/update', {
|
|
|
|
gender: JSON.parse(e.detail.value)
|
|
|
|
}, function (ret) {
|
|
|
|
that.getList()
|
2024-02-21 17:43:11 +08:00
|
|
|
})
|
2024-03-13 15:14:37 +08:00
|
|
|
},
|
|
|
|
getList() {
|
|
|
|
let that = this
|
|
|
|
userProfile(wx.getStorageSync('userId')).then(res => {
|
|
|
|
that.setData({
|
|
|
|
memberInfo: res.data,
|
2024-03-28 09:04:13 +08:00
|
|
|
sexindex: res.data.gender
|
2024-03-13 15:14:37 +08:00
|
|
|
})
|
2024-02-21 17:43:11 +08:00
|
|
|
})
|
2024-03-13 15:14:37 +08:00
|
|
|
},
|
|
|
|
chooseimage: function () {
|
|
|
|
var that = this
|
|
|
|
let imgUrl = that.data.imgUrl
|
|
|
|
wx.chooseImage({
|
|
|
|
count: 1, // 默认9
|
|
|
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
|
|
success: function (res) {
|
|
|
|
console.log(res.tempFilePaths[0])
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '../cropper/cropper?img=' + res.tempFilePaths[0],
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
navCropper() {
|
|
|
|
this.chooseimage()
|
|
|
|
},
|
|
|
|
exitaccount() {
|
|
|
|
wx.showModal({
|
|
|
|
title: '提示',
|
|
|
|
content: '确定退出账号吗',
|
|
|
|
success(res) {
|
|
|
|
if (res.confirm) {
|
|
|
|
wx.clearStorageSync()
|
|
|
|
wx.reLaunch({
|
|
|
|
url: '/pages/login/login',
|
|
|
|
})
|
|
|
|
} else if (res.cancel) {
|
|
|
|
console.log('用户点击取消')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2024-02-21 17:43:11 +08:00
|
|
|
})
|