index.js 4.9 KB

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