gxd-uni-library-editx 1.0.102 → 1.0.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gxd-uni-library-editx",
3
- "version": "1.0.102",
3
+ "version": "1.0.103",
4
4
  "private": false,
5
5
  "description": "聚福宝基础插件专用库",
6
6
  "main": "index.js",
@@ -0,0 +1,1013 @@
1
+ <template>
2
+ <view class="xd-card-pay">
3
+ <slot></slot>
4
+ <xd-down-drawer
5
+ :show.sync="xdDownDrawer"
6
+ :isBodyClose="false"
7
+ :z-index="3000"
8
+ >
9
+ <view style="height: 80rpx; background: #fff"></view>
10
+ <view class="jfb-cashier-verification-pay__body">
11
+ <view class="column-group">
12
+ <view class="column-item">
13
+ <view class="column_label">
14
+ 我的票券
15
+ <view
16
+ :style="{ color: style.$warningColor }"
17
+ v-if="checkedCards.length > 0"
18
+ class="label_sub"
19
+ >(已使用{{ checkedCards.length }}张票券)</view
20
+ >
21
+ <view
22
+ :style="{ marginLeft: '20rpx', color: style.$warningColor }"
23
+ class="label_sub"
24
+ v-else
25
+ >请勾选票券</view
26
+ >
27
+ </view>
28
+ <view class="column_value">
29
+ <xd-button
30
+ width="220rpx"
31
+ radius="60rpx"
32
+ type="primary"
33
+ size="small"
34
+ @click="xdDownDrawerNewCard = true"
35
+ >使用新票券</xd-button
36
+ >
37
+ </view>
38
+ </view>
39
+ <view class="column-item">
40
+ <view class="column_label">
41
+ 仍需支付
42
+ <view class="label_sub">(可使用多张票券支付)</view>
43
+ </view>
44
+ <view class="column_value text-primary">
45
+ <xd-unit
46
+ :price="needPayPrice"
47
+ :isOld="false"
48
+ :font-size="32"
49
+ :icon-size="0.3"
50
+ ></xd-unit>
51
+ </view>
52
+ </view>
53
+ </view>
54
+ <view class="ticket_list" :key="renderChecked">
55
+ <view v-if="showCouponList.length" class="coupon_list">
56
+ <xd-coupon-item
57
+ style="margin-bottom: 20rpx"
58
+ v-for="(item, i) in showCouponList"
59
+ :key="i"
60
+ :couponRadius="couponRadius"
61
+ :couponImageUrl="couponImageUrl"
62
+ :couponTitleBgColor="couponTitleBgColor"
63
+ :couponUseBtnPadding="couponUseBtnPadding"
64
+ :couponBtnRadius="couponBtnRadius"
65
+ :couponBtnTextStyle="couponBtnTextStyle"
66
+ :couponLeftBgColor="couponLeftBgColor"
67
+ :item="item"
68
+ @useCoupon="doCardLogin(item)"
69
+ >
70
+ <template slot="btn">
71
+ <xd-radio
72
+ class="cou_btn"
73
+ :disabled="item.is_valid === 'N' || item.card_point == 0"
74
+ size="mini"
75
+ @change="(flat) => handlerTicketSelect(flat, item)"
76
+ :value="checkedCards.includes(item.card_number)"
77
+ ></xd-radio>
78
+ </template>
79
+ </xd-coupon-item>
80
+ <view v-if="!hasCouponList" class="no_more_card"
81
+ >没有更多券了,查看失效的票券 ></view
82
+ >
83
+ </view>
84
+ <view :style="{color: mainColor}" class="ticket_add_new" @click="xdDownDrawerNewCard = true">
85
+ <view :style="{backgroundColor: mainColor}" class="plus_icon">+</view>
86
+ <view>使用新票券</view>
87
+ </view>
88
+ </view>
89
+ <view style="height: 100rpx"></view>
90
+ <view v-if="xdDownDrawer" class="bottom_btn" :style="alert_bottom">
91
+ <xd-button
92
+ width="360rpx"
93
+ type="primary"
94
+ radius="50rpx"
95
+ @click="doTicketPay"
96
+ >确认支付</xd-button
97
+ >
98
+ </view>
99
+ </view>
100
+ </xd-down-drawer>
101
+ <xd-down-drawer
102
+ :show.sync="xdDownDrawerNewCard"
103
+ :z-index="3010"
104
+ height="580rpx"
105
+ @close="switchValidToken"
106
+ >
107
+ <view class="drawer_title">使用新票券</view>
108
+ <xd-form label-width="180" label-align="left" content-align="left">
109
+ <xd-form-item label="票券号码" content-align="left">
110
+ <view class="flex align-center">
111
+ <xd-form-input
112
+ placeholder="电子码无需输入券号"
113
+ v-model="cardForm.card_number"
114
+ />
115
+ <view v-if="isQrCode" class="scan_icon" @click="doScanCode">
116
+ <xd-font-icon icon="iconsaoma"></xd-font-icon>
117
+ </view>
118
+ </view>
119
+ </xd-form-item>
120
+ <xd-form-item label="票券密码" content-align="left">
121
+ <xd-form-input
122
+ placeholder="请输入票券密码"
123
+ v-model="cardForm.card_password"
124
+ />
125
+ </xd-form-item>
126
+ <xd-form-item label="验证码" content-align="left">
127
+ <view class="flex align-center">
128
+ <xd-form-input
129
+ placeholder="请输入验证码"
130
+ v-model="cardForm.valid_code"
131
+ />
132
+ <view
133
+ v-if="cardForm.valid_token"
134
+ class="capture"
135
+ @click="switchValidToken"
136
+ >
137
+ <image
138
+ style="width: 100%; height: 100%"
139
+ :src="
140
+ validImageAPIUrl +
141
+ '?image_width=180&image_height=80&token=' +
142
+ cardForm.valid_token
143
+ "
144
+ />
145
+ </view>
146
+ </view>
147
+ </xd-form-item>
148
+ </xd-form>
149
+ <xd-button
150
+ width="360rpx"
151
+ type="primary"
152
+ radius="50rpx"
153
+ @click="addNewCoupon()"
154
+ >使用新票券</xd-button
155
+ >
156
+ <view :style="{ height: layoutInfo.bottom + 'rpx' }"></view>
157
+ </xd-down-drawer>
158
+ </view>
159
+ </template>
160
+ <script>
161
+ /**
162
+ * @description 选择卡券支付 & 支持三方支付
163
+ * @property show {Boolean} 是否显示支付卡券弹窗
164
+ * @property layoutInfo {Object} XdLayout返回的布局信息
165
+ * @property validImageAPIUrl {String} 图片验证码接口API地址
166
+ * @property jwxSDK {Object} JSSDK授权对象
167
+ * @property price {Number|String} 订单总额 单位元
168
+ * @property getSettleListCoupons {Function(successCallBack(cardList))} 获取支付卡券列表
169
+ * @property setSettleSelectCoupon {Function(options, successCallBack, errCallBack)} 选择卡券列表
170
+ * @property addSettleCoupon {Function(options, successCallBack)} 添加卡券
171
+ *
172
+ */
173
+ import XdDownDrawer from "@/components/XdDownDrawer/XdDownDrawer";
174
+ import XdButton from "@/components/XdButton/XdButton";
175
+ import XdUnit from "@/components/XdUnit/XdUnit";
176
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
177
+ import XdRadio from "@/components/XdRadio/XdRadio";
178
+ import XdForm from "@/components/XdForm/XdForm";
179
+ import XdFormItem from "@/components/XdFormItem/XdFormItem";
180
+ import XdFormInput from "@/components/XdFormInput/XdFormInput";
181
+ import XdCouponItem from "@/components/XdCouponItem/XdCouponItem";
182
+ import {
183
+ getParentsStyle, //获取页面风格单个键值值
184
+ getParentsStyles, //获取页面风格列表
185
+ isQrCode,
186
+ } from "@/utils/xd.base";
187
+
188
+ export default {
189
+ name: "XdCardPayChose",
190
+ components: {
191
+ XdDownDrawer,
192
+ XdButton,
193
+ XdUnit,
194
+ XdFontIcon,
195
+ XdRadio,
196
+ XdForm,
197
+ XdFormItem,
198
+ XdFormInput,
199
+ XdCouponItem,
200
+ },
201
+ props: {
202
+ show: false,
203
+ layoutInfo: {},
204
+ validImageAPIUrl: {
205
+ //图片验证码 接口地址
206
+ type: String,
207
+ },
208
+ orderTotalPrice: {
209
+ //订单总额 单位元
210
+ type: String | Number,
211
+ default: "100",
212
+ },
213
+ orderNeedPayPrice: {
214
+ type: String | Number,
215
+ default: "100",
216
+ },
217
+ jwxSDK: {
218
+ //JSSDK授权对象
219
+ type: Object,
220
+ },
221
+ getSettleListCoupons: {
222
+ //支付卡券列表
223
+ type: Function,
224
+ },
225
+ setSettleSelectCoupon: {
226
+ //选择卡券列表
227
+ type: Function,
228
+ },
229
+ addSettleCoupon: {
230
+ //添加卡券
231
+ type: Function,
232
+ },
233
+ hadChoseCoupon: {
234
+ type: null | Array,
235
+ },
236
+ mainColor: {
237
+ type: String,
238
+ },
239
+ couponRadius: {
240
+ type: String,
241
+ default: "16",
242
+ },
243
+ couponLeftBgColor: {
244
+ type: String,
245
+ default: "linear-gradient(180deg, #FFA852 0%, #FF5733 100%)",
246
+ },
247
+ couponImageUrl: {
248
+ type: Object | String,
249
+ },
250
+ couponTitleBgColor: {
251
+ type: String,
252
+ default: "rgba(255, 87, 51, 0.1)",
253
+ },
254
+ couponUseBtnPadding: {
255
+ type: Object,
256
+ default() {
257
+ return {
258
+ top: 20,
259
+ right: 20,
260
+ bottom: 10,
261
+ left: 20,
262
+ };
263
+ },
264
+ },
265
+ couponBtnRadius: {
266
+ type: String,
267
+ default: "16",
268
+ },
269
+ couponBtnTextStyle: {
270
+ type: Object,
271
+ default() {
272
+ return {
273
+ color: "#fff",
274
+ bgColor: "#ff5722",
275
+ fontSize: "30rpx",
276
+ fontWeight: "normal",
277
+ };
278
+ },
279
+ },
280
+ },
281
+ watch: {
282
+ show(n, o) {
283
+ this.xdDownDrawer = n;
284
+ },
285
+ xdDownDrawer(n, o) {
286
+ console.log("xdDownDrawer value", n, o);
287
+ if (n) {
288
+ console.log(this.hadChoseCoupon);
289
+ let checkedArr = (this.hadChoseCoupon || []).map((c) => c.card_number);
290
+ this.selectedCardList = this.selectedCardList.map((item) => {
291
+ if (!checkedArr.includes(item.card_number)) {
292
+ this.needPayPrice = +this.needPayPrice + item["card_use_price"];
293
+ this.cardPayPrice = this.cardPayPrice - item.card_use_price;
294
+ item["card_use_point"] = 0;
295
+ }
296
+ return item;
297
+ });
298
+ }
299
+ this.$emit("update:show", n);
300
+ this.$emit("onAlert");
301
+ },
302
+ orderTotalPrice: {
303
+ handler(n) {
304
+ this.clearChecked();
305
+ },
306
+ },
307
+ orderNeedPayPrice(n, o) {
308
+ console.log("orderNeedPayPrice", n);
309
+ this.needPayPrice = n;
310
+ },
311
+ xdDownDrawerNewCard(n) {
312
+ if (!n) {
313
+ this.cardForm = {
314
+ card_number: "",
315
+ card_password: "",
316
+ valid_code: "",
317
+ valid_token: this.$xdUniHelper.randomChar(20),
318
+ };
319
+ }
320
+ },
321
+ },
322
+ data() {
323
+ return {
324
+ xdDownDrawer: false,
325
+ xdDownDrawerNewCard: false,
326
+ channel_provider_id: "",
327
+ cardList: [], //展示
328
+ selectedCardList: [],
329
+ needPayPrice: 0,
330
+ cardPayPrice: 0,
331
+ cardForm: {
332
+ //添加新卡券表单
333
+ card_number: "",
334
+ card_password: "",
335
+ valid_code: "", //验证码正文
336
+ valid_token: "", //验证码token
337
+ },
338
+ renderChecked: "renderChecked",
339
+
340
+ total_price: "",
341
+ style: {},
342
+ isQrCode: false,
343
+ hasCouponList: false,
344
+ };
345
+ },
346
+ computed: {
347
+ showCouponList() {
348
+ //筛选出不存在于cardList的数据
349
+ let otherCardList = this.selectedCardList.filter((item) => {
350
+ let cur = this.cardList.find(
351
+ (ii) => ii.card_number == item.card_number
352
+ );
353
+ return !cur;
354
+ });
355
+ //合并selectedCardList数据到对应的cardList
356
+ let combineList = this.cardList.map((item) => {
357
+ let cur = this.selectedCardList.find(
358
+ (ii) => ii.card_number == item.card_number
359
+ );
360
+ if (cur) return Object.assign(item, cur);
361
+ return item;
362
+ });
363
+ return combineList.concat(otherCardList);
364
+ },
365
+ checkedCards() {
366
+ return this.showCouponList
367
+ .filter((item) => item.card_use_point > 0)
368
+ .map((item) => item.card_number);
369
+ },
370
+ //提交是的selectedCardList, 由于取消选中不走接口 & 避免取消隐藏
371
+ submitCardList() {
372
+ return this.selectedCardList.filter((item) => item.card_use_point > 0);
373
+ },
374
+ alert_bottom() {
375
+ return this.fixedStyle({ paddingBottom: 24, zIndex: 110 });
376
+ },
377
+ },
378
+ async created() {
379
+ this.isQrCode = isQrCode(this);
380
+ this.switchValidToken();
381
+ this.style = await getParentsStyles(this.$parent);
382
+ console.log(this.mainColor,'this.$parent');
383
+ this.handleInit();
384
+ },
385
+ methods: {
386
+ handleInit() {
387
+ this.total_price = this.$xdUniHelper.multiplyFloatNumber(
388
+ this.orderTotalPrice,
389
+ 100
390
+ );
391
+ this.needPayPrice = this.total_price;
392
+ this.getList();
393
+ this.selectedCardList = this.selectedCardList.map((item) => {
394
+ item["card_use_point"] = 0;
395
+ return item;
396
+ });
397
+ },
398
+ clearChecked() {
399
+ console.log("xdCardPayChose", this.orderTotalPrice);
400
+ this.total_price = this.$xdUniHelper.multiplyFloatNumber(
401
+ this.orderTotalPrice,
402
+ 100
403
+ );
404
+ this.needPayPrice = this.total_price;
405
+ this.cardPayPrice = 0;
406
+ this.selectedCardList = this.selectedCardList.map((item) => {
407
+ item["card_use_point"] = 0;
408
+ return item;
409
+ });
410
+ this.doTicketPay();
411
+ },
412
+ divideFloatNumber(num) {
413
+ return this.$xdUniHelper.divisionFloatNumber(num, 100);
414
+ },
415
+ fixedStyle(options = {}, type = "bottom") {
416
+ let paddingBottom = options.paddingBottom || options.height || 0;
417
+ if (options.paddingBottom) delete options.paddingBottom;
418
+ if (options.height) delete options.height;
419
+ let obj = Object.assign(
420
+ {},
421
+ {
422
+ top: 0,
423
+ left: 0,
424
+ right: 0,
425
+ bottom: 0,
426
+ zIndex: 100,
427
+ },
428
+ options
429
+ );
430
+ let style = "position: fixed";
431
+ style = `${style};left:${obj.left}rpx`;
432
+ style = `${style};right:${obj.right}rpx`;
433
+ style = `${style};z-index:${obj.zIndex}`;
434
+ if (type === "bottom") {
435
+ let padding =
436
+ (this.layoutInfo.bottomHeight +
437
+ this.layoutInfo.footerHeight +
438
+ paddingBottom) *
439
+ this.$rpxNum;
440
+ style = `${style}; padding-bottom:calc(${padding}px + constant(safe-area-inset-bottom));`;
441
+ style = `${style}; padding-bottom:calc(${padding}px + env(safe-area-inset-bottom));`;
442
+ style = `${style};bottom:0;`;
443
+ }
444
+ if (type === "top") {
445
+ style = `${style};top:${obj.top}rpx`;
446
+ }
447
+ return style;
448
+ },
449
+ getTimeFormat(time) {
450
+ let date = null;
451
+ if (time == +time) {
452
+ if ((time + "").length <= 10) date = new Date(+time * 1000);
453
+ else date = new Date(+time);
454
+ return (
455
+ date.getFullYear() +
456
+ "-" +
457
+ (date.getMonth() + 1) +
458
+ "-" +
459
+ date.getDate()
460
+ );
461
+ }
462
+ return time;
463
+ },
464
+ getList() {
465
+ //获取卡券列表
466
+ this.getSettleListCoupons((cardList) => {
467
+ this.$xdLog.setARMSInfo(
468
+ this.filterMGinfo(cardList),
469
+ "init_binded_list"
470
+ );
471
+ this.cardList = cardList;
472
+ });
473
+ },
474
+ //选卡弹出项
475
+ useCardPop(data) {
476
+ return new Promise((resolve, reject) => {
477
+ uni.showModal({
478
+ title: "提示",
479
+ content: data.pop_message,
480
+ confirmText: data.confirm_text,
481
+ cancelText: data.cancel_text,
482
+ success: function (res) {
483
+ if (res.confirm) {
484
+ resolve(2);
485
+ } else if (res.cancel) {
486
+ // reject("取消支付");
487
+ if (data.pop_type == "confirm") {
488
+ resolve();
489
+ } else {
490
+ resolve(3);
491
+ }
492
+ }
493
+ },
494
+ fail: function (res) {
495
+ reject(res);
496
+ },
497
+ });
498
+ });
499
+ },
500
+
501
+ //选择卡券
502
+ handlerTicketSelect(flat, ticket, options) {
503
+ if (flat) {
504
+ //选择卡券,重新调用接口获取 selectedCardList, neePayPrice
505
+ const { submitCardList, total_price } = this;
506
+ let callThis = this;
507
+ // #ifdef MP
508
+ callThis = this.$parent;
509
+ // #endif
510
+ this.$xdShowLoading({});
511
+ callThis.setSettleSelectCoupon(
512
+ {
513
+ total_price,
514
+ card_number: ticket.card_number,
515
+ selected_card_list_json: JSON.stringify(submitCardList),
516
+ ...options,
517
+ },
518
+ (res) => {
519
+ let resOptions = JSON.parse(JSON.stringify(res));
520
+ if (resOptions["selected_card_list1"])
521
+ delete resOptions["selected_card_list1"];
522
+ if (resOptions["selected_card_list"]) {
523
+ resOptions["selected_card_list"] = this.filterMGinfo(
524
+ resOptions["selected_card_list"]
525
+ );
526
+ }
527
+ this.$xdLog.setARMSInfo(
528
+ {
529
+ card_number: ticket.card_number,
530
+ selected_card_list_json: this.filterMGinfo(submitCardList),
531
+ ...options,
532
+ res: resOptions,
533
+ },
534
+ "select_binded_card"
535
+ );
536
+ this.$xdHideLoading();
537
+ const {
538
+ selected_card_list,
539
+ need_pay_price,
540
+ is_need_pop,
541
+ card_total_use_price,
542
+ } = res;
543
+ if (is_need_pop) {
544
+ this.useCardPop(res)
545
+ .then((select_content) => {
546
+ if (select_content) {
547
+ this.handlerTicketSelect(true, ticket, { select_content });
548
+ } else {
549
+ this.handlerTicketSelect(false, ticket);
550
+ }
551
+ })
552
+ .catch(() => {});
553
+ } else {
554
+ this.selectedCardList = selected_card_list;
555
+ this.needPayPrice = need_pay_price;
556
+ this.cardPayPrice = card_total_use_price;
557
+ this.renderChecked = Date.now();
558
+ }
559
+ },
560
+ (err) => {
561
+ this.$xdHideLoading();
562
+ this.renderChecked = Date.now();
563
+ }
564
+ );
565
+ } else {
566
+ this.$xdLog.setARMSInfo(
567
+ {
568
+ ticket: this.filterMGinfo(ticket),
569
+ ...options,
570
+ },
571
+ "cancel_card"
572
+ );
573
+ //不走接口, selectedCardList不是真实选中的
574
+ this.selectedCardList = this.selectedCardList.map((item) => {
575
+ if (item.card_number == ticket.card_number) {
576
+ this.needPayPrice = +this.needPayPrice + item["card_use_price"];
577
+ item["card_use_price"] = 0;
578
+ item["card_use_point"] = 0;
579
+ }
580
+ return item;
581
+ });
582
+ if (ticket.is_new) {
583
+ this.cardList = this.cardList.filter(
584
+ (item) => item.card_number != ticket.card_number
585
+ );
586
+ this.selectedCardList = this.selectedCardList.filter(
587
+ (item) => item.card_number != ticket.card_number
588
+ );
589
+ }
590
+ this.cardPayPrice = this.cardPayPrice - ticket.card_use_price;
591
+ this.renderChecked = Date.now();
592
+ }
593
+ },
594
+
595
+ filterMGinfo(list) {
596
+ //深拷贝
597
+ if (
598
+ this.$xdUniHelper.checkVarType(list) === "object" ||
599
+ this.$xdUniHelper.checkVarType(list) === "array"
600
+ ) {
601
+ list = JSON.parse(JSON.stringify(list));
602
+ }
603
+ //object
604
+ if (this.$xdUniHelper.checkVarType(list) === "object") {
605
+ if (list.card_use_certificate)
606
+ list.card_use_certificate =
607
+ list.card_use_certificate.substr(0, 2) +
608
+ "********" +
609
+ list.card_use_certificate.substr(-3);
610
+ if (list.card_cert)
611
+ list.card_cert =
612
+ list.card_cert.substr(0, 2) +
613
+ "********" +
614
+ list.card_cert.substr(-3);
615
+ if (list.card_password)
616
+ list.card_password =
617
+ list.card_password.substr(0, 2) +
618
+ "********" +
619
+ list.card_password.substr(-3);
620
+ return list;
621
+ }
622
+
623
+ //array
624
+ return list.map((item) => {
625
+ if (item.card_use_certificate)
626
+ item.card_use_certificate =
627
+ item.card_use_certificate.substr(0, 2) +
628
+ "********" +
629
+ item.card_use_certificate.substr(-3);
630
+ if (item.card_cert)
631
+ item.card_cert =
632
+ item.card_cert.substr(0, 2) +
633
+ "********" +
634
+ item.card_cert.substr(-3);
635
+ if (item.card_password)
636
+ item.card_password =
637
+ item.card_password.substr(0, 2) +
638
+ "********" +
639
+ item.card_password.substr(-4);
640
+ return item;
641
+ });
642
+ },
643
+
644
+ //添加新卡券
645
+ addNewCoupon(options = {}) {
646
+ const { cardForm, total_price, submitCardList } = this;
647
+ let err_tip = "";
648
+ if (!cardForm.card_qrcode) {
649
+ if (!cardForm.valid_code) err_tip = "验证码不能为空";
650
+ else if (!cardForm.card_number && !cardForm.card_password)
651
+ err_tip = "票券和密码不能为空";
652
+ }
653
+ if (err_tip) {
654
+ return uni.showToast({
655
+ title: err_tip,
656
+ icon: "none",
657
+ });
658
+ }
659
+ let callThis = this;
660
+ // #ifdef MP
661
+ callThis = this.$parent;
662
+ // #endif
663
+ this.$xdShowLoading({});
664
+ callThis.addSettleCoupon(
665
+ {
666
+ ...cardForm,
667
+ selected_card_list_json: JSON.stringify(submitCardList),
668
+ total_price,
669
+ ...options,
670
+ },
671
+ (res) => {
672
+ let resOptions = JSON.parse(JSON.stringify(res));
673
+ resOptions.selected_card_list = this.filterMGinfo(
674
+ resOptions.selected_card_list
675
+ );
676
+ this.$xdLog.setARMSInfo(
677
+ {
678
+ ...options,
679
+ total_price,
680
+ cardForm: {
681
+ ...cardForm,
682
+ card_password: cardForm.card_password
683
+ ? cardForm.card_password.substr(0, 2) +
684
+ "********" +
685
+ cardForm.card_password.substr(-3)
686
+ : "",
687
+ },
688
+ selected_card_list_json: this.filterMGinfo(submitCardList),
689
+ res: resOptions,
690
+ },
691
+ "add_card"
692
+ );
693
+ this.$xdHideLoading();
694
+
695
+ //成功回调
696
+ let {
697
+ selected_card_list = [],
698
+ need_pay_price,
699
+ is_need_pop,
700
+ card_total_use_price,
701
+ } = res;
702
+
703
+ if (is_need_pop) {
704
+ this.useCardPop(res)
705
+ .then((select_content) => {
706
+ if (select_content) this.addNewCoupon({ select_content });
707
+ // this.handlerTicketSelect(true, cardForm.card_number, {select_content})
708
+ })
709
+ .catch((e) => {
710
+ console.error(e);
711
+ });
712
+ return;
713
+ } else {
714
+ // filterCard 去重后的卡券
715
+ let r_cards = this.cardList.map((item) => item.card_number);
716
+ let filterCard = selected_card_list.filter(
717
+ (item) => !r_cards.includes(item.card_number)
718
+ );
719
+ //重合的卡券列表
720
+ let repeatCardList = selected_card_list.filter((item) =>
721
+ r_cards.includes(item.card_number)
722
+ );
723
+
724
+ if (repeatCardList.length > 0) {
725
+ for (let i = 0; i < repeatCardList.length; i++) {
726
+ let repeatCard = repeatCardList[i];
727
+ //重复的以前的卡数据
728
+ let oldCard = this.cardList.find(
729
+ (item) => item.card_number == repeatCard.card_number
730
+ );
731
+ //自动选中当前重合的卡券
732
+ if (
733
+ this.selectedCardList.findIndex(
734
+ (item) => item.card_number == repeatCard.card_number
735
+ ) == -1
736
+ ) {
737
+ this.selectedCardList.push({ ...oldCard, ...repeatCard });
738
+ } else {
739
+ this.selectedCardList = this.selectedCardList.map((item) => {
740
+ if (item.card_number == repeatCard.card_number) {
741
+ item = { ...oldCard, ...repeatCard };
742
+ }
743
+ return item;
744
+ });
745
+ }
746
+ }
747
+ }
748
+
749
+ selected_card_list = filterCard.map((item) => {
750
+ item["is_new"] = true;
751
+ return item;
752
+ });
753
+ this.cardList = selected_card_list.concat(this.cardList);
754
+ this.selectedCardList = selected_card_list.concat(
755
+ this.selectedCardList
756
+ );
757
+ this.needPayPrice = need_pay_price;
758
+ this.cardPayPrice = card_total_use_price;
759
+ }
760
+ this.xdDownDrawerNewCard = false;
761
+ this.renderChecked = Date.now();
762
+ //清空cardForm
763
+ this.cardForm = {
764
+ card_number: "",
765
+ card_password: "",
766
+ valid_code: "",
767
+ };
768
+ this.switchValidToken();
769
+ },
770
+ (err) => {
771
+ this.$xdHideLoading();
772
+ this.switchValidToken();
773
+ }
774
+ );
775
+ },
776
+ //确认支付
777
+ async doTicketPay() {
778
+ const { cardPayPrice, submitCardList, needPayPrice } = this;
779
+ let postData = {
780
+ cardPayPrice: cardPayPrice,
781
+ selectedCardList: submitCardList,
782
+ needPayPrice: needPayPrice,
783
+ };
784
+ this.$emit("onChose", postData);
785
+ },
786
+ //刷新图片验证码
787
+ switchValidToken() {
788
+ let valid_token = this.$xdUniHelper.randomChar(20);
789
+ this.$set(this.cardForm, "valid_token", valid_token);
790
+ },
791
+ //扫码
792
+ doScanCode() {
793
+ // #ifdef H5
794
+ this.jwxSDK.scanQRCode({
795
+ needResult: 1,
796
+ success: (res) => {
797
+ // this.$set(this.cardForm, 'card_number', res.resultStr)
798
+ this.$set(this.cardForm, "card_qrcode", res.resultStr);
799
+ this.addNewCoupon();
800
+ },
801
+ });
802
+ // #endif
803
+ // #ifdef MP
804
+ uni.scanCode({
805
+ success: (res) => {
806
+ console.log("scanCode", res);
807
+ // this.$set(this.cardForm, 'card_number', res.result)
808
+ this.$set(this.cardForm, "card_qrcode", res.result);
809
+ this.addNewCoupon();
810
+ },
811
+ });
812
+ // #endif
813
+ },
814
+ },
815
+ };
816
+ </script>
817
+
818
+ <style lang="less" scoped>
819
+ .xd-card-pay {
820
+ .text-gray {
821
+ color: #999999;
822
+ }
823
+ .text-primary {
824
+ color: #fe7a63;
825
+ }
826
+ .flex {
827
+ display: flex;
828
+ }
829
+ .align-center {
830
+ align-items: center;
831
+ }
832
+ .drawer_title {
833
+ line-height: 100rpx;
834
+ text-align: center;
835
+ font-size: 32rpx;
836
+ }
837
+ .scan_icon {
838
+ width: 32rpx;
839
+ height: 32rpx;
840
+ }
841
+ .capture {
842
+ width: 180rpx;
843
+ height: 80rpx;
844
+ background: #ddd;
845
+ }
846
+ }
847
+ .coupon_list {
848
+ ::v-deep .xd-coupon_item {
849
+ margin: var(--card-list-margin) 0;
850
+ }
851
+ }
852
+ .cou_btn{
853
+ position: absolute;
854
+ padding: 10rpx 30rpx;
855
+ border-radius: 12rpx;
856
+ right: 20rpx;
857
+ bottom: 20rpx;
858
+ }
859
+ .no_more_card{
860
+ text-align: center;
861
+ padding: 20rpx 0;
862
+ color: #CCCCCC;
863
+ font-size: 28rpx;
864
+ }
865
+ .jfb-cashier-verification-pay {
866
+ &__body {
867
+ padding-bottom: 150rpx;
868
+ max-height: 70vh;
869
+ overflow: auto;
870
+ .column-group {
871
+ .column-item {
872
+ display: flex;
873
+ align-items: center;
874
+ justify-content: space-between;
875
+ border-bottom: 1px solid rgba(238, 238, 238, 1);
876
+ padding: 30rpx 50rpx;
877
+
878
+ .column_label {
879
+ display: flex;
880
+ align-items: center;
881
+ font-size: 28rpx;
882
+ }
883
+ .column_value {
884
+ display: flex;
885
+ align-items: center;
886
+ font-size: 24rpx;
887
+ .xd-coins {
888
+ margin-left: 8rpx;
889
+ }
890
+ }
891
+ .label_sub {
892
+ font-size: 18rpx;
893
+ color: #999999;
894
+ }
895
+ }
896
+ }
897
+
898
+ .ticket_list {
899
+ padding: 40rpx;
900
+ .ticket_add_new {
901
+ width: 690rpx;
902
+ height: 220rpx;
903
+ border-radius: 10rpx;
904
+ background: rgba(255, 255, 255, 1);
905
+ box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.1);
906
+ margin: 30rpx auto;
907
+ display: flex;
908
+ flex-direction: column;
909
+ align-items: center;
910
+ justify-content: center;
911
+ font-size: 24rpx;
912
+
913
+ .plus_icon {
914
+ color: #ffffff;
915
+ border-radius: 20rpx;
916
+ display: flex;
917
+ align-items: center;
918
+ justify-content: center;
919
+ font-size: 48rpx;
920
+ width: 80rpx;
921
+ height: 80rpx;
922
+ margin-bottom: 20rpx;
923
+ }
924
+ }
925
+ .ticket_item {
926
+ width: 690rpx;
927
+ border-radius: 10rpx;
928
+ background: rgba(255, 255, 255, 1);
929
+ box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.1);
930
+ margin: 30rpx auto;
931
+ padding: 30rpx 0 20rpx;
932
+ ._header {
933
+ display: flex;
934
+ justify-content: space-between;
935
+ padding: 0rpx 30rpx;
936
+ font-size: 28rpx;
937
+ }
938
+ ._cont {
939
+ display: flex;
940
+ font-size: 18rpx;
941
+ padding: 24rpx 30rpx;
942
+ border-bottom: 1px solid rgba(242, 242, 242, 1);
943
+ color: #777777;
944
+ }
945
+ ._footer {
946
+ display: flex;
947
+ justify-content: space-between;
948
+ padding: 24rpx 30rpx 12rpx;
949
+ font-size: 24rpx;
950
+ ._item {
951
+ display: flex;
952
+ align-items: center;
953
+ }
954
+ }
955
+ .orther_pay {
956
+ display: inline-block;
957
+ background: #f5f5f5;
958
+ font-size: 24rpx;
959
+ font-weight: 400;
960
+ border-radius: 8rpx;
961
+ color: #999999;
962
+ padding: 8rpx 20rpx;
963
+ margin: 16rpx 0 0 30rpx;
964
+ }
965
+ }
966
+ }
967
+
968
+ .remain_pay {
969
+ .remain_header {
970
+ display: flex;
971
+ justify-content: space-between;
972
+ padding: 30rpx 50rpx 0;
973
+ color: #999999;
974
+ font-size: 24rpx;
975
+ }
976
+ .pay_item {
977
+ display: flex;
978
+ align-items: center;
979
+ width: 700rpx;
980
+ height: 120rpx;
981
+ border-radius: 10rpx;
982
+ background: rgba(255, 255, 255, 1);
983
+ box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.1);
984
+ padding: 24rpx 35rpx;
985
+ box-sizing: border-box;
986
+ margin: 30rpx auto;
987
+ font-size: 28rpx;
988
+
989
+ .icon {
990
+ width: 64rpx;
991
+ height: 64rpx;
992
+ border-radius: 32rpx;
993
+ // background: #DDD;
994
+ margin-right: 30rpx;
995
+ }
996
+ .pay_name {
997
+ flex: 1;
998
+ }
999
+ }
1000
+ }
1001
+ .bottom_btn {
1002
+ position: fixed;
1003
+ width: 100%;
1004
+ padding: 24rpx 0;
1005
+ background: #ffffff;
1006
+ box-shadow: 0 0 0px 1px rgba(0, 0, 0, 0.1);
1007
+ transition: 500ms all;
1008
+ padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
1009
+ padding-bottom: calc(24rpx + constant(safe-area-inset-bottom));
1010
+ }
1011
+ }
1012
+ }
1013
+ </style>
@@ -0,0 +1,273 @@
1
+ <template>
2
+ <view class="xd-coupon_item" :style="couponItemBoxStyle">
3
+ <view class="coupon_left" :style="{
4
+ background: couponLeftBgColor
5
+ }">
6
+ <view class="_point">
7
+ <xd-unit
8
+ :unitFontSize="24"
9
+ :fontSize="48"
10
+ :price="item.card_point"
11
+ :isOld="false"
12
+ :unit="item.unit || ''"
13
+ :colorNew="'#ffffff'"
14
+ ></xd-unit>
15
+ <!-- <text style="font-size: 24rpx;">{{ item.unit }}</text> -->
16
+ </view>
17
+ <view class="_rule">{{ item.card_use_rule }}</view>
18
+ </view>
19
+ <view class="coupon_right" :style="couponRightItemBoxStyle">
20
+ <view class="cont_top" :style="{
21
+ background: couponTitleBgColor
22
+ }">{{ item.card_type_name }}</view>
23
+ <view class="cont_main">
24
+ <view class="cou_number">券号:{{ item.card_number }}</view>
25
+ <view class="cou_time">有效期:{{ item.end_time }}</view>
26
+ <view class="cou_point">
27
+ 余额:
28
+ <xd-unit
29
+ :unitFontSize="24"
30
+ :fontSize="28"
31
+ :price="item.card_point"
32
+ :isOld="false"
33
+ :unit="item.unit || ''"
34
+ :colorNew="'#333333'"
35
+ ></xd-unit>
36
+ </view>
37
+ <slot name="btn">
38
+ <view class="cou_btn"
39
+ :style="[
40
+ item.is_login === 'Y' ? couponBtnActiveStyle : couponBtnStyle,
41
+ {
42
+ padding: couponBtnPadding,
43
+ borderRadius: couponBtnRadius + 'rpx'
44
+ }
45
+ ]"
46
+ @click="goToUseCoupon"
47
+ >{{item.is_login === 'Y' ? '已登录' : '去使用'}}</view>
48
+ </slot>
49
+ </view>
50
+ <view class="cont_bottom">
51
+ <view class="switch_rule" @click="switchRule">
52
+ <view>使用规则</view>
53
+ <view>
54
+ <xd-font-icon v-if="!expand" icon="iconxia_down" size="24"></xd-font-icon>
55
+ <xd-font-icon v-else icon="iconshang_up" size="24"></xd-font-icon>
56
+ </view>
57
+ </view>
58
+ <view v-if="expand" class="expand_rule">
59
+ {{ item.card_use_rule }}
60
+ </view>
61
+ </view>
62
+ </view>
63
+ </view>
64
+ </template>
65
+ <script>
66
+ import getServiceUrl from '@/common/getServiceUrl'
67
+ import XdUnit from "@/components/XdUnit/XdUnit";
68
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
69
+ export default{
70
+ name: "XdCouponItem",
71
+ components: {
72
+ XdFontIcon,
73
+ XdUnit
74
+ },
75
+ props: {
76
+ item:{
77
+ type: Object,
78
+ },
79
+ couponRadius: {
80
+ type: String,
81
+ default: "16"
82
+ },
83
+ couponLeftBgColor: {
84
+ type: String,
85
+ default: 'linear-gradient(180deg, #FFA852 0%, #FF5733 100%)'
86
+ },
87
+ couponImageUrl: {
88
+ type: Object | String
89
+ },
90
+ couponTitleBgColor: {
91
+ type: String,
92
+ default: "rgba(255, 87, 51, 0.1)"
93
+ },
94
+ couponUseBtnPadding: {
95
+ type: Object,
96
+ default(){
97
+ return {
98
+ top: 20,
99
+ right: 20,
100
+ bottom: 10,
101
+ left: 20
102
+ }
103
+ },
104
+ },
105
+ couponBtnRadius: {
106
+ type: String,
107
+ default: "16"
108
+ },
109
+ couponBtnTextStyle: {
110
+ type: Object,
111
+ default(){
112
+ return {
113
+ color: '#fff',
114
+ bgColor: '#ff5722',
115
+ fontSize: '30rpx',
116
+ fontWeight: 'normal'
117
+ }
118
+ }
119
+ }
120
+ },
121
+ data() {
122
+ return {
123
+ expand: false,
124
+ }
125
+ },
126
+ computed: {
127
+ couponItemBoxStyle(){
128
+ return this.styleObjectToString({
129
+ borderRadius: this.couponRadius + 'rpx',
130
+ })
131
+ },
132
+ couponBtnPadding(){
133
+ let padding = `${this.checkValue(this.couponUseBtnPadding.top, 20)}rpx`;
134
+ padding = `${padding} ${this.checkValue(this.couponUseBtnPadding.right, 20)}rpx`;
135
+ padding = `${padding} ${this.checkValue(this.couponUseBtnPadding.bottom, 20)}rpx`;
136
+ padding = `${padding} ${this.checkValue(this.couponUseBtnPadding.left, 20)}rpx`;
137
+ return padding;
138
+ },
139
+ couponBtnStyle(){
140
+ let styleObj = {
141
+ color: this.couponBtnTextStyle['color'] || '#333',
142
+ background: this.couponBtnTextStyle['bgColor'] || '#fff',
143
+ fontSize: this.couponBtnTextStyle['fontSize'] || '30rpx',
144
+ fontWeight: this.couponBtnTextStyle['fontWeight'] || 'normal',
145
+ }
146
+ return this.styleObjectToString(styleObj)
147
+ },
148
+ couponBtnActiveStyle(){
149
+ return this.styleObjectToString({
150
+ color: this.couponBtnTextStyle['actColor'] || '#fff',
151
+ background: this.couponBtnTextStyle['actBgColor'] || '#ff5722',
152
+ fontSize: this.couponBtnTextStyle['actFontSize'] || '30rpx',
153
+ fontWeight: this.couponBtnTextStyle['actFontWeight'] || 'normal',
154
+ })
155
+ },
156
+ couponRightItemBoxStyle(){
157
+ let image = {};
158
+ if(this.cardImageUrl) image = {
159
+ backgroundImage: `url(${this.getCouponBgImage})`,
160
+ backgroundSize: '100%',
161
+ backgroundRepeat: 'no-repeat',
162
+ }
163
+ return this.styleObjectToString(image)
164
+ },
165
+ getCouponBgImage(){
166
+ let bg = '';
167
+ if(this.$xdUniHelper.checkVarType(this.couponImageUrl) === 'object'
168
+ || this.$xdUniHelper.checkVarType(this.couponImageUrl) === 'array'
169
+ ) {
170
+ if(!this.$xdUniHelper.isEmpty(this.couponImageUrl)) {
171
+ return getServiceUrl(this.couponImageUrl.url)
172
+ }
173
+ }
174
+ return bg
175
+ },
176
+ },
177
+ methods: {
178
+ switchRule(){
179
+ this.expand = !this.expand;
180
+ },
181
+ goToUseCoupon(){
182
+ this.$emit('useCoupon', this.item);
183
+ },
184
+ checkValue(value, dValue = 0){
185
+ if(value === undefined || value === '' || value === null) return dValue;
186
+ return Number(value || 0);
187
+ },
188
+ }
189
+ }
190
+
191
+ </script>
192
+ <style lang="less" scoped>
193
+ .xd-coupon_item{
194
+ display: flex;
195
+ margin: 20rpx 0;
196
+ border-radius: 16rpx;
197
+ background: #FFFFFF;
198
+ overflow: hidden;
199
+ .coupon_left{
200
+ color: #FFFFFF;
201
+ width: 170rpx;
202
+ display: flex;
203
+ flex-direction: column;
204
+ align-items: center;
205
+ justify-content: center;
206
+
207
+ ._point{
208
+ font-size: 48rpx;
209
+ }
210
+ ._rule{
211
+ font-size: 24rpx;
212
+ }
213
+ }
214
+ .coupon_right{
215
+ flex: 1;
216
+ width: 530rpx;
217
+ .cont_top{
218
+ background: rgba(255, 87, 51, 0.1);
219
+ padding: 8rpx 40rpx;
220
+ font-size: 24rpx;
221
+ overflow: hidden;
222
+ white-space: nowrap;
223
+ text-overflow: ellipsis;
224
+ }
225
+ .cont_main{
226
+ position: relative;
227
+ padding: 28rpx 20rpx 28rpx 40rpx;
228
+ color: #333333;
229
+ .cou_number{
230
+ font-size: 32rpx;
231
+ font-weight: bold;
232
+ }
233
+ .cou_time{
234
+ font-size: 28rpx;
235
+ margin: 16rpx 0;
236
+ }
237
+ .cou_point{
238
+ font-size: 28rpx;
239
+ display: flex;
240
+ align-items: center;
241
+ }
242
+ .cou_btn{
243
+ position: absolute;
244
+ padding: 10rpx 30rpx;
245
+ background-color: #ddd;
246
+ border-radius: 12rpx;
247
+ right: 20rpx;
248
+ bottom: 20rpx;
249
+ }
250
+ }
251
+ .cont_bottom{
252
+ background: #EEEEEE;
253
+ .switch_rule{
254
+ display: flex;
255
+ align-items: center;
256
+ justify-content: space-between;
257
+ padding: 12rpx 40rpx;
258
+ font-size: 24rpx;
259
+ color: #666666;
260
+ }
261
+ .expand_rule{
262
+ padding: 12rpx 40rpx;
263
+ font-size: 20rpx;
264
+ color: #333333;
265
+ overflow: hidden;
266
+ white-space: nowrap;
267
+ text-overflow: ellipsis;
268
+ background-color: #F5F5F5;
269
+ }
270
+ }
271
+ }
272
+ }
273
+ </style>