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,252 @@
|
|
|
1
|
+
const MIN_DISTANCE = 10;
|
|
2
|
+
export default {
|
|
3
|
+
data() {
|
|
4
|
+
return {
|
|
5
|
+
uniShow: false,
|
|
6
|
+
left: 0,
|
|
7
|
+
buttonShow: 'none',
|
|
8
|
+
ani: false,
|
|
9
|
+
moveLeft:''
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
watch: {
|
|
13
|
+
show(newVal) {
|
|
14
|
+
if (this.autoClose) return
|
|
15
|
+
this.openState(newVal)
|
|
16
|
+
},
|
|
17
|
+
left(){
|
|
18
|
+
this.moveLeft = `translateX(${this.left}px)`
|
|
19
|
+
},
|
|
20
|
+
buttonShow(newVal){
|
|
21
|
+
if (this.autoClose) return
|
|
22
|
+
this.openState(newVal)
|
|
23
|
+
},
|
|
24
|
+
leftOptions() {
|
|
25
|
+
this.init()
|
|
26
|
+
},
|
|
27
|
+
rightOptions() {
|
|
28
|
+
this.init()
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
mounted() {
|
|
32
|
+
// this.position = {}
|
|
33
|
+
if (this.swipeaction.children !== undefined) {
|
|
34
|
+
this.swipeaction.children.push(this)
|
|
35
|
+
}
|
|
36
|
+
this.init()
|
|
37
|
+
},
|
|
38
|
+
beforeDestoy() {
|
|
39
|
+
this.swipeaction.children.forEach((item, index) => {
|
|
40
|
+
if (item === this) {
|
|
41
|
+
this.swipeaction.children.splice(index, 1)
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
},
|
|
45
|
+
methods: {
|
|
46
|
+
init(){
|
|
47
|
+
clearTimeout(this.timer)
|
|
48
|
+
this.timer = setTimeout(() => {
|
|
49
|
+
this.getSelectorQuery()
|
|
50
|
+
}, 100)
|
|
51
|
+
// 移动距离
|
|
52
|
+
this.left = 0
|
|
53
|
+
this.x = 0
|
|
54
|
+
},
|
|
55
|
+
closeSwipe(e) {
|
|
56
|
+
if (!this.autoClose) return
|
|
57
|
+
this.swipeaction.closeOther(this)
|
|
58
|
+
},
|
|
59
|
+
appTouchStart(e) {
|
|
60
|
+
const {
|
|
61
|
+
clientX
|
|
62
|
+
} = e.changedTouches[0]
|
|
63
|
+
this.clientX = clientX
|
|
64
|
+
this.timestamp = new Date().getTime()
|
|
65
|
+
},
|
|
66
|
+
appTouchEnd(e, index, item, position) {
|
|
67
|
+
const {
|
|
68
|
+
clientX
|
|
69
|
+
} = e.changedTouches[0]
|
|
70
|
+
// fixed by xxxx 模拟点击事件,解决 ios 13 点击区域错位的问题
|
|
71
|
+
let diff = Math.abs(this.clientX - clientX)
|
|
72
|
+
let time = (new Date().getTime()) - this.timestamp
|
|
73
|
+
if (diff < 40 && time < 300) {
|
|
74
|
+
this.$emit('click', {
|
|
75
|
+
content: item,
|
|
76
|
+
index,
|
|
77
|
+
position
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
touchstart(e) {
|
|
82
|
+
if (this.disabled) return
|
|
83
|
+
this.ani = false
|
|
84
|
+
this.x = this.left || 0
|
|
85
|
+
this.stopTouchStart(e)
|
|
86
|
+
this.autoClose && this.closeSwipe()
|
|
87
|
+
},
|
|
88
|
+
touchmove(e) {
|
|
89
|
+
if (this.disabled) return
|
|
90
|
+
// 是否可以滑动页面
|
|
91
|
+
this.stopTouchMove(e);
|
|
92
|
+
if (this.direction !== 'horizontal') {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.move(this.x + this.deltaX)
|
|
97
|
+
},
|
|
98
|
+
touchend() {
|
|
99
|
+
if (this.disabled) return
|
|
100
|
+
this.moveDirection(this.left)
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* 设置移动距离
|
|
104
|
+
* @param {Object} value
|
|
105
|
+
*/
|
|
106
|
+
move(value) {
|
|
107
|
+
value = value || 0
|
|
108
|
+
const leftWidth = this.leftWidth
|
|
109
|
+
const rightWidth = this.rightWidth
|
|
110
|
+
// 获取可滑动范围
|
|
111
|
+
this.left = this.range(value, -rightWidth, leftWidth);
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 获取范围
|
|
116
|
+
* @param {Object} num
|
|
117
|
+
* @param {Object} min
|
|
118
|
+
* @param {Object} max
|
|
119
|
+
*/
|
|
120
|
+
range(num, min, max) {
|
|
121
|
+
return Math.min(Math.max(num, min), max);
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* 移动方向判断
|
|
125
|
+
* @param {Object} left
|
|
126
|
+
* @param {Object} value
|
|
127
|
+
*/
|
|
128
|
+
moveDirection(left) {
|
|
129
|
+
const threshold = this.threshold
|
|
130
|
+
const isopen = this.isopen || 'none'
|
|
131
|
+
const leftWidth = this.leftWidth
|
|
132
|
+
const rightWidth = this.rightWidth
|
|
133
|
+
if (this.deltaX === 0) {
|
|
134
|
+
this.openState('none')
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth > 0 && rightWidth +
|
|
138
|
+
left < threshold)) {
|
|
139
|
+
// right
|
|
140
|
+
this.openState('right')
|
|
141
|
+
} else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth > 0 &&
|
|
142
|
+
leftWidth - left < threshold)) {
|
|
143
|
+
// left
|
|
144
|
+
this.openState('left')
|
|
145
|
+
} else {
|
|
146
|
+
// default
|
|
147
|
+
this.openState('none')
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 开启状态
|
|
153
|
+
* @param {Boolean} type
|
|
154
|
+
*/
|
|
155
|
+
openState(type) {
|
|
156
|
+
const leftWidth = this.leftWidth
|
|
157
|
+
const rightWidth = this.rightWidth
|
|
158
|
+
let left = ''
|
|
159
|
+
this.isopen = this.isopen ? this.isopen : 'none'
|
|
160
|
+
switch (type) {
|
|
161
|
+
case "left":
|
|
162
|
+
left = leftWidth
|
|
163
|
+
break
|
|
164
|
+
case "right":
|
|
165
|
+
left = -rightWidth
|
|
166
|
+
break
|
|
167
|
+
default:
|
|
168
|
+
left = 0
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
if (this.isopen !== type) {
|
|
173
|
+
this.throttle = true
|
|
174
|
+
this.$emit('change', type)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
this.isopen = type
|
|
178
|
+
// 添加动画类
|
|
179
|
+
this.ani = true
|
|
180
|
+
this.$nextTick(() => {
|
|
181
|
+
this.move(left)
|
|
182
|
+
})
|
|
183
|
+
// 设置最终移动位置,理论上只要进入到这个函数,肯定是要打开的
|
|
184
|
+
},
|
|
185
|
+
close() {
|
|
186
|
+
this.openState('none')
|
|
187
|
+
},
|
|
188
|
+
getDirection(x, y) {
|
|
189
|
+
if (x > y && x > MIN_DISTANCE) {
|
|
190
|
+
return 'horizontal';
|
|
191
|
+
}
|
|
192
|
+
if (y > x && y > MIN_DISTANCE) {
|
|
193
|
+
return 'vertical';
|
|
194
|
+
}
|
|
195
|
+
return '';
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 重置滑动状态
|
|
200
|
+
* @param {Object} event
|
|
201
|
+
*/
|
|
202
|
+
resetTouchStatus() {
|
|
203
|
+
this.direction = '';
|
|
204
|
+
this.deltaX = 0;
|
|
205
|
+
this.deltaY = 0;
|
|
206
|
+
this.offsetX = 0;
|
|
207
|
+
this.offsetY = 0;
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* 设置滑动开始位置
|
|
212
|
+
* @param {Object} event
|
|
213
|
+
*/
|
|
214
|
+
stopTouchStart(event) {
|
|
215
|
+
this.resetTouchStatus();
|
|
216
|
+
const touch = event.touches[0];
|
|
217
|
+
this.startX = touch.clientX;
|
|
218
|
+
this.startY = touch.clientY;
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 滑动中,是否禁止打开
|
|
223
|
+
* @param {Object} event
|
|
224
|
+
*/
|
|
225
|
+
stopTouchMove(event) {
|
|
226
|
+
const touch = event.touches[0];
|
|
227
|
+
this.deltaX = touch.clientX - this.startX;
|
|
228
|
+
this.deltaY = touch.clientY - this.startY;
|
|
229
|
+
this.offsetX = Math.abs(this.deltaX);
|
|
230
|
+
this.offsetY = Math.abs(this.deltaY);
|
|
231
|
+
this.direction = this.direction || this.getDirection(this.offsetX, this.offsetY);
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
getSelectorQuery() {
|
|
235
|
+
const views = uni.createSelectorQuery().in(this)
|
|
236
|
+
views
|
|
237
|
+
.selectAll('.uni-swipe_button-group')
|
|
238
|
+
.boundingClientRect(data => {
|
|
239
|
+
let show = 'none'
|
|
240
|
+
if (this.autoClose) {
|
|
241
|
+
show = 'none'
|
|
242
|
+
} else {
|
|
243
|
+
show = this.show
|
|
244
|
+
}
|
|
245
|
+
this.leftWidth = data[0].width || 0
|
|
246
|
+
this.rightWidth = data[1].width || 0
|
|
247
|
+
this.buttonShow = show
|
|
248
|
+
})
|
|
249
|
+
.exec()
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { isPC } from "./isPC"
|
|
2
|
+
export default {
|
|
3
|
+
data() {
|
|
4
|
+
return {
|
|
5
|
+
position: [],
|
|
6
|
+
button: {},
|
|
7
|
+
btn: "[]"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
// computed: {
|
|
11
|
+
// pos() {
|
|
12
|
+
// return JSON.stringify(this.position)
|
|
13
|
+
// },
|
|
14
|
+
// btn() {
|
|
15
|
+
// return JSON.stringify(this.button)
|
|
16
|
+
// }
|
|
17
|
+
// },
|
|
18
|
+
watch: {
|
|
19
|
+
button: {
|
|
20
|
+
handler(newVal) {
|
|
21
|
+
this.btn = JSON.stringify(newVal)
|
|
22
|
+
},
|
|
23
|
+
deep: true
|
|
24
|
+
},
|
|
25
|
+
show(newVal) {
|
|
26
|
+
if (this.autoClose) return
|
|
27
|
+
if (!this.button) {
|
|
28
|
+
this.init()
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
this.button.show = newVal
|
|
32
|
+
},
|
|
33
|
+
leftOptions() {
|
|
34
|
+
this.init()
|
|
35
|
+
},
|
|
36
|
+
rightOptions() {
|
|
37
|
+
this.init()
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
created() {
|
|
41
|
+
if (this.swipeaction.children !== undefined) {
|
|
42
|
+
this.swipeaction.children.push(this)
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
mounted() {
|
|
46
|
+
this.$nextTick(() => {
|
|
47
|
+
this.init()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
},
|
|
51
|
+
beforeDestroy() {
|
|
52
|
+
this.swipeaction.children.forEach((item, index) => {
|
|
53
|
+
if (item === this) {
|
|
54
|
+
this.swipeaction.children.splice(index, 1)
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
},
|
|
58
|
+
methods: {
|
|
59
|
+
init() {
|
|
60
|
+
this.$nextTick(() => {
|
|
61
|
+
clearTimeout(this.swipetimer)
|
|
62
|
+
this.swipetimer = setTimeout(() => {
|
|
63
|
+
this.getButtonSize()
|
|
64
|
+
}, 50)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
},
|
|
68
|
+
closeSwipe(e) {
|
|
69
|
+
if (!this.autoClose) return
|
|
70
|
+
this.swipeaction.closeOther(this)
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
change(e) {
|
|
74
|
+
this.$emit('change', e.open)
|
|
75
|
+
let show = this.button.show
|
|
76
|
+
if (show !== e.open) {
|
|
77
|
+
this.button.show = e.open
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
appTouchStart(e) {
|
|
83
|
+
// #ifdef H5
|
|
84
|
+
if(isPC()) return
|
|
85
|
+
// #endif
|
|
86
|
+
const {
|
|
87
|
+
clientX
|
|
88
|
+
} = e.changedTouches[0]
|
|
89
|
+
this.clientX = clientX
|
|
90
|
+
this.timestamp = new Date().getTime()
|
|
91
|
+
},
|
|
92
|
+
appTouchEnd(e, index, item, position) {
|
|
93
|
+
// #ifdef H5
|
|
94
|
+
if(isPC()) return
|
|
95
|
+
// #endif
|
|
96
|
+
const {
|
|
97
|
+
clientX
|
|
98
|
+
} = e.changedTouches[0]
|
|
99
|
+
// fixed by xxxx 模拟点击事件,解决 ios 13 点击区域错位的问题
|
|
100
|
+
let diff = Math.abs(this.clientX - clientX)
|
|
101
|
+
let time = (new Date().getTime()) - this.timestamp
|
|
102
|
+
if (diff < 40 && time < 300) {
|
|
103
|
+
this.$emit('click', {
|
|
104
|
+
content: item,
|
|
105
|
+
index,
|
|
106
|
+
position
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
onClickForPC(index, item, position) {
|
|
112
|
+
// #ifdef H5
|
|
113
|
+
if(!isPC()) return
|
|
114
|
+
// #endif
|
|
115
|
+
this.$emit('click', {
|
|
116
|
+
content: item,
|
|
117
|
+
index,
|
|
118
|
+
position
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
getButtonSize() {
|
|
122
|
+
const views = uni.createSelectorQuery().in(this)
|
|
123
|
+
views
|
|
124
|
+
.selectAll('.uni-swipe_button-group')
|
|
125
|
+
.boundingClientRect(data => {
|
|
126
|
+
let show = 'none'
|
|
127
|
+
if (this.autoClose) {
|
|
128
|
+
show = 'none'
|
|
129
|
+
} else {
|
|
130
|
+
show = this.show
|
|
131
|
+
}
|
|
132
|
+
this.button = {
|
|
133
|
+
data,
|
|
134
|
+
show
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
.exec()
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|