const util = require("../../../utils/util.js");
const qrcode = require('../../../utils/qrcode.js');
import { base64src } from '../../../utils/base64src.js';
const app = getApp();

Page({
  data: {
    invitecode:'',
    islogin:false,
    invitePrice: util.config.invitePrice
  },
  onLoad(invitecode) {
    if (util.isEmpty(invitecode)){
      util.showTips("分享的页面不正确，缺少参数。");
      return false;
    }
    let that = this;
    invitecode['nickname'] = decodeURIComponent(invitecode['nickname']);
    invitecode['commentContent'] = decodeURIComponent(invitecode['commentContent']);
    invitecode['commentSource'] = decodeURIComponent(invitecode['commentSource']);
    
    if (invitecode.code) {
      wx.setStorageSync("WX-invite", invitecode.code);
    }
    if (!util.isEmpty(invitecode.avatar)) {
      wx.downloadFile({
        url: util.config.apiServer + "file.do?url=" + invitecode.avatar, // 仅为示例，并非真实的资源
        success(ret) {
          if (ret.statusCode === 200) {
            invitecode.avatar = ret.tempFilePath;
          }
          that.setData({ invitecode, islogin: !util.isObjEmpty(app.globalData.userInfo) });
        }
      });
    }else{
      userInfo.avatar = "/images/default_logo.jpg";
      this.setData({ invitecode, islogin: !util.isObjEmpty(app.globalData.userInfo) });
    }
  }
})