gxd-uni-library-editx 1.0.7 → 1.0.8-beta2

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.7",
3
+ "version": "1.0.8-beta2",
4
4
  "private": false,
5
5
  "description": "聚福宝基础插件专用库",
6
6
  "main": "index.js",
@@ -0,0 +1,635 @@
1
+ <template>
2
+ <view class="xd-card-pay">
3
+ <slot></slot>
4
+ <xd-down-drawer :show.sync="xdDownDrawer"
5
+ :z-index="3000">
6
+ <view style="height: 80rpx;background:#FFF;"></view>
7
+ <view class="jfb-cashier-verification-pay__body">
8
+ <view class="column-group">
9
+ <view class="column-item">
10
+ <view class="column_label">
11
+ 订单总额
12
+ </view>
13
+ <view class="column_value text-gray">
14
+ <xd-unit
15
+ :price="total_price"
16
+ :isOld="false"
17
+ :font-size="24"
18
+ :icon-size="0.3"
19
+ ></xd-unit>
20
+ </view>
21
+ </view>
22
+ <view class="column-item">
23
+ <view class="column_label">
24
+ 仍需支付
25
+ <view class="label_sub">(可使用多张票券支付)</view>
26
+ </view>
27
+ <view class="column_value text-primary">
28
+ <xd-unit
29
+ :price="needPayPrice"
30
+ :isOld="false"
31
+ :font-size="24"
32
+ :icon-size="0.3"
33
+ ></xd-unit>
34
+ </view>
35
+ </view>
36
+ <view class="column-item">
37
+ <view class="column_label">
38
+ 我的票券
39
+ <view class="label_sub">(已使用{{checkedCards.length}}张票券)</view>
40
+ </view>
41
+ <view class="column_value">
42
+ <xd-button
43
+ width="220rpx"
44
+ radius="60rpx"
45
+ type="primary"
46
+ size="small"
47
+ @click="xdDownDrawerNewCard=true"
48
+ >使用新票券</xd-button>
49
+ </view>
50
+ </view>
51
+ </view>
52
+ <view
53
+ class="ticket_list"
54
+ :key="renderChecked"
55
+ >
56
+ <view
57
+ class="ticket_item"
58
+ v-for="ticket in showCardList"
59
+ :key="ticket.card_number"
60
+ >
61
+ <view class="_header">
62
+ <view class="flex align-center">
63
+ <xd-font-icon
64
+ style="margin-right: 8rpx;"
65
+ icon="iconkaquan"
66
+ color="#ffc65d"
67
+ size="32"
68
+ ></xd-font-icon>
69
+ {{ticket.card_type_name}}
70
+ </view>
71
+ <xd-radio
72
+ size="mini"
73
+ @change="flat => handlerTicketSelect(flat, ticket.card_number)"
74
+ :value="checkedCards.includes(ticket.card_number)"
75
+ ></xd-radio>
76
+ </view>
77
+ <view class="_cont">
78
+ <view style="margin-right: 30rpx;">ID:{{ticket.card_number}}</view>
79
+ <view>有效期至:{{ticket.end_time}}</view>
80
+ </view>
81
+ <view class="_footer">
82
+ <view class="_item"> 剩余:<xd-unit
83
+ :price="ticket.card_point"
84
+ :isOld="false"
85
+ :font-size="24"
86
+ :icon-size="0.3"
87
+ ></xd-unit>
88
+ </view>
89
+ <view
90
+ v-if="ticket.card_use_price"
91
+ class="_item text-primary"
92
+ >
93
+ 使用:<xd-unit
94
+ :price="ticket.card_use_price"
95
+ :isOld="false"
96
+ :font-size="24"
97
+ :icon-size="0.3"
98
+ ></xd-unit>
99
+ </view>
100
+ </view>
101
+ </view>
102
+ </view>
103
+ <view
104
+ v-if="needPayPrice>0"
105
+ class="remain_pay"
106
+ >
107
+ <view class="remain_header">
108
+ <view>选择以下支付方式</view>
109
+ <view class="flex align-center text-primary">
110
+ <view style="margin-right:8rpx;">继续支付</view>
111
+ <xd-unit
112
+ :price="needPayPrice"
113
+ :is-show-icon="false"
114
+ unit="元"
115
+ :isOld="false"
116
+ :font-size="24"
117
+ :icon-size="0.3"
118
+ ></xd-unit>
119
+ </view>
120
+ </view>
121
+ <view class="pay_list">
122
+ <view
123
+ v-for="item in payChannels"
124
+ :key="item.channel_provider_id"
125
+ class="pay_item"
126
+ >
127
+ <view class="icon">
128
+ <xd-font-icon
129
+ v-if="item.channel_code =='wxpay'"
130
+ icon="iconwx"
131
+ size="64"
132
+ color="#25bc46"
133
+ ></xd-font-icon>
134
+ </view>
135
+ <view class="pay_name">{{item.channel_provider_name}}</view>
136
+ <xd-radio
137
+ @change="flat => handlerPayCheck(item.channel_provider_id, flat)"
138
+ :value="channel_provider_id==item.channel_provider_id"
139
+ ></xd-radio>
140
+ </view>
141
+ </view>
142
+ </view>
143
+ <view
144
+ class="bottom_btn"
145
+ :style="{bottom: layoutInfo.bottom+'rpx', opacity: this.show?'1':'0'}"
146
+ >
147
+ <xd-button
148
+ width="360rpx"
149
+ type="primary"
150
+ radius="50rpx"
151
+ @click="doTicketPay"
152
+ >确认支付</xd-button>
153
+ </view>
154
+ </view>
155
+ </xd-down-drawer>
156
+ <xd-down-drawer
157
+ :show.sync="xdDownDrawerNewCard"
158
+ :z-index="3010"
159
+ height="580rpx"
160
+ >
161
+ <view class="drawer_title">使用新票券</view>
162
+ <xd-form
163
+ label-width="180"
164
+ label-align="left"
165
+ content-align="left"
166
+ >
167
+ <xd-form-item
168
+ label="票券号码"
169
+ content-align="left"
170
+ >
171
+ <view class="flex align-center">
172
+ <xd-form-input
173
+ placeholder="请输入票券号码"
174
+ v-model="cardForm.card_number"
175
+ />
176
+ <view
177
+ class="scan_icon"
178
+ @click="doScanCode"
179
+ >
180
+ <xd-font-icon icon="iconsaoma"></xd-font-icon>
181
+ </view>
182
+ </view>
183
+ </xd-form-item>
184
+ <xd-form-item
185
+ label="票券密码"
186
+ content-align="left"
187
+ >
188
+ <xd-form-input
189
+ placeholder="请输入票券密码"
190
+ v-model="cardForm.card_password"
191
+ />
192
+ </xd-form-item>
193
+ <xd-form-item
194
+ label="验证码"
195
+ content-align="left"
196
+ >
197
+ <view class="flex align-center">
198
+ <xd-form-input
199
+ placeholder="请输入验证码"
200
+ v-model="cardForm.valid_code"
201
+ />
202
+ <view
203
+ v-if="cardForm.valid_token"
204
+ class="capture"
205
+ @click="switchValidToken"
206
+ >
207
+ <image
208
+ style="width: 100%;height:100%"
209
+ :src="validImageAPIUrl + '?image_width=180&image_height=80&token='+cardForm.valid_token"
210
+ />
211
+ </view>
212
+ </view>
213
+ </xd-form-item>
214
+ </xd-form>
215
+ <xd-button
216
+ width="360rpx"
217
+ type="primary"
218
+ radius="50rpx"
219
+ @click="addNewCard"
220
+ >使用新票券</xd-button>
221
+ </xd-down-drawer>
222
+ </view>
223
+ </template>
224
+ <script>
225
+ /**
226
+ * @description 选择卡券支付 & 支持三方支付
227
+ * @property show {Boolean} 是否显示支付卡券弹窗
228
+ * @property layoutInfo {Object} XdLayout返回的布局信息
229
+ * @property validImageAPIUrl {String} 图片验证码接口API地址
230
+ * @property jwxSDK {Object} JSSDK授权对象
231
+ * @property payChannels {Array} 三方支付列表
232
+ * @property price {Number|String} 订单总额 单位元
233
+ * @property getSettleListCards {Function(successCallBack(cardList))} 获取支付卡券列表
234
+ * @property setSettleSelectCard {Function(options, successCallBack, errCallBack)} 选择卡券列表
235
+ * @property addSettleCard {Function(options, successCallBack)} 添加卡券
236
+ * @property createSettleOrder {Function(options, successCallBack)} 创建订单
237
+ * @property setThirdPlace {Function(options, successCallBack)} 获取三方支付签名
238
+ *
239
+ * @event {Function} onCreateOrder 订单创建完成触发函数
240
+ */
241
+ import XdDownDrawer from "@/components/XdDownDrawer/XdDownDrawer"
242
+ import XdButton from "@/components/XdButton/XdButton"
243
+ import XdUnit from "@/components/XdUnit/XdUnit"
244
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon"
245
+ import XdRadio from "@/components/XdRadio/XdRadio"
246
+ import XdForm from "@/components/XdForm/XdForm"
247
+ import XdFormItem from "@/components/XdFormItem/XdFormItem"
248
+ import XdFormInput from "@/components/XdFormInput/XdFormInput"
249
+
250
+ export default {
251
+ name: "XdCardPay",
252
+ components: {
253
+ XdDownDrawer,
254
+ XdButton,
255
+ XdUnit,
256
+ XdFontIcon,
257
+ XdRadio,
258
+ XdForm,
259
+ XdFormItem,
260
+ XdFormInput
261
+ },
262
+ props: {
263
+ show: false,
264
+ layoutInfo: {},
265
+ validImageAPIUrl: { //图片验证码 接口地址
266
+ type: String,
267
+ },
268
+ price: { //订单总额 单位元
269
+ type: String|Number,
270
+ default: "100"
271
+ },
272
+ jwxSDK: { //JSSDK授权对象
273
+ type: Object,
274
+ },
275
+ payChannels: { //三方支付列表
276
+ type: Array,
277
+ default: () => {
278
+ return []
279
+ }
280
+ },
281
+ getSettleListCards: { //支付卡券列表
282
+ type: Function
283
+ },
284
+ setSettleSelectCard: { //选择卡券列表
285
+ type: Function
286
+ },
287
+ addSettleCard: { //添加卡券
288
+ type: Function
289
+ },
290
+ createSettleOrder: { //创建订单
291
+ type: Function
292
+ },
293
+ setThirdPlace: { //获取三方支付签名参数
294
+ type: Function
295
+ }
296
+ },
297
+ watch: {
298
+ show(n, o){
299
+ this.xdDownDrawer = n;
300
+ },
301
+ xdDownDrawer(n){
302
+ this.$emit('update:show', n);
303
+ }
304
+ },
305
+ data(){
306
+ return {
307
+ xdDownDrawer: false,
308
+ xdDownDrawerNewCard: false,
309
+ channel_provider_id: "",
310
+ cardList: [
311
+ {
312
+ "card_number":"101001000005193",
313
+ "card_type_name":"聚福宝福卡测试蛋糕",
314
+ "end_time":"2024-10-31",
315
+ "card_point":100000000,
316
+ "is_bind_card":true
317
+ },
318
+ ], //展示
319
+ selectedCardList: [],
320
+ needPayPrice: 0,
321
+ cardForm: { //添加新卡券表单
322
+ card_number: "",
323
+ card_password: "",
324
+ valid_code: "", //验证码正文
325
+ valid_token: "", //验证码token
326
+ },
327
+ renderChecked: "renderChecked",
328
+
329
+ total_price: "",
330
+ }
331
+ },
332
+ computed: {
333
+ showCardList(){
334
+ //筛选出不存在于cardList的数据
335
+ let otherCardList = this.selectedCardList.filter(item =>{
336
+ let cur = this.cardList.find(ii => ii.card_number === item.card_number);
337
+ return !cur;
338
+ })
339
+ //合并selectedCardList数据到对应的cardList
340
+ let combineList = this.cardList.map(item => {
341
+ let cur = this.selectedCardList.find(ii => ii.card_number === item.card_number);
342
+ if(cur) return Object.assign(item, cur);
343
+ return item;
344
+ })
345
+ return combineList.concat(otherCardList);
346
+ },
347
+ checkedCards(){
348
+ return this.showCardList.filter(item => item.card_use_price > 0).map(item => item.card_number);
349
+ },
350
+ //提交是的selectedCardList, 由于取消选中不走接口 & 避免取消隐藏
351
+ submitCardList(){
352
+ return this.selectedCardList.filter(item => item.card_use_price > 0);
353
+ },
354
+ curPayChannel(){
355
+ return this.payChannels.find(item => item.channel_provider_id === this.channel_provider_id);
356
+ }
357
+ },
358
+ created(){
359
+ this.total_price = this.$xdUniHelper.multiplyFloatNumber(this.price, 100);
360
+ this.needPayPrice = this.total_price;
361
+
362
+ this.getList();
363
+ },
364
+ methods: {
365
+ getList(){
366
+ //获取卡券列表
367
+ this.getSettleListCards((cardList) => {
368
+ this.cardList = cardList;
369
+ })
370
+ },
371
+ //选择卡券
372
+ handlerTicketSelect(flat, card_number){
373
+ if(flat){ //选择卡券,重新调用接口获取 selectedCardList, neePayPrice
374
+ const {submitCardList, total_price} = this;
375
+ this.setSettleSelectCard({
376
+ total_price,
377
+ card_number,
378
+ selected_card_list_json: JSON.stringify(submitCardList)
379
+ }, (res) => {
380
+ const {selected_card_list, need_pay_price} = res;
381
+ this.selectedCardList = selected_card_list;
382
+ this.needPayPrice = need_pay_price;
383
+ this.renderChecked = Date.now();
384
+ }, (err) => {
385
+ this.renderChecked = Date.now();
386
+ })
387
+ }else{
388
+ //不走接口, selectedCardList不是真实选中的
389
+ this.selectedCardList = this.selectedCardList.map(item => {
390
+ if(item.card_number === card_number){
391
+ this.needPayPrice = +this.needPayPrice + item['card_use_price']
392
+ item['card_use_price'] = 0;
393
+ }
394
+ return item;
395
+ });
396
+ this.renderChecked = Date.now();
397
+ }
398
+
399
+ },
400
+ //添加新卡券
401
+ addNewCard(){
402
+ const { cardForm, total_price, submitCardList } = this;
403
+ this.addSettleCard({
404
+ ...cardForm,
405
+ selected_card_list_json: JSON.stringify(submitCardList),
406
+ total_price,
407
+ }, () => {
408
+ //成功回调
409
+ this.getList();
410
+ })
411
+ },
412
+ //确认支付
413
+ doTicketPay(){
414
+ const { total_price, submitCardList, needPayPrice } = this;
415
+
416
+ if(+needPayPrice > 0 && !this.channel_provider_id){
417
+ uni.showToast({
418
+ title: "请选择继续支付方式",
419
+ icon: "none"
420
+ });
421
+ return false;
422
+ }
423
+ let postData = {
424
+ total_price,
425
+ selected_card_list_json: JSON.stringify(submitCardList),
426
+ need_pay_price: needPayPrice
427
+ };
428
+
429
+ this.createSettleOrder(postData, (order) => {
430
+ if(+needPayPrice > 0){
431
+ this.doThirdPay(order);
432
+ }else{
433
+ this.$emit("onCreateOrder", order); //支付完成,触发
434
+ }
435
+ })
436
+ },
437
+ //扫码
438
+ doScanCode(){
439
+ this.jwxSDK.scanQRCode({
440
+ needResult: 1,
441
+ success: res => {
442
+ console.log(res);
443
+ this.$set(this.cardForm, 'card_number', res.resultStr)
444
+ }
445
+ })
446
+ },
447
+ //第三方支付签名获取
448
+ doThirdPay(order){
449
+ const { channel_provider_id } = this;
450
+ this.setThirdPlace({order_id: order.fms_order_id,channel_provider_id}, (res) => {
451
+ const { channel_data } = res;
452
+ const paySignData = JSON.parse(Base64.decode(channel_data));
453
+ this.openTemplatePay(paySignData, ps => {
454
+ this.$emit("onCreateOrder", order); //支付完成,触发
455
+ });
456
+ })
457
+ },
458
+ //唤醒三方平台支付
459
+ openTemplatePay(paySignData, cb){
460
+ // #ifdef H5
461
+ this.jwxSDK.chooseWXPay({
462
+ ...paySignData,
463
+ success: (res) => {
464
+ console.log('pay success', res);
465
+ uni.showToast({
466
+ title: "支付成功",
467
+ icon: "none"
468
+ })
469
+ cb(res);
470
+ },
471
+ cancel: () => {
472
+ uni.showToast({
473
+ title: "取消支付",
474
+ icon: "none"
475
+ })
476
+ },
477
+ fail: err => {
478
+ uni.showToast({
479
+ title: "支付失败",
480
+ icon: "none"
481
+ })
482
+ console.log('pay fail', err);
483
+ }
484
+ })
485
+ // #endif
486
+
487
+ // #ifndef H5
488
+ console.log("未支持唤醒三方支付");
489
+ // #endif
490
+ },
491
+ }
492
+ }
493
+ </script>
494
+
495
+ <style lang="less" scoped>
496
+ .xd-card-pay{
497
+ .text-gray{
498
+ color: #999999;
499
+ }
500
+ .text-primary{
501
+ color: #FE7A63;
502
+ }
503
+ .flex{
504
+ display: flex;
505
+ }
506
+ .align-center{
507
+ align-items: center;
508
+ }
509
+ .drawer_title{
510
+ line-height: 100rpx;
511
+ text-align: center;
512
+ font-size: 32rpx;
513
+ }
514
+ .scan_icon{
515
+ width: 32rpx;
516
+ height: 32rpx;
517
+ }
518
+ .capture{
519
+ width: 180rpx;
520
+ height: 80rpx;
521
+ background: #DDD;
522
+ }
523
+ }
524
+ .jfb-cashier-verification-pay {
525
+ &__body{
526
+ padding-bottom: 150rpx;
527
+ max-height: 70vh;
528
+ overflow: auto;
529
+ .column-group{
530
+ .column-item{
531
+ display: flex;
532
+ align-items: center;
533
+ justify-content: space-between;
534
+ border-bottom: 1px solid rgba(238, 238, 238, 1);
535
+ padding: 30rpx 50rpx;
536
+
537
+ .column_label{
538
+ display: flex;
539
+ align-items: center;
540
+ font-size: 28rpx;
541
+ }
542
+ .column_value{
543
+ display: flex;
544
+ align-items: center;
545
+ font-size: 24rpx;
546
+ .xd-coins{
547
+ margin-left: 8rpx;
548
+ }
549
+ }
550
+ .label_sub{
551
+ font-size: 18rpx;
552
+ color: #999999;
553
+ }
554
+ }
555
+ }
556
+
557
+ .ticket_list{
558
+ .ticket_item{
559
+ width: 690rpx;
560
+ border-radius: 10rpx;
561
+ background: rgba(255, 255, 255, 1);
562
+ box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.1);
563
+ margin: 30rpx auto;
564
+ padding: 30rpx 0 20rpx;
565
+ ._header{
566
+ display: flex;
567
+ justify-content: space-between;
568
+ padding: 0rpx 30rpx;
569
+ font-size: 28rpx;
570
+ }
571
+ ._cont{
572
+ display: flex;
573
+ font-size: 18rpx;
574
+ padding: 24rpx 30rpx;
575
+ border-bottom: 1px solid rgba(242, 242, 242, 1);
576
+ color: #777777;
577
+ }
578
+ ._footer{
579
+ display: flex;
580
+ justify-content: space-between;
581
+ padding: 24rpx 30rpx 12rpx;
582
+ font-size: 24rpx;
583
+ ._item{
584
+ display: flex;
585
+ align-items: center;
586
+ }
587
+ }
588
+ }
589
+ }
590
+
591
+ .remain_pay{
592
+ .remain_header{
593
+ display: flex;
594
+ justify-content: space-between;
595
+ padding: 30rpx 50rpx 0;
596
+ color: #999999;
597
+ font-size: 24rpx;
598
+ }
599
+ .pay_item{
600
+ display: flex;
601
+ align-items: center;
602
+ width: 700rpx;
603
+ height: 120rpx;
604
+ border-radius: 10rpx;
605
+ background: rgba(255, 255, 255, 1);
606
+ box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.1);
607
+ padding: 24rpx 35rpx;
608
+ box-sizing: border-box;
609
+ margin: 30rpx auto;
610
+ font-size: 28rpx;
611
+
612
+ .icon{
613
+ width: 64rpx;
614
+ height: 64rpx;
615
+ border-radius: 32rpx;
616
+ // background: #DDD;
617
+ margin-right: 30rpx;
618
+ }
619
+ .pay_name{
620
+ flex: 1;
621
+ }
622
+ }
623
+ }
624
+ .bottom_btn{
625
+ position: fixed;
626
+ width: 100%;
627
+ padding: 24rpx 0;
628
+ background: #FFFFFF;
629
+ box-shadow: 0 0 0px 1px rgba(0, 0, 0, 0.1);
630
+ opacity: 0;
631
+ transition: 500ms all;
632
+ }
633
+ }
634
+ }
635
+ </style>
@@ -820,6 +820,14 @@ class Helpers {
820
820
  }
821
821
  }
822
822
 
823
+ //#ifdef H5
824
+ if(window['$configProject'] && window['$configProject'].isPreview) {
825
+ if(obj['url'].indexOf('/preview/index/index') === -1) {
826
+ alert(`点击链接跳转地址:${obj['url']}`);
827
+ }
828
+ }
829
+ // #endif
830
+
823
831
  if (isH5) {
824
832
  window.location.href = obj['url'];
825
833
  } else {
@@ -36,7 +36,7 @@ export function jfbRootExec(fnName, params) {
36
36
  ) {
37
37
  console.log(`调用方法名字:${fnName},返回值:`, params.vm.$root.mocks[fnName]);
38
38
  return new Promise((resolve) => {
39
- resolve(params.vm.$root.mocks[fnName]);
39
+ resolve(JSON.parse(JSON.stringify(params.vm.$root.mocks[fnName])));
40
40
  });
41
41
  }
42
42
  //#endif
@@ -91,7 +91,6 @@ class xdFrame {
91
91
  * @param attr {String} 属性名字
92
92
  */
93
93
  getParentData(attr) {
94
- console.log('getParentData',)
95
94
  if (window.parent['$boardData']) {
96
95
  return this.getParent()['$boardData'][attr];
97
96
  } else return [];
@@ -212,7 +212,6 @@ class Logs {
212
212
 
213
213
  checkMessage(error){
214
214
  console.error(error);
215
- throw error;
216
215
  let errorStr = error;
217
216
  if(Object.prototype.toString.call(error) === '[object Error]') {
218
217
  errorStr = JSON.stringify(runtime().getErrorInfo(error));