123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- let time = null;
- const _Http = getApp().globalData.http;
- const MD5 = require('../../../../utils/md5'),
- deletMark = require("../../../../utils/Check");
- Page({
- data: {
- site: getApp().globalData.site,
- attinfos: [],
- fromList1: [{
- label: "姓名",
- error: false,
- errMsg: "",
- type: "text",
- value: "",
- placeholder: "请填写",
- valueName: "name", //绑定的字段名称
- required: true, //必填
- }, {
- label: "邮箱",
- error: false,
- errMsg: "",
- type: "text",
- value: "",
- placeholder: "请填写",
- valueName: "email", //绑定的字段名称
- required: true //必填
- }],
- disabled: true, //禁用按钮
- show: false, //显示验证码输入框
- password: "", //验证码
- countDown: 0, //倒计时
- loading: false
- },
- onLoad(options) {
- const that = this;
- getApp().globalData.Language.getLanguagePackage(this, '个人信息')
- this.setData({
- attinfos: JSON.parse(options.attinfos),
- "fromList1[0].value": options.name,
- "fromList1[1].value": options.email == "undefined" ? "" : options.email,
- "copyPhonenumber": options.phonenumber
- });
- if (!['美大'].includes(this.data.site)) { //美大禁用修改手机号
- this.data.fromList1.push({
- label: "手机号",
- error: false,
- errMsg: "",
- type: "text",
- value: options.phonenumber,
- placeholder: "请填写",
- valueName: "phonenumber", //绑定的字段名称
- required: true, //必填
- callback: function ({
- value
- }) {
- that.setData({
- show: (value != that.data.copyPhonenumber) ? true : false,
- newPhone: value
- })
- },
- })
- this.setData({
- fromList1: this.data.fromList1
- })
- }
- },
- /* from1监听 */
- form1CompletedOrNot({
- detail
- }) {
- this.setData({
- disabled: !detail
- })
- if (this.data.show) this.setData({
- disabled: this.data.password.length == 6
- })
- },
- /* 开始倒计时 */
- startCountDown() {
- let countDown = this.data.countDown;
- if (countDown != 0) return;
- if (!deletMark.CheckPhoneNumber(this.data.newPhone.trim() - 0)) return;
- _Http.basic({
- "classname": "common.usercenter.usercenter",
- "method": "updateUserMsg_getPassWord",
- "content": {
- "phonenumber": this.data.newPhone.trim()
- }
- }).then(res => {
- console.log(res)
- wx.showToast({
- title: res.msg,
- icon: "none"
- })
- if (res.code != 1) return;
- this.setData({
- countDown: 30
- })
- time = setInterval(() => {
- if (this.data.countDown == '0') return clearInterval(time);
- this.setData({
- countDown: this.data.countDown - 1
- })
- }, 1000);
- })
- },
- /* 提交 */
- submit() {
- if (this.data.disabled || this.data.loading) return;
- let data = this.selectComponent("#form1").getData().returnData;
- if (!deletMark.CheckPhoneNumber(data.phonenumber.trim() - 0)) return;
- if (!deletMark.CheckEmail(data.email.trim())) return;
- if (this.data.show && this.data.password.length == 0) return wx.showToast({
- title: getApp().globalData.Language.getMapText("请输入短信验证码"),
- icon: "none"
- });
- this.setData({
- loading: true
- });
- _Http.basic({
- "classname": "common.usercenter.usercenter",
- "method": "updateUserMsg",
- "content": {
- "name": data.name,
- "phonenumber": data.phonenumber,
- "email": data.email,
- "password": MD5.hexMD5(this.data.password.trim())
- }
- }).then(res => {
- this.setData({
- loading: false
- })
- if (res.code != 1) return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- wx.showToast({
- title: getApp().globalData.Language.getMapText("修改成功") + '!',
- });
- this.changeUserMsg();
- setTimeout(() => {
- wx.navigateBack({
- delta: 0,
- })
- }, 300);
- })
- },
- changeUserMsg() {
- let pages = getCurrentPages();
- let prevPage = pages[pages.length - 2];
- prevPage.queryUserMsg();
- },
- changeUserImage({
- detail
- }) {
- _Http.basic({
- "classname": "system.attachment.Attachment",
- "method": "createFileLink",
- "content": {
- "ownertable": "sys_users",
- "ownerid": wx.getStorageSync('userMsg').userid,
- "usetype": "headportrait",
- "attachmentids": detail
- }
- }).then(async res => {
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- let linksids = this.data.attinfos.map(v => v.linksid);
- if (linksids.length) await _Http.basic({
- "classname": "system.attachment.Attachment",
- "method": "deleteFileLink",
- "content": {
- "linksids": linksids
- }
- });
- this.setData({
- attinfos: res.data
- })
- this.changeUserMsg();
- })
- },
- })
|