myNotice.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. const app = require('../../utils/util.js');
  2. const tools = require('../../utils/tools.js');
  3. // import WxValidate from '../../utils/WxValidate';
  4. Page({
  5. data: {
  6. active: 0,
  7. wdArr: [],
  8. ydArr: [],
  9. showNull: false,
  10. showNull1: false
  11. },
  12. getArr(sessionKey) {
  13. let _this = this;
  14. wx.request({
  15. url: app.globalData.publicUrl3 + '/wx/eduNoticeSee/list',
  16. method: "post",
  17. data: {
  18. sessionKey: sessionKey,
  19. isSee: 1,
  20. isNotice: 0
  21. },
  22. success: function (res) {
  23. if (res.data.code == 0) {
  24. if (res.data.list.length !== 0) {
  25. _this.setData({
  26. showNull: false,
  27. wdArr: res.data.list
  28. })
  29. } else {
  30. _this.setData({
  31. wdArr: res.data.list,
  32. showNull: true
  33. })
  34. }
  35. } else {
  36. _this.setData({
  37. showNull: true
  38. })
  39. }
  40. },
  41. fail: function () {
  42. _this.setData({
  43. showNull: true
  44. })
  45. }
  46. })
  47. },
  48. getArr1(sessionKey) {
  49. let _this = this;
  50. wx.request({
  51. url: app.globalData.publicUrl3 + '/wx/eduNoticeSee/list',
  52. method: "post",
  53. data: {
  54. sessionKey: sessionKey,
  55. isSee: 0,
  56. isNotice: 0
  57. },
  58. success: function (res) {
  59. if (res.data.code == 0) {
  60. if (res.data.list.length !== 0) {
  61. _this.setData({
  62. showNull1: false,
  63. ydArr: res.data.list
  64. })
  65. } else {
  66. _this.setData({
  67. ydArr: res.data.list,
  68. showNull1: true
  69. })
  70. }
  71. } else {
  72. _this.setData({
  73. showNull1: true
  74. })
  75. }
  76. },
  77. fail: function () {
  78. _this.setData({
  79. showNull1: true
  80. })
  81. }
  82. })
  83. },
  84. async onChange(event) {
  85. // var _this = this;
  86. if (event.detail.index == 1) {
  87. const sessionKey = await tools.checkSessionAndLogin();
  88. this.getArr1(sessionKey);
  89. // wx.checkSession({
  90. // success: () => {
  91. // console.log("我有缓存")
  92. // var sessionKey = wx.getStorageSync('sessionKey');
  93. // console.log(sessionKey)
  94. // if (sessionKey == "") {
  95. // wx.login({
  96. // success(res) {
  97. // console.log(res);
  98. // var code = res.code
  99. // wx.request({
  100. // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  101. // method: "get",
  102. // data: {
  103. // code
  104. // },
  105. // success: function (res) {
  106. // sessionKey = res.data.sessionKey;
  107. // wx.setStorageSync('sessionKey', res.data.sessionKey);
  108. // _this.getArr1(sessionKey);
  109. // }
  110. // })
  111. // }
  112. // })
  113. // } else {
  114. // _this.getArr1(sessionKey);
  115. // }
  116. // },
  117. // fail() {
  118. // console.log("我没有缓存并去登录请求")
  119. // wx.login({
  120. // success(res) {
  121. // console.log(res);
  122. // var code = res.code
  123. // wx.request({
  124. // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  125. // method: "get",
  126. // data: {
  127. // code
  128. // },
  129. // success: function (res) {
  130. // wx.setStorageSync('sessionKey', res.data.sessionKey);
  131. // var sessionKey = res.data.sessionKey;
  132. // _this.getArr1(sessionKey);
  133. // // _this.socketConnect(sessionKey);
  134. // }
  135. // })
  136. // }
  137. // })
  138. // }
  139. // })
  140. } else {
  141. const sessionKey = await tools.checkSessionAndLogin();
  142. this.getArr(sessionKey);
  143. // wx.checkSession({
  144. // success: () => {
  145. // console.log("我有缓存")
  146. // var sessionKey = wx.getStorageSync('sessionKey');
  147. // console.log(sessionKey)
  148. // if (sessionKey == "") {
  149. // wx.login({
  150. // success(res) {
  151. // console.log(res);
  152. // var code = res.code
  153. // wx.request({
  154. // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  155. // method: "get",
  156. // data: {
  157. // code
  158. // },
  159. // success: function (res) {
  160. // sessionKey = res.data.sessionKey;
  161. // wx.setStorageSync('sessionKey', res.data.sessionKey);
  162. // _this.getArr(sessionKey);
  163. // }
  164. // })
  165. // }
  166. // })
  167. // } else {
  168. // _this.getArr(sessionKey);
  169. // }
  170. // },
  171. // fail() {
  172. // console.log("我没有缓存并去登录请求")
  173. // wx.login({
  174. // success(res) {
  175. // console.log(res);
  176. // var code = res.code
  177. // wx.request({
  178. // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  179. // method: "get",
  180. // data: {
  181. // code
  182. // },
  183. // success: function (res) {
  184. // wx.setStorageSync('sessionKey', res.data.sessionKey);
  185. // var sessionKey = res.data.sessionKey;
  186. // _this.getArr(sessionKey);
  187. // // _this.socketConnect(sessionKey);
  188. // }
  189. // })
  190. // }
  191. // })
  192. // }
  193. // })
  194. }
  195. },
  196. meRead(sessionKey, noticeId) {
  197. var _this = this;
  198. wx.request({
  199. url: app.globalData.publicUrl3 + '/wx/eduNoticeSee/edit',
  200. method: "post",
  201. data: {
  202. sessionKey: sessionKey,
  203. isSee: 0,
  204. noticeId: noticeId
  205. },
  206. success: function (res) {
  207. _this.getArr(sessionKey)
  208. }
  209. })
  210. },
  211. async btn(e) {
  212. console.log(e.currentTarget.dataset.item.noticeId, "99999")
  213. let noticeId = e.currentTarget.dataset.item.noticeId;
  214. const sessionKey = await tools.checkSessionAndLogin();
  215. this.meRead(sessionKey, noticeId);
  216. // var _this = this;
  217. // wx.checkSession({
  218. // success: () => {
  219. // console.log("我有缓存")
  220. // var sessionKey = wx.getStorageSync('sessionKey');
  221. // console.log(sessionKey)
  222. // if (sessionKey == "") {
  223. // wx.login({
  224. // success(res) {
  225. // console.log(res);
  226. // var code = res.code
  227. // wx.request({
  228. // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  229. // method: "get",
  230. // data: {
  231. // code
  232. // },
  233. // success: function (res) {
  234. // sessionKey = res.data.sessionKey;
  235. // wx.setStorageSync('sessionKey', res.data.sessionKey);
  236. // _this.meRead(sessionKey, noticeId);
  237. // }
  238. // })
  239. // }
  240. // })
  241. // } else {
  242. // _this.meRead(sessionKey, noticeId);
  243. // }
  244. // },
  245. // fail() {
  246. // console.log("我没有缓存并去登录请求")
  247. // wx.login({
  248. // success(res) {
  249. // console.log(res);
  250. // var code = res.code
  251. // wx.request({
  252. // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  253. // method: "get",
  254. // data: {
  255. // code
  256. // },
  257. // success: function (res) {
  258. // wx.setStorageSync('sessionKey', res.data.sessionKey);
  259. // var sessionKey = res.data.sessionKey;
  260. // _this.meRead(sessionKey, noticeId);
  261. // // _this.socketConnect(sessionKey);
  262. // }
  263. // })
  264. // }
  265. // })
  266. // }
  267. // })
  268. },
  269. async onLoad () {
  270. const sessionKey = await tools.checkSessionAndLogin();
  271. this.getArr(sessionKey);
  272. // var _this = this;
  273. // wx.checkSession({
  274. // success: () => {
  275. // console.log("我有缓存")
  276. // var sessionKey = wx.getStorageSync('sessionKey');
  277. // console.log(sessionKey)
  278. // if (sessionKey == "") {
  279. // wx.login({
  280. // success(res) {
  281. // console.log(res);
  282. // var code = res.code
  283. // wx.request({
  284. // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  285. // method: "get",
  286. // data: {
  287. // code
  288. // },
  289. // success: function (res) {
  290. // sessionKey = res.data.sessionKey;
  291. // wx.setStorageSync('sessionKey', res.data.sessionKey);
  292. // _this.getArr(sessionKey);
  293. // }
  294. // })
  295. // }
  296. // })
  297. // } else {
  298. // _this.getArr(sessionKey);
  299. // }
  300. // },
  301. // fail() {
  302. // console.log("我没有缓存并去登录请求")
  303. // wx.login({
  304. // success(res) {
  305. // console.log(res);
  306. // var code = res.code
  307. // wx.request({
  308. // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
  309. // method: "get",
  310. // data: {
  311. // code
  312. // },
  313. // success: function (res) {
  314. // wx.setStorageSync('sessionKey', res.data.sessionKey);
  315. // var sessionKey = res.data.sessionKey;
  316. // _this.getArr(sessionKey);
  317. // // _this.socketConnect(sessionKey);
  318. // }
  319. // })
  320. // }
  321. // })
  322. // }
  323. // })
  324. }
  325. })