edu.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import {liveStatus, logicStatus} from "../../model/enum";
  2. import User from "../../model/user";
  3. import Api from "../../model/api";
  4. import {formatYMD, getDataSet, getEventParam} 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. async bindLogin(e){
  14. let isLogin = getEventParam(e,"isLogin");
  15. if (isLogin){
  16. const res = await Api.getUserProjects();
  17. res.data = res.data.map(item => {
  18. item.teamStart = formatYMD(item.teamStart);
  19. item.teamEnd = formatYMD(item.teamEnd);
  20. return item;
  21. })
  22. this.setData({
  23. rows: res.data.reverse(),
  24. messageTemplate: res.messageTemplate,
  25. }, async () => {
  26. if (res.data.length == 1 && !this.data.isFinish) {
  27. let setting = await wx.getSetting({
  28. withSubscriptions: true,
  29. });
  30. // console.log('setting --> ', setting);
  31. const subscriptionsSetting = setting.subscriptionsSetting;
  32. if (subscriptionsSetting.itemSettings) {
  33. //如果执行了订阅操作(拒绝或允许),可直接跳转到详情页
  34. let e = {currentTarget: {dataset: {item: res.data[0]}}};
  35. this.toEdu(e);
  36. }
  37. // let e = {currentTarget: {dataset: {item: res.data[0]}}};
  38. // this.toEdu(e)
  39. }
  40. this.setData({
  41. isFinish: true,
  42. })
  43. })
  44. }
  45. },
  46. onTabItemTap(object) {
  47. this.setData({
  48. isFinish: false,
  49. })
  50. },
  51. toEdu(e) {
  52. const item = getDataSet(e, "item");
  53. if (item.isRegister) {
  54. const user = User.getUserInfoByLocal();
  55. if (!user.wechatOpenId || !user.msWechatOpenId) {
  56. // 如果没有绑定微信,或者发送订阅消息的openid是空的,执行绑定微信方法 -- 对应在app中完成微信绑定的情况
  57. User.bindWechat();
  58. }
  59. wx.requestSubscribeMessage({
  60. tmplIds: this.data.messageTemplate.split(","),
  61. })
  62. Route.toEduDetail(item.teamId, logicStatus.NO)
  63. } else {
  64. Route.toStuInfo(item.teamId, item.eduStuId)
  65. }
  66. },
  67. })