payment.vue 6.9 KB
Newer Older
M
maguohua 已提交
1 2 3 4 5 6 7 8 9
 <template>
    <div class="rating_page">
        <head-top head-title="在线支付" go-back='true'></head-top>
        <section class="show_time_amount">
        	<section>
                <header class="time_last">支付剩余时间</header>
                <p class="time">{{remaining}}</p>
                <footer class="order_detail" v-if="payDetail.resultData">
                    <span>详情</span>
M
update  
maguohua 已提交
10
                    <span>¥ {{cartPrice&&cartPrice.toFixed(2) || payDetail.resultData.orderInfo.orderAmount&&(payDetail.resultData.orderInfo.orderAmount/100).toFixed(2)}}</span>
M
maguohua 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
                </footer>   
            </section>
        </section>
        <div class="pay_way">选择支付方式</div>
        <section class="pay_way_list">
            <section class="pay_item">
                <div class="pay_icon_contaienr">
                    <div class="zhifubao">
                        
                    </div>
                    <span>支付宝</span>
                </div>
                <svg class="choose_icon" @click="payWay = 1" :class="{choosed_way: payWay == 1}">
                    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#select"></use>
                </svg>
            </section>
            <section class="pay_item">
                <div class="pay_icon_contaienr">
                    <svg>
                        <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#weixin"></use>
                    </svg>
                    <span>微信</span>
                </div>
                <svg class="choose_icon" @click="payWay = 2" :class="{choosed_way: payWay == 2}">
                    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#select"></use>
                </svg>
            </section>
        </section>
        <p class="determine" @click="confrimPay">确认支付</p>
        <alert-tip v-if="showAlert" @closeTip="closeTipFun" :alertText="alertText"></alert-tip>
    </div>
</template>

<script>
M
update  
maguohua 已提交
45
    import headTop from 'src/components/header/head'
M
maguohua 已提交
46
    import {mapState, mapMutations} from 'vuex'
M
update  
maguohua 已提交
47 48
    import {payRequest} from 'src/service/getData'
    import alertTip from 'src/components/common/alertTip'
M
maguohua 已提交
49 50 51 52 53

    export default {
      data(){
            return{
               	payDetail: false, //付款信息详情
M
update  
maguohua 已提交
54 55 56 57 58
                showAlert: false,
                alertText: null,
                payWay: 1,
                countNum: 900,
                gotoOrders: false,
M
maguohua 已提交
59 60 61 62 63 64 65 66
            }
        },
        components: {
            headTop,
            alertTip,
        },
        created(){
            this.initData();
M
update  
maguohua 已提交
67 68 69
            if (this.shopid) {
                this.CLEAR_CART(this.shopid);
            }
M
maguohua 已提交
70 71 72 73 74 75 76 77 78 79
        },
        mounted(){
            this.remainingTime();
        },
        beforeDestroy(){
            clearInterval(this.timer);
        },
        props:[],
        computed: {
            ...mapState([
M
update  
maguohua 已提交
80
                'orderMessage', 'userInfo', 'shopid', 'cartPrice'
M
maguohua 已提交
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
            ]),
            remaining: function (){
                let minute = parseInt(this.countNum/60);
                if (minute < 10) {
                    minute = '0' + minute;
                }
                let second = parseInt(this.countNum%60);
                if (second < 10) {
                    second = '0' + second;
                }
                return '00 : ' + minute + ' : ' + second;
            }
        },
        methods: {
            ...mapMutations([
                'CONFIRM_INVOICE', 'CLEAR_CART'
            ]),
            async initData(){
            	this.payDetail = await payRequest(this.orderMessage.order_id, this.userInfo.user_id);
                if (this.payDetail.message) {
                    this.showAlert = true;
                    this.alertText = this.payDetail.message;
                    return
                }
            },
            remainingTime(){
                clearInterval(this.timer);
                this.timer = setInterval(() => {
                    this.countNum --;
                    if (this.countNum == 0) {
                        clearInterval(this.timer);
                        this.showAlert = true;
                        this.alertText = '支付超时';
                    }
                }, 1000);
            },
            confrimPay(){
                this.showAlert = true;
                this.alertText = '当前环境无法支付,请打开官方APP进行付款';
                this.gotoOrders = true;
            },
            closeTipFun(){
                this.showAlert = false;
                if (this.gotoOrders) {
                    this.$router.push('/order');
                }
            },
        }
    }
</script>
  
<style lang="scss" scoped>
M
update  
maguohua 已提交
133
    @import 'src/style/mixin';
M
maguohua 已提交
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
  
    .rating_page{
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #f5f5f5;
        z-index: 204;
        padding-top: 1.95rem;
        p, span{
            font-family: Helvetica Neue,Tahoma,Arial;
        }
    }
    .show_time_amount{
		background-color: #fff;
        padding: .7rem;
        text-align: center;
        .time_last{
            @include sc(.6rem, #666);
            margin-top: 1rem;
        }
        .time{
            @include sc(1.5rem, #333);
            margin: .3rem 0 1rem;
        }
        .order_detail{
            @include fj;
            span{
                @include sc(.65rem, #666);
            }
            span:nth-of-type(2){
                color: #ff6000;
                font-weight: bold;
            }
        }
    }
    .pay_way{
        background-color: #f1f1f1;
        padding: 0 .7rem;
        @include sc(.7rem, #666);
        line-height: 1.8rem;
    }
    .pay_way_list{
        background-color: #fff;
        .pay_item{
            padding: .4rem .7rem;
            @include fj;
            align-items: center;
            line-height: 2.6rem;
            border-bottom: 0.025rem solid #f5f5f5;
            .pay_icon_contaienr{
                @include fj;
                align-items: center;
                .zhifubao{
                    @include wh(2rem, 2rem);
                    background: url(../../../images/zhifubao.png) no-repeat;
                    background-size: 100% 100%;
                    margin-right: .2rem;
                }
                svg{
                    @include wh(2rem, 2rem);
                    margin-right: .3rem;
                }
                span{
                    @include sc(.7rem, #666);
                }
            }
            .choose_icon{
                @include wh(1rem, 1rem);
                fill: #ccc;
            }
            .choosed_way{
                fill: #4cd964;
            }
        }
    }
    .determine{
        background-color: #4cd964;
        @include sc(.7rem, #fff);
        text-align: center;
        margin: 0 .7rem;
        line-height: 1.8rem;
        border-radius: 0.2rem;
        margin-top: 0.5rem;
        font-weight: bold;
    }
    
</style>