/*
// 自定义组件
import '../../xr-custom/components/AutoRotate';
import '../../xr-custom/components/Particle/SystemProperty/BasicParticle';
import '../../xr-custom/components/Particle/index';
import '../../xr-custom/elements/xr-auto-rotate-touchable-gltf';
import '../../xr-custom/elements/xr-custom-particle';
// 自定义Geometry
import '../../xr-custom/assets/geometry-star';
import '../../xr-custom/assets/geometry-specialCylinder';
// 自定义材质
import '../../xr-custom/elements/xr-shining-star';
// 自定义effect
import '../../xr-custom/assets/effect-shining';
import '../../xr-custom/assets/effect-last-record-final';
*/
import { sup } from '../behavior-scene/scene-ready';
import list from './data/index';

let lastOpened = false;
let lastCount = 0;
let first = true;

Page({
  data: {
    list,
    root: '',
    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',
     ],
     sysheight:600,
     listShowModelDes:[
      {ModelName:'禺强',ModelIntroduce:'北海之渚中，有神，人面鸟身，珥两青蛇，践两赤蛇，名曰禺彊（禺强）',ModelPrice:'¥1.99'},
      {ModelName:'AAA',ModelIntroduce:'北海之渚中，有神，人面鸟身，珥两青蛇，践两赤蛇，名曰禺彊（AAA）',ModelPrice:'¥2.99'},
      {ModelName:'BBB',ModelIntroduce:'北海之渚中，有神，人面鸟身，珥两青蛇，践两赤蛇，名曰禺彊（BBB）',ModelPrice:'¥3.99'},
    ],
    products:[],
  },
  toupper:function(){
    console.log("触发了toupper");
   },
   onShow(){
 
   },
  /*onLoad() {
   // const scene = this.scene = detail.value;
    wx.getSystemInfo({//获取设备屏幕真实高度
      success: (result) => {
        var height = result.windowHeight;
        this.setData({
          sysheight:height
        });
      },
    });
    const that = this;
    wx.request({
      url: 'https://api-fat1.ghz-tech.com/miniprogram-shanhaijing/v1/product/listInfo',
      method:'POST',
      header:{
        'Content-Type':'application/json'
      },
      data:{
        topic:1
      },
      success:(res)=>{
        
          console.log('POST 请求成功', res.data);
          var products2 = res.data.data.products;
          console.log(' 商品列表 ',products2[0].desc);
          const newArray = [1, 2, 3, 4, 5];
          that.setData({products:products2});
          
          console.log(' 商品列表 ',this.data.products[0]);
  
        

      },
      
      fail:function(err){
        console.error('POST 请求失败', err);
      }
    });
    wx.login({
      success: (res) => {
        if (res.code) {
          // 获取到用户的临时登录凭证 code，可以发送给服务器
          console.log('用户登录成功，code：', res.code);
          wx.request({
            url: 'https://api-fat1.ghz-tech.com/miniprogram-shanhaijing/v1/order/prepay',
            method:'POST',
            header:{
              'Content-Type':'application/json'
            },
            data:{
              shop_cart:[{
                id:1,
                count:1
              }],
              js_code:res.code
            },
            success:function(res){
              console.log('POST 请求成功', res.data.data);
              var paySignStr = res.data.data.pay_Sign;
              console.log('即将调取微信支付',res.data.data.pay_Sign);
             
              wx.requestPayment({
                nonceStr: res.data.data.nonce_str,
                package: res.data.data.package,
                paySign: res.data.data.pay_sign,
                timeStamp: res.data.data.time_stamp,
                signType:res.data.data.sign_type,
                success(res){
                  console.log( '微信支付请求成功',res );
                  // 付款成功回调
                },
                fail(err){
                  console.log('微信支付请求失败',err);
                }
              })
            },
            fail:function(err){
              console.error('POST 请求失败', err);
            }
          });
        } else {
          console.log('登录失败！' + res.errMsg);
        }
      },
    });
  },*/
  onShareAppMessage() {
    return {
      title: 'XR-FRAME官方示例'
    }
  },
  onShareTimeline() {
    return {
      title: 'XR-FRAME官方示例'
    }
  },
  clickHandle(e) {
    wx.navigateTo({
    // url: '/pages/ar/plane-ar-v2-marker/plane-ar-v2-marker',
    url: '/pages/ar-classic/scene-classic-saomiao/index',
      success: () => {
      },
      fail: () => {
      },
    });
    return;
    
    if (!path) {
      return;
    }

    if (path === '/pages/scene-last-record/index') {
      this.handleLastRecord();
      return;
    }

    if (path) {
      
      wx.navigateTo({
        url: root + path + `?path=${path}`,
        success: () => {
        },
        fail: () => {
        },
      });
    }
  },
  clickTuJian(e){
    console.log('clickTuJianAAAAAAAAAA');
    wx.navigateTo({
      url: '/pages/ar-classic/scene-classic-tujian/index',
   //   url: 'pages/ar-classic/scene-classic-portal/index',
      success: () => {
      },
      fail: (err) => {
        console.log(' 跳转失败 ',err);
      },
    });
  },
  handleLastRecord: async function () {
    return;
    if (lastOpened) {
      return;
    }

    lastCount += 1;
    // if (Math.random() >= (0.34 + lastCount * 0.1)) {
    //   return;
    // }

    let root = this.data.root;
    lastOpened = true;

    wx.request({
      url: 'https://mmbizwxaminiprogram-1258344707.cos.ap-guangzhou.myqcloud.com/xr-frame/demo/xr-frame-team/last-gate.txt',
      success: function (res) {
        wx.showModal({
          title: '一把钥匙',
          content: res.data,
          confirmText: '探寻真实',
          cancelText: '放下钥匙',
          success: function(res) {
            if (res.cancel) {
              wx.onAppShow((result) => {
                lastOpened = false;
              });
              return;
            }

            wx.navigateTo({
              url: root + '/pages/scene-last-record/index',
              success: () => {
                wx.onAppShow((result) => {
                  lastOpened = false;
                });
              }
            });
          }
        });
      },
      fail: function (err) {
        lastOpened = false;
      }
    });
  },
});
