index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. let list = processingData.annunciateCheckdate(res.data),
  72. data = [];
  73. if (this.data.pageNumber == 1) {
  74. data = processingData.imageType(list, 'cover');
  75. } else {
  76. let L = this.data.annunciateList;
  77. data = L.concat(processingData.imageType(list, 'cover'));
  78. }
  79. this.setData({
  80. annunciateList: data,
  81. pageTotal: res.pageTotal
  82. })
  83. })
  84. },
  85. /* 历史发布修改 */
  86. toChang(e) {
  87. const {
  88. index
  89. } = e.currentTarget.dataset;
  90. wx.navigateTo({
  91. url: './newAndChange?id=' + this.data.annunciateList[index].tnoticeid,
  92. });
  93. },
  94. /* 查询数据 */
  95. toQueryData(e) {
  96. const {
  97. index
  98. } = e.currentTarget.dataset;
  99. wx.navigateTo({
  100. url: './glanceover?id=' + this.data.annunciateList[index].tnoticeid,
  101. })
  102. },
  103. /* 发布公告 */
  104. toAnnounce() {
  105. wx.navigateTo({
  106. url: '/pages/annunciate/newAndChange',
  107. })
  108. },
  109. /* tab切换 */
  110. setIndex({
  111. detail
  112. }) {
  113. if (detail == this.data.tabsIndex) return;
  114. this.setData({
  115. tabsIndex: detail
  116. });
  117. this.initializePage();
  118. this.getList();
  119. },
  120. /* tabs回调 */
  121. tabsSelectedIitem({
  122. detail
  123. }) {
  124. let showType = null;
  125. switch (detail) {
  126. case "家纺城通告":
  127. showType = '官方'
  128. break;
  129. case "合作商通告":
  130. showType = '商户'
  131. break;
  132. case "团队通告":
  133. showType = '团队'
  134. break;
  135. default:
  136. showType = ''
  137. break;
  138. }
  139. this.setData({
  140. showType
  141. });
  142. this.initializePage();
  143. this.getList();
  144. },
  145. /* 初始化分页数据 */
  146. initializePage() {
  147. this.setData({
  148. pageNumber: 1,
  149. pageTotal: 1
  150. })
  151. },
  152. /**
  153. * 生命周期函数--监听页面初次渲染完成
  154. */
  155. onReady: function () {
  156. },
  157. /**
  158. * 生命周期函数--监听页面显示
  159. */
  160. onShow: function () {
  161. this.getList()
  162. },
  163. /**
  164. * 生命周期函数--监听页面隐藏
  165. */
  166. onHide: function () {
  167. },
  168. /**
  169. * 生命周期函数--监听页面卸载
  170. */
  171. onUnload: function () {
  172. },
  173. /**
  174. * 页面相关事件处理函数--监听用户下拉动作
  175. */
  176. onPullDownRefresh: function () {
  177. },
  178. /**
  179. * 页面上拉触底事件的处理函数
  180. */
  181. onReachBottom: function () {
  182. if (this.data.pageNumber < this.data.pageTotal) {
  183. this.setData({
  184. pageNumber: this.data.pageNumber + 1
  185. });
  186. this.getList()
  187. }
  188. },
  189. /**
  190. * 用户点击右上角分享
  191. */
  192. onShareAppMessage: function () {
  193. }
  194. })