home.ts 1.75 KB
// index.ts// app.ts
import { HTTPService as HTTP } from "../../services/HTTPService";
// 获取应用实例
import minaEnv from "../../utils/minaEnv";
import { API_CONST } from "./../../api/smartElectric";
// @ts-ignore
const app = getApp<IAppOption>();
Page({
  data: {
    url: "",
    userInfoObj: {}
  },
  onLoad() {
    // this.__getUserInfoDetail()
    const power_user_info: any = wx.getStorageSync("power_user_info")
    console.log(power_user_info,'power_user_info')
    
    if(Object.entries(power_user_info).length>0&&power_user_info){
      const arr = power_user_info.userName.split("")
      const lastName = arr[arr.length-1]
      const dataTitle = "徽辰智电"
      console.log(arr,'pppppparrr')
      this.setData({
        userInfoObj:  {...power_user_info,lastName,dataTitle}
      })
    }
  },
  handleGetMessage(e: any) {
    console.log(e, 'handleGetMessagehandleGetMessage')
  },
  loadSuccess() {
    console.log('网页加载成功!!!')
  },
  onShow() {
    // let pages = getCurrentPages();
    // console.log(pages)
  },
  gotoAcount() {
    const userInfoStr = JSON.stringify(this.data.userInfoObj)
    wx.navigateTo({ url: `/pages/acount/acount?userInfoStr=${userInfoStr}` })
  },
  onReady() { },
  __getUserInfoDetail() {
    HTTP.GET({
      ...API_CONST.home.userInfoDetail,
      payload: {
        corpCode: "hczd",
        cookieFlag: true
      }
    }).then((res: any) => {
      console.log(res, 'rrreeesss')
      const arr = res.data.dataTitle.split("")
      const lastName = arr[arr.length-1]
      console.log(arr,'pppppparrr')
      if (res.success) {
        this.setData({
          userInfoObj:  {...res.data,lastName}
        })
      }else {
        this.setData({
          userInfoObj: {}
        })
      }
    })
  },

});