// pages/search/index.js const request = require('../../utils/request.js'); const app = getApp() Page({ /** * 页面的初始数据 */ data: { nvabarData: { showCapsule: 1, //是否显示左上角图标,消息中心 1表示显示 0表示不显示 showBack: 0, //返回 title: '首贷融资', //导航栏 中间的标题 // 此页面 页面内容距最顶部的距离 height: app.globalData.height * 2 + 20, }, active: 1, icon: { normal: '/pages/images/home.png', active: '/pages/images/home_fill.png', bankNormal: '/pages/images/duijie.png', bankActive: '/pages/images/duijie_fill.png', marketNormal: '/pages/images/recharge.png', marketActive: '/pages/images/recharge_fill.png', policyNormal: '/pages/images/news_hot.png', policyActive: '/pages/images/news_hot_fill.png', myNormal: '/pages/images/people.png', myActive: '/pages/images/people_fill.png' }, warehouseContent: '点击选择', //输入框显示的内容 // 担保 dbindexList: [], //开户行 kaihuList:[], // 可接受利率范围 dbindexList1: [{ name: '0-5%(含)', code: '2801' }, { name: '5%-7%(含)', code: '2802' }, { name: '7%-10%(含)', code: '2803' }, { name: '10%以上', code: '2804' }, ], dbtext: '请选择', kaihutext:'请选择', dbindex: null, // 地区 yjrzxqList: [ { name: '长春市', code: '220100' }, { name: '吉林市', code: '220200' }, { name: '四平市', code: '220300' }, { name: '辽源市', code: '220400' }, { name: '通化市', code: '220500' }, { name: '白山市', code: '220600' }, { name: '松原市', code: '220700' }, { name: '白城市', code: '220800' }, { name: '延边朝鲜族自治州', code: '222400' }, ], xqtext: '请选择', dbtext1: '请选择', xqindex: null, kaihuindex: null, show: false, endInfo: { // "bank_name": '中国建设银行' }, // 融资取向 rzqxList: [], // 融资取向显示 rzqxLists: [], company: '', person: '', phone: '', opening_bank: '', isButtonClick: false }, // 担保 dbindexListChange: function (e) { this.setData({ dbindex: e.detail.value, dbtext: '', }) }, // 可接受利率范围 dbindexListChange1: function (e) { this.setData({ dbindex1: e.detail.value, dbtext1: '', }) }, // 地区 yjrzxqListChange: function (e) { this.setData({ xqindex: e.detail.value, xqtext: '', }) }, // 开户行 kaihuListChange: function (e) { this.setData({ kaihuindex: e.detail.value, kaihutext: '', }) }, // 开户行 whenData: function () { wx.request({ method: "get", url: app.globalData.publicUrl + 'api/financial/institution', data: {}, success: (e) => { if (e.data.errcode == 0) { this.setData({ kaihuList: e.data.data, }) } else { wx.showToast({ title: e.data.details ? e.data.details : e.data.errmsg, icon: 'none', duration: 1500 }) } } }) }, // 融资取向显示部分 async checkboxChange(e) { let arr = []; for (const val of e.detail.value) { const arr1 = { code: val } arr.push(arr1) } let nameArr = []; for (const v of arr) { let res = await request.query({ url: 'api/financial/dictionary', data: { code: v.code } }); if (res.data.errcode == 0) { let dayu = { name: '>' } let name1 = { name: res.data.data[0].name } // nameArr.push(name1) if (nameArr.length > 0) { nameArr.push(dayu); nameArr.push(name1) // let name1 = { // name: '>'+ res.data.data[0].name // } // nameArr.push(name1) } else { nameArr.push(name1) // let name2 = { // name:res.data.data[0].name // } // nameArr.push(name2) } } else { wx.showToast({ title: e.data.details ? e.data.details : e.data.errmsg, icon: 'none', duration: 1500 }) } } this.setData({ rzqxLists: nameArr }); }, formSubmit(e) { if (!(/(^[0-9]*$)/.test(e.detail.value.money))) { wx.showModal({ title: '提示', content: '请输入融资需求有效数字', }) } else { if (e.detail.value.money > 5000) { wx.showModal({ title: '提示', content: '申请失败,请您核实是否符合该产品相关信息', }) } else { if (this.data.isButtonClick) { return; } this.data.isButtonClick = true; let user = wx.getStorageSync('user') e.detail.value.uid = user._id; var that = this; wx.showModal({ title: '提示', content: '是否开始对接', success(res) { if (res.confirm) { that.ok(e, user); } else if (res.cancel) { console.log('用户点击取消') } }, complete: function () { that.data.isButtonClick = false } }) } } }, async ok(e, user) { console.log('form表单提交', e.detail.value) wx.showLoading({ title: '加载中', mask: true }) e.detail.value.opening_bank = this.data.opening_bank; let list = await request.query({ url: 'api/financial/intelligentDocking/intelligentDocking', data: e.detail.value, method: 'post' }); wx.hideLoading(); if (list.data.errmsg == 'ok') { this.ok1(user); } else { wx.showToast({ title: list.data.details ? list.data.details : list.data.errmsg, icon: 'none', duration: 2000 }) } }, async ok1(user) { wx.showLoading({ title: '加载中', mask: true }) let one = await request.query({ url: 'api/financial/intelligentDocking/dockingSearch', data: { uid: user._id, status: '0' }, method: 'post' }); if (one.data.result.length) { wx.hideLoading(); this.setData({ endInfo: { bank_name: one.data.result[0].institution.name }, show: true }); } }, onClose() { this.setData({ show: false }); wx.redirectTo({ url: '/pages/home/index' }) }, // 切换菜单 onChange(event) { this.setData({ active: event.detail }); if (event.detail == 0) { wx.redirectTo({ url: '/pages/home/index' }) } else if (event.detail == 1) { wx.redirectTo({ url: '/pages/bank/index' }) } else if (event.detail == 2) { wx.redirectTo({ url: '/pages/market/index' }) } else if (event.detail == 3) { wx.redirectTo({ url: '/pages/policy/index' }) } else if (event.detail == 4) { wx.redirectTo({ url: '/pages/my/index' }) } }, loadData: function () { let user = wx.getStorageSync('user') wx.request({ method: "get", url: app.globalData.publicUrl + 'api/financial/intelligentDocking', data: { uid: user._id, status: '0' }, success: (e) => { if (e.data.errcode == 0) { if (e.data.data.length) { wx.showModal({ title: '提示', content: '您有一个融资需求正在处理,请点击我的-我的融资查看状态', showCancel: false, confirmText: '返回首页', success: function (res) { if (res.confirm) { wx.redirectTo({ url: '/pages/home/index' }) } } }) } } else { wx.showToast({ title: e.data.details ? e.data.details : e.data.errmsg, icon: 'none', duration: 1500 }) } } }) }, // renzheng: function () { // let user = wx.getStorageSync('user') // wx.request({ // method: "get", // url: app.globalData.publicUrl + 'api/financial/companyidentify', // data: { // uid: user._id, // status: '1' // }, // success: (e) => { // if (e.data.data.length) { // // 已认证 // this.setData({ // company: user.company_name, // person: user.person, // phone: user.phone // }) // this.loadData(); // } else { // wx.showModal({ // title: '提示', // content: '您没有进行企业认证,请到我的-我的企业中进行认证', // confirmText: '去认证', // success(res) { // if (res.confirm) { // wx.navigateTo({ // url: '/pages/attestation/index' // }) // } else if (res.cancel) { // wx.redirectTo({ // url: '/pages/home/index' // }) // } // } // }) // } // } // }) // }, // db 担保 dbData: function () { wx.request({ method: "get", url: app.globalData.publicUrl + 'api/financial/dictionary', data: { type: 'db' }, success: (e) => { if (e.data.errcode == 0) { this.setData({ dbindexList: e.data.data, }) } else { wx.showToast({ title: e.data.details ? e.data.details : e.data.errmsg, icon: 'none', duration: 1500 }) } } }) }, // 融资取向 rongziData: function () { wx.request({ method: "get", url: app.globalData.publicUrl + 'api/financial/dictionary', data: { type: 'cpsx' }, success: (e) => { if (e.data.errcode == 0) { this.setData({ rzqxList: e.data.data, }) } else { wx.showToast({ title: e.data.details ? e.data.details : e.data.errmsg, icon: 'none', duration: 1500 }) } } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.dbData(); this.rongziData(); this.whenData(); // const num = this.randomCode(4); // wx.setStorage({ // key: 'num', // data: num, // }) // console.log('随机码',wx.getStorageSync('num')) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { let user = wx.getStorageSync('user') if (user) { // this.renzheng(); if (user.roles == '1') { // 已认证 this.setData({ company: user.company_name, person: user.person, phone: user.phone, opening_bank: user.opening_bank, }) this.loadData(); } else { wx.showModal({ title: '提示', content: '您没有进行企业认证,请到我的-我的企业中进行认证', confirmText: '去认证', success(res) { if (res.confirm) { wx.navigateTo({ url: '/pages/attestation/index' }) } else if (res.cancel) { wx.redirectTo({ url: '/pages/home/index' }) } } }) } } else { wx.showModal({ title: '', content: '您当前没有登录!', showCancel: false, confirmText: '去登录', success: function (res) { if (res.confirm) { wx.redirectTo({ url: '/pages/login/index' }) } } }) } }, // randomCode: function(length) { // const chars = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ]; // let result = ''; // for (let i = 0; i < length; i++) { // const index = Math.ceil(Math.random() * 9); // result += chars[index]; // } // return result; // }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })