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.
Files changed (215) hide show
  1. package/.editorconfig +14 -0
  2. package/README.md +447 -0
  3. package/index.js +3 -0
  4. package/package.json +104 -0
  5. package/postcss.config.js +22 -0
  6. package/settings.js.tpl +68 -0
  7. package/src/XdAppClass.1.0.js +257 -0
  8. package/src/XdAppClass.js +150 -0
  9. package/src/components/XdAddress/XdAddress.vue +579 -0
  10. package/src/components/XdAddressSelect/XdAddressSelect.vue +243 -0
  11. package/src/components/XdBaiduMap/XdBaiduMap.vue +204 -0
  12. package/src/components/XdBaiduOverlay/XdBaiduOverlay.vue +345 -0
  13. package/src/components/XdBaiduSearch/XdBaiduSearch.vue +354 -0
  14. package/src/components/XdBar/XdBar.vue +339 -0
  15. package/src/components/XdButton/XdButton.vue +288 -0
  16. package/src/components/XdCartList/XdCartList.vue +791 -0
  17. package/src/components/XdCartNoStoreList/XdCartNoStoreList.vue +747 -0
  18. package/src/components/XdCity/XdCity.vue +620 -0
  19. package/src/components/XdCity/city.js +93 -0
  20. package/src/components/XdCity/testData.js +124 -0
  21. package/src/components/XdCityLocation/XdCityLocation.vue +314 -0
  22. package/src/components/XdCityLocation/jweixin.js +72 -0
  23. package/src/components/XdCityShow/XdCityShow.vue +354 -0
  24. package/src/components/XdClipImage/XdClipImage.vue +879 -0
  25. package/src/components/XdCoins/XdCoins.vue +66 -0
  26. package/src/components/XdConfirm/XdConfirm.vue +240 -0
  27. package/src/components/XdContentXss/XdContentXss.vue +71 -0
  28. package/src/components/XdDailog/XdDailog.vue +258 -0
  29. package/src/components/XdDate/XdDataItemOne.vue +236 -0
  30. package/src/components/XdDate/XdDate.vue +1081 -0
  31. package/src/components/XdDate/XdDateItem.vue +316 -0
  32. package/src/components/XdDate/XdDateTime.vue +929 -0
  33. package/src/components/XdDate/i18n/en.json +19 -0
  34. package/src/components/XdDate/i18n/index.js +8 -0
  35. package/src/components/XdDate/i18n/zh-Hans.json +19 -0
  36. package/src/components/XdDate/i18n/zh-Hant.json +19 -0
  37. package/src/components/XdDate/keypress.js +45 -0
  38. package/src/components/XdDate/util.js +418 -0
  39. package/src/components/XdDownDrawer/XdDownDrawer.vue +176 -0
  40. package/src/components/XdEditPwd/XdEditPwd.vue +305 -0
  41. package/src/components/XdEnterOrderList/XdEnterOrderList.vue +413 -0
  42. package/src/components/XdExpressTimeLine/XdExpressTimeLine.vue +280 -0
  43. package/src/components/XdFilter/XdFilter.vue +541 -0
  44. package/src/components/XdFontIcon/XdFontIcon.vue +165 -0
  45. package/src/components/XdFontIcon/css/icon.less +498 -0
  46. package/src/components/XdFooterBar/XdFooterBar.vue +291 -0
  47. package/src/components/XdFooterTabbar/XdFooterTabbar.vue +284 -0
  48. package/src/components/XdForm/XdForm.vue +481 -0
  49. package/src/components/XdForm/validate.js +486 -0
  50. package/src/components/XdFormCheckbox/XdFormCheckbox.vue +858 -0
  51. package/src/components/XdFormDate.vue +187 -0
  52. package/src/components/XdFormInput/XdFormInput.vue +535 -0
  53. package/src/components/XdFormInput/common.js +56 -0
  54. package/src/components/XdFormItem/XdFormItem.vue +583 -0
  55. package/src/components/XdFormSelect/XdFormSelect.vue +119 -0
  56. package/src/components/XdImage/XdImage.vue +113 -0
  57. package/src/components/XdItemCardUser/XdItemCardUser.vue +232 -0
  58. package/src/components/XdItemFilmImage/XdItemFilmImage.vue +146 -0
  59. package/src/components/XdItemFilmText/XdItemFilmText.vue +83 -0
  60. package/src/components/XdItemPhysical/XdItemPhysical.vue +410 -0
  61. package/src/components/XdItemPhysicalPack/XdItemPhysicalPack.vue +240 -0
  62. package/src/components/XdItemStore/XdItemStore.vue +236 -0
  63. package/src/components/XdItemUserInfo/XdItemUserInfo.vue +175 -0
  64. package/src/components/XdJson/XdJson.vue +398 -0
  65. package/src/components/XdKeyValue/XdKeyValue.vue +150 -0
  66. package/src/components/XdLabelNew/XdLabelNew.vue +193 -0
  67. package/src/components/XdLayout/XdLayout.vue +634 -0
  68. package/src/components/XdLoading/XdLoading.vue +165 -0
  69. package/src/components/XdMore/XdMore.vue +66 -0
  70. package/src/components/XdMpHtml/XdMpHtml.vue +458 -0
  71. package/src/components/XdMpHtml/node/node.vue +536 -0
  72. package/src/components/XdMpHtml/parser.js +1260 -0
  73. package/src/components/XdMpHtml/static/js/handler.js +1 -0
  74. package/src/components/XdMpHtml/static/js/uni.webview.min.js +1 -0
  75. package/src/components/XdMpHtml/static/local.html +1 -0
  76. package/src/components/XdMy/XdMy.vue +294 -0
  77. package/src/components/XdMySuccess/XdMySuccess.vue +603 -0
  78. package/src/components/XdNavTab/XdNavTab.vue +147 -0
  79. package/src/components/XdNoData/XdNoData.vue +87 -0
  80. package/src/components/XdNoticeBar/XdNoticeBar.vue +501 -0
  81. package/src/components/XdNumber/XdNumber.vue +210 -0
  82. package/src/components/XdNumberUni/XdNumberUni.vue +270 -0
  83. package/src/components/XdNumberUni/readme.md +42 -0
  84. package/src/components/XdOnlineConfirm/XdOnlineConfirm.vue +385 -0
  85. package/src/components/XdOnlineDetail/XdOnlineDetail.vue +332 -0
  86. package/src/components/XdOnlinePay/XdOnlinePay.vue +349 -0
  87. package/src/components/XdOnlineSchedule/XdOnlineSchedule.vue +453 -0
  88. package/src/components/XdOnlineSeat/XdOnlineSeat.vue +796 -0
  89. package/src/components/XdOnlineSeatMove/XdOnlineSeatMove.vue +1012 -0
  90. package/src/components/XdPayCombo/XdPayCombo.vue +118 -0
  91. package/src/components/XdPreviewImage/XdPreviewImage.vue +372 -0
  92. package/src/components/XdPwPay/XdPwPay.vue +214 -0
  93. package/src/components/XdRadio/XdRadio.vue +151 -0
  94. package/src/components/XdRangeSlider/XdRangeSlider.vue +355 -0
  95. package/src/components/XdRedName/XdRedName.vue +35 -0
  96. package/src/components/XdSearchBar/XdSearchBar.vue +286 -0
  97. package/src/components/XdSelect/XdSelect.vue +382 -0
  98. package/src/components/XdSelectCity/XdSelectCity.vue +270 -0
  99. package/src/components/XdSelectTime/XdSelectTime.vue +342 -0
  100. package/src/components/XdStar/XdStar.vue +261 -0
  101. package/src/components/XdStoreCashier/XdStoreCashier.vue +526 -0
  102. package/src/components/XdStoreItem/XdStoreItem.vue +400 -0
  103. package/src/components/XdStoreOrderDetail/XdStoreOrderDetail.vue +1571 -0
  104. package/src/components/XdStoreOrderList/XdStoreOrderList.vue +450 -0
  105. package/src/components/XdStoreProductInfo/XdStoreProductInfo.vue +940 -0
  106. package/src/components/XdStoreProductType/XdStoreProductType.vue +307 -0
  107. package/src/components/XdSuccess/XdSuccess.vue +527 -0
  108. package/src/components/XdSwipeSelect/XdSwipeSelect.vue +99 -0
  109. package/src/components/XdSwiper/XdSwiper.vue +124 -0
  110. package/src/components/XdSwitch/XdSwitch.vue +204 -0
  111. package/src/components/XdTab/XdTab.vue +220 -0
  112. package/src/components/XdTabScroll/XdTabScroll.vue +212 -0
  113. package/src/components/XdTag/XdTag.vue +423 -0
  114. package/src/components/XdTimeLine/XdTimeLine.vue +121 -0
  115. package/src/components/XdTips/XdTips.vue +212 -0
  116. package/src/components/XdTipsBlock/XdTipsBlock.vue +141 -0
  117. package/src/components/XdTitleSection/XdTitleSection.vue +152 -0
  118. package/src/components/XdTitleTab/XdTitleTab.vue +227 -0
  119. package/src/components/XdUnit/XdUnit.vue +206 -0
  120. package/src/components/XdUpload/XdUpload.vue +197 -0
  121. package/src/components/XdUploadImage/XdUploadImage.vue +145 -0
  122. package/src/components/Xdlogs/XdLogs.vue +144 -0
  123. package/src/components/autoload.js +211 -0
  124. package/src/components/swipeAction/UniSwipeAction.vue +43 -0
  125. package/src/components/swipeActionItem/UniSwipeActionItem.vue +386 -0
  126. package/src/components/swipeActionItem/bindingx.js +298 -0
  127. package/src/components/swipeActionItem/index.wxs +321 -0
  128. package/src/components/swipeActionItem/isPC.js +18 -0
  129. package/src/components/swipeActionItem/mpalipay.js +210 -0
  130. package/src/components/swipeActionItem/mpother.js +252 -0
  131. package/src/components/swipeActionItem/mpwxs.js +140 -0
  132. package/src/dome/dome/address.vue +415 -0
  133. package/src/dome/dome/auth/login.vue +166 -0
  134. package/src/dome/dome/baidu_show.vue +20 -0
  135. package/src/dome/dome/cake.vue +186 -0
  136. package/src/dome/dome/cart.vue +205 -0
  137. package/src/dome/dome/cart_store.vue +149 -0
  138. package/src/dome/dome/cashier/cashier.vue +73 -0
  139. package/src/dome/dome/cashier/check_cashier.vue +469 -0
  140. package/src/dome/dome/cashier/success.vue +127 -0
  141. package/src/dome/dome/city.vue +148 -0
  142. package/src/dome/dome/cityData.js +9 -0
  143. package/src/dome/dome/clip.vue +82 -0
  144. package/src/dome/dome/date/date.vue +273 -0
  145. package/src/dome/dome/date/selected.js +315 -0
  146. package/src/dome/dome/dcom/app1.vue +13 -0
  147. package/src/dome/dome/dcom/app2.vue +13 -0
  148. package/src/dome/dome/dcom/app3.vue +13 -0
  149. package/src/dome/dome/dcom/app4.vue +13 -0
  150. package/src/dome/dome/dcom/app5.vue +13 -0
  151. package/src/dome/dome/dcom/index.vue +1 -0
  152. package/src/dome/dome/debug/debug.vue +95 -0
  153. package/src/dome/dome/docache/docache.vue +88 -0
  154. package/src/dome/dome/express.vue +269 -0
  155. package/src/dome/dome/form.vue +312 -0
  156. package/src/dome/dome/icon.js +125 -0
  157. package/src/dome/dome/icon.vue +93 -0
  158. package/src/dome/dome/index.vue +725 -0
  159. package/src/dome/dome/item.vue +236 -0
  160. package/src/dome/dome/json/json.vue +88 -0
  161. package/src/dome/dome/layout.vue +105 -0
  162. package/src/dome/dome/line.vue +113 -0
  163. package/src/dome/dome/map/search.vue +70 -0
  164. package/src/dome/dome/my.vue +171 -0
  165. package/src/dome/dome/notice.vue +93 -0
  166. package/src/dome/dome/online/confirm.vue +92 -0
  167. package/src/dome/dome/online/detail.vue +80 -0
  168. package/src/dome/dome/online/pay.vue +78 -0
  169. package/src/dome/dome/online/schedule.vue +73 -0
  170. package/src/dome/dome/online/seat.vue +98 -0
  171. package/src/dome/dome/order/detail.vue +166 -0
  172. package/src/dome/dome/order/enter_order.vue +294 -0
  173. package/src/dome/dome/order/list.vue +219 -0
  174. package/src/dome/dome/order/order.js +18 -0
  175. package/src/dome/dome/order/success.vue +68 -0
  176. package/src/dome/dome/product.vue +179 -0
  177. package/src/dome/dome/store_cashier.vue +67 -0
  178. package/src/dome/dome/swiper.vue +32 -0
  179. package/src/dome/dome/webview.vue +61 -0
  180. package/src/install.js +183 -0
  181. package/src/main/address/address.vue +251 -0
  182. package/src/main/cart/cart.vue +149 -0
  183. package/src/main/cashier/cashier.vue +72 -0
  184. package/src/main/cashier/check_cashier.vue +483 -0
  185. package/src/main/city/city.vue +149 -0
  186. package/src/main/date/date.vue +260 -0
  187. package/src/main/order/order.js +19 -0
  188. package/src/main/order/order.vue +222 -0
  189. package/src/main/product/detail.vue +121 -0
  190. package/src/main/product/type.vue +108 -0
  191. package/src/main/search/search.vue +501 -0
  192. package/src/pages.json +337 -0
  193. package/src/plugins/CreatedComponentsPlugin.js +19 -0
  194. package/src/plugins/JsonRename.js +72 -0
  195. package/src/plugins/SetAppParams.js +171 -0
  196. package/src/project.js +18 -0
  197. package/src/utils/Cookie.js +68 -0
  198. package/src/utils/Runtime.js +105 -0
  199. package/src/utils/Storage.js +104 -0
  200. package/src/utils/XdNetwork.js +133 -0
  201. package/src/utils/helper.js +1321 -0
  202. package/src/utils/nourl.js +95 -0
  203. package/src/utils/project.js +17 -0
  204. package/src/utils/xd.auth.js +61 -0
  205. package/src/utils/xd.base.js +474 -0
  206. package/src/utils/xd.common.js +240 -0
  207. package/src/utils/xd.event.js +99 -0
  208. package/src/utils/xd.frame.js +96 -0
  209. package/src/utils/xd.path.js +96 -0
  210. package/src/utils/xdAppLog.js +170 -0
  211. package/src/utils/xdWxLog.js +302 -0
  212. package/src/utils/xdh5log.js +307 -0
  213. package/src/websetting.js +64 -0
  214. package/tsconfig.json +9 -0
  215. package/xd.less +180 -0
@@ -0,0 +1,929 @@
1
+ <template>
2
+ <view class="uni-datetime-picker">
3
+ <view @click="initTimePicker">
4
+ <slot>
5
+ <view class="uni-datetime-picker-timebox-pointer"
6
+ :class="{'uni-datetime-picker-disabled': disabled, 'uni-datetime-picker-timebox': border}">
7
+ <text class="uni-datetime-picker-text">{{time}}</text>
8
+ <view v-if="!time" class="uni-datetime-picker-time">
9
+ <xd-font-icon icon="iconxuanzeriqi" size="26"></xd-font-icon>
10
+ </view>
11
+ </view>
12
+ </slot>
13
+ </view>
14
+ <view v-if="visible" id="mask" class="uni-datetime-picker-mask" @click="tiggerTimePicker"></view>
15
+ <view v-if="visible" class="uni-datetime-picker-popup" :class="[dateShow && timeShow ? '' : 'fix-nvue-height']"
16
+ :style="fixNvueBug">
17
+ <view class="uni-title">
18
+ <text class="uni-datetime-picker-text">{{selectTimeText}}</text>
19
+ </view>
20
+ <view v-if="dateShow" class="uni-datetime-picker__container-box">
21
+ <picker-view class="uni-datetime-picker-view" :indicator-style="indicatorStyle" :value="ymd"
22
+ @change="bindDateChange">
23
+ <picker-view-column>
24
+ <view class="uni-datetime-picker-item" v-for="(item,index) in years" :key="index">
25
+ <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
26
+ </view>
27
+ </picker-view-column>
28
+ <picker-view-column>
29
+ <view class="uni-datetime-picker-item" v-for="(item,index) in months" :key="index">
30
+ <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
31
+ </view>
32
+ </picker-view-column>
33
+ <picker-view-column>
34
+ <view class="uni-datetime-picker-item" v-for="(item,index) in days" :key="index">
35
+ <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
36
+ </view>
37
+ </picker-view-column>
38
+ </picker-view>
39
+ <!-- 兼容 nvue 不支持伪类 -->
40
+ <text class="uni-datetime-picker-sign sign-left">-</text>
41
+ <text class="uni-datetime-picker-sign sign-right">-</text>
42
+ </view>
43
+ <view v-if="timeShow" class="uni-datetime-picker__container-box">
44
+ <picker-view class="uni-datetime-picker-view" :class="[hideSecond ? 'time-hide-second' : '']"
45
+ :indicator-style="indicatorStyle" :value="hms" @change="bindTimeChange">
46
+ <picker-view-column>
47
+ <view class="uni-datetime-picker-item" v-for="(item,index) in hours" :key="index">
48
+ <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
49
+ </view>
50
+ </picker-view-column>
51
+ <picker-view-column>
52
+ <view class="uni-datetime-picker-item" v-for="(item,index) in minutes" :key="index">
53
+ <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
54
+ </view>
55
+ </picker-view-column>
56
+ <picker-view-column v-if="!hideSecond">
57
+ <view class="uni-datetime-picker-item" v-for="(item,index) in seconds" :key="index">
58
+ <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
59
+ </view>
60
+ </picker-view-column>
61
+ </picker-view>
62
+ <!-- 兼容 nvue 不支持伪类 -->
63
+ <text class="uni-datetime-picker-sign" :class="[hideSecond ? 'sign-center' : 'sign-left']">:</text>
64
+ <text v-if="!hideSecond" class="uni-datetime-picker-sign sign-right">:</text>
65
+ </view>
66
+ <view class="uni-datetime-picker-btn">
67
+ <view @click="clearTime">
68
+ <text class="uni-datetime-picker-btn-text">{{clearText}}</text>
69
+ </view>
70
+ <view class="uni-datetime-picker-btn-group">
71
+ <view class="uni-datetime-picker-cancel" @click="tiggerTimePicker">
72
+ <text class="uni-datetime-picker-btn-text">{{cancelText}}</text>
73
+ </view>
74
+ <view @click="setTime">
75
+ <text class="uni-datetime-picker-btn-text">{{okText}}</text>
76
+ </view>
77
+ </view>
78
+ </view>
79
+ </view>
80
+ </view>
81
+ </template>
82
+
83
+ <script>
84
+ // #ifdef H5
85
+ import keypress from './keypress'
86
+ // #endif
87
+ import {
88
+ initVueI18n
89
+ } from '@dcloudio/uni-i18n'
90
+ import messages from './i18n/index.js'
91
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
92
+ const { t } = initVueI18n('zh', messages)
93
+
94
+ /**
95
+ * DatetimePicker 时间选择器
96
+ * @description 可以同时选择日期和时间的选择器
97
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=xxx
98
+ * @property {String} type = [datetime | date | time] 显示模式
99
+ * @property {Boolean} multiple = [true|false] 是否多选
100
+ * @property {String|Number} value 默认值
101
+ * @property {String|Number} start 起始日期或时间
102
+ * @property {String|Number} end 起始日期或时间
103
+ * @property {String} return-type = [timestamp | string]
104
+ * @event {Function} change 选中发生变化触发
105
+ */
106
+
107
+ export default {
108
+ name: 'UniDatetimePicker',
109
+ components: {
110
+ XdFontIcon,
111
+ // #ifdef H5
112
+ keypress
113
+ // #endif
114
+ },
115
+ data() {
116
+ return {
117
+ indicatorStyle: `height: 50px;`,
118
+ visible: false,
119
+ fixNvueBug: {},
120
+ dateShow: true,
121
+ timeShow: true,
122
+ title: '日期和时间',
123
+ // 输入框当前时间
124
+ time: '',
125
+ // 当前的年月日时分秒
126
+ year: 1920,
127
+ month: 0,
128
+ day: 0,
129
+ hour: 0,
130
+ minute: 0,
131
+ second: 0,
132
+ // 起始时间
133
+ startYear: 1920,
134
+ startMonth: 1,
135
+ startDay: 1,
136
+ startHour: 0,
137
+ startMinute: 0,
138
+ startSecond: 0,
139
+ // 结束时间
140
+ endYear: 2120,
141
+ endMonth: 12,
142
+ endDay: 31,
143
+ endHour: 23,
144
+ endMinute: 59,
145
+ endSecond: 59,
146
+ }
147
+ },
148
+ props: {
149
+ type: {
150
+ type: String,
151
+ default: 'datetime'
152
+ },
153
+ value: {
154
+ type: [String, Number],
155
+ default: ''
156
+ },
157
+ modelValue: {
158
+ type: [String, Number],
159
+ default: ''
160
+ },
161
+ start: {
162
+ type: [Number, String],
163
+ default: ''
164
+ },
165
+ end: {
166
+ type: [Number, String],
167
+ default: ''
168
+ },
169
+ returnType: {
170
+ type: String,
171
+ default: 'string'
172
+ },
173
+ disabled: {
174
+ type: [Boolean, String],
175
+ default: false
176
+ },
177
+ border: {
178
+ type: [Boolean, String],
179
+ default: true
180
+ },
181
+ hideSecond: {
182
+ type: [Boolean, String],
183
+ default: false
184
+ }
185
+ },
186
+ watch: {
187
+ value: {
188
+ handler(newVal, oldVal) {
189
+ if (newVal) {
190
+ this.parseValue(this.fixIosDateFormat(newVal)) //兼容 iOS、safari 日期格式
191
+ this.initTime(false)
192
+ } else {
193
+ this.time = ''
194
+ this.parseValue(Date.now())
195
+ }
196
+ },
197
+ immediate: true
198
+ },
199
+ type: {
200
+ handler(newValue) {
201
+ if (newValue === 'date') {
202
+ this.dateShow = true
203
+ this.timeShow = false
204
+ this.title = '日期'
205
+ } else if (newValue === 'time') {
206
+ this.dateShow = false
207
+ this.timeShow = true
208
+ this.title = '时间'
209
+ } else {
210
+ this.dateShow = true
211
+ this.timeShow = true
212
+ this.title = '日期和时间'
213
+ }
214
+ },
215
+ immediate: true
216
+ },
217
+ start: {
218
+ handler(newVal) {
219
+ this.parseDatetimeRange(this.fixIosDateFormat(newVal), 'start') //兼容 iOS、safari 日期格式
220
+ },
221
+ immediate: true
222
+ },
223
+ end: {
224
+ handler(newVal) {
225
+ this.parseDatetimeRange(this.fixIosDateFormat(newVal), 'end') //兼容 iOS、safari 日期格式
226
+ },
227
+ immediate: true
228
+ },
229
+
230
+ // 月、日、时、分、秒可选范围变化后,检查当前值是否在范围内,不在则当前值重置为可选范围第一项
231
+ months(newVal) {
232
+ this.checkValue('month', this.month, newVal)
233
+ },
234
+ days(newVal) {
235
+ this.checkValue('day', this.day, newVal)
236
+ },
237
+ hours(newVal) {
238
+ this.checkValue('hour', this.hour, newVal)
239
+ },
240
+ minutes(newVal) {
241
+ this.checkValue('minute', this.minute, newVal)
242
+ },
243
+ seconds(newVal) {
244
+ this.checkValue('second', this.second, newVal)
245
+ }
246
+ },
247
+ computed: {
248
+ // 当前年、月、日、时、分、秒选择范围
249
+ years() {
250
+ return this.getCurrentRange('year')
251
+ },
252
+
253
+ months() {
254
+ return this.getCurrentRange('month')
255
+ },
256
+
257
+ days() {
258
+ return this.getCurrentRange('day')
259
+ },
260
+
261
+ hours() {
262
+ return this.getCurrentRange('hour')
263
+ },
264
+
265
+ minutes() {
266
+ return this.getCurrentRange('minute')
267
+ },
268
+
269
+ seconds() {
270
+ return this.getCurrentRange('second')
271
+ },
272
+
273
+ // picker 当前值数组
274
+ ymd() {
275
+ return [this.year - this.minYear, this.month - this.minMonth, this.day - this.minDay]
276
+ },
277
+ hms() {
278
+ return [this.hour - this.minHour, this.minute - this.minMinute, this.second - this.minSecond]
279
+ },
280
+
281
+ // 当前 date 是 start
282
+ currentDateIsStart() {
283
+ return this.year === this.startYear && this.month === this.startMonth && this.day === this.startDay
284
+ },
285
+
286
+ // 当前 date 是 end
287
+ currentDateIsEnd() {
288
+ return this.year === this.endYear && this.month === this.endMonth && this.day === this.endDay
289
+ },
290
+
291
+ // 当前年、月、日、时、分、秒的最小值和最大值
292
+ minYear() {
293
+ return this.startYear
294
+ },
295
+ maxYear() {
296
+ return this.endYear
297
+ },
298
+ minMonth() {
299
+ if (this.year === this.startYear) {
300
+ return this.startMonth
301
+ } else {
302
+ return 1
303
+ }
304
+ },
305
+ maxMonth() {
306
+ if (this.year === this.endYear) {
307
+ return this.endMonth
308
+ } else {
309
+ return 12
310
+ }
311
+ },
312
+ minDay() {
313
+ if (this.year === this.startYear && this.month === this.startMonth) {
314
+ return this.startDay
315
+ } else {
316
+ return 1
317
+ }
318
+ },
319
+ maxDay() {
320
+ if (this.year === this.endYear && this.month === this.endMonth) {
321
+ return this.endDay
322
+ } else {
323
+ return this.daysInMonth(this.year, this.month)
324
+ }
325
+ },
326
+ minHour() {
327
+ if (this.type === 'datetime') {
328
+ if (this.currentDateIsStart) {
329
+ return this.startHour
330
+ } else {
331
+ return 0
332
+ }
333
+ }
334
+ if (this.type === 'time') {
335
+ return this.startHour
336
+ }
337
+ },
338
+ maxHour() {
339
+ if (this.type === 'datetime') {
340
+ if (this.currentDateIsEnd) {
341
+ return this.endHour
342
+ } else {
343
+ return 23
344
+ }
345
+ }
346
+ if (this.type === 'time') {
347
+ return this.endHour
348
+ }
349
+ },
350
+ minMinute() {
351
+ if (this.type === 'datetime') {
352
+ if (this.currentDateIsStart && this.hour === this.startHour) {
353
+ return this.startMinute
354
+ } else {
355
+ return 0
356
+ }
357
+ }
358
+ if (this.type === 'time') {
359
+ if (this.hour === this.startHour) {
360
+ return this.startMinute
361
+ } else {
362
+ return 0
363
+ }
364
+ }
365
+ },
366
+ maxMinute() {
367
+ if (this.type === 'datetime') {
368
+ if (this.currentDateIsEnd && this.hour === this.endHour) {
369
+ return this.endMinute
370
+ } else {
371
+ return 59
372
+ }
373
+ }
374
+ if (this.type === 'time') {
375
+ if (this.hour === this.endHour) {
376
+ return this.endMinute
377
+ } else {
378
+ return 59
379
+ }
380
+ }
381
+ },
382
+ minSecond() {
383
+ if (this.type === 'datetime') {
384
+ if (this.currentDateIsStart && this.hour === this.startHour && this.minute === this.startMinute) {
385
+ return this.startSecond
386
+ } else {
387
+ return 0
388
+ }
389
+ }
390
+ if (this.type === 'time') {
391
+ if (this.hour === this.startHour && this.minute === this.startMinute) {
392
+ return this.startSecond
393
+ } else {
394
+ return 0
395
+ }
396
+ }
397
+ },
398
+ maxSecond() {
399
+ if (this.type === 'datetime') {
400
+ if (this.currentDateIsEnd && this.hour === this.endHour && this.minute === this.endMinute) {
401
+ return this.endSecond
402
+ } else {
403
+ return 59
404
+ }
405
+ }
406
+ if (this.type === 'time') {
407
+ if (this.hour === this.endHour && this.minute === this.endMinute) {
408
+ return this.endSecond
409
+ } else {
410
+ return 59
411
+ }
412
+ }
413
+ },
414
+
415
+ /**
416
+ * for i18n
417
+ */
418
+ selectTimeText() {
419
+ return t("uni-datetime-picker.selectTime")
420
+ },
421
+ okText() {
422
+ return t("uni-datetime-picker.ok")
423
+ },
424
+ clearText() {
425
+ return t("uni-datetime-picker.clear")
426
+ },
427
+ cancelText() {
428
+ return t("uni-datetime-picker.cancel")
429
+ }
430
+ },
431
+
432
+ mounted() {
433
+ // #ifdef APP-NVUE
434
+ const res = getApp().globalData.$systemInfo;
435
+ this.fixNvueBug = {
436
+ top: res.windowHeight / 2,
437
+ left: res.windowWidth / 2
438
+ }
439
+ // #endif
440
+ },
441
+
442
+ methods: {
443
+ /**
444
+ * @param {Object} item
445
+ * 小于 10 在前面加个 0
446
+ */
447
+
448
+ lessThanTen(item) {
449
+ return item < 10 ? '0' + item : item
450
+ },
451
+
452
+ /**
453
+ * 解析时分秒字符串,例如:00:00:00
454
+ * @param {String} timeString
455
+ */
456
+ parseTimeType(timeString) {
457
+ if (timeString) {
458
+ let timeArr = timeString.split(':')
459
+ this.hour = Number(timeArr[0])
460
+ this.minute = Number(timeArr[1])
461
+ this.second = Number(timeArr[2])
462
+ }
463
+ },
464
+
465
+ /**
466
+ * 解析选择器初始值,类型可以是字符串、时间戳,例如:2000-10-02、'08:30:00'、 1610695109000
467
+ * @param {String | Number} datetime
468
+ */
469
+ initPickerValue(datetime) {
470
+ let defaultValue = null
471
+ if (datetime) {
472
+ defaultValue = this.compareValueWithStartAndEnd(datetime, this.start, this.end)
473
+ } else {
474
+ defaultValue = Date.now()
475
+ defaultValue = this.compareValueWithStartAndEnd(defaultValue, this.start, this.end)
476
+ }
477
+ this.parseValue(defaultValue)
478
+ },
479
+
480
+ /**
481
+ * 初始值规则:
482
+ * - 用户设置初始值 value
483
+ * - 设置了起始时间 start、终止时间 end,并 start < value < end,初始值为 value, 否则初始值为 start
484
+ * - 只设置了起始时间 start,并 start < value,初始值为 value,否则初始值为 start
485
+ * - 只设置了终止时间 end,并 value < end,初始值为 value,否则初始值为 end
486
+ * - 无起始终止时间,则初始值为 value
487
+ * - 无初始值 value,则初始值为当前本地时间 Date.now()
488
+ * @param {Object} value
489
+ * @param {Object} dateBase
490
+ */
491
+ compareValueWithStartAndEnd(value, start, end) {
492
+ let winner = null
493
+ value = this.superTimeStamp(value)
494
+ start = this.superTimeStamp(start)
495
+ end = this.superTimeStamp(end)
496
+
497
+ if (start && end) {
498
+ if (value < start) {
499
+ winner = new Date(start)
500
+ } else if (value > end) {
501
+ winner = new Date(end)
502
+ } else {
503
+ winner = new Date(value)
504
+ }
505
+ } else if (start && !end) {
506
+ winner = start <= value ? new Date(value) : new Date(start)
507
+ } else if (!start && end) {
508
+ winner = value <= end ? new Date(value) : new Date(end)
509
+ } else {
510
+ winner = new Date(value)
511
+ }
512
+
513
+ return winner
514
+ },
515
+
516
+ /**
517
+ * 转换为可比较的时间戳,接受日期、时分秒、时间戳
518
+ * @param {Object} value
519
+ */
520
+ superTimeStamp(value) {
521
+ let dateBase = ''
522
+ if (this.type === 'time' && value && typeof value === 'string') {
523
+ const now = new Date()
524
+ const year = now.getFullYear()
525
+ const month = now.getMonth() + 1
526
+ const day = now.getDate()
527
+ dateBase = year + '/' + month + '/' + day + ' '
528
+ }
529
+ if (Number(value) && typeof value !== NaN) {
530
+ value = parseInt(value)
531
+ dateBase = 0
532
+ }
533
+ return this.createTimeStamp(dateBase + value)
534
+ },
535
+
536
+ /**
537
+ * 解析默认值 value,字符串、时间戳
538
+ * @param {Object} defaultTime
539
+ */
540
+ parseValue(value) {
541
+ if (!value) {
542
+ return
543
+ }
544
+ if (this.type === 'time' && typeof value === "string") {
545
+ this.parseTimeType(value)
546
+ } else {
547
+ let defaultDate = null
548
+ defaultDate = new Date(value)
549
+ if (this.type !== 'time') {
550
+ this.year = defaultDate.getFullYear()
551
+ this.month = defaultDate.getMonth() + 1
552
+ this.day = defaultDate.getDate()
553
+ }
554
+ if (this.type !== 'date') {
555
+ this.hour = defaultDate.getHours()
556
+ this.minute = defaultDate.getMinutes()
557
+ this.second = defaultDate.getSeconds()
558
+ }
559
+ }
560
+ if (this.hideSecond) {
561
+ this.second = 0
562
+ }
563
+ },
564
+
565
+ /**
566
+ * 解析可选择时间范围 start、end,年月日字符串、时间戳
567
+ * @param {Object} defaultTime
568
+ */
569
+ parseDatetimeRange(point, pointType) {
570
+ // 时间为空,则重置为初始值
571
+ if (!point) {
572
+ if (pointType === 'start') {
573
+ this.startYear = 1920
574
+ this.startMonth = 1
575
+ this.startDay = 1
576
+ this.startHour = 0
577
+ this.startMinute = 0
578
+ this.startSecond = 0
579
+ }
580
+ if (pointType === 'end') {
581
+ this.endYear = 2120
582
+ this.endMonth = 12
583
+ this.endDay = 31
584
+ this.endHour = 23
585
+ this.endMinute = 59
586
+ this.endSecond = 59
587
+ }
588
+ return
589
+ }
590
+ if (this.type === 'time') {
591
+ const pointArr = point.split(':')
592
+ this[pointType + 'Hour'] = Number(pointArr[0])
593
+ this[pointType + 'Minute'] = Number(pointArr[1])
594
+ this[pointType + 'Second'] = Number(pointArr[2])
595
+ } else {
596
+ if (!point) {
597
+ pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60
598
+ return
599
+ }
600
+ if (Number(point) && Number(point) !== NaN) {
601
+ point = parseInt(point)
602
+ }
603
+ // datetime 的 end 没有时分秒, 则不限制
604
+ const hasTime = /[0-9]:[0-9]/
605
+ if (this.type === 'datetime' && pointType === 'end' && typeof point === 'string' && !hasTime.test(
606
+ point)) {
607
+ point = point + ' 23:59:59'
608
+ }
609
+ const pointDate = new Date(point)
610
+ this[pointType + 'Year'] = pointDate.getFullYear()
611
+ this[pointType + 'Month'] = pointDate.getMonth() + 1
612
+ this[pointType + 'Day'] = pointDate.getDate()
613
+ if (this.type === 'datetime') {
614
+ this[pointType + 'Hour'] = pointDate.getHours()
615
+ this[pointType + 'Minute'] = pointDate.getMinutes()
616
+ this[pointType + 'Second'] = pointDate.getSeconds()
617
+ }
618
+ }
619
+ },
620
+
621
+ // 获取 年、月、日、时、分、秒 当前可选范围
622
+ getCurrentRange(value) {
623
+ const range = []
624
+ for (let i = this['min' + this.capitalize(value)]; i <= this['max' + this.capitalize(value)]; i++) {
625
+ range.push(i)
626
+ }
627
+ return range
628
+ },
629
+
630
+ // 字符串首字母大写
631
+ capitalize(str) {
632
+ return str.charAt(0).toUpperCase() + str.slice(1)
633
+ },
634
+
635
+ // 检查当前值是否在范围内,不在则当前值重置为可选范围第一项
636
+ checkValue(name, value, values) {
637
+ if (values.indexOf(value) === -1) {
638
+ this[name] = values[0]
639
+ }
640
+ },
641
+
642
+ // 每个月的实际天数
643
+ daysInMonth(year, month) { // Use 1 for January, 2 for February, etc.
644
+ return new Date(year, month, 0).getDate();
645
+ },
646
+
647
+ //兼容 iOS、safari 日期格式
648
+ fixIosDateFormat(value) {
649
+ if (typeof value === 'string') {
650
+ value = value.replace(/-/g, '/')
651
+ }
652
+ return value
653
+ },
654
+
655
+ /**
656
+ * 生成时间戳
657
+ * @param {Object} time
658
+ */
659
+ createTimeStamp(time) {
660
+ if (!time) return
661
+ if (typeof time === "number") {
662
+ return time
663
+ } else {
664
+ time = time.replace(/-/g, '/')
665
+ if (this.type === 'date') {
666
+ time = time + ' ' + '00:00:00'
667
+ }
668
+ return Date.parse(time)
669
+ }
670
+ },
671
+
672
+ /**
673
+ * 生成日期或时间的字符串
674
+ */
675
+ createDomSting() {
676
+ const yymmdd = this.year +
677
+ '-' +
678
+ this.lessThanTen(this.month) +
679
+ '-' +
680
+ this.lessThanTen(this.day)
681
+
682
+ let hhmmss = this.lessThanTen(this.hour) +
683
+ ':' +
684
+ this.lessThanTen(this.minute)
685
+
686
+ if (!this.hideSecond) {
687
+ hhmmss = hhmmss + ':' + this.lessThanTen(this.second)
688
+ }
689
+
690
+ if (this.type === 'date') {
691
+ return yymmdd
692
+ } else if (this.type === 'time') {
693
+ return hhmmss
694
+ } else {
695
+ return yymmdd + ' ' + hhmmss
696
+ }
697
+ },
698
+
699
+ /**
700
+ * 初始化返回值,并抛出 change 事件
701
+ */
702
+ initTime(emit = true) {
703
+ this.time = this.createDomSting()
704
+ if (!emit) return
705
+ if (this.returnType === 'timestamp' && this.type !== 'time') {
706
+ this.$emit('change', this.createTimeStamp(this.time))
707
+ this.$emit('input', this.createTimeStamp(this.time))
708
+ this.$emit('update:modelValue', this.createTimeStamp(this.time))
709
+ } else {
710
+ this.$emit('change', this.time)
711
+ this.$emit('input', this.time)
712
+ this.$emit('update:modelValue', this.time)
713
+ }
714
+ },
715
+
716
+ /**
717
+ * 用户选择日期或时间更新 data
718
+ * @param {Object} e
719
+ */
720
+ bindDateChange(e) {
721
+ const val = e.detail.value
722
+ this.year = this.years[val[0]]
723
+ this.month = this.months[val[1]]
724
+ this.day = this.days[val[2]]
725
+ },
726
+ bindTimeChange(e) {
727
+ const val = e.detail.value
728
+ this.hour = this.hours[val[0]]
729
+ this.minute = this.minutes[val[1]]
730
+ this.second = this.seconds[val[2]]
731
+ },
732
+
733
+ /**
734
+ * 初始化弹出层
735
+ */
736
+ initTimePicker() {
737
+ if (this.disabled) return
738
+ const value = this.fixIosDateFormat(this.value)
739
+ this.initPickerValue(value)
740
+ this.visible = !this.visible
741
+ },
742
+
743
+ /**
744
+ * 触发或关闭弹框
745
+ */
746
+ tiggerTimePicker(e) {
747
+ this.visible = !this.visible
748
+ },
749
+
750
+ /**
751
+ * 用户点击“清空”按钮,清空当前值
752
+ */
753
+ clearTime() {
754
+ this.time = ''
755
+ this.$emit('change', this.time)
756
+ this.$emit('input', this.time)
757
+ this.$emit('update:modelValue', this.time)
758
+ this.tiggerTimePicker()
759
+ },
760
+
761
+ /**
762
+ * 用户点击“确定”按钮
763
+ */
764
+ setTime() {
765
+ this.initTime()
766
+ this.tiggerTimePicker()
767
+ }
768
+ }
769
+ }
770
+ </script>
771
+
772
+ <style>
773
+ .uni-datetime-picker {
774
+ /* #ifndef APP-NVUE */
775
+ /* width: 100%; */
776
+ /* #endif */
777
+ }
778
+
779
+ .uni-datetime-picker-view {
780
+ height: 130px;
781
+ width: 270px;
782
+ /* #ifndef APP-NVUE */
783
+ cursor: pointer;
784
+ /* #endif */
785
+ }
786
+
787
+ .uni-datetime-picker-item {
788
+ height: 50px;
789
+ line-height: 50px;
790
+ text-align: center;
791
+ font-size: 14px;
792
+ }
793
+
794
+ .uni-datetime-picker-btn {
795
+ margin-top: 60px;
796
+ /* #ifndef APP-NVUE */
797
+ display: flex;
798
+ cursor: pointer;
799
+ /* #endif */
800
+ flex-direction: row;
801
+ justify-content: space-between;
802
+ }
803
+
804
+ .uni-datetime-picker-btn-text {
805
+ font-size: 14px;
806
+ color: #007AFF;
807
+ }
808
+
809
+ .uni-datetime-picker-btn-group {
810
+ /* #ifndef APP-NVUE */
811
+ display: flex;
812
+ /* #endif */
813
+ flex-direction: row;
814
+ }
815
+
816
+ .uni-datetime-picker-cancel {
817
+ margin-right: 30px;
818
+ }
819
+
820
+ .uni-datetime-picker-mask {
821
+ position: fixed;
822
+ bottom: 0px;
823
+ top: 0px;
824
+ left: 0px;
825
+ right: 0px;
826
+ background-color: rgba(0, 0, 0, 0.4);
827
+ transition-duration: 0.3s;
828
+ z-index: 998;
829
+ }
830
+
831
+ .uni-datetime-picker-popup {
832
+ border-radius: 8px;
833
+ padding: 30px;
834
+ width: 270px;
835
+ /* #ifdef APP-NVUE */
836
+ height: 500px;
837
+ /* #endif */
838
+ /* #ifdef APP-NVUE */
839
+ width: 330px;
840
+ /* #endif */
841
+ background-color: #fff;
842
+ position: fixed;
843
+ top: 50%;
844
+ left: 50%;
845
+ transform: translate(-50%, -50%);
846
+ transition-duration: 0.3s;
847
+ z-index: 999;
848
+ }
849
+
850
+ .fix-nvue-height {
851
+ /* #ifdef APP-NVUE */
852
+ height: 330px;
853
+ /* #endif */
854
+ }
855
+
856
+ .uni-datetime-picker-time {
857
+ color: grey;
858
+ }
859
+
860
+ .uni-datetime-picker-column {
861
+ height: 50px;
862
+ }
863
+
864
+ .uni-datetime-picker-timebox {
865
+
866
+ border: 1px solid #E5E5E5;
867
+ border-radius: 5px;
868
+ padding: 7px 10px;
869
+ /* #ifndef APP-NVUE */
870
+ box-sizing: border-box;
871
+ cursor: pointer;
872
+ /* #endif */
873
+ }
874
+
875
+ .uni-datetime-picker-timebox-pointer {
876
+ /* #ifndef APP-NVUE */
877
+ cursor: pointer;
878
+ /* #endif */
879
+ display: flex;
880
+ justify-content: space-between;
881
+ align-items: center;
882
+ }
883
+
884
+
885
+ .uni-datetime-picker-disabled {
886
+ opacity: 0.4;
887
+ /* #ifdef H5 */
888
+ cursor: not-allowed !important;
889
+ /* #endif */
890
+ }
891
+
892
+ .uni-datetime-picker-text {
893
+ font-size: 26rpx;
894
+ }
895
+
896
+ .uni-datetime-picker-sign {
897
+ position: absolute;
898
+ top: 53px;
899
+ /* 减掉 10px 的元素高度,兼容nvue */
900
+ color: #999;
901
+ /* #ifdef APP-NVUE */
902
+ font-size: 16px;
903
+ /* #endif */
904
+ }
905
+
906
+ .sign-left {
907
+ left: 86px;
908
+ }
909
+
910
+ .sign-right {
911
+ right: 86px;
912
+ }
913
+
914
+ .sign-center {
915
+ left: 135px;
916
+ }
917
+
918
+ .uni-datetime-picker__container-box {
919
+ position: relative;
920
+ display: flex;
921
+ align-items: center;
922
+ justify-content: center;
923
+ margin-top: 40px;
924
+ }
925
+
926
+ .time-hide-second {
927
+ width: 180px;
928
+ }
929
+ </style>