submitinfo.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. // pages/mine/wxml/submitinfo/submitinfo.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. AuctionCompanies:["请选择公司","公司1","公司2","公司3","公司4","未加入公司"],
  8. pickerIndex:0,
  9. userNameCheck:false,
  10. userIdcardCheck:false,
  11. userPhoneCheck:false,
  12. pickerCheck:false,
  13. frontPhoto:"images/IDfront.png",
  14. backPhoto:"images/IDback.png",
  15. completePhoto:"images/complete.png",
  16. buttonInfo:true,
  17. checkInfo:false,
  18. frontPhotoInfo:false,
  19. backPhotoInfo:false,
  20. completePhotoInfo:false,
  21. imgInfo: false,
  22. userName:false,
  23. userIdcard:false,
  24. userPhone:false,
  25. pickerInfo:false
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {
  31. },
  32. /**
  33. * 生命周期函数--监听页面初次渲染完成
  34. */
  35. onReady: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面显示
  39. */
  40. onShow: function () {
  41. },
  42. /**
  43. * 生命周期函数--监听页面隐藏
  44. */
  45. onHide: function () {
  46. },
  47. /**
  48. * 生命周期函数--监听页面卸载
  49. */
  50. onUnload: function () {
  51. },
  52. /**
  53. * 页面相关事件处理函数--监听用户下拉动作
  54. */
  55. onPullDownRefresh: function () {
  56. },
  57. /**
  58. * 页面上拉触底事件的处理函数
  59. */
  60. onReachBottom: function () {
  61. },
  62. formSubmit: function(e){
  63. e.detail.value.AuctionCompanies = this.data.AuctionCompanies[e.detail.value.AuctionCompanies];
  64. let formData = e.detail.value
  65. formData.frontPhotoUrl = this.data.frontPhoto[0];
  66. formData.backPhotoUrl = this.data.backPhoto[0];
  67. formData.completePhotoUrl = this.data.completePhoto[0];
  68. console.log(formData);
  69. },
  70. onCheck:function(e) {
  71. let myreg = "";
  72. let info = false;
  73. let checkInfo = true;
  74. let userName, userIdcard, userPhone;
  75. let _this = this;
  76. if (e.currentTarget.id == "user-name"){
  77. myreg = /^[\u4e00-\u9fa5]+(·[\u4e00-\u9fa5]+)*$/;
  78. if (!myreg.test(e.detail.value)) {
  79. info = true;
  80. userName = false;
  81. } else { userName = true}
  82. _this.setData({
  83. userNameCheck: info,
  84. userName: userName
  85. })
  86. } else if (e.currentTarget.id == "user-idcard"){
  87. myreg = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|[xX])$/;
  88. if (!myreg.test(e.detail.value)) {
  89. info = true;
  90. userIdcard = false;
  91. } else { userIdcard = true}
  92. _this.setData({
  93. userIdcardCheck: info,
  94. userIdcard: userIdcard
  95. })
  96. } else if (e.currentTarget.id == "user-phone"){
  97. myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
  98. if (!myreg.test(e.detail.value)) {
  99. info = true;
  100. userPhone = false;
  101. } else { userPhone = true}
  102. _this.setData({
  103. userPhoneCheck: info,
  104. userPhone: userPhone
  105. })
  106. };
  107. if (_this.data.userName && _this.data.userIdcard && _this.data.userPhone) {
  108. checkInfo = true;
  109. _this.setData({
  110. checkInfo: checkInfo
  111. });
  112. }else{
  113. checkInfo = false;
  114. _this.setData({
  115. checkInfo: checkInfo
  116. });
  117. }
  118. _this.buttonClickState(_this.data.checkInfo, _this.data.imgInfo, _this.data.pickerInfo);
  119. },
  120. onSelectPhoto:function(e){
  121. let _this = this;
  122. let imgInfo = false;
  123. let frontPhotoInfo, backPhotoInfo, completePhotoInfo;
  124. wx.chooseImage({
  125. count:1,
  126. success:function(res){
  127. if (e.currentTarget.dataset.btnname == "front"){
  128. frontPhotoInfo = true;
  129. _this.setData({
  130. frontPhoto: res.tempFilePaths,
  131. frontPhotoInfo: frontPhotoInfo
  132. })
  133. } else if (e.currentTarget.dataset.btnname == "back"){
  134. backPhotoInfo = true;
  135. _this.setData({
  136. backPhoto: res.tempFilePaths,
  137. backPhotoInfo: backPhotoInfo
  138. })
  139. } else if (e.currentTarget.dataset.btnname == "complete"){
  140. completePhotoInfo = true;
  141. _this.setData({
  142. completePhoto: res.tempFilePaths,
  143. completePhotoInfo: completePhotoInfo
  144. })
  145. }
  146. if (_this.data.frontPhotoInfo && _this.data.backPhotoInfo && _this.data.completePhotoInfo) {
  147. _this.setData({
  148. imgInfo: true
  149. })
  150. }
  151. _this.buttonClickState(_this.data.checkInfo, _this.data.imgInfo,_this.data.pickerInfo);
  152. }
  153. });
  154. },
  155. buttonClickState:function(checkInfo,imgInfo,pickerInfo){
  156. //console.log(checkInfo, imgInfo, pickerInfo)
  157. let _this = this;
  158. if(checkInfo && imgInfo && pickerInfo){
  159. _this.setData({
  160. buttonInfo : false
  161. })
  162. }else{
  163. _this.setData({
  164. buttonInfo:  true
  165. })
  166. }
  167. },
  168. bindPickerChange: function (e) {
  169. let _this = this;
  170. if (this.data.AuctionCompanies[e.detail.value] == "请选择公司"){
  171. //console.log("请选择拍卖公司");
  172. _this.setData({
  173. pickerInfo: false,
  174. pickerCheck:true
  175. })
  176. }else{
  177. _this.setData({
  178. pickerInfo: true,
  179. pickerCheck: false
  180. })
  181. }
  182. this.setData({
  183. pickerIndex: e.detail.value
  184. })
  185. _this.buttonClickState(_this.data.checkInfo, _this.data.imgInfo, _this.data.pickerInfo);
  186. },
  187. });