curatorInfo.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // pages/settled/personInfo/personInfo.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. type:2, //策展入驻
  12. mobile:"",
  13. email:"",
  14. address:"",
  15. weixinNo:""
  16. },
  17. rules: {
  18. mobile: {
  19. required: true,
  20. tel:true,
  21. },
  22. address:{
  23. required: true,
  24. },
  25. email: {
  26. required: true,
  27. email:true
  28. },
  29. weixinNo:{
  30. required: true,
  31. }
  32. },
  33. messages: {
  34. mobile: {
  35. required: '请输入手机号',
  36. tel:"请输入正确的手机号"
  37. },
  38. email: {
  39. required: '请输入邮箱地址',
  40. email:'请输入邮箱地址'
  41. },
  42. address:{
  43. required: '请输入地址',
  44. },
  45. weixinNo:{
  46. required: '请输入微信号',
  47. }
  48. }
  49. },
  50. /**
  51. * 生命周期函数--监听页面加载
  52. */
  53. onLoad: function (options) {
  54. const { rules, messages } = this.data;
  55. this.WxValidate = new WxValidate(rules, messages);
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady: function () {
  61. const { rules, messages } = this.data;
  62. this.WxValidate = new WxValidate(rules, messages);
  63. },
  64. /**
  65. * 生命周期函数--监听页面显示
  66. */
  67. onShow: function () {
  68. },
  69. saveData() {
  70. const {formData} = this.data;
  71. // 传入表单数据,调用验证方法
  72. if (!this.WxValidate.checkForm(formData)) {
  73. const error = this.WxValidate.errorList[0];
  74. wx.showToast({
  75. title: error.msg,
  76. icon: 'none',
  77. duration: 2000
  78. })
  79. return false
  80. }
  81. console.log(this.WxValidate);
  82. app.post(api.addPersonalDetails, formData).then(res => {
  83. console.log(res);
  84. wx.redirectTo({
  85. url:"/pages/user/success/success",
  86. })
  87. /* wx.redirectTo({
  88. url:"/pages/invoice/contract/contract"
  89. })*/
  90. });
  91. },
  92. changeInput(e){
  93. console.log(e);
  94. const id = e.currentTarget.id;
  95. const value = e.detail.value;
  96. this.setData({
  97. [id]: value
  98. });
  99. },
  100. /**
  101. * 生命周期函数--监听页面隐藏
  102. */
  103. onHide: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面卸载
  107. */
  108. onUnload: function () {
  109. },
  110. /**
  111. * 页面相关事件处理函数--监听用户下拉动作
  112. */
  113. onPullDownRefresh: function () {
  114. },
  115. /**
  116. * 页面上拉触底事件的处理函数
  117. */
  118. onReachBottom: function () {
  119. },
  120. /**
  121. * 用户点击右上角分享
  122. */
  123. onShareAppMessage: function () {
  124. }
  125. })