|
@@ -1,6 +1,5 @@
|
|
const app = getApp()
|
|
const app = getApp()
|
|
import WxValidate from '../../utils/wxValidate'
|
|
import WxValidate from '../../utils/wxValidate'
|
|
-const { gender } = require('../../utils/dict')
|
|
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -10,15 +9,8 @@ Page({
|
|
frameStyle: { useTop: true, name: '信息管理', leftArrow: true, useBar: false },
|
|
frameStyle: { useTop: true, name: '信息管理', leftArrow: true, useBar: false },
|
|
id: '',
|
|
id: '',
|
|
form: { icon: [] },
|
|
form: { icon: [] },
|
|
- typeList: [
|
|
|
|
- { label: '超级管理员', value: '-1' },
|
|
|
|
- { label: '普通用户', value: '0' },
|
|
|
|
- { label: '管理员', value: '1' },
|
|
|
|
- { label: '教练', value: '2' },
|
|
|
|
- { label: '学员', value: '3' },
|
|
|
|
- { label: '游客', value: '10' },
|
|
|
|
- ],
|
|
|
|
- genderList: gender
|
|
|
|
|
|
+ typeList: [],
|
|
|
|
+ genderList: []
|
|
},
|
|
},
|
|
initValidate() {
|
|
initValidate() {
|
|
const rules = { type: { required: true }, icon: { required: true }, name: { required: true }, gender: { required: true }, phone: { required: true, tel: true } }
|
|
const rules = { type: { required: true }, icon: { required: true }, name: { required: true }, gender: { required: true }, phone: { required: true, tel: true } }
|
|
@@ -49,7 +41,7 @@ Page({
|
|
let data = that.data.typeList[e.detail.value];
|
|
let data = that.data.typeList[e.detail.value];
|
|
if (data) {
|
|
if (data) {
|
|
that.setData({ 'form.type': data.value });
|
|
that.setData({ 'form.type': data.value });
|
|
- that.setData({ 'form.type_name': data.label });
|
|
|
|
|
|
+ that.setData({ 'form.zhType': data.label });
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 选择性别
|
|
// 选择性别
|
|
@@ -58,7 +50,7 @@ Page({
|
|
let data = that.data.genderList[e.detail.value];
|
|
let data = that.data.genderList[e.detail.value];
|
|
if (data) {
|
|
if (data) {
|
|
that.setData({ 'form.gender': data.value });
|
|
that.setData({ 'form.gender': data.value });
|
|
- that.setData({ 'form.gender_name': data.label });
|
|
|
|
|
|
+ that.setData({ 'form.zhGender': data.label });
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 提交登录
|
|
// 提交登录
|
|
@@ -82,18 +74,31 @@ Page({
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
- onLoad: function (options) {
|
|
|
|
|
|
+ onLoad: async function (options) {
|
|
const that = this;
|
|
const that = this;
|
|
that.setData({ id: options.id || null })
|
|
that.setData({ id: options.id || null })
|
|
//验证规则函数
|
|
//验证规则函数
|
|
that.initValidate();
|
|
that.initValidate();
|
|
|
|
+ // 查询其他信息
|
|
|
|
+ await that.searchOther();
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
- that.watchLogin();
|
|
|
|
-
|
|
|
|
|
|
+ await that.watchLogin();
|
|
|
|
+ },
|
|
|
|
+ searchOther: async function () {
|
|
|
|
+ const that = this;
|
|
|
|
+ let arr;
|
|
|
|
+ // 用户类型
|
|
|
|
+ arr = await app.$get(`/dict`, { code: 'user_type' });
|
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) { let list = arr.data[0].list; that.setData({ typeList: list }) }
|
|
|
|
+ // 用户性别
|
|
|
|
+ arr = await app.$get(`/dict`, { code: 'gender' });
|
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) { let list = arr.data[0].list; that.setData({ genderList: list }) }
|
|
},
|
|
},
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
watchLogin: async function () {
|
|
watchLogin: async function () {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ let typeList = that.data.typeList;
|
|
|
|
+ let genderList = that.data.genderList;
|
|
wx.getStorage({
|
|
wx.getStorage({
|
|
key: 'user',
|
|
key: 'user',
|
|
success: async res => {
|
|
success: async res => {
|
|
@@ -101,10 +106,10 @@ Page({
|
|
if (that.data.id) {
|
|
if (that.data.id) {
|
|
arr = await app.$get(`/user/${that.data.id}`);
|
|
arr = await app.$get(`/user/${that.data.id}`);
|
|
if (arr.errcode == '0') {
|
|
if (arr.errcode == '0') {
|
|
- let type = that.data.typeList.find(i => i.value == arr.data.type);
|
|
|
|
- if (type) arr.data.type_name = type.label;
|
|
|
|
- let gender = that.data.genderList.find(i => i.value == arr.data.gender);
|
|
|
|
- if (gender) arr.data.gender_name = gender.label;
|
|
|
|
|
|
+ let type = typeList.find(i => i.value == arr.data.type);
|
|
|
|
+ if (type) arr.data.zhType = type.label;
|
|
|
|
+ let gender = genderList.find(i => i.value == arr.data.gender);
|
|
|
|
+ if (gender) arr.data.zhGender = gender.label;
|
|
that.setData({ form: arr.data })
|
|
that.setData({ form: arr.data })
|
|
} else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
} else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
}
|
|
}
|