detail.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '信息管理', leftArrow: true, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. form: {},
  13. },
  14. initValidate() {
  15. const rules = { name: { required: true, }, phone: { required: true, tel: true }, password: { required: true, }, email: { required: true }, address: { required: true, }, company: { required: true, }, office_phone: { required: true, } }
  16. // 验证字段的提示信息,若不传则调用默认的信息
  17. const messages = { name: { required: '请输入姓名', }, phone: { required: '请输入联系电话', }, password: { required: '请输入密码', }, email: { required: '请输入电子邮箱', }, address: { required: '请输入联系地址', }, company: { required: '请输入工作单位', }, office_phone: { required: '请输入办公电话', } };
  18. this.WxValidate = new WxValidate(rules, messages)
  19. },
  20. back: function () {
  21. wx.navigateBack({ url: '/pages/county/index' })
  22. },
  23. // 取消保存
  24. onReset: function (e) {
  25. this.back()
  26. },
  27. // 提交保存
  28. onSubmit: function (e) {
  29. const params = e.detail.value;
  30. if (!this.WxValidate.checkForm(params)) {
  31. const error = this.WxValidate.errorList[0];
  32. wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
  33. return false
  34. } else {
  35. console.log(params);
  36. wx.showToast({ title: `创建信息成功`, icon: 'success', duration: 2000 })
  37. }
  38. },
  39. /**
  40. * 生命周期函数--监听页面加载
  41. */
  42. onLoad: function (options) {
  43. //验证规则函数
  44. this.initValidate()
  45. const { id } = options;
  46. // 查询信息
  47. if (id) this.search(id);
  48. // 计算高度
  49. this.searchHeight()
  50. },
  51. // 查询信息
  52. search: function (id) {
  53. console.log(id);
  54. },
  55. // 计算高度
  56. searchHeight: function () {
  57. let frameStyle = this.data.frameStyle;
  58. let client = app.globalData.client;
  59. // 减去状态栏
  60. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  61. // 是否减去底部菜单
  62. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  63. if (infoHeight) this.setData({ infoHeight: infoHeight })
  64. },
  65. /**
  66. * 生命周期函数--监听页面初次渲染完成
  67. */
  68. onReady: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面显示
  72. */
  73. onShow: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面隐藏
  77. */
  78. onHide: function () {
  79. },
  80. /**
  81. * 生命周期函数--监听页面卸载
  82. */
  83. onUnload: function () {
  84. },
  85. /**
  86. * 页面相关事件处理函数--监听用户下拉动作
  87. */
  88. onPullDownRefresh: function () {
  89. },
  90. /**
  91. * 页面上拉触底事件的处理函数
  92. */
  93. onReachBottom: function () {
  94. },
  95. /**
  96. * 用户点击右上角分享
  97. */
  98. onShareAppMessage: function () {
  99. }
  100. })