add.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. const app = getApp()
  2. import WxValidate from '../../../utils/wxValidate';
  3. Page({
  4. data: {
  5. frameStyle: { useTop: true, name: '课程信息', leftArrow: true, useBar: false },
  6. form: {},
  7. },
  8. initValidate() {
  9. const rules = { salary: { required: false } }
  10. // 验证字段的提示信息,若不传则调用默认的信息
  11. const messages = { salary: { required: '请输入提现金额' } };
  12. this.WxValidate = new WxValidate(rules, messages)
  13. },
  14. // 返回
  15. back: function () {
  16. wx.navigateBack({ delta: 1 })
  17. },
  18. //提交
  19. onSubmit: async function (e) {
  20. const that = this;
  21. const params = e.detail.value;
  22. if (!this.WxValidate.checkForm(params)) {
  23. const error = this.WxValidate.errorList[0];
  24. wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
  25. return false
  26. } else {
  27. console.log(params);
  28. // const arr = await app.$post(`/billApply`, params)
  29. // if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
  30. // else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
  31. }
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: async function (options) {
  37. const that = this;
  38. that.setData({ id: options.id || '' })
  39. //验证规则函数
  40. that.initValidate();
  41. // 查询其他信息
  42. await that.searchOther();
  43. // 监听用户是否登录
  44. await that.watchLogin();
  45. },
  46. // 查询其他信息
  47. searchOther: function () {
  48. const that = this;
  49. let arr;
  50. },
  51. // 监听用户是否登录
  52. watchLogin: async function () {
  53. const that = this;
  54. wx.getStorage({
  55. key: 'user',
  56. success: async res => {
  57. let data = res.data;
  58. // 教练与学校的关系
  59. // const school = await app.$get(`/rcs`, { coach_id: form.coach_id });
  60. // if (school.errcode == '0' && school.total > 0) { form.school_id = school.data[0].school_id }
  61. // let form = { coach_id: data.info.id };
  62. // else { wx.showToast({ title: `缺少必要信息`, icon: 'error', duration: 2000 }) };
  63. // that.setData({ form })
  64. },
  65. fail: async res => {
  66. wx.redirectTo({ url: '/pages/index/index' })
  67. }
  68. })
  69. },
  70. /**
  71. * 生命周期函数--监听页面初次渲染完成
  72. */
  73. onReady: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面显示
  77. */
  78. onShow: function () {
  79. },
  80. /**
  81. * 生命周期函数--监听页面隐藏
  82. */
  83. onHide: function () {
  84. },
  85. /**
  86. * 生命周期函数--监听页面卸载
  87. */
  88. onUnload: function () {
  89. },
  90. /**
  91. * 页面相关事件处理函数--监听用户下拉动作
  92. */
  93. onPullDownRefresh: function () {
  94. },
  95. /**
  96. * 页面上拉触底事件的处理函数
  97. */
  98. onReachBottom: function () {
  99. },
  100. /**
  101. * 用户点击右上角分享
  102. */
  103. onShareAppMessage: function () {
  104. }
  105. })