downContract.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // pages/invoice/downContract/downContract.js
  2. const app = getApp();
  3. const api = app.api;
  4. import WxValidate from '../../../utils/WxValidate'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. formData:{
  11. email:""
  12. },
  13. rules: {
  14. email: {
  15. required: true,
  16. email:true
  17. },
  18. },
  19. messages: {
  20. email: {
  21. required: '请输入邮箱'
  22. }
  23. },
  24. isSubmit:false,
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. const { rules, messages } = this.data;
  31. this.WxValidate = new WxValidate(rules, messages);
  32. },
  33. saveData() {
  34. const {formData,isSubmit} = this.data;
  35. // console.log(this.WxValidate.checkForm(formData));
  36. if(isSubmit){
  37. return
  38. }
  39. // 传入表单数据,调用验证方法
  40. if (!this.WxValidate.checkForm(formData)) {
  41. const error = this.WxValidate.errorList[0];
  42. wx.showToast({
  43. title: error.msg,
  44. icon: 'none',
  45. duration: 2000
  46. })
  47. return false
  48. }
  49. this.setData({
  50. isSubmit:true
  51. });
  52. app.post(api.downloadArtistUserInvoice, formData).then(res => {
  53. wx.showToast({
  54. title: '合同模板已发送到邮箱,请查收',
  55. duration: 2000
  56. })
  57. this.setData({
  58. isSubmit:false,
  59. });
  60. wx.navigateBack();
  61. }).catch(()=>{
  62. this.setData({
  63. isSubmit:false
  64. });
  65. })
  66. },
  67. changeInput(e){
  68. console.log(e);
  69. const id = e.currentTarget.id;
  70. const value = e.detail.value;
  71. this.setData({
  72. [id]: value
  73. });
  74. },
  75. backClose(){
  76. wx.navigateBack();
  77. },
  78. /**
  79. * 生命周期函数--监听页面初次渲染完成
  80. */
  81. onReady: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面显示
  85. */
  86. onShow: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面隐藏
  90. */
  91. onHide: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面卸载
  95. */
  96. onUnload: function () {
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh: function () {
  102. },
  103. /**
  104. * 页面上拉触底事件的处理函数
  105. */
  106. onReachBottom: function () {
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage: function () {
  112. }
  113. })