gxd-uni-library-editx 1.0.0
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/.editorconfig +14 -0
- package/README.md +447 -0
- package/index.js +3 -0
- package/package.json +104 -0
- package/postcss.config.js +22 -0
- package/settings.js.tpl +68 -0
- package/src/XdAppClass.1.0.js +257 -0
- package/src/XdAppClass.js +150 -0
- package/src/components/XdAddress/XdAddress.vue +579 -0
- package/src/components/XdAddressSelect/XdAddressSelect.vue +243 -0
- package/src/components/XdBaiduMap/XdBaiduMap.vue +204 -0
- package/src/components/XdBaiduOverlay/XdBaiduOverlay.vue +345 -0
- package/src/components/XdBaiduSearch/XdBaiduSearch.vue +354 -0
- package/src/components/XdBar/XdBar.vue +339 -0
- package/src/components/XdButton/XdButton.vue +288 -0
- package/src/components/XdCartList/XdCartList.vue +791 -0
- package/src/components/XdCartNoStoreList/XdCartNoStoreList.vue +747 -0
- package/src/components/XdCity/XdCity.vue +620 -0
- package/src/components/XdCity/city.js +93 -0
- package/src/components/XdCity/testData.js +124 -0
- package/src/components/XdCityLocation/XdCityLocation.vue +314 -0
- package/src/components/XdCityLocation/jweixin.js +72 -0
- package/src/components/XdCityShow/XdCityShow.vue +354 -0
- package/src/components/XdClipImage/XdClipImage.vue +879 -0
- package/src/components/XdCoins/XdCoins.vue +66 -0
- package/src/components/XdConfirm/XdConfirm.vue +240 -0
- package/src/components/XdContentXss/XdContentXss.vue +71 -0
- package/src/components/XdDailog/XdDailog.vue +258 -0
- package/src/components/XdDate/XdDataItemOne.vue +236 -0
- package/src/components/XdDate/XdDate.vue +1081 -0
- package/src/components/XdDate/XdDateItem.vue +316 -0
- package/src/components/XdDate/XdDateTime.vue +929 -0
- package/src/components/XdDate/i18n/en.json +19 -0
- package/src/components/XdDate/i18n/index.js +8 -0
- package/src/components/XdDate/i18n/zh-Hans.json +19 -0
- package/src/components/XdDate/i18n/zh-Hant.json +19 -0
- package/src/components/XdDate/keypress.js +45 -0
- package/src/components/XdDate/util.js +418 -0
- package/src/components/XdDownDrawer/XdDownDrawer.vue +176 -0
- package/src/components/XdEditPwd/XdEditPwd.vue +305 -0
- package/src/components/XdEnterOrderList/XdEnterOrderList.vue +413 -0
- package/src/components/XdExpressTimeLine/XdExpressTimeLine.vue +280 -0
- package/src/components/XdFilter/XdFilter.vue +541 -0
- package/src/components/XdFontIcon/XdFontIcon.vue +165 -0
- package/src/components/XdFontIcon/css/icon.less +498 -0
- package/src/components/XdFooterBar/XdFooterBar.vue +291 -0
- package/src/components/XdFooterTabbar/XdFooterTabbar.vue +284 -0
- package/src/components/XdForm/XdForm.vue +481 -0
- package/src/components/XdForm/validate.js +486 -0
- package/src/components/XdFormCheckbox/XdFormCheckbox.vue +858 -0
- package/src/components/XdFormDate.vue +187 -0
- package/src/components/XdFormInput/XdFormInput.vue +535 -0
- package/src/components/XdFormInput/common.js +56 -0
- package/src/components/XdFormItem/XdFormItem.vue +583 -0
- package/src/components/XdFormSelect/XdFormSelect.vue +119 -0
- package/src/components/XdImage/XdImage.vue +113 -0
- package/src/components/XdItemCardUser/XdItemCardUser.vue +232 -0
- package/src/components/XdItemFilmImage/XdItemFilmImage.vue +146 -0
- package/src/components/XdItemFilmText/XdItemFilmText.vue +83 -0
- package/src/components/XdItemPhysical/XdItemPhysical.vue +410 -0
- package/src/components/XdItemPhysicalPack/XdItemPhysicalPack.vue +240 -0
- package/src/components/XdItemStore/XdItemStore.vue +236 -0
- package/src/components/XdItemUserInfo/XdItemUserInfo.vue +175 -0
- package/src/components/XdJson/XdJson.vue +398 -0
- package/src/components/XdKeyValue/XdKeyValue.vue +150 -0
- package/src/components/XdLabelNew/XdLabelNew.vue +193 -0
- package/src/components/XdLayout/XdLayout.vue +634 -0
- package/src/components/XdLoading/XdLoading.vue +165 -0
- package/src/components/XdMore/XdMore.vue +66 -0
- package/src/components/XdMpHtml/XdMpHtml.vue +458 -0
- package/src/components/XdMpHtml/node/node.vue +536 -0
- package/src/components/XdMpHtml/parser.js +1260 -0
- package/src/components/XdMpHtml/static/js/handler.js +1 -0
- package/src/components/XdMpHtml/static/js/uni.webview.min.js +1 -0
- package/src/components/XdMpHtml/static/local.html +1 -0
- package/src/components/XdMy/XdMy.vue +294 -0
- package/src/components/XdMySuccess/XdMySuccess.vue +603 -0
- package/src/components/XdNavTab/XdNavTab.vue +147 -0
- package/src/components/XdNoData/XdNoData.vue +87 -0
- package/src/components/XdNoticeBar/XdNoticeBar.vue +501 -0
- package/src/components/XdNumber/XdNumber.vue +210 -0
- package/src/components/XdNumberUni/XdNumberUni.vue +270 -0
- package/src/components/XdNumberUni/readme.md +42 -0
- package/src/components/XdOnlineConfirm/XdOnlineConfirm.vue +385 -0
- package/src/components/XdOnlineDetail/XdOnlineDetail.vue +332 -0
- package/src/components/XdOnlinePay/XdOnlinePay.vue +349 -0
- package/src/components/XdOnlineSchedule/XdOnlineSchedule.vue +453 -0
- package/src/components/XdOnlineSeat/XdOnlineSeat.vue +796 -0
- package/src/components/XdOnlineSeatMove/XdOnlineSeatMove.vue +1012 -0
- package/src/components/XdPayCombo/XdPayCombo.vue +118 -0
- package/src/components/XdPreviewImage/XdPreviewImage.vue +372 -0
- package/src/components/XdPwPay/XdPwPay.vue +214 -0
- package/src/components/XdRadio/XdRadio.vue +151 -0
- package/src/components/XdRangeSlider/XdRangeSlider.vue +355 -0
- package/src/components/XdRedName/XdRedName.vue +35 -0
- package/src/components/XdSearchBar/XdSearchBar.vue +286 -0
- package/src/components/XdSelect/XdSelect.vue +382 -0
- package/src/components/XdSelectCity/XdSelectCity.vue +270 -0
- package/src/components/XdSelectTime/XdSelectTime.vue +342 -0
- package/src/components/XdStar/XdStar.vue +261 -0
- package/src/components/XdStoreCashier/XdStoreCashier.vue +526 -0
- package/src/components/XdStoreItem/XdStoreItem.vue +400 -0
- package/src/components/XdStoreOrderDetail/XdStoreOrderDetail.vue +1571 -0
- package/src/components/XdStoreOrderList/XdStoreOrderList.vue +450 -0
- package/src/components/XdStoreProductInfo/XdStoreProductInfo.vue +940 -0
- package/src/components/XdStoreProductType/XdStoreProductType.vue +307 -0
- package/src/components/XdSuccess/XdSuccess.vue +527 -0
- package/src/components/XdSwipeSelect/XdSwipeSelect.vue +99 -0
- package/src/components/XdSwiper/XdSwiper.vue +124 -0
- package/src/components/XdSwitch/XdSwitch.vue +204 -0
- package/src/components/XdTab/XdTab.vue +220 -0
- package/src/components/XdTabScroll/XdTabScroll.vue +212 -0
- package/src/components/XdTag/XdTag.vue +423 -0
- package/src/components/XdTimeLine/XdTimeLine.vue +121 -0
- package/src/components/XdTips/XdTips.vue +212 -0
- package/src/components/XdTipsBlock/XdTipsBlock.vue +141 -0
- package/src/components/XdTitleSection/XdTitleSection.vue +152 -0
- package/src/components/XdTitleTab/XdTitleTab.vue +227 -0
- package/src/components/XdUnit/XdUnit.vue +206 -0
- package/src/components/XdUpload/XdUpload.vue +197 -0
- package/src/components/XdUploadImage/XdUploadImage.vue +145 -0
- package/src/components/Xdlogs/XdLogs.vue +144 -0
- package/src/components/autoload.js +211 -0
- package/src/components/swipeAction/UniSwipeAction.vue +43 -0
- package/src/components/swipeActionItem/UniSwipeActionItem.vue +386 -0
- package/src/components/swipeActionItem/bindingx.js +298 -0
- package/src/components/swipeActionItem/index.wxs +321 -0
- package/src/components/swipeActionItem/isPC.js +18 -0
- package/src/components/swipeActionItem/mpalipay.js +210 -0
- package/src/components/swipeActionItem/mpother.js +252 -0
- package/src/components/swipeActionItem/mpwxs.js +140 -0
- package/src/dome/dome/address.vue +415 -0
- package/src/dome/dome/auth/login.vue +166 -0
- package/src/dome/dome/baidu_show.vue +20 -0
- package/src/dome/dome/cake.vue +186 -0
- package/src/dome/dome/cart.vue +205 -0
- package/src/dome/dome/cart_store.vue +149 -0
- package/src/dome/dome/cashier/cashier.vue +73 -0
- package/src/dome/dome/cashier/check_cashier.vue +469 -0
- package/src/dome/dome/cashier/success.vue +127 -0
- package/src/dome/dome/city.vue +148 -0
- package/src/dome/dome/cityData.js +9 -0
- package/src/dome/dome/clip.vue +82 -0
- package/src/dome/dome/date/date.vue +273 -0
- package/src/dome/dome/date/selected.js +315 -0
- package/src/dome/dome/dcom/app1.vue +13 -0
- package/src/dome/dome/dcom/app2.vue +13 -0
- package/src/dome/dome/dcom/app3.vue +13 -0
- package/src/dome/dome/dcom/app4.vue +13 -0
- package/src/dome/dome/dcom/app5.vue +13 -0
- package/src/dome/dome/dcom/index.vue +1 -0
- package/src/dome/dome/debug/debug.vue +95 -0
- package/src/dome/dome/docache/docache.vue +88 -0
- package/src/dome/dome/express.vue +269 -0
- package/src/dome/dome/form.vue +312 -0
- package/src/dome/dome/icon.js +125 -0
- package/src/dome/dome/icon.vue +93 -0
- package/src/dome/dome/index.vue +725 -0
- package/src/dome/dome/item.vue +236 -0
- package/src/dome/dome/json/json.vue +88 -0
- package/src/dome/dome/layout.vue +105 -0
- package/src/dome/dome/line.vue +113 -0
- package/src/dome/dome/map/search.vue +70 -0
- package/src/dome/dome/my.vue +171 -0
- package/src/dome/dome/notice.vue +93 -0
- package/src/dome/dome/online/confirm.vue +92 -0
- package/src/dome/dome/online/detail.vue +80 -0
- package/src/dome/dome/online/pay.vue +78 -0
- package/src/dome/dome/online/schedule.vue +73 -0
- package/src/dome/dome/online/seat.vue +98 -0
- package/src/dome/dome/order/detail.vue +166 -0
- package/src/dome/dome/order/enter_order.vue +294 -0
- package/src/dome/dome/order/list.vue +219 -0
- package/src/dome/dome/order/order.js +18 -0
- package/src/dome/dome/order/success.vue +68 -0
- package/src/dome/dome/product.vue +179 -0
- package/src/dome/dome/store_cashier.vue +67 -0
- package/src/dome/dome/swiper.vue +32 -0
- package/src/dome/dome/webview.vue +61 -0
- package/src/install.js +183 -0
- package/src/main/address/address.vue +251 -0
- package/src/main/cart/cart.vue +149 -0
- package/src/main/cashier/cashier.vue +72 -0
- package/src/main/cashier/check_cashier.vue +483 -0
- package/src/main/city/city.vue +149 -0
- package/src/main/date/date.vue +260 -0
- package/src/main/order/order.js +19 -0
- package/src/main/order/order.vue +222 -0
- package/src/main/product/detail.vue +121 -0
- package/src/main/product/type.vue +108 -0
- package/src/main/search/search.vue +501 -0
- package/src/pages.json +337 -0
- package/src/plugins/CreatedComponentsPlugin.js +19 -0
- package/src/plugins/JsonRename.js +72 -0
- package/src/plugins/SetAppParams.js +171 -0
- package/src/project.js +18 -0
- package/src/utils/Cookie.js +68 -0
- package/src/utils/Runtime.js +105 -0
- package/src/utils/Storage.js +104 -0
- package/src/utils/XdNetwork.js +133 -0
- package/src/utils/helper.js +1321 -0
- package/src/utils/nourl.js +95 -0
- package/src/utils/project.js +17 -0
- package/src/utils/xd.auth.js +61 -0
- package/src/utils/xd.base.js +474 -0
- package/src/utils/xd.common.js +240 -0
- package/src/utils/xd.event.js +99 -0
- package/src/utils/xd.frame.js +96 -0
- package/src/utils/xd.path.js +96 -0
- package/src/utils/xdAppLog.js +170 -0
- package/src/utils/xdWxLog.js +302 -0
- package/src/utils/xdh5log.js +307 -0
- package/src/websetting.js +64 -0
- package/tsconfig.json +9 -0
- package/xd.less +180 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 在微信小程序 app vue端 h5 使用wxs 实现-->
|
|
3
|
+
<!-- #ifdef APP-VUE || MP-WEIXIN || H5 -->
|
|
4
|
+
<view class="uni-swipe">
|
|
5
|
+
<view
|
|
6
|
+
class="uni-swipe_box"
|
|
7
|
+
:data-threshold="threshold"
|
|
8
|
+
:data-disabled="disabled"
|
|
9
|
+
:change:prop="swipe.sizeReady"
|
|
10
|
+
:prop="btn"
|
|
11
|
+
@touchstart="swipe.touchstart"
|
|
12
|
+
@touchmove="swipe.touchmove"
|
|
13
|
+
@touchend="swipe.touchend"
|
|
14
|
+
@mousedown="swipe.mousedown"
|
|
15
|
+
@mousemove="swipe.mousemove"
|
|
16
|
+
@mouseup="swipe.mouseup"
|
|
17
|
+
@mouseleave="swipe.mouseleave"
|
|
18
|
+
>
|
|
19
|
+
<!-- 在微信小程序 app vue端 h5 使用wxs 实现-->
|
|
20
|
+
<view class="uni-swipe_button-group button-group--left">
|
|
21
|
+
<slot name="left">
|
|
22
|
+
<view
|
|
23
|
+
v-for="(item,index) in leftOptions"
|
|
24
|
+
:data-button="btn"
|
|
25
|
+
:key="index"
|
|
26
|
+
:style="{
|
|
27
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
|
|
28
|
+
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
|
|
29
|
+
}"
|
|
30
|
+
class="uni-swipe_button button-hock"
|
|
31
|
+
@touchstart="appTouchStart"
|
|
32
|
+
@touchend="appTouchEnd($event,index,item,'left')"
|
|
33
|
+
@click.stop="onClickForPC(index,item,'left')"
|
|
34
|
+
><text
|
|
35
|
+
class="uni-swipe_button-text"
|
|
36
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}"
|
|
37
|
+
>{{ item.text }}</text></view>
|
|
38
|
+
</slot>
|
|
39
|
+
</view>
|
|
40
|
+
<view class="uni-swipe_text--center">
|
|
41
|
+
<slot></slot>
|
|
42
|
+
</view>
|
|
43
|
+
<view class="uni-swipe_button-group button-group--right">
|
|
44
|
+
<slot name="right">
|
|
45
|
+
<view
|
|
46
|
+
v-for="(item,index) in rightOptions"
|
|
47
|
+
:data-button="btn"
|
|
48
|
+
:key="index"
|
|
49
|
+
:style="{
|
|
50
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
|
|
51
|
+
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
|
|
52
|
+
}"
|
|
53
|
+
class="uni-swipe_button button-hock"
|
|
54
|
+
@touchstart="appTouchStart"
|
|
55
|
+
@touchend="appTouchEnd($event,index,item,'right')"
|
|
56
|
+
@click.stop="onClickForPC(index,item,'right')"
|
|
57
|
+
><text
|
|
58
|
+
class="uni-swipe_button-text"
|
|
59
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}"
|
|
60
|
+
>{{ item.text }}</text></view>
|
|
61
|
+
</slot>
|
|
62
|
+
</view>
|
|
63
|
+
</view>
|
|
64
|
+
</view>
|
|
65
|
+
<!-- #endif -->
|
|
66
|
+
<!-- app nvue端 使用 bindingx -->
|
|
67
|
+
<!-- #ifdef APP-NVUE -->
|
|
68
|
+
<view
|
|
69
|
+
ref="selector-box--hock"
|
|
70
|
+
class="uni-swipe"
|
|
71
|
+
@horizontalpan="touchstart"
|
|
72
|
+
@touchend="touchend"
|
|
73
|
+
>
|
|
74
|
+
<view
|
|
75
|
+
ref='selector-left-button--hock'
|
|
76
|
+
class="uni-swipe_button-group button-group--left"
|
|
77
|
+
>
|
|
78
|
+
<slot name="left">
|
|
79
|
+
<view
|
|
80
|
+
v-for="(item,index) in leftOptions"
|
|
81
|
+
:data-button="btn"
|
|
82
|
+
:key="index"
|
|
83
|
+
:style="{
|
|
84
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
|
|
85
|
+
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
|
|
86
|
+
}"
|
|
87
|
+
class="uni-swipe_button button-hock"
|
|
88
|
+
@click.stop="onClick(index,item,'left')"
|
|
89
|
+
><text
|
|
90
|
+
class="uni-swipe_button-text"
|
|
91
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}"
|
|
92
|
+
>{{ item.text }}</text></view>
|
|
93
|
+
</slot>
|
|
94
|
+
</view>
|
|
95
|
+
<view
|
|
96
|
+
ref='selector-right-button--hock'
|
|
97
|
+
class="uni-swipe_button-group button-group--right"
|
|
98
|
+
>
|
|
99
|
+
<slot name="right">
|
|
100
|
+
<view
|
|
101
|
+
v-for="(item,index) in rightOptions"
|
|
102
|
+
:data-button="btn"
|
|
103
|
+
:key="index"
|
|
104
|
+
:style="{
|
|
105
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
|
|
106
|
+
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
|
|
107
|
+
}"
|
|
108
|
+
class="uni-swipe_button button-hock"
|
|
109
|
+
@click.stop="onClick(index,item,'right')"
|
|
110
|
+
><text
|
|
111
|
+
class="uni-swipe_button-text"
|
|
112
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}"
|
|
113
|
+
>{{ item.text }}</text></view>
|
|
114
|
+
</slot>
|
|
115
|
+
</view>
|
|
116
|
+
<view
|
|
117
|
+
ref='selector-content--hock'
|
|
118
|
+
class="uni-swipe_box"
|
|
119
|
+
>
|
|
120
|
+
<slot></slot>
|
|
121
|
+
</view>
|
|
122
|
+
</view>
|
|
123
|
+
<!-- #endif -->
|
|
124
|
+
<!-- 其他平台使用 js ,长列表性能可能会有影响-->
|
|
125
|
+
<!-- #ifdef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || MP-QQ -->
|
|
126
|
+
<view class="uni-swipe">
|
|
127
|
+
<view
|
|
128
|
+
class="uni-swipe_box"
|
|
129
|
+
@touchstart="touchstart"
|
|
130
|
+
@touchmove="touchmove"
|
|
131
|
+
@touchend="touchend"
|
|
132
|
+
:style="{transform:moveLeft}"
|
|
133
|
+
:class="{ani:ani}"
|
|
134
|
+
>
|
|
135
|
+
<view class="uni-swipe_button-group button-group--left">
|
|
136
|
+
<slot name="left">
|
|
137
|
+
<view
|
|
138
|
+
v-for="(item,index) in leftOptions"
|
|
139
|
+
:data-button="btn"
|
|
140
|
+
:key="index"
|
|
141
|
+
:style="{
|
|
142
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
|
|
143
|
+
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
|
|
144
|
+
}"
|
|
145
|
+
class="uni-swipe_button button-hock"
|
|
146
|
+
@touchstart="appTouchStart"
|
|
147
|
+
@touchend="appTouchEnd($event,index,item,'left')"
|
|
148
|
+
><text
|
|
149
|
+
class="uni-swipe_button-text"
|
|
150
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}"
|
|
151
|
+
>{{ item.text }}</text></view>
|
|
152
|
+
</slot>
|
|
153
|
+
</view>
|
|
154
|
+
<slot></slot>
|
|
155
|
+
<view class="uni-swipe_button-group button-group--right">
|
|
156
|
+
<slot name="right">
|
|
157
|
+
<view
|
|
158
|
+
v-for="(item,index) in rightOptions"
|
|
159
|
+
:data-button="btn"
|
|
160
|
+
:key="index"
|
|
161
|
+
:style="{
|
|
162
|
+
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
|
|
163
|
+
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '32px',
|
|
164
|
+
}"
|
|
165
|
+
@touchstart="appTouchStart"
|
|
166
|
+
@touchend="appTouchEnd($event,index,item,'right')"
|
|
167
|
+
class="uni-swipe_button button-hock"
|
|
168
|
+
><text
|
|
169
|
+
class="uni-swipe_button-text"
|
|
170
|
+
:style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}"
|
|
171
|
+
>{{ item.text }}</text></view>
|
|
172
|
+
</slot>
|
|
173
|
+
</view>
|
|
174
|
+
</view>
|
|
175
|
+
</view>
|
|
176
|
+
<!-- #endif -->
|
|
177
|
+
|
|
178
|
+
</template>
|
|
179
|
+
<script
|
|
180
|
+
src="./index.wxs"
|
|
181
|
+
module="swipe"
|
|
182
|
+
lang="wxs"
|
|
183
|
+
></script>
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
<script>
|
|
187
|
+
// #ifdef APP-VUE|| MP-WEIXIN || H5
|
|
188
|
+
import mpwxs from './mpwxs'
|
|
189
|
+
// #endif
|
|
190
|
+
|
|
191
|
+
// #ifdef APP-NVUE
|
|
192
|
+
import bindingx from './bindingx.js'
|
|
193
|
+
// #endif
|
|
194
|
+
|
|
195
|
+
// #ifndef APP-PLUS|| MP-WEIXIN || H5
|
|
196
|
+
import mixins from './mpother'
|
|
197
|
+
// #endif
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* SwipeActionItem 滑动操作子组件
|
|
201
|
+
* @description 通过滑动触发选项的容器
|
|
202
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=181
|
|
203
|
+
* @property {Boolean} show = [left|right|none] 开启关闭组件,auto-close = false 时生效
|
|
204
|
+
* @property {Boolean} disabled = [true|false] 是否禁止滑动
|
|
205
|
+
* @property {Boolean} autoClose = [true|false] 滑动打开当前组件,是否关闭其他组件
|
|
206
|
+
* @property {Number} threshold 滑动缺省值
|
|
207
|
+
* @property {Array} leftOptions 左侧选项内容及样式
|
|
208
|
+
* @property {Array} rgihtOptions 右侧选项内容及样式
|
|
209
|
+
* @event {Function} click 点击选项按钮时触发事件,e = {content,index} ,content(点击内容)、index(下标)
|
|
210
|
+
* @event {Function} change 组件打开或关闭时触发,left\right\none
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
export default {
|
|
214
|
+
name:'UniSwipeActionItem',
|
|
215
|
+
// #ifdef APP-VUE|| MP-WEIXIN||H5
|
|
216
|
+
mixins: [mpwxs],
|
|
217
|
+
// #endif
|
|
218
|
+
|
|
219
|
+
// #ifdef APP-NVUE
|
|
220
|
+
mixins: [bindingx],
|
|
221
|
+
// #endif
|
|
222
|
+
|
|
223
|
+
// #ifndef APP-PLUS|| MP-WEIXIN || H5
|
|
224
|
+
mixins: [mixins],
|
|
225
|
+
// #endif
|
|
226
|
+
|
|
227
|
+
props: {
|
|
228
|
+
// 控制开关
|
|
229
|
+
show: {
|
|
230
|
+
type: String,
|
|
231
|
+
default: 'none'
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
// 禁用
|
|
235
|
+
disabled: {
|
|
236
|
+
type: Boolean,
|
|
237
|
+
default: false
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
// 是否自动关闭
|
|
241
|
+
autoClose: {
|
|
242
|
+
type: Boolean,
|
|
243
|
+
default: true
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
// 滑动缺省距离
|
|
247
|
+
threshold: {
|
|
248
|
+
type: Number,
|
|
249
|
+
default: 20
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
// 左侧按钮内容
|
|
253
|
+
leftOptions: {
|
|
254
|
+
type: Array,
|
|
255
|
+
default () {
|
|
256
|
+
return []
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
// 右侧按钮内容
|
|
261
|
+
rightOptions: {
|
|
262
|
+
type: Array,
|
|
263
|
+
default () {
|
|
264
|
+
return []
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
},
|
|
269
|
+
inject: ['swipeaction']
|
|
270
|
+
}
|
|
271
|
+
</script>
|
|
272
|
+
<style
|
|
273
|
+
lang="less"
|
|
274
|
+
scoped
|
|
275
|
+
>
|
|
276
|
+
.uni-swipe {
|
|
277
|
+
position: relative;
|
|
278
|
+
/* #ifndef APP-NVUE */
|
|
279
|
+
overflow: hidden;
|
|
280
|
+
/* #endif */
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.uni-swipe_box {
|
|
284
|
+
/* #ifndef APP-NVUE */
|
|
285
|
+
display: flex;
|
|
286
|
+
flex-shrink: 0;
|
|
287
|
+
/* #endif */
|
|
288
|
+
position: relative;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.uni-swipe_content {
|
|
292
|
+
// border: 1px red solid;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.uni-swipe_text--center {
|
|
296
|
+
width:100%;
|
|
297
|
+
/*margin-right: unit(10, rpx);*/
|
|
298
|
+
cursor: grab;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.uni-swipe_button-group {
|
|
302
|
+
/* #ifndef APP-NVUE */
|
|
303
|
+
box-sizing: border-box;
|
|
304
|
+
display: flex;
|
|
305
|
+
/* #endif */
|
|
306
|
+
flex-direction: row;
|
|
307
|
+
position: absolute;
|
|
308
|
+
top: 0;
|
|
309
|
+
bottom: 0;
|
|
310
|
+
/* #ifdef H5 */
|
|
311
|
+
cursor: pointer;
|
|
312
|
+
/* #endif */
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.button-group--left {
|
|
316
|
+
left: 0;
|
|
317
|
+
transform: translateX(-100%)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.button-group--right {
|
|
321
|
+
right: 0;
|
|
322
|
+
transform: translateX(100%)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.uni-swipe_button {
|
|
326
|
+
/* #ifdef APP-NVUE */
|
|
327
|
+
flex: 1;
|
|
328
|
+
/* #endif */
|
|
329
|
+
/* #ifndef APP-NVUE */
|
|
330
|
+
display: flex;
|
|
331
|
+
/* #endif */
|
|
332
|
+
flex-direction: row;
|
|
333
|
+
justify-content: center;
|
|
334
|
+
align-items: center;
|
|
335
|
+
padding: 0 unit(20,rpx);
|
|
336
|
+
min-width: unit(100,rpx);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.uni-swipe_button-text {
|
|
340
|
+
/* #ifndef APP-NVUE */
|
|
341
|
+
flex-shrink: 0;
|
|
342
|
+
/* #endif */
|
|
343
|
+
font-size: unit(28, rpx);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.ani {
|
|
347
|
+
transition-property: transform;
|
|
348
|
+
transition-duration: 0.3s;
|
|
349
|
+
transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/* #ifdef MP-ALIPAY */
|
|
353
|
+
.movable-area {
|
|
354
|
+
/* width: 100%; */
|
|
355
|
+
height: unit(90,rpx);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.movable-view {
|
|
359
|
+
display: flex;
|
|
360
|
+
/* justify-content: center; */
|
|
361
|
+
position: relative;
|
|
362
|
+
flex: 1;
|
|
363
|
+
height: unit(90, rpx);
|
|
364
|
+
z-index: 2;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.movable-view-button {
|
|
368
|
+
display: flex;
|
|
369
|
+
flex-shrink: 0;
|
|
370
|
+
flex-direction: row;
|
|
371
|
+
height: 100%;
|
|
372
|
+
background: #C0C0C0;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/* .transition {
|
|
376
|
+
transition: all 0.3s;
|
|
377
|
+
} */
|
|
378
|
+
|
|
379
|
+
.movable-view-box {
|
|
380
|
+
flex-shrink: 0;
|
|
381
|
+
height: 100%;
|
|
382
|
+
background-color: #fff;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/* #endif */
|
|
386
|
+
</style>
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
const BindingX = uni.requireNativePlugin('bindingx');
|
|
2
|
+
const dom = uni.requireNativePlugin('dom');
|
|
3
|
+
const animation = uni.requireNativePlugin('animation');
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
data() {
|
|
7
|
+
return {}
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
watch: {
|
|
11
|
+
|
|
12
|
+
show(newVal) {
|
|
13
|
+
if (this.autoClose) return
|
|
14
|
+
if (this.stop) return
|
|
15
|
+
this.stop = true
|
|
16
|
+
if (newVal) {
|
|
17
|
+
this.open(newVal)
|
|
18
|
+
} else {
|
|
19
|
+
this.close()
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
leftOptions() {
|
|
23
|
+
this.getSelectorQuery()
|
|
24
|
+
this.init()
|
|
25
|
+
},
|
|
26
|
+
rightOptions(newVal) {
|
|
27
|
+
this.init()
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
created() {
|
|
31
|
+
if (this.swipeaction.children !== undefined) {
|
|
32
|
+
this.swipeaction.children.push(this)
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
mounted() {
|
|
36
|
+
this.$nextTick(()=>{
|
|
37
|
+
this.box = this.getEl(this.$refs['selector-box--hock'])
|
|
38
|
+
this.selector = this.getEl(this.$refs['selector-content--hock']);
|
|
39
|
+
this.leftButton = this.getEl(this.$refs['selector-left-button--hock']);
|
|
40
|
+
this.rightButton = this.getEl(this.$refs['selector-right-button--hock']);
|
|
41
|
+
this.init()
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
},
|
|
45
|
+
beforeDestroy() {
|
|
46
|
+
this.swipeaction.children.forEach((item, index) => {
|
|
47
|
+
if (item === this) {
|
|
48
|
+
this.swipeaction.children.splice(index, 1)
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
},
|
|
52
|
+
methods: {
|
|
53
|
+
init() {
|
|
54
|
+
this.x = 0
|
|
55
|
+
this.button = {
|
|
56
|
+
show: false
|
|
57
|
+
}
|
|
58
|
+
this.$nextTick(()=>{
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
this.getSelectorQuery()
|
|
61
|
+
}, 200)
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
},
|
|
66
|
+
onClick(index, item, position) {
|
|
67
|
+
this.$emit('click', {
|
|
68
|
+
content: item,
|
|
69
|
+
index,
|
|
70
|
+
position
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
touchstart(e) {
|
|
74
|
+
// 每次只触发一次,避免多次监听造成闪烁
|
|
75
|
+
if (this.stop) return
|
|
76
|
+
this.stop = true
|
|
77
|
+
if (this.autoClose) {
|
|
78
|
+
this.swipeaction.closeOther(this)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const leftWidth = this.button.left.width
|
|
82
|
+
const rightWidth = this.button.right.width
|
|
83
|
+
let expression = this.range(this.x, -rightWidth, leftWidth)
|
|
84
|
+
let leftExpression = this.range(this.x - leftWidth, -leftWidth, 0)
|
|
85
|
+
let rightExpression = this.range(this.x + rightWidth, 0, rightWidth)
|
|
86
|
+
|
|
87
|
+
this.eventpan = BindingX.bind({
|
|
88
|
+
anchor: this.box,
|
|
89
|
+
eventType: 'pan',
|
|
90
|
+
props: [{
|
|
91
|
+
element: this.selector,
|
|
92
|
+
property: 'transform.translateX',
|
|
93
|
+
expression
|
|
94
|
+
}, {
|
|
95
|
+
element: this.leftButton,
|
|
96
|
+
property: 'transform.translateX',
|
|
97
|
+
expression: leftExpression
|
|
98
|
+
}, {
|
|
99
|
+
element: this.rightButton,
|
|
100
|
+
property: 'transform.translateX',
|
|
101
|
+
expression: rightExpression
|
|
102
|
+
}, ]
|
|
103
|
+
}, (e) => {
|
|
104
|
+
// nope
|
|
105
|
+
if (e.state === 'end') {
|
|
106
|
+
this.x = e.deltaX + this.x;
|
|
107
|
+
this.isclick = true
|
|
108
|
+
this.bindTiming(e.deltaX)
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
touchend(e) {
|
|
113
|
+
if (this.isopen !== 'none' && !this.isclick) {
|
|
114
|
+
this.open('none')
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
bindTiming(x) {
|
|
118
|
+
const left = this.x
|
|
119
|
+
const leftWidth = this.button.left.width
|
|
120
|
+
const rightWidth = this.button.right.width
|
|
121
|
+
const threshold = this.threshold
|
|
122
|
+
if (!this.isopen || this.isopen === 'none') {
|
|
123
|
+
if (left > threshold) {
|
|
124
|
+
this.open('left')
|
|
125
|
+
} else if (left < -threshold) {
|
|
126
|
+
this.open('right')
|
|
127
|
+
} else {
|
|
128
|
+
this.open('none')
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
if ((x > -leftWidth && x < 0) || x > rightWidth) {
|
|
132
|
+
if ((x > -threshold && x < 0) || (x - rightWidth > threshold)) {
|
|
133
|
+
this.open('left')
|
|
134
|
+
} else {
|
|
135
|
+
this.open('none')
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
if ((x < threshold && x > 0) || (x + leftWidth < -threshold)) {
|
|
139
|
+
this.open('right')
|
|
140
|
+
} else {
|
|
141
|
+
this.open('none')
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 移动范围
|
|
149
|
+
* @param {Object} num
|
|
150
|
+
* @param {Object} mix
|
|
151
|
+
* @param {Object} max
|
|
152
|
+
*/
|
|
153
|
+
range(num, mix, max) {
|
|
154
|
+
return `min(max(x+${num}, ${mix}), ${max})`
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 开启swipe
|
|
159
|
+
*/
|
|
160
|
+
open(type) {
|
|
161
|
+
this.animation(type)
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 关闭swipe
|
|
166
|
+
*/
|
|
167
|
+
close() {
|
|
168
|
+
this.animation('none')
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 开启关闭动画
|
|
173
|
+
* @param {Object} type
|
|
174
|
+
*/
|
|
175
|
+
animation(type) {
|
|
176
|
+
const time = 300
|
|
177
|
+
const leftWidth = this.button.left.width
|
|
178
|
+
const rightWidth = this.button.right.width
|
|
179
|
+
if (this.eventpan && this.eventpan.token) {
|
|
180
|
+
BindingX.unbind({
|
|
181
|
+
token: this.eventpan.token,
|
|
182
|
+
eventType: 'pan'
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
switch (type) {
|
|
187
|
+
case 'left':
|
|
188
|
+
Promise.all([
|
|
189
|
+
this.move(this.selector, leftWidth),
|
|
190
|
+
this.move(this.leftButton, 0),
|
|
191
|
+
this.move(this.rightButton, rightWidth * 2)
|
|
192
|
+
]).then(() => {
|
|
193
|
+
this.setEmit(leftWidth, type)
|
|
194
|
+
})
|
|
195
|
+
break
|
|
196
|
+
case 'right':
|
|
197
|
+
Promise.all([
|
|
198
|
+
this.move(this.selector, -rightWidth),
|
|
199
|
+
this.move(this.leftButton, -leftWidth * 2),
|
|
200
|
+
this.move(this.rightButton, 0)
|
|
201
|
+
]).then(() => {
|
|
202
|
+
this.setEmit(-rightWidth, type)
|
|
203
|
+
})
|
|
204
|
+
break
|
|
205
|
+
default:
|
|
206
|
+
Promise.all([
|
|
207
|
+
this.move(this.selector, 0),
|
|
208
|
+
this.move(this.leftButton, -leftWidth),
|
|
209
|
+
this.move(this.rightButton, rightWidth)
|
|
210
|
+
]).then(() => {
|
|
211
|
+
this.setEmit(0, type)
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
setEmit(x, type) {
|
|
217
|
+
const leftWidth = this.button.left.width
|
|
218
|
+
const rightWidth = this.button.right.width
|
|
219
|
+
this.isopen = this.isopen || 'none'
|
|
220
|
+
this.stop = false
|
|
221
|
+
this.isclick = false
|
|
222
|
+
// 只有状态不一致才会返回结果
|
|
223
|
+
if (this.isopen !== type && this.x !== x) {
|
|
224
|
+
if (type === 'left' && leftWidth > 0) {
|
|
225
|
+
this.$emit('change', 'left')
|
|
226
|
+
}
|
|
227
|
+
if (type === 'right' && rightWidth > 0) {
|
|
228
|
+
this.$emit('change', 'right')
|
|
229
|
+
}
|
|
230
|
+
if (type === 'none') {
|
|
231
|
+
this.$emit('change', 'none')
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
this.x = x
|
|
235
|
+
this.isopen = type
|
|
236
|
+
},
|
|
237
|
+
move(ref, value) {
|
|
238
|
+
return new Promise((resolve, reject) => {
|
|
239
|
+
animation.transition(ref, {
|
|
240
|
+
styles: {
|
|
241
|
+
transform: `translateX(${value})`,
|
|
242
|
+
},
|
|
243
|
+
duration: 150, //ms
|
|
244
|
+
timingFunction: 'linear',
|
|
245
|
+
needLayout: false,
|
|
246
|
+
delay: 0 //ms
|
|
247
|
+
}, function(res) {
|
|
248
|
+
resolve(res)
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* 获取ref
|
|
256
|
+
* @param {Object} el
|
|
257
|
+
*/
|
|
258
|
+
getEl(el) {
|
|
259
|
+
return el.ref
|
|
260
|
+
},
|
|
261
|
+
/**
|
|
262
|
+
* 获取节点信息
|
|
263
|
+
*/
|
|
264
|
+
getSelectorQuery() {
|
|
265
|
+
Promise.all([
|
|
266
|
+
this.getDom('left'),
|
|
267
|
+
this.getDom('right'),
|
|
268
|
+
]).then((data) => {
|
|
269
|
+
let show = 'none'
|
|
270
|
+
if (this.autoClose) {
|
|
271
|
+
show = 'none'
|
|
272
|
+
} else {
|
|
273
|
+
show = this.show
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (show === 'none') {
|
|
277
|
+
// this.close()
|
|
278
|
+
} else {
|
|
279
|
+
this.open(show)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
},
|
|
285
|
+
getDom(str) {
|
|
286
|
+
return new Promise((resolve, reject) => {
|
|
287
|
+
dom.getComponentRect(this.$refs[`selector-${str}-button--hock`], (data) => {
|
|
288
|
+
if (data) {
|
|
289
|
+
this.button[str] = data.size
|
|
290
|
+
resolve(data)
|
|
291
|
+
} else {
|
|
292
|
+
reject()
|
|
293
|
+
}
|
|
294
|
+
})
|
|
295
|
+
})
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|