123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541 |
- // 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: [],
- // 可接受利率范围
- dbindexList1: [{
- name: '0-5%(含)',
- code: '2801'
- },
- {
- name: '5%-7%(含)',
- code: '2802'
- },
- {
- name: '7%-10%(含)',
- code: '2803'
- },
- {
- name: '10%以上',
- code: '2804'
- },
- ],
- dbtext: '请选择',
- 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,
- 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: '',
- })
- },
- // 融资取向显示部分
- 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();
- // 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 () {
- }
- })
|