|
@@ -1,5 +1,6 @@
|
|
// pages/login/login.js
|
|
// pages/login/login.js
|
|
import WxValidate from '../../utils/wxValidate'
|
|
import WxValidate from '../../utils/wxValidate'
|
|
|
|
+const { type } = require('../../utils/dict');
|
|
const app = getApp()
|
|
const app = getApp()
|
|
Page({
|
|
Page({
|
|
|
|
|
|
@@ -10,17 +11,10 @@ Page({
|
|
frameStyle: { useTop: true, name: '基本信息', leftArrow: true, useBar: false },
|
|
frameStyle: { useTop: true, name: '基本信息', leftArrow: true, useBar: false },
|
|
// 主体高度
|
|
// 主体高度
|
|
infoHeight: '',
|
|
infoHeight: '',
|
|
- info: { id: '1234567', name: '测试人员', phone: '12345678901', email: '123456@qq.com', address: '1', dept: '1', zw: '1', company: '1', type: '0', type_name: '超级管理员' },
|
|
|
|
|
|
+ id: '',
|
|
form: {},
|
|
form: {},
|
|
// 用户类别
|
|
// 用户类别
|
|
- typeList: [
|
|
|
|
- { value: '0', label: '超级管理员' },
|
|
|
|
- { value: '1', label: '科室人员' },
|
|
|
|
- { value: '2', label: '办公室人员' },
|
|
|
|
- { value: '3', label: '采购部门' },
|
|
|
|
- { value: '4', label: '入库管理部门' },
|
|
|
|
- { value: '5', label: '财务部门' },
|
|
|
|
- { value: '6', label: '供货单位' },]
|
|
|
|
|
|
+ typeList: type
|
|
},
|
|
},
|
|
initValidate() {
|
|
initValidate() {
|
|
const rules = { type_name: { required: true, }, name: { required: true, }, phone: { required: true, tel: true }, email: { required: true, }, address: { required: true, }, dept: { required: true, }, zw: { required: true, }, company: { required: true, } }
|
|
const rules = { type_name: { required: true, }, name: { required: true, }, phone: { required: true, tel: true }, email: { required: true, }, address: { required: true, }, dept: { required: true, }, zw: { required: true, }, company: { required: true, } }
|
|
@@ -44,20 +38,49 @@ Page({
|
|
},
|
|
},
|
|
// 提交修改
|
|
// 提交修改
|
|
onSubmit: function (e) {
|
|
onSubmit: function (e) {
|
|
- console.log(e.detail.value)
|
|
|
|
|
|
+ const params = e.detail.value;
|
|
|
|
+ if (!this.WxValidate.checkForm(params)) {
|
|
|
|
+ const error = this.WxValidate.errorList[0];
|
|
|
|
+ wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
|
+ return false
|
|
|
|
+ } else {
|
|
|
|
+ console.log(params);
|
|
|
|
+ }
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
- if (options.id) {
|
|
|
|
- this.setData({ 'form': this.data.info })
|
|
|
|
- }
|
|
|
|
//验证规则函数
|
|
//验证规则函数
|
|
this.initValidate();
|
|
this.initValidate();
|
|
|
|
+ if (options.id) this.setData({ id: options.id })
|
|
|
|
+ // 监听用户是否登录
|
|
|
|
+ this.watchLogin();
|
|
// 计算高度
|
|
// 计算高度
|
|
this.searchHeight()
|
|
this.searchHeight()
|
|
},
|
|
},
|
|
|
|
+ // 监听用户是否登录
|
|
|
|
+ watchLogin: function () {
|
|
|
|
+ const that = this;
|
|
|
|
+ let id = that.data.id;
|
|
|
|
+ if (id) {
|
|
|
|
+ // 如果有ID查询数据详情,赋值给form
|
|
|
|
+ }
|
|
|
|
+ // wx.getStorage({
|
|
|
|
+ // key: 'user',
|
|
|
|
+ // success: res => {
|
|
|
|
+ // if (res.data) {
|
|
|
|
+ // // 查询菜单
|
|
|
|
+ // if (res.data) this.searchRouter(res.data);
|
|
|
|
+ // res.data.type = type.find((i) => i.value == res.data.type).label;
|
|
|
|
+ // if (res.data) this.setData({ userInfo: res.data });
|
|
|
|
+ // if (res.data && res.data.avatarUrl) this.setData({ avatarUrl: res.data.avatarUrl });
|
|
|
|
+ // } else {
|
|
|
|
+ // wx.redirectTo({ url: '/pages/login/index', })
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ },
|
|
// 计算高度
|
|
// 计算高度
|
|
searchHeight: function () {
|
|
searchHeight: function () {
|
|
let frameStyle = this.data.frameStyle;
|
|
let frameStyle = this.data.frameStyle;
|