index.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. // pages/search/index.js
  2. const request = require('../../utils/request.js');
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. nvabarData: {
  10. showCapsule: 1, //是否显示左上角图标,消息中心 1表示显示 0表示不显示
  11. showBack: 0, //返回
  12. title: '我要融资', //导航栏 中间的标题
  13. // 此页面 页面内容距最顶部的距离
  14. height: app.globalData.height * 2 + 20,
  15. },
  16. active: 1,
  17. warehouseContent: '点击选择', //输入框显示的内容
  18. // 担保
  19. dbindexList: [],
  20. dbtext: '请选择',
  21. dbindex: null,
  22. // 需求
  23. yjrzxqList: [],
  24. xqtext: '请选择',
  25. xqindex: null,
  26. show: false,
  27. endInfo: {
  28. // "bank_name": '中国建设银行'
  29. },
  30. // 融资取向
  31. rzqxList: [],
  32. // 融资取向显示
  33. rzqxLists: [],
  34. company:'',
  35. person:'',
  36. phone:''
  37. },
  38. // 担保
  39. dbindexListChange: function (e) {
  40. console.log('dbindexListChange发送选择改变,携带值为', e)
  41. this.setData({
  42. dbindex: e.detail.value,
  43. dbtext: '',
  44. })
  45. },
  46. // 开户行
  47. yjrzxqListChange: function (e) {
  48. console.log('yjrzxqListChange发送选择改变,携带值为', e)
  49. this.setData({
  50. xqindex: e.detail.value,
  51. xqtext: '',
  52. })
  53. },
  54. // 融资取向显示部分
  55. async checkboxChange(e) {
  56. console.log('checkbox发生change事件,携带value值为:', e.detail.value);
  57. let arr = [];
  58. console.log('e.detail.value', e.detail.value)
  59. for (const val of e.detail.value) {
  60. const arr1 = {
  61. code: val
  62. }
  63. arr.push(arr1)
  64. }
  65. let nameArr = [];
  66. for (const v of arr) {
  67. let res = await request.query({
  68. url: 'api/financial/dictionary',
  69. data: {
  70. code: v.code
  71. }
  72. });
  73. if (res.data.errcode == 0) {
  74. let dayu = {
  75. name:'>'
  76. }
  77. let name1 = {
  78. name:res.data.data[0].name
  79. }
  80. // nameArr.push(name1)
  81. if(nameArr.length > 0){
  82. console.log("1")
  83. nameArr.push(dayu);
  84. nameArr.push(name1)
  85. // let name1 = {
  86. // name: '>'+ res.data.data[0].name
  87. // }
  88. // nameArr.push(name1)
  89. } else{
  90. console.log("2")
  91. nameArr.push(name1)
  92. // let name2 = {
  93. // name:res.data.data[0].name
  94. // }
  95. // nameArr.push(name2)
  96. }
  97. } else {
  98. wx.showToast({
  99. title: e.data.details ? e.data.details : e.data.errmsg,
  100. icon: 'none',
  101. duration: 1500
  102. })
  103. }
  104. }
  105. this.setData({
  106. rzqxLists: nameArr
  107. });
  108. },
  109. async formSubmit(e) {
  110. let user = wx.getStorageSync('user')
  111. e.detail.value.uid = user._id;
  112. console.log('form发生了submit事件,携带数据为:', e.detail.value);
  113. let list = await request.query({
  114. url: 'api/financial/intelligentDocking/intelligentDocking',
  115. data: e.detail.value,
  116. method: 'post'
  117. });
  118. console.log('bank', list)
  119. if (list.data.errmsg == 'ok') {
  120. // let one = await request.query({
  121. // url: 'api/financial/intelligentDocking/dockingSearch',
  122. // data: {
  123. // uid: user._id,
  124. // status:'0'
  125. // },
  126. // method: 'post'
  127. // });
  128. // console.log('one',one)
  129. // if (one.data.result.length) {
  130. this.setData({
  131. // endInfo: {
  132. // bank_name: one.data.result[0].institution.name
  133. // },
  134. show: true
  135. });
  136. // }
  137. } else {
  138. wx.showToast({
  139. title: list.data.details ? list.data.details : list.data.errmsg,
  140. icon: 'none',
  141. duration: 2000
  142. })
  143. }
  144. },
  145. onClose() {
  146. this.setData({
  147. show: false
  148. });
  149. wx.redirectTo({
  150. url: '/pages/home/index'
  151. })
  152. },
  153. // 切换菜单
  154. onChange(event) {
  155. this.setData({
  156. active: event.detail
  157. });
  158. if (event.detail == 0) {
  159. wx.redirectTo({
  160. url: '/pages/home/index'
  161. })
  162. } else if (event.detail == 1) {
  163. wx.redirectTo({
  164. url: '/pages/bank/index'
  165. })
  166. } else if (event.detail == 2) {
  167. wx.redirectTo({
  168. url: '/pages/market/index'
  169. })
  170. } else if (event.detail == 3) {
  171. wx.redirectTo({
  172. url: '/pages/policy/index'
  173. })
  174. } else if (event.detail == 4) {
  175. wx.redirectTo({
  176. url: '/pages/my/index'
  177. })
  178. }
  179. },
  180. loadData: function () {
  181. let user = wx.getStorageSync('user')
  182. console.log('user', user._id)
  183. wx.request({
  184. method: "post",
  185. url: app.globalData.publicUrl + 'api/financial/intelligentDocking/dockingSearch',
  186. data: {
  187. uid: user._id,
  188. status:'0'
  189. },
  190. success: (e) => {
  191. console.log('success', e);
  192. if (e.data.errcode == 0) {
  193. if (e.data.result.length > 0) {
  194. wx.showModal({
  195. title: '警告',
  196. content: '您已有一个正在进行中的需求,请勿重复提交!',
  197. showCancel: false,
  198. confirmText: '返回首页',
  199. success: function (res) {
  200. if (res.confirm) {
  201. wx.redirectTo({
  202. url: '/pages/home/index'
  203. })
  204. }
  205. }
  206. })
  207. }
  208. } else {
  209. wx.showToast({
  210. title: e.data.details ? e.data.details : e.data.errmsg,
  211. icon: 'none',
  212. duration: 1500
  213. })
  214. }
  215. }
  216. })
  217. },
  218. renzheng: function () {
  219. let user = wx.getStorageSync('user')
  220. console.log('user',user._id)
  221. wx.request({
  222. method:"get",
  223. url: app.globalData.publicUrl + 'api/financial/companyidentify',
  224. data: {uid:user._id,status:'1'},
  225. success:(e) => {
  226. console.log('success',e);
  227. if(e.data.data.length){
  228. // 已认证
  229. this.setData({
  230. company:user.company_name,
  231. person:user.person,
  232. phone:user.phone
  233. })
  234. this.loadData();
  235. } else {
  236. wx.showModal({
  237. title: '警告',
  238. content: '您当前没有认证!',
  239. confirmText: '去认证',
  240. success(res) {
  241. if (res.confirm) {
  242. wx.navigateTo({
  243. url: '/pages/attestation/index'
  244. })
  245. } else if (res.cancel) {
  246. wx.redirectTo({
  247. url: '/pages/home/index'
  248. })
  249. }
  250. }
  251. })
  252. }
  253. }
  254. })
  255. },
  256. // db 担保
  257. dbData: function () {
  258. wx.request({
  259. method: "get",
  260. url: app.globalData.publicUrl + 'api/financial/dictionary',
  261. data: {
  262. type: 'db'
  263. },
  264. success: (e) => {
  265. if (e.data.errcode == 0) {
  266. this.setData({
  267. dbindexList: e.data.data,
  268. })
  269. } else {
  270. wx.showToast({
  271. title: e.data.details ? e.data.details : e.data.errmsg,
  272. icon: 'none',
  273. duration: 1500
  274. })
  275. }
  276. }
  277. })
  278. },
  279. // 融资取向
  280. rongziData: function () {
  281. wx.request({
  282. method: "get",
  283. url: app.globalData.publicUrl + 'api/financial/dictionary',
  284. data: {
  285. type: 'cpsx'
  286. },
  287. success: (e) => {
  288. if (e.data.errcode == 0) {
  289. this.setData({
  290. rzqxList: e.data.data,
  291. })
  292. } else {
  293. wx.showToast({
  294. title: e.data.details ? e.data.details : e.data.errmsg,
  295. icon: 'none',
  296. duration: 1500
  297. })
  298. }
  299. }
  300. })
  301. },
  302. /**
  303. * 生命周期函数--监听页面加载
  304. */
  305. onLoad: function (options) {
  306. this.dbData();
  307. this.rongziData();
  308. },
  309. /**
  310. * 生命周期函数--监听页面初次渲染完成
  311. */
  312. onReady: function () {
  313. let user = wx.getStorageSync('user')
  314. if (user) {
  315. this.renzheng();
  316. } else {
  317. wx.showModal({
  318. title: '',
  319. content: '您当前没有登录!',
  320. showCancel: false,
  321. confirmText: '去登录',
  322. success: function (res) {
  323. if (res.confirm) {
  324. wx.redirectTo({
  325. url: '/pages/login/index'
  326. })
  327. }
  328. }
  329. })
  330. }
  331. },
  332. /**
  333. * 生命周期函数--监听页面显示
  334. */
  335. onShow: function () {
  336. },
  337. /**
  338. * 生命周期函数--监听页面隐藏
  339. */
  340. onHide: function () {
  341. },
  342. /**
  343. * 生命周期函数--监听页面卸载
  344. */
  345. onUnload: function () {
  346. },
  347. /**
  348. * 页面相关事件处理函数--监听用户下拉动作
  349. */
  350. onPullDownRefresh: function () {
  351. },
  352. /**
  353. * 页面上拉触底事件的处理函数
  354. */
  355. onReachBottom: function () {
  356. },
  357. /**
  358. * 用户点击右上角分享
  359. */
  360. onShareAppMessage: function () {
  361. }
  362. })