diff --git a/api/index.js b/api/index.js index 3bc6212..b2dbea8 100644 --- a/api/index.js +++ b/api/index.js @@ -5,6 +5,11 @@ const API = { //微信登录 getToken: data => net.POST('/login/token',data), // 获取token wx_login: (data,userId) => net.POST('/user/binding/wechat',data,true,{"userId":userId}), // 微信登录 + // upload: (data) => net.POST('/user/upload',data), // 文件上传 + userinfoUpdae:data => net.PUT('/user/info',data), // 更新用户信息 + // 首页 + getHospitalList:data => net.GET('/hospital/list',data), // 获取医院信息 + /* 首页信息 */ diff --git a/api/request.js b/api/request.js index d7407f5..7dc2c7b 100644 --- a/api/request.js +++ b/api/request.js @@ -3,13 +3,23 @@ import config from '../config' // import store from '../store' const loginUrl = 'pages/user/login'; - +// function JSON_to_URLEncoded(element,key,list){ +// var list = list || []; +// if(typeof(element)=='object'){ +// for (var idx in element) +// JSON_to_URLEncoded(element[idx],key?key+'['+idx+']':idx,list); +// } else { +// list.push(key+'='+encodeURIComponent(element)); +// } +// return list.join('&'); +// } export default { REQUEST(url, method = 'GET', data, checkLogin = true, header) { - let token = uni.getStorageSync('access_token') || 'Basic ZGV20mRldjEyMw=='; + + let token = uni.getStorageSync('access_token') || 'Basic ZGV2OmRldjEyMw=='; const headers = { - "Content-Type": "application/json", - // "Content-Type": "application/x-www-form-urlencoded", + // "Content-Type": "application/json", + "Content-Type": "application/x-www-form-urlencoded", "Authorization": token, "x-token": token, "token":token, @@ -18,10 +28,6 @@ export default { } var pages = getCurrentPages(); var page = pages[pages.length - 1]; - if(!header) { - headers["Content-Type"] = 'application/x-www-form-urlencode' - } - console.log("headers :",headers) return uni.request({ url: config.baseUrl + url, method, diff --git a/config/index.js b/config/index.js index 631383e..2972aff 100644 --- a/config/index.js +++ b/config/index.js @@ -1,6 +1,6 @@ // isdev 为 true 表示开发环境 false 表示发布环境 const isdev = true; -const baseUrl = isdev ? 'https://71e86bc1.r15.cpolar.top' : 'http://niunai.zhitou1688.com';// 办公室接口 & 测试环境 +const baseUrl = isdev ? 'http://2580c89.r18.cpolar.top/' : 'http://niunai.zhitou1688.com';// 办公室接口 & 测试环境 // const baseUrl = isdev ? 'http://192.168.1.133:8899' : 'https://api.gwkjxb.com';// 办公室接口 & 正式环境 // const baseUrl = 'https://api.gwkjxb.com';// 正式环境(由于本地测试后台没有启动,暂时通用正式服) diff --git a/manifest.json b/manifest.json index 7110b62..ec17600 100644 --- a/manifest.json +++ b/manifest.json @@ -52,7 +52,9 @@ "mp-weixin" : { "appid" : "wxaaf66dbb5c3983b3", "setting" : { - "urlCheck" : false + "urlCheck" : false + // "ignoreDevUnusedFiles": false , + // "ignoreUploadUnusedFiles": false” }, "usingComponents" : true }, diff --git a/pages.json b/pages.json index b1e3ed8..1624c66 100644 --- a/pages.json +++ b/pages.json @@ -17,12 +17,18 @@ "style": { "navigationBarTitleText": "我的" } + }, + { + "path": "pages/login/login", + "style": { + "navigationBarTitleText": "登录" + } } ], "globalStyle": { - "navigationBarTextStyle": "black", + "navigationBarTextStyle": "white", "navigationBarTitleText": "uni-app", - "navigationBarBackgroundColor": "#F8F8F8", + "navigationBarBackgroundColor": "#26758d", "backgroundColor": "#F8F8F8" }, "uniIdRouter": {}, diff --git a/pages/index/index.vue b/pages/index/index.vue index 02bb541..7cde14a 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -1,5 +1,7 @@ - \ No newline at end of file diff --git a/static/avatar.png b/static/avatar.png new file mode 100644 index 0000000..c552c1f Binary files /dev/null and b/static/avatar.png differ diff --git a/store/index.js b/store/index.js index 2a9a49e..1641875 100644 --- a/store/index.js +++ b/store/index.js @@ -61,7 +61,7 @@ export const useStore = defineStore('main2', { if(access_token) { this.access_token = access_token this.isLogin = true - this.getUserInfo() + // this.getUserInfo() } // else{ // if(!visitState) { diff --git a/uni_modules/uni-datetime-picker/changelog.md b/uni_modules/uni-datetime-picker/changelog.md new file mode 100644 index 0000000..1e82f46 --- /dev/null +++ b/uni_modules/uni-datetime-picker/changelog.md @@ -0,0 +1,140 @@ +## 2.2.24(2023-06-02) +- 修复 部分情况修改时间,开始、结束时间显示异常的Bug [详情](https://ask.dcloud.net.cn/question/171146) +- 优化 当前月可以选择上月、下月的日期 +## 2.2.23(2023-05-02) +- 修复 部分情况修改时间,开始时间未更新 [详情](https://github.com/dcloudio/uni-ui/issues/737) +- 修复 部分平台及设备第一次点击无法显示弹框 +- 修复 ios 日期格式未补零显示及使用异常 [详情](https://ask.dcloud.net.cn/question/162979) +## 2.2.22(2023-03-30) +- 修复 日历 picker 修改年月后,自动选中当月1日 [详情](https://ask.dcloud.net.cn/question/165937) +- 修复 小程序端 低版本 ios NaN [详情](https://ask.dcloud.net.cn/question/162979) +## 2.2.21(2023-02-20) +- 修复 firefox 浏览器显示区域点击无法拉起日历弹框的Bug [详情](https://ask.dcloud.net.cn/question/163362) +## 2.2.20(2023-02-17) +- 优化 值为空依然选中当天问题 +- 优化 提供 default-value 属性支持配置选择器打开时默认显示的时间 +- 优化 非范围选择未选择日期时间,点击确认按钮选中当前日期时间 +- 优化 字节小程序日期时间范围选择,底部日期换行问题 +## 2.2.19(2023-02-09) +- 修复 2.2.18 引起范围选择配置 end 选择无效的Bug [详情](https://github.com/dcloudio/uni-ui/issues/686) +## 2.2.18(2023-02-08) +- 修复 移动端范围选择change事件触发异常的Bug [详情](https://github.com/dcloudio/uni-ui/issues/684) +- 优化 PC端输入日期格式错误时返回当前日期时间 +- 优化 PC端输入日期时间超出 start、end 限制的Bug +- 优化 移动端日期时间范围用法时间展示不完整问题 +## 2.2.17(2023-02-04) +- 修复 小程序端绑定 Date 类型报错的Bug [详情](https://github.com/dcloudio/uni-ui/issues/679) +- 修复 vue3 time-picker 无法显示绑定时分秒的Bug +## 2.2.16(2023-02-02) +- 修复 字节小程序报错的Bug +## 2.2.15(2023-02-02) +- 修复 某些情况切换月份错误的Bug +## 2.2.14(2023-01-30) +- 修复 某些情况切换月份错误的Bug [详情](https://ask.dcloud.net.cn/question/162033) +## 2.2.13(2023-01-10) +- 修复 多次加载组件造成内存占用的Bug +## 2.2.12(2022-12-01) +- 修复 vue3 下 i18n 国际化初始值不正确的Bug +## 2.2.11(2022-09-19) +- 修复 支付宝小程序样式错乱的Bug [详情](https://github.com/dcloudio/uni-app/issues/3861) +## 2.2.10(2022-09-19) +- 修复 反向选择日期范围,日期显示异常的Bug [详情](https://ask.dcloud.net.cn/question/153401?item_id=212892&rf=false) +## 2.2.9(2022-09-16) +- 可以使用 uni-scss 控制主题色 +## 2.2.8(2022-09-08) +- 修复 close事件无效的Bug +## 2.2.7(2022-09-05) +- 修复 移动端 maskClick 无效的Bug [详情](https://ask.dcloud.net.cn/question/140824) +## 2.2.6(2022-06-30) +- 优化 组件样式,调整了组件图标大小、高度、颜色等,与uni-ui风格保持一致 +## 2.2.5(2022-06-24) +- 修复 日历顶部年月及底部确认未国际化的Bug +## 2.2.4(2022-03-31) +- 修复 Vue3 下动态赋值,单选类型未响应的Bug +## 2.2.3(2022-03-28) +- 修复 Vue3 下动态赋值未响应的Bug +## 2.2.2(2021-12-10) +- 修复 clear-icon 属性在小程序平台不生效的Bug +## 2.2.1(2021-12-10) +- 修复 日期范围选在小程序平台,必须多点击一次才能取消选中状态的Bug +## 2.2.0(2021-11-19) +- 优化 组件UI,并提供设计资源 [详情](https://uniapp.dcloud.io/component/uniui/resource) +- 文档迁移 [https://uniapp.dcloud.io/component/uniui/uni-datetime-picker](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker) +## 2.1.5(2021-11-09) +- 新增 提供组件设计资源,组件样式调整 +## 2.1.4(2021-09-10) +- 修复 hide-second 在移动端的Bug +- 修复 单选赋默认值时,赋值日期未高亮的Bug +- 修复 赋默认值时,移动端未正确显示时间的Bug +## 2.1.3(2021-09-09) +- 新增 hide-second 属性,支持只使用时分,隐藏秒 +## 2.1.2(2021-09-03) +- 优化 取消选中时(范围选)直接开始下一次选择, 避免多点一次 +- 优化 移动端支持清除按钮,同时支持通过 ref 调用组件的 clear 方法 +- 优化 调整字号大小,美化日历界面 +- 修复 因国际化导致的 placeholder 失效的Bug +## 2.1.1(2021-08-24) +- 新增 支持国际化 +- 优化 范围选择器在 pc 端过宽的问题 +## 2.1.0(2021-08-09) +- 新增 适配 vue3 +## 2.0.19(2021-08-09) +- 新增 支持作为 uni-forms 子组件相关功能 +- 修复 在 uni-forms 中使用时,选择时间报 NAN 错误的Bug +## 2.0.18(2021-08-05) +- 修复 type 属性动态赋值无效的Bug +- 修复 ‘确认’按钮被 tabbar 遮盖 bug +- 修复 组件未赋值时范围选左、右日历相同的Bug +## 2.0.17(2021-08-04) +- 修复 范围选未正确显示当前值的Bug +- 修复 h5 平台(移动端)报错 'cale' of undefined 的Bug +## 2.0.16(2021-07-21) +- 新增 return-type 属性支持返回 date 日期对象 +## 2.0.15(2021-07-14) +- 修复 单选日期类型,初始赋值后不在当前日历的Bug +- 新增 clearIcon 属性,显示框的清空按钮可配置显示隐藏(仅 pc 有效) +- 优化 移动端移除显示框的清空按钮,无实际用途 +## 2.0.14(2021-07-14) +- 修复 组件赋值为空,界面未更新的Bug +- 修复 start 和 end 不能动态赋值的Bug +- 修复 范围选类型,用户选择后再次选择右侧日历(结束日期)显示不正确的Bug +## 2.0.13(2021-07-08) +- 修复 范围选择不能动态赋值的Bug +## 2.0.12(2021-07-08) +- 修复 范围选择的初始时间在一个月内时,造成无法选择的bug +## 2.0.11(2021-07-08) +- 优化 弹出层在超出视窗边缘定位不准确的问题 +## 2.0.10(2021-07-08) +- 修复 范围起始点样式的背景色与今日样式的字体前景色融合,导致日期字体看不清的Bug +- 优化 弹出层在超出视窗边缘被遮盖的问题 +## 2.0.9(2021-07-07) +- 新增 maskClick 事件 +- 修复 特殊情况日历 rpx 布局错误的Bug,rpx -> px +- 修复 范围选择时清空返回值不合理的bug,['', ''] -> [] +## 2.0.8(2021-07-07) +- 新增 日期时间显示框支持插槽 +## 2.0.7(2021-07-01) +- 优化 添加 uni-icons 依赖 +## 2.0.6(2021-05-22) +- 修复 图标在小程序上不显示的Bug +- 优化 重命名引用组件,避免潜在组件命名冲突 +## 2.0.5(2021-05-20) +- 优化 代码目录扁平化 +## 2.0.4(2021-05-12) +- 新增 组件示例地址 +## 2.0.3(2021-05-10) +- 修复 ios 下不识别 '-' 日期格式的Bug +- 优化 pc 下弹出层添加边框和阴影 +## 2.0.2(2021-05-08) +- 修复 在 admin 中获取弹出层定位错误的bug +## 2.0.1(2021-05-08) +- 修复 type 属性向下兼容,默认值从 date 变更为 datetime +## 2.0.0(2021-04-30) +- 支持日历形式的日期+时间的范围选择 + > 注意:此版本不向后兼容,不再支持单独时间选择(type=time)及相关的 hide-second 属性(时间选可使用内置组件 picker) +## 1.0.6(2021-03-18) +- 新增 hide-second 属性,时间支持仅选择时、分 +- 修复 选择跟显示的日期不一样的Bug +- 修复 chang事件触发2次的Bug +- 修复 分、秒 end 范围错误的Bug +- 优化 更好的 nvue 适配 diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar-item.vue b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar-item.vue new file mode 100644 index 0000000..8f3c461 --- /dev/null +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar-item.vue @@ -0,0 +1,177 @@ + + + + + diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue new file mode 100644 index 0000000..ec8e472 --- /dev/null +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue @@ -0,0 +1,929 @@ + + + + + diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/en.json b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/en.json new file mode 100644 index 0000000..56cd0a6 --- /dev/null +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/en.json @@ -0,0 +1,22 @@ +{ + "uni-datetime-picker.selectDate": "select date", + "uni-datetime-picker.selectTime": "select time", + "uni-datetime-picker.selectDateTime": "select date and time", + "uni-datetime-picker.startDate": "start date", + "uni-datetime-picker.endDate": "end date", + "uni-datetime-picker.startTime": "start time", + "uni-datetime-picker.endTime": "end time", + "uni-datetime-picker.ok": "ok", + "uni-datetime-picker.clear": "clear", + "uni-datetime-picker.cancel": "cancel", + "uni-datetime-picker.year": "-", + "uni-datetime-picker.month": "", + "uni-calender.MON": "MON", + "uni-calender.TUE": "TUE", + "uni-calender.WED": "WED", + "uni-calender.THU": "THU", + "uni-calender.FRI": "FRI", + "uni-calender.SAT": "SAT", + "uni-calender.SUN": "SUN", + "uni-calender.confirm": "confirm" +} diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js new file mode 100644 index 0000000..fa8f0f3 --- /dev/null +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js @@ -0,0 +1,8 @@ +import en from './en.json' +import zhHans from './zh-Hans.json' +import zhHant from './zh-Hant.json' +export default { + en, + 'zh-Hans': zhHans, + 'zh-Hant': zhHant +} diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hans.json b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hans.json new file mode 100644 index 0000000..d2df5e7 --- /dev/null +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hans.json @@ -0,0 +1,22 @@ +{ + "uni-datetime-picker.selectDate": "选择日期", + "uni-datetime-picker.selectTime": "选择时间", + "uni-datetime-picker.selectDateTime": "选择日期时间", + "uni-datetime-picker.startDate": "开始日期", + "uni-datetime-picker.endDate": "结束日期", + "uni-datetime-picker.startTime": "开始时间", + "uni-datetime-picker.endTime": "结束时间", + "uni-datetime-picker.ok": "确定", + "uni-datetime-picker.clear": "清除", + "uni-datetime-picker.cancel": "取消", + "uni-datetime-picker.year": "年", + "uni-datetime-picker.month": "月", + "uni-calender.SUN": "日", + "uni-calender.MON": "一", + "uni-calender.TUE": "二", + "uni-calender.WED": "三", + "uni-calender.THU": "四", + "uni-calender.FRI": "五", + "uni-calender.SAT": "六", + "uni-calender.confirm": "确认" +} \ No newline at end of file diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hant.json b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hant.json new file mode 100644 index 0000000..d23fa3c --- /dev/null +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hant.json @@ -0,0 +1,22 @@ +{ + "uni-datetime-picker.selectDate": "選擇日期", + "uni-datetime-picker.selectTime": "選擇時間", + "uni-datetime-picker.selectDateTime": "選擇日期時間", + "uni-datetime-picker.startDate": "開始日期", + "uni-datetime-picker.endDate": "結束日期", + "uni-datetime-picker.startTime": "開始时间", + "uni-datetime-picker.endTime": "結束时间", + "uni-datetime-picker.ok": "確定", + "uni-datetime-picker.clear": "清除", + "uni-datetime-picker.cancel": "取消", + "uni-datetime-picker.year": "年", + "uni-datetime-picker.month": "月", + "uni-calender.SUN": "日", + "uni-calender.MON": "一", + "uni-calender.TUE": "二", + "uni-calender.WED": "三", + "uni-calender.THU": "四", + "uni-calender.FRI": "五", + "uni-calender.SAT": "六", + "uni-calender.confirm": "確認" +} \ No newline at end of file diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/time-picker.vue b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/time-picker.vue new file mode 100644 index 0000000..f03dff6 --- /dev/null +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/time-picker.vue @@ -0,0 +1,934 @@ + + + + + diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue new file mode 100644 index 0000000..7650d0f --- /dev/null +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue @@ -0,0 +1,1032 @@ + + + + diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js new file mode 100644 index 0000000..3ea5bb1 --- /dev/null +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js @@ -0,0 +1,453 @@ +class Calendar { + constructor({ + selected, + startDate, + endDate, + range, + } = {}) { + // 当前日期 + this.date = this.getDateObj(new Date()) // 当前初入日期 + // 打点信息 + this.selected = selected || []; + // 起始时间 + this.startDate = startDate + // 终止时间 + this.endDate = endDate + // 是否范围选择 + this.range = range + // 多选状态 + this.cleanMultipleStatus() + // 每周日期 + this.weeks = {} + this.lastHover = false + } + /** + * 设置日期 + * @param {Object} date + */ + setDate(date) { + const selectDate = this.getDateObj(date) + this.getWeeks(selectDate.fullDate) + } + + /** + * 清理多选状态 + */ + cleanMultipleStatus() { + this.multipleStatus = { + before: '', + after: '', + data: [] + } + } + + setStartDate(startDate) { + this.startDate = startDate + } + + setEndDate(endDate) { + this.endDate = endDate + } + + getPreMonthObj(date){ + date = fixIosDateFormat(date) + date = new Date(date) + + const oldMonth = date.getMonth() + date.setMonth(oldMonth - 1) + const newMonth = date.getMonth() + if(oldMonth !== 0 && newMonth - oldMonth === 0){ + date.setMonth(newMonth - 1) + } + return this.getDateObj(date) + } + getNextMonthObj(date){ + date = fixIosDateFormat(date) + date = new Date(date) + + const oldMonth = date.getMonth() + date.setMonth(oldMonth + 1) + const newMonth = date.getMonth() + if(newMonth - oldMonth > 1){ + date.setMonth(newMonth - 1) + } + return this.getDateObj(date) + } + + /** + * 获取指定格式Date对象 + */ + getDateObj(date) { + date = fixIosDateFormat(date) + date = new Date(date) + + return { + fullDate: getDate(date), + year: date.getFullYear(), + month: addZero(date.getMonth() + 1), + date: addZero(date.getDate()), + day: date.getDay() + } + } + + /** + * 获取上一个月日期集合 + */ + getPreMonthDays(amount, dateObj) { + const result = [] + for (let i = amount - 1; i >= 0; i--) { + const month = dateObj.month > 1 ? dateObj.month -1 : 12 + const year = month === 12 ? dateObj.year - 1 : dateObj.year + const date = new Date(year,month,-i).getDate() + const fullDate = `${year}-${addZero(month)}-${addZero(date)}` + let multiples = this.multipleStatus.data + let multiplesStatus = -1 + if (this.range && multiples) { + multiplesStatus = multiples.findIndex((item) => { + return this.dateEqual(item, fullDate) + }) + } + const checked = multiplesStatus !== -1 + // 获取打点信息 + const extraInfo = this.selected && this.selected.find((item) => { + if (this.dateEqual(fullDate, item.date)) { + return item + } + }) + result.push({ + fullDate, + year, + month, + date, + multiple: this.range ? checked : false, + beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after), + afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after), + disable: (this.startDate && !dateCompare(this.startDate, fullDate)) || (this.endDate && !dateCompare(fullDate,this.endDate)), + isToday: fullDate === this.date.fullDate, + userChecked: false, + extraInfo + }) + } + return result + } + /** + * 获取本月日期集合 + */ + getCurrentMonthDays(amount, dateObj) { + const result = [] + const fullDate = this.date.fullDate + for (let i = 1; i <= amount; i++) { + const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}` + const isToday = fullDate === currentDate + // 获取打点信息 + const extraInfo = this.selected && this.selected.find((item) => { + if (this.dateEqual(currentDate, item.date)) { + return item + } + }) + + // 日期禁用 + let disableBefore = true + let disableAfter = true + if (this.startDate) { + disableBefore = dateCompare(this.startDate, currentDate) + } + + if (this.endDate) { + disableAfter = dateCompare(currentDate, this.endDate) + } + + let multiples = this.multipleStatus.data + let multiplesStatus = -1 + if (this.range && multiples) { + multiplesStatus = multiples.findIndex((item) => { + return this.dateEqual(item, currentDate) + }) + } + const checked = multiplesStatus !== -1 + + result.push({ + fullDate: currentDate, + year: dateObj.year, + month: dateObj.month, + date: i, + multiple: this.range ? checked : false, + beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after), + afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after), + disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(currentDate,this.endDate)), + isToday, + userChecked: false, + extraInfo + }) + } + return result + } + /** + * 获取下一个月日期集合 + */ + _getNextMonthDays(amount, dateObj) { + const result = [] + const month = dateObj.month + 1 + for (let i = 1; i <= amount; i++) { + const month = dateObj.month === 12 ? 1 : dateObj.month*1 + 1 + const year = month === 1 ? dateObj.year + 1 : dateObj.year + const fullDate = `${year}-${addZero(month)}-${addZero(i)}` + let multiples = this.multipleStatus.data + let multiplesStatus = -1 + if (this.range && multiples) { + multiplesStatus = multiples.findIndex((item) => { + return this.dateEqual(item, fullDate) + }) + } + const checked = multiplesStatus !== -1 + // 获取打点信息 + const extraInfo = this.selected && this.selected.find((item) => { + if (this.dateEqual(fullDate, item.date)) { + return item + } + }) + result.push({ + fullDate, + year, + date: i, + month, + multiple: this.range ? checked : false, + beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after), + afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after), + disable: (this.startDate && !dateCompare(this.startDate, fullDate)) || (this.endDate && !dateCompare(fullDate,this.endDate)), + isToday: fullDate === this.date.fullDate, + userChecked: false, + extraInfo + }) + } + return result + } + + /** + * 获取当前日期详情 + * @param {Object} date + */ + getInfo(date) { + if (!date) { + date = new Date() + } + + return this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate) + } + + /** + * 比较时间是否相等 + */ + dateEqual(before, after) { + before = new Date(fixIosDateFormat(before)) + after = new Date(fixIosDateFormat(after)) + return before.valueOf() === after.valueOf() + } + + /** + * 比较真实起始日期 + */ + + isLogicBefore(currentDate, before, after) { + let logicBefore = before + if (before && after) { + logicBefore = dateCompare(before, after) ? before : after + } + return this.dateEqual(logicBefore, currentDate) + } + + isLogicAfter(currentDate, before, after) { + let logicAfter = after + if (before && after) { + logicAfter = dateCompare(before, after) ? after : before + } + return this.dateEqual(logicAfter, currentDate) + } + + /** + * 获取日期范围内所有日期 + * @param {Object} begin + * @param {Object} end + */ + geDateAll(begin, end) { + var arr = [] + var ab = begin.split('-') + var ae = end.split('-') + var db = new Date() + db.setFullYear(ab[0], ab[1] - 1, ab[2]) + var de = new Date() + de.setFullYear(ae[0], ae[1] - 1, ae[2]) + var unixDb = db.getTime() - 24 * 60 * 60 * 1000 + var unixDe = de.getTime() - 24 * 60 * 60 * 1000 + for (var k = unixDb; k <= unixDe;) { + k = k + 24 * 60 * 60 * 1000 + arr.push(this.getDateObj(new Date(parseInt(k))).fullDate) + } + return arr + } + + /** + * 获取多选状态 + */ + setMultiple(fullDate) { + if (!this.range) return + + let { + before, + after + } = this.multipleStatus + if (before && after) { + if (!this.lastHover) { + this.lastHover = true + return + } + this.multipleStatus.before = fullDate + this.multipleStatus.after = '' + this.multipleStatus.data = [] + this.multipleStatus.fulldate = '' + this.lastHover = false + } else { + if (!before) { + this.multipleStatus.before = fullDate + this.lastHover = false + } else { + this.multipleStatus.after = fullDate + if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { + this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus + .after); + } else { + this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus + .before); + } + this.lastHover = true + } + } + this.getWeeks(fullDate) + } + + /** + * 鼠标 hover 更新多选状态 + */ + setHoverMultiple(fullDate) { + if (!this.range || this.lastHover) return + + const { before } = this.multipleStatus + + if (!before) { + this.multipleStatus.before = fullDate + } else { + this.multipleStatus.after = fullDate + if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { + this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after); + } else { + this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before); + } + } + this.getWeeks(fullDate) + } + + /** + * 更新默认值多选状态 + */ + setDefaultMultiple(before, after) { + this.multipleStatus.before = before + this.multipleStatus.after = after + if (before && after) { + if (dateCompare(before, after)) { + this.multipleStatus.data = this.geDateAll(before, after); + this.getWeeks(after) + } else { + this.multipleStatus.data = this.geDateAll(after, before); + this.getWeeks(before) + } + } + } + + /** + * 获取每周数据 + * @param {Object} dateData + */ + getWeeks(dateData) { + const { + year, + month, + } = this.getDateObj(dateData) + + const preMonthDayAmount = new Date(year, month - 1, 1).getDay() + const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData)) + + const currentMonthDayAmount = new Date(year, month, 0).getDate() + const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData)) + + const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount + const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData)) + + const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays] + + const weeks = new Array(6) + for (let i = 0; i < calendarDays.length; i++) { + const index = Math.floor(i / 7) + if(!weeks[index]){ + weeks[index] = new Array(7) + } + weeks[index][i % 7] = calendarDays[i] + } + + this.calendar = calendarDays + this.weeks = weeks + } +} + +function getDateTime(date, hideSecond){ + return `${getDate(date)} ${getTime(date, hideSecond)}` +} + +function getDate(date) { + date = fixIosDateFormat(date) + date = new Date(date) + const year = date.getFullYear() + const month = date.getMonth()+1 + const day = date.getDate() + return `${year}-${addZero(month)}-${addZero(day)}` +} + +function getTime(date, hideSecond){ + date = fixIosDateFormat(date) + date = new Date(date) + const hour = date.getHours() + const minute = date.getMinutes() + const second = date.getSeconds() + return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}` +} + +function addZero(num) { + if(num < 10){ + num = `0${num}` + } + return num +} + +function getDefaultSecond(hideSecond) { + return hideSecond ? '00:00' : '00:00:00' +} + +function dateCompare(startDate, endDate) { + startDate = new Date(fixIosDateFormat(startDate)) + endDate = new Date(fixIosDateFormat(endDate)) + return startDate <= endDate +} + +function checkDate(date){ + const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g + return date.match(dateReg) +} + +const dateTimeReg = /^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])( [0-5]?[0-9]:[0-5]?[0-9]:[0-5]?[0-9])?$/ +function fixIosDateFormat(value) { + if (typeof value === 'string' && dateTimeReg.test(value)) { + value = value.replace(/-/g, '/') + } + return value +} + +export {Calendar, getDateTime, getDate, getTime, addZero, getDefaultSecond, dateCompare, checkDate, fixIosDateFormat} \ No newline at end of file diff --git a/uni_modules/uni-datetime-picker/package.json b/uni_modules/uni-datetime-picker/package.json new file mode 100644 index 0000000..cabb668 --- /dev/null +++ b/uni_modules/uni-datetime-picker/package.json @@ -0,0 +1,87 @@ +{ + "id": "uni-datetime-picker", + "displayName": "uni-datetime-picker 日期选择器", + "version": "2.2.24", + "description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择", + "keywords": [ + "uni-datetime-picker", + "uni-ui", + "uniui", + "日期时间选择器", + "日期时间" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, +"dcloudext": { + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", + "type": "component-vue" + }, + "uni_modules": { + "dependencies": [ + "uni-scss", + "uni-icons" + ], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "n" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" + }, + "H5-pc": { + "Chrome": "y", + "IE": "y", + "Edge": "y", + "Firefox": "y", + "Safari": "y" + }, + "小程序": { + "微信": "y", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y" + }, + "快应用": { + "华为": "u", + "联盟": "u" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } +} diff --git a/uni_modules/uni-datetime-picker/readme.md b/uni_modules/uni-datetime-picker/readme.md new file mode 100644 index 0000000..162fbef --- /dev/null +++ b/uni_modules/uni-datetime-picker/readme.md @@ -0,0 +1,21 @@ + + +> `重要通知:组件升级更新 2.0.0 后,支持日期+时间范围选择,组件 ui 将使用日历选择日期,ui 变化较大,同时支持 PC 和 移动端。此版本不向后兼容,不再支持单独的时间选择(type=time)及相关的 hide-second 属性(时间选可使用内置组件 picker)。若仍需使用旧版本,可在插件市场下载*非uni_modules版本*,旧版本将不再维护` + +## DatetimePicker 时间选择器 + +> **组件名:uni-datetime-picker** +> 代码块: `uDatetimePicker` + + +该组件的优势是,支持**时间戳**输入和输出(起始时间、终止时间也支持时间戳),可**同时选择**日期和时间。 + +若只是需要单独选择日期和时间,不需要时间戳输入和输出,可使用原生的 picker 组件。 + +**_点击 picker 默认值规则:_** + +- 若设置初始值 value, 会显示在 picker 显示框中 +- 若无初始值 value,则初始值 value 为当前本地时间 Date.now(), 但不会显示在 picker 显示框中 + +### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker) +#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 \ No newline at end of file diff --git a/uni_modules/uni-easyinput/changelog.md b/uni_modules/uni-easyinput/changelog.md new file mode 100644 index 0000000..765401a --- /dev/null +++ b/uni_modules/uni-easyinput/changelog.md @@ -0,0 +1,97 @@ +## 1.1.9(2023-04-11) +- 修复 vue3 下 keyboardheightchange 事件报错的bug +## 1.1.8(2023-03-29) +- 优化 trim 属性默认值 +## 1.1.7(2023-03-29) +- 新增 cursor-spacing 属性 +## 1.1.6(2023-01-28) +- 新增 keyboardheightchange 事件,可监听键盘高度变化 +## 1.1.5(2022-11-29) +- 优化 主题样式 +## 1.1.4(2022-10-27) +- 修复 props 中背景颜色无默认值的bug +## 1.1.0(2022-06-30) + +- 新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容 +- 新增 clear 事件,点击右侧叉号图标触发 +- 新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发 +- 优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等 + +## 1.0.5(2022-06-07) + +- 优化 clearable 显示策略 + +## 1.0.4(2022-06-07) + +- 优化 clearable 显示策略 + +## 1.0.3(2022-05-20) + +- 修复 关闭图标某些情况下无法取消的 bug + +## 1.0.2(2022-04-12) + +- 修复 默认值不生效的 bug + +## 1.0.1(2022-04-02) + +- 修复 value 不能为 0 的 bug + +## 1.0.0(2021-11-19) + +- 优化 组件 UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) +- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-easyinput](https://uniapp.dcloud.io/component/uniui/uni-easyinput) + +## 0.1.4(2021-08-20) + +- 修复 在 uni-forms 的动态表单中默认值校验不通过的 bug + +## 0.1.3(2021-08-11) + +- 修复 在 uni-forms 中重置表单,错误信息无法清除的问题 + +## 0.1.2(2021-07-30) + +- 优化 vue3 下事件警告的问题 + +## 0.1.1 + +- 优化 errorMessage 属性支持 Boolean 类型 + +## 0.1.0(2021-07-13) + +- 组件兼容 vue3,如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834) + +## 0.0.16(2021-06-29) + +- 修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug + +## 0.0.15(2021-06-21) + +- 修复 passwordIcon 属性拼写错误的 bug + +## 0.0.14(2021-06-18) + +- 新增 passwordIcon 属性,当 type=password 时是否显示小眼睛图标 +- 修复 confirmType 属性不生效的问题 + +## 0.0.13(2021-06-04) + +- 修复 disabled 状态可清出内容的 bug + +## 0.0.12(2021-05-12) + +- 新增 组件示例地址 + +## 0.0.11(2021-05-07) + +- 修复 input-border 属性不生效的问题 + +## 0.0.10(2021-04-30) + +- 修复 ios 遮挡文字、显示一半的问题 + +## 0.0.9(2021-02-05) + +- 调整为 uni_modules 目录规范 +- 优化 兼容 nvue 页面 diff --git a/uni_modules/uni-easyinput/components/uni-easyinput/common.js b/uni_modules/uni-easyinput/components/uni-easyinput/common.js new file mode 100644 index 0000000..5549cc9 --- /dev/null +++ b/uni_modules/uni-easyinput/components/uni-easyinput/common.js @@ -0,0 +1,56 @@ +/** + * @desc 函数防抖 + * @param func 目标函数 + * @param wait 延迟执行毫秒数 + * @param immediate true - 立即执行, false - 延迟执行 + */ +export const debounce = function(func, wait = 1000, immediate = true) { + let timer; + console.log(1); + return function() { + console.log(123); + let context = this, + args = arguments; + if (timer) clearTimeout(timer); + if (immediate) { + let callNow = !timer; + timer = setTimeout(() => { + timer = null; + }, wait); + if (callNow) func.apply(context, args); + } else { + timer = setTimeout(() => { + func.apply(context, args); + }, wait) + } + } +} +/** + * @desc 函数节流 + * @param func 函数 + * @param wait 延迟执行毫秒数 + * @param type 1 使用表时间戳,在时间段开始的时候触发 2 使用表定时器,在时间段结束的时候触发 + */ +export const throttle = (func, wait = 1000, type = 1) => { + let previous = 0; + let timeout; + return function() { + let context = this; + let args = arguments; + if (type === 1) { + let now = Date.now(); + + if (now - previous > wait) { + func.apply(context, args); + previous = now; + } + } else if (type === 2) { + if (!timeout) { + timeout = setTimeout(() => { + timeout = null; + func.apply(context, args) + }, wait) + } + } + } +} diff --git a/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue b/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue new file mode 100644 index 0000000..7f5113e --- /dev/null +++ b/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue @@ -0,0 +1,657 @@ + + + + + diff --git a/uni_modules/uni-easyinput/package.json b/uni_modules/uni-easyinput/package.json new file mode 100644 index 0000000..bd128e1 --- /dev/null +++ b/uni_modules/uni-easyinput/package.json @@ -0,0 +1,87 @@ +{ + "id": "uni-easyinput", + "displayName": "uni-easyinput 增强输入框", + "version": "1.1.9", + "description": "Easyinput 组件是对原生input组件的增强", + "keywords": [ + "uni-ui", + "uniui", + "input", + "uni-easyinput", + "输入框" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, +"dcloudext": { + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", + "type": "component-vue" + }, + "uni_modules": { + "dependencies": [ + "uni-scss", + "uni-icons" + ], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "y" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" + }, + "H5-pc": { + "Chrome": "y", + "IE": "y", + "Edge": "y", + "Firefox": "y", + "Safari": "y" + }, + "小程序": { + "微信": "y", + "阿里": "y", + "百度": "y", + "字节跳动": "y", + "QQ": "y" + }, + "快应用": { + "华为": "u", + "联盟": "u" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-easyinput/readme.md b/uni_modules/uni-easyinput/readme.md new file mode 100644 index 0000000..f1faf8f --- /dev/null +++ b/uni_modules/uni-easyinput/readme.md @@ -0,0 +1,11 @@ + + +### Easyinput 增强输入框 +> **组件名:uni-easyinput** +> 代码块: `uEasyinput` + + +easyinput 组件是对原生input组件的增强 ,是专门为配合表单组件[uni-forms](https://ext.dcloud.net.cn/plugin?id=2773)而设计的,easyinput 内置了边框,图标等,同时包含 input 所有功能 + +### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-easyinput) +#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/api/index.js b/unpackage/dist/dev/mp-weixin/api/index.js index 4f304a3..8491bb6 100644 --- a/unpackage/dist/dev/mp-weixin/api/index.js +++ b/unpackage/dist/dev/mp-weixin/api/index.js @@ -7,6 +7,12 @@ const API = { // 获取token wx_login: (data, userId) => api_request.net.POST("/user/binding/wechat", data, true, { "userId": userId }), // 微信登录 + // upload: (data) => net.POST('/user/upload',data), // 文件上传 + userinfoUpdae: (data) => api_request.net.PUT("/user/info", data), + // 更新用户信息 + // 首页 + getHospitalList: (data) => api_request.net.GET("/hospital/list", data), + // 获取医院信息 /* 首页信息 */ diff --git a/unpackage/dist/dev/mp-weixin/api/request.js b/unpackage/dist/dev/mp-weixin/api/request.js index 0e6ce17..bff5e5e 100644 --- a/unpackage/dist/dev/mp-weixin/api/request.js +++ b/unpackage/dist/dev/mp-weixin/api/request.js @@ -4,10 +4,10 @@ const config_index = require("../config/index.js"); const loginUrl = "pages/user/login"; const net = { REQUEST(url, method = "GET", data, checkLogin = true, header) { - let token = common_vendor.index.getStorageSync("access_token") || "Basic ZGV20mRldjEyMw=="; + let token = common_vendor.index.getStorageSync("access_token") || "Basic ZGV2OmRldjEyMw=="; const headers = { - "Content-Type": "application/json", - // "Content-Type": "application/x-www-form-urlencoded", + // "Content-Type": "application/json", + "Content-Type": "application/x-www-form-urlencoded", "Authorization": token, "x-token": token, "token": token @@ -16,10 +16,6 @@ const net = { }; var pages = getCurrentPages(); var page = pages[pages.length - 1]; - if (!header) { - headers["Content-Type"] = "application/x-www-form-urlencode"; - } - console.log("headers :", headers); return common_vendor.index.request({ url: config_index.config.baseUrl + url, method, diff --git a/unpackage/dist/dev/mp-weixin/app.js b/unpackage/dist/dev/mp-weixin/app.js index 26f2973..9901132 100644 --- a/unpackage/dist/dev/mp-weixin/app.js +++ b/unpackage/dist/dev/mp-weixin/app.js @@ -5,6 +5,7 @@ if (!Math) { "./pages/index/index.js"; "./pages/wikipedia/index.js"; "./pages/user/index.js"; + "./pages/login/login.js"; } const _sfc_main = { onLaunch: function() { diff --git a/unpackage/dist/dev/mp-weixin/app.json b/unpackage/dist/dev/mp-weixin/app.json index 8f785f9..55033ec 100644 --- a/unpackage/dist/dev/mp-weixin/app.json +++ b/unpackage/dist/dev/mp-weixin/app.json @@ -2,12 +2,13 @@ "pages": [ "pages/index/index", "pages/wikipedia/index", - "pages/user/index" + "pages/user/index", + "pages/login/login" ], "window": { - "navigationBarTextStyle": "black", + "navigationBarTextStyle": "white", "navigationBarTitleText": "uni-app", - "navigationBarBackgroundColor": "#F8F8F8", + "navigationBarBackgroundColor": "#26758d", "backgroundColor": "#F8F8F8" }, "tabBar": { diff --git a/unpackage/dist/dev/mp-weixin/common/vendor.js b/unpackage/dist/dev/mp-weixin/common/vendor.js index 8fb5b39..b71fcf8 100644 --- a/unpackage/dist/dev/mp-weixin/common/vendor.js +++ b/unpackage/dist/dev/mp-weixin/common/vendor.js @@ -29,7 +29,7 @@ function normalizeStyle(value) { return res; } else if (isString(value)) { return value; - } else if (isObject(value)) { + } else if (isObject$1(value)) { return value; } } @@ -57,7 +57,7 @@ function normalizeClass(value) { res += normalized + " "; } } - } else if (isObject(value)) { + } else if (isObject$1(value)) { for (const name in value) { if (value[name]) { res += name + " "; @@ -66,6 +66,28 @@ function normalizeClass(value) { } return res.trim(); } +const toDisplayString = (val) => { + return isString(val) ? val : val == null ? "" : isArray(val) || isObject$1(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val); +}; +const replacer = (_key, val) => { + if (val && val.__v_isRef) { + return replacer(_key, val.value); + } else if (isMap(val)) { + return { + [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val2]) => { + entries[`${key} =>`] = val2; + return entries; + }, {}) + }; + } else if (isSet(val)) { + return { + [`Set(${val.size})`]: [...val.values()] + }; + } else if (isObject$1(val) && !isArray(val) && !isPlainObject$1(val)) { + return String(val); + } + return val; +}; const EMPTY_OBJ = Object.freeze({}); const EMPTY_ARR = Object.freeze([]); const NOOP = () => { @@ -81,17 +103,17 @@ const remove = (arr, el) => { arr.splice(i, 1); } }; -const hasOwnProperty$1 = Object.prototype.hasOwnProperty; -const hasOwn = (val, key) => hasOwnProperty$1.call(val, key); +const hasOwnProperty$2 = Object.prototype.hasOwnProperty; +const hasOwn$1 = (val, key) => hasOwnProperty$2.call(val, key); const isArray = Array.isArray; const isMap = (val) => toTypeString(val) === "[object Map]"; const isSet = (val) => toTypeString(val) === "[object Set]"; const isFunction = (val) => typeof val === "function"; const isString = (val) => typeof val === "string"; const isSymbol = (val) => typeof val === "symbol"; -const isObject = (val) => val !== null && typeof val === "object"; +const isObject$1 = (val) => val !== null && typeof val === "object"; const isPromise = (val) => { - return isObject(val) && isFunction(val.then) && isFunction(val.catch); + return isObject$1(val) && isFunction(val.then) && isFunction(val.catch); }; const objectToString = Object.prototype.toString; const toTypeString = (value) => objectToString.call(value); @@ -362,11 +384,96 @@ E.prototype = { } }; var E$1 = E; +const isObject = (val) => val !== null && typeof val === "object"; +const defaultDelimiters = ["{", "}"]; +class BaseFormatter { + constructor() { + this._caches = /* @__PURE__ */ Object.create(null); + } + interpolate(message, values, delimiters = defaultDelimiters) { + if (!values) { + return [message]; + } + let tokens = this._caches[message]; + if (!tokens) { + tokens = parse(message, delimiters); + this._caches[message] = tokens; + } + return compile$1(tokens, values); + } +} +const RE_TOKEN_LIST_VALUE = /^(?:\d)+/; +const RE_TOKEN_NAMED_VALUE = /^(?:\w)+/; +function parse(format, [startDelimiter, endDelimiter]) { + const tokens = []; + let position = 0; + let text = ""; + while (position < format.length) { + let char = format[position++]; + if (char === startDelimiter) { + if (text) { + tokens.push({ type: "text", value: text }); + } + text = ""; + let sub = ""; + char = format[position++]; + while (char !== void 0 && char !== endDelimiter) { + sub += char; + char = format[position++]; + } + const isClosed = char === endDelimiter; + const type = RE_TOKEN_LIST_VALUE.test(sub) ? "list" : isClosed && RE_TOKEN_NAMED_VALUE.test(sub) ? "named" : "unknown"; + tokens.push({ value: sub, type }); + } else { + text += char; + } + } + text && tokens.push({ type: "text", value: text }); + return tokens; +} +function compile$1(tokens, values) { + const compiled = []; + let index2 = 0; + const mode = Array.isArray(values) ? "list" : isObject(values) ? "named" : "unknown"; + if (mode === "unknown") { + return compiled; + } + while (index2 < tokens.length) { + const token = tokens[index2]; + switch (token.type) { + case "text": + compiled.push(token.value); + break; + case "list": + compiled.push(values[parseInt(token.value, 10)]); + break; + case "named": + if (mode === "named") { + compiled.push(values[token.value]); + } else { + { + console.warn(`Type of token '${token.type}' and format of value '${mode}' don't match!`); + } + } + break; + case "unknown": + { + console.warn(`Detect 'unknown' type of token!`); + } + break; + } + index2++; + } + return compiled; +} const LOCALE_ZH_HANS = "zh-Hans"; const LOCALE_ZH_HANT = "zh-Hant"; const LOCALE_EN = "en"; const LOCALE_FR = "fr"; const LOCALE_ES = "es"; +const hasOwnProperty$1 = Object.prototype.hasOwnProperty; +const hasOwn = (val, key) => hasOwnProperty$1.call(val, key); +const defaultFormatter = new BaseFormatter(); function include(str, parts) { return !!parts.find((part) => str.indexOf(part) !== -1); } @@ -406,6 +513,161 @@ function normalizeLocale(locale, messages) { return lang; } } +class I18n { + constructor({ locale, fallbackLocale, messages, watcher, formater }) { + this.locale = LOCALE_EN; + this.fallbackLocale = LOCALE_EN; + this.message = {}; + this.messages = {}; + this.watchers = []; + if (fallbackLocale) { + this.fallbackLocale = fallbackLocale; + } + this.formater = formater || defaultFormatter; + this.messages = messages || {}; + this.setLocale(locale || LOCALE_EN); + if (watcher) { + this.watchLocale(watcher); + } + } + setLocale(locale) { + const oldLocale = this.locale; + this.locale = normalizeLocale(locale, this.messages) || this.fallbackLocale; + if (!this.messages[this.locale]) { + this.messages[this.locale] = {}; + } + this.message = this.messages[this.locale]; + if (oldLocale !== this.locale) { + this.watchers.forEach((watcher) => { + watcher(this.locale, oldLocale); + }); + } + } + getLocale() { + return this.locale; + } + watchLocale(fn) { + const index2 = this.watchers.push(fn) - 1; + return () => { + this.watchers.splice(index2, 1); + }; + } + add(locale, message, override = true) { + const curMessages = this.messages[locale]; + if (curMessages) { + if (override) { + Object.assign(curMessages, message); + } else { + Object.keys(message).forEach((key) => { + if (!hasOwn(curMessages, key)) { + curMessages[key] = message[key]; + } + }); + } + } else { + this.messages[locale] = message; + } + } + f(message, values, delimiters) { + return this.formater.interpolate(message, values, delimiters).join(""); + } + t(key, locale, values) { + let message = this.message; + if (typeof locale === "string") { + locale = normalizeLocale(locale, this.messages); + locale && (message = this.messages[locale]); + } else { + values = locale; + } + if (!hasOwn(message, key)) { + console.warn(`Cannot translate the value of keypath ${key}. Use the value of keypath as default.`); + return key; + } + return this.formater.interpolate(message[key], values).join(""); + } +} +function watchAppLocale(appVm, i18n) { + if (appVm.$watchLocale) { + appVm.$watchLocale((newLocale) => { + i18n.setLocale(newLocale); + }); + } else { + appVm.$watch(() => appVm.$locale, (newLocale) => { + i18n.setLocale(newLocale); + }); + } +} +function getDefaultLocale() { + if (typeof index !== "undefined" && index.getLocale) { + return index.getLocale(); + } + if (typeof global !== "undefined" && global.getLocale) { + return global.getLocale(); + } + return LOCALE_EN; +} +function initVueI18n(locale, messages = {}, fallbackLocale, watcher) { + if (typeof locale !== "string") { + [locale, messages] = [ + messages, + locale + ]; + } + if (typeof locale !== "string") { + locale = getDefaultLocale(); + } + if (typeof fallbackLocale !== "string") { + fallbackLocale = typeof __uniConfig !== "undefined" && __uniConfig.fallbackLocale || LOCALE_EN; + } + const i18n = new I18n({ + locale, + fallbackLocale, + messages, + watcher + }); + let t2 = (key, values) => { + if (typeof getApp !== "function") { + t2 = function(key2, values2) { + return i18n.t(key2, values2); + }; + } else { + let isWatchedAppLocale = false; + t2 = function(key2, values2) { + const appVm = getApp().$vm; + if (appVm) { + appVm.$locale; + if (!isWatchedAppLocale) { + isWatchedAppLocale = true; + watchAppLocale(appVm, i18n); + } + } + return i18n.t(key2, values2); + }; + } + return t2(key, values); + }; + return { + i18n, + f(message, values, delimiters) { + return i18n.f(message, values, delimiters); + }, + t(key, values) { + return t2(key, values); + }, + add(locale2, message, override = true) { + return i18n.add(locale2, message, override); + }, + watch(fn) { + return i18n.watchLocale(fn); + }, + getLocale() { + return i18n.getLocale(); + }, + setLocale(newLocale) { + return i18n.setLocale(newLocale); + } + }; +} function getBaseSystemInfo() { return wx.getSystemInfoSync(); } @@ -417,7 +679,7 @@ function validateProtocol(name, data, protocol, onFail) { onFail = validateProtocolFail; } for (const key in protocol) { - const errMsg = validateProp$1(key, data[key], protocol[key], !hasOwn(data, key)); + const errMsg = validateProp$1(key, data[key], protocol[key], !hasOwn$1(data, key)); if (isString(errMsg)) { onFail(name, errMsg); } @@ -474,13 +736,13 @@ function assertType$1(value, type) { let valid; const expectedType = getType$1(type); if (isSimpleType$1(expectedType)) { - const t = typeof value; - valid = t === expectedType.toLowerCase(); - if (!valid && t === "object") { + const t2 = typeof value; + valid = t2 === expectedType.toLowerCase(); + if (!valid && t2 === "object") { valid = value instanceof type; } } else if (expectedType === "Object") { - valid = isObject(value); + valid = isObject$1(value); } else if (expectedType === "Array") { valid = isArray(value); } else { @@ -736,7 +998,7 @@ function formatApiArgs(args, options) { return errMsg; } } else { - if (!hasOwn(params, name)) { + if (!hasOwn$1(params, name)) { params[name] = formatterOrDefaultValue; } } @@ -1104,7 +1366,7 @@ function initWrapper(protocols2) { argsOption = argsOption(fromArgs, toArgs) || {}; } for (const key in fromArgs) { - if (hasOwn(argsOption, key)) { + if (hasOwn$1(argsOption, key)) { let keyOption = argsOption[key]; if (isFunction(keyOption)) { keyOption = keyOption(fromArgs[key], fromArgs, toArgs); @@ -1122,7 +1384,7 @@ function initWrapper(protocols2) { toArgs[key] = processCallback(methodName, callback, returnValue); } } else { - if (!keepFromArgs && !hasOwn(toArgs, key)) { + if (!keepFromArgs && !hasOwn$1(toArgs, key)) { toArgs[key] = fromArgs[key]; } } @@ -1140,7 +1402,7 @@ function initWrapper(protocols2) { return processArgs(methodName, res, returnValue, {}, keepReturnValue); } return function wrapper(methodName, method) { - if (!hasOwn(protocols2, methodName)) { + if (!hasOwn$1(protocols2, methodName)) { return method; } const protocol = protocols2[methodName]; @@ -1434,13 +1696,13 @@ function initUni(api, protocols2, platform = wx) { const wrapper = initWrapper(protocols2); const UniProxyHandlers = { get(target, key) { - if (hasOwn(target, key)) { + if (hasOwn$1(target, key)) { return target[key]; } - if (hasOwn(api, key)) { + if (hasOwn$1(api, key)) { return promisify(key, api[key]); } - if (hasOwn(baseApis, key)) { + if (hasOwn$1(baseApis, key)) { return promisify(key, baseApis[key]); } return promisify(key, wrapper(key, platform[key])); @@ -1941,7 +2203,7 @@ function createGetter(isReadonly2 = false, shallow = false) { } const targetIsArray = isArray(target); if (!isReadonly2) { - if (targetIsArray && hasOwn(arrayInstrumentations, key)) { + if (targetIsArray && hasOwn$1(arrayInstrumentations, key)) { return Reflect.get(arrayInstrumentations, key, receiver); } if (key === "hasOwnProperty") { @@ -1961,7 +2223,7 @@ function createGetter(isReadonly2 = false, shallow = false) { if (isRef(res)) { return targetIsArray && isIntegerKey(key) ? res : res.value; } - if (isObject(res)) { + if (isObject$1(res)) { return isReadonly2 ? readonly(res) : reactive(res); } return res; @@ -1985,7 +2247,7 @@ function createSetter(shallow = false) { return true; } } - const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key); + const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn$1(target, key); const result = Reflect.set(target, key, value, receiver); if (target === toRaw(receiver)) { if (!hadKey) { @@ -1998,7 +2260,7 @@ function createSetter(shallow = false) { }; } function deleteProperty(target, key) { - const hadKey = hasOwn(target, key); + const hadKey = hasOwn$1(target, key); const oldValue = target[key]; const result = Reflect.deleteProperty(target, key); if (result && hadKey) { @@ -2315,7 +2577,7 @@ function createInstrumentationGetter(isReadonly2, shallow) { } else if (key === "__v_raw") { return target; } - return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); + return Reflect.get(hasOwn$1(instrumentations, key) && key in target ? instrumentations : target, key, receiver); }; } const mutableCollectionHandlers = { @@ -2377,7 +2639,7 @@ function shallowReadonly(target) { return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap); } function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) { - if (!isObject(target)) { + if (!isObject$1(target)) { { console.warn(`value cannot be made reactive: ${String(target)}`); } @@ -2442,8 +2704,8 @@ function markRaw(value) { def(value, "__v_skip", true); return value; } -const toReactive = (value) => isObject(value) ? reactive(value) : value; -const toReadonly = (value) => isObject(value) ? readonly(value) : value; +const toReactive = (value) => isObject$1(value) ? reactive(value) : value; +const toReadonly = (value) => isObject$1(value) ? readonly(value) : value; function trackRefValue(ref2) { if (shouldTrack && activeEffect) { ref2 = toRaw(ref2); @@ -3235,7 +3497,7 @@ function normalizeEmitsOptions(comp, appContext, asMixin = false) { } } if (!raw && !hasExtends) { - if (isObject(comp)) { + if (isObject$1(comp)) { cache.set(comp, null); } return null; @@ -3245,7 +3507,7 @@ function normalizeEmitsOptions(comp, appContext, asMixin = false) { } else { extend(normalized, raw); } - if (isObject(comp)) { + if (isObject$1(comp)) { cache.set(comp, normalized); } return normalized; @@ -3255,7 +3517,7 @@ function isEmitListener(options, key) { return false; } key = key.slice(2).replace(/Once$/, ""); - return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key); + return hasOwn$1(options, key[0].toLowerCase() + key.slice(1)) || hasOwn$1(options, hyphenate(key)) || hasOwn$1(options, key); } let currentRenderingInstance = null; function setCurrentRenderingInstance(instance) { @@ -3472,7 +3734,7 @@ function createPathGetter(ctx, path) { }; } function traverse(value, seen) { - if (!isObject(value) || value[ + if (!isObject$1(value) || value[ "__v_skip" /* ReactiveFlags.SKIP */ ]) { @@ -3687,7 +3949,7 @@ const publicPropertiesMap = ( }) ); const isReservedPrefix = (key) => key === "_" || key === "$"; -const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key); +const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn$1(state, key); const PublicInstanceProxyHandlers = { get({ _: instance }, key) { const { ctx, setupState, data, props, accessCache, type, appContext } = instance; @@ -3711,17 +3973,17 @@ const PublicInstanceProxyHandlers = { } else if (hasSetupBinding(setupState, key)) { accessCache[key] = 1; return setupState[key]; - } else if (data !== EMPTY_OBJ && hasOwn(data, key)) { + } else if (data !== EMPTY_OBJ && hasOwn$1(data, key)) { accessCache[key] = 2; return data[key]; } else if ( // only cache other properties when instance has declared (thus stable) // props - (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key) + (normalizedProps = instance.propsOptions[0]) && hasOwn$1(normalizedProps, key) ) { accessCache[key] = 3; return props[key]; - } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { + } else if (ctx !== EMPTY_OBJ && hasOwn$1(ctx, key)) { accessCache[key] = 4; return ctx[key]; } else if (shouldCacheAccess) { @@ -3740,12 +4002,12 @@ const PublicInstanceProxyHandlers = { (cssModule = type.__cssModules) && (cssModule = cssModule[key]) ) { return cssModule; - } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { + } else if (ctx !== EMPTY_OBJ && hasOwn$1(ctx, key)) { accessCache[key] = 4; return ctx[key]; } else if ( // global properties - globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key) + globalProperties = appContext.config.globalProperties, hasOwn$1(globalProperties, key) ) { { return globalProperties[key]; @@ -3753,7 +4015,7 @@ const PublicInstanceProxyHandlers = { } else if (currentRenderingInstance && (!isString(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading // to infinite warning loop key.indexOf("__v") !== 0)) { - if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) { + if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn$1(data, key)) { warn(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`); } else if (instance === currentRenderingInstance) { warn(`Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`); @@ -3765,13 +4027,13 @@ const PublicInstanceProxyHandlers = { if (hasSetupBinding(setupState, key)) { setupState[key] = value; return true; - } else if (setupState.__isScriptSetup && hasOwn(setupState, key)) { + } else if (setupState.__isScriptSetup && hasOwn$1(setupState, key)) { warn(`Cannot mutate