2024-02-21 17:43:11 +08:00
|
|
|
let app = getApp()
|
2024-03-13 15:14:37 +08:00
|
|
|
|
|
|
|
import {
|
|
|
|
userProfile
|
|
|
|
} from "../../../api/user/user.js"
|
|
|
|
|
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: [],
|
|
|
|
parkindex: 0
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
2024-03-13 15:14:37 +08:00
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onShow(e) {
|
|
|
|
var 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
|
|
|
|
})
|
|
|
|
app.AjaxRequest('get', {
|
|
|
|
'content-type': 'application/json'
|
|
|
|
}, '/park/list', {}, function (res) {
|
|
|
|
if (res.code == 0) {
|
|
|
|
res.data.forEach(item => {
|
|
|
|
let park = that.data.park
|
|
|
|
park.push(item.parkName)
|
|
|
|
that.setData({
|
|
|
|
park
|
|
|
|
})
|
|
|
|
})
|
|
|
|
that.setData({
|
|
|
|
parkList: res.data
|
|
|
|
})
|
|
|
|
that.parkIdtype(res.data, wx.getStorageSync('parkId'))
|
|
|
|
}
|
2024-02-21 17:43:11 +08:00
|
|
|
})
|
2024-03-13 15:14:37 +08:00
|
|
|
that.getList()
|
|
|
|
},
|
2024-02-21 17:43:11 +08:00
|
|
|
|
2024-03-13 15:14:37 +08:00
|
|
|
parkIdtype(list, id) {
|
|
|
|
list.forEach((item, index) => {
|
|
|
|
if (item.id == id) {
|
|
|
|
this.setData({
|
|
|
|
parkindex: index
|
|
|
|
})
|
|
|
|
}
|
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
|
|
|
parkChange(e) {
|
2024-04-02 17:51:41 +08:00
|
|
|
let that = this
|
2024-03-13 15:14:37 +08:00
|
|
|
that.data.parkList.forEach(item => {
|
|
|
|
if (that.data.park[e.detail.value] == item.parkName) {
|
2024-04-02 17:51:41 +08:00
|
|
|
that.setData({
|
|
|
|
parkindex: e.detail.value
|
2024-03-13 15:14:37 +08:00
|
|
|
})
|
2024-04-02 17:51:41 +08:00
|
|
|
wx.setStorageSync('parkId', item.id)
|
|
|
|
wx.setStorageSync('parkName', item.parkName)
|
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
|
|
|
})
|