applyDistCon.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. var http = require("../../utils/http.js");
  2. var util = require("../../utils/util.js");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. identityCardNumber: "",
  9. identityCardPicBack: "",
  10. identityCardPicFront: "",
  11. identityCardPicHold: "",
  12. _identityCardPicBack: "",
  13. _identityCardPicFront: "",
  14. _identityCardPicHold: "",
  15. realName: "",
  16. sharerCardNo: "",
  17. // shopId: 1,
  18. userMobile: "",
  19. needIdCardNo: false,
  20. neddIdCardPic: false,
  21. needRealName: false,
  22. distributionCardNo: ""
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. console.log(options)
  29. wx.showLoading();
  30. var params = {
  31. url: "/p/distribution/register/condition",
  32. method: "GET",
  33. callBack: (res) => {
  34. console.log(res)
  35. this.setData({
  36. needIdCardNo: res.identityCardNumber,
  37. neddIdCardPic: res.identityCardPic,
  38. needRealName: res.realName
  39. })
  40. wx.hideLoading();
  41. }
  42. };
  43. http.request(params);
  44. if (options.scene) {
  45. const scene = decodeURIComponent(options.scene);
  46. this.setData({
  47. distributionCardNo: scene
  48. });
  49. }
  50. },
  51. onMobileInput: function (e) {
  52. this.setData({
  53. userMobile: e.detail.value
  54. });
  55. },
  56. onRealNameInput: function (e) {
  57. this.setData({
  58. realName: e.detail.value
  59. });
  60. },
  61. onIdCardNoInput: function (e) {
  62. this.setData({
  63. identityCardNumber: e.detail.value
  64. });
  65. },
  66. uploadIdCardFront: function () {
  67. var ths = this;
  68. wx.chooseImage({
  69. count: 1, // 默认9
  70. sizeType: ['compressed'],
  71. sourceType: ['album', 'camera'],
  72. success: function (res) {
  73. var tempFilePaths = res.tempFilePaths;
  74. wx.showLoading({
  75. mask: true
  76. })
  77. var params = {
  78. url: "/p/file/upload",
  79. filePath: tempFilePaths[0],
  80. name: 'file',
  81. callBack: function (res2) {
  82. wx.hideLoading();
  83. ths.setData({
  84. _identityCardPicFront: JSON.parse(res2).resourcesUrl + JSON.parse(res2).filePath,
  85. identityCardPicFront: JSON.parse(res2).filePath
  86. })
  87. }
  88. };
  89. http.upload(params);
  90. }
  91. })
  92. },
  93. uploadIdCardBack: function () {
  94. var ths = this;
  95. wx.chooseImage({
  96. count: 1, // 默认9
  97. sizeType: ['compressed'],
  98. sourceType: ['album', 'camera'],
  99. success: function (res) {
  100. var tempFilePaths = res.tempFilePaths;
  101. wx.showLoading({
  102. mask: true
  103. })
  104. var params = {
  105. url: "/p/file/upload",
  106. filePath: tempFilePaths[0],
  107. name: 'file',
  108. callBack: function (res2) {
  109. wx.hideLoading();
  110. ths.setData({
  111. _identityCardPicBack: JSON.parse(res2).resourcesUrl + JSON.parse(res2).filePath,
  112. identityCardPicBack: JSON.parse(res2).filePath
  113. })
  114. }
  115. };
  116. http.upload(params);
  117. }
  118. })
  119. },
  120. uploadIdCardHold: function () {
  121. var ths = this;
  122. wx.chooseImage({
  123. count: 1, // 默认9
  124. sizeType: ['compressed'],
  125. sourceType: ['album', 'camera'],
  126. success: function (res) {
  127. var tempFilePaths = res.tempFilePaths;
  128. wx.showLoading({
  129. mask: true
  130. })
  131. var params = {
  132. url: "/p/file/upload",
  133. filePath: tempFilePaths[0],
  134. name: 'file',
  135. callBack: function (res2) {
  136. wx.hideLoading();
  137. ths.setData({
  138. _identityCardPicHold: JSON.parse(res2).resourcesUrl + JSON.parse(res2).filePath,
  139. identityCardPicHold: JSON.parse(res2).filePath
  140. })
  141. }
  142. };
  143. http.upload(params);
  144. }
  145. })
  146. },
  147. /**
  148. * 提交申请
  149. */
  150. submitDisterApply: function () {
  151. var identityCardNumber = this.data.identityCardNumber;
  152. var identityCardPicBack = this.data.identityCardPicBack;
  153. var identityCardPicFront = this.data.identityCardPicFront;
  154. var identityCardPicHold = this.data.identityCardPicHold;
  155. var distributionCardNo = this.data.distributionCardNo;
  156. var realName = this.data.realName;
  157. var userMobile = this.data.userMobile;
  158. var needIdCardNo = this.data.needIdCardNo;
  159. var neddIdCardPic = this.data.neddIdCardPic;
  160. var needRealName = this.data.needRealName;
  161. if (!util.checkPhoneNumber(this.data.userMobile)) {
  162. wx.showToast({
  163. title: '请输入正确的手机号码',
  164. icon: "none"
  165. })
  166. } else if (needRealName && realName.length < 2) {
  167. wx.showToast({
  168. title: '请输入真实姓名',
  169. icon: "none"
  170. })
  171. } else if (needIdCardNo && identityCardNumber.length < 15) {
  172. wx.showToast({
  173. title: '请输入正确的身份证号码',
  174. icon: "none"
  175. })
  176. } else if (neddIdCardPic && identityCardPicFront == "") {
  177. wx.showToast({
  178. title: '请上传身份证人像面',
  179. icon: "none"
  180. })
  181. } else if (neddIdCardPic && identityCardPicBack == "") {
  182. wx.showToast({
  183. title: '请上传身份证国徽面',
  184. icon: "none"
  185. })
  186. } else if (neddIdCardPic && identityCardPicHold == "") {
  187. wx.showToast({
  188. title: '请上传手持身份证照片',
  189. icon: "none"
  190. })
  191. } else {
  192. wx.showLoading({
  193. mask: true
  194. })
  195. var params = {
  196. url: "/p/distribution/register/addDistributionUser",
  197. method: "post",
  198. data: {
  199. identityCardNumber: identityCardNumber,
  200. identityCardPicBack: identityCardPicBack,
  201. identityCardPicFront: identityCardPicFront,
  202. identityCardPicHold: identityCardPicHold,
  203. realName: realName,
  204. sharerCardNo: distributionCardNo,
  205. // shopId: 1,
  206. userMobile: userMobile,
  207. },
  208. callBack: (res) => {
  209. wx.hideLoading();
  210. wx.showModal({
  211. content: '申请已提交,请等待审核',
  212. showCancel: false,
  213. complete: function () {
  214. wx.switchTab({
  215. url: '/pages/user/user',
  216. })
  217. }
  218. })
  219. }
  220. };
  221. http.request(params);
  222. }
  223. },
  224. })