123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- const app = getApp()
- import WxValidate from '../../utils/WxValidate';
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- nvabarData: {
- showCapsule: 0,
- showBack: 1,
- title: '贷款产品',
- height: app.globalData.height * 2 + 20,
- },
- loanDetail: {},
- rateValue: 5,
- pid: '',
- money: '', //融资金额:
- use: '', //融资用途:
- warehouseContent: '', //融资方式
- claims_min_term: '', //期望融资期限:
- claims_max_term: '', //期望融资期限:
- mongey_min_rate: '', //期望利率范围:
- mongey_max_rate: '', //期望利率范围:
- remarks: '', //补充信息:
- yhname: '', // 银行名字
- show: true,
- text: '请选择',
- warehouseContent: '点击选择', //输入框显示的内容
- index: null,
- objectArray: [{
- name: '保证',
- code: '2201'
- },
- {
- name: '抵押',
- code: '2202'
- },
- {
- name: '质押',
- code: '2203'
- },
- ],
- finalpic: '',
- finalcomtitle: '',
- finalnum: '',
- jg_id: '',
- jg_pro_id: '',
- finalecode: '',
- ensure_id: '', //融资方式code
- isButtonClick: false
- },
- loadDetail: function () {
- console.log(this.data.pid);
- },
- bindPickerChange: function (e) {
- console.log('picker发送选择改变,携带值为', e)
- this.setData({
- index: e.detail.value,
- text: '',
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.initValidate();
- this.setData({
- finalpic: options.img,
- finalcomtitle: wx.getStorageSync('user').company_name,
- finalnum: options.num,
- jg_id: options.uid,
- jg_pro_id: options.id,
- finalecode: options.ecode,
- yhname: options.name
- });
- this.loadDetail();
- },
- initValidate() {
- const rules = {
- money: {
- required: true,
- number: true,
- },
- use: {
- required: true,
- },
- // claims_min_term: {
- // required: true,
- // number: true,
- // },
- // claims_max_term: {
- // required: true,
- // number: true,
- // },
- // mongey_min_rate: {
- // required: true,
- // number: true,
- // },
- // mongey_max_rate: {
- // required: true,
- // number: true,
- // },
- };
- const messages = {
- money: {
- required: '请输入融资金额',
- number: '请输入融资金额有效数字',
- },
- use: {
- required: '请输入融资用途',
- },
- claims_min_term: {
- required: '请输入期望融资期限最小值',
- number: '请输入期望融资期限最小值有效数字',
- },
- claims_max_term: {
- required: '请输入期望融资期限最大值有效数字',
- },
- mongey_min_rate: {
- required: '请输入期望利率最小值有效数字',
- },
- mongey_max_rate: {
- required: '请输入期望利率最大值有效数字',
- },
- };
- // 创建实例对象
- this.WxValidate = new WxValidate(rules, messages)
- },
- submitForm(e) {
- /***4-3(表单提交校验)*/
- const params = e.detail.value
- const id = e.detail.target.dataset.id
- const claims_max_money = e.detail.target.dataset.claims_max_money
- if (!this.WxValidate.checkForm(params)) {
- const error = this.WxValidate.errorList[0]
- this.showModal(error)
- return false
- }
- /*** 这里添写验证成功以后的逻辑**/
- //验证通过以后->
- this.submitInfo(params, claims_max_money);
- },
- // form提交
- submitInfo(params, claims_max_money) {
- var that = this;
- if (this.data.isButtonClick) {
- return;
- }
- this.data.isButtonClick = true;
- let form = params;
- form.ensure_id = this.data.ensure_id;
- form.jg_id = this.data.jg_id;
- form.jg_pro_id = this.data.jg_pro_id;
- form.userid = wx.getStorageSync('user')._id;
- let user = wx.getStorageSync('user');
- let yhname = this.data.loanDetail.name;
- console.log(user, "用户sss")
- console.log(this.data.loanDetail.name, "银行名字")
- console.log('89898898998988998', claims_max_money);
- wx.showModal({
- title: '提示',
- content: '请确认您是否符合该产品相关信息,我们将为您对接金融机构。',
- success(res) {
- if (res.confirm) {
- console.log("wenti1")
- that.setData({
- remarks: form.remarks
- })
- that.toclamneed(form, claims_max_money);
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- },
- complete: function () {
- that.data.isButtonClick = false;
- }
- })
- },
- showModal(error) {
- wx.showModal({
- content: error.msg,
- showCancel: false,
- })
- },
- toclamneed(finaldata, claims_max_money) {
- console.log(claims_max_money,'00000');
-
- if (finaldata.money <= claims_max_money) {
- var that = this;
- wx.request({
- method: "POST",
- url: app.globalData.publicUrl + 'api/financial/claimneed',
- data: finaldata,
- success: (res) => {
- console.log(res, "测试")
- if (res.data.errcode == 0) {
- //希望跳转过去的页面
- that.addclamtviews(res.data.data.id, res, finaldata);
- } else {
- wx.showModal({
- title: '提示',
- content: '申请失败,请您核实是否符合该产品相关信息',
- })
- }
- }
- })
- } else {
- wx.showModal({
- title: '提示',
- content: '申请失败,请您核实是否符合该产品相关信息',
- })
- }
- },
- addclamtviews(id, res, finaldata,claims_max_money) {
- console.log(id, res, "id传值后台 ...............................接口")
- console.log(finaldata, " aaaaaaaaaaaaaaaaaaaa")
- console.log(claims_max_money, "565656")
- wx.request({
- method: "POST",
- url: app.globalData.publicUrl + 'api/financial/claimneed/addclamtviews',
- data: {
- id: id
- },
- success: (a) => {
- wx.redirectTo({
- 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
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- let finalid = this.data.jg_pro_id;
- wx.request({
- method: "get",
- url: app.globalData.publicUrl + 'api/financial/financeclaims/' + finalid,
- success: (res) => {
- if (res.data.errcode == 0) {
- this.setData({
- loanDetail: res.data.data,
- ensure_id: res.data.data.ensure_id,
- })
- console.log(this.data.loanDetail, "撒旦撒旦撒多撒大所sssssssss多")
- }
- }
- })
- },
- })
|