index.js 2.6 KB
import { IMG_URL } from "~/utils/constantData";
import ActivityApi from "~/api/activityApi/index";
import USERAPI from '~/api/usersApi/index'
import {taskLoginAndRegister} from '../../../common/common'
Page({
  data: {
    IMG_URL: IMG_URL,
    localData: {
      merchantName: '嘀加企微管家SCRM',
      WelfareOfficer: '业务顾问-小杨',
      code: 'not_open_code'
    }
  },

  onRoute(options) {
    taskLoginAndRegister({options,pages:'addFLG'}, this.getFLG(options.open==1))
    // console.log(options);
    // if (!options) {
    //   this.getFLG(false)
    //   return
    // }
    // if (options.merchantId) {
    //   options.pages = 'addFLG'
    //   const sessionId = wx.$storage.get('sessionId')
    //   if (!sessionId) {
    //     let para = {
    //       merchantId: options.merchantId,
    //       type: 1,
    //       pages:'addFLG'
    //     }
    //     let temp = encodeURIComponent(JSON.stringify(para))
    //     wx.navigateTo({
    //       url: '/packageStoreAssistant/packageAuth/pages/authentication/register/register?data=' + temp,
    //     });
    //   } else {
    //     const USERINFO = wx.$storage.get('userInfo')
    //     if (USERINFO.merchantId == options.merchantId) {
    //       USERAPI.checkSession().then(({
    //         code
    //       }) => {
    //         if (code == '0') {
    //           this.getFLG(true,options.merchantId)
    //         } else {
    //           wx.$router.reLaunch('/packageStoreAssistant/packageAuth/pages/authentication/login/login', options)
    //         }
    //       })
    //     } else {
    //       let para = {
    //         merchantId: options.merchantId,
    //         type: 1,
    //         pages:'addFLG'
    //       }
    //       let temp = encodeURIComponent(JSON.stringify(para))
    //       wx.navigateTo({
    //         url: '/packageStoreAssistant/packageAuth/pages/authentication/register/register?data=' + temp,
    //       });
    //     }
    //   }
    // }else{
    //   this.getFLG(options.open==1)
    // }
  },

  getFLG(open,merchantId) {
    const userStorage = wx.$storage.get("userInfo");
    let para = {
      merchantIds: [merchantId || userStorage.merchantId]
    }
    let localData = {}
    if(!open){
      this.setData({
        open
      })
      return
    }
    ActivityApi.getWelfareInfo(para).then(res => {
      if (res && res.length) {
        const item = res[0]
        localData = {
          merchantName: item.merchantName,
          WelfareOfficer: item.welfareManName,
          code: item.qrCode
        }
        this.setData({
          localData,
          open
        })
      }
    })
  }

})