detail.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. statusList: [
  14. { id: '0', status: '待审中' },
  15. { id: '1', status: '审核通过' },
  16. { id: '-1', status: '审核拒绝' },
  17. ]
  18. },
  19. initValidate() {
  20. const rules = { name: { required: true, }, create_time: { required: true, }, brief: { required: true, }}
  21. // 验证字段的提示信息,若不传则调用默认的信息
  22. const messages = { name: { required: '请输入名称', }, phone: { required: '请输入创建时间', }, brief: { required: '请输入简介', }};
  23. this.WxValidate = new WxValidate(rules, messages)
  24. },
  25. back: function () {
  26. wx.navigateBack({ url: '/pages/group/index' })
  27. },
  28. // 选择检查时间
  29. dateChange: function (e) {
  30. let { value } = e.detail;
  31. this.setData({ 'form.create_time': value })
  32. },
  33. // // 选择状态
  34. // statusChange: function (e) {
  35. // let { value } = e.detail;
  36. // let data = this.data.statusList[value];
  37. // this.setData({ 'form.status_id': data.id })
  38. // this.setData({ 'form.status_name': data.status })
  39. // },
  40. // 取消保存
  41. onReset: function (e) {
  42. this.back()
  43. },
  44. // 提交保存
  45. onSubmit: function (e) {
  46. const params = e.detail.value;
  47. if (!this.WxValidate.checkForm(params)) {
  48. const error = this.WxValidate.errorList[0];
  49. wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
  50. return false
  51. } else {
  52. console.log(params);
  53. wx.showToast({ title: `创建信息成功`, icon: 'success', duration: 2000 })
  54. }
  55. },
  56. /**
  57. * 生命周期函数--监听页面加载
  58. */
  59. onLoad: function (options) {
  60. //验证规则函数
  61. this.initValidate()
  62. const { id } = options;
  63. // 查询信息
  64. if (id) this.search(id);
  65. // 计算高度
  66. this.searchHeight()
  67. },
  68. // 查询信息
  69. search: function (id) {
  70. console.log(id);
  71. },
  72. // 计算高度
  73. searchHeight: function () {
  74. let frameStyle = this.data.frameStyle;
  75. let client = app.globalData.client;
  76. // 减去状态栏
  77. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  78. // 是否减去底部菜单
  79. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  80. if (infoHeight) this.setData({ infoHeight: infoHeight })
  81. },
  82. /**
  83. * 生命周期函数--监听页面初次渲染完成
  84. */
  85. onReady: function () {
  86. },
  87. /**
  88. * 生命周期函数--监听页面显示
  89. */
  90. onShow: function () {
  91. },
  92. /**
  93. * 生命周期函数--监听页面隐藏
  94. */
  95. onHide: function () {
  96. },
  97. /**
  98. * 生命周期函数--监听页面卸载
  99. */
  100. onUnload: function () {
  101. },
  102. /**
  103. * 页面相关事件处理函数--监听用户下拉动作
  104. */
  105. onPullDownRefresh: function () {
  106. },
  107. /**
  108. * 页面上拉触底事件的处理函数
  109. */
  110. onReachBottom: function () {
  111. },
  112. /**
  113. * 用户点击右上角分享
  114. */
  115. onShareAppMessage: function () {
  116. }
  117. })