macunIntro.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // pages/secondIntro/secondIntro.js
  2. import request from '../../utils/request'
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. bannersList:[],
  9. textIntro:''
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad:async function(options) {
  15. // 进入页面时,提示“数据加载中”
  16. wx.showLoading({
  17. title: '数据加载中',
  18. mask:true
  19. })
  20. //获取轮播图
  21. let result = await request('/front/introduce/files/2').catch(err=>{
  22. wx.hideLoading()
  23. wx.showModal({
  24. title: '数据加载失败',
  25. content: '当前网络不佳,请稍后再试',
  26. complete: (res) => {
  27. if (res.cancel) {
  28. wx.navigateBack()
  29. }
  30. if (res.confirm) {
  31. wx.navigateBack()
  32. }
  33. }
  34. })
  35. })
  36. // console.log(result);
  37. //获取简介信息
  38. let introduce = await request('/front/introduce/2')
  39. this.setData({
  40. bannersList:result,
  41. textIntro:introduce
  42. })
  43. // 关闭“数据加载中”的提示
  44. if(this.data.bannersList.length != 0 || this.data.textIntro != ''){
  45. wx.hideLoading()
  46. }else{
  47. setTimeout(function () {
  48. wx.hideLoading()
  49. }, 2000)
  50. }
  51. },
  52. /**
  53. * 生命周期函数--监听页面初次渲染完成
  54. */
  55. onReady() {
  56. },
  57. /**
  58. * 生命周期函数--监听页面显示
  59. */
  60. onShow() {
  61. },
  62. /**
  63. * 生命周期函数--监听页面隐藏
  64. */
  65. onHide() {
  66. },
  67. /**
  68. * 生命周期函数--监听页面卸载
  69. */
  70. onUnload() {
  71. },
  72. /**
  73. * 页面相关事件处理函数--监听用户下拉动作
  74. */
  75. onPullDownRefresh() {
  76. },
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom() {
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage() {
  86. }
  87. })