buy-pay-ok.vue 3.11 KB
<template>
  <LayoutApp :show-back="true" title="支付成功">
    <div class="body">
      <div class="header">
        <i class="iconfont iconOk icon-class"></i>
      </div>
      <div class="title">支付成功</div>

      <div class="desc">如卖家原因导致交易失败,您可以获得相应赔偿金,具体金额参考《买家须知》。建议您设置支付宝账号作为赔偿收款账户,如未绑定支付宝账号视为放弃赔偿。</div>

      <div class="btn-wrap">
        <YohoButton :txt="authorizeFlag ? txt : txt1" class="btn-class" @click="onClick"></YohoButton>
      </div>

      <div class="info">
        <div class="item" @click="goHome">随便逛逛</div>
      </div>

      <div class="recommend" v-if="productList.length">
        <div class="recommend-title">为您推荐</div>
        <ProductList :list="productList"></ProductList>
      </div>
    </div>
  </LayoutApp>
</template>

<script>

import ProductList from '../list/components/productList';
import { createNamespacedHelpers } from 'vuex';
import { get } from 'lodash';

const { mapActions: mapProductAction } = createNamespacedHelpers('product');
const { mapActions: mapOrderConfirmAction } = createNamespacedHelpers('order/orderConfirm');

export default {
  name: 'BuyPayOk',
  props: ['productId', 'orderCode'],
  components: {
    ProductList
  },
  data() {
    return {
      txt: '返回首页',
      txt1: '绑定支付宝',
      authorizeFlag: false,
      productList: []
    };
  },
  activated() {
    if (this.productId) {
      this.fetchRecommendProduct({ productId: this.productId }).then(result => {
        this.productList = result;
      });
    }

    this.fetchAlipayStatus().then(result => {
      this.authorizeFlag = get(result, 'data.authorizeFlag', false);
    });
  },
  computed: {},
  methods: {
    ...mapProductAction(['fetchRecommendProduct']),
    ...mapOrderConfirmAction(['fetchAlipayStatus']),
    onClick() {
      if (this.authorizeFlag) {
        this.goHome();
      } else {
        this.goBindAccount();
      }
    },
    goHome() {
      this.$router.replace({
        name: 'ChannelPage'
      });
    },
    goBindAccount() {
      this.$router.replace({
        name: 'bindAccount',
        query: {
          back: 'ChannelPage'
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.body {
  height: 100%;
  padding-bottom: 140px;
  overflow-y: auto;
}

.header {
  margin-top: 80px;
  text-align: center;
}

.icon-class {
  font-size: 120px;
}

.btn-wrap {
  margin: 0 32px;
}

.btn-class {
  height: 88px;
  font-size: 32px;
  line-height: 88px;
}

.desc {
  width: 560px;
  margin: 60px auto;
  font-size: 24px;
  color: #999;
  text-align: center;
  line-height: 40px;
}

.title {
  font-size: 40px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 60px;
}

.info {
  font-size: 28px;
  display: flex;
  margin-top: 30px;
  margin-bottom: 66px;

  .item {
    width: 100%;
    text-align: center;
  }
}

.recommend {
  background: #f5f5f5;

  .recommend-title {
    font-weight: bold;
    font-size: 36px;
    line-height: 50px;
    padding: 20px 0 0;
    margin: 0 40px;
  }
}

</style>