index.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. const app = getApp()
  2. import WxValidate from '../../utils/WxValidate';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. nvabarData: {
  9. showCapsule: 0,
  10. showBack: 1,
  11. title: '贷款产品',
  12. height: app.globalData.height * 2 + 20,
  13. },
  14. loanDetail: {},
  15. rateValue: 5,
  16. pid: '',
  17. money: '', //融资金额:
  18. use: '', //融资用途:
  19. warehouseContent: '', //融资方式
  20. claims_min_term: '', //期望融资期限:
  21. claims_max_term: '', //期望融资期限:
  22. mongey_min_rate: '', //期望利率范围:
  23. mongey_max_rate: '', //期望利率范围:
  24. remarks: '', //补充信息:
  25. yhname: '', // 银行名字
  26. show: true,
  27. text: '请选择',
  28. warehouseContent: '点击选择', //输入框显示的内容
  29. index: null,
  30. objectArray: [{
  31. name: '保证',
  32. code: '2201'
  33. },
  34. {
  35. name: '抵押',
  36. code: '2202'
  37. },
  38. {
  39. name: '质押',
  40. code: '2203'
  41. },
  42. ],
  43. finalpic: '',
  44. finalcomtitle: '',
  45. finalnum: '',
  46. jg_id: '',
  47. jg_pro_id: '',
  48. finalecode: '',
  49. ensure_id: '', //融资方式code
  50. isButtonClick: false
  51. },
  52. loadDetail: function () {
  53. console.log(this.data.pid);
  54. },
  55. bindPickerChange: function (e) {
  56. console.log('picker发送选择改变,携带值为', e)
  57. this.setData({
  58. index: e.detail.value,
  59. text: '',
  60. })
  61. },
  62. /**
  63. * 生命周期函数--监听页面加载
  64. */
  65. onLoad: function (options) {
  66. this.initValidate();
  67. this.setData({
  68. finalpic: options.img,
  69. finalcomtitle: wx.getStorageSync('user').company_name,
  70. finalnum: options.num,
  71. jg_id: options.uid,
  72. jg_pro_id: options.id,
  73. finalecode: options.ecode,
  74. yhname: options.name
  75. });
  76. this.loadDetail();
  77. },
  78. initValidate() {
  79. const rules = {
  80. money: {
  81. required: true,
  82. number: true,
  83. },
  84. use: {
  85. required: true,
  86. },
  87. // claims_min_term: {
  88. // required: true,
  89. // number: true,
  90. // },
  91. // claims_max_term: {
  92. // required: true,
  93. // number: true,
  94. // },
  95. // mongey_min_rate: {
  96. // required: true,
  97. // number: true,
  98. // },
  99. // mongey_max_rate: {
  100. // required: true,
  101. // number: true,
  102. // },
  103. };
  104. const messages = {
  105. money: {
  106. required: '请输入融资金额',
  107. number: '请输入融资金额有效数字',
  108. },
  109. use: {
  110. required: '请输入融资用途',
  111. },
  112. claims_min_term: {
  113. required: '请输入期望融资期限最小值',
  114. number: '请输入期望融资期限最小值有效数字',
  115. },
  116. claims_max_term: {
  117. required: '请输入期望融资期限最大值有效数字',
  118. },
  119. mongey_min_rate: {
  120. required: '请输入期望利率最小值有效数字',
  121. },
  122. mongey_max_rate: {
  123. required: '请输入期望利率最大值有效数字',
  124. },
  125. };
  126. // 创建实例对象
  127. this.WxValidate = new WxValidate(rules, messages)
  128. },
  129. submitForm(e) {
  130. /***4-3(表单提交校验)*/
  131. const params = e.detail.value
  132. const id = e.detail.target.dataset.id
  133. const claims_max_money = e.detail.target.dataset.claims_max_money
  134. if (!this.WxValidate.checkForm(params)) {
  135. const error = this.WxValidate.errorList[0]
  136. this.showModal(error)
  137. return false
  138. }
  139. /*** 这里添写验证成功以后的逻辑**/
  140. //验证通过以后->
  141. this.submitInfo(params, claims_max_money);
  142. },
  143. // form提交
  144. submitInfo(params, claims_max_money) {
  145. var that = this;
  146. if (this.data.isButtonClick) {
  147. return;
  148. }
  149. this.data.isButtonClick = true;
  150. let form = params;
  151. form.ensure_id = this.data.ensure_id;
  152. form.jg_id = this.data.jg_id;
  153. form.jg_pro_id = this.data.jg_pro_id;
  154. form.userid = wx.getStorageSync('user')._id;
  155. let user = wx.getStorageSync('user');
  156. let yhname = this.data.loanDetail.name;
  157. console.log(user, "用户sss")
  158. console.log(this.data.loanDetail.name, "银行名字")
  159. console.log('89898898998988998', claims_max_money);
  160. wx.showModal({
  161. title: '提示',
  162. content: '请确认您是否符合该产品相关信息,我们将为您对接金融机构。',
  163. success(res) {
  164. if (res.confirm) {
  165. console.log("wenti1")
  166. that.setData({
  167. remarks: form.remarks
  168. })
  169. that.toclamneed(form, claims_max_money);
  170. } else if (res.cancel) {
  171. console.log('用户点击取消')
  172. }
  173. },
  174. complete: function () {
  175. that.data.isButtonClick = false;
  176. }
  177. })
  178. },
  179. showModal(error) {
  180. wx.showModal({
  181. content: error.msg,
  182. showCancel: false,
  183. })
  184. },
  185. toclamneed(finaldata, claims_max_money) {
  186. console.log(claims_max_money,'00000');
  187. if (finaldata.money <= claims_max_money) {
  188. var that = this;
  189. wx.request({
  190. method: "POST",
  191. url: app.globalData.publicUrl + 'api/financial/claimneed',
  192. data: finaldata,
  193. success: (res) => {
  194. console.log(res, "测试")
  195. if (res.data.errcode == 0) {
  196. //希望跳转过去的页面
  197. that.addclamtviews(res.data.data.id, res, finaldata);
  198. } else {
  199. wx.showModal({
  200. title: '提示',
  201. content: '申请失败,请您核实是否符合该产品相关信息',
  202. })
  203. }
  204. }
  205. })
  206. } else {
  207. wx.showModal({
  208. title: '提示',
  209. content: '申请失败,请您核实是否符合该产品相关信息',
  210. })
  211. }
  212. },
  213. addclamtviews(id, res, finaldata,claims_max_money) {
  214. console.log(id, res, "id传值后台 ...............................接口")
  215. console.log(finaldata, " aaaaaaaaaaaaaaaaaaaa")
  216. console.log(claims_max_money, "565656")
  217. wx.request({
  218. method: "POST",
  219. url: app.globalData.publicUrl + 'api/financial/claimneed/addclamtviews',
  220. data: {
  221. id: id
  222. },
  223. success: (a) => {
  224. wx.redirectTo({
  225. url: '/pages/loanDetailapplysuccess/index?id=' + res.data.data._id + '&img=' + this.data.finalpic + '&num=' + this.data.finalnum + '&ecode=' + this.data.finalecode + '&proid=' + this.data.jg_pro_id + '&remarks=' + this.data.remarks
  226. })
  227. }
  228. })
  229. },
  230. /**
  231. * 生命周期函数--监听页面显示
  232. */
  233. onShow: function () {
  234. let finalid = this.data.jg_pro_id;
  235. wx.request({
  236. method: "get",
  237. url: app.globalData.publicUrl + 'api/financial/financeclaims/' + finalid,
  238. success: (res) => {
  239. if (res.data.errcode == 0) {
  240. this.setData({
  241. loanDetail: res.data.data,
  242. ensure_id: res.data.data.ensure_id,
  243. })
  244. console.log(this.data.loanDetail, "撒旦撒旦撒多撒大所sssssssss多")
  245. }
  246. }
  247. })
  248. },
  249. })