<template>
  <view>

  </view>
</template>

<script>
  import {
    strToParams
  } from '@/utils/tools';
  export default {
    data() {
      return {

      };
    },
    onLoad(e) {
      const scene = strToParams(decodeURIComponent(e.scene))
      console.log(scene);
      if (scene.product) {
        uni.redirectTo({
          url: '/pages/product_details/index?skuId=' + scene.product
        })
        uni.setStorageSync('INVITE_CODE', scene.code)
      } else if (scene.order_pre) {
        setTimeout(async () => {
          uni.showLoading({
            title: '加载中',
            mask: true
          });
          const obj = {
            id: scene.order_pre
          }
          const {
            order_id
          } = await this.$api.post(`/v1/order-pre/order`, obj)
          uni.hideLoading()
          uni.redirectTo({
            url: '/pages/order_details/index?id=' + order_id
          })
        }, 1000)
      }else if(scene.invite_code){
        uni.redirectTo({
          url: '/pages/index/index'
        })
        uni.setStorageSync('INVITE_CODE', scene.invite_code)
      }
    },
  }
</script>

<style lang="scss">

</style>
