index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel();
  5. let processingData = require('../../utils/processingData.js');
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. swiperBannerList: [], //轮播图
  12. tabsList: ['通告列表', '历史发布'], //tab列表
  13. tabsIndex: 0, //tab选中项
  14. showType: "官方", //请求列表类型
  15. pageNumber: 1, //获取页码
  16. pageTotal: 1, //总页码
  17. /* 圆角按钮tabs列表 */
  18. roundedList: ["家纺城通告", "合作商通告", "团队通告"],
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. /* //分类
  25. _Http.basic({
  26. "accesstoken": wx.getStorageSync('userData').token,
  27. "classname": "enterprise.system.notice",
  28. "method": "query_typeselectList",
  29. "content": {}
  30. }).then(res => {
  31. console.log(res)
  32. }) */
  33. /* 获取轮播图 */
  34. const bannerList = wx.getStorageSync('bannerDataList').filter(value => value.flocation == 'home_head');
  35. this.setData({
  36. swiperBannerList: bannerList[0].banner
  37. });
  38. },
  39. /* 跳转详情 */
  40. toDetails(e) {
  41. const {
  42. index
  43. } = e.currentTarget.dataset;
  44. wx.navigateTo({
  45. url: './details?id=' + this.data.annunciateList[index].tnoticeid + '&type=' + this.data.tabsIndex,
  46. })
  47. },
  48. /* 获取列表 */
  49. getList() {
  50. //历史发布
  51. let data = {
  52. "accesstoken": wx.getStorageSync('userData').token,
  53. "classname": "customer.notice.notice",
  54. "method": "query_noticeList",
  55. "content": {
  56. "getdatafromdbanyway": true,
  57. "pageNumber": this.data.pageNumber,
  58. "pageSize": 20,
  59. "where": {
  60. "condition": "",
  61. "ftype": this.data.showType
  62. }
  63. }
  64. };
  65. if (this.data.tabsIndex == 1) {
  66. data.classname = 'customer.noticemag.noticemag';
  67. data.content.where.ftype = '';
  68. };
  69. _Http.basic(data).then(res => {
  70. console.log(res)
  71. this.setData({
  72. annunciateList: processingData.imageType(res.data, 'cover'),
  73. pageTotal: res.pageTotal
  74. })
  75. })
  76. },
  77. /* 历史发布修改 */
  78. toChang(e) {
  79. const {
  80. index
  81. } = e.currentTarget.dataset;
  82. wx.navigateTo({
  83. url: './newAndChange?id=' + this.data.annunciateList[index].tnoticeid,
  84. });
  85. },
  86. /* 查询数据 */
  87. toQueryData(e) {
  88. const {
  89. index
  90. } = e.currentTarget.dataset;
  91. wx.navigateTo({
  92. url: './glanceover?id=' + this.data.annunciateList[index].tnoticeid,
  93. })
  94. },
  95. /* 发布公告 */
  96. toAnnounce() {
  97. wx.navigateTo({
  98. url: '/pages/annunciate/newAndChange',
  99. })
  100. },
  101. /* tab切换 */
  102. setIndex({
  103. detail
  104. }) {
  105. this.setData({
  106. tabsIndex: detail
  107. });
  108. this.getList();
  109. },
  110. /* tabs回调 */
  111. tabsSelectedIitem({
  112. detail
  113. }) {
  114. let showType = null;
  115. switch (detail) {
  116. case "家纺城通告":
  117. showType = '官方'
  118. break;
  119. case "合作商通告":
  120. showType = '商户'
  121. break;
  122. case "团队通告":
  123. showType = '团队'
  124. break;
  125. default:
  126. showType = ''
  127. break;
  128. }
  129. this.setData({
  130. showType
  131. });
  132. this.getList();
  133. },
  134. /**
  135. * 生命周期函数--监听页面初次渲染完成
  136. */
  137. onReady: function () {
  138. },
  139. /**
  140. * 生命周期函数--监听页面显示
  141. */
  142. onShow: function () {
  143. this.getList()
  144. },
  145. /**
  146. * 生命周期函数--监听页面隐藏
  147. */
  148. onHide: function () {
  149. },
  150. /**
  151. * 生命周期函数--监听页面卸载
  152. */
  153. onUnload: function () {
  154. },
  155. /**
  156. * 页面相关事件处理函数--监听用户下拉动作
  157. */
  158. onPullDownRefresh: function () {
  159. },
  160. /**
  161. * 页面上拉触底事件的处理函数
  162. */
  163. onReachBottom: function () {
  164. },
  165. /**
  166. * 用户点击右上角分享
  167. */
  168. onShareAppMessage: function () {
  169. }
  170. })