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,286 @@
1
+ <template>
2
+ <view class="xd-navbar" :style="{height: getBoxHeight+'rpx'}">
3
+ <view class="xd-navbar-fixed" :style="{background: uiBgColor}">
4
+ <!-- 状态栏 -->
5
+ <view :style="{height:(statusBarHeight) +'rpx'}"></view>
6
+ <!-- 导航栏内容 -->
7
+ <view
8
+ class="xd-navbar-content"
9
+ :style="{
10
+ height:navBarHeight+'rpx',
11
+ width:windowWidth+'px',
12
+ paddingRight: isBack? '30rpx': '20rpx'
13
+ }"
14
+ >
15
+ <view v-if="isBack" class="xd-navbar-content__icons" @click.stop="back">
16
+ <xd-font-icon :size="40*$isIpadCC" icon="iconxiazai6" :color="uiBackIconColor"></xd-font-icon>
17
+ </view>
18
+ <view class="xd-navbar-content__search">
19
+ <input
20
+ :style="{
21
+ borderColor: uiInputBorderColor,
22
+ borderRadius: inputBorderRadius,
23
+ height: navBarHeight * isH5Num + 'rpx',
24
+ lineHeight: navBarHeight * isH5Num + 'rpx',
25
+ fontSize: ($isIpadCC * 30) + 'rpx',
26
+ background: inputBackground,
27
+ paddingRight: isSearch? ((140*$isIpadCC) + 'rpx'): ((30*$isIpadCC) + 'rpx'),
28
+ paddingLeft: 60*$isIpadCC + 'rpx',
29
+ borderRadius: 20* $isIpadCC + 'rpx'
30
+ }"
31
+ class="app-input"
32
+ :focus="false"
33
+ @confirm="doneInput"
34
+ type="text"
35
+ confirm-type="search"
36
+ :adjust-position="false"
37
+ @input="onInput"
38
+ :placeholder="placeholder"
39
+ v-model="searchValue"/>
40
+ <xd-font-icon color="#9b9b9b" :size="34*$isIpadCC" icon="iconsousuo"></xd-font-icon>
41
+ <button
42
+ :style="{
43
+ height: navBarHeight * isH5Num + 'rpx',
44
+ lineHeight: navBarHeight * isH5Num + 'rpx',
45
+ background: $mainColor,
46
+ color: '#fff',
47
+ fontSize: ($isIpadCC * 30) + 'rpx',
48
+ borderRadius: 20* $isIpadCC + 'rpx',
49
+ width: 128* $isIpadCC + 'rpx'
50
+ }"
51
+ @click="onSearch"
52
+ >搜索</button>
53
+ </view>
54
+ </view>
55
+ </view>
56
+ <view :style="{height: getBoxHeight+'rpx'}"></view>
57
+ </view>
58
+ </template>
59
+
60
+ <script>
61
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
62
+ import XdButton from "@/components/XdButton/XdButton";
63
+
64
+ /**
65
+ * XdSearchBar 全局UI
66
+ * @description 自定义header tabbar功能
67
+ * @tutorial
68
+ * @property {Boolean} isBack 开启返回按钮功能并启动返回操作事件 (可选) 默认:false
69
+ * @property {String} backIconColor 返回图标显示颜色值 (可选) 默认:使用主色调 $mainColor
70
+ * @property {Boolean} isSearch 显示搜索按钮 (可选) 默认:false
71
+ * @property {String} placeholder 设置placeholder文本 (可选) 默认:搜索
72
+ * @property {String} bg 设置tabbar背景颜色主 (可选) 默认:为页面主色调 $mainColor
73
+ * @property {String} inputBorderColor 输入框边框颜色 (可选) 默认:为页面主色调 $mainColor
74
+ * @property {String} inputBorderRadius 输入框边框圆角设置 (可选) 默认:30rpx
75
+ * @property {String} inputBackground 输入框背景颜色 (可选) 默认 #fff
76
+ *
77
+ * @slot 接受默认插槽
78
+ *
79
+ * @event {Function} click或者tap 按钮点击事件e
80
+ */
81
+
82
+ export default {
83
+ name: "XdSearchBar",
84
+ components: {XdFontIcon, XdButton},
85
+ props: {
86
+ value: {
87
+ type: [String, Number],
88
+ default: ''
89
+ },
90
+ isBack: {
91
+ type: Boolean,
92
+ default: false
93
+ },
94
+ backIconColor: {
95
+ type: String,
96
+ default: '',
97
+ },
98
+ isSearch: {
99
+ type: Boolean,
100
+ default: false
101
+ },
102
+ placeholder: {
103
+ type: String,
104
+ default: '搜索',
105
+ },
106
+ bg : {
107
+ type: String,
108
+ default: '',
109
+ },
110
+ inputBorderColor: {
111
+ type: String,
112
+ default: '',
113
+ },
114
+ inputBorderRadius: {
115
+ type: String,
116
+ default: '30rpx',
117
+ },
118
+ inputBackground: {
119
+ type: String,
120
+ default: '#fff',
121
+ }
122
+ },
123
+ data() {
124
+ return {
125
+ statusBarHeight: 20, //rpx
126
+ navBarHeight: 90, //H5的默认值 rpx
127
+ windowWidth: 375, //页面宽度px
128
+ searchValue: '', //搜索值
129
+ uiBgColor: '', //插件背景颜色
130
+ uiColor: '', //插件文本颜色
131
+ uiBackIconColor:'', //返回按钮颜色
132
+ uiInputBorderColor: '', //输入框边框颜色
133
+ inputTimeer: null, //无搜索按钮时候输入事件延时处理
134
+ isH5Num: 0.8
135
+ };
136
+ },
137
+ computed:{
138
+ getBoxHeight() {
139
+ return (this.statusBarHeight + this.navBarHeight);
140
+ },
141
+ },
142
+ watch: {
143
+ value(newVal) {
144
+ this.searchValue = newVal
145
+ }
146
+ },
147
+ created() {
148
+ this.uiBgColor = this.$mainColor;
149
+ this.uiBackIconColor = '#fff';
150
+ this.uiInputBorderColor = this.$mainColor;
151
+ if(this.bg) {
152
+ this.uiBgColor = this.bg;
153
+ }
154
+
155
+ //#ifdef H5
156
+ this.isH5Num = 0.7;
157
+ // #endif
158
+
159
+ if(this.backIconColor) {
160
+ this.uiBackIconColor = this.backIconColor;
161
+ }
162
+
163
+ if (this.inputBorderColor) {
164
+ this.uiInputBorderColor = this.inputBorderColor;
165
+ }
166
+
167
+ this.setNavBar();
168
+ uni.onWindowResize((res) => {
169
+ this.setNavBar();
170
+ });
171
+
172
+ this.searchValue = this.value;
173
+
174
+ },
175
+ methods: {
176
+ setNavBar(){
177
+ // 获取手机系统信息
178
+ const info = getApp().globalData.$systemInfo
179
+ // 设置状态栏高度
180
+ this.statusBarHeight = info.statusBarHeight * this.$pxNum;
181
+ this.windowWidth = info.windowWidth
182
+ // h5 app mp-alipay
183
+ // #ifndef H5 || APP-PLUS || MP-ALIPAY
184
+ // 获取胶囊的位置
185
+ const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
186
+ // (胶囊底部高度 - 状态栏的高度) + (胶囊顶部高度 - 状态栏内的高度) = 导航栏的高度
187
+ this.navBarHeight = ((menuButtonInfo.bottom - info.statusBarHeight) + (menuButtonInfo.top - info.statusBarHeight)) * this.$pxNum
188
+ this.windowWidth = menuButtonInfo.left
189
+ // #endif
190
+ },
191
+ back() {
192
+ this.$emit('back');
193
+ },
194
+
195
+
196
+ doneInput() {
197
+ uni.hideKeyboard()
198
+ },
199
+
200
+ /**
201
+ * @description 输入事件
202
+ */
203
+ onInput(e) {
204
+ //有搜索按钮不启动输入事件
205
+ if(this.isSearch) return;
206
+ if(this.inputTimeer) {
207
+ clearTimeout(this.inputTimeer);
208
+ this.inputTimeer = null;
209
+ }
210
+ //延时处理逻辑
211
+ this.inputTimeer = setTimeout(()=>{
212
+ this.searchValue = e.target.value.trim();
213
+ this.$emit('onSearch', this.searchValue);
214
+ this.$emit('input', this.searchValue)
215
+ console.log(this.searchValue);
216
+ },700);
217
+ },
218
+
219
+ onSearch(){
220
+ console.log(this.searchValue.trim())
221
+ this.$emit('onSearch', this.searchValue.trim());
222
+ this.$emit('input', this.searchValue.trim())
223
+ },
224
+ }
225
+ }
226
+ </script>
227
+
228
+ <style lang="less">
229
+ .xd-navbar {
230
+ &-fixed {
231
+ position: fixed;
232
+ top: 0;
233
+ left: 0;
234
+ z-index: 99;
235
+ width: 100%;
236
+ background-color: @xd-base-color;
237
+ }
238
+
239
+ &-content {
240
+ display: flex;
241
+ justify-content: flex-start;
242
+ align-items: center;
243
+ padding: 0 unit(30, rpx) 0 unit(20, rpx);
244
+ height: unit(90, rpx);
245
+ box-sizing: border-box;
246
+
247
+
248
+ &__icons {
249
+ margin-right: unit(20, rpx);
250
+ }
251
+
252
+ &__search {
253
+ position: relative;
254
+ flex: 1;
255
+
256
+ /deep/ .xd-iconfont {
257
+ position: absolute;
258
+ left: unit(16, rpx);
259
+ top: 50%;
260
+ transform: translateY(-50%);
261
+ }
262
+
263
+ button {
264
+ position: absolute;
265
+ right: unit(0, rpx);
266
+ top: unit(0, rpx);
267
+ padding: 0;
268
+
269
+ &:hover {
270
+ opacity: 0.85;
271
+ }
272
+ }
273
+
274
+ .app-input {
275
+ background-color: @xd-text-color-inverse;
276
+ border-width: unit(2, rpx);
277
+ border-style: solid;
278
+ box-sizing: border-box;
279
+ }
280
+
281
+ }
282
+
283
+ }
284
+
285
+ }
286
+ </style>
@@ -0,0 +1,382 @@
1
+ <template>
2
+ <view class="xd-select" :style="{width: width}">
3
+ <picker
4
+ class="xd-select__picker "
5
+ @change="bindPickerChange"
6
+ :range="flimTypeList"
7
+ :mode="mode"
8
+ :value="flimTypeIndex"
9
+ :disabled="disabled"
10
+ @cancel="bindPickerClick(false)"
11
+ >
12
+ <view
13
+ class="xd-select__box"
14
+ :class="{'xd-select__disabled': disabled}"
15
+ :style="{height: uiHeight + 'rpx'}"
16
+ >
17
+ <view v-if="label">{{label}}</view>
18
+ <view
19
+ :style="{
20
+ border: borderWidth + 'rpx solid ' + (!disabled ? uiColor : '#eee'),
21
+ color: getColor ? '#999': textColor,
22
+ background: disabled ? '#f4f4f4' : '#fff',
23
+ borderRadius: radius,
24
+ height: uiHeight + 'rpx',
25
+ lineHeight: uiHeight + 'rpx',
26
+ 'box-sizing': 'border-box',
27
+ padding: padding,
28
+ fontSize: uiFontSize + 'rpx',
29
+ justifyContent: justifyContent,
30
+ width: width
31
+ }"
32
+
33
+ @click="bindPickerClick(true)"
34
+ >
35
+ <text
36
+ :style="{
37
+ 'max-height': uiHeight + 'rpx',
38
+ 'margin': margin
39
+ }"
40
+ >{{getSelectName}}
41
+ </text>
42
+ <view>
43
+ <slot :status="isUp">
44
+ <xd-font-icon
45
+ size="15"
46
+ :icon="isUp ? 'iconrepository-xialaxuanxiangup': 'iconrepository-xialaxuanxiangdown'"
47
+ ></xd-font-icon>
48
+ </slot>
49
+
50
+ </view>
51
+ </view>
52
+ </view>
53
+ </picker>
54
+ </view>
55
+ </template>
56
+
57
+ <script>
58
+
59
+ /**
60
+ * XdSelect 全局Ui, 不支持异步数据
61
+ * @description 自定义选择插件
62
+ * @property textColor {String} 文字颜色 默认:
63
+ * @property justifyContent {String} 文字对齐方式 默认:flex-start 其值:flex-start,flex-end ,space-between
64
+ * @property fontSize {Number} 文字大小 默认:28rpx
65
+ * @property borderWidth {Number|String} 边框大小 默认: 1rpx
66
+ * @property padding {String} 显示内容区域填充 默认: 0 20rpx
67
+ * @property height {Number|String} 插件高度 默认:默认: 60rpx
68
+ * @property width {String} 插件宽度 默认:默认: auto
69
+ * @property defaultValue {Number} 选中的默认值 默认:第一项
70
+ * @property list {Array|Object} 选项卡数据列表 null=>使用默认数据
71
+ * @property disabled {Boolean} 是否禁用 默认:false
72
+ * @property contentPrefix {Boolean} 文字内容后缀 默认:-
73
+ * @property mode {String} 模式类型 默认:selector 其值:multiSelector,selector
74
+ * @property label {String} 选择框名称 默认:空,不显示
75
+ * @property placeholder {String} 提示文案 默认:空,不显示
76
+ * @property radius {String} 显示圆角 默认:25rpx
77
+ * @property borderColor {String} 显示圆角 默认:''
78
+ *
79
+ * @event {Function} change 点击元宝事件
80
+ */
81
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
82
+
83
+ export default {
84
+ name: "XdSelect",
85
+ components: {XdFontIcon},
86
+ props: {
87
+ textColor: {
88
+ type: String,
89
+ default: '#333'
90
+ },
91
+ width: {
92
+ type: String,
93
+ default: 'auto'
94
+ },
95
+ justifyContent: {
96
+ type: String,
97
+ default: 'flex-start' //
98
+ },
99
+ fontSize: {
100
+ type: String | Number,
101
+ default: 28
102
+ },
103
+ padding: {
104
+ type: String,
105
+ default: '0 20rpx'
106
+ },
107
+ borderWidth: {
108
+ type: String | Number,
109
+ default: ''
110
+ },
111
+ height: {
112
+ type: String | Number,
113
+ default: ''
114
+ },
115
+ defaultValue: {
116
+ type: String | Number | null | Array,
117
+ default: null
118
+ },
119
+ list: {
120
+ type: Array | null,
121
+ default: null
122
+ },
123
+ disabled: {
124
+ type: Boolean,
125
+ default: false
126
+ },
127
+ contentPrefix: {
128
+ type: String,
129
+ default: '-'
130
+ },
131
+ mode: {
132
+ type: String,
133
+ default: 'selector', //multiSelector selector
134
+ },
135
+ label: {
136
+ type: String,
137
+ default: ''
138
+ },
139
+ placeholder: {
140
+ type: String,
141
+ default: ''
142
+ },
143
+ radius: {
144
+ type: String,
145
+ default: '30rpx'
146
+ },
147
+ borderColor: {
148
+ type: String,
149
+ default: ''
150
+ },
151
+ margin: {
152
+ type: String,
153
+ default: ''
154
+ }
155
+
156
+ },
157
+ data() {
158
+ return {
159
+ uiHeight: 60,
160
+ isUp: false,
161
+ flimTypeIndex: null, //选择ID
162
+ flimTypeList: [], //选项列表
163
+ flimTypeListSource: [], //原始数据
164
+
165
+ //下拉菜单icon
166
+ iconArray: [
167
+ {up: 'iconrepository-xialaxuanxiangup', down: 'iconrepository-xialaxuanxiangdown'},
168
+ {up: '', down: ''},
169
+ ],
170
+
171
+ defaultFormot: [ //测试数据
172
+ {value: 1, label: '2D'},
173
+ {value: 2, label: '3D'},
174
+ {value: 3, label: '3DMAX'},
175
+ {value: 4, label: 'AA'}
176
+ ],
177
+
178
+ uiColor: '',
179
+ uiFontSize: 28,
180
+ }
181
+ },
182
+
183
+ computed: {
184
+ getSelectName() {
185
+ if (this.flimTypeIndex === null || this.flimTypeIndex.length === 0) {
186
+ return this.placeholder;
187
+ }
188
+ if (this.mode === 'selector') {
189
+ return this.flimTypeList[this.flimTypeIndex];
190
+ }
191
+
192
+ if (this.mode === 'multiSelector') {
193
+ let select = [];
194
+ this.flimTypeIndex.map((item, index) => {
195
+ select.push(this.flimTypeList[index][item]);
196
+ });
197
+ return select.join(this.contentPrefix);
198
+ }
199
+
200
+ },
201
+
202
+ getColor() {
203
+ if (this.disabled || this.flimTypeIndex === null || this.flimTypeIndex.length === 0) return true;
204
+ if (this.mode === 'selector') return !this.flimTypeListSource[this.flimTypeIndex];
205
+ return false;
206
+ },
207
+ },
208
+
209
+ watch: {
210
+ defaultValue() {
211
+ if (this.mode === 'selector') this.init(this.list);
212
+ if (this.mode === 'multiSelector') this.multiInit(this.list)
213
+ },
214
+ list(value) {
215
+ if (this.mode === 'selector') this.init(value);
216
+ if (this.mode === 'multiSelector') this.multiInit(value)
217
+ }
218
+ },
219
+
220
+ created() {
221
+ console.log('flimTypeList', this.mode)
222
+ this.uiColor = this.$mainColor;
223
+ this.uiFontSize = this.fontSize;
224
+ if (this.borderColor) this.uiColor = this.borderColor;
225
+
226
+ //字号
227
+ if (this.$xdUniHelper.checkVarType(this.fontSize) === 'string') {
228
+ this.uiFontSize = Number(this.fontSize);
229
+ }
230
+
231
+
232
+ if (this.height) {
233
+ this.uiHeight = this.height;
234
+ if (this.$xdUniHelper.checkVarType(this.height) === 'string') {
235
+ this.uiHeight = Number(this.height);
236
+ }
237
+ }
238
+
239
+ //使用测试数据
240
+ if (this.list === null) {
241
+
242
+ if (this.mode === 'selector') this.init(this.defaultFormot);
243
+ if (this.mode === 'multiSelector') this.multiInit([this.defaultFormot, this.defaultFormot])
244
+ }
245
+ //使用正式数据
246
+ else if (this.$xdUniHelper.checkVarType(this.list) === 'array') {
247
+ if (this.mode === 'selector') this.init(this.list);
248
+ if (this.mode === 'multiSelector') this.multiInit(this.list)
249
+
250
+ } else {
251
+ throw new Error('数据格式错误')
252
+ }
253
+ },
254
+
255
+ methods: {
256
+ init(list = []) {
257
+ let flimTypeList = [];
258
+ let select = null;
259
+ list.map((item, index) => {
260
+ if (this.defaultValue !== null && (
261
+ item.label === this.defaultValue ||
262
+ item.value === this.defaultValue)
263
+ ) {
264
+ select = item;
265
+ this.flimTypeIndex = index
266
+ }
267
+ flimTypeList.push(item.label);
268
+ });
269
+ this.flimTypeList = flimTypeList;
270
+ this.flimTypeListSource = this.$xdUniHelper.cloneDeep(list);
271
+
272
+ //已经有选中值
273
+ if (select && !this.disabled) {
274
+ this.$emit('input', select);
275
+ this.$emit('change', {item: select, index: this.flimTypeIndex});
276
+ }
277
+ },
278
+
279
+ multiInit(list) {
280
+ let defaultValue = this.defaultValue;
281
+ if (this.$xdUniHelper.checkVarType(this.defaultValue) !== 'array') {
282
+ defaultValue = [];
283
+ }
284
+ let selectIndex = [];
285
+ let flimTypeList = [];
286
+ list.map((item, index) => {
287
+ let tempitem = [];
288
+ item.map((it, idx) => {
289
+ let value = defaultValue[index];
290
+ if (value) {
291
+ if (value === it.label || value === it.value) {
292
+ selectIndex.push(idx);
293
+ }
294
+ }
295
+ tempitem.push(it.label);
296
+ })
297
+ flimTypeList.push(tempitem);
298
+ });
299
+ console.log(selectIndex);
300
+ this.flimTypeIndex = selectIndex;
301
+ this.flimTypeList = flimTypeList;
302
+
303
+ this.flimTypeListSource = this.$xdUniHelper.cloneDeep(list);
304
+
305
+ //已经有选中值
306
+ if (!this.disabled && this.flimTypeIndex.length > 0) {
307
+ let select = [];
308
+ this.flimTypeIndex.map((item, index) => {
309
+ select.push(this.flimTypeListSource[index][item]);
310
+ });
311
+ this.$emit('input', select);
312
+ this.$emit('change', {item: select, index: this.flimTypeIndex})
313
+ }
314
+ },
315
+
316
+ bindPickerChange(e) {
317
+
318
+ this.isUp = false;
319
+ if (e['detail']['value'] === this.flimTypeIndex) return;
320
+ this.flimTypeIndex = e['detail']['value'];
321
+
322
+ if (this.mode === 'selector') {
323
+ if (!this.flimTypeListSource[this.flimTypeIndex]) return;
324
+ this.$emit('input', this.flimTypeListSource[this.flimTypeIndex]);
325
+ this.$emit('change', {item: this.flimTypeListSource[this.flimTypeIndex], index: this.flimTypeIndex})
326
+ }
327
+
328
+ if (this.mode === 'multiSelector') {
329
+ let select = [];
330
+ this.flimTypeIndex.map((item, index) => {
331
+ select.push(this.flimTypeListSource[index][item]);
332
+ });
333
+ this.$emit('input', select);
334
+ this.$emit('change', {item: select, index: this.flimTypeIndex})
335
+ }
336
+
337
+ },
338
+
339
+
340
+ bindPickerClick(type) {
341
+ if (!this.disabled) this.isUp = type;
342
+ },
343
+
344
+ }
345
+ }
346
+ </script>
347
+
348
+ <style scoped lang="less">
349
+ .xd-select {
350
+ &__picker {
351
+ z-index: 500;
352
+ }
353
+
354
+ &__box {
355
+ font-size: @xd-font-size-base + 2;
356
+ display: flex;
357
+ justify-content: flex-start;
358
+ align-items: center;
359
+
360
+ & > view:first-child {
361
+
362
+ }
363
+
364
+ & > view:last-child {
365
+ flex: 1;
366
+ box-sizing: border-box;
367
+ display: flex;
368
+ justify-content: space-between;
369
+ align-items: center;
370
+
371
+ & > text {
372
+ .uni-max-cut(1, 60)
373
+ }
374
+ }
375
+
376
+ }
377
+
378
+ &__disabled {
379
+
380
+ }
381
+ }
382
+ </style>