123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- // 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,
- warehouseContent: '点击选择', //输入框显示的内容
- // 担保
- dbindexList: [],
- dbtext: '请选择',
- dbindex: null,
- // 需求
- yjrzxqList: [],
- xqtext: '请选择',
- xqindex: null,
- show: false,
- endInfo: {
- // "bank_name": '中国建设银行'
- },
- // 融资取向
- rzqxList: [],
- // 融资取向显示
- rzqxLists: [],
- company:'',
- person:'',
- phone:''
- },
- // 担保
- dbindexListChange: function (e) {
- console.log('dbindexListChange发送选择改变,携带值为', e)
- this.setData({
- dbindex: e.detail.value,
- dbtext: '',
- })
- },
- // 开户行
- yjrzxqListChange: function (e) {
- console.log('yjrzxqListChange发送选择改变,携带值为', e)
- this.setData({
- xqindex: e.detail.value,
- xqtext: '',
- })
- },
- // 融资取向显示部分
- async checkboxChange(e) {
- console.log('checkbox发生change事件,携带value值为:', e.detail.value);
- let arr = [];
- console.log('e.detail.value', e.detail.value)
- 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){
- console.log("1")
- nameArr.push(dayu);
- nameArr.push(name1)
- // let name1 = {
- // name: '>'+ res.data.data[0].name
- // }
- // nameArr.push(name1)
- } else{
- console.log("2")
- 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
- });
- },
- async formSubmit(e) {
- let user = wx.getStorageSync('user')
- e.detail.value.uid = user._id;
- console.log('form发生了submit事件,携带数据为:', e.detail.value);
- let list = await request.query({
- url: 'api/financial/intelligentDocking/intelligentDocking',
- data: e.detail.value,
- method: 'post'
- });
- console.log('bank', list)
- if (list.data.errmsg == 'ok') {
- // let one = await request.query({
- // url: 'api/financial/intelligentDocking/dockingSearch',
- // data: {
- // uid: user._id,
- // status:'0'
- // },
- // method: 'post'
- // });
- // console.log('one',one)
- // if (one.data.result.length) {
- this.setData({
- // endInfo: {
- // bank_name: one.data.result[0].institution.name
- // },
- show: true
- });
- // }
- } else {
- wx.showToast({
- title: list.data.details ? list.data.details : list.data.errmsg,
- icon: 'none',
- duration: 2000
- })
- }
- },
- 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')
- console.log('user', user._id)
- wx.request({
- method: "post",
- url: app.globalData.publicUrl + 'api/financial/intelligentDocking/dockingSearch',
- data: {
- uid: user._id,
- status:'0'
- },
- success: (e) => {
- console.log('success', e);
- if (e.data.errcode == 0) {
- if (e.data.result.length > 0) {
- 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')
- console.log('user',user._id)
- wx.request({
- method:"get",
- url: app.globalData.publicUrl + 'api/financial/companyidentify',
- data: {uid:user._id,status:'1'},
- success:(e) => {
- console.log('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();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- let user = wx.getStorageSync('user')
- if (user) {
- this.renzheng();
- } else {
- wx.showModal({
- title: '',
- content: '您当前没有登录!',
- showCancel: false,
- confirmText: '去登录',
- success: function (res) {
- if (res.confirm) {
- wx.redirectTo({
- url: '/pages/login/index'
- })
- }
- }
- })
- }
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|