OfflinePayment.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. // pages/OfflinePayment/OfflinePayment.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. kid: '',
  9. deposit: '',
  10. agree: true,
  11. img:'',
  12. fileid: '',
  13. bidding_agreement_path:'',
  14. bidding_rules_path:'',
  15. },
  16. formSubmit: function(e) {
  17. var _this = this;
  18. var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
  19. var format = /^(([1][1-5])|([2][1-3])|([3][1-7])|([4][1-6])|([5][0-4])|([6][1-5])|([7][1])|([8][1-2]))\d{4}(([1][9]\d{2})|([2]\d{3}))(([0][1-9])|([1][0-2]))(([0][1-9])|([1-2][0-9])|([3][0-1]))\d{3}[0-9xX]$/;
  20. var receive_mobile = e.detail.value.number;
  21. var id_card = e.detail.value.card;
  22. var company_name = e.detail.value.company_name;
  23. if (company_name == '' || company_name == undefined) {
  24. wx.showToast({
  25. title: '公司名称不能为空',
  26. icon: 'none',
  27. duration: 2000
  28. });
  29. } else if (!myreg.test(receive_mobile) || receive_mobile == "" || receive_mobile == undefined) {
  30. wx.showToast({
  31. title: '请输入正确的手机号',
  32. icon: 'none',
  33. duration: 2000
  34. });
  35. } else if (!format.test(id_card) || id_card == "" || id_card == undefined) {
  36. wx.showToast({
  37. title: '请输入正确格式的身份证号',
  38. icon: 'none',
  39. duration: 2000
  40. });
  41. } else if (this.data.agree) {
  42. wx.request({
  43. url: app.globalData.prodUrl + 'web-pm/wx/submit/offline_apply',
  44. data: {
  45. pm_item_id: this.data.kid,
  46. receive_name: e.detail.value.name,
  47. receive_mobile: receive_mobile,
  48. id_card: id_card,
  49. company_name: company_name,
  50. file_id:this.data.fileid,
  51. },
  52. header: {
  53. 'ydw-token': wx.getStorageSync('key').ydw_token
  54. },
  55. method: 'GET',
  56. dataType: 'json',
  57. responseType: 'text',
  58. success: function(res) {
  59. if (res.statusCode == 200) {
  60. wx.navigateBack({})
  61. }
  62. },
  63. fail: function(res) {}
  64. })
  65. } else {
  66. wx.showToast({
  67. title: '请确认同意《用户竞买协议》和《保证金规则》',
  68. icon: 'none',
  69. duration: 3000,
  70. success: function(res) {
  71. }
  72. })
  73. }
  74. },
  75. // 选择图片
  76. selectimg: function () {
  77. const that = this;
  78. wx.chooseImage({
  79. count: 1, // 最多可以选择的图片张数(最大数量-当前已上传数量)
  80. sizeType: ['original', 'compressed'],
  81. sourceType: ['album', 'camera'],
  82. success: function (res) {
  83. that.setData({
  84. img: res.tempFilePaths[0]
  85. });
  86. var imgUrl = res.tempFilePaths[0];
  87. wx.uploadFile({
  88. //上传图片的网路请求地址
  89. url: app.globalData.prodUrl + 'web-cp-all/upload_pm/upload',
  90. //选择
  91. filePath: imgUrl,
  92. name: 'file',
  93. method: "POST",
  94. success: function (res) {
  95. that.setData({
  96. fileid: JSON.parse(res.data).file_id
  97. })
  98. },
  99. fail: function (res) {
  100. wx.showToast({
  101. title: keyurl.message + '请重新上传',
  102. icon: 'none'
  103. })
  104. }
  105. });
  106. },
  107. })
  108. },
  109. // 图片预览
  110. previewImage: function(e) {
  111. var current = e.target.dataset.src
  112. wx.previewImage({
  113. current: current,
  114. urls: this.data.img,
  115. })
  116. },
  117. // 删除图片(选中图片移除)
  118. delImg: function (e) {
  119. const that = this;
  120. that.setData({
  121. img: '',
  122. })
  123. },
  124. // 勾选同意协议事件
  125. checkboxChange: function(e) {
  126. if (e.detail.value[0] === '确认同意') {
  127. this.setData({
  128. agree: true
  129. })
  130. } else {
  131. this.setData({
  132. agree: false
  133. })
  134. }
  135. },
  136. getWeiz: function(e) {
  137. var name = e.target.dataset.name;
  138. var lat = e.target.dataset.lat;
  139. var lng = e.target.dataset.lng;
  140. wx.openLocation({ //​使用微信内置地图查看位置。
  141. name: name,
  142. scale: 28,
  143. address: name
  144. })
  145. },
  146. // 点击事件
  147. openFile(event) { // item为当前点击的事物对象
  148. // 预览网络文档
  149. wx.downloadFile({
  150. url: event.currentTarget.dataset.id, // 文件的本身url
  151. filePath: wx.env.USER_DATA_PATH + '/res' , // 本地自定义的文件名
  152. success: function (res) {
  153. let filePath = res.filePath; // 微信临时文件路径(这里要使用自定义的名字文件名,否则打开的文件名是乱码)
  154. wx.openDocument({
  155. filePath: filePath,
  156. fileType: 'pdf',
  157. success: function () {
  158. },
  159. });
  160. },
  161. });
  162. },
  163. /**
  164. * 生命周期函数--监听页面加载
  165. */
  166. onLoad: function(options) {
  167. this.setData({
  168. kid: options.kid,
  169. deposit: options.deposit,
  170. bidding_agreement_path:options.bidding_agreement_path,
  171. bidding_rules_path:options.bidding_rules_path,
  172. })
  173. },
  174. /**
  175. * 生命周期函数--监听页面初次渲染完成
  176. */
  177. onReady: function() {
  178. },
  179. /**
  180. * 生命周期函数--监听页面显示
  181. */
  182. onShow: function() {
  183. },
  184. /**
  185. * 生命周期函数--监听页面隐藏
  186. */
  187. onHide: function() {
  188. },
  189. /**
  190. * 生命周期函数--监听页面卸载
  191. */
  192. onUnload: function() {
  193. },
  194. /**
  195. * 页面相关事件处理函数--监听用户下拉动作
  196. */
  197. onPullDownRefresh: function() {
  198. },
  199. /**
  200. * 页面上拉触底事件的处理函数
  201. */
  202. onReachBottom: function() {
  203. },
  204. /**
  205. * 用户点击右上角分享
  206. */
  207. onShareAppMessage: function() {
  208. }
  209. })