|
|
@@ -1,4 +1,11 @@
|
|
|
-// pages/userCenter/index.js
|
|
|
+import {
|
|
|
+ ApiModel
|
|
|
+} from "../../utils/api";
|
|
|
+const _Http = new ApiModel();
|
|
|
+import {
|
|
|
+ TestVerify
|
|
|
+} from "../../utils/verify";
|
|
|
+const _Verify = new TestVerify();
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
@@ -6,6 +13,12 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
userMessage: {}, //用户数据列表
|
|
|
+ /* 错误提示 */
|
|
|
+ errTips: {
|
|
|
+ fname: false, //用户名
|
|
|
+ frole: false, //身份/职位
|
|
|
+ fphonenumber: false, //手机号
|
|
|
+ },
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -13,9 +26,72 @@ Page({
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
const userMessage = JSON.parse(options.data);
|
|
|
- console.log(userMessage)
|
|
|
+ const attinfos = {
|
|
|
+ attinfos: userMessage.attinfos
|
|
|
+ }
|
|
|
this.setData({
|
|
|
- userMessage
|
|
|
+ userMessage: attinfos,
|
|
|
+ fname: userMessage.fname,
|
|
|
+ fphonenumber: userMessage.fphonenumber,
|
|
|
+ fsex: userMessage.fsex,
|
|
|
+ fbirthdate: userMessage.fbirthdate,
|
|
|
+ femail: userMessage.femail,
|
|
|
+ fwechatno: userMessage.fwechatno,
|
|
|
+ faddress: userMessage.faddress,
|
|
|
+ frole: userMessage.frole
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 表单验证 */
|
|
|
+ formVerify() {
|
|
|
+ let errTips = this.data.errTips,
|
|
|
+ verify = true;
|
|
|
+ /* 验证用户名 */
|
|
|
+ if (!_Verify.required(this.data.fname)) {
|
|
|
+ errTips.fname = true;
|
|
|
+ verify = false;
|
|
|
+ }
|
|
|
+ /* 验证身份 */
|
|
|
+ if (!_Verify.required(this.data.frole)) {
|
|
|
+ errTips.frole = true;
|
|
|
+ verify = false;
|
|
|
+ }
|
|
|
+ if (!verify) {
|
|
|
+ this.setData({
|
|
|
+ errTips
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return verify;
|
|
|
+ },
|
|
|
+ /* 提交 */
|
|
|
+ submit() {
|
|
|
+ if (!this.formVerify()) return wx.showToast({
|
|
|
+ title: '请检查表单内容',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "customer.usercenter.usermsg.usermsg",
|
|
|
+ "method": "update_usermsg",
|
|
|
+ "content": {
|
|
|
+ "fname": this.data.fname,
|
|
|
+ "fsex": this.data.fsex,
|
|
|
+ "fbirthdate": this.data.fbirthdate,
|
|
|
+ "femail": this.data.femail,
|
|
|
+ "fwechatno": this.data.fwechatno,
|
|
|
+ "faddress": this.data.faddress,
|
|
|
+ "frole": this.data.frole
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg == "成功") {
|
|
|
+ wx.showToast({
|
|
|
+ title: '保存成功',
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ })
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
/* 修改用户头像 */
|