index.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. const request = require('../../utils/request.js');
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. // 组件所需的参数
  9. nvabarData: {
  10. showCapsule: 1, //是否显示左上角图标,消息中心 1表示显示 0表示不显示
  11. showBack: 0, //返回
  12. title: '我的主页', //导航栏 中间的标题
  13. // 此页面 页面内容距最顶部的距离
  14. height: app.globalData.height * 2 + 20,
  15. },
  16. // 此页面 页面内容距最顶部的距离
  17. active: 0,
  18. // 成功对接
  19. mainOneInfo: {
  20. "registerCompany": 0,
  21. "solutionFinancing": 0,
  22. "demandCount": 0,
  23. "demandMoney": 0,
  24. "financialProduct": 0,
  25. "financialInstitution": 0,
  26. "helpCompany": 0,
  27. },
  28. // 热门产品
  29. productList: [],
  30. // 政策解读
  31. policyList: [],
  32. // 轮播
  33. backgrounds: [{
  34. "pic": "/images/banner3.png",
  35. },
  36. {
  37. "pic": "images/banner1.png",
  38. },
  39. {
  40. "pic": "/images/banner2.png",
  41. }
  42. ],
  43. indicatorDots: true,
  44. vertical: false,
  45. autoplay: true,
  46. interval: 5000,
  47. duration: 500
  48. },
  49. // 我要融资
  50. tongjiBtn: function () {
  51. wx.navigateTo({
  52. url: '/pages/bank/index'
  53. })
  54. },
  55. // 政策解读页面列表跳转
  56. policyListTap: function () {
  57. wx.navigateTo({
  58. url: '/pages/policy/index'
  59. })
  60. },
  61. // 政策解读页面详情跳转
  62. // 判断id
  63. policyListDetailTap: function (e) {
  64. console.log(e)
  65. wx.navigateTo({
  66. url: '/pages/policyDetail/index?id=' + e.currentTarget.dataset.pid // 希望跳转过去的页面
  67. })
  68. },
  69. // 热门产品跳转
  70. toshow(e) {
  71. let claimid = e.currentTarget.dataset.claimid;
  72. let img = e.currentTarget.dataset.img;
  73. console.log(e);
  74. console.log(JSON.stringify(e.currentTarget.dataset))
  75. wx.navigateTo({
  76. url: '/pages/marketLoanDetail/index?claimid=' + claimid + '&img=' + img,
  77. })
  78. },
  79. // 热门产品更多
  80. clickMore(){
  81. },
  82. // 切换菜单
  83. onChange(event) {
  84. this.setData({
  85. active: event.detail
  86. });
  87. if (event.detail == 0) {
  88. wx.redirectTo({
  89. url: '/pages/home/index'
  90. })
  91. } else if (event.detail == 1) {
  92. wx.redirectTo({
  93. url: '/pages/bank/index'
  94. })
  95. } else if (event.detail == 2) {
  96. wx.redirectTo({
  97. url: '/pages/market/index'
  98. })
  99. } else if (event.detail == 3) {
  100. wx.redirectTo({
  101. url: '/pages/policy/index'
  102. })
  103. } else if (event.detail == 4) {
  104. wx.redirectTo({
  105. url: '/pages/my/index'
  106. })
  107. }
  108. },
  109. topNews: function () {
  110. wx.request({
  111. method: "POST",
  112. url: app.globalData.publicUrl + 'api/financial/financeclaims/top',
  113. success: (e) => {
  114. if (e.data.errcode == 0) {
  115. let arr = [];
  116. e.data.data.forEach((item) => {
  117. let nikeName = '';
  118. if(item.name.length > 5){
  119. nikeName = item.name.substring(0, 5) + '....'
  120. }else{
  121. nikeName = item.name
  122. }
  123. arr.push({
  124. _id: item._id,
  125. pic: app.globalData.imageUrl + item.innew.logo,
  126. mongey_min_rate: item.mongey_min_rate,
  127. mongey_max_rate: item.mongey_max_rate,
  128. claims_min_money: item.claims_min_money,
  129. claims_max_money: item.claims_max_money,
  130. claims_min_term:item.claims_min_term,
  131. claims_max_term: item.claims_max_term,
  132. introduction: item.innew.introduction,
  133. // title: item.name.substring(0, 5) + '...'
  134. title: nikeName
  135. });
  136. });
  137. this.setData({
  138. productList: arr
  139. })
  140. }
  141. }
  142. })
  143. },
  144. getDate(val, formatStr) {
  145. if (val) {
  146. return this.format(new Date(Number(val)), formatStr);
  147. }
  148. return '';
  149. },
  150. format(date, formatStr) {
  151. formatStr = formatStr.replace(/yyyy|YYYY/, date.getFullYear());
  152. formatStr = formatStr.replace(/MM/, (date.getMonth() + 1) > 9 ? (date.getMonth() + 1).toString() : '0' + (date.getMonth() + 1));
  153. formatStr = formatStr.replace(/dd|DD/, date.getDate() > 9 ? date.getDate().toString() : '0' + date.getDate());
  154. return formatStr;
  155. },
  156. loadPolicyList: function () {
  157. request.query({
  158. url: 'api/financial/tPolicyInterpretation',
  159. data: {
  160. skip: 0,
  161. limit: 4
  162. }
  163. }).then((res) => {
  164. let temp = res.data.data.map((item) => {
  165. if (item.image) {
  166. item.image = request.imageUrl + item.image
  167. }
  168. if (item.create_time) {
  169. item.create_time = this.getDate(item.create_time, 'yyyy.MM.dd')
  170. }
  171. return item;
  172. });
  173. this.setData({
  174. policyList: temp
  175. });
  176. }).catch((err) => {
  177. console.log(err);
  178. });
  179. },
  180. loadStatistics: function () {
  181. request.query({
  182. url: 'api/financial/tGovernmentStatistics/pageSelect',
  183. }).then((res) => {
  184. this.setData({
  185. mainOneInfo: res.data.data
  186. });
  187. }).catch((err) => {
  188. console.log(err);
  189. });
  190. },
  191. //轮播图
  192. getbanner() {
  193. wx.request({
  194. method: "GET",
  195. url: app.globalData.publicUrl + 'api/financial/banner',
  196. data: {
  197. skip: 0,
  198. limit: 3,
  199. },
  200. success: (res) => {
  201. if (res.data.errcode == 0) {
  202. this.setData({
  203. background: res.data.data
  204. })
  205. }
  206. }
  207. })
  208. },
  209. /**
  210. * 生命周期函数--监听页面加载
  211. */
  212. onLoad: function (options) {
  213. this.topNews();
  214. this.loadPolicyList();
  215. this.loadStatistics();
  216. this.getbanner();
  217. },
  218. /**
  219. * 生命周期函数--监听页面初次渲染完成
  220. */
  221. onReady: function () {
  222. console.log(JSON.stringify(wx.getStorageSync('user')))
  223. },
  224. /**
  225. * 生命周期函数--监听页面显示
  226. */
  227. onShow: function () {
  228. },
  229. /**
  230. * 生命周期函数--监听页面隐藏
  231. */
  232. onHide: function () {
  233. },
  234. /**
  235. * 生命周期函数--监听页面卸载
  236. */
  237. onUnload: function () {
  238. },
  239. /**
  240. * 页面相关事件处理函数--监听用户下拉动作
  241. */
  242. onPullDownRefresh: function () {
  243. },
  244. /**
  245. * 页面上拉触底事件的处理函数
  246. */
  247. onReachBottom: function () {
  248. },
  249. /**
  250. * 用户点击右上角分享
  251. */
  252. onShareAppMessage: function () {
  253. }
  254. })