addIntroducer.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. // pages/role/addIntroducer.js
  2. const utils = require('../../utils/util')
  3. const form = require('../../utils/formValidation')
  4. const util = require('../../utils/util.js');
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. userInfo:{
  12. realname: '',
  13. telephone: '',
  14. area: '',
  15. password: '000000',
  16. mgvmRole: 2
  17. },
  18. region: [],// 选中的数据
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. },
  25. /**
  26. * 生命周期函数--监听页面初次渲染完成
  27. */
  28. onReady: function () {
  29. },
  30. /**
  31. * 生命周期函数--监听页面显示
  32. */
  33. onShow: function () {
  34. },
  35. /**
  36. * 生命周期函数--监听页面隐藏
  37. */
  38. onHide: function () {
  39. },
  40. /**
  41. * 生命周期函数--监听页面卸载
  42. */
  43. onUnload: function () {
  44. },
  45. /**
  46. * 页面相关事件处理函数--监听用户下拉动作
  47. */
  48. onPullDownRefresh: function () {
  49. },
  50. /**
  51. * 页面上拉触底事件的处理函数
  52. */
  53. onReachBottom: function () {
  54. },
  55. /**
  56. * 用户点击右上角分享
  57. */
  58. onShareAppMessage: function () {
  59. },
  60. formSubmit: function(e) {
  61. //表单规则
  62. let rules = [{
  63. name: "realname",
  64. rule: ["required"], //可使用区间,此处主要测试功能
  65. msg: ["请输入介绍人姓名"]
  66. },{
  67. name: "telephone",
  68. rule: ["required", "isMobile"],
  69. msg: ["请输入电话号码", "请输入正确的手机号"]
  70. },{
  71. name: "area",
  72. rule: ["required"],
  73. msg: ["请选择所在地区"]
  74. }];
  75. //进行表单检查
  76. let formData = e.detail.value;
  77. let checkRes = form.validation(formData, rules);
  78. if (!checkRes) {
  79. // wx.showToast({
  80. // title: "验证通过!",
  81. // icon: "none"
  82. // });
  83. var that = this
  84. console.log("9999")
  85. console.log(that.data.userInfo)
  86. console.log("8888")
  87. util.request(util.api.addRole, that.data.userInfo, "POST", false, true,app.globalData.token).then((res)=>{
  88. if (res.code == 200) {
  89. wx.navigateTo({
  90. url: '/pages/role/introducerList',
  91. })
  92. }
  93. }).catch((res) => {})
  94. } else {
  95. wx.showToast({
  96. title: checkRes,
  97. icon: "none"
  98. });
  99. return;
  100. }
  101. },
  102. formReset: function(e) {
  103. console.log("清空数据")
  104. },
  105. bindRegionChange: function (e) {
  106. console.log(e.detail.value)
  107. console.log(e.detail.code)
  108. this.setData({
  109. region: e.detail.value
  110. })
  111. this.data.userInfo.area = this.data.region.join(" ")
  112. },
  113. // addIntroducer(){
  114. // var that = this
  115. // console.log("9999")
  116. // console.log(that.data.userInfo)
  117. // console.log("8888")
  118. // util.request(util.api.addRole, that.data.userInfo, "POST", false, true,app.globalData.token).then((res)=>{
  119. // if (res.code == 200) {
  120. // wx.navigateTo({
  121. // url: '/pages/role/introducerList',
  122. // })
  123. // }
  124. // }).catch((res) => {})
  125. // },
  126. inputedit: function (e) {
  127. let _this = this;
  128. let dataset = e.currentTarget.dataset;
  129. let value = e.detail.value;
  130. let name = dataset.name;
  131. _this.data[name] = value;
  132. _this.setData({
  133. [name]: _this.data[name]
  134. });
  135. },
  136. })