index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. toshow(e) {
  64. var that = this;
  65. var claimid = e.currentTarget.dataset.claimid;
  66. console.log(claimid)
  67. // wx.navigateTo({
  68. // url: '../minenotic/minenotic?noticeid=' + noticeid,
  69. // })
  70. },
  71. // 切换菜单
  72. onChange(event) {
  73. this.setData({
  74. active: event.detail
  75. });
  76. if (event.detail == 0) {
  77. wx.navigateTo({
  78. url: '/pages/home/index'
  79. })
  80. } else if (event.detail == 1) {
  81. wx.navigateTo({
  82. url: '/pages/bank/index'
  83. })
  84. } else if (event.detail == 2) {
  85. wx.navigateTo({
  86. url: '/pages/market/index'
  87. })
  88. } else if (event.detail == 3) {
  89. wx.navigateTo({
  90. url: '/pages/policy/index'
  91. })
  92. } else if (event.detail == 4) {
  93. wx.navigateTo({
  94. url: '/pages/my/index'
  95. })
  96. }
  97. },
  98. topNews: function () {
  99.     wx.request({
  100.       method:"POST",
  101.       url: app.globalData.publicUrl + 'api/financial/financeclaims/top',
  102.       success:(e) => {
  103.         if(e.data.errcode == 0){
  104. let arr = [];
  105. e.data.data.forEach((item) => {
  106. arr.push({_id:item._id,pic: app.globalData.imageUrl+item.innew.logo, title: item.name.substring(0,5)+'...'});
  107. });
  108.           this.setData({
  109.             productList:arr
  110.           })
  111.         }
  112.       }
  113.     })
  114.   },
  115. loadPolicyList: function () {
  116. request.query({
  117. url: 'api/financial/tPolicyInterpretation/select',
  118. data: {
  119. skip: 0,
  120. limit: 4,
  121. publish_state: 1
  122. }
  123. }).then((res) => {
  124. let temp = res.data.data.map((item) => {
  125. if (item.image) {
  126. item.image = request.imageUrl + item.image
  127. }
  128. return item;
  129. });
  130. this.setData({
  131. policyList: temp
  132. });
  133. }).catch((err) => {
  134. console.log(err);
  135. });
  136. },
  137. //轮播图
  138. getbanner(){
  139. wx.request({
  140. method: "GET",
  141. url: app.globalData.publicUrl + 'api/financial/banner',
  142. data: {
  143. skip: 0,
  144. limit: 3,
  145. },
  146. success: (res)  =>  {
  147. if (res.data.errcode == 0) {
  148. this.setData({
  149. background: res.data.data
  150. })
  151. }
  152. }
  153. })
  154. },
  155. /**
  156. * 生命周期函数--监听页面加载
  157. */
  158. onLoad: function (options) {
  159. this.topNews();
  160. this.loadPolicyList();
  161. this.getbanner();
  162. },
  163. /**
  164. * 生命周期函数--监听页面初次渲染完成
  165. */
  166. onReady: function () {
  167. console.log(JSON.stringify(wx.getStorageSync('user')))
  168. },
  169. /**
  170. * 生命周期函数--监听页面显示
  171. */
  172. onShow: function () {
  173. },
  174. /**
  175. * 生命周期函数--监听页面隐藏
  176. */
  177. onHide: function () {
  178. },
  179. /**
  180. * 生命周期函数--监听页面卸载
  181. */
  182. onUnload: function () {
  183. },
  184. /**
  185. * 页面相关事件处理函数--监听用户下拉动作
  186. */
  187. onPullDownRefresh: function () {
  188. },
  189. /**
  190. * 页面上拉触底事件的处理函数
  191. */
  192. onReachBottom: function () {
  193. },
  194. /**
  195. * 用户点击右上角分享
  196. */
  197. onShareAppMessage: function () {
  198. }
  199. })