index.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. const request = require('../../utils/request.js');
  2. import WxCountUp from '../../utils/WxCountUp'
  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. guidanceUnitList:[],
  32. // 成功对接
  33. mainOneInfo: {
  34. "registerCompany": 0,
  35. "solutionFinancing": 0,
  36. "demandCount": 0,
  37. "demandMoney": 0,
  38. "financialProduct": 0,
  39. "financialInstitution": 0,
  40. "helpCompany": 0,
  41. "finalsummoney":0,
  42. },
  43. // 热门产品
  44. productList: [],
  45. // 政策解读
  46. policyList: [],
  47. // 轮播
  48. backgrounds: [{
  49. "pic": "/pages/images/banner1.jpg",
  50. link:'../aboutme/index',
  51. },
  52. {
  53. "pic": "/pages/images/banner2.jpg",
  54. link:'../aboutme/index',
  55. },
  56. {
  57. "pic": "/pages/images/banner3.jpg",
  58. link:'../aboutme/index',
  59. },
  60. {
  61. "pic": "/pages/images/banner4.jpg",
  62. link:'../aboutme/index',
  63. },
  64. ],
  65. indicatorDots: true,
  66. vertical: false,
  67. autoplay: true,
  68. interval: 5000,
  69. duration: 500
  70. },
  71. // 我要融资
  72. tongjiBtn: function () {
  73. wx.navigateTo({
  74. url: '/pages/bank/index'
  75. })
  76. },
  77. // 政策解读页面列表跳转
  78. policyListTap: function () {
  79. wx.navigateTo({
  80. url: '/pages/policy/index'
  81. })
  82. },
  83. // 政策解读页面详情跳转
  84. // 判断id
  85. policyListDetailTap: function (e) {
  86. console.log(e)
  87. wx.navigateTo({
  88. url: '/pages/policyDetail/index?id=' + e.currentTarget.dataset.pid // 希望跳转过去的页面
  89. })
  90. },
  91. // 热门产品跳转
  92. toshow(e) {
  93. let claimid = e.currentTarget.dataset.claimid;
  94. let img = e.currentTarget.dataset.img;
  95. console.log(e);
  96. // console.log(JSON.stringify(e.currentTarget.dataset))
  97. wx.navigateTo({
  98. url: '/pages/marketLoanDetail/index?claimid=' + claimid + '&img=' + img,
  99. })
  100. },
  101. // 热门产品更多
  102. clickMore(){
  103. },
  104. // 切换菜单
  105. onChange(event) {
  106. this.setData({
  107. active: event.detail
  108. });
  109. if (event.detail == 0) {
  110. wx.redirectTo({
  111. url: '/pages/home/index'
  112. })
  113. } else if (event.detail == 1) {
  114. wx.redirectTo({
  115. url: '/pages/bank/index'
  116. })
  117. } else if (event.detail == 2) {
  118. wx.redirectTo({
  119. url: '/pages/market/index'
  120. })
  121. } else if (event.detail == 3) {
  122. wx.redirectTo({
  123. url: '/pages/policy/index'
  124. })
  125. } else if (event.detail == 4) {
  126. wx.redirectTo({
  127. url: '/pages/my/index'
  128. })
  129. }
  130. },
  131. topNews: function () {
  132. wx.request({
  133. method: "POST",
  134. url: app.globalData.publicUrl + 'api/financial/financeclaims/top',
  135. success: (e) => {
  136. if (e.data.errcode == 0) {
  137. let arr = [];
  138. e.data.data.forEach((item) => {
  139. let nikeName = '';
  140. if(item.name.length > 3){
  141. nikeName = item.name.substring(0, 3) + '....'
  142. }else{
  143. nikeName = item.name
  144. }
  145. arr.push({
  146. _id: item._id,
  147. pic: app.globalData.imageUrl + item.innew.logo,
  148. mongey_min_rate: item.mongey_min_rate,
  149. mongey_max_rate: item.mongey_max_rate,
  150. claims_min_money: item.claims_min_money,
  151. claims_max_money: item.claims_max_money,
  152. claims_min_term:item.claims_min_term,
  153. claims_max_term: item.claims_max_term,
  154. introduction: item.innew.introduction,
  155. // title: item.name.substring(0, 5) + '...'
  156. title: nikeName
  157. });
  158. });
  159. this.setData({
  160. productList: arr
  161. })
  162. }
  163. }
  164. })
  165. },
  166. getDate(val, formatStr) {
  167. if (val) {
  168. return this.format(new Date(Number(val)), formatStr);
  169. }
  170. return '';
  171. },
  172. format(date, formatStr) {
  173. formatStr = formatStr.replace(/yyyy|YYYY/, date.getFullYear());
  174. formatStr = formatStr.replace(/MM/, (date.getMonth() + 1) > 9 ? (date.getMonth() + 1).toString() : '0' + (date.getMonth() + 1));
  175. formatStr = formatStr.replace(/dd|DD/, date.getDate() > 9 ? date.getDate().toString() : '0' + date.getDate());
  176. return formatStr;
  177. },
  178. loadPolicyList: function () {
  179. request.query({
  180. url: 'api/financial/tPolicyInterpretation',
  181. data: {
  182. skip: 0,
  183. limit: 4
  184. }
  185. }).then((res) => {
  186. let temp = res.data.data.map((item) => {
  187. if (item.image) {
  188. item.image = request.imageUrl + item.image
  189. }
  190. if (item.create_time) {
  191. item.create_time = this.getDate(item.create_time, 'yyyy.MM.dd')
  192. }
  193. return item;
  194. });
  195. this.setData({
  196. policyList: temp
  197. });
  198. }).catch((err) => {
  199. console.log(err);
  200. });
  201. },
  202. loadGuidanceUnitList: function () {
  203. request.query({
  204. url: 'api/financial/tGuidanceUnit',
  205. data: {
  206. skip: 0,
  207. limit: 3
  208. }
  209. }).then((res) => {
  210. let temp = res.data.data.map((item) => {
  211. if (item.image) {
  212. item.image = request.imageUrl + item.image
  213. }
  214. return item;
  215. });
  216. this.setData({
  217. guidanceUnitList: temp
  218. });
  219. }).catch((err) => {
  220. console.log(err);
  221. });
  222. },
  223. loadStatistics: function () {
  224. var that = this;
  225. request.query({
  226. url: 'api/financial/tGovernmentStatistics/pageSelect',
  227. }).then((res) => {
  228. this.setData({
  229. mainOneInfo: res.data.data
  230. });
  231. that.countUp = new WxCountUp('mainOneInfo.registerCompany', res.data.data.registerCompany, {}, that);
  232. that.countUp.start();
  233. that.countUp1 = new WxCountUp('mainOneInfo.financialInstitution', res.data.data.financialInstitution, {}, that);
  234. that.countUp1.start();
  235. that.countUp2 = new WxCountUp('mainOneInfo.demandCount', res.data.data.demandCount, {}, that);
  236. that.countUp2.start();
  237. that.countUp3 = new WxCountUp('mainOneInfo.finalsummoney', res.data.data.finalsummoney, {}, that);
  238. that.countUp3.start();
  239. }).catch((err) => {
  240. console.log(err);
  241. });
  242. },
  243. //轮播图
  244. getbanner() {
  245. wx.request({
  246. method: "GET",
  247. url: app.globalData.publicUrl + 'api/financial/banner',
  248. data: {
  249. skip: 0,
  250. limit: 3,
  251. },
  252. success: (res) => {
  253. if (res.data.errcode == 0) {
  254. this.setData({
  255. background: res.data.data
  256. })
  257. }
  258. }
  259. })
  260. },
  261. /**
  262. * 生命周期函数--监听页面加载
  263. */
  264. onLoad: function (options) {
  265. this.topNews();
  266. this.loadPolicyList();
  267. this.loadGuidanceUnitList();
  268. this.loadStatistics();
  269. this.getbanner();
  270. },
  271. /**
  272. * 生命周期函数--监听页面初次渲染完成
  273. */
  274. onReady: function () {
  275. console.log(JSON.stringify(wx.getStorageSync('user')))
  276. },
  277. /**
  278. * 生命周期函数--监听页面显示
  279. */
  280. onShow: function () {
  281. },
  282. /**
  283. * 生命周期函数--监听页面隐藏
  284. */
  285. onHide: function () {
  286. },
  287. /**
  288. * 生命周期函数--监听页面卸载
  289. */
  290. onUnload: function () {
  291. },
  292. /**
  293. * 页面相关事件处理函数--监听用户下拉动作
  294. */
  295. onPullDownRefresh: function () {
  296. },
  297. /**
  298. * 页面上拉触底事件的处理函数
  299. */
  300. onReachBottom: function () {
  301. },
  302. /**
  303. * 用户点击右上角分享
  304. */
  305. onShareAppMessage: function () {
  306. }
  307. })