index.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. const request = require('../../utils/request.js');
  2. // pages/home/index.js
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. // 组件所需的参数
  10. nvabarData: {
  11. showCapsule: 1, //是否显示左上角图标,消息中心 1表示显示 0表示不显示
  12. showBack: 0, //返回
  13. title: '我的主页', //导航栏 中间的标题
  14. // 此页面 页面内容距最顶部的距离
  15. height: app.globalData.height * 2 + 20,
  16. },
  17. // 此页面 页面内容距最顶部的距离
  18. active: 0,
  19. icon: {
  20. normal: '/pages/images/home.png',
  21. active: '/pages/images/home_fill.png',
  22. bankNormal:'/pages/images/duijie.png',
  23. bankActive:'/pages/images/duijie_fill.png',
  24. marketNormal:'/pages/images/recharge.png',
  25. marketActive:'/pages/images/recharge_fill.png',
  26. policyNormal:'/pages/images/news_hot.png',
  27. policyActive:'/pages/images/news_hot_fill.png',
  28. myNormal:'/pages/images/people.png',
  29. myActive:'/pages/images/people_fill.png'
  30. },
  31. // 热门产品
  32. productList: [
  33. // {
  34. // "pic": '/pages/images/cooperation01.png',
  35. // title: '热门产品'
  36. // },
  37. // {
  38. // "pic": '/pages/images/cooperation01.png',
  39. // title: '热门产品'
  40. // }
  41. ],
  42. // 政策解读
  43. policyList: [],
  44. // 轮播
  45. background: [{
  46. "pic": "/pages/images/test1.png",
  47. },
  48. {
  49. "pic": "/pages/images/test.jpg",
  50. }
  51. ],
  52. indicatorDots: true,
  53. vertical: false,
  54. autoplay: true,
  55. interval: 2000,
  56. duration: 500
  57. },
  58. // 政策解读页面列表跳转
  59. policyListTap: function () {
  60. wx.navigateTo({
  61. url: '/pages/policy/index'
  62. })
  63. },
  64. // 政策解读页面详情跳转
  65. // 判断id
  66. policyListDetailTap: function (e) {
  67. console.log(e)
  68. wx.navigateTo({
  69. url: '/pages/policyDetail/index?id=' + e.currentTarget.dataset.pid // 希望跳转过去的页面
  70. })
  71. },
  72. /*// 无id,模拟数据跳转
  73. policyListDetailTap: function () {
  74. wx.navigateTo({
  75. url: '/pages/policyDetail/index'
  76. })
  77. },*/
  78. // 热门产品跳转
  79. productListDetail: function (e) {
  80. console.log('productListDetail',e.currentTarget.id)
  81. wx.navigateTo({
  82. url: '/pages/productListDetail/index?id=' + e.currentTarget.id // 希望跳转过去的页面
  83. })
  84. },
  85. // 无id,模拟数据跳转
  86. // productListDetail: function () {
  87. // wx.navigateTo({
  88. // // url: '/pages/policyDetail/index'
  89. // })
  90. // },
  91. // 切换菜单
  92. onChange(event) {
  93. this.setData({
  94. active: event.detail
  95. });
  96. if (event.detail == 0) {
  97. wx.navigateTo({
  98. url: '/pages/home/index'
  99. })
  100. } else if (event.detail == 1) {
  101. wx.navigateTo({
  102. url: '/pages/bank/index'
  103. })
  104. } else if (event.detail == 2) {
  105. wx.navigateTo({
  106. url: '/pages/market/index'
  107. })
  108. } else if (event.detail == 3) {
  109. wx.navigateTo({
  110. url: '/pages/policy/index'
  111. })
  112. } else if (event.detail == 4) {
  113. wx.navigateTo({
  114. url: '/pages/my/index'
  115. })
  116. }
  117. },
  118. topNews: function () {
  119.     wx.request({
  120.       method:"POST",
  121.       url: app.globalData.publicUrl + 'api/financial/financeclaims/top',
  122.       success:(e) => {
  123.         console.log('success',e);
  124.         if(e.data.errcode == 0){
  125. let arr = [];
  126. e.data.data.forEach((item) => {
  127. // console.log('success',item.name.substring(0,5));
  128. arr.push({_id:item._id,pic: app.globalData.imageUrl+item.innew.logo, title: item.name.substring(0,5)+'...'});
  129. });
  130.           this.setData({
  131.             productList:arr
  132.           })
  133.         }
  134.       }
  135.     })
  136.   },
  137. loadPolicyList: function () {
  138. request.query({
  139. url: 'api/financial/tPolicyInterpretation/select',
  140. data: {
  141. skip: 0,
  142. limit: 4,
  143. publish_state: 1
  144. }
  145. }).then((res) => {
  146. let temp = res.data.data.map((item) => {
  147. if (item.image) {
  148. item.image = request.baseUrl + item.image
  149. }
  150. return item;
  151. });
  152. this.setData({
  153. policyList: temp
  154. });
  155. }).catch((err) => {
  156. console.log(err);
  157. });
  158. },
  159. /**
  160. * 生命周期函数--监听页面加载
  161. */
  162. onLoad: function (options) {
  163. this.topNews();
  164. this.loadPolicyList();
  165. },
  166. /**
  167. * 生命周期函数--监听页面初次渲染完成
  168. */
  169. onReady: function () {
  170. console.log(JSON.stringify(wx.getStorageSync('user')))
  171. },
  172. /**
  173. * 生命周期函数--监听页面显示
  174. */
  175. onShow: function () {
  176. },
  177. /**
  178. * 生命周期函数--监听页面隐藏
  179. */
  180. onHide: function () {
  181. },
  182. /**
  183. * 生命周期函数--监听页面卸载
  184. */
  185. onUnload: function () {
  186. },
  187. /**
  188. * 页面相关事件处理函数--监听用户下拉动作
  189. */
  190. onPullDownRefresh: function () {
  191. },
  192. /**
  193. * 页面上拉触底事件的处理函数
  194. */
  195. onReachBottom: function () {
  196. },
  197. /**
  198. * 用户点击右上角分享
  199. */
  200. onShareAppMessage: function () {
  201. }
  202. })