|
| 1 | + <template> |
| 2 | + <div class="rating_page"> |
| 3 | + <head-top head-title="在线支付" go-back='true'></head-top> |
| 4 | + <section class="show_time_amount"> |
| 5 | + <section> |
| 6 | + <header class="time_last">支付剩余时间</header> |
| 7 | + <p class="time">{{remaining}}</p> |
| 8 | + <footer class="order_detail" v-if="payDetail.resultData"> |
| 9 | + <span>详情</span> |
| 10 | + <span>¥ {{(payDetail.resultData.orderInfo.orderAmount/100).toFixed(2)}}</span> |
| 11 | + </footer> |
| 12 | + </section> |
| 13 | + </section> |
| 14 | + <div class="pay_way">选择支付方式</div> |
| 15 | + <section class="pay_way_list"> |
| 16 | + <section class="pay_item"> |
| 17 | + <div class="pay_icon_contaienr"> |
| 18 | + <div class="zhifubao"> |
| 19 | + |
| 20 | + </div> |
| 21 | + <span>支付宝</span> |
| 22 | + </div> |
| 23 | + <svg class="choose_icon" @click="payWay = 1" :class="{choosed_way: payWay == 1}"> |
| 24 | + <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#select"></use> |
| 25 | + </svg> |
| 26 | + </section> |
| 27 | + <section class="pay_item"> |
| 28 | + <div class="pay_icon_contaienr"> |
| 29 | + <svg> |
| 30 | + <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#weixin"></use> |
| 31 | + </svg> |
| 32 | + <span>微信</span> |
| 33 | + </div> |
| 34 | + <svg class="choose_icon" @click="payWay = 2" :class="{choosed_way: payWay == 2}"> |
| 35 | + <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#select"></use> |
| 36 | + </svg> |
| 37 | + </section> |
| 38 | + </section> |
| 39 | + <p class="determine" @click="confrimPay">确认支付</p> |
| 40 | + <alert-tip v-if="showAlert" @closeTip="closeTipFun" :alertText="alertText"></alert-tip> |
| 41 | + </div> |
| 42 | +</template> |
| 43 | + |
| 44 | +<script> |
| 45 | + import headTop from '../../../components/header/head' |
| 46 | + import {mapState, mapMutations} from 'vuex' |
| 47 | + import {payRequest} from '../../../service/getData' |
| 48 | + import alertTip from '../../../components/common/alertTip' |
| 49 | +
|
| 50 | + export default { |
| 51 | + data(){ |
| 52 | + return{ |
| 53 | + payDetail: false, //付款信息详情 |
| 54 | + showAlert: false, |
| 55 | + alertText: null, |
| 56 | + payWay: 1, |
| 57 | + countNum: 900, |
| 58 | + gotoOrders: false, |
| 59 | + } |
| 60 | + }, |
| 61 | + components: { |
| 62 | + headTop, |
| 63 | + alertTip, |
| 64 | + }, |
| 65 | + created(){ |
| 66 | + this.initData(); |
| 67 | + this.CLEAR_CART(this.shopid); |
| 68 | + }, |
| 69 | + mounted(){ |
| 70 | + this.remainingTime(); |
| 71 | + }, |
| 72 | + beforeDestroy(){ |
| 73 | + clearInterval(this.timer); |
| 74 | + }, |
| 75 | + props:[], |
| 76 | + computed: { |
| 77 | + ...mapState([ |
| 78 | + 'orderMessage', 'userInfo', 'shopid' |
| 79 | + ]), |
| 80 | + remaining: function (){ |
| 81 | + let minute = parseInt(this.countNum/60); |
| 82 | + if (minute < 10) { |
| 83 | + minute = '0' + minute; |
| 84 | + } |
| 85 | + let second = parseInt(this.countNum%60); |
| 86 | + if (second < 10) { |
| 87 | + second = '0' + second; |
| 88 | + } |
| 89 | + return '00 : ' + minute + ' : ' + second; |
| 90 | + } |
| 91 | + }, |
| 92 | + methods: { |
| 93 | + ...mapMutations([ |
| 94 | + 'CONFIRM_INVOICE', 'CLEAR_CART' |
| 95 | + ]), |
| 96 | + async initData(){ |
| 97 | + this.payDetail = await payRequest(this.orderMessage.order_id, this.userInfo.user_id); |
| 98 | + if (this.payDetail.message) { |
| 99 | + this.showAlert = true; |
| 100 | + this.alertText = this.payDetail.message; |
| 101 | + return |
| 102 | + } |
| 103 | + }, |
| 104 | + remainingTime(){ |
| 105 | + clearInterval(this.timer); |
| 106 | + this.timer = setInterval(() => { |
| 107 | + this.countNum --; |
| 108 | + if (this.countNum == 0) { |
| 109 | + clearInterval(this.timer); |
| 110 | + this.showAlert = true; |
| 111 | + this.alertText = '支付超时'; |
| 112 | + } |
| 113 | + }, 1000); |
| 114 | + }, |
| 115 | + confrimPay(){ |
| 116 | + this.showAlert = true; |
| 117 | + this.alertText = '当前环境无法支付,请打开官方APP进行付款'; |
| 118 | + this.gotoOrders = true; |
| 119 | + }, |
| 120 | + closeTipFun(){ |
| 121 | + this.showAlert = false; |
| 122 | + if (this.gotoOrders) { |
| 123 | + this.$router.push('/order'); |
| 124 | + } |
| 125 | + }, |
| 126 | + } |
| 127 | + } |
| 128 | +</script> |
| 129 | + |
| 130 | +<style lang="scss" scoped> |
| 131 | + @import '../../../style/mixin'; |
| 132 | + |
| 133 | + .rating_page{ |
| 134 | + position: fixed; |
| 135 | + top: 0; |
| 136 | + left: 0; |
| 137 | + right: 0; |
| 138 | + bottom: 0; |
| 139 | + background-color: #f5f5f5; |
| 140 | + z-index: 204; |
| 141 | + padding-top: 1.95rem; |
| 142 | + p, span{ |
| 143 | + font-family: Helvetica Neue,Tahoma,Arial; |
| 144 | + } |
| 145 | + } |
| 146 | + .show_time_amount{ |
| 147 | + background-color: #fff; |
| 148 | + padding: .7rem; |
| 149 | + text-align: center; |
| 150 | + .time_last{ |
| 151 | + @include sc(.6rem, #666); |
| 152 | + margin-top: 1rem; |
| 153 | + } |
| 154 | + .time{ |
| 155 | + @include sc(1.5rem, #333); |
| 156 | + margin: .3rem 0 1rem; |
| 157 | + } |
| 158 | + .order_detail{ |
| 159 | + @include fj; |
| 160 | + span{ |
| 161 | + @include sc(.65rem, #666); |
| 162 | + } |
| 163 | + span:nth-of-type(2){ |
| 164 | + color: #ff6000; |
| 165 | + font-weight: bold; |
| 166 | + } |
| 167 | + } |
| 168 | + } |
| 169 | + .pay_way{ |
| 170 | + background-color: #f1f1f1; |
| 171 | + padding: 0 .7rem; |
| 172 | + @include sc(.7rem, #666); |
| 173 | + line-height: 1.8rem; |
| 174 | + } |
| 175 | + .pay_way_list{ |
| 176 | + background-color: #fff; |
| 177 | + .pay_item{ |
| 178 | + padding: .4rem .7rem; |
| 179 | + @include fj; |
| 180 | + align-items: center; |
| 181 | + line-height: 2.6rem; |
| 182 | + border-bottom: 0.025rem solid #f5f5f5; |
| 183 | + .pay_icon_contaienr{ |
| 184 | + @include fj; |
| 185 | + align-items: center; |
| 186 | + .zhifubao{ |
| 187 | + @include wh(2rem, 2rem); |
| 188 | + background: url(../../../images/zhifubao.png) no-repeat; |
| 189 | + background-size: 100% 100%; |
| 190 | + margin-right: .2rem; |
| 191 | + } |
| 192 | + svg{ |
| 193 | + @include wh(2rem, 2rem); |
| 194 | + margin-right: .3rem; |
| 195 | + } |
| 196 | + span{ |
| 197 | + @include sc(.7rem, #666); |
| 198 | + } |
| 199 | + } |
| 200 | + .choose_icon{ |
| 201 | + @include wh(1rem, 1rem); |
| 202 | + fill: #ccc; |
| 203 | + } |
| 204 | + .choosed_way{ |
| 205 | + fill: #4cd964; |
| 206 | + } |
| 207 | + } |
| 208 | + } |
| 209 | + .determine{ |
| 210 | + background-color: #4cd964; |
| 211 | + @include sc(.7rem, #fff); |
| 212 | + text-align: center; |
| 213 | + margin: 0 .7rem; |
| 214 | + line-height: 1.8rem; |
| 215 | + border-radius: 0.2rem; |
| 216 | + margin-top: 0.5rem; |
| 217 | + font-weight: bold; |
| 218 | + } |
| 219 | + |
| 220 | +</style> |
0 commit comments