index.js 5.2 KB

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