var sceneReadyBehavior = require('../../behavior-scene/scene-ready');
//var capate = require("G:/GUnityProject/WXXR/miniprogram/components/xr-classic-show/index.js");
Page({
  behaviors:[sceneReadyBehavior],
  data:{   
    captureState: 0,
    recordState: 0,
    captureQuality: 0.8,
    captureType: 'jpg',
    recordFPS: 30,
    recordScale: 1,
    recordWidth: 0,
    recordHeight: 0,
    recordBPS: 30000,
    sceneWidth: 0,
    sceneHeight: 0,

    zhaohuanstate:true,
    paizhaostate:false,
    luxiangstate:false,
    isStartluxiang:true,
    isCloseluxiang:false,

    uiShowModelView:false,
    uiMainView:true,
    uiShowNum:3,
    uiShowIndex:0,
 

    showModelName:'禺强',
    showModelIntroduce:'北海之渚中，有神，人面鸟身，珥两青蛇，践两赤蛇，名曰禺彊（禺强）',
    showModelPrice:'¥1.99',

    listShowModelNames:['禺强','AAA','BBB'],
    listShowModelIntroduces:['北海之渚中，有神，人面鸟身，珥两青蛇，践两赤蛇，名曰禺彊（禺强）','北海之渚中，有神，人面鸟身，珥两青蛇，践两赤蛇，名曰禺彊（AAA）','北海之渚中，有神，人面鸟身，珥两青蛇，践两赤蛇，名曰禺彊（BBB）'],
    listShowModelPrice:['¥1.99','¥2.99','¥3.99'],
    imgUrls:[
      'https://gss0.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D600%2C800/sign=8b20fba45e6034a829b7b087fb23656c/14ce36d3d539b60028f67d12eb50352ac65cb75e.jpg',
      'https://gss0.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D600%2C800/sign=3386e39a49fbfbeddc0c3e7948c0db0e/32fa828ba61ea8d3943606a1950a304e251f587a.jpg',
      'http://img04.sogoucdn.com/app/a/100520093/ca86e620b9e623ff-d72d635343d5bade-dcf2acda7a45cb44f172db138bdf8d2d.jpg',
     ],
    listShowModelDes:[
      {ModelName:'禺强',ModelIntroduce:'北海之渚中，有神，人面鸟身，珥两青蛇，践两赤蛇，名曰禺彊（禺强）',ModelPrice:'¥1.99'},
      {ModelName:'AAA',ModelIntroduce:'北海之渚中，有神，人面鸟身，珥两青蛇，践两赤蛇，名曰禺彊（AAA）',ModelPrice:'¥2.99'},
      {ModelName:'BBB',ModelIntroduce:'北海之渚中，有神，人面鸟身，珥两青蛇，践两赤蛇，名曰禺彊（BBB）',ModelPrice:'¥3.99'},
    ],
  },
  handleReady: function({detail}) {
    this.setData({
      sceneWidth: detail.width,
      sceneHeight: detail.height,
      recordWidth: detail.width,
      recordHeight: detail.height,
    });

  },
  handleProgress: function({detail}) {
    console.log('assets progress', detail);

    this.setData({progressInfo: `${~~(detail.progress * 100)} %\n`});
  },
  handleLoaded: function({detail}) {
    console.log('assets loaded', detail);

    this.setData({loaded: true});
  },
  handlestr: function({detail}) {
    //console.log('assets handlestr', detail);

    this.setData({
      loadedSaoMiao: true,
    });
  },
  
  clickZhaoHuan(e){
    this.setData({zhaohuanstate:true});
    this.setData({paizhaostate:false});
    this.setData({luxiangstate:false});
    this.setData({isStartluxiang:false});
  },
  clickPaiZhao(e){
    this.setData({zhaohuanstate:false});
    this.setData({paizhaostate:true});
    this.setData({luxiangstate:false});
    this.setData({isStartluxiang:false});

  
  },
  clickLuXiang(e){
     this.setData({luxiangstate:true});
      this.setData({zhaohuanstate:false});
      this.setData({paizhaostate:false});
  },
  ClickzhaohuanSS(e){
    this.setData({zhaohuanstate:false});
    this.setData({uiMainView:false});
    this.setData({uiShowModelView:true});
    this.setData({uiShowNum:1});
  },
  Clickpaizhaoss(e){
   
   // this.capture();
   /* this.scene.share.captureToFriends({
      fileType: 'png',
      quality: 0.8
    });
    //const base64 = scene.share.captureToDataURL();
    if(supported){
       // 判断当前客户端是否支持分享系统
   // const supported = scene.share.supported;
   await this.scene.share.captureToFriends({
    fileType: this.data.captureType,
    quality: this.data.captureQuality
  });
    }*/
    //capate.capate();
    //this.setData({paizhaostate:false});
    
    if (this.data.recordState) {
      wx.showToast({
        title: '录屏中不允许！',
      });
      return;
    }

    if (this.data.captureState) {
      wx.showToast({
        title: '等待上次完成！',
      });
      return;
    }

    this.setData({captureState: 1});
    // hack，其实应该等待异步方法完成
    setTimeout(() => {
      this.setData({captureState: 0});
    }, 1000);
    
  },
  Clickstartluxiang(e){
  
   this.setData({isStartluxiang:true});
   this.setData({recordState: 1});
  },
  Clickcloseluxiang(e){

    this.setData({isStartluxiang:false});
    this.setData({recordState: 0});
    wx.showToast({
      title: '视频录制完成',
    });
  },
  changeCaptureState(e) {
    if (this.data.recordState) {
      wx.showToast({
        title: '录屏中不允许！',
      });
      return;
    }

    if (this.data.captureState) {
      wx.showToast({
        title: '等待上次完成！',
      });
      return;
    }

    this.setData({captureState: 1});
    // hack，其实应该等待异步方法完成
    setTimeout(() => {
      this.setData({captureState: 0});
    }, 1000);
  },
  changeRecordState(e) {
    this.setData({recordState: this.data.recordState ? 0 : 1});
  },
  clickCloseUIShow(e){
    this.setData({uiMainView:true});
    this.setData({uiShowModelView:false});
  },
  clickShowLeft(e){
   
    var leftoldIndex = this.data.uiShowNum;
    if(leftoldIndex ==0){
      
    }
   
    switch(this.data.uiShowIndex){
      case 0:
        this.setData({uiShowIndex:2});
        break;
      case 2:
        this.setData({uiShowIndex:1});
        break;
      case 1:
        this.setData({uiShowIndex:0});
        break;
    }
  },
  clickShowRight(e){
    var  oldIndex = this.data.uiShowIndex;
    oldIndex = oldIndex+1;    
    var nIndex = oldIndex%3;
    this.setData({uiShowIndex:nIndex});  
  }

});

