index.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. this.setData({
  113. tabsIndex: detail
  114. });
  115. this.initializePage();
  116. this.getList();
  117. },
  118. /* tabs回调 */
  119. tabsSelectedIitem({
  120. detail
  121. }) {
  122. let showType = null;
  123. switch (detail) {
  124. case "家纺城通告":
  125. showType = '官方'
  126. break;
  127. case "合作商通告":
  128. showType = '商户'
  129. break;
  130. case "团队通告":
  131. showType = '团队'
  132. break;
  133. default:
  134. showType = ''
  135. break;
  136. }
  137. this.setData({
  138. showType
  139. });
  140. this.initializePage();
  141. this.getList();
  142. },
  143. /* 初始化分页数据 */
  144. initializePage() {
  145. this.setData({
  146. pageNumber: 1,
  147. pageTotal: 1
  148. })
  149. },
  150. /**
  151. * 生命周期函数--监听页面初次渲染完成
  152. */
  153. onReady: function () {
  154. },
  155. /**
  156. * 生命周期函数--监听页面显示
  157. */
  158. onShow: function () {
  159. this.getList()
  160. },
  161. /**
  162. * 生命周期函数--监听页面隐藏
  163. */
  164. onHide: function () {
  165. },
  166. /**
  167. * 生命周期函数--监听页面卸载
  168. */
  169. onUnload: function () {
  170. },
  171. /**
  172. * 页面相关事件处理函数--监听用户下拉动作
  173. */
  174. onPullDownRefresh: function () {
  175. },
  176. /**
  177. * 页面上拉触底事件的处理函数
  178. */
  179. onReachBottom: function () {
  180. if (this.data.pageNumber < this.data.pageTotal) {
  181. this.setData({
  182. pageNumber: this.data.pageNumber + 1
  183. });
  184. this.getList()
  185. }
  186. },
  187. /**
  188. * 用户点击右上角分享
  189. */
  190. onShareAppMessage: function () {
  191. }
  192. })