myNotice.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. const app = require('../../utils/util.js');
  2. const tools = require('../../utils/tools.js');
  3. Page({
  4. data: {
  5. active: 0,
  6. wdArr: [],
  7. ydArr: [],
  8. showNull: false,
  9. showNull1: false
  10. },
  11. getNotice(){
  12. wx.showLoading();
  13. wx.getStorage({
  14. key: 'noticeArr',
  15. success:(res)=>{
  16. console.log(res);
  17. wx.hideLoading();
  18. this.setData({
  19. wdArr:res.data.data.notReadAfficheList,
  20. ydArr:res.data.data.readAfficheList,
  21. showNull:res.data.data.notReadAfficheList.length>0?false:true,
  22. showNull1:res.data.data.readAfficheList.length>0?false:true,
  23. })
  24. },
  25. fail:()=>{
  26. wx.hideLoading();
  27. }
  28. })
  29. },
  30. getNoticeArr(sessionKey,active){
  31. console.log("getNoticeArr");
  32. wx.showLoading();
  33. wx.request({
  34. url: app.globalData.publicUrl + '/wx/eduNoticeSee/afficheLists',
  35. method: "post",
  36. data: {
  37. sessionKey: sessionKey,
  38. // isSee: 1
  39. // // isNotice: 0
  40. },
  41. success: (res) => {
  42. console.log(res);
  43. wx.hideLoading();
  44. if (res.data.code == 0) {
  45. if(active){
  46. console.log("1");
  47. if(active==0){
  48. this.setData({
  49. wdArr:res.data.data.notReadAfficheList,
  50. ydArr:res.data.data.readAfficheList,
  51. showNull1:res.data.data.readAfficheList.length>0?false:true,
  52. })
  53. }else{
  54. this.setData({
  55. wdArr:res.data.data.notReadAfficheList,
  56. ydArr:res.data.data.readAfficheList,
  57. showNull:res.data.data.notReadAfficheList.length>0?false:true,
  58. })
  59. }
  60. }else{
  61. console.log("2");
  62. this.setData({
  63. wdArr:res.data.data.notReadAfficheList,
  64. ydArr:res.data.data.readAfficheList,
  65. showNull:res.data.data.notReadAfficheList.length>0?false:true,
  66. showNull1:res.data.data.readAfficheList.length>0?false:true,
  67. })
  68. }
  69. } else {
  70. if(active){
  71. if(active==0){
  72. this.setData({
  73. wdArr:res.data.data.notReadAfficheList,
  74. ydArr:res.data.data.readAfficheList,
  75. showNull1:res.data.data.readAfficheList.length>0?false:true,
  76. })
  77. }else{
  78. this.setData({
  79. wdArr:res.data.data.notReadAfficheList,
  80. ydArr:res.data.data.readAfficheList,
  81. showNull:res.data.data.notReadAfficheList.length>0?false:true,
  82. })
  83. }
  84. }
  85. }
  86. },
  87. fail: () => {
  88. console.log("fal");
  89. console.log("active",typeof active);
  90. wx.hideLoading();
  91. wx.showModal({
  92. showCancel: false,
  93. content: "网络错误"
  94. })
  95. // if(typeof active=="number"){
  96. // if(active==0){
  97. // console.log("weidu");
  98. // this.setData({
  99. // wdArr:[],
  100. // showNull:true,
  101. // })
  102. // }else{
  103. // this.setData({
  104. // ydArr:[],
  105. // showNull1:true,
  106. // })
  107. // }
  108. // }
  109. }
  110. })
  111. },
  112. getArr(sessionKey) {
  113. wx.request({
  114. url: app.globalData.publicUrl + '/wx/eduNoticeSee/list',
  115. method: "post",
  116. data: {
  117. sessionKey: sessionKey,
  118. isSee: 1
  119. // isNotice: 0
  120. },
  121. success: (res) => {
  122. if (res.data.code == 0) {
  123. if (res.data.list.length !== 0) {
  124. this.setData({
  125. showNull: false,
  126. wdArr: res.data.list
  127. })
  128. } else {
  129. this.setData({
  130. wdArr: res.data.list,
  131. showNull: true
  132. })
  133. }
  134. } else {
  135. this.setData({
  136. showNull: true
  137. })
  138. }
  139. },
  140. fail: () => {
  141. this.setData({
  142. showNull: true
  143. })
  144. }
  145. })
  146. },
  147. getArr1(sessionKey) {
  148. wx.request({
  149. url: app.globalData.publicUrl + '/wx/eduNoticeSee/list',
  150. method: "post",
  151. data: {
  152. sessionKey: sessionKey,
  153. isSee: 0
  154. // isNotice: 0
  155. },
  156. success: (res) => {
  157. if (res.data.code == 0) {
  158. if (res.data.list.length !== 0) {
  159. this.setData({
  160. showNull1: false,
  161. ydArr: res.data.list
  162. })
  163. } else {
  164. this.setData({
  165. ydArr: res.data.list,
  166. showNull1: true
  167. })
  168. }
  169. } else {
  170. this.setData({
  171. showNull1: true
  172. })
  173. }
  174. },
  175. fail: () => {
  176. this.setData({
  177. showNull1: true
  178. })
  179. }
  180. })
  181. },
  182. async onChange(event) {
  183. console.log("onCHange");
  184. const sessionKey = await tools.checkSessionAndLogin();
  185. this.getNoticeArr(sessionKey,event.detail.index);
  186. },
  187. meRead(sessionKey, noticeId) {
  188. wx.request({
  189. url: app.globalData.publicUrl + '/wx/eduNoticeSee/edit',
  190. method: "post",
  191. data: {
  192. sessionKey: sessionKey,
  193. isSee: 0,
  194. noticeId: noticeId
  195. },
  196. success: () => {
  197. console.log("meRead",noticeId);
  198. this.getNoticeArr(sessionKey)
  199. }
  200. })
  201. },
  202. async btn(e) {
  203. console.log(e.currentTarget.dataset.item.id);
  204. let noticeId = e.currentTarget.dataset.item.id;
  205. const sessionKey = await tools.checkSessionAndLogin();
  206. this.meRead(sessionKey, noticeId);
  207. },
  208. async onLoad() {
  209. const sessionKey = await tools.checkSessionAndLogin();
  210. this.getNotice();
  211. //this.getArr(sessionKey);
  212. }
  213. })