From cea40871e3449987300925bb8fd021b92460277a Mon Sep 17 00:00:00 2001 From: chengkun <2500338766@qq.com> Date: Thu, 7 Jul 2022 18:28:12 +0800 Subject: [PATCH] =?UTF-8?q?feature-hub-1.0:=E5=88=9D=E6=AD=A5=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 - api/index.js | 27 +- pages.json | 51 +- pages/index/index.vue | 325 +++--- pages/profit/profit.vue | 107 +- pages/userInfo/userInfo.vue | 316 +++-- .../components/uni-badge/uni-badge.vue | 2 +- uni_modules/uni-badge/package.json | 2 +- uni_modules/uni-breadcrumb/changelog.md | 6 - .../uni-breadcrumb-item.vue | 121 -- .../uni-breadcrumb/uni-breadcrumb.vue | 41 - uni_modules/uni-breadcrumb/package.json | 88 -- uni_modules/uni-breadcrumb/readme.md | 66 -- .../uni-calendar/uni-calendar-item.vue | 7 - .../components/uni-calendar/uni-calendar.vue | 8 - .../components/uni-calendar/util.js | 6 +- .../components/uni-combox/uni-combox.vue | 2 +- uni_modules/uni-data-checkbox/changelog.md | 2 + .../uni-data-checkbox/uni-data-checkbox.vue | 48 +- uni_modules/uni-data-checkbox/package.json | 2 +- uni_modules/uni-data-picker/changelog.md | 6 + .../uni-data-picker/uni-data-picker.vue | 29 +- uni_modules/uni-data-picker/package.json | 5 +- uni_modules/uni-data-select/changelog.md | 10 - .../uni-data-select/uni-data-select.vue | 402 ------- uni_modules/uni-data-select/package.json | 88 -- uni_modules/uni-data-select/readme.md | 8 - uni_modules/uni-datetime-picker/changelog.md | 2 + .../uni-datetime-picker.vue | 89 +- uni_modules/uni-datetime-picker/package.json | 2 +- .../components/uni-drawer/uni-drawer.vue | 2 +- uni_modules/uni-easyinput/changelog.md | 6 + .../uni-easyinput/uni-easyinput.vue | 322 ++++-- uni_modules/uni-easyinput/package.json | 2 +- uni_modules/uni-file-picker/changelog.md | 2 + .../uni-file-picker/uni-file-picker.vue | 5 + uni_modules/uni-file-picker/package.json | 2 +- uni_modules/uni-forms/changelog.md | 22 + .../uni-forms-item/uni-forms-item.vue | 1023 +++++++++-------- .../components/uni-forms/uni-forms.vue | 470 ++++---- .../uni-forms/components/uni-forms/utils.js | 293 +++++ uni_modules/uni-forms/package.json | 2 +- .../uni-grid-item/uni-grid-item.vue | 2 +- .../uni-grid/components/uni-grid/uni-grid.vue | 2 +- .../uni-indexed-list-item.vue | 2 +- .../uni-indexed-list/uni-indexed-list.vue | 4 +- uni_modules/uni-nav-bar/changelog.md | 2 + uni_modules/uni-nav-bar/package.json | 2 +- .../uni-notice-bar/uni-notice-bar.vue | 2 +- .../uni-number-box/uni-number-box.vue | 7 +- uni_modules/uni-pagination/changelog.md | 2 + .../components/uni-pagination/i18n/en.json | 3 +- .../components/uni-pagination/i18n/es.json | 3 +- .../components/uni-pagination/i18n/fr.json | 3 +- .../uni-pagination/i18n/zh-Hans.json | 3 +- .../uni-pagination/i18n/zh-Hant.json | 3 +- .../uni-pagination/uni-pagination.vue | 62 +- uni_modules/uni-pagination/package.json | 2 +- uni_modules/uni-pagination/readme.md | 2 - .../uni-row/components/uni-col/uni-col.vue | 2 +- .../uni-row/components/uni-row/uni-row.vue | 2 +- .../uni-segmented-control.vue | 2 +- .../uni-swiper-dot/uni-swiper-dot.vue | 2 +- .../uni-tag/components/uni-tag/uni-tag.vue | 2 +- uni_modules/uni-test/changelog.md | 39 - .../uni-test/components/uni-test/uni-test.vue | 26 - uni_modules/uni-test/package.json | 83 -- uni_modules/uni-test/readme.md | 10 - uni_modules/uni-tooltip/changelog.md | 10 - .../components/uni-tooltip/uni-tooltip.vue | 68 -- uni_modules/uni-tooltip/package.json | 88 -- uni_modules/uni-tooltip/readme.md | 8 - uni_modules/uni-ui/changelog.md | 36 + uni_modules/uni-ui/package.json | 6 +- 74 files changed, 1958 insertions(+), 2559 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 uni_modules/uni-breadcrumb/changelog.md delete mode 100644 uni_modules/uni-breadcrumb/components/uni-breadcrumb-item/uni-breadcrumb-item.vue delete mode 100644 uni_modules/uni-breadcrumb/components/uni-breadcrumb/uni-breadcrumb.vue delete mode 100644 uni_modules/uni-breadcrumb/package.json delete mode 100644 uni_modules/uni-breadcrumb/readme.md delete mode 100644 uni_modules/uni-data-select/changelog.md delete mode 100644 uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue delete mode 100644 uni_modules/uni-data-select/package.json delete mode 100644 uni_modules/uni-data-select/readme.md create mode 100644 uni_modules/uni-forms/components/uni-forms/utils.js delete mode 100644 uni_modules/uni-test/changelog.md delete mode 100644 uni_modules/uni-test/components/uni-test/uni-test.vue delete mode 100644 uni_modules/uni-test/package.json delete mode 100644 uni_modules/uni-test/readme.md delete mode 100644 uni_modules/uni-tooltip/changelog.md delete mode 100644 uni_modules/uni-tooltip/components/uni-tooltip/uni-tooltip.vue delete mode 100644 uni_modules/uni-tooltip/package.json delete mode 100644 uni_modules/uni-tooltip/readme.md diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 8a89b0d..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/../../../../:\workspace\bnyer-cloud-hub\.idea/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/api/index.js b/api/index.js index b831d0c..7f27db2 100644 --- a/api/index.js +++ b/api/index.js @@ -30,15 +30,6 @@ export function listType() { }) } -// 小程序艺术家登录 -export function login(data) { - return request({ - url: `${serviceTitle}${prefix}/login`, - method: 'post', - data - }) -} - // 新增艺术家图片 export function insertTiktokImg(data) { return request({ @@ -46,7 +37,7 @@ export function insertTiktokImg(data) { method: 'post', data }) -} +} // 修改艺术家图片 export function updateTiktokImg(data) { @@ -74,3 +65,19 @@ export function listTiktokImgIn(data) { }) } +// 查询公告详情 +export function getNoticeDetails(id) { + return request({ + url: `${serviceTitle}${prefix}/listType/${id}`, + method: 'get' + }) +} + +// 查询公告列表 +export function getNoticeList() { + return request({ + url: `${serviceTitle}${prefix}/getNoticeList`, + method: 'get' + }) +} + diff --git a/pages.json b/pages.json index 93d9ebd..0cad8e7 100644 --- a/pages.json +++ b/pages.json @@ -4,7 +4,7 @@ "path": "pages/index/index", "style": { "navigationBarTitleText": "首页", - "enablePullDownRefresh": true + "enablePullDownRefresh": false } }, { @@ -20,8 +20,49 @@ "navigationBarTitleText": "我的", "enablePullDownRefresh": false } - } - ], + },{ + "path": "pages/userInfo/about/about", + "style": { + "navigationBarTitleText": "关于", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/userInfo/contact/contact", + "style": { + "navigationBarTitleText": "联系我们", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/userInfo/extends/extends", + "style": { + "navigationBarTitleText": "邀请更多", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/userInfo/inviteLog/inviteLog", + "style": { + "navigationBarTitleText": "邀请记录", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/userInfo/notice/notice", + "style": { + "navigationBarTitleText": "系统公告", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/userInfo/withdraw/withdraw", + "style": { + "navigationBarTitleText": "提现记录", + "enablePullDownRefresh": false + } + } + ], "globalStyle": { "navigationBarTextStyle": "black", "navigationBarTitleText": "bnyer", @@ -41,13 +82,13 @@ "text": "首页" }, { - "pagePath": "pages/profit/index", + "pagePath": "pages/profit/profit", "iconPath": "static/theme-default.png", "selectedIconPath": "static/theme-select.png", "text": "收益" }, { - "pagePath": "pages/userInfo/index", + "pagePath": "pages/userInfo/userInfo", "iconPath": "static/mine-default.png", "selectedIconPath": "static/mine-select.png", "text": "我的" diff --git a/pages/index/index.vue b/pages/index/index.vue index 8c03e21..1d2c04c 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -1,79 +1,54 @@ - diff --git a/pages/profit/profit.vue b/pages/profit/profit.vue index 8c03e21..20db052 100644 --- a/pages/profit/profit.vue +++ b/pages/profit/profit.vue @@ -1,27 +1,14 @@ @@ -39,90 +26,14 @@ }, // 下拉刷新 onPullDownRefresh() { - this.showChoiceness = false uni.stopPullDownRefresh() }, created() { - const userInfo = uni.getStorageSync('userInfo') - if (!userInfo) { - console.log('havent userInfo') - this.getUserInfo() - } else { - console.log('have userInfo') - } - }, - onPageScroll(e) { - // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件 - - if (e.scrollTop > 160) { - this.showChoiceness = true - // uni.redirectTo({ - // url: '../index/choiceness' - // }) - } + }, methods: { - // 搜索 - search(res) { - if (res.value) { - console.log('search', res.value) - this.goCreatorDetail(res.value) - } else { - uni.showToast({ - title: '请输入艺术家代号', - icon: 'none' - }) - } - - }, - // 获取用户信息 - getUserInfo() { - wx.login({ - force: true, - success: res => { - wx.getUserInfo({ - withCredentials: true, - success: userInfo => { - const params = { - code: res.code, - encryptedData: userInfo.encryptedData, - iv: userInfo.iv - } - // 用户授权登录 - console.log('params',params); - loginWx(params).then(res => { - if (res.data.code === 200) { - uni.setStorage({ - key: 'userInfo', - data: res.data.data.userInfo, - }) - } else { - uni.showToast({ - title: res.data.msg, - icon: 'none' - }) - } - }).catch(res => {}) - console.log(`getUserInfo 调用成功`, userInfo); - }, - fail(userInfo) { - console.log(`getUserInfo 调用失败`); - }, - }); - }, - fail(res) { - console.log(`login 调用失败`); - }, - }); - - }, - // 滚动监听 - handleScroll() { - let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop - console.log(scrollTop) - }, }, } diff --git a/pages/userInfo/userInfo.vue b/pages/userInfo/userInfo.vue index 8c03e21..102e434 100644 --- a/pages/userInfo/userInfo.vue +++ b/pages/userInfo/userInfo.vue @@ -1,204 +1,158 @@ - diff --git a/uni_modules/uni-badge/components/uni-badge/uni-badge.vue b/uni_modules/uni-badge/components/uni-badge/uni-badge.vue index fcbfe93..1981b4e 100644 --- a/uni_modules/uni-badge/components/uni-badge/uni-badge.vue +++ b/uni_modules/uni-badge/components/uni-badge/uni-badge.vue @@ -160,7 +160,7 @@ }; - diff --git a/uni_modules/uni-breadcrumb/components/uni-breadcrumb/uni-breadcrumb.vue b/uni_modules/uni-breadcrumb/components/uni-breadcrumb/uni-breadcrumb.vue deleted file mode 100644 index 94493a2..0000000 --- a/uni_modules/uni-breadcrumb/components/uni-breadcrumb/uni-breadcrumb.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - diff --git a/uni_modules/uni-breadcrumb/package.json b/uni_modules/uni-breadcrumb/package.json deleted file mode 100644 index 0a04e50..0000000 --- a/uni_modules/uni-breadcrumb/package.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "id": "uni-breadcrumb", - "displayName": "uni-breadcrumb 面包屑", - "version": "0.1.2", - "description": "Breadcrumb 面包屑", - "keywords": [ - "uni-breadcrumb", - "breadcrumb", - "uni-ui", - "面包屑导航", - "面包屑" -], - "repository": "", - "engines": { - "HBuilderX": "^3.1.0" - }, - "directories": { - "example": "../../temps/example_temps" - }, - "dcloudext": { - "category": [ - "前端组件", - "通用组件" - ], - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "" - }, - "uni_modules": { - "dependencies": [], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "y", - "aliyun": "y" - }, - "client": { - "Vue": { - "vue2": "y", - "vue3": "y" - }, - "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", - "阿里": "u", - "百度": "u", - "字节跳动": "u", - "QQ": "u", - "京东": "u" - }, - "快应用": { - "华为": "u", - "联盟": "u" - } - } - } - } -} diff --git a/uni_modules/uni-breadcrumb/readme.md b/uni_modules/uni-breadcrumb/readme.md deleted file mode 100644 index 6976b8d..0000000 --- a/uni_modules/uni-breadcrumb/readme.md +++ /dev/null @@ -1,66 +0,0 @@ - -## breadcrumb 面包屑导航 -> **组件名:uni-breadcrumb** -> 代码块: `ubreadcrumb` - -显示当前页面的路径,快速返回之前的任意页面。 - -### 安装方式 - -本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`。 - -如需通过`npm`方式使用`uni-ui`组件,另见文档:[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55) - -### 基本用法 - -在 ``template`` 中使用组件 - -```html - - {{route.name}} - -``` - -```js -export default { - name: "uni-stat-breadcrumb", - data() { - return { - routes: [{ - to: '/A', - name: 'A页面' - }, { - to: '/B', - name: 'B页面' - }, { - to: '/C', - name: 'C页面' - }] - }; - } - } -``` - - -## API - -### Breadcrumb Props - -|属性名 |类型 |默认值 |说明 | -|:-: |:-: |:-: |:-: | -|separator |String |斜杠'/' |分隔符 | -|separatorClass |String | |图标分隔符 class | - -### Breadcrumb Item Props - -|属性名 |类型 |默认值 |说明 | -|:-: |:-: |:-: |:-: | -|to |String | |路由跳转页面路径 | -|replace|Boolean | |在使用 to 进行路由跳转时,启用 replace 将不会向 history 添加新记录(仅 h5 支持) | - - - - -## 组件示例 - -点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/breadcrumb/breadcrumb](https://hellouniapp.dcloud.net.cn/pages/extUI/breadcrumb/breadcrumb) \ No newline at end of file diff --git a/uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue b/uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue index 30bd6c8..0353011 100644 --- a/uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue +++ b/uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue @@ -96,13 +96,6 @@ diff --git a/uni_modules/uni-data-select/package.json b/uni_modules/uni-data-select/package.json deleted file mode 100644 index 2a31eef..0000000 --- a/uni_modules/uni-data-select/package.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "id": "uni-data-select", - "displayName": "uni-data-select 下拉框选择器", - "version": "0.1.3", - "description": "通过数据驱动的下拉框选择器", - "keywords": [ - "uni-ui", - "select", - "uni-data-select", - "下拉框", - "下拉选" -], - "repository": "https://github.com/dcloudio/uni-ui", - "engines": { - "HBuilderX": "^3.1.1" - }, - "directories": { - "example": "../../temps/example_temps" - }, - "dcloudext": { - "category": [ - "前端组件", - "通用组件" - ], - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" - }, - "uni_modules": { - "dependencies": ["uni-load-more"], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "y", - "aliyun": "y" - }, - "client": { - "App": { - "app-vue": "u", - "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", - "阿里": "u", - "百度": "u", - "字节跳动": "u", - "QQ": "u", - "京东": "u" - }, - "快应用": { - "华为": "u", - "联盟": "u" - }, - "Vue": { - "vue2": "y", - "vue3": "y" - } - } - } - } -} diff --git a/uni_modules/uni-data-select/readme.md b/uni_modules/uni-data-select/readme.md deleted file mode 100644 index eb58de3..0000000 --- a/uni_modules/uni-data-select/readme.md +++ /dev/null @@ -1,8 +0,0 @@ -## DataSelect 下拉框选择器 -> **组件名:uni-data-select** -> 代码块: `uDataSelect` - -当选项过多时,使用下拉菜单展示并选择内容 - -### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-select) -#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 diff --git a/uni_modules/uni-datetime-picker/changelog.md b/uni_modules/uni-datetime-picker/changelog.md index 285f574..5c9735a 100644 --- a/uni_modules/uni-datetime-picker/changelog.md +++ b/uni_modules/uni-datetime-picker/changelog.md @@ -1,3 +1,5 @@ +## 2.2.6(2022-06-30) +- 优化 组件样式,调整了组件图标大小、高度、颜色等,与uni-ui风格保持一致 ## 2.2.5(2022-06-24) - 修复 日历顶部年月及底部确认未国际化 bug ## 2.2.4(2022-03-31) 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 index ea00857..9bdf8bc 100644 --- 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 @@ -5,12 +5,12 @@ - + - + @@ -20,7 +20,7 @@ :placeholder="endPlaceholderText" :disabled="true" /> - + @@ -127,10 +127,23 @@ export default { name: 'UniDatetimePicker', + options: { + virtualHost: true + }, components: { calendar, timePicker }, + inject: { + form: { + from: 'uniForm', + default: null + }, + formItem: { + from: 'uniFormItem', + default: null + }, + }, data() { return { isRange: false, @@ -386,33 +399,16 @@ } }, created() { - this.form = this.getForm('uniForms') - this.formItem = this.getForm('uniFormsItem') - - // if (this.formItem) { - // if (this.formItem.name) { - // this.rename = this.formItem.name - // this.form.inputChildrens.push(this) - // } + // if (this.form && this.formItem) { + // this.$watch('formItem.errMsg', (newVal) => { + // this.localMsg = newVal + // }) // } }, mounted() { this.platform() }, methods: { - /** - * 获取父元素实例 - */ - getForm(name = 'uniForms') { - let parent = this.$parent; - let parentName = parent.$options.name; - while (parentName !== name) { - parent = parent.$parent; - if (!parent) return false - parentName = parent.$options.name; - } - return parent; - }, initPicker(newVal) { if (!newVal || Array.isArray(newVal) && !newVal.length) { this.$nextTick(() => { @@ -545,7 +541,8 @@ } } } - this.formItem && this.formItem.setValue(value) + + this.$emit('change', value) this.$emit('input', value) this.$emit('update:modelValue', value) @@ -710,7 +707,15 @@ this.$refs.pcSingle && this.$refs.pcSingle.clearCalender() } if (needEmit) { - this.formItem && this.formItem.setValue('') + // 校验规则 + // if(this.form && this.formItem){ + // const { + // validateTrigger + // } = this.form + // if (validateTrigger === 'blur') { + // this.formItem.onFieldChange() + // } + // } this.$emit('change', '') this.$emit('input', '') this.$emit('update:modelValue', '') @@ -730,7 +735,6 @@ this.$refs.right && this.$refs.right.next() } if (needEmit) { - this.formItem && this.formItem.setValue([]) this.$emit('change', []) this.$emit('input', []) this.$emit('update:modelValue', []) @@ -779,6 +783,12 @@ diff --git a/uni_modules/uni-forms/components/uni-forms/uni-forms.vue b/uni_modules/uni-forms/components/uni-forms/uni-forms.vue index 42ecac6..ed2f6d9 100644 --- a/uni_modules/uni-forms/components/uni-forms/uni-forms.vue +++ b/uni_modules/uni-forms/components/uni-forms/uni-forms.vue @@ -1,13 +1,27 @@ - diff --git a/uni_modules/uni-forms/components/uni-forms/utils.js b/uni_modules/uni-forms/components/uni-forms/utils.js new file mode 100644 index 0000000..6da2421 --- /dev/null +++ b/uni_modules/uni-forms/components/uni-forms/utils.js @@ -0,0 +1,293 @@ +/** + * 简单处理对象拷贝 + * @param {Obejct} 被拷贝对象 + * @@return {Object} 拷贝对象 + */ +export const deepCopy = (val) => { + return JSON.parse(JSON.stringify(val)) +} +/** + * 过滤数字类型 + * @param {String} format 数字类型 + * @@return {Boolean} 返回是否为数字类型 + */ +export const typeFilter = (format) => { + return format === 'int' || format === 'double' || format === 'number' || format === 'timestamp'; +} + +/** + * 把 value 转换成指定的类型,用于处理初始值,原因是初始值需要入库不能为 undefined + * @param {String} key 字段名 + * @param {any} value 字段值 + * @param {Object} rules 表单校验规则 + */ +export const getValue = (key, value, rules) => { + const isRuleNumType = rules.find(val => val.format && typeFilter(val.format)); + const isRuleBoolType = rules.find(val => (val.format && val.format === 'boolean') || val.format === 'bool'); + // 输入类型为 number + if (!!isRuleNumType) { + if (!value && value !== 0) { + value = null + } else { + value = isNumber(Number(value)) ? Number(value) : value + } + } + + // 输入类型为 boolean + if (!!isRuleBoolType) { + value = isBoolean(value) ? value : false + } + + return value; +} + +/** + * 获取表单数据 + * @param {String|Array} name 真实名称,需要使用 realName 获取 + * @param {Object} data 原始数据 + * @param {any} value 需要设置的值 + */ +export const setDataValue = (field, formdata, value) => { + formdata[field] = value + return value || '' +} + +/** + * 获取表单数据 + * @param {String|Array} field 真实名称,需要使用 realName 获取 + * @param {Object} data 原始数据 + */ +export const getDataValue = (field, data) => { + return objGet(data, field) +} + +/** + * 获取表单类型 + * @param {String|Array} field 真实名称,需要使用 realName 获取 + */ +export const getDataValueType = (field, data) => { + const value = getDataValue(field, data) + return { + type: type(value), + value + } +} + +/** + * 获取表单可用的真实name + * @param {String|Array} name 表单name + * @@return {String} 表单可用的真实name + */ +export const realName = (name, data = {}) => { + const base_name = _basePath(name) + if (typeof base_name === 'object' && Array.isArray(base_name) && base_name.length > 1) { + const realname = base_name.reduce((a, b) => a += `#${b}`, '_formdata_') + return realname + } + return base_name[0] || name +} + +/** + * 判断是否表单可用的真实name + * @param {String|Array} name 表单name + * @@return {String} 表单可用的真实name + */ +export const isRealName = (name) => { + const reg = /^_formdata_#*/ + return reg.test(name) +} + +/** + * 获取表单数据的原始格式 + * @@return {Object|Array} object 需要解析的数据 + */ +export const rawData = (object = {}, name) => { + let newData = JSON.parse(JSON.stringify(object)) + let formData = {} + for(let i in newData){ + let path = name2arr(i) + objSet(formData,path,newData[i]) + } + return formData +} + +/** + * 真实name还原为 array + * @param {*} name + */ +export const name2arr = (name) => { + let field = name.replace('_formdata_#', '') + field = field.split('#').map(v => (isNumber(v) ? Number(v) : v)) + return field +} + +/** + * 对象中设置值 + * @param {Object|Array} object 源数据 + * @param {String| Array} path 'a.b.c' 或 ['a',0,'b','c'] + * @param {String} value 需要设置的值 + */ +export const objSet = (object, path, value) => { + if (typeof object !== 'object') return object; + _basePath(path).reduce((o, k, i, _) => { + if (i === _.length - 1) { + // 若遍历结束直接赋值 + o[k] = value + return null + } else if (k in o) { + // 若存在对应路径,则返回找到的对象,进行下一次遍历 + return o[k] + } else { + // 若不存在对应路径,则创建对应对象,若下一路径是数字,新对象赋值为空数组,否则赋值为空对象 + o[k] = /^[0-9]{1,}$/.test(_[i + 1]) ? [] : {} + return o[k] + } + }, object) + // 返回object + return object; +} + +// 处理 path, path有三种形式:'a[0].b.c'、'a.0.b.c' 和 ['a','0','b','c'],需要统一处理成数组,便于后续使用 +function _basePath(path) { + // 若是数组,则直接返回 + if (Array.isArray(path)) return path + // 若有 '[',']',则替换成将 '[' 替换成 '.',去掉 ']' + return path.replace(/\[/g, '.').replace(/\]/g, '').split('.') +} + +/** + * 从对象中获取值 + * @param {Object|Array} object 源数据 + * @param {String| Array} path 'a.b.c' 或 ['a',0,'b','c'] + * @param {String} defaultVal 如果无法从调用链中获取值的默认值 + */ +export const objGet = (object, path, defaultVal = 'undefined') => { + // 先将path处理成统一格式 + let newPath = _basePath(path) + // 递归处理,返回最后结果 + let val = newPath.reduce((o, k) => { + return (o || {})[k] + }, object); + return !val || val !== undefined ? val : defaultVal +} + + +/** + * 是否为 number 类型 + * @param {any} num 需要判断的值 + * @return {Boolean} 是否为 number + */ +export const isNumber = (num) => { + return !isNaN(Number(num)) +} + +/** + * 是否为 boolean 类型 + * @param {any} bool 需要判断的值 + * @return {Boolean} 是否为 boolean + */ +export const isBoolean = (bool) => { + return (typeof bool === 'boolean') +} +/** + * 是否有必填字段 + * @param {Object} rules 规则 + * @return {Boolean} 是否有必填字段 + */ +export const isRequiredField = (rules) => { + let isNoField = false; + for (let i = 0; i < rules.length; i++) { + const ruleData = rules[i]; + if (ruleData.required) { + isNoField = true; + break; + } + } + return isNoField; +} + + +/** + * 获取数据类型 + * @param {Any} obj 需要获取数据类型的值 + */ +export const type = (obj) => { + var class2type = {}; + + // 生成class2type映射 + "Boolean Number String Function Array Date RegExp Object Error".split(" ").map(function(item, index) { + class2type["[object " + item + "]"] = item.toLowerCase(); + }) + if (obj == null) { + return obj + ""; + } + return typeof obj === "object" || typeof obj === "function" ? + class2type[Object.prototype.toString.call(obj)] || "object" : + typeof obj; +} + +/** + * 判断两个值是否相等 + * @param {any} a 值 + * @param {any} b 值 + * @return {Boolean} 是否相等 + */ +export const isEqual = (a, b) => { + //如果a和b本来就全等 + if (a === b) { + //判断是否为0和-0 + return a !== 0 || 1 / a === 1 / b; + } + //判断是否为null和undefined + if (a == null || b == null) { + return a === b; + } + //接下来判断a和b的数据类型 + var classNameA = toString.call(a), + classNameB = toString.call(b); + //如果数据类型不相等,则返回false + if (classNameA !== classNameB) { + return false; + } + //如果数据类型相等,再根据不同数据类型分别判断 + switch (classNameA) { + case '[object RegExp]': + case '[object String]': + //进行字符串转换比较 + return '' + a === '' + b; + case '[object Number]': + //进行数字转换比较,判断是否为NaN + if (+a !== +a) { + return +b !== +b; + } + //判断是否为0或-0 + return +a === 0 ? 1 / +a === 1 / b : +a === +b; + case '[object Date]': + case '[object Boolean]': + return +a === +b; + } + //如果是对象类型 + if (classNameA == '[object Object]') { + //获取a和b的属性长度 + var propsA = Object.getOwnPropertyNames(a), + propsB = Object.getOwnPropertyNames(b); + if (propsA.length != propsB.length) { + return false; + } + for (var i = 0; i < propsA.length; i++) { + var propName = propsA[i]; + //如果对应属性对应值不相等,则返回false + if (a[propName] !== b[propName]) { + return false; + } + } + return true; + } + //如果是数组类型 + if (classNameA == '[object Array]') { + if (a.toString() == b.toString()) { + return true; + } + return false; + } +} diff --git a/uni_modules/uni-forms/package.json b/uni_modules/uni-forms/package.json index 4253d5c..89fa608 100644 --- a/uni_modules/uni-forms/package.json +++ b/uni_modules/uni-forms/package.json @@ -1,7 +1,7 @@ { "id": "uni-forms", "displayName": "uni-forms 表单", - "version": "1.3.3", + "version": "1.4.5", "description": "由输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据", "keywords": [ "uni-ui", diff --git a/uni_modules/uni-grid/components/uni-grid-item/uni-grid-item.vue b/uni_modules/uni-grid/components/uni-grid-item/uni-grid-item.vue index 20fd54e..19c08d7 100644 --- a/uni_modules/uni-grid/components/uni-grid-item/uni-grid-item.vue +++ b/uni_modules/uni-grid/components/uni-grid-item/uni-grid-item.vue @@ -68,7 +68,7 @@ } - diff --git a/uni_modules/uni-test/package.json b/uni_modules/uni-test/package.json deleted file mode 100644 index 9a3c4c4..0000000 --- a/uni_modules/uni-test/package.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "id": "uni-test", - "displayName": "Test 测试插件", - "version": "2.0.13", - "description": "测试插件 ", - "keywords": [ - "test" -], - "repository": "https://github.com/dcloudio/uni-ui", - "engines": { - "HBuilderX": "^3.1.3" - }, - "directories": { - "example": "../../temps/example_temps" - }, - "dcloudext": { - "category": [ - "前端组件", - "通用组件" - ], - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" - }, - "uni_modules": { - "dependencies": ["uni-scss"], - "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" - }, - "快应用": { - "华为": "y", - "联盟": "y" - }, - "Vue": { - "vue2": "y", - "vue3": "y" - } - } - } - } -} diff --git a/uni_modules/uni-test/readme.md b/uni_modules/uni-test/readme.md deleted file mode 100644 index ddb24c6..0000000 --- a/uni_modules/uni-test/readme.md +++ /dev/null @@ -1,10 +0,0 @@ - - -## DataCheckbox 数据驱动的单选复选框 -> **组件名:uni-data-checkbox** -> 代码块: `uDataCheckbox` - - -本组件是基于uni-app基础组件checkbox的封装。本组件要解决问题包括: - -### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-card) \ No newline at end of file diff --git a/uni_modules/uni-tooltip/changelog.md b/uni_modules/uni-tooltip/changelog.md deleted file mode 100644 index 00f1572..0000000 --- a/uni_modules/uni-tooltip/changelog.md +++ /dev/null @@ -1,10 +0,0 @@ -## 0.2.1(2022-05-09) -- 修复 content 为空时仍然弹出的bug -## 0.2.0(2022-05-07) -**注意:破坏性更新** -- 更新 text 属性变更为 content -- 更新 移除 width 属性 -## 0.1.1(2022-04-27) -- 修复 组件根 text 嵌套组件 warning -## 0.1.0(2022-04-21) -- 初始化 diff --git a/uni_modules/uni-tooltip/components/uni-tooltip/uni-tooltip.vue b/uni_modules/uni-tooltip/components/uni-tooltip/uni-tooltip.vue deleted file mode 100644 index ffbb6fa..0000000 --- a/uni_modules/uni-tooltip/components/uni-tooltip/uni-tooltip.vue +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - diff --git a/uni_modules/uni-tooltip/package.json b/uni_modules/uni-tooltip/package.json deleted file mode 100644 index e88ecf8..0000000 --- a/uni_modules/uni-tooltip/package.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "id": "uni-tooltip", - "displayName": "uni-tooltip 提示文字", - "version": "0.2.1", - "description": "Tooltip 提示文字", - "keywords": [ - "uni-tooltip", - "uni-ui", - "tooltip", - "tip", - "文字提示" - ], - "repository": "https://github.com/dcloudio/uni-ui", - "engines": { - "HBuilderX": "" - }, - "directories": { - "example": "../../temps/example_temps" - }, - "dcloudext": { - "category": [ - "前端组件", - "通用组件" - ], - "sale": { - "regular": { - "price": "0.00" - }, - "sourcecode": { - "price": "0.00" - } - }, - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无 ", - "data": "无", - "permissions": "无" - }, - "npmurl": "" - }, - "uni_modules": { - "dependencies": [], - "encrypt": [], - "platforms": { - "cloud": { - "tcb": "y", - "aliyun": "y" - }, - "client": { - "Vue": { - "vue2": "y", - "vue3": "y" - }, - "App": { - "app-vue": "y", - "app-nvue": "u" - }, - "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", - "阿里": "u", - "百度": "u", - "字节跳动": "u", - "QQ": "u", - "京东": "u" - }, - "快应用": { - "华为": "u", - "联盟": "u" - } - } - } - } -} \ No newline at end of file diff --git a/uni_modules/uni-tooltip/readme.md b/uni_modules/uni-tooltip/readme.md deleted file mode 100644 index faafa2e..0000000 --- a/uni_modules/uni-tooltip/readme.md +++ /dev/null @@ -1,8 +0,0 @@ -## Badge 数字角标 -> **组件名:uni-tooltip** -> 代码块: `uTooltip` - -数字角标一般和其它控件(列表、9宫格等)配合使用,用于进行数量提示,默认为实心灰色背景, - -### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-tooltip) -#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 diff --git a/uni_modules/uni-ui/changelog.md b/uni_modules/uni-ui/changelog.md index 37a2c21..e99b036 100644 --- a/uni_modules/uni-ui/changelog.md +++ b/uni_modules/uni-ui/changelog.md @@ -1,3 +1,39 @@ +## 1.4.19(2022-07-07) +- uni-data-picker 优化 pc端图标位置不正确的问题 +- uni-data-select 修复 pc端宽度异常的bug +## 1.4.18(2022-07-06) +- uni-forms 【重要】组件逻辑重构,部分用法旧版本不兼容,请注意兼容问题 +- uni-forms 【重要】组件使用 Provide/Inject 方式注入依赖,提供了自定义表单组件调用 uni-forms 校验表单的能力 +- uni-forms 新增 更多表单示例 +- uni-forms 新增 model 属性,等同于原 value/modelValue 属性,旧属性即将废弃 +- uni-forms 新增 validateTrigger 属性的 blur 值,仅 uni-easyinput 生效 +- uni-forms 新增 onFieldChange 方法,可以对子表单进行校验,可替代binddata方法 +- uni-forms 新增 子表单的 setRules 方法,配合自定义校验函数使用 +- uni-forms 新增 uni-forms-item 的 setRules 方法,配置动态表单使用可动态更新校验规则 +- uni-forms 修复 由 1.4.0 引发的 label 插槽不生效的bug +- uni-forms 修复 子组件找不到 setValue 报错的bug +- uni-forms 修复 uni-data-picker 在 uni-forms-item 中报错的bug +- uni-forms 修复 uni-data-picker 在 uni-forms-item 中宽度不正确的bug +- uni-forms 修复 表单校验顺序无序问题 +- uni-forms 优化 子表单组件uni-datetime-picker、uni-data-select、uni-data-picker的显示样式 +- uni-forms 优化 动态表单校验方式,废弃拼接name的方式 +- uni-breadcrumb 修复 微信小程序 separator 不显示问题 +- uni-data-checkbox 优化 在 uni-forms 中的依赖注入方式 +- uni-data-picker 修复 uni-data-picker 在 uni-forms-item 中宽度不正确的bug +- uni-data-picker 优化 显示样式 +- uni-data-select 优化 显示样式 +- uni-datetime-picker 修复 日历顶部年月及底部确认未国际化 bug +- uni-datetime-picker 优化 组件样式,调整了组件图标大小、高度、颜色等,与uni-ui风格保持一致 +- uni-easyinput 新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容 +- uni-easyinput 新增 clear 事件,点击右侧叉号图标触发 +- uni-easyinput 新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发 +- uni-easyinput 优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等 +- uni-easyinput 优化 clearable 显示策略 +- uni-file-picker 修复 在uni-forms下样式不生效的bug +- uni-nav-bar 修复 组件示例中插槽用法无法显示内容的bug +- uni-swipe-action 修复 vue3 下使用组件不能正常运行的Bug +- uni-swipe-action 修复 h5端点击click触发两次的Bug +- uni-table 修复 微信小程序存在无使用组件的问题 ## 1.4.17(2022-06-30) - 支持 ios 安全区 ## 1.4.16(2022-06-06) diff --git a/uni_modules/uni-ui/package.json b/uni_modules/uni-ui/package.json index a884512..603719f 100644 --- a/uni_modules/uni-ui/package.json +++ b/uni_modules/uni-ui/package.json @@ -1,7 +1,7 @@ { "id": "uni-ui", "displayName": "uni-ui", - "version": "1.4.17", + "version": "1.4.19", "description": "uni-ui 是基于uni-app的、全端兼容的、高性能UI框架", "keywords": [ "uni-ui", @@ -112,8 +112,8 @@ "阿里": "y", "百度": "y", "字节跳动": "y", - "QQ": "y", - "京东": "u" + "QQ": "y", + "京东": "u" }, "快应用": { "华为": "u",