石广澎
2024-07-23 87f34aa6e95d08d1b061bfa201813af34b677a1b
1
2
3
4
5
6
7
8
9
10
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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
133
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<template>
    <view id="content">
        <block v-if="youHuiInfo">
            <view class="box bg-fff u-m-t-20">
                <view class="status-box u-text-center">
                    <image class="icon-success" src="/static/paySuccess.png" mode=""></image>
                    <view class="u-font-32 font-bold u-m-t-10" style="color: #14AF0D;">支付成功</view>
                </view>
                <view class="shop-info">
                    <view class="u-text-center u-font-32 color-666">{{youHuiInfo.shopName}}</view>
                    <view class="u-text-center u-m-t-20">
                        <text class="u-font-30 lh-1">¥</text>
                        <text class="u-font-money lh-1">{{$u.priceFormat(youHuiInfo.payMoney/100, 2)}}</text>
                    </view>
                </view>
                <view class="u-flex u-m-t-30 u-font-30">
                    <view class="color-999 u-flex">
                        <view class="label">应付金额</view>
                    </view>
                    <view class="u-flex-1 u-text-right">¥{{$u.priceFormat(youHuiInfo.money/100, 2)}}</view>
                </view>
<!--                <view class="u-flex u-m-t-16 u-font-30">
                    <view class="color-999 u-flex">
                        <view class="label" style="color: #F69249;">使用积分</view>
                    </view>
                    <view class="u-flex-1 u-text-right" style="color: #F69249;">{{youHuiInfo.score}}积分<text
                            v-if="youHuiInfo.score>0">抵扣{{$u.priceFormat(youHuiInfo.scoreDkPrice/100, 2)}}元</text>
                    </view>
                </view>-->
                <view v-if="youHuiInfo.couponDkPrice!=0" class="u-flex u-m-t-16 u-font-30">
                    <view class="color-999 u-flex">
                        <view class="label">优惠券</view>
                    </view>
                    <view class="u-flex-1 u-text-right">¥{{$u.priceFormat(youHuiInfo.couponDkPrice/100, 2)}}</view>
                </view>
                <view class="u-flex u-m-t-16 u-font-30">
                    <view class="color-999 u-flex">
                        <view class="label">支付时间</view>
                    </view>
                    <view class="u-flex-1 u-text-right">{{$u.timeFormat(Number(new Date()), 'yyyy.mm.dd hh:MM:ss')}}
                    </view>
                </view>
            </view>
            <view v-if="couponList.length" class="box bg-fff u-m-t-20">
                <view class="u-font-32 font-bold u-m-b-30">已获取优惠券<text style="color: #E93F33;">{{couponList.length}}</text>张
                </view>
                <view v-for="(item,i) in couponList" :key="i" class="coupon">
                    <view class="num">
                        <view>
                            <text class="unit">¥</text>
                            <text class="money">{{parseFloat(item.discount/100)}}</text>
                        </view>
                        <view class="condition">满{{parseFloat(item.threshold_value/100)}}元使用</view>
                    </view>
                    <view class="info">
                        <view class="title">{{item.name}}</view>
                        <view v-if="item.validityDay" class="validity">
                            有效期:领取后{{item.validityDay}}天</view>
                        <view v-else class="validity">
                            有效期至:{{$u.timeFormat(item.out_time||item.validityEndTime, 'yyyy-mm-dd hh:MM')}}</view>
                    </view>
                </view>
            </view>
 
            <view :url="jumpUrl" class="btn-box">
                <u-button @click="clickDone" text="完成" type="success" plain shape="circle"></u-button>
            </view>
        </block>
        <block v-else>
            <view class="box bg-fff">
                <view class="shop-info">
                    <view class="u-text-center"><text class="u-font-36">¥</text><text
                            class="u-font-money">{{$u.priceFormat(orderInfo.payMoney/100, 2)}}</text>
                    </view>
                    <view class="u-text-center u-font-30">{{orderInfo.shopName}}</view>
                </view>
                <view class="u-flex u-m-t-30 u-font-30">
                    <view class="color-999 u-flex">
                        <view class="label">应付金额</view>:
                    </view>
                    <view class="u-flex-1">¥{{$u.priceFormat(orderInfo.orderPrice/100, 2)}}</view>
                </view>
<!--                <view class="u-flex u-m-t-30 u-font-30">
                    <view class="color-999 u-flex">
                        <view class="label">使用积分</view>:
                    </view>
                    <view class="u-flex-1">{{orderInfo.payIntegral}}积分<text
                            v-if="orderInfo.payIntegral>0">抵扣{{$u.priceFormat(orderInfo.integralMoney/100, 2)}}元</text>
                    </view>
                </view>-->
                <view  class="u-flex u-m-t-30 u-font-30">
                    <view class="color-999 u-flex">
                        <view class="label">优惠券</view>:
                    </view>
                    <view class="u-flex-1">¥{{$u.priceFormat(orderInfo.couponFace/100, 2)}}</view>
                </view>
                <view class="u-flex u-m-t-30 u-font-30">
                    <view class="color-999 u-flex">
                        <view class="label">支付时间</view>:
                    </view>
                    <view class="u-flex-1">{{$u.timeFormat(orderInfo.createTime, 'yyyy.mm.dd hh:MM:ss')}}</view>
                </view>
            </view>
            <view class="btn-box">
                <u-button @click="clickDone" text="完成" type="success" plain shape="circle"></u-button>
            </view>
        </block>
 
    </view>
</template>
 
<script>
    import {
        getWxOrderInfo,
    } from 'common/api/index'
    export default {
        data() {
            return {
        plat: this.$utils.getPlat(),
                info: {
                    bankCardName: '',
                    totalDiscount: 0,
                    dayMax: 0,
                    numOfMin: 0,
                    numOfDay: 0,
                    numOfUser: 0,
                    actRules: ''
                },
                bankCardStyle: {
                    color: '',
                    logo: '',
                },
                orderId: null,
                couponList: [],
                jumpUrl: null,
                youHuiInfo: {},
                orderInfo: {
                    payMoney: 0, //实付金额
                    shopName: '', //门店名称
                    orderPrice: 0, //订单金额
                    payIntegral: 0, //使用积分数量
                    integralMoney: 0, //积分抵扣金额
                    couponFace: 0, //优惠券减免
                    createTime: Number(new Date())
                },
                join: true,
            };
        },
        onLoad(opt) {
            if (uni.getStorageSync("bankCardStyle")) {
                this.bankCardStyle = uni.getStorageSync("bankCardStyle")
            }
 
            if (opt.youHuiInfo) {
                this.youHuiInfo = JSON.parse(opt.youHuiInfo)
            }
            if (opt.orderId) {
                this.orderId = opt.orderId
                /*orderRefBrushNode({
                    orderId: this.orderId
                }).then(res => {
                    this.couponList = res.coupIdsMap || []
                })*/
            }
        },
        onReady() {
            const query = uni.createSelectorQuery().in(this);
            let mchData = {
                action: 'onIframeReady',
                displayStyle: 'SHOW_CUSTOM_PAGE',
                height: 861
            }
            let postData = JSON.stringify(mchData)
            parent.postMessage(postData, 'https://payapp.weixin.qq.com')
            //获取参数
            var sub_mch_id = this.getQueryString("sub_mch_id"); //特约商户号
            var out_trade_no = this.getQueryString("out_trade_no"); //商户订单号
            var check_code = this.getQueryString("check_code"); //md5 校验码
            if (!this.youHuiInfo) {
                getWxOrderInfo({
                    sub_mch_id: sub_mch_id,
                    out_trade_no: out_trade_no,
                    check_code: check_code,
                }).then(res => {
                    this.orderInfo = res
                    this.$nextTick(() => {
                        query.select('#content').boundingClientRect(rect => {
                            const height = rect.height * (640 / rect.width);
                            let mchData = {
                                action: 'onIframeReady',
                                displayStyle: 'SHOW_CUSTOM_PAGE',
                                height: height
                            }
                            let postData = JSON.stringify(mchData)
                            parent.postMessage(postData, 'https://payapp.weixin.qq.com')
                        }).exec();
                    })
                })
            }
 
        },
        methods: {
            getQueryString(name) {
                var query = window.location.search.substring(1);
                var vars = query.split("&");
                for (var i = 0; i < vars.length; i++) {
                    var pair = vars[i].split("=");
                    if (pair[0] == name) {
                        return pair[1];
                    }
                }
                return null;
            },
            clickDone() {
        let browser = navigator.userAgent.toLowerCase();
        if (browser.match(/Alipay/i) == "alipay") {
          console.log("支付宝app的浏览器");
          //这个可以关闭安卓系统的手机
          document.addEventListener("AlipayJSBridgeReady", function () {
                AlipayJSBridge.call("closeWindow");
              },
              false
          );
          //这个可以关闭ios系统的手机
          AlipayJSBridge.call('closeWebview'); //支付宝
        } else if (browser.match(/MicroMessenger/i) == "micromessenger") {
          //这个可以关闭安卓系统的手机
          document.addEventListener("WeixinJSBridgeReady", function () {
                WeixinJSBridge.call("closeWindow");
              },
              false
          );
          //这个可以关闭ios系统的手机
          WeixinJSBridge.call("closeWindow");
        } else {
          console.log("其它浏览器");
          window.opener = null;             //如果没有这行和下面的一行则会出现上面的第二个询问框。
          window.open(' ', '_self', ' ');
          window.close()
        }
            },
            doJump() {
                var mchData = {
                    action: 'jumpOut',
                    jumpOutUrl: this.jumpUrl //跳转的页面
                }
                var postData = JSON.stringify(mchData)
                parent.postMessage(postData, 'https://payapp.weixin.qq.com')
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .status-box {
        padding: 50rpx 0;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
 
    .icon-success {
        width: 144rpx;
        height: 98rpx;
    }
 
    .box {
        margin: 0 30rpx;
        padding: 30rpx;
        border-radius: 15rpx;
    }
 
    .u-font-money {
        font-size: 72rpx;
        font-weight: bold;
    }
 
    .shop-info {
        border-bottom: 1rpx dashed #999;
        padding-bottom: 30rpx;
    }
 
    .btn-box {
        width: 300rpx;
        padding: 30rpx;
        margin: 0 auto;
    }
 
    .label {
        width: 130rpx;
        text-align-last: justify;
        text-align: justify;
    }
 
    .coupon {
        width: 638rpx;
        height: 172rpx;
        background-image: url('~@/static/pay-by-card-coupon.png');
        background-size: cover;
        margin: 10rpx auto 20rpx;
        display: flex;
        align-items: center;
    }
 
    .num {
        color: #D31F28;
        margin-top: 14rpx;
        width: 180rpx;
        height: 130rpx;
        text-align: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        border-right: 1rpx dashed #FA969A;
    }
 
    .unit {
        font-size: 36rpx;
        font-weight: 900;
    }
 
    .money {
        line-height: 1;
        font-size: 64rpx;
        font-weight: 900;
    }
 
    .condition {
        font-size: 20rpx;
        font-weight: 400;
    }
 
    .info {
        width: 457rpx;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 0 20rpx;
    }
 
    .title {
        font-size: 32rpx;
        font-weight: 400;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        /* white-space:nowrap; */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
 
    .validity {
        margin-top: 15rpx;
        font-size: 24rpx;
        font-weight: 400;
        color: #999;
    }
 
    .card-logo {
        width: 80rpx;
        height: 80rpx;
        margin-right: 20rpx;
    }
 
    .lh-1 {
        line-height: 1;
    }
</style>