@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,366 @@
1
- <template>
2
1
  <view class="uni-calendar">
3
2
  <view
4
3
  v-if="!insert && show"
5
4
  class="uni-calendar__mask"
6
5
  :class="{ 'uni-calendar--mask-show': aniMaskShow }"
7
6
  @click="clean"
8
7
  ></view>
9
8
  <view
10
9
  v-if="insert || show"
11
10
  class="uni-calendar__content"
12
11
  :class="{ 'uni-calendar--fixed': !insert, 'uni-calendar--ani-show': aniMaskShow }"
13
12
  >
14
13
  <view v-if="!insert" class="uni-calendar__header uni-calendar--fixed-top">
15
14
  <view class="uni-calendar__header-btn-box" @click="close">
16
15
  <text class="uni-calendar__header-text uni-calendar--fixed-width">{{ cancelText }}</text>
17
16
  </view>
18
17
  <view class="uni-calendar__header-btn-box" @click="confirm">
19
18
  <text class="uni-calendar__header-text uni-calendar--fixed-width">{{ okText }}</text>
20
19
  </view>
21
20
  </view>
22
21
  <view class="uni-calendar__header">
23
22
  <view class="uni-calendar__header-btn-box" @click.stop="pre">
24
23
  <view class="uni-calendar__header-btn uni-calendar--left"></view>
25
24
  </view>
26
25
  <picker mode="date" :value="date" fields="month" @change="bindDateChange">
27
26
  <text class="uni-calendar__header-text">{{ (nowDate.year || '') + ' / ' + (nowDate.month || '') }}</text>
28
27
  </picker>
29
28
  <view class="uni-calendar__header-btn-box" @click.stop="next">
30
29
  <view class="uni-calendar__header-btn uni-calendar--right"></view>
31
30
  </view>
32
31
  <text class="uni-calendar__backtoday" @click="backToday">{{ todayText }}</text>
33
32
  </view>
34
33
  <view class="uni-calendar__box">
35
34
  <view v-if="showMonth" class="uni-calendar__box-bg">
36
35
  <text class="uni-calendar__box-bg-text">{{ nowDate.month }}</text>
37
36
  </view>
38
37
  <view class="uni-calendar__weeks">
39
38
  <view class="uni-calendar__weeks-day">
40
39
  <text class="uni-calendar__weeks-day-text">{{ SUNText }}</text>
41
40
  </view>
42
41
  <view class="uni-calendar__weeks-day">
43
42
  <text class="uni-calendar__weeks-day-text">{{ monText }}</text>
44
43
  </view>
45
44
  <view class="uni-calendar__weeks-day">
46
45
  <text class="uni-calendar__weeks-day-text">{{ TUEText }}</text>
47
46
  </view>
48
47
  <view class="uni-calendar__weeks-day">
49
48
  <text class="uni-calendar__weeks-day-text">{{ WEDText }}</text>
50
49
  </view>
51
50
  <view class="uni-calendar__weeks-day">
52
51
  <text class="uni-calendar__weeks-day-text">{{ THUText }}</text>
53
52
  </view>
54
53
  <view class="uni-calendar__weeks-day">
55
54
  <text class="uni-calendar__weeks-day-text">{{ FRIText }}</text>
56
55
  </view>
57
56
  <view class="uni-calendar__weeks-day">
58
57
  <text class="uni-calendar__weeks-day-text">{{ SATText }}</text>
59
58
  </view>
60
59
  </view>
61
60
  <view class="uni-calendar__weeks" v-for="(item, weekIndex) in weeks" :key="weekIndex">
62
61
  <view class="uni-calendar__weeks-item" v-for="(weeks, weeksIndex) in item" :key="weeksIndex">
63
62
  <calendar-item
64
63
  class="uni-calendar-item--hook"
65
64
  :weeks="weeks"
66
65
  :calendar="calendar"
67
66
  :selected="selected"
68
67
  :lunar="lunar"
69
68
  @change="choiceDate"
70
69
  ></calendar-item>
71
70
  </view>
72
71
  </view>
73
72
  </view>
74
73
  </view>
75
74
  </view>
76
75
  * Calendar 日历
77
76
  * @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
78
77
  * @tutorial https://ext.dcloud.net.cn/plugin?id=56
79
78
  * @property {String} date 自定义当前时间,默认为今天
80
79
  * @property {Boolean} lunar 显示农历
81
80
  * @property {String} startDate 日期选择范围-开始日期
82
81
  * @property {String} endDate 日期选择范围-结束日期
83
82
  * @property {Boolean} range 范围选择
84
83
  * @property {Boolean} insert = [true|false] 插入模式,默认为false
85
84
  * @value true 弹窗模式
86
85
  * @value false 插入模式
87
86
  * @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
88
87
  * @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
89
88
  * @property {Boolean} showMonth 是否选择月份为背景
90
89
  * @event {Function} change 日期改变,`insert :ture` 时生效
91
90
  * @event {Function} confirm 确认选择`insert :false` 时生效
92
91
  * @event {Function} monthSwitch 切换月份时触发
93
92
  * @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
94
93
  */
95
94
  components: {
96
95
  CalendarItem
97
96
  },
98
97
  emits: ['close', 'confirm', 'change', 'monthSwitch'],
99
98
  props: {
100
99
  date: {
101
100
  type: String,
102
101
  default: ''
103
102
  },
104
103
  selected: {
105
104
  type: Array,
106
105
  default() {
107
106
  return [];
108
107
  }
109
108
  },
110
109
  lunar: {
111
110
  type: Boolean,
112
111
  default: false
113
112
  },
114
113
  startDate: {
115
114
  type: String,
116
115
  default: ''
117
116
  },
118
117
  endDate: {
119
118
  type: String,
120
119
  default: ''
121
120
  },
122
121
  range: {
123
122
  type: Boolean,
124
123
  default: false
125
124
  },
126
125
  insert: {
127
126
  type: Boolean,
128
127
  default: true
129
128
  },
130
129
  showMonth: {
131
130
  type: Boolean,
132
131
  default: true
133
132
  },
134
133
  clearDate: {
135
134
  type: Boolean,
136
135
  default: true
137
136
  }
138
137
  },
139
138
  data() {
140
139
  return {
141
140
  show: false,
142
141
  weeks: [],
143
142
  calendar: {},
144
143
  nowDate: '',
145
144
  aniMaskShow: false
146
145
  };
147
146
  },
148
147
  computed: {
149
148
  /**
150
149
  * for i18n
151
150
  */
152
151
  okText() {
153
152
  return t('uni-calender.ok');
154
153
  },
155
154
  cancelText() {
156
155
  return t('uni-calender.cancel');
157
156
  },
158
157
  todayText() {
159
158
  return t('uni-calender.today');
160
159
  },
161
160
  monText() {
162
161
  return t('uni-calender.MON');
163
162
  },
164
163
  TUEText() {
165
164
  return t('uni-calender.TUE');
166
165
  },
167
166
  WEDText() {
168
167
  return t('uni-calender.WED');
169
168
  },
170
169
  THUText() {
171
170
  return t('uni-calender.THU');
172
171
  },
173
172
  FRIText() {
174
173
  return t('uni-calender.FRI');
175
174
  },
176
175
  SATText() {
177
176
  return t('uni-calender.SAT');
178
177
  },
179
178
  SUNText() {
180
179
  return t('uni-calender.SUN');
181
180
  }
182
181
  },
183
182
  watch: {
184
183
  date(newVal) {
185
184
  // this.cale.setDate(newVal)
186
185
  this.init(newVal);
187
186
  },
188
187
  startDate(val) {
189
188
  this.cale.resetSatrtDate(val);
190
189
  this.cale.setDate(this.nowDate.fullDate);
191
190
  this.weeks = this.cale.weeks;
192
191
  },
193
192
  endDate(val) {
194
193
  this.cale.resetEndDate(val);
195
194
  this.cale.setDate(this.nowDate.fullDate);
196
195
  this.weeks = this.cale.weeks;
197
196
  },
198
197
  selected(newVal) {
199
198
  this.cale.setSelectInfo(this.nowDate.fullDate, newVal);
200
199
  this.weeks = this.cale.weeks;
201
200
  }
202
201
  },
203
202
  created() {
204
203
  this.cale = new Calendar({
205
204
  selected: this.selected,
206
205
  startDate: this.startDate,
207
206
  endDate: this.endDate,
208
207
  range: this.range
209
208
  });
210
209
  this.init(this.date);
211
210
  },
212
211
  methods: {
213
212
  // 取消穿透
214
213
  clean() {},
215
214
  bindDateChange(e) {
216
215
  const value = e.detail.value + '-1';
217
216
  this.setDate(value);
218
217
  const { year, month } = this.cale.getDate(value);
219
218
  this.$emit('monthSwitch', {
220
219
  year,
221
220
  month
222
221
  });
223
222
  },
224
223
  /**
225
224
  * 初始化日期显示
226
225
  * @param {Object} date
227
226
  */
228
227
  init(date) {
229
228
  this.cale.setDate(date);
230
229
  this.weeks = this.cale.weeks;
231
230
  this.nowDate = this.calendar = this.cale.getInfo(date);
232
231
  },
233
232
  /**
234
233
  * 打开日历弹窗
235
234
  */
236
235
  open() {
237
236
  // 弹窗模式并且清理数据
238
237
  if (this.clearDate && !this.insert) {
239
238
  this.cale.cleanMultipleStatus();
240
239
  // this.cale.setDate(this.date)
241
240
  this.init(this.date);
242
241
  }
243
242
  this.show = true;
244
243
  this.$nextTick(() => {
245
244
  setTimeout(() => {
246
245
  this.aniMaskShow = true;
247
246
  }, 50);
248
247
  });
249
248
  },
250
249
  /**
251
250
  * 关闭日历弹窗
252
251
  */
253
252
  close() {
254
253
  this.aniMaskShow = false;
255
254
  this.$nextTick(() => {
256
255
  setTimeout(() => {
257
256
  this.show = false;
258
257
  this.$emit('close');
259
258
  }, 300);
260
259
  });
261
260
  },
262
261
  /**
263
262
  * 确认按钮
264
263
  */
265
264
  confirm() {
266
265
  this.setEmit('confirm');
267
266
  this.close();
268
267
  },
269
268
  /**
270
269
  * 变化触发
271
270
  */
272
271
  change() {
273
272
  if (!this.insert) return;
274
273
  this.setEmit('change');
275
274
  },
276
275
  /**
277
276
  * 选择月份触发
278
277
  */
279
278
  monthSwitch() {
280
279
  let { year, month } = this.nowDate;
281
280
  this.$emit('monthSwitch', {
282
281
  year,
283
282
  month: Number(month)
284
283
  });
285
284
  },
286
285
  /**
287
286
  * 派发事件
288
287
  * @param {Object} name
289
288
  */
290
289
  setEmit(name) {
291
290
  let { year, month, date, fullDate, lunar, extraInfo } = this.calendar;
292
291
  this.$emit(name, {
293
292
  range: this.cale.multipleStatus,
294
293
  year,
295
294
  month,
296
295
  date,
297
296
  fulldate: fullDate,
298
297
  lunar,
299
298
  extraInfo: extraInfo || {}
300
299
  });
301
300
  },
302
301
  /**
303
302
  * 选择天触发
304
303
  * @param {Object} weeks
305
304
  */
306
305
  choiceDate(weeks) {
307
306
  if (weeks.disable) return;
308
307
  this.calendar = weeks;
309
308
  // 设置多选
310
309
  this.cale.setMultiple(this.calendar.fullDate);
311
310
  this.weeks = this.cale.weeks;
312
311
  this.change();
313
312
  },
314
313
  /**
315
314
  * 回到今天
316
315
  */
317
316
  backToday() {
318
317
  const nowYearMonth = `${this.nowDate.year}-${this.nowDate.month}`;
319
318
  const date = this.cale.getDate(new Date());
320
319
  const todayYearMonth = `${date.year}-${date.month}`;
321
320
  if (nowYearMonth !== todayYearMonth) {
322
321
  this.monthSwitch();
323
322
  }
324
323
  this.init(date.fullDate);
325
324
  this.change();
326
325
  },
327
326
  /**
328
327
  * 上个月
329
328
  */
330
329
  pre() {
331
330
  const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate;
332
331
  this.setDate(preDate);
333
332
  this.monthSwitch();
334
333
  },
335
334
  /**
336
335
  * 下个月
337
336
  */
338
337
  next() {
339
338
  const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate;
340
339
  this.setDate(nextDate);
341
340
  this.monthSwitch();
342
341
  },
343
342
  /**
344
343
  * 设置日期
345
344
  * @param {Object} date
346
345
  */
347
346
  setDate(date) {
348
347
  this.cale.setDate(date);
349
348
  this.weeks = this.cale.weeks;
350
349
  this.nowDate = this.cale.getInfo(date);
351
350
  }
352
351
  }
352
+ <template>
353
+ <view class="uni-calendar">
354
+ <view
355
+ v-if="!insert && show"
356
+ class="uni-calendar__mask"
357
+ :class="{ 'uni-calendar--mask-show': aniMaskShow }"
358
+ @click="clean"
359
+ ></view>
360
+ <view
361
+ v-if="insert || show"
362
+ class="uni-calendar__content"
363
+ :class="{ 'uni-calendar--fixed': !insert, 'uni-calendar--ani-show': aniMaskShow }"
364
+ >
365
+ <view v-if="!insert" class="uni-calendar__header uni-calendar--fixed-top">
366
+ <view class="uni-calendar__header-btn-box" @click="close">
367
+ <text class="uni-calendar__header-text uni-calendar--fixed-width">{{ cancelText }}</text>
368
+ </view>
369
+ <view class="uni-calendar__header-btn-box" @click="confirm">
370
+ <text class="uni-calendar__header-text uni-calendar--fixed-width">{{ okText }}</text>
371
+ </view>
372
+ </view>
373
+ <view class="uni-calendar__header">
374
+ <view class="uni-calendar__header-btn-box" @click.stop="pre">
375
+ <view class="uni-calendar__header-btn uni-calendar--left"></view>
376
+ </view>
377
+ <picker mode="date" :value="date" fields="month" @change="bindDateChange">
378
+ <text class="uni-calendar__header-text">{{ (nowDate.year || '') + ' / ' + (nowDate.month || '') }}</text>
379
+ </picker>
380
+ <view class="uni-calendar__header-btn-box" @click.stop="next">
381
+ <view class="uni-calendar__header-btn uni-calendar--right"></view>
382
+ </view>
383
+ <text class="uni-calendar__backtoday" @click="backToday">{{ todayText }}</text>
384
+ </view>
385
+ <view class="uni-calendar__box">
386
+ <view v-if="showMonth" class="uni-calendar__box-bg">
387
+ <text class="uni-calendar__box-bg-text">{{ nowDate.month }}</text>
388
+ </view>
389
+ <view class="uni-calendar__weeks">
390
+ <view class="uni-calendar__weeks-day">
391
+ <text class="uni-calendar__weeks-day-text">{{ SUNText }}</text>
392
+ </view>
393
+ <view class="uni-calendar__weeks-day">
394
+ <text class="uni-calendar__weeks-day-text">{{ monText }}</text>
395
+ </view>
396
+ <view class="uni-calendar__weeks-day">
397
+ <text class="uni-calendar__weeks-day-text">{{ TUEText }}</text>
398
+ </view>
399
+ <view class="uni-calendar__weeks-day">
400
+ <text class="uni-calendar__weeks-day-text">{{ WEDText }}</text>
401
+ </view>
402
+ <view class="uni-calendar__weeks-day">
403
+ <text class="uni-calendar__weeks-day-text">{{ THUText }}</text>
404
+ </view>
405
+ <view class="uni-calendar__weeks-day">
406
+ <text class="uni-calendar__weeks-day-text">{{ FRIText }}</text>
407
+ </view>
408
+ <view class="uni-calendar__weeks-day">
409
+ <text class="uni-calendar__weeks-day-text">{{ SATText }}</text>
410
+ </view>
411
+ </view>
412
+ <view class="uni-calendar__weeks" v-for="(item, weekIndex) in weeks" :key="weekIndex">
413
+ <view class="uni-calendar__weeks-item" v-for="(weeks, weeksIndex) in item" :key="weeksIndex">
414
+ <calendar-item
415
+ class="uni-calendar-item--hook"
416
+ :weeks="weeks"
417
+ :calendar="calendar"
418
+ :selected="selected"
419
+ :lunar="lunar"
420
+ @change="choiceDate"
421
+ ></calendar-item>
422
+ </view>
423
+ </view>
424
+ </view>
425
+ </view>
426
+ </view>
427
+ </template>
428
+ <script>
429
+ import Calendar from './util.js';
430
+ import CalendarItem from './uni-calendar-item.vue';
431
+ import { initVueI18n } from '@dcloudio/uni-i18n';
432
+ import i18nMessages from './i18n/index.js';
433
+ const { t } = initVueI18n(i18nMessages);
434
+ /**
435
+ * Calendar 日历
436
+ * @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
437
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=56
438
+ * @property {String} date 自定义当前时间,默认为今天
439
+ * @property {Boolean} lunar 显示农历
440
+ * @property {String} startDate 日期选择范围-开始日期
441
+ * @property {String} endDate 日期选择范围-结束日期
442
+ * @property {Boolean} range 范围选择
443
+ * @property {Boolean} insert = [true|false] 插入模式,默认为false
444
+ * @value true 弹窗模式
445
+ * @value false 插入模式
446
+ * @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
447
+ * @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
448
+ * @property {Boolean} showMonth 是否选择月份为背景
449
+ * @event {Function} change 日期改变,`insert :ture` 时生效
450
+ * @event {Function} confirm 确认选择`insert :false` 时生效
451
+ * @event {Function} monthSwitch 切换月份时触发
452
+ * @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
453
+ */
454
+ export default {
455
+ components: {
456
+ CalendarItem
457
+ },
458
+ emits: ['close', 'confirm', 'change', 'monthSwitch'],
459
+ props: {
460
+ date: {
461
+ type: String,
462
+ default: ''
463
+ },
464
+ selected: {
465
+ type: Array,
466
+ default() {
467
+ return [];
468
+ }
469
+ },
470
+ lunar: {
471
+ type: Boolean,
472
+ default: false
473
+ },
474
+ startDate: {
475
+ type: String,
476
+ default: ''
477
+ },
478
+ endDate: {
479
+ type: String,
480
+ default: ''
481
+ },
482
+ range: {
483
+ type: Boolean,
484
+ default: false
485
+ },
486
+ insert: {
487
+ type: Boolean,
488
+ default: true
489
+ },
490
+ showMonth: {
491
+ type: Boolean,
492
+ default: true
493
+ },
494
+ clearDate: {
495
+ type: Boolean,
496
+ default: true
497
+ }
498
+ },
499
+ data() {
500
+ return {
501
+ show: false,
502
+ weeks: [],
503
+ calendar: {},
504
+ nowDate: '',
505
+ aniMaskShow: false
506
+ };
507
+ },
508
+ computed: {
509
+ /**
510
+ * for i18n
511
+ */
512
+ okText() {
513
+ return t('uni-calender.ok');
514
+ },
515
+ cancelText() {
516
+ return t('uni-calender.cancel');
517
+ },
518
+ todayText() {
519
+ return t('uni-calender.today');
520
+ },
521
+ monText() {
522
+ return t('uni-calender.MON');
523
+ },
524
+ TUEText() {
525
+ return t('uni-calender.TUE');
526
+ },
527
+ WEDText() {
528
+ return t('uni-calender.WED');
529
+ },
530
+ THUText() {
531
+ return t('uni-calender.THU');
532
+ },
533
+ FRIText() {
534
+ return t('uni-calender.FRI');
535
+ },
536
+ SATText() {
537
+ return t('uni-calender.SAT');
538
+ },
539
+ SUNText() {
540
+ return t('uni-calender.SUN');
541
+ }
542
+ },
543
+ watch: {
544
+ date(newVal) {
545
+ // this.cale.setDate(newVal)
546
+ this.init(newVal);
547
+ },
548
+ startDate(val) {
549
+ this.cale.resetSatrtDate(val);
550
+ this.cale.setDate(this.nowDate.fullDate);
551
+ this.weeks = this.cale.weeks;
552
+ },
553
+ endDate(val) {
554
+ this.cale.resetEndDate(val);
555
+ this.cale.setDate(this.nowDate.fullDate);
556
+ this.weeks = this.cale.weeks;
557
+ },
558
+ selected(newVal) {
559
+ this.cale.setSelectInfo(this.nowDate.fullDate, newVal);
560
+ this.weeks = this.cale.weeks;
561
+ }
562
+ },
563
+ created() {
564
+ this.cale = new Calendar({
565
+ selected: this.selected,
566
+ startDate: this.startDate,
567
+ endDate: this.endDate,
568
+ range: this.range
569
+ });
570
+ this.init(this.date);
571
+ },
572
+ methods: {
573
+ // 取消穿透
574
+ clean() {},
575
+ bindDateChange(e) {
576
+ const value = e.detail.value + '-1';
577
+ this.setDate(value);
578
+ const { year, month } = this.cale.getDate(value);
579
+ this.$emit('monthSwitch', {
580
+ year,
581
+ month
582
+ });
583
+ },
584
+ /**
585
+ * 初始化日期显示
586
+ * @param {Object} date
587
+ */
588
+ init(date) {
589
+ this.cale.setDate(date);
590
+ this.weeks = this.cale.weeks;
591
+ this.nowDate = this.calendar = this.cale.getInfo(date);
592
+ },
593
+ /**
594
+ * 打开日历弹窗
595
+ */
596
+ open() {
597
+ // 弹窗模式并且清理数据
598
+ if (this.clearDate && !this.insert) {
599
+ this.cale.cleanMultipleStatus();
600
+ // this.cale.setDate(this.date)
601
+ this.init(this.date);
602
+ }
603
+ this.show = true;
604
+ this.$nextTick(() => {
605
+ setTimeout(() => {
606
+ this.aniMaskShow = true;
607
+ }, 50);
608
+ });
609
+ },
610
+ /**
611
+ * 关闭日历弹窗
612
+ */
613
+ close() {
614
+ this.aniMaskShow = false;
615
+ this.$nextTick(() => {
616
+ setTimeout(() => {
617
+ this.show = false;
618
+ this.$emit('close');
619
+ }, 300);
620
+ });
621
+ },
622
+ /**
623
+ * 确认按钮
624
+ */
625
+ confirm() {
626
+ this.setEmit('confirm');
627
+ this.close();
628
+ },
629
+ /**
630
+ * 变化触发
631
+ */
632
+ change() {
633
+ if (!this.insert) return;
634
+ this.setEmit('change');
635
+ },
636
+ /**
637
+ * 选择月份触发
638
+ */
639
+ monthSwitch() {
640
+ let { year, month } = this.nowDate;
641
+ this.$emit('monthSwitch', {
642
+ year,
643
+ month: Number(month)
644
+ });
645
+ },
646
+ /**
647
+ * 派发事件
648
+ * @param {Object} name
649
+ */
650
+ setEmit(name) {
651
+ let { year, month, date, fullDate, lunar, extraInfo } = this.calendar;
652
+ this.$emit(name, {
653
+ range: this.cale.multipleStatus,
654
+ year,
655
+ month,
656
+ date,
657
+ fulldate: fullDate,
658
+ lunar,
659
+ extraInfo: extraInfo || {}
660
+ });
661
+ },
662
+ /**
663
+ * 选择天触发
664
+ * @param {Object} weeks
665
+ */
666
+ choiceDate(weeks) {
667
+ if (weeks.disable) return;
668
+ this.calendar = weeks;
669
+ // 设置多选
670
+ this.cale.setMultiple(this.calendar.fullDate);
671
+ this.weeks = this.cale.weeks;
672
+ this.change();
673
+ },
674
+ /**
675
+ * 回到今天
676
+ */
677
+ backToday() {
678
+ const nowYearMonth = `${this.nowDate.year}-${this.nowDate.month}`;
679
+ const date = this.cale.getDate(new Date());
680
+ const todayYearMonth = `${date.year}-${date.month}`;
681
+ if (nowYearMonth !== todayYearMonth) {
682
+ this.monthSwitch();
683
+ }
684
+ this.init(date.fullDate);
685
+ this.change();
686
+ },
687
+ /**
688
+ * 上个月
689
+ */
690
+ pre() {
691
+ const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate;
692
+ this.setDate(preDate);
693
+ this.monthSwitch();
694
+ },
695
+ /**
696
+ * 下个月
697
+ */
698
+ next() {
699
+ const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate;
700
+ this.setDate(nextDate);
701
+ this.monthSwitch();
702
+ },
703
+ /**
704
+ * 设置日期
705
+ * @param {Object} date
706
+ */
707
+ setDate(date) {
708
+ this.cale.setDate(date);
709
+ this.weeks = this.cale.weeks;
710
+ this.nowDate = this.cale.getInfo(date);
711
+ }
712
+ }
713
+ };
714
+ </script>
715
+ <style scoped>
716
+ @import 'style.css';
717
+ </style>