<template>
  <view class="Mall4j page-pay-result">
    <view class="pay-det">
      <view class="img">
        <image
          class="pay-img"
          :src="sts===1?'/static/images/hook.png':'/static/images/payment-close.png'"
          alt=""
        />
      </view>
      <view class="error-text">
        {{ sts===1?'支付成功，感谢您的购买':'支付失败，请重新支付' }}
      </view>
    </view>
    <view class="pay-bottom">
      <view
        class="btn"
        @tap="toIndex"
      >
        返回首页
      </view>
      <view
        class="btn back"
        @tap="toOrderList"
      >
        查看订单
      </view>
    </view>
    <!-- 广告弹窗 -->
    <popup-ad
      v-model="popupadShow"
      :popup-info="popupInfo"
      :shop-id="0"
    />
  </view>
</template>

<script setup>
const orderIds = ref('')
const sts = ref(0) // 订单支付状态:  0失败; 1成功
onLoad((options) => {
  orderIds.value = options.orderIds
  sts.value = Number(options.sts)
  onGetPopupInfo()
})

// 获取弹窗广告信息
const popupadShow = ref(false)
const popupInfo = ref({})
const onGetPopupInfo = async () => {
  const info = await util.getPopupInfo({ pageType: 3, shopId: 0 })
  if (info) {
    popupInfo.value = info
    popupadShow.value = true
  }
}

// 去首页
const toIndex = () => {
  uni.switchTab({
    url: '/pages/index/index'
  })
}

// 去订单详情
const toOrderList = () => {
  uni.redirectTo({
    url: '/package-user/pages/order/order?orderStatus=0'
  })
}

</script>

<style lang="scss" scoped>
@use "./payment-result.scss";
</style>
