edu.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import {liveStatus, logicStatus} from "../../model/enum";
  2. import User from "../../model/user";
  3. import Api from "../../model/api";
  4. import {formatYMD, getDataSet} from "../../utils/utils";
  5. import Route from "../../model/route";
  6. Page({
  7. data: {
  8. liveStatusEnum: liveStatus,
  9. rows: [],
  10. messageTemplate: '',
  11. isFinish: false,
  12. },
  13. onLoad: function (options) {
  14. },
  15. async onShow(e) {
  16. const isLogin = User.isLogin();
  17. this.setData({
  18. isLogin,
  19. })
  20. if (isLogin) {
  21. const res = await Api.getUserProjects();
  22. res.data = res.data.map(item => {
  23. item.teamStart = formatYMD(item.teamStart);
  24. item.teamEnd = formatYMD(item.teamEnd);
  25. return item;
  26. })
  27. this.setData({
  28. rows: res.data,
  29. messageTemplate: res.messageTemplate,
  30. }, () => {
  31. if (res.data.length == 1 && !this.data.isFinish) {
  32. let e = {currentTarget: {dataset: {item: res.data[0]}}};
  33. this.toEdu(e)
  34. }
  35. this.setData({
  36. isFinish: true,
  37. })
  38. })
  39. }
  40. },
  41. onTabItemTap(object) {
  42. this.setData({
  43. isFinish: false,
  44. })
  45. },
  46. toLogin(e) {
  47. Route.toLogin();
  48. },
  49. toEdu(e) {
  50. const item = getDataSet(e, "item");
  51. if (item.isRegister) {
  52. wx.requestSubscribeMessage({
  53. tmplIds: this.data.messageTemplate.split(","),
  54. })
  55. Route.toEduDetail(item.teamId, logicStatus.NO)
  56. } else {
  57. Route.toStuInfo(item.teamId, item.eduStuId)
  58. }
  59. },
  60. })