12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import {liveStatus, logicStatus} from "../../model/enum";
- import User from "../../model/user";
- import Api from "../../model/api";
- import {formatYMD, getDataSet, getEventParam} from "../../utils/utils";
- import Route from "../../model/route";
- Page({
- data: {
- liveStatusEnum: liveStatus,
- rows: [],
- messageTemplate: '',
- isFinish: false,
- },
- async bindLogin(e){
- let isLogin = getEventParam(e,"isLogin");
- if (isLogin){
- const res = await Api.getUserProjects();
- res.data = res.data.map(item => {
- item.teamStart = formatYMD(item.teamStart);
- item.teamEnd = formatYMD(item.teamEnd);
- return item;
- })
- this.setData({
- rows: res.data.reverse(),
- messageTemplate: res.messageTemplate,
- }, async () => {
- if (res.data.length == 1 && !this.data.isFinish) {
- let setting = await wx.getSetting({
- withSubscriptions: true,
- });
- // console.log('setting --> ', setting);
- const subscriptionsSetting = setting.subscriptionsSetting;
- if (subscriptionsSetting.itemSettings) {
- //如果执行了订阅操作(拒绝或允许),可直接跳转到详情页
- let e = {currentTarget: {dataset: {item: res.data[0]}}};
- this.toEdu(e);
- }
- // let e = {currentTarget: {dataset: {item: res.data[0]}}};
- // this.toEdu(e)
- }
- this.setData({
- isFinish: true,
- })
- })
- }
- },
- onTabItemTap(object) {
- this.setData({
- isFinish: false,
- })
- },
- toEdu(e) {
- const item = getDataSet(e, "item");
- if (item.isRegister) {
- const user = User.getUserInfoByLocal();
- if (!user.wechatOpenId || !user.msWechatOpenId) {
- // 如果没有绑定微信,或者发送订阅消息的openid是空的,执行绑定微信方法 -- 对应在app中完成微信绑定的情况
- User.bindWechat();
- }
- wx.requestSubscribeMessage({
- tmplIds: this.data.messageTemplate.split(","),
- })
- Route.toEduDetail(item.teamId, logicStatus.NO)
- } else {
- Route.toStuInfo(item.teamId, item.eduStuId)
- }
- },
- })
|