wl-design-mobile 0.6.9 → 0.7.1

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.
@@ -52,11 +52,11 @@ export default {
52
52
  },
53
53
  minDate: {
54
54
  type: Date,
55
- default: () => new Date((new Date()).getFullYear() - 3, (new Date()).getMonth(), (new Date()).getDate())
55
+ default: () => moment().subtract(3, 'years').toDate(),
56
56
  },
57
57
  maxDate: {
58
58
  type: Date,
59
- default: () => new Date((new Date()).getFullYear() + 3, (new Date()).getMonth(), (new Date()).getDate())
59
+ default: () => moment().add(3, 'years').toDate(),
60
60
  },
61
61
  allowSameDay: {
62
62
  type: Boolean,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wl-design-mobile",
3
- "version": "0.6.9",
3
+ "version": "0.7.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "finch",
@@ -0,0 +1,326 @@
1
+ <template>
2
+ <div
3
+ class="week-date-picker"
4
+ @touchstart="handleTouchStart"
5
+ @touchmove="handleTouchMove"
6
+ @touchend="handleTouchEnd"
7
+ @mousedown="handleMouseDown"
8
+ @mousemove="handleMouseMove"
9
+ @mouseup="handleMouseUp"
10
+ @mouseleave="handleMouseLeave"
11
+ >
12
+ <div class="week-days">
13
+ <div
14
+ v-for="day in weekDays"
15
+ :key="day.date.getTime()"
16
+ class="day-item"
17
+ :class="{
18
+ 'today': day.isToday,
19
+ 'active': day.isSelected,
20
+ }"
21
+ @click="selectDay(day)"
22
+ >
23
+ <div class="day-week">{{ day.weekDay }}</div>
24
+ <div class="day-month">{{ day.month }}月</div>
25
+ <div class="day-date">{{ day.date.getDate() }}</div>
26
+ <div v-if="day.isToday" class="today-dot"></div>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </template>
31
+
32
+ <script>
33
+ const WEEK_DAYS = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
34
+
35
+ export default {
36
+ name: "LamboWeekSelect",
37
+
38
+ data() {
39
+ return {
40
+ selectedDate: new Date(),
41
+ weekStart: null,
42
+ startX: 0,
43
+ endX: 0,
44
+ isDragging: false,
45
+ swipeThreshold: 50,
46
+ clickDisabled: false
47
+ }
48
+ },
49
+ props: {
50
+ weekDate: {
51
+ type: String,
52
+ default: null
53
+ },
54
+ },
55
+
56
+ created() {
57
+ if (this.weekDate) {
58
+ this.initWithWeekDate(this.weekDate);
59
+ } else {
60
+ const today = new Date();
61
+ const todayStr = this.formatDateToYYYYMMDD(today);
62
+ this.initWithWeekDate(todayStr);
63
+ }
64
+ },
65
+
66
+ computed: {
67
+ weekDays() {
68
+ if (!this.weekStart) return [];
69
+ return Array.from({length: 7}, (_, i) => {
70
+ const date = new Date(this.weekStart);
71
+ date.setDate(this.weekStart.getDate() + i);
72
+ const today = new Date();
73
+ return {
74
+ date,
75
+ month: date.getMonth() + 1,
76
+ weekDay: WEEK_DAYS[date.getDay()],
77
+ isToday: this.isSameDay(date, today),
78
+ isSelected: this.isSameDay(date, this.selectedDate)
79
+ };
80
+ });
81
+ }
82
+ },
83
+
84
+ methods: {
85
+ /**
86
+ * 根据YYYYMMDD格式的字符串初始化组件
87
+ * @param {string} dateFormat- 格式如:"20251205"
88
+ */
89
+ initWithWeekDate(dateFormat) {
90
+ // 解析YYYYMMDD格式字符串为Date对象
91
+ const date = this.parseYYYYMMDD(dateFormat);
92
+
93
+ if (date) {
94
+ console.log("根据传入日期初始化:", dateFormat);
95
+ this.setWeekStart(date);
96
+ this.selectedDate = new Date(date);
97
+ } else {
98
+ console.log("日期解析失败,使用今天");
99
+ const today = new Date();
100
+ this.setWeekStart(today);
101
+ this.selectedDate = new Date(today);
102
+ }
103
+ },
104
+
105
+ /**
106
+ * 解析YYYYMMDD格式字符串为Date对象
107
+ * @param {string} yyyymmdd - 格式如:"20251205"
108
+ * @returns {Date|null} Date对象或null
109
+ */
110
+ parseYYYYMMDD(dateFormat) {
111
+ if (!dateFormat || typeof dateFormat !== 'string' || dateFormat.length !== 8) {
112
+ return null;
113
+ }
114
+
115
+ try {
116
+ const year = parseInt(dateFormat.substring(0, 4));
117
+ const month = parseInt(dateFormat.substring(4, 6)) - 1;
118
+ const day = parseInt(dateFormat.substring(6, 8));
119
+
120
+ const date = new Date(year, month, day);
121
+
122
+ // 验证日期是否有效
123
+ if (isNaN(date.getTime()) ||
124
+ date.getFullYear() !== year ||
125
+ date.getMonth() !== month ||
126
+ date.getDate() !== day) {
127
+ return null;
128
+ }
129
+
130
+ return date;
131
+ } catch (error) {
132
+ console.error("日期解析错误:", error);
133
+ return null;
134
+ }
135
+ },
136
+
137
+ setWeekStart(date) {
138
+ const d = new Date(date);
139
+ const day = d.getDay();
140
+ const diff = d.getDate() - (day === 0 ? 6 : day - 1);
141
+ d.setDate(diff);
142
+ d.setHours(0, 0, 0, 0);
143
+ this.weekStart = d;
144
+ },
145
+
146
+ isSameDay(d1, d2) {
147
+ if (!d1 || !d2) return false;
148
+ return d1.toDateString() === d2.toDateString();
149
+ },
150
+
151
+ formatDateToYYYYMMDD(date) {
152
+ const year = date.getFullYear();
153
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
154
+ const day = date.getDate().toString().padStart(2, '0');
155
+ return `${year}${month}${day}`;
156
+ },
157
+
158
+ selectDay(day) {
159
+ if (this.clickDisabled) {
160
+ this.clickDisabled = false;
161
+ return;
162
+ }
163
+ this.selectedDate = new Date(day.date);
164
+ const clickDate = this.formatDateToYYYYMMDD(this.selectedDate);
165
+ console.log('选中的日期:', clickDate);
166
+ // 触发自定义事件,传递YYYYMMDD格式的日期
167
+ this.$emit('click', clickDate);
168
+ },
169
+
170
+ goPrevWeek() {
171
+ const newWeekStart = new Date(this.weekStart);
172
+ newWeekStart.setDate(this.weekStart.getDate() - 7);
173
+ this.setWeekStart(newWeekStart);
174
+ },
175
+
176
+ goNextWeek() {
177
+ const newWeekStart = new Date(this.weekStart);
178
+ newWeekStart.setDate(this.weekStart.getDate() + 7);
179
+ this.setWeekStart(newWeekStart);
180
+ },
181
+
182
+ handleTouchStart(e) {
183
+ this.startX = e.touches[0].clientX;
184
+ this.endX = this.startX;
185
+ this.isDragging = true;
186
+ this.clickDisabled = false;
187
+ },
188
+
189
+ handleTouchMove(e) {
190
+ if (!this.isDragging) return;
191
+ this.endX = e.touches[0].clientX;
192
+ },
193
+
194
+ handleTouchEnd() {
195
+ if (!this.isDragging) return;
196
+
197
+ const deltaX = this.endX - this.startX;
198
+ this.handleSwipe(deltaX);
199
+
200
+ this.isDragging = false;
201
+ },
202
+
203
+ handleMouseDown(e) {
204
+ this.startX = e.clientX;
205
+ this.endX = this.startX;
206
+ this.isDragging = true;
207
+ this.clickDisabled = false;
208
+ },
209
+
210
+ handleMouseMove(e) {
211
+ if (!this.isDragging) return;
212
+ this.endX = e.clientX;
213
+ },
214
+
215
+ handleMouseUp() {
216
+ if (!this.isDragging) return;
217
+
218
+ const deltaX = this.endX - this.startX;
219
+ this.handleSwipe(deltaX);
220
+
221
+ this.isDragging = false;
222
+ },
223
+
224
+ handleMouseLeave() {
225
+ this.isDragging = false;
226
+ },
227
+
228
+ handleSwipe(deltaX) {
229
+ if (Math.abs(deltaX) > this.swipeThreshold) {
230
+ this.clickDisabled = true;
231
+ if (deltaX > 0) {
232
+ this.goPrevWeek();
233
+ } else {
234
+ this.goNextWeek();
235
+ }
236
+ }
237
+ }
238
+ }
239
+ }
240
+ </script>
241
+
242
+ <style scoped>
243
+ .week-date-picker {
244
+ width: 100%;
245
+ background: white;
246
+ padding: 16px 0;
247
+ box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
248
+ user-select: none;
249
+ border-radius: 8px;
250
+ overflow: hidden;
251
+ cursor: grab;
252
+ }
253
+
254
+ .week-date-picker:active {
255
+ cursor: grabbing;
256
+ }
257
+
258
+ .week-days {
259
+ display: flex;
260
+ justify-content: space-around;
261
+ align-items: center;
262
+ padding: 0 8px;
263
+ }
264
+
265
+ .day-item {
266
+ display: flex;
267
+ flex-direction: column;
268
+ align-items: center;
269
+ justify-content: center;
270
+ width: 44px;
271
+ height: 64px;
272
+ border-radius: 8px;
273
+ cursor: pointer;
274
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
275
+ position: relative;
276
+ flex-shrink: 0;
277
+ }
278
+
279
+ .day-item:hover {
280
+ background-color: #f5f5f5;
281
+ transform: translateY(-2px);
282
+ }
283
+
284
+ .day-item.active {
285
+ background-color: #1677ff;
286
+ box-shadow: 0 4px 12px rgba(22, 119, 255, 0.3);
287
+ transform: translateY(-2px);
288
+ }
289
+
290
+ .day-item.active .day-week,
291
+ .day-item.active .day-month,
292
+ .day-item.active .day-date {
293
+ color: white;
294
+ }
295
+
296
+ .day-week {
297
+ font-size: 12px;
298
+ color: #666;
299
+ margin-bottom: 4px;
300
+ }
301
+
302
+ .day-month {
303
+ font-size: 10px;
304
+ color: #999;
305
+ margin-bottom: 2px;
306
+ }
307
+
308
+ .day-date {
309
+ font-size: 20px;
310
+ font-weight: 500;
311
+ color: #333;
312
+ }
313
+
314
+ .today-dot {
315
+ position: absolute;
316
+ bottom: -4px;
317
+ width: 4px;
318
+ height: 4px;
319
+ background-color: #1677ff;
320
+ border-radius: 50%;
321
+ }
322
+
323
+ .day-item.active .today-dot {
324
+ background-color: white;
325
+ }
326
+ </style>
package/util/jssdk.js CHANGED
@@ -250,39 +250,67 @@ let JsSDK = (function () {
250
250
  }
251
251
  })
252
252
  }
253
- function takePhoto(){
253
+ function takePhoto({count = 1} = {}){
254
254
  return new Promise((resolve, reject) =>{
255
255
  if(getAppType() === '30'){
256
256
  reject('钉钉不支持此方式拍照')
257
257
  }else{
258
258
  configWx().then(()=>{
259
259
  wx.chooseImage({
260
- count: 1, // 默认1
260
+ count: count, // 默认1
261
261
  sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
262
262
  sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有
263
- success: function (res) {
263
+ success: async function (res) {
264
264
  let localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
265
- let localId = localIds[0];
266
265
  Toast.loading({
267
266
  duration: 0, // 持续展示 toast
268
267
  forbidClick: false,
269
268
  message: '正在上传',
270
269
  });
271
- setTimeout(() => {
272
- wx.uploadImage({
273
- localId: localId, // 需要上传的图片的本地ID,由chooseImage接口获得
274
- isShowProgressTips: 0, // 默认为1,显示进度提示
275
- success: function (res) {
276
- Toast.clear()
277
- let serverId = res.serverId; // 返回图片的服务器端ID
278
- resolve({
279
- appId:sessionStorage.getItem(APP_ID),
280
- agentId:sessionStorage.getItem(AGENT_ID),
281
- serverId:serverId
282
- })
283
- }
284
- })
285
- }, 200);
270
+ let uploadPromises = localIds.map(localId => {
271
+ return new Promise((resolve, reject) => {
272
+ wx.uploadImage({
273
+ localId: localId, // 需要上传的图片的本地ID,由chooseImage接口获得
274
+ isShowProgressTips: 0, // 默认为1,显示进度提示
275
+ success: function (res) {
276
+ let serverId = res.serverId; // 返回图片的服务器端ID
277
+ resolve(serverId);
278
+ },
279
+ fail: function (error) {
280
+ reject(error);
281
+ }
282
+ });
283
+ });
284
+ });
285
+ try {
286
+ let serverIds = await Promise.all(uploadPromises);
287
+ console.log('choosePhoto', serverIds)
288
+ Toast.clear()
289
+ resolve({
290
+ appId: sessionStorage.getItem(APP_ID),
291
+ agentId: sessionStorage.getItem(AGENT_ID),
292
+ serverId: serverIds[0],
293
+ serverIds: serverIds
294
+ });
295
+ } catch (error) {
296
+ Toast.clear()
297
+ reject('上传图片失败:' + error);
298
+ }
299
+ // setTimeout(() => {
300
+ // wx.uploadImage({
301
+ // localId: localId, // 需要上传的图片的本地ID,由chooseImage接口获得
302
+ // isShowProgressTips: 0, // 默认为1,显示进度提示
303
+ // success: function (res) {
304
+ // Toast.clear()
305
+ // let serverId = res.serverId; // 返回图片的服务器端ID
306
+ // resolve({
307
+ // appId:sessionStorage.getItem(APP_ID),
308
+ // agentId:sessionStorage.getItem(AGENT_ID),
309
+ // serverId:serverId
310
+ // })
311
+ // }
312
+ // })
313
+ // }, 200);
286
314
  },
287
315
  cancel:function (){
288
316
  reject('取消拍照')