| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 | const Parse = getApp().Parse    // const company = getApp().globalData.companyconst dateF = require('../../../utils/date')Page({    /**     * 页面的初始数据     */    data: {        consume: 0,        activeColor: "",        titleColor: "",        currentDate: new Date().getTime(),        minDate: (new Date().getTime() - 70 * 12 * 30 * 24 * 60 * 60 * 1000),        account: null,        mobile: null,        nickname: null,        actions: [{                name: '男',            },            {                name: '女',            },        ],        images: []    },    onSelect(event) {        console.log(event.detail);        let {            name        } = event.detail        let {            user        } = this.data        user.sex = name        this.setData({            user,            show2: false        })    },    async getUser() {        let id = Parse.User.current() ? Parse.User.current().id : ""        if (!id) {            wx.showToast({                title: '您还未登录请先登录',                icon: 'error'            })            setTimeout(() => {                wx.navigateBack({                    delta: 1                });            }, 1000)            return        }        let new_user = new Parse.Query('_User')        new_user.include('invite')        new_user.include('agentLevel')        new_user.select('objectId', 'avatar', 'authentication', 'nickname', 'mobile', 'invite.nickname',            'agentLevel.name')        let res = await new_user.get(id)        let user = res.toJSON()        user.joinTime = dateF.formatTime("YYYY-mm-dd", user.createdAt)        if (user.authentication && user.authentication != {}) {            user.auth = { isAuth: true, label: "已认证" }        } else {            user.auth = { isAuth: false, label: "未认证" }        }        console.log(user.avatar)        this.setData({            user: user,            images: [user.avatar]        })    },    // 会员头像,会员昵称,手机号,会员性别,实名认证,会员等级,会员ID, 邀请人,    async getAccount() {        let Account = new Parse.Query('Account')        Account.equalTo('user', Parse.User.current().id)        Account.select('bank', 'wechat')        let account = await Account.first()        let a = account.toJSON()        if (a.bank && a.bank.length > 0) {            a.isBank = { isBank: true, label: "已绑定" }        } else {            a.isBank = { isBank: false, label: "未绑定" }        }        if (a.wechat) {            a.isWechat = { isWechat: true, label: "已绑定" }        } else {            a.isWechat = { isWechat: false, label: "未绑定" }        }        if (account && account.id) {            this.setData({                account: a            })        }    },    editMobile(e) {        let mobile = e.detail.value        let a = /^1[3456789]\d{9}$/;        if (!mobile.match(a)) {            wx.showToast({                icon: "none",                title: "请填写正确的手机记号格式",            });            return;        } else {            this.setData({                mobile: mobile            })        }    },    changeImage(e) {        if (e.detail && e.detail.length > 0) {            this.setData({                image: [e.detail[0].url]            })        } else {            this.setData({                image: []            })        }    },    editNickname(e) {        let nickname = e.detail        this.setData({            nickname: nickname        })    },    onInput(event) {        this.setData({            currentDate: event.detail,        });    },    showPicker() {        this.setData({            show: true        })    },    //取消日期选择    onClose() {        this.setData({            show: false,            show2: false        })    },    showSelect() {        this.setData({            show2: true        })    },    async submit() {        let {            sex        } = this.data.user        console.log(this.data.user)        let id = Parse.User.current().id        let new_user = new Parse.Query('_User')        let res = await new_user.get(id)        if (sex) {            res.set("sex", sex)        }        if (this.data.mobile) {            res.set("mobile", this.data.mobile)        }        if (this.data.nickname) {            res.set("nickname", this.data.nickname)        }        let updateuser = await res.save()        if (updateuser) {            console.log(updateuser)            wx.showToast({                title: '修改成功',                icon: 'success',                image: '',                duration: 1000,                mask: false,                success: (result) => {                    setTimeout(() => {                        wx.navigateBack({                            delta: 1                        });                    }, 1000);                },                fail: () => {},                complete: () => {}            });        }    },    toAuth() {        wx.navigateTo({            url: '/common-page/pages/info/cauth/cauth'        })    },    bindWechat(e) {        wx.navigateTo({            url: `/common-page/pages/info/bindWechat/index?way='wechat'`,        })    },    bindBank() {        wx.navigateTo({            url: `/common-page/pages/info/bindBank/index`,        })    },    /**     * 生命周期函数--监听页面加载     */    onLoad: function(options) {        this.getUser()        this.getAccount()        console.log(getApp().globalData.activeColor, 'getApp().globalData.activeColor')        this.setData({            activeColor: getApp().globalData.activeColor,            titleColor: getApp().globalData.titleColor        })        console.log(this.data.activeColor);    },    /**     * 生命周期函数--监听页面初次渲染完成     */    onReady: function() {    },    /**     * 生命周期函数--监听页面显示     */    onShow: function() {        this.getUser()        this.getAccount()    },    /**     * 生命周期函数--监听页面隐藏     */    onHide: function() {    },    /**     * 生命周期函数--监听页面卸载     */    onUnload: function() {    },    /**     * 页面相关事件处理函数--监听用户下拉动作     */    onPullDownRefresh: function() {    },    /**     * 页面上拉触底事件的处理函数     */    onReachBottom: function() {    },    /**     * 用户点击右上角分享     */    onShareAppMessage: function() {    }})
 |