@10yun/cv-mobile-ui 0.5.19 → 0.5.21

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 (137) hide show
  1. package/other/mpvue-picker/mpvuePicker.vue +402 -0
  2. package/{uni-ui/lib → other}/mpvue-picker/style.css +0 -1
  3. package/{uni-ui/lib → other}/tab-nvue/style.css +0 -1
  4. package/other/uParse/components/style.css +1 -0
  5. package/other/uParse/components/wxParseAudio.vue +1 -0
  6. package/other/uParse/components/wxParseImg.vue +86 -0
  7. package/other/uParse/components/wxParseTable.vue +54 -0
  8. package/other/uParse/components/wxParseTemplate0.vue +98 -0
  9. package/other/uParse/components/wxParseTemplate1.vue +81 -0
  10. package/other/uParse/components/wxParseTemplate10.vue +81 -0
  11. package/other/uParse/components/wxParseTemplate11.vue +79 -0
  12. package/other/uParse/components/wxParseTemplate2.vue +81 -0
  13. package/other/uParse/components/wxParseTemplate3.vue +81 -0
  14. package/other/uParse/components/wxParseTemplate4.vue +81 -0
  15. package/other/uParse/components/wxParseTemplate5.vue +81 -0
  16. package/other/uParse/components/wxParseTemplate6.vue +81 -0
  17. package/other/uParse/components/wxParseTemplate7.vue +81 -0
  18. package/other/uParse/components/wxParseTemplate8.vue +81 -0
  19. package/other/uParse/components/wxParseTemplate9.vue +81 -0
  20. package/other/uParse/components/wxParseVideo.vue +14 -0
  21. package/other/uParse/editor.css +495 -0
  22. package/{uni-ui/lib/uParse/src → other/uParse}/libs/html2json.js +19 -22
  23. package/{uni-ui/lib/uParse/src → other/uParse}/libs/htmlparser.js +12 -5
  24. package/{uni-ui/lib/uParse/src → other/uParse}/libs/wxDiscode.js +2 -2
  25. package/other/uParse/wxParse.vue +196 -0
  26. package/package.json +1 -1
  27. package/plugins/map/amqp-wx.js +173 -0
  28. package/{uni-ui/lib/mpvueGestureLock/index.vue → ui-cv/components/cv-draw-gesture-lock/cv-draw-gesture-lock.vue} +4 -1
  29. package/ui-cv/components/cv-draw-gesture-lock/gestureLock.js +169 -0
  30. package/{uni-ui/lib/mpvueGestureLock → ui-cv/components/cv-draw-gesture-lock}/style.css +0 -1
  31. package/{uni-ui/lib/mpvue-citypicker → ui-cv/components/cv-geo-region}/style.css +0 -1
  32. package/ui-cv/components/cv-grid-item/cv-grid-item.vue +1 -1
  33. package/uni-ui/lib/uni-badge/uni-badge.vue +150 -1
  34. package/uni-ui/lib/uni-breadcrumb/uni-breadcrumb.vue +37 -1
  35. package/uni-ui/lib/uni-breadcrumb-item/uni-breadcrumb-item.vue +83 -1
  36. package/uni-ui/lib/uni-calendar/uni-calendar-item.vue +122 -1
  37. package/uni-ui/lib/uni-calendar/uni-calendar.vue +366 -1
  38. package/uni-ui/lib/uni-card/uni-card.vue +124 -1
  39. package/uni-ui/lib/uni-col/uni-col.vue +1 -1
  40. package/uni-ui/lib/uni-collapse/uni-collapse.vue +135 -1
  41. package/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +266 -1
  42. package/uni-ui/lib/uni-combox/uni-combox.vue +1 -1
  43. package/uni-ui/lib/uni-countdown/uni-countdown.vue +239 -1
  44. package/uni-ui/lib/uni-data-checkbox/uni-data-checkbox.vue +487 -1
  45. package/uni-ui/lib/uni-data-picker/uni-data-picker.vue +530 -1
  46. package/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +157 -150
  47. package/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +166 -1
  48. package/uni-ui/lib/uni-data-select/uni-data-select.vue +289 -1
  49. package/uni-ui/lib/uni-datetime-picker/calendar-item.vue +70 -1
  50. package/uni-ui/lib/uni-datetime-picker/calendar.vue +629 -1
  51. package/uni-ui/lib/uni-datetime-picker/time-picker.vue +741 -1
  52. package/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +847 -1
  53. package/uni-ui/lib/uni-drawer/uni-drawer.vue +115 -1
  54. package/uni-ui/lib/uni-easyinput/uni-easyinput.vue +515 -1
  55. package/uni-ui/lib/uni-fab/uni-fab.vue +257 -1
  56. package/uni-ui/lib/uni-fav/uni-fav.vue +123 -1
  57. package/uni-ui/lib/uni-file-picker/uni-file-picker.vue +642 -1
  58. package/uni-ui/lib/uni-file-picker/upload-file.vue +177 -1
  59. package/uni-ui/lib/uni-file-picker/upload-image.vue +176 -1
  60. package/uni-ui/lib/uni-forms/uni-forms.vue +375 -1
  61. package/uni-ui/lib/uni-forms-item/uni-forms-item.vue +429 -1
  62. package/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +129 -1
  63. package/uni-ui/lib/uni-grid/uni-grid.vue +115 -1
  64. package/uni-ui/lib/uni-grid-item/uni-grid-item.vue +78 -1
  65. package/uni-ui/lib/uni-group/uni-group.vue +85 -1
  66. package/uni-ui/lib/uni-icons/uni-icons.vue +85 -1
  67. package/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +68 -1
  68. package/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +294 -1
  69. package/uni-ui/lib/uni-list/uni-list.vue +81 -1
  70. package/uni-ui/lib/uni-list-ad/uni-list-ad.vue +77 -1
  71. package/uni-ui/lib/uni-list-chat/uni-list-chat.vue +294 -1
  72. package/uni-ui/lib/uni-list-item/uni-list-item.vue +346 -1
  73. package/uni-ui/lib/uni-load-more/uni-load-more.vue +172 -1
  74. package/uni-ui/lib/uni-nav-bar/uni-nav-bar.vue +205 -1
  75. package/uni-ui/lib/uni-nav-bar/uni-status-bar.vue +18 -1
  76. package/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +331 -1
  77. package/uni-ui/lib/uni-number-box/uni-number-box.vue +166 -1
  78. package/uni-ui/lib/uni-pagination/uni-pagination.vue +323 -1
  79. package/uni-ui/lib/uni-popup/uni-popup.vue +1 -1
  80. package/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +173 -1
  81. package/uni-ui/lib/uni-popup-message/uni-popup-message.vue +74 -1
  82. package/uni-ui/lib/uni-popup-share/uni-popup-share.vue +106 -1
  83. package/uni-ui/lib/uni-rate/uni-rate.vue +322 -1
  84. package/uni-ui/lib/uni-row/uni-row.vue +1 -1
  85. package/uni-ui/lib/uni-search-bar/uni-search-bar.vue +236 -1
  86. package/uni-ui/lib/uni-section/uni-section.vue +109 -1
  87. package/uni-ui/lib/uni-segmented-control/uni-segmented-control.vue +103 -1
  88. package/uni-ui/lib/uni-status-bar/uni-status-bar.vue +1 -1
  89. package/uni-ui/lib/uni-steps/uni-steps.vue +120 -1
  90. package/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +226 -3
  91. package/uni-ui/lib/uni-swiper-dot/uni-swiper-dot.vue +167 -1
  92. package/uni-ui/lib/uni-table/uni-table.vue +297 -1
  93. package/uni-ui/lib/uni-tag/uni-tag.vue +100 -1
  94. package/uni-ui/lib/uni-td/uni-td.vue +78 -1
  95. package/uni-ui/lib/uni-th/filter-dropdown.vue +1 -1
  96. package/uni-ui/lib/uni-th/uni-th.vue +224 -1
  97. package/uni-ui/lib/uni-thead/uni-thead.vue +77 -1
  98. package/uni-ui/lib/uni-tr/table-checkbox.vue +79 -1
  99. package/uni-ui/lib/uni-tr/uni-tr.vue +135 -1
  100. package/uni-ui/lib/amap-wx/js/util.js +0 -181
  101. package/uni-ui/lib/marked/index.js +0 -1
  102. package/uni-ui/lib/mpvue-citypicker/city-data/area.js +0 -12542
  103. package/uni-ui/lib/mpvue-citypicker/city-data/city.js +0 -1503
  104. package/uni-ui/lib/mpvue-citypicker/city-data/province.js +0 -139
  105. package/uni-ui/lib/mpvue-picker/mpvuePicker.vue +0 -3
  106. package/uni-ui/lib/mpvueGestureLock/gestureLock.js +0 -175
  107. package/uni-ui/lib/uParse/src/components/style.css +0 -2
  108. package/uni-ui/lib/uParse/src/components/wxParseAudio.vue +0 -1
  109. package/uni-ui/lib/uParse/src/components/wxParseImg.vue +0 -1
  110. package/uni-ui/lib/uParse/src/components/wxParseTable.vue +0 -3
  111. package/uni-ui/lib/uParse/src/components/wxParseTemplate0.vue +0 -1
  112. package/uni-ui/lib/uParse/src/components/wxParseTemplate1.vue +0 -1
  113. package/uni-ui/lib/uParse/src/components/wxParseTemplate10.vue +0 -1
  114. package/uni-ui/lib/uParse/src/components/wxParseTemplate11.vue +0 -1
  115. package/uni-ui/lib/uParse/src/components/wxParseTemplate2.vue +0 -1
  116. package/uni-ui/lib/uParse/src/components/wxParseTemplate3.vue +0 -1
  117. package/uni-ui/lib/uParse/src/components/wxParseTemplate4.vue +0 -1
  118. package/uni-ui/lib/uParse/src/components/wxParseTemplate5.vue +0 -1
  119. package/uni-ui/lib/uParse/src/components/wxParseTemplate6.vue +0 -1
  120. package/uni-ui/lib/uParse/src/components/wxParseTemplate7.vue +0 -1
  121. package/uni-ui/lib/uParse/src/components/wxParseTemplate8.vue +0 -1
  122. package/uni-ui/lib/uParse/src/components/wxParseTemplate9.vue +0 -1
  123. package/uni-ui/lib/uParse/src/components/wxParseVideo.vue +0 -1
  124. package/uni-ui/lib/uParse/src/editor.css +0 -495
  125. package/uni-ui/lib/uParse/src/wxParse.vue +0 -1
  126. /package/{uni-ui/lib → other}/api-set-tabbar.nvue +0 -0
  127. /package/{uni-ui/lib → other}/mpvue-echarts/src/echarts.vue +0 -0
  128. /package/{uni-ui/lib → other}/mpvue-echarts/src/style.css +0 -0
  129. /package/{uni-ui/lib → other}/mpvue-echarts/src/wx-canvas.js +0 -0
  130. /package/{uni-ui/lib → other}/product.vue +0 -0
  131. /package/{uni-ui/lib → other}/style.css +0 -0
  132. /package/{uni-ui/lib → other}/tab-nvue/mediaList.vue +0 -0
  133. /package/{uni-ui/lib → other}/u-charts/u-charts.js +0 -0
  134. /package/{uni-ui/lib/uParse/src → other/uParse}/wxParse.css +0 -0
  135. /package/{uni-ui/lib/amap-wx → plugins/map}/lib/amap-wx.js +0 -0
  136. /package/{uni-ui/lib/mpvue-citypicker → ui-cv/components/cv-geo-region}/mpvueCityPicker.vue +0 -0
  137. /package/{uni-ui/lib/marked → ui-cv/components/cv-markdown-show}/lib/marked.js +0 -0
@@ -1 +1,289 @@
1
- <template>
2
1
  <view class="uni-stat__select">
3
2
  <span v-if="label" class="uni-label-text hide-on-phone">{{ label + ':' }}</span>
4
3
  <view class="uni-stat-box" :class="{ 'uni-stat__actived': current }">
5
4
  <view class="uni-select" :class="{ 'uni-select--disabled': disabled }">
6
5
  <view class="uni-select__input-box" @click="toggleSelector">
7
6
  <view v-if="current" class="uni-select__input-text">{{ current }}</view>
8
7
  <view v-else class="uni-select__input-text uni-select__input-placeholder">{{ typePlaceholder }}</view>
9
8
  <view v-if="current && clear && !disabled" @click.stop="clearVal">
10
9
  <uni-icons type="clear" color="#c0c4cc" size="24" />
11
10
  </view>
12
11
  <view v-else>
13
12
  <uni-icons :type="showSelector ? 'top' : 'bottom'" size="14" color="#999" />
14
13
  </view>
15
14
  </view>
16
15
  <view class="uni-select--mask" v-if="showSelector" @click="toggleSelector" />
17
16
  <view class="uni-select__selector" v-if="showSelector">
18
17
  <view class="uni-popper__arrow"></view>
19
18
  <scroll-view scroll-y="true" class="uni-select__selector-scroll">
20
19
  <view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0">
21
20
  <text>{{ emptyTips }}</text>
22
21
  </view>
23
22
  <view
24
23
  v-else
25
24
  class="uni-select__selector-item"
26
25
  v-for="(item, index) in mixinDatacomResData"
27
26
  :key="index"
28
27
  @click="change(item)"
29
28
  >
30
29
  <text :class="{ 'uni-select__selector__disabled': item.disable }">{{ formatItemName(item) }}</text>
31
30
  </view>
32
31
  </scroll-view>
33
32
  </view>
34
33
  </view>
35
34
  </view>
36
35
  </view>
37
36
  * DataChecklist 数据选择器
38
37
  * @description 通过数据渲染的下拉框组件
39
38
  * @tutorial https://uniapp.dcloud.io/component/uniui/uni-data-select
40
39
  * @property {String} value 默认值
41
40
  * @property {Array} localdata 本地数据 ,格式 [{text:'',value:''}]
42
41
  * @property {Boolean} clear 是否可以清空已选项
43
42
  * @property {Boolean} emptyText 没有数据时显示的文字 ,本地数据无效
44
43
  * @property {String} label 左侧标题
45
44
  * @property {String} placeholder 输入框的提示文字
46
45
  * @property {Boolean} disabled 是否禁用
47
46
  * @event {Function} change 选中发生变化触发
48
47
  */
49
48
  name: 'uni-data-select',
50
49
  mixins: [uniCloud.mixinDatacom || {}],
51
50
  props: {
52
51
  localdata: {
53
52
  type: Array,
54
53
  default() {
55
54
  return [];
56
55
  }
57
56
  },
58
57
  value: {
59
58
  type: [String, Number],
60
59
  default: ''
61
60
  },
62
61
  modelValue: {
63
62
  type: [String, Number],
64
63
  default: ''
65
64
  },
66
65
  label: {
67
66
  type: String,
68
67
  default: ''
69
68
  },
70
69
  placeholder: {
71
70
  type: String,
72
71
  default: '请选择'
73
72
  },
74
73
  emptyTips: {
75
74
  type: String,
76
75
  default: '无选项'
77
76
  },
78
77
  clear: {
79
78
  type: Boolean,
80
79
  default: true
81
80
  },
82
81
  defItem: {
83
82
  type: Number,
84
83
  default: 0
85
84
  },
86
85
  disabled: {
87
86
  type: Boolean,
88
87
  default: false
89
88
  },
90
89
  // 格式化输出 用法 field="_id as value, version as text, uni_platform as label" format="{label} - {text}"
91
90
  format: {
92
91
  type: String,
93
92
  default: ''
94
93
  }
95
94
  },
96
95
  data() {
97
96
  return {
98
97
  showSelector: false,
99
98
  current: '',
100
99
  mixinDatacomResData: [],
101
100
  apps: [],
102
101
  channels: [],
103
102
  cacheKey: 'uni-data-select-lastSelectedValue'
104
103
  };
105
104
  },
106
105
  created() {
107
106
  this.debounceGet = this.debounce(() => {
108
107
  this.query();
109
108
  }, 300);
110
109
  if (this.collection && !this.localdata.length) {
111
110
  this.debounceGet();
112
111
  }
113
112
  },
114
113
  computed: {
115
114
  typePlaceholder() {
116
115
  const text = {
117
116
  'opendb-stat-app-versions': '版本',
118
117
  'opendb-app-channels': '渠道',
119
118
  'opendb-app-list': '应用'
120
119
  };
121
120
  const common = this.placeholder;
122
121
  const placeholder = text[this.collection];
123
122
  return placeholder ? common + placeholder : common;
124
123
  },
125
124
  valueCom() {
126
125
  // #ifdef VUE3
127
126
  return this.modelValue;
128
127
  // #endif
129
128
  // #ifndef VUE3
130
129
  return this.value;
131
130
  // #endif
132
131
  }
133
132
  },
134
133
  watch: {
135
134
  localdata: {
136
135
  immediate: true,
137
136
  handler(val, old) {
138
137
  if (Array.isArray(val) && old !== val) {
139
138
  this.mixinDatacomResData = val;
140
139
  }
141
140
  }
142
141
  },
143
142
  valueCom(val, old) {
144
143
  this.initDefVal();
145
144
  },
146
145
  mixinDatacomResData: {
147
146
  immediate: true,
148
147
  handler(val) {
149
148
  if (val.length) {
150
149
  this.initDefVal();
151
150
  }
152
151
  }
153
152
  }
154
153
  },
155
154
  methods: {
156
155
  debounce(fn, time = 100) {
157
156
  let timer = null;
158
157
  return function (...args) {
159
158
  if (timer) clearTimeout(timer);
160
159
  timer = setTimeout(() => {
161
160
  fn.apply(this, args);
162
161
  }, time);
163
162
  };
164
163
  },
165
164
  // 执行数据库查询
166
165
  query() {
167
166
  this.mixinDatacomEasyGet();
168
167
  },
169
168
  // 监听查询条件变更事件
170
169
  onMixinDatacomPropsChange() {
171
170
  if (this.collection) {
172
171
  this.debounceGet();
173
172
  }
174
173
  },
175
174
  initDefVal() {
176
175
  let defValue = '';
177
176
  if ((this.valueCom || this.valueCom === 0) && !this.isDisabled(this.valueCom)) {
178
177
  defValue = this.valueCom;
179
178
  } else {
180
179
  let strogeValue;
181
180
  if (this.collection) {
182
181
  strogeValue = this.getCache();
183
182
  }
184
183
  if (strogeValue || strogeValue === 0) {
185
184
  defValue = strogeValue;
186
185
  } else {
187
186
  let defItem = '';
188
187
  if (this.defItem > 0 && this.defItem <= this.mixinDatacomResData.length) {
189
188
  defItem = this.mixinDatacomResData[this.defItem - 1].value;
190
189
  }
191
190
  defValue = defItem;
192
191
  }
193
192
  if (defValue || defValue === 0) {
194
193
  this.emit(defValue);
195
194
  }
196
195
  }
197
196
  const def = this.mixinDatacomResData.find((item) => item.value === defValue);
198
197
  this.current = def ? this.formatItemName(def) : '';
199
198
  },
200
199
  /**
201
200
  * @param {[String, Number]} value
202
201
  * 判断用户给的 value 是否同时为禁用状态
203
202
  */
204
203
  isDisabled(value) {
205
204
  let isDisabled = false;
206
205
  this.mixinDatacomResData.forEach((item) => {
207
206
  if (item.value === value) {
208
207
  isDisabled = item.disable;
209
208
  }
210
209
  });
211
210
  return isDisabled;
212
211
  },
213
212
  clearVal() {
214
213
  this.emit('');
215
214
  if (this.collection) {
216
215
  this.removeCache();
217
216
  }
218
217
  },
219
218
  change(item) {
220
219
  if (!item.disable) {
221
220
  this.showSelector = false;
222
221
  this.current = this.formatItemName(item);
223
222
  this.emit(item.value);
224
223
  }
225
224
  },
226
225
  emit(val) {
227
226
  this.$emit('input', val);
228
227
  this.$emit('update:modelValue', val);
229
228
  this.$emit('change', val);
230
229
  if (this.collection) {
231
230
  this.setCache(val);
232
231
  }
233
232
  },
234
233
  toggleSelector() {
235
234
  if (this.disabled) {
236
235
  return;
237
236
  }
238
237
  this.showSelector = !this.showSelector;
239
238
  },
240
239
  formatItemName(item) {
241
240
  let { text, value, channel_code } = item;
242
241
  channel_code = channel_code ? `(${channel_code})` : '';
243
242
  if (this.format) {
244
243
  // 格式化输出
245
244
  let str = '';
246
245
  str = this.format;
247
246
  for (let key in item) {
248
247
  str = str.replace(new RegExp(`{${key}}`, 'g'), item[key]);
249
248
  }
250
249
  return str;
251
250
  } else {
252
251
  return this.collection.indexOf('app-list') > 0 ? `${text}(${value})` : text ? text : `未命名${channel_code}`;
253
252
  }
254
253
  },
255
254
  // 获取当前加载的数据
256
255
  getLoadData() {
257
256
  return this.mixinDatacomResData;
258
257
  },
259
258
  // 获取当前缓存key
260
259
  getCurrentCacheKey() {
261
260
  return this.collection;
262
261
  },
263
262
  // 获取缓存
264
263
  getCache(name = this.getCurrentCacheKey()) {
265
264
  let cacheData = uni.getStorageSync(this.cacheKey) || {};
266
265
  return cacheData[name];
267
266
  },
268
267
  // 设置缓存
269
268
  setCache(value, name = this.getCurrentCacheKey()) {
270
269
  let cacheData = uni.getStorageSync(this.cacheKey) || {};
271
270
  cacheData[name] = value;
272
271
  uni.setStorageSync(this.cacheKey, cacheData);
273
272
  },
274
273
  // 删除缓存
275
274
  removeCache(name = this.getCurrentCacheKey()) {
276
275
  let cacheData = uni.getStorageSync(this.cacheKey) || {};
277
276
  delete cacheData[name];
278
277
  uni.setStorageSync(this.cacheKey, cacheData);
279
278
  }
280
279
  }
280
+ <template>
281
+ <view class="uni-stat__select">
282
+ <span v-if="label" class="uni-label-text hide-on-phone">{{ label + ':' }}</span>
283
+ <view class="uni-stat-box" :class="{ 'uni-stat__actived': current }">
284
+ <view class="uni-select" :class="{ 'uni-select--disabled': disabled }">
285
+ <view class="uni-select__input-box" @click="toggleSelector">
286
+ <view v-if="current" class="uni-select__input-text">{{ current }}</view>
287
+ <view v-else class="uni-select__input-text uni-select__input-placeholder">{{ typePlaceholder }}</view>
288
+ <view v-if="current && clear && !disabled" @click.stop="clearVal">
289
+ <uni-icons type="clear" color="#c0c4cc" size="24" />
290
+ </view>
291
+ <view v-else>
292
+ <uni-icons :type="showSelector ? 'top' : 'bottom'" size="14" color="#999" />
293
+ </view>
294
+ </view>
295
+ <view class="uni-select--mask" v-if="showSelector" @click="toggleSelector" />
296
+ <view class="uni-select__selector" v-if="showSelector">
297
+ <view class="uni-popper__arrow"></view>
298
+ <scroll-view scroll-y="true" class="uni-select__selector-scroll">
299
+ <view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0">
300
+ <text>{{ emptyTips }}</text>
301
+ </view>
302
+ <view
303
+ v-else
304
+ class="uni-select__selector-item"
305
+ v-for="(item, index) in mixinDatacomResData"
306
+ :key="index"
307
+ @click="change(item)"
308
+ >
309
+ <text :class="{ 'uni-select__selector__disabled': item.disable }">{{ formatItemName(item) }}</text>
310
+ </view>
311
+ </scroll-view>
312
+ </view>
313
+ </view>
314
+ </view>
315
+ </view>
316
+ </template>
317
+ <script>
318
+ /**
319
+ * DataChecklist 数据选择器
320
+ * @description 通过数据渲染的下拉框组件
321
+ * @tutorial https://uniapp.dcloud.io/component/uniui/uni-data-select
322
+ * @property {String} value 默认值
323
+ * @property {Array} localdata 本地数据 ,格式 [{text:'',value:''}]
324
+ * @property {Boolean} clear 是否可以清空已选项
325
+ * @property {Boolean} emptyText 没有数据时显示的文字 ,本地数据无效
326
+ * @property {String} label 左侧标题
327
+ * @property {String} placeholder 输入框的提示文字
328
+ * @property {Boolean} disabled 是否禁用
329
+ * @event {Function} change 选中发生变化触发
330
+ */
331
+ export default {
332
+ name: 'uni-data-select',
333
+ mixins: [uniCloud.mixinDatacom || {}],
334
+ props: {
335
+ localdata: {
336
+ type: Array,
337
+ default() {
338
+ return [];
339
+ }
340
+ },
341
+ value: {
342
+ type: [String, Number],
343
+ default: ''
344
+ },
345
+ modelValue: {
346
+ type: [String, Number],
347
+ default: ''
348
+ },
349
+ label: {
350
+ type: String,
351
+ default: ''
352
+ },
353
+ placeholder: {
354
+ type: String,
355
+ default: '请选择'
356
+ },
357
+ emptyTips: {
358
+ type: String,
359
+ default: '无选项'
360
+ },
361
+ clear: {
362
+ type: Boolean,
363
+ default: true
364
+ },
365
+ defItem: {
366
+ type: Number,
367
+ default: 0
368
+ },
369
+ disabled: {
370
+ type: Boolean,
371
+ default: false
372
+ },
373
+ // 格式化输出 用法 field="_id as value, version as text, uni_platform as label" format="{label} - {text}"
374
+ format: {
375
+ type: String,
376
+ default: ''
377
+ }
378
+ },
379
+ data() {
380
+ return {
381
+ showSelector: false,
382
+ current: '',
383
+ mixinDatacomResData: [],
384
+ apps: [],
385
+ channels: [],
386
+ cacheKey: 'uni-data-select-lastSelectedValue'
387
+ };
388
+ },
389
+ created() {
390
+ this.debounceGet = this.debounce(() => {
391
+ this.query();
392
+ }, 300);
393
+ if (this.collection && !this.localdata.length) {
394
+ this.debounceGet();
395
+ }
396
+ },
397
+ computed: {
398
+ typePlaceholder() {
399
+ const text = {
400
+ 'opendb-stat-app-versions': '版本',
401
+ 'opendb-app-channels': '渠道',
402
+ 'opendb-app-list': '应用'
403
+ };
404
+ const common = this.placeholder;
405
+ const placeholder = text[this.collection];
406
+ return placeholder ? common + placeholder : common;
407
+ },
408
+ valueCom() {
409
+ // #ifdef VUE3
410
+ return this.modelValue;
411
+ // #endif
412
+ // #ifndef VUE3
413
+ return this.value;
414
+ // #endif
415
+ }
416
+ },
417
+ watch: {
418
+ localdata: {
419
+ immediate: true,
420
+ handler(val, old) {
421
+ if (Array.isArray(val) && old !== val) {
422
+ this.mixinDatacomResData = val;
423
+ }
424
+ }
425
+ },
426
+ valueCom(val, old) {
427
+ this.initDefVal();
428
+ },
429
+ mixinDatacomResData: {
430
+ immediate: true,
431
+ handler(val) {
432
+ if (val.length) {
433
+ this.initDefVal();
434
+ }
435
+ }
436
+ }
437
+ },
438
+ methods: {
439
+ debounce(fn, time = 100) {
440
+ let timer = null;
441
+ return function (...args) {
442
+ if (timer) clearTimeout(timer);
443
+ timer = setTimeout(() => {
444
+ fn.apply(this, args);
445
+ }, time);
446
+ };
447
+ },
448
+ // 执行数据库查询
449
+ query() {
450
+ this.mixinDatacomEasyGet();
451
+ },
452
+ // 监听查询条件变更事件
453
+ onMixinDatacomPropsChange() {
454
+ if (this.collection) {
455
+ this.debounceGet();
456
+ }
457
+ },
458
+ initDefVal() {
459
+ let defValue = '';
460
+ if ((this.valueCom || this.valueCom === 0) && !this.isDisabled(this.valueCom)) {
461
+ defValue = this.valueCom;
462
+ } else {
463
+ let strogeValue;
464
+ if (this.collection) {
465
+ strogeValue = this.getCache();
466
+ }
467
+ if (strogeValue || strogeValue === 0) {
468
+ defValue = strogeValue;
469
+ } else {
470
+ let defItem = '';
471
+ if (this.defItem > 0 && this.defItem <= this.mixinDatacomResData.length) {
472
+ defItem = this.mixinDatacomResData[this.defItem - 1].value;
473
+ }
474
+ defValue = defItem;
475
+ }
476
+ if (defValue || defValue === 0) {
477
+ this.emit(defValue);
478
+ }
479
+ }
480
+ const def = this.mixinDatacomResData.find((item) => item.value === defValue);
481
+ this.current = def ? this.formatItemName(def) : '';
482
+ },
483
+ /**
484
+ * @param {[String, Number]} value
485
+ * 判断用户给的 value 是否同时为禁用状态
486
+ */
487
+ isDisabled(value) {
488
+ let isDisabled = false;
489
+ this.mixinDatacomResData.forEach((item) => {
490
+ if (item.value === value) {
491
+ isDisabled = item.disable;
492
+ }
493
+ });
494
+ return isDisabled;
495
+ },
496
+ clearVal() {
497
+ this.emit('');
498
+ if (this.collection) {
499
+ this.removeCache();
500
+ }
501
+ },
502
+ change(item) {
503
+ if (!item.disable) {
504
+ this.showSelector = false;
505
+ this.current = this.formatItemName(item);
506
+ this.emit(item.value);
507
+ }
508
+ },
509
+ emit(val) {
510
+ this.$emit('input', val);
511
+ this.$emit('update:modelValue', val);
512
+ this.$emit('change', val);
513
+ if (this.collection) {
514
+ this.setCache(val);
515
+ }
516
+ },
517
+ toggleSelector() {
518
+ if (this.disabled) {
519
+ return;
520
+ }
521
+ this.showSelector = !this.showSelector;
522
+ },
523
+ formatItemName(item) {
524
+ let { text, value, channel_code } = item;
525
+ channel_code = channel_code ? `(${channel_code})` : '';
526
+ if (this.format) {
527
+ // 格式化输出
528
+ let str = '';
529
+ str = this.format;
530
+ for (let key in item) {
531
+ str = str.replace(new RegExp(`{${key}}`, 'g'), item[key]);
532
+ }
533
+ return str;
534
+ } else {
535
+ return this.collection.indexOf('app-list') > 0 ? `${text}(${value})` : text ? text : `未命名${channel_code}`;
536
+ }
537
+ },
538
+ // 获取当前加载的数据
539
+ getLoadData() {
540
+ return this.mixinDatacomResData;
541
+ },
542
+ // 获取当前缓存key
543
+ getCurrentCacheKey() {
544
+ return this.collection;
545
+ },
546
+ // 获取缓存
547
+ getCache(name = this.getCurrentCacheKey()) {
548
+ let cacheData = uni.getStorageSync(this.cacheKey) || {};
549
+ return cacheData[name];
550
+ },
551
+ // 设置缓存
552
+ setCache(value, name = this.getCurrentCacheKey()) {
553
+ let cacheData = uni.getStorageSync(this.cacheKey) || {};
554
+ cacheData[name] = value;
555
+ uni.setStorageSync(this.cacheKey, cacheData);
556
+ },
557
+ // 删除缓存
558
+ removeCache(name = this.getCurrentCacheKey()) {
559
+ let cacheData = uni.getStorageSync(this.cacheKey) || {};
560
+ delete cacheData[name];
561
+ uni.setStorageSync(this.cacheKey, cacheData);
562
+ }
563
+ }
564
+ };
565
+ </script>
566
+ <style>
567
+ @import 'style.css';
568
+ </style>
@@ -1 +1,70 @@
1
- <template>
2
1
  <view
3
2
  class="uni-calendar-item__weeks-box"
4
3
  :class="{
5
4
  'uni-calendar-item--disable': weeks.disable,
6
5
  'uni-calendar-item--before-checked-x': weeks.beforeMultiple,
7
6
  'uni-calendar-item--multiple': weeks.multiple,
8
7
  'uni-calendar-item--after-checked-x': weeks.afterMultiple
9
8
  }"
10
9
  @click="choiceDate(weeks)"
11
10
  @mouseenter="handleMousemove(weeks)"
12
11
  >
13
12
  <view
14
13
  class="uni-calendar-item__weeks-box-item"
15
14
  :class="{
16
15
  'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && (calendar.userChecked || !checkHover),
17
16
  'uni-calendar-item--checked-range-text': checkHover,
18
17
  'uni-calendar-item--before-checked': weeks.beforeMultiple,
19
18
  'uni-calendar-item--multiple': weeks.multiple,
20
19
  'uni-calendar-item--after-checked': weeks.afterMultiple,
21
20
  'uni-calendar-item--disable': weeks.disable
22
21
  }"
23
22
  >
24
23
  <text v-if="selected && weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
25
24
  <text class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">
26
25
  {{ weeks.date }}
27
26
  </text>
28
27
  </view>
29
28
  <view :class="{ 'uni-calendar-item--today': weeks.isToday }"></view>
30
29
  </view>
31
30
  props: {
32
31
  weeks: {
33
32
  type: Object,
34
33
  default() {
35
34
  return {};
36
35
  }
37
36
  },
38
37
  calendar: {
39
38
  type: Object,
40
39
  default: () => {
41
40
  return {};
42
41
  }
43
42
  },
44
43
  selected: {
45
44
  type: Array,
46
45
  default: () => {
47
46
  return [];
48
47
  }
49
48
  },
50
49
  checkHover: {
51
50
  type: Boolean,
52
51
  default: false
53
52
  }
54
53
  },
55
54
  methods: {
56
55
  choiceDate(weeks) {
57
56
  this.$emit('change', weeks);
58
57
  },
59
58
  handleMousemove(weeks) {
60
59
  this.$emit('handleMouse', weeks);
61
60
  }
62
61
  }
62
+ <template>
63
+ <view
64
+ class="uni-calendar-item__weeks-box"
65
+ :class="{
66
+ 'uni-calendar-item--disable': weeks.disable,
67
+ 'uni-calendar-item--before-checked-x': weeks.beforeMultiple,
68
+ 'uni-calendar-item--multiple': weeks.multiple,
69
+ 'uni-calendar-item--after-checked-x': weeks.afterMultiple
70
+ }"
71
+ @click="choiceDate(weeks)"
72
+ @mouseenter="handleMousemove(weeks)"
73
+ >
74
+ <view
75
+ class="uni-calendar-item__weeks-box-item"
76
+ :class="{
77
+ 'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && (calendar.userChecked || !checkHover),
78
+ 'uni-calendar-item--checked-range-text': checkHover,
79
+ 'uni-calendar-item--before-checked': weeks.beforeMultiple,
80
+ 'uni-calendar-item--multiple': weeks.multiple,
81
+ 'uni-calendar-item--after-checked': weeks.afterMultiple,
82
+ 'uni-calendar-item--disable': weeks.disable
83
+ }"
84
+ >
85
+ <text v-if="selected && weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
86
+ <text class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">
87
+ {{ weeks.date }}
88
+ </text>
89
+ </view>
90
+ <view :class="{ 'uni-calendar-item--today': weeks.isToday }"></view>
91
+ </view>
92
+ </template>
93
+ <script>
94
+ export default {
95
+ props: {
96
+ weeks: {
97
+ type: Object,
98
+ default() {
99
+ return {};
100
+ }
101
+ },
102
+ calendar: {
103
+ type: Object,
104
+ default: () => {
105
+ return {};
106
+ }
107
+ },
108
+ selected: {
109
+ type: Array,
110
+ default: () => {
111
+ return [];
112
+ }
113
+ },
114
+ checkHover: {
115
+ type: Boolean,
116
+ default: false
117
+ }
118
+ },
119
+ methods: {
120
+ choiceDate(weeks) {
121
+ this.$emit('change', weeks);
122
+ },
123
+ handleMousemove(weeks) {
124
+ this.$emit('handleMouse', weeks);
125
+ }
126
+ }
127
+ };
128
+ </script>
129
+ <style>
130
+ @import 'style.css';
131
+ </style>