123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- // pages/operUserInfo/operUserInfo.js
- const app = getApp()
- const utils = require('../../utils/util.js')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- globalUrl: app.globalData.globalUrl,
- userInfo: '', //缓存的用户信息
- user: '', //用户信息
- other: '', //角色信息
- sex: ['男', '女'], //性别列表
- sexIndex: '', //当前性别下标
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- userInfo: utils.getInfo()
- })
- this.getUser()
- },
- //获取用户信息
- getUser() {
- utils.getUser({
- sendBefore: () => {
- wx.showLoading({
- title: '加载中...',
- mask: true
- })
- },
- complete: () => {
- wx.hideLoading()
- }
- }).then(res => {
- if (res.data.sex) {
- if (res.data.sex === 'M') {
- this.setData({
- sexIndex: 0
- })
- } else if (res.data.sex === 'F') {
- this.setData({
- sexIndex: 1
- })
- }
- }
- this.setData({
- user: res.data
- })
- })
- },
- //修改或者上传头像
- uploadAvatar() {
- utils.chooseImage({
- sendBefore: () => {
- wx.showLoading({
- title: '上传中...'
- })
- }
- }).then(res => {
- utils.uploadFile({
- name: 'file',
- url: '/auth/comm/user/avatar/update',
- filePath: res.tempFilePaths[0],
- formData: {
- mobile: this.data.userInfo.mobile,
- reqChannel: 5
- },
- complete: () => {
- wx.hideLoading()
- }
- }).then(res => {
- this.updateSuccess()
- })
- })
- },
- //修改其他字段
- request(params) {
- utils.axios({
- method: 'post',
- url: '/auth/comm/user/personalInfo/save',
- data: params,
- success: res => {
- this.updateSuccess()
- }
- })
- },
- //信息修改成功执行的字段
- updateSuccess() {
- utils.toast('信息修改成功')
- this.selectComponent('#nickName').hideModal()
- this.selectComponent('#intro').hideModal()
- this.getUser()
- },
- //昵称
- showNickName() {
- this.selectComponent('#nickName').showModal()
- },
- getNickName(e) {
- let params = {
- mobile: this.data.userInfo.mobile,
- reqChannel: 5,
- nickName: e.detail
- }
- this.request(params)
- },
- //性别
- setSex(e) {
- let sexList = ['M', 'F']
- let params = {
- mobile: this.data.userInfo.mobile,
- reqChannel: 5,
- sex: sexList[e.detail.value]
- }
- this.request(params)
- },
- //个人简介
- showIntro() {
- this.selectComponent('#intro').showModal()
- },
- getIntro(e) {
- let params = {
- mobile: this.data.userInfo.mobile,
- reqChannel: 5,
- personalProfile: e.detail
- }
- this.request(params)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- title: '诺信云',
- path: '/pages/index/index'
- }
- }
- })
|