articlDetail.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // pages/articlDetail/articlDetail.js
  2. import {
  3. imgUrl
  4. } from "../api/request"
  5. import {
  6. info
  7. } from "../api/index-api2"
  8. const IMGPATH = "https://www.cqna.gov.cn/data/mini/hlw/forward?url="
  9. // const imageCdn = 'https://tdesign.gtimg.com/site/swiper';
  10. // const swiperList = [];
  11. Page({
  12. /**
  13. * 页面的初始数据
  14. */
  15. data: {
  16. imgUrl: imgUrl,
  17. chnlid: "",
  18. docid: "",
  19. data: {},
  20. current: 0,
  21. autoplay: true,
  22. duration: 500,
  23. interval: 5000,
  24. paginationPosition: 'bottom-right',
  25. swiperList:[],
  26. navigation: { type: 'fraction' },
  27. imgShow:true
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad(options) {
  33. wx.showLoading({
  34. title: '页面加载中',
  35. })
  36. this.setData({
  37. chnlid: options.CHNLID,
  38. docid: options.DOCID
  39. })
  40. this.initPage();
  41. },
  42. initPage() {
  43. info(this.data.chnlid, this.data.docid).then(res => {
  44. // console.log(res);
  45. let swiperLists = [];
  46. if (res.result) {
  47. let imgs = res.data.DOCATTACHPICFIELD;
  48. if(imgs.length<=0&&res.data.THUMBFILES!=null&&res.data.THUMBFILES!=""){
  49. let imgName = res.data.THUMBFILES.split(',');
  50. // /webpic/W0202210/W020221019/W020221019788334970636.jpg
  51. for (const imgOne of imgName) {
  52. let one = "/webpic"
  53. let two = "/"+imgOne.slice(0,8)
  54. // console.log(two);
  55. let three = "/"+imgOne.slice(0,10)+"/"
  56. // console.log(three);
  57. swiperLists.push(IMGPATH+one+two+three+imgOne)
  58. }
  59. }else{
  60. for (const img of imgs) {
  61. if(img.APPFILEURL!=null&&img.APPFILEURL!=''){
  62. swiperLists.push(IMGPATH+img.APPFILEURL);
  63. }
  64. }
  65. }
  66. // console.log(swiperLists);
  67. if(swiperLists.length<=0){
  68. this.setData({
  69. imgShow:false
  70. })
  71. }
  72. this.setData({
  73. data: res.data,
  74. swiperList: swiperLists
  75. })
  76. // wx.setNavigationBarTitle({
  77. // title: res.data.DOCTITLE
  78. // })
  79. wx.hideLoading();
  80. }
  81. })
  82. },
  83. /**
  84. * 生命周期函数--监听页面初次渲染完成
  85. */
  86. onReady() {
  87. },
  88. /**
  89. * 生命周期函数--监听页面显示
  90. */
  91. onShow() {
  92. },
  93. /**
  94. * 生命周期函数--监听页面隐藏
  95. */
  96. onHide() {
  97. },
  98. /**
  99. * 生命周期函数--监听页面卸载
  100. */
  101. onUnload() {
  102. },
  103. /**
  104. * 页面相关事件处理函数--监听用户下拉动作
  105. */
  106. onPullDownRefresh() {
  107. },
  108. /**
  109. * 页面上拉触底事件的处理函数
  110. */
  111. onReachBottom() {
  112. },
  113. /**
  114. * 用户点击右上角分享
  115. */
  116. onShareAppMessage(res) {
  117. return {
  118. title: this.data.data.DOCTITLE
  119. };
  120. },
  121. onShareTimeline() {
  122. return {
  123. title: this.data.data.DOCTITLE
  124. };
  125. }
  126. })