<template>
  <view class="pageBg">
    <view class="success_box">
      <image src="http://139.9.103.171:1888/img/image/success.png"></image>
      <text v-if="state">{{state==1?"支付成功":"支付失败"}}</text>
      <view class="price"><text>￥</text><text>{{amount}}</text></view>
      <view class="btn_group">
        <view class="go_home btn" @tap="goHome">返回首页</view>
        <view class="go_order_detail btn" @tap="goOrderDetail">查看订单</view>
      </view>
    </view>

  </view>
</template>
<script>

export default {
  data() {
    return {
      tradeNo: '',
      amount: '',
      payFlag: '',
      state: '',
      orderSns: ''
    }
  },

  methods: {

    onLoadPage(options) {
	  wx.hideShareMenu();
      console.log(options);
      this.payFlag = options.payFlag;
      this.state = options.state;
      this.tradeNo = options.tradeNo;
      this.amount = options.amount;
      this.orderSns = options.orderSns;
      this.wxappFinish();
    },

    async wxappFinish() {
      let data = {};
      data.tradeNo = this.tradeNo;
      data.status=this.state;
      let res = await this.$api.wxappFinish(data);
      console.log(res);
    },

    goHome() {
      uni.switchTab({
        url: '/pages/home'
      });
    },
    goOrderDetail() {
      if (this.payFlag == this.$global.payFlag.normal) {
        this.$util.refreshPage([
          'pages/wode/wode'
        ])
      }else if (this.payFlag == this.$global.payFlag.order) {
        this.$util.refreshPage([
          'pages/wode/wode',
          '/pagesM/pages/mine_order_list'
        ])
      }
      uni.redirectTo({
        url: "/pagesM/pages/order_detail?orderSns=" + this.orderSns
      });
      
    }
  },
}
</script>

<style lang="scss" scoped>
.success_box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  image {
    width: 100upx;
    height: 100upx;
    padding-top: 110upx;
  }
  text {
    color: #353535;
    font-size: 30upx;
    margin-top: 20upx;
  }
  .price {
    color: #333333;
    margin-top: 50upx;
    text:first-child {
      font-size: 30upx;
    }
    text:last-child {
      font-size: 60upx;
    }
  }
  .btn_group {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-top: 140upx;
    width: 520upx;
    justify-content: space-between;
    .btn {
      border-radius: 10upx;
      font-size: 30upx;
      padding: 15upx 50upx;
      letter-spacing: 1upx;
    }
    .go_home {
      background: #fff;
      color: #333;
      border: 1upx solid #ccc;
    }
    .go_order_detail {
      background: $dt-color-primary;
      color: #fff;
    }
  }
}
</style>
