index.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. // pages/market/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: 2,
  17. icon: {
  18. normal: '/pages/images/home.png',
  19. active: '/pages/images/home_fill.png',
  20. bankNormal: '/pages/images/duijie.png',
  21. bankActive: '/pages/images/duijie_fill.png',
  22. marketNormal: '/pages/images/recharge.png',
  23. marketActive: '/pages/images/recharge_fill.png',
  24. policyNormal: '/pages/images/news_hot.png',
  25. policyActive: '/pages/images/news_hot_fill.png',
  26. myNormal: '/pages/images/people.png',
  27. myActive: '/pages/images/people_fill.png'
  28. },
  29. tabActive: 0,
  30. currentTab: 0,
  31. idx: '0',
  32. applyList: [{
  33. id: "0",
  34. name: "全部"
  35. }, {
  36. id: "1",
  37. name: "最低利率"
  38. },
  39. // {
  40. // id: "2",
  41. // name: "成功率"
  42. // }
  43. ],
  44. // 判断状态 0为默认不展开 1为展开
  45. _num:0,
  46. // 筛选-单选按钮选中内容 默认为a
  47. // checked: false,
  48. checked1:false,
  49. show: false,
  50. showView: false,
  51. successNum: '1000',
  52. // 全部-视频列表
  53. marketOneVideoList: [],
  54. //全部-无视频列表
  55. marketOneNovideoList: [],
  56. rzqxList: [{
  57. code: '3',
  58. name: '3个月及以下',
  59. },
  60. {
  61. code: '6',
  62. name: '6个月及以下',
  63. },
  64. {
  65. code: '9',
  66. name: '9个月及以下'
  67. },
  68. {
  69. code: '12',
  70. name: '12个月及以下'
  71. },
  72. {
  73. code: '13',
  74. name: '12个月及以上'
  75. },
  76. ],
  77. dbfsList: [],
  78. rzedList: [{
  79. code: '100',
  80. name: '100万及以下',
  81. },
  82. {
  83. code: '200',
  84. name: '200万及以下',
  85. },
  86. {
  87. code: '500',
  88. name: '500万及以下'
  89. },
  90. {
  91. code: '1000',
  92. name: '1000万及以下'
  93. },
  94. {
  95. code: '1001',
  96. name: '1000万及以上'
  97. },
  98. ],
  99. rzqdList: [],
  100. title: '',
  101. name: '',
  102. formData: {
  103. skip: 0,
  104. limit: 5,
  105. mongey_min_rate: '', // 最低利率排序
  106. title: '', //请输入金融产品名称
  107. name: '', // 银行
  108. claims_max_money: "", //筛选钱
  109. claims_max_term: "", //筛选期限
  110. ensure_id: "", // 融资方式
  111. cplx_id: '', // 抗疫贷 科技贷 全部
  112. uid: '', // 融资渠道
  113. },
  114. total: 0,
  115. pageSize: 1,
  116. showMore: false, //更多
  117. },
  118. // 更多
  119. listToggle: function () {
  120. this.setData({
  121. showMore: !this.data.showMore
  122. })
  123. },
  124. // 搜索按钮
  125. radioChange: function (e) {
  126. console.log(e,"e")
  127. console.log('radio发生change事件,携带value值为:', e.detail.value)
  128. },
  129. // 筛选提交
  130. formSubmit: function (e) {
  131. console.log('form发生了submit事件,携带数据为:', e.detail.value)
  132. this.setData({
  133. show: false,
  134. _num: 0
  135. });
  136. var claims_max_money = 'formData.claims_max_money'
  137. var claims_max_term = 'formData.claims_max_term'
  138. var skip = 'formData.skip'
  139. var ensure_id = 'formData.ensure_id'
  140. var uid = 'formData.uid'
  141. var that = this;
  142. that.setData({
  143. [claims_max_money]: e.detail.value.claims_max_money,
  144. [claims_max_term]: e.detail.value.claims_max_term,
  145. [ensure_id]: e.detail.value.code,
  146. [uid]: e.detail.value.uid,
  147. marketOneVideoList: [],
  148. marketOneNovideoList: [],
  149. [skip]: 0,
  150. pageSize: 1
  151. })
  152. this.all();
  153. },
  154. formReset: function (e) {
  155. console.log('form发生了reset事件')
  156. console.log(e);
  157. },
  158. // 有id跳转
  159. marketOneVideoDetail: function (e) {
  160. console.log(e)
  161. let pid = e.currentTarget.dataset.pid;
  162. let img = e.currentTarget.dataset.img;
  163. let joincount = e.currentTarget.dataset.joincount;
  164. let code = e.currentTarget.dataset.code;
  165. let uid = e.currentTarget.dataset.uid;
  166. if (wx.getStorageSync('user') == "") {
  167. wx.redirectTo({
  168. url: '/pages/login/index'
  169. })
  170. } else {
  171. if (wx.getStorageSync('user').roles != "0") {
  172. wx.navigateTo({
  173. url: '/pages/loanDetailapply/index?id=' + pid + '&uid=' + uid + '&num=' + joincount + '&ecode=' + code + '&img=' + img // 希望跳转过去的页面
  174. })
  175. } else {
  176. wx.showToast({
  177. title: '您的企业正在审核中,暂不能申请',
  178. icon: "none"
  179. })
  180. }
  181. }
  182. },
  183. //
  184. marketOneVideoNoDetail(e) {
  185. let claimid = e.currentTarget.dataset.claimid;
  186. let img = e.currentTarget.dataset.img;
  187. wx.navigateTo({
  188. url: '/pages/marketLoanDetail/index?claimid=' + claimid + '&img=' + img,
  189. })
  190. },
  191. // 上下效果
  192. onChangeShowState: function () {
  193. var that = this;
  194. that.setData({
  195. showView: (!that.data.showView)
  196. })
  197. },
  198. showPopup() {
  199. console.log('showPopup');
  200. this.setData({
  201. show: true,
  202. _num: 1
  203. });
  204. },
  205. onClose() {
  206. this.setData({
  207. show: true,
  208. _num: 0
  209. });
  210. },
  211. // 切换标签
  212. onChangeTab(event) {
  213. // this.setData({
  214. // marketOneNovideoList : [],
  215. // marketOnevideoList : []
  216. // });
  217. // console.log(this.data.marketOnevideoList,"切换时候为空么?");
  218. var cplx_id = 'formData.cplx_id'
  219. var skip = 'formData.skip'
  220. var that = this
  221. if (event.detail.index == 0) {
  222. console.log("1");
  223. that.setData({
  224. [cplx_id]: '',
  225. [skip]: 0,
  226. marketOneVideoList: [],
  227. marketOneNovideoList: [],
  228. pageSize: 1
  229. })
  230. } else if (event.detail.index == 1) {
  231. that.setData({
  232. [cplx_id]: '2401',
  233. [skip]: 0,
  234. marketOneVideoList: [],
  235. marketOneNovideoList: [],
  236. pageSize: 1
  237. })
  238. } else if (event.detail.index == 2) {
  239. that.setData({
  240. [cplx_id]: '2402',
  241. [skip]: 0,
  242. marketOneVideoList: [],
  243. marketOneNovideoList: [],
  244. pageSize: 1
  245. })
  246. }
  247. this.all();
  248. // wx.showToast({
  249. // title: `切换到标签 ${event.detail.title}`,
  250. // });
  251. },
  252. // 筛选
  253. selectApply: function (e) {
  254. let id = e.target.dataset.id
  255. console.log(id)
  256. var skip = 'formData.skip'
  257. this.setData({
  258. idx: id
  259. })
  260. if (id == '0') {
  261. var mongey_min_rate = 'formData.mongey_min_rate'
  262. var that = this
  263. that.setData({
  264. [mongey_min_rate]: '',
  265. marketOneVideoList: [],
  266. marketOneNovideoList: [],
  267. pageSize: 1,
  268. [skip]: 0,
  269. })
  270. } else if (id == '1') {
  271. var mongey_min_rate = 'formData.mongey_min_rate'
  272. var that = this
  273. that.setData({
  274. [mongey_min_rate]: '1',
  275. marketOneVideoList: [],
  276. marketOneNovideoList: [],
  277. pageSize: 1,
  278. [skip]: 0,
  279. })
  280. }
  281. this.all();
  282. },
  283. //搜索input 金融产品
  284. titleInput(e) {
  285. this.setData({
  286. title: e.detail.value
  287. })
  288. },
  289. // 搜索 金融产品
  290. clickSearch(e) {
  291. var title = 'formData.title'
  292. var skip = 'formData.skip'
  293. var that = this
  294. that.setData({
  295. [title]: this.data.title,
  296. marketOneVideoList: [],
  297. marketOneNovideoList: [],
  298. [skip]: 0,
  299. pageSize: 1
  300. })
  301. this.all();
  302. },
  303. //搜索input 银行
  304. titleInput1(e) {
  305. this.setData({
  306. name: e.detail.value
  307. })
  308. },
  309. // 搜索 银行
  310. clickSearch1(e) {
  311. var name = 'formData.name'
  312. var that = this
  313. that.setData({
  314. [name]: this.data.name
  315. })
  316. this.all();
  317. },
  318. // 切换菜单
  319. onChange(event) {
  320. console.log(event.detail)
  321. this.setData({
  322. active: event.detail
  323. });
  324. if (event.detail == 0) {
  325. wx.redirectTo({
  326. url: '/pages/home/index'
  327. })
  328. } else if (event.detail == 1) {
  329. wx.redirectTo({
  330. url: '/pages/bank/index'
  331. })
  332. } else if (event.detail == 2) {
  333. wx.redirectTo({
  334. url: '/pages/market/index'
  335. })
  336. } else if (event.detail == 3) {
  337. wx.redirectTo({
  338. url: '/pages/policy/index'
  339. })
  340. } else if (event.detail == 4) {
  341. wx.redirectTo({
  342. url: '/pages/my/index'
  343. })
  344. }
  345. },
  346. // 查询列表
  347. all() {
  348. wx.showLoading({
  349. title: '加载中',
  350. })
  351. var that = this;
  352. wx.request({
  353. method: "POST",
  354. url: app.globalData.publicUrl + 'api/financial/searchauto/financeclaims',
  355. data: this.data.formData,
  356. success: (e) => {
  357. if (e.data.data.length !== 0) {
  358. for (const val1 of that.data.dbfsList) {
  359. for (const val of e.data.data) {
  360. if (val1.code == val.ensure_id) {
  361. val.ensure_name = val1.name
  362. }
  363. }
  364. }
  365. if (that.data.marketOneVideoList.isEmpty) {
  366. that.setData({ // 设置页面列表的内容
  367. marketOneVideoList: e.data.data,
  368. marketOneNovideoList: e.data.data,
  369. })
  370. } else {
  371. console.log(e.data.data);
  372. that.setData({ // 设置页面列表的内容
  373. marketOneVideoList: that.data.marketOneVideoList.concat(e.data.data),
  374. marketOneNovideoList: that.data.marketOneNovideoList.concat(e.data.data),
  375. total: e.data.total
  376. })
  377. }
  378. } else {
  379. // that.setData({ // 设置页面列表的内容
  380. // marketOneVideoList: e.data.data,
  381. // marketOneNovideoList: e.data.data,
  382. // })
  383. wx.showToast({
  384. title: "沒有更多数据",
  385. duration: 1000,
  386. icon: 'none',
  387. mask: true
  388. })
  389. }
  390. },
  391. complete: function () {
  392. wx.hideLoading();
  393. wx.hideNavigationBarLoading() //完成停止加载
  394. wx.stopPullDownRefresh() //停止下拉刷新
  395. }
  396. })
  397. },
  398. // 字典表
  399. dictory(code) {
  400. wx.request({
  401. method: "get",
  402. url: app.globalData.publicUrl + 'api/financial/dictionary',
  403. data: {
  404. type: code
  405. },
  406. success: (e) => {
  407. if (e.data.errcode == 0) {
  408. this.setData({
  409. dbfsList: e.data.data,
  410. })
  411. } else {
  412. wx.showToast({
  413. title: e.data.details ? e.data.details : e.data.errmsg,
  414. icon: 'none',
  415. duration: 1500
  416. })
  417. }
  418. }
  419. })
  420. },
  421. /**
  422. * 生命周期函数--监听页面加载
  423. */
  424. onLoad: function (options) {
  425. this.dictory('db');
  426. wx.request({
  427. method: "get",
  428. url: app.globalData.publicUrl + 'api/financial/institution',
  429. success: (e) => {
  430. if (e.data.errcode == 0) {
  431. this.setData({
  432. rzqdList: e.data.data,
  433. })
  434. } else {
  435. wx.showToast({
  436. title: e.data.details ? e.data.details : e.data.errmsg,
  437. icon: 'none',
  438. duration: 1500
  439. })
  440. }
  441. }
  442. })
  443. },
  444. /**
  445. * 生命周期函数--监听页面初次渲染完成
  446. */
  447. onReady: function () {
  448. this.all();
  449. },
  450. /**
  451. * 生命周期函数--监听页面显示
  452. */
  453. onShow: function () {
  454. },
  455. /**
  456. * 生命周期函数--监听页面隐藏
  457. */
  458. onHide: function () {
  459. },
  460. /**
  461. * 生命周期函数--监听页面卸载
  462. */
  463. onUnload: function () {
  464. },
  465. /**
  466. * 页面相关事件处理函数--监听用户下拉动作
  467. */
  468. onPullDownRefresh: function (e) {
  469. console.log(this.data._num,"我是判断是否展开")
  470. if(this.data._num==1){
  471. return false
  472. }else{
  473. wx.showNavigationBarLoading() //在标题栏中显示加载
  474. this.data.formData.skip = 0
  475. this.data.pageSize = 1
  476. this.data.marketOneVideoList = []
  477. this.data.marketOneNovideoList = []
  478. wx.showLoading({
  479. title: '正在刷新数据',
  480. })
  481. this.all()
  482. wx.stopPullDownRefresh();
  483. }
  484. },
  485. /**
  486. * 页面上拉触底事件的处理函数
  487. */
  488. onReachBottom: function () {
  489. let newPageSize = this.data.pageSize + 1;
  490. const pageNum = newPageSize;
  491. const _pagenum = Math.ceil(this.data.total / this.data.formData.limit);
  492. console.log('下拉+1', newPageSize);
  493. console.log('已用', pageNum);
  494. console.log('skip', _pagenum);
  495. if (newPageSize <= _pagenum) {
  496. var skip = 'formData.skip'
  497. var that = this
  498. that.setData({
  499. [skip]: (newPageSize - 1) * this.data.formData.limit,
  500. pageSize: newPageSize
  501. })
  502. this.all()
  503. } else {
  504. wx.showToast({
  505. title: '没有更多数据了',
  506. })
  507. }
  508. },
  509. /**
  510. * 用户点击右上角分享
  511. */
  512. onShareAppMessage: function () {
  513. console.log("dayin")
  514. },
  515. // checkedTap:function(e){
  516. // console.log(e,"woshi ")
  517. // }
  518. })