diff --git a/package-lock.json b/package-lock.json index b82ab3f..86fed66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5645,6 +5645,15 @@ "keygrip": "~1.1.0" } }, + "copy-anything": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-2.0.6.tgz", + "integrity": "sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==", + "dev": true, + "requires": { + "is-what": "^3.14.1" + } + }, "copy-concurrently": { "version": "1.0.5", "resolved": "https://registry.npmmirror.com/copy-concurrently/-/copy-concurrently-1.0.5.tgz", @@ -8296,6 +8305,13 @@ "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", "dev": true }, + "image-size": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz", + "integrity": "sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==", + "dev": true, + "optional": true + }, "immediate": { "version": "3.0.6", "resolved": "https://registry.npmmirror.com/immediate/-/immediate-3.0.6.tgz", @@ -8889,6 +8905,12 @@ "call-bind": "^1.0.2" } }, + "is-what": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/is-what/-/is-what-3.14.1.tgz", + "integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==", + "dev": true + }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmmirror.com/is-windows/-/is-windows-1.0.2.tgz", @@ -11013,6 +11035,119 @@ "invert-kv": "^3.0.0" } }, + "less": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/less/-/less-4.1.3.tgz", + "integrity": "sha512-w16Xk/Ta9Hhyei0Gpz9m7VS8F28nieJaL/VyShID7cYvP6IL5oHeL6p4TXSDJqZE/lNv0oJ2pGVjJsRkfwm5FA==", + "dev": true, + "requires": { + "copy-anything": "^2.0.1", + "errno": "^0.1.1", + "graceful-fs": "^4.1.2", + "image-size": "~0.5.0", + "make-dir": "^2.1.0", + "mime": "^1.4.1", + "needle": "^3.1.0", + "parse-node-version": "^1.0.1", + "source-map": "~0.6.0", + "tslib": "^2.3.0" + }, + "dependencies": { + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true, + "optional": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "optional": true + } + } + }, + "less-loader": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/less-loader/-/less-loader-6.2.0.tgz", + "integrity": "sha512-Cl5h95/Pz/PWub/tCBgT1oNMFeH1WTD33piG80jn5jr12T4XbxZcjThwNXDQ7AG649WEynuIzO4b0+2Tn9Qolg==", + "dev": true, + "requires": { + "clone": "^2.1.2", + "less": "^3.11.3", + "loader-utils": "^2.0.0", + "schema-utils": "^2.7.0" + }, + "dependencies": { + "clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", + "dev": true + }, + "less": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/less/-/less-3.13.1.tgz", + "integrity": "sha512-SwA1aQXGUvp+P5XdZslUOhhLnClSLIjWvJhmd+Vgib5BFIr9lMNlQwmwUNOjXThF/A0x+MCYYPeWEfeWiLRnTw==", + "dev": true, + "requires": { + "copy-anything": "^2.0.1", + "errno": "^0.1.1", + "graceful-fs": "^4.1.2", + "image-size": "~0.5.0", + "make-dir": "^2.1.0", + "mime": "^1.4.1", + "native-request": "^1.0.5", + "source-map": "~0.6.0", + "tslib": "^1.10.0" + } + }, + "loader-utils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz", + "integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true, + "optional": true + }, + "schema-utils": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.1.tgz", + "integrity": "sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.5", + "ajv": "^6.12.4", + "ajv-keywords": "^3.5.2" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "optional": true + }, + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + } + } + }, "leven": { "version": "3.1.0", "resolved": "https://registry.npmmirror.com/leven/-/leven-3.1.0.tgz", @@ -11722,12 +11857,53 @@ "to-regex": "^3.0.1" } }, + "native-request": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/native-request/-/native-request-1.1.0.tgz", + "integrity": "sha512-uZ5rQaeRn15XmpgE0xoPL8YWqcX90VtCFglYwAgkvKM5e8fog+vePLAhHxuuv/gRkrQxIeh5U3q9sMNUrENqWw==", + "dev": true, + "optional": true + }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmmirror.com/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "needle": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/needle/-/needle-3.1.0.tgz", + "integrity": "sha512-gCE9weDhjVGCRqS8dwDR/D3GTAeyXLXuqp7I8EzH6DllZGXSUyxuqqLh+YX9rMAWaaTFyVAg6rHGL25dqvczKw==", + "dev": true, + "optional": true, + "requires": { + "debug": "^3.2.6", + "iconv-lite": "^0.6.3", + "sax": "^1.2.4" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "optional": true, + "requires": { + "ms": "^2.1.1" + } + }, + "iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "optional": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + } + } + }, "negotiator": { "version": "0.6.3", "resolved": "https://registry.npmmirror.com/negotiator/-/negotiator-0.6.3.tgz", @@ -12400,6 +12576,12 @@ "lines-and-columns": "^1.1.6" } }, + "parse-node-version": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz", + "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==", + "dev": true + }, "parse5": { "version": "3.0.3", "resolved": "https://registry.npmmirror.com/parse5/-/parse5-3.0.3.tgz", @@ -14278,6 +14460,86 @@ } } }, + "sass-resources-loader": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/sass-resources-loader/-/sass-resources-loader-2.2.5.tgz", + "integrity": "sha512-po8rfETH9cOQACWxubT/1CCu77KjxwRtCDm6QAXZH99aUHBydwSoxdIjC40SGp/dcS/FkSNJl0j1VEojGZqlvQ==", + "dev": true, + "requires": { + "async": "^3.2.3", + "chalk": "^4.1.0", + "glob": "^7.1.6", + "loader-utils": "^2.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "async": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", + "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==", + "dev": true + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "loader-utils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz", + "integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "sax": { "version": "1.2.4", "resolved": "https://registry.npmmirror.com/sax/-/sax-1.2.4.tgz", diff --git a/package.json b/package.json index 3c292dc..5d556dc 100644 --- a/package.json +++ b/package.json @@ -89,11 +89,14 @@ "babel-plugin-import": "^1.11.0", "cross-env": "^7.0.2", "jest": "^25.4.0", + "less": "^4.1.3", + "less-loader": "^6.2.0", "mini-types": "*", "miniprogram-api-typings": "*", "node-sass": "^4.14.1", "postcss-comment": "^2.0.0", "sass-loader": "^10.0.1", + "sass-resources-loader": "^2.2.5", "vue-template-compiler": "^2.6.11" }, "browserslist": [ @@ -102,5 +105,13 @@ ], "uni-app": { "scripts": {} - } + }, + "description": "```\r yarn install\r ```", + "main": "babel.config.js", + "repository": { + "type": "git", + "url": "git@git.zdool.com:xs/yyx/h5.git" + }, + "author": "", + "license": "ISC" } diff --git a/src/components/loading.vue b/src/components/loading.vue new file mode 100644 index 0000000..c6a9ea8 --- /dev/null +++ b/src/components/loading.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/src/components/msgList2/msgList2.vue b/src/components/msgList2/msgList2.vue new file mode 100644 index 0000000..9c5a7cf --- /dev/null +++ b/src/components/msgList2/msgList2.vue @@ -0,0 +1,217 @@ + + + + + diff --git a/src/components/nothing/nothing.vue b/src/components/nothing/nothing.vue new file mode 100644 index 0000000..9eb2785 --- /dev/null +++ b/src/components/nothing/nothing.vue @@ -0,0 +1,36 @@ + + + + + diff --git a/src/components/pageLoading.vue b/src/components/pageLoading.vue new file mode 100644 index 0000000..622ca79 --- /dev/null +++ b/src/components/pageLoading.vue @@ -0,0 +1,89 @@ + + + + + diff --git a/src/components/topLoading.vue b/src/components/topLoading.vue new file mode 100644 index 0000000..7b2016c --- /dev/null +++ b/src/components/topLoading.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/src/components/uni-swipe-action-item/bindingx.js b/src/components/uni-swipe-action-item/bindingx.js new file mode 100644 index 0000000..50b9241 --- /dev/null +++ b/src/components/uni-swipe-action-item/bindingx.js @@ -0,0 +1,245 @@ +const BindingX = uni.requireNativePlugin('bindingx'); +const dom = uni.requireNativePlugin('dom'); +const animation = uni.requireNativePlugin('animation'); + +export default { + data() { + return { + right: 0, + button: [], + preventGesture: false + } + }, + + watch: { + show(newVal) { + if (!this.position || JSON.stringify(this.position) === '{}') return; + if (this.autoClose) return + if (this.isInAnimation) return + if (newVal) { + this.open() + } else { + this.close() + } + }, + }, + created() { + if (this.swipeaction.children !== undefined) { + this.swipeaction.children.push(this) + } + }, + mounted() { + this.boxSelector = this.getEl(this.$refs['selector-box-hock']); + this.selector = this.getEl(this.$refs['selector-content-hock']); + this.buttonSelector = this.getEl(this.$refs['selector-button-hock']); + this.position = {} + this.x = 0 + setTimeout(() => { + this.getSelectorQuery() + }, 200) + }, + beforeDestroy() { + if (this.timing) { + BindingX.unbind({ + token: this.timing.token, + eventType: 'timing' + }) + } + if (this.eventpan) { + BindingX.unbind({ + token: this.eventpan.token, + eventType: 'pan' + }) + } + this.swipeaction.children.forEach((item, index) => { + if (item === this) { + this.swipeaction.children.splice(index, 1) + } + }) + }, + methods: { + onClick(index, item) { + this.$emit('click', { + content: item, + index + }) + }, + touchstart(e) { + if (this.isInAnimation) return + if (this.stop) return + this.stop = true + if (this.autoClose) { + this.swipeaction.closeOther(this) + } + let endWidth = this.right + let boxStep = `(x+${this.x})` + let pageX = `${boxStep}> ${-endWidth} && ${boxStep} < 0?${boxStep}:(x+${this.x} < 0? ${-endWidth}:0)` + + let props = [{ + element: this.selector, + property: 'transform.translateX', + expression: pageX + }] + + let left = 0 + for (let i = 0; i < this.options.length; i++) { + let buttonSelectors = this.getEl(this.$refs['button-hock'][i]); + if (this.button.length === 0 || !this.button[i] || !this.button[i].width) return + let moveMix = endWidth - left + left += this.button[i].width + let step = `(${this.x}+x)/${endWidth}` + let moveX = `(${step}) * ${moveMix}` + let pageButtonX = `${moveX}&& (x+${this.x} > ${-endWidth})?${moveX}:${-moveMix}` + props.push({ + element: buttonSelectors, + property: 'transform.translateX', + expression: pageButtonX + }) + } + + this.eventpan = this._bind(this.boxSelector, props, 'pan', (e) => { + if (e.state === 'end') { + this.x = e.deltaX + this.x; + if (this.x < -endWidth) { + this.x = -endWidth + } + if (this.x > 0) { + this.x = 0 + } + this.stop = false + this.bindTiming(); + } + }) + }, + touchend(e) { + this.$nextTick(() => { + if (this.isopen && !this.isDrag && !this.isInAnimation) { + this.close() + } + }) + }, + bindTiming() { + if (this.isopen) { + this.move(this.x, -this.right) + } else { + this.move(this.x, -40) + } + }, + move(left, value) { + if (left >= value) { + this.close() + } else { + this.open() + } + }, + /** + * 开启swipe + */ + open() { + this.animation(true) + }, + /** + * 关闭swipe + */ + close() { + this.animation(false) + }, + /** + * 开启关闭动画 + * @param {Object} type + */ + animation(type) { + this.isDrag = true + let endWidth = this.right + let time = 200 + this.isInAnimation = true; + + let exit = `t>${time}`; + let translate_x_expression = `easeOutExpo(t,${this.x},${type?(-endWidth-this.x):(-this.x)},${time})` + let props = [{ + element: this.selector, + property: 'transform.translateX', + expression: translate_x_expression + }] + + let left = 0 + for (let i = 0; i < this.options.length; i++) { + let buttonSelectors = this.getEl(this.$refs['button-hock'][i]); + if (this.button.length === 0 || !this.button[i] || !this.button[i].width) return + let moveMix = endWidth - left + left += this.button[i].width + let step = `${this.x}/${endWidth}` + let moveX = `(${step}) * ${moveMix}` + let pageButtonX = `easeOutExpo(t,${moveX},${type ? -moveMix + '-' + moveX: 0 + '-' + moveX},${time})` + props.push({ + element: buttonSelectors, + property: 'transform.translateX', + expression: pageButtonX + }) + } + + this.timing = BindingX.bind({ + eventType: 'timing', + exitExpression: exit, + props: props + }, (e) => { + if (e.state === 'end' || e.state === 'exit') { + this.x = type ? -endWidth : 0 + this.isInAnimation = false; + + this.isopen = this.isopen || false + if (this.isopen !== type) { + this.$emit('change', type) + } + this.isopen = type + this.isDrag = false + } + }); + }, + /** + * 绑定 BindingX + * @param {Object} anchor + * @param {Object} props + * @param {Object} fn + */ + _bind(anchor, props, eventType, fn) { + return BindingX.bind({ + anchor, + eventType, + props + }, (e) => { + typeof(fn) === 'function' && fn(e) + }); + }, + /** + * 获取ref + * @param {Object} el + */ + getEl(el) { + return el.ref + }, + /** + * 获取节点信息 + */ + getSelectorQuery() { + dom.getComponentRect(this.$refs['selector-content-hock'], (data) => { + if (this.position.content) return + this.position.content = data.size + }) + for (let i = 0; i < this.options.length; i++) { + dom.getComponentRect(this.$refs['button-hock'][i], (data) => { + if (!this.button) { + this.button = [] + } + if (this.options.length === this.button.length) return + this.button.push(data.size) + this.right += data.size.width + if (this.autoClose) return + if (this.show) { + this.open() + } + }) + } + } + } +} diff --git a/src/components/uni-swipe-action-item/index.wxs b/src/components/uni-swipe-action-item/index.wxs new file mode 100644 index 0000000..24c94bb --- /dev/null +++ b/src/components/uni-swipe-action-item/index.wxs @@ -0,0 +1,204 @@ +/** + * 监听页面内值的变化,主要用于动态开关swipe-action + * @param {Object} newValue + * @param {Object} oldValue + * @param {Object} ownerInstance + * @param {Object} instance + */ +function sizeReady(newValue, oldValue, ownerInstance, instance) { + var state = instance.getState() + state.position = JSON.parse(newValue) + if (!state.position || state.position.length === 0) return + var show = state.position[0].show + state.left = state.left || state.position[0].left; + // 通过用户变量,开启或关闭 + if (show) { + openState(true, instance, ownerInstance) + } else { + openState(false, instance, ownerInstance) + } +} + +/** + * 开始触摸操作 + * @param {Object} e + * @param {Object} ins + */ +function touchstart(e, ins) { + var instance = e.instance; + var state = instance.getState(); + var pageX = e.touches[0].pageX; + // 开始触摸时移除动画类 + instance.removeClass('ani'); + var owner = ins.selectAllComponents('.button-hock') + for (var i = 0; i < owner.length; i++) { + owner[i].removeClass('ani'); + } + // state.position = JSON.parse(instance.getDataset().position); + state.left = state.left || state.position[0].left; + // 获取最终按钮组的宽度 + state.width = pageX - state.left; + ins.callMethod('closeSwipe') +} + +/** + * 开始滑动操作 + * @param {Object} e + * @param {Object} ownerInstance + */ +function touchmove(e, ownerInstance) { + var instance = e.instance; + var disabled = instance.getDataset().disabled + var state = instance.getState() + // fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复 + disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false; + + if (disabled) return + var pageX = e.touches[0].pageX; + move(pageX - state.width, instance, ownerInstance) +} + +/** + * 结束触摸操作 + * @param {Object} e + * @param {Object} ownerInstance + */ +function touchend(e, ownerInstance) { + var instance = e.instance; + var disabled = instance.getDataset().disabled + var state = instance.getState() + + // fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复 + disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false; + + if (disabled) return + // 滑动过程中触摸结束,通过阙值判断是开启还是关闭 + // fixed by mehaotian 定时器解决点击按钮,touchend 触发比 click 事件时机早的问题 ,主要是 ios13 + moveDirection(state.left, -40, instance, ownerInstance) +} + +/** + * 设置移动距离 + * @param {Object} value + * @param {Object} instance + * @param {Object} ownerInstance + */ +function move(value, instance, ownerInstance) { + var state = instance.getState() + // 获取可滑动范围 + var x = Math.max(-state.position[1].width, Math.min((value), 0)); + state.left = x; + instance.setStyle({ + transform: 'translateX(' + x + 'px)', + '-webkit-transform': 'translateX(' + x + 'px)' + }) + // 折叠按钮动画 + buttonFold(x, instance, ownerInstance) +} + +/** + * 移动方向判断 + * @param {Object} left + * @param {Object} value + * @param {Object} ownerInstance + * @param {Object} ins + */ +function moveDirection(left, value, ins, ownerInstance) { + var state = ins.getState() + var position = state.position + var isopen = state.isopen + if (!position[1].width) { + openState(false, ins, ownerInstance) + return + } + // 如果已经是打开状态,进行判断是否关闭,还是保留打开状态 + if (isopen) { + if (-left <= position[1].width) { + openState(false, ins, ownerInstance) + } else { + openState(true, ins, ownerInstance) + } + return + } + // 如果是关闭状态,进行判断是否打开,还是保留关闭状态 + if (left <= value) { + openState(true, ins, ownerInstance) + } else { + openState(false, ins, ownerInstance) + } +} + +/** + * 设置按钮移动距离 + * @param {Object} value + * @param {Object} instance + * @param {Object} ownerInstance + */ +function buttonFold(value, instance, ownerInstance) { + var ins = ownerInstance.selectAllComponents('.button-hock'); + var state = instance.getState(); + var position = state.position; + var arr = []; + var w = 0; + for (var i = 0; i < ins.length; i++) { + if (!ins[i].getDataset().button) return + var btnData = JSON.parse(ins[i].getDataset().button) + + // fix by mehaotian TODO 在 app-vue 中,字符串转对象,需要转两次,这里先这么兼容 + if (typeof(btnData) === 'string') { + btnData = JSON.parse(btnData) + } + + var button = btnData[i] && btnData[i].width || 0 + w += button + arr.push(-w) + // 动态计算按钮组每个按钮的折叠动画移动距离 + var distance = arr[i - 1] + value * (arr[i - 1] / position[1].width) + if (i != 0) { + ins[i].setStyle({ + transform: 'translateX(' + distance + 'px)', + }) + } + } +} + +/** + * 开启状态 + * @param {Boolean} type + * @param {Object} ins + * @param {Object} ownerInstance + */ +function openState(type, ins, ownerInstance) { + var state = ins.getState() + var position = state.position + if (state.isopen === undefined) { + state.isopen = false + } + // 只有状态有改变才会通知页面改变状态 + if (state.isopen !== type) { + // 通知页面,已经打开 + ownerInstance.callMethod('change', { + open: type + }) + } + // 设置打开和移动状态 + state.isopen = type + + + // 添加动画类 + ins.addClass('ani'); + var owner = ownerInstance.selectAllComponents('.button-hock') + for (var i = 0; i < owner.length; i++) { + owner[i].addClass('ani'); + } + // 设置最终移动位置 + move(type ? -position[1].width : 0, ins, ownerInstance) + +} + +module.exports = { + sizeReady: sizeReady, + touchstart: touchstart, + touchmove: touchmove, + touchend: touchend +} diff --git a/src/components/uni-swipe-action-item/mpalipay.js b/src/components/uni-swipe-action-item/mpalipay.js new file mode 100644 index 0000000..2b494a4 --- /dev/null +++ b/src/components/uni-swipe-action-item/mpalipay.js @@ -0,0 +1,160 @@ +export default { + data() { + return { + isshow: false, + viewWidth: 0, + buttonWidth: 0, + disabledView: false, + x: 0, + transition: false + } + }, + watch: { + show(newVal) { + if (this.autoClose) return + if (newVal) { + this.open() + } else { + this.close() + } + }, + }, + created() { + if (this.swipeaction.children !== undefined) { + this.swipeaction.children.push(this) + } + }, + beforeDestroy() { + this.swipeaction.children.forEach((item, index) => { + if (item === this) { + this.swipeaction.children.splice(index, 1) + } + }) + }, + mounted() { + this.isopen = false + this.transition = true + setTimeout(() => { + this.getQuerySelect() + }, 50) + + }, + methods: { + onClick(index, item) { + this.$emit('click', { + content: item, + index + }) + }, + touchstart(e) { + let { + pageX, + pageY + } = e.changedTouches[0] + this.transition = false + this.startX = pageX + if (this.autoClose) { + this.swipeaction.closeOther(this) + } + }, + touchmove(e) { + let { + pageX, + } = e.changedTouches[0] + this.slide = this.getSlide(pageX) + if (this.slide === 0) { + this.disabledView = false + } + + }, + touchend(e) { + this.stop = false + this.transition = true + if (this.isopen) { + if (this.moveX === -this.buttonWidth) { + this.close() + return + } + this.move() + } else { + if (this.moveX === 0) { + this.close() + return + } + this.move() + } + }, + open() { + this.x = this.moveX + this.$nextTick(() => { + this.x = -this.buttonWidth + this.moveX = this.x + + if(!this.isopen){ + this.isopen = true + this.$emit('change', true) + } + }) + }, + close() { + this.x = this.moveX + this.$nextTick(() => { + this.x = 0 + this.moveX = this.x + if(this.isopen){ + this.isopen = false + this.$emit('change', false) + } + }) + }, + move() { + if (this.slide === 0) { + this.open() + } else { + this.close() + } + }, + onChange(e) { + let x = e.detail.x + this.moveX = x + if (x >= this.buttonWidth) { + this.disabledView = true + this.$nextTick(() => { + this.x = this.buttonWidth + }) + } + }, + getSlide(x) { + if (x >= this.startX) { + this.startX = x + return 1 + } else { + this.startX = x + return 0 + } + + }, + getQuerySelect() { + const query = uni.createSelectorQuery().in(this); + query.selectAll('.viewWidth-hook').boundingClientRect(data => { + + this.viewWidth = data[0].width + this.buttonWidth = data[1].width + this.transition = false + this.$nextTick(() => { + this.transition = true + }) + + if (!this.buttonWidth) { + this.disabledView = true + } + + if (this.autoClose) return + if (this.show) { + this.open() + } + }).exec(); + + } + } +} diff --git a/src/components/uni-swipe-action-item/mpother.js b/src/components/uni-swipe-action-item/mpother.js new file mode 100644 index 0000000..3534b81 --- /dev/null +++ b/src/components/uni-swipe-action-item/mpother.js @@ -0,0 +1,158 @@ +// #ifdef APP-NVUE +const dom = weex.requireModule('dom'); +// #endif +export default { + data() { + return { + uniShow: false, + left: 0 + } + }, + computed: { + moveLeft() { + return `translateX(${this.left}px)` + } + }, + watch: { + show(newVal) { + if (!this.position || JSON.stringify(this.position) === '{}') return; + if (this.autoClose) return + if (newVal) { + this.$emit('change', true) + this.open() + } else { + this.$emit('change', false) + this.close() + } + } + }, + mounted() { + this.position = {} + if (this.swipeaction.children !== undefined) { + this.swipeaction.children.push(this) + } + setTimeout(() => { + this.getSelectorQuery() + }, 100) + }, + beforeDestoy() { + this.swipeaction.children.forEach((item, index) => { + if (item === this) { + this.swipeaction.children.splice(index, 1) + } + }) + }, + methods: { + onClick(index, item) { + this.$emit('click', { + content: item, + index + }) + this.close() + }, + touchstart(e) { + const { + pageX + } = e.touches[0] + if (this.disabled) return + const left = this.position.content.left + if (this.autoClose) { + this.swipeaction.closeOther(this) + } + this.width = pageX - left + if (this.isopen) return + if (this.uniShow) { + this.uniShow = false + this.isopen = true + this.openleft = this.left + this.position.button.width + } + }, + touchmove(e, index) { + if (this.disabled) return + const { + pageX + } = e.touches[0] + this.setPosition(pageX) + }, + touchend() { + if (this.disabled) return + if (this.isopen) { + this.move(this.openleft, 0) + return + } + this.move(this.left, -40) + }, + setPosition(x, y) { + if (!this.position.button.width) { + return + } + // this.left = x - this.width + this.setValue(x - this.width) + }, + setValue(value) { + // 设置最大最小值 + this.left = Math.max(-this.position.button.width, Math.min(parseInt(value), 0)) + this.position.content.left = this.left + if (this.isopen) { + this.openleft = this.left + this.position.button.width + } + }, + move(left, value) { + if (left >= value) { + this.$emit('change', false) + this.close() + } else { + this.$emit('change', true) + this.open() + } + }, + open() { + this.uniShow = true + this.left = -this.position.button.width + this.setValue(-this.position.button.width) + }, + close() { + this.uniShow = true + this.setValue(0) + setTimeout(() => { + this.uniShow = false + this.isopen = false + }, 300) + }, + getSelectorQuery() { + // #ifndef APP-NVUE + const views = uni.createSelectorQuery() + .in(this) + views + .selectAll('.selector-query-hock') + .boundingClientRect(data => { + this.position.content = data[1] + this.position.button = data[0] + if (this.autoClose) return + if (this.show) { + this.open() + } else { + this.close() + } + }) + .exec() + // #endif + // #ifdef APP-NVUE + dom.getComponentRect(this.$refs['selector-content-hock'], (data) => { + if (this.position.content) return + this.position.content = data.size + }) + dom.getComponentRect(this.$refs['selector-button-hock'], (data) => { + if (this.position.button) return + this.position.button = data.size + if (this.autoClose) return + if (this.show) { + this.open() + } else { + this.close() + } + }) + // #endif + } + } +} diff --git a/src/components/uni-swipe-action-item/mpwxs.js b/src/components/uni-swipe-action-item/mpwxs.js new file mode 100644 index 0000000..f9d2813 --- /dev/null +++ b/src/components/uni-swipe-action-item/mpwxs.js @@ -0,0 +1,97 @@ +export default { + data() { + return { + position: [], + button: [] + } + }, + computed: { + pos() { + return JSON.stringify(this.position) + }, + btn() { + return JSON.stringify(this.button) + } + }, + watch: { + show(newVal) { + if (this.autoClose) return + let valueObj = this.position[0] + if (!valueObj) { + this.init() + return + } + valueObj.show = newVal + this.$set(this.position, 0, valueObj) + } + }, + created() { + if (this.swipeaction.children !== undefined) { + this.swipeaction.children.push(this) + } + }, + mounted() { + this.init() + + }, + beforeDestroy() { + this.swipeaction.children.forEach((item, index) => { + if (item === this) { + this.swipeaction.children.splice(index, 1) + } + }) + }, + methods: { + init() { + + setTimeout(() => { + this.getSize() + this.getButtonSize() + }, 50) + }, + closeSwipe(e) { + if (!this.autoClose) return + this.swipeaction.closeOther(this) + }, + + change(e) { + this.$emit('change', e.open) + let valueObj = this.position[0] + if (valueObj.show !== e.open) { + valueObj.show = e.open + this.$set(this.position, 0, valueObj) + } + }, + onClick(index, item) { + this.$emit('click', { + content: item, + index + }) + }, + appTouchStart(){}, + appTouchEnd(){}, + getSize() { + const views = uni.createSelectorQuery().in(this) + views + .selectAll('.selector-query-hock') + .boundingClientRect(data => { + if (this.autoClose) { + data[0].show = false + } else { + data[0].show = this.show + } + this.position = data + }) + .exec() + }, + getButtonSize() { + const views = uni.createSelectorQuery().in(this) + views + .selectAll('.button-hock') + .boundingClientRect(data => { + this.button = data + }) + .exec() + } + } +} diff --git a/src/components/uni-swipe-action-item/uni-swipe-action-item.vue b/src/components/uni-swipe-action-item/uni-swipe-action-item.vue new file mode 100644 index 0000000..af962d6 --- /dev/null +++ b/src/components/uni-swipe-action-item/uni-swipe-action-item.vue @@ -0,0 +1,270 @@ + + + + diff --git a/src/components/uni-swipe-action/uni-swipe-action.vue b/src/components/uni-swipe-action/uni-swipe-action.vue new file mode 100644 index 0000000..c8b656c --- /dev/null +++ b/src/components/uni-swipe-action/uni-swipe-action.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/src/pages.json b/src/pages.json index fd12ba6..9d390cd 100644 --- a/src/pages.json +++ b/src/pages.json @@ -21,7 +21,8 @@ "path": "pages/famousArts/artistList", "style": { "navigationBarTitleText": "文艺名家", - "enablePullDownRefresh": false + "enablePullDownRefresh": true, + "onReachBottomDistance": 20 } }, { @@ -561,6 +562,24 @@ } ], + "subPackages":[ + { + "root": "pagesA/", + "pages": [{ + "path": "msgTalk/msgTalk", + "style": { + "navigationBarTitleText": "我的消息" + } + }, + { + "path": "talkPage/talkPage", + "style": { + "navigationBarTitleText": "消息" + } + } + ] + } + ], "globalStyle": { "navigationBarTitleText": "艺象心", "navigationBarTextStyle": "black", //导航栏标题颜色及状态栏前景颜色,仅支持 black/white diff --git a/src/pages/PolicyExpress/PolicyExpress.vue b/src/pages/PolicyExpress/PolicyExpress.vue index e696406..3a9e3e7 100644 --- a/src/pages/PolicyExpress/PolicyExpress.vue +++ b/src/pages/PolicyExpress/PolicyExpress.vue @@ -19,7 +19,28 @@ }; }, + onLoad() { + this.getData() + }, methods:{ + getData(){ + let _this = this + this.http.request('/policy/list', {}, "GET").then(res => { + if (res.code == 200) { + + // res.data.forEach(function(item) { + // _this.list.push(item.imagePath) + // }) + // this.load = false + // this.getEnjoy() + } + }).catch(e => { + uni.showToast({ + title: e.data.message, + icon: "none", + }); + }) + }, toDetail(val){ uni.navigateTo({ url: "/pages/PolicyExpress/PolicyExpressDetail?id=" + val diff --git a/src/pages/PublishWorks/PublishWorks.vue b/src/pages/PublishWorks/PublishWorks.vue index df4ffa1..14267f2 100644 --- a/src/pages/PublishWorks/PublishWorks.vue +++ b/src/pages/PublishWorks/PublishWorks.vue @@ -50,7 +50,7 @@ - + 作品内容可上传图片(png/jpg/jpeg/bmp/gif/tif/tiff)或pdf diff --git a/src/pages/famousArts/artistList.vue b/src/pages/famousArts/artistList.vue index 4decfb6..aaa0017 100644 --- a/src/pages/famousArts/artistList.vue +++ b/src/pages/famousArts/artistList.vue @@ -23,6 +23,8 @@ return { load: true, writerList: [], + pages: 1, + size: 20, }; }, onReady() { @@ -37,23 +39,43 @@ // #endif }, onShow() { + this.pages = 1 + this.writerList = [] this.getArtist() }, + // 下拉刷新 + onPullDownRefresh() { + this.pages = 1 + this.writerList = [] + this.getArtist() + setTimeout(function() { + uni.stopPullDownRefresh(); + }, 1000); + }, + //上拉 + onReachBottom() { + this.pages++ + this.getArtist(); + }, methods: { getArtist(){ let _this = this - this.http.request('/indexImage/artists', {}, "GET").then(res => { + this.http.request('/indexImage/artists', {page:this.pages,size:this.size}, "GET").then(res => { if (res.code == 200) { - res.data.forEach(function(item) { - if (item.images != undefined) { - let img = JSON.parse(item.images) - item.images = img[0] - } - }) - this.writerList = res.data - console.log(this.writerList) + if(res.data.records.length > 0){ + res.data.records.forEach(function(item) { + if (item.images) { + let img = JSON.parse(item.images) + item.images = img[0] + }else{ + item.images = '../../static/txIcon.png' + } + _this.writerList.push(item) + }) + }else{ + this.pages-- + } this.load = false - // this.getEnjoy() } }).catch(e => { uni.showToast({ diff --git a/src/pages/famousArts/famousArts.vue b/src/pages/famousArts/famousArts.vue index 4b77997..5075c35 100644 --- a/src/pages/famousArts/famousArts.vue +++ b/src/pages/famousArts/famousArts.vue @@ -38,7 +38,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -65,7 +65,7 @@ - + @@ -117,25 +117,28 @@ let _this = this this.http.request('/indexImage/artistsDetails', {id:this.userId}, "GET").then(res => { if (res.code == 200) { - console.log(res.data) - if (res.data.images != undefined) { + if (res.data.images) { let img = JSON.parse(res.data.images) _this.userImg = img[0] + }else{ + _this.userImg = '../../static/txIcon.png' } //成就 - if (res.data.artAtt != undefined) { + if (res.data.artAtt) { let art = JSON.parse(res.data.artAtt) _this.achievement = art } //荣誉 - if (res.data.greats != undefined) { + if (res.data.greats) { let great = JSON.parse(res.data.greats) _this.honor = great } //代表作 - if (res.data.opus != undefined) { + if (res.data.opus) { let opu = JSON.parse(res.data.opus) _this.represe = opu + }else{ + _this.represe = [] } this.userName = res.data.userName this.load = false diff --git a/src/pages/my/My.vue b/src/pages/my/My.vue index 434e5af..1013ea2 100644 --- a/src/pages/my/My.vue +++ b/src/pages/my/My.vue @@ -13,11 +13,17 @@ {{userName}} - - - - - + + + + + + + + + + + @@ -111,7 +117,7 @@ - + 消息 @@ -280,6 +286,12 @@ uni.navigateTo({ url: "/pages/my/logOut" }) + }, + // 消息 + myNews(){ + uni.navigateTo({ + url: "/pagesA/msgTalk/msgTalk" + }) } } } @@ -296,7 +308,7 @@ } .top { - height: 280rpx; + height: 180rpx; border: 1px solid transparent; position: relative; @@ -307,14 +319,14 @@ box-sizing: border-box; position: absolute; bottom: 0px; - height: 80px; + height: 160rpx; border: 1px solid transparent; width: 100%; - padding: 2px 16px; + padding: 4rpx 32rpx; .tou { - width: 72px; - height: 72px; + width: 144rpx; + height: 144rpx; border: 1px solid transparent; border-radius: 50%; overflow: hidden; @@ -322,29 +334,40 @@ .user_name { flex-grow: 1; - margin-left: 12px; + margin-left: 24rpx; .user_name_de { color: #251B1D; font-size: 40rpx; font-weight: 600; - .sf_text { - width: 180rpx; - height: 56rpx; + .sf_textA { + width: 146rpx; + height: 48rpx; + margin-top: 12rpx; + } + .sf_textB { + width: 166rpx; + height: 48rpx; + margin-top: 12rpx; + } + .sf_textC { + width: 186rpx; + height: 48rpx; + margin-top: 16rpx; } } .words { - margin-top: 8px; + margin-top: 16rpx; color: #AFADB0; - font-size: 12px; + font-size: 24rpx; } } .arrow { - width: 24px; - height: 24px; + width: 48rpx; + height: 48rpx; } } @@ -352,14 +375,15 @@ .content_area { - padding: 0 16px; - margin-bottom: 60px; + padding: 0 32rpx; + margin-bottom: 120rpx; + margin-top: 20rpx; .fans_box { display: flex; justify-content: space-around; align-items: center; - height: 80px; + height: 160rpx; border: 1px solid transparent; border-radius: 8px; background-color: #FFFFFF; @@ -374,56 +398,55 @@ .itms_name { color: #AFADB0; - font-size: 12px; - margin-top: 8px; + font-size: 24rpx; + margin-top: 16rpx; } } } .jifen_box { - - padding: 16px 0px; + padding: 32rpx 0px; display: flex; justify-content: space-between; align-items: center; .jifen_box_itm { box-sizing: border-box; - padding: 12px; + padding: 24rpx; display: flex; - width: 166px; - height: 68px; + width: 332rpx; + height: 136rpx; background-color: #FFFFFF; border-radius: 8px; .ji_ico { - width: 22px; - height: 22px; + width: 44rpx; + height: 44rpx; border-radius: 50%; overflow: hidden; } .ji_word_box { - margin-left: 8px; + margin-left: 16rpx; .ji_word_title { - font-size: 14px; + font-size: 28rpx; color: #251B1D; font-weight: 600; } .ji_con { color: #AFADB0; - font-size: 12px; + font-size: 24rpx; font-weight: 400; - margin-top: 4px; + margin-top: 8rpx; } } } } .content_bott { - padding: 16px; + padding: 32rpx; background-color: #FFFFFF; border-radius: 8px; @@ -431,17 +454,17 @@ display: flex; justify-content: space-between; align-items: center; - margin: 26px 0px; + margin: 52rpx 0px; .content_bott_wods { - font-size: 14px; + font-size: 28rpx; color: #251B1D; font-weight: 600; } .content_bott_arrow { - width: 16px; - height: 16px; + width: 32rpx; + height: 32rpx; } } } diff --git a/src/pages/orderHall/addOrder.vue b/src/pages/orderHall/addOrder.vue index fc76f24..df42c9a 100644 --- a/src/pages/orderHall/addOrder.vue +++ b/src/pages/orderHall/addOrder.vue @@ -50,24 +50,27 @@ 截止时间 - - + + 活动时间 - - + + - + + 接单设置 @@ -215,9 +218,9 @@ }, sureTime(e) { if (this.timeTab == 0) { - this.eTime = uni.$u.timeFormat(e.value) + this.eTime = uni.$u.timeFormat(e.value,'yyyy-mm-dd hh:MM') } else { - this.wTime = uni.$u.timeFormat(e.value) + this.wTime = uni.$u.timeFormat(e.value,'yyyy-mm-dd hh:MM') } this.showTime = false }, @@ -329,7 +332,7 @@ } if(this.eTime == ''){ uni.showToast({ - title: '请选择截止时间', + title: '请选择截止日期', icon: "none", }); this.ok = false @@ -337,7 +340,23 @@ } if(this.wTime == ''){ uni.showToast({ - title: '请请选择活动时间', + title: '请选择活动日期', + icon: "none", + }); + this.ok = false + return + } + if(this.eTime.length < 12){ + uni.showToast({ + title: '请选择截止时间', + icon: "none", + }); + this.ok = false + return + } + if(this.wTime.length < 12){ + uni.showToast({ + title: '请选择活动时间', icon: "none", }); this.ok = false @@ -412,7 +431,18 @@ } + + diff --git a/src/pagesA/talkPage/talkPage.vue b/src/pagesA/talkPage/talkPage.vue new file mode 100644 index 0000000..1f5eb9c --- /dev/null +++ b/src/pagesA/talkPage/talkPage.vue @@ -0,0 +1,1825 @@ + + + + + diff --git a/src/request/interface.js b/src/request/interface.js index 4877534..d1b2974 100644 --- a/src/request/interface.js +++ b/src/request/interface.js @@ -7,7 +7,7 @@ export default { config: { // baseUrl: "http://192.168.0.57:8080/h5/api", //王锡 // baseUrl: "http://192.168.124.110:8088/api", //周源 - // baseUrl: "http://10.0.0.78:8080/h5/api", //俞燕红 + // baseUrl: "http://10.0.0.48:8080/h5/api", //俞燕红 baseUrl: "https://yxx.ydool.net/h5/api", //线上 header: { 'Content-Type': 'application/json;charset=UTF-8', diff --git a/src/static/nogoods.png b/src/static/nogoods.png new file mode 100644 index 0000000..7e859a2 Binary files /dev/null and b/src/static/nogoods.png differ diff --git a/src/static/play.png b/src/static/play.png new file mode 100644 index 0000000..918f505 Binary files /dev/null and b/src/static/play.png differ diff --git a/src/static/talk/add.png b/src/static/talk/add.png new file mode 100644 index 0000000..a973799 Binary files /dev/null and b/src/static/talk/add.png differ diff --git a/src/static/talk/close.png b/src/static/talk/close.png new file mode 100644 index 0000000..aac1737 Binary files /dev/null and b/src/static/talk/close.png differ diff --git a/src/static/talk/cyy.png b/src/static/talk/cyy.png new file mode 100644 index 0000000..f3a9db0 Binary files /dev/null and b/src/static/talk/cyy.png differ diff --git a/src/static/talk/dg.png b/src/static/talk/dg.png new file mode 100644 index 0000000..ce71ef7 Binary files /dev/null and b/src/static/talk/dg.png differ diff --git a/src/static/talk/jp.png b/src/static/talk/jp.png new file mode 100644 index 0000000..026f9a5 Binary files /dev/null and b/src/static/talk/jp.png differ diff --git a/src/static/talk/myt.png b/src/static/talk/myt.png new file mode 100644 index 0000000..51157aa Binary files /dev/null and b/src/static/talk/myt.png differ diff --git a/src/static/talk/push.png b/src/static/talk/push.png new file mode 100644 index 0000000..589319a Binary files /dev/null and b/src/static/talk/push.png differ diff --git a/src/static/talk/t1.png b/src/static/talk/t1.png new file mode 100644 index 0000000..cfa6ea3 Binary files /dev/null and b/src/static/talk/t1.png differ diff --git a/src/static/talk/t2.png b/src/static/talk/t2.png new file mode 100644 index 0000000..04b5374 Binary files /dev/null and b/src/static/talk/t2.png differ diff --git a/src/static/talk/t3.png b/src/static/talk/t3.png new file mode 100644 index 0000000..555680d Binary files /dev/null and b/src/static/talk/t3.png differ diff --git a/src/static/talk/t4.png b/src/static/talk/t4.png new file mode 100644 index 0000000..0442ddf Binary files /dev/null and b/src/static/talk/t4.png differ diff --git a/src/static/talk/t5.png b/src/static/talk/t5.png new file mode 100644 index 0000000..30cb687 Binary files /dev/null and b/src/static/talk/t5.png differ diff --git a/src/static/talk/talk.png b/src/static/talk/talk.png new file mode 100644 index 0000000..3be6679 Binary files /dev/null and b/src/static/talk/talk.png differ diff --git a/src/static/talk/tt.png b/src/static/talk/tt.png new file mode 100644 index 0000000..b84c3e7 Binary files /dev/null and b/src/static/talk/tt.png differ diff --git a/src/static/txIcon.png b/src/static/txIcon.png new file mode 100644 index 0000000..9ad10e8 Binary files /dev/null and b/src/static/txIcon.png differ diff --git a/src/uni.scss b/src/uni.scss index a653d83..ab26a5f 100644 --- a/src/uni.scss +++ b/src/uni.scss @@ -12,6 +12,7 @@ * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 */ @import 'uview-ui/theme.scss'; +@import "uview-ui/index.scss"; /* 颜色变量 */ $red:#99241B; $black:#251B1D; diff --git a/src/uni_modules/uni-datetime-picker/changelog.md b/src/uni_modules/uni-datetime-picker/changelog.md new file mode 100644 index 0000000..5c9735a --- /dev/null +++ b/src/uni_modules/uni-datetime-picker/changelog.md @@ -0,0 +1,93 @@ +## 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/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/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar-item.vue b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar-item.vue new file mode 100644 index 0000000..3d2dbea --- /dev/null +++ b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar-item.vue @@ -0,0 +1,185 @@ + + + + + diff --git a/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue new file mode 100644 index 0000000..8f7f181 --- /dev/null +++ b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue @@ -0,0 +1,907 @@ + + + + + diff --git a/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/en.json b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/en.json new file mode 100644 index 0000000..9acf1ab --- /dev/null +++ b/src/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 datetime", + "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/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js new file mode 100644 index 0000000..de7509c --- /dev/null +++ b/src/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/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hans.json b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hans.json new file mode 100644 index 0000000..d2df5e7 --- /dev/null +++ b/src/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/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hant.json b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hant.json new file mode 100644 index 0000000..d23fa3c --- /dev/null +++ b/src/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/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/keypress.js b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/keypress.js new file mode 100644 index 0000000..9601aba --- /dev/null +++ b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/keypress.js @@ -0,0 +1,45 @@ +// #ifdef H5 +export default { + name: 'Keypress', + props: { + disable: { + type: Boolean, + default: false + } + }, + mounted () { + const keyNames = { + esc: ['Esc', 'Escape'], + tab: 'Tab', + enter: 'Enter', + space: [' ', 'Spacebar'], + up: ['Up', 'ArrowUp'], + left: ['Left', 'ArrowLeft'], + right: ['Right', 'ArrowRight'], + down: ['Down', 'ArrowDown'], + delete: ['Backspace', 'Delete', 'Del'] + } + const listener = ($event) => { + if (this.disable) { + return + } + const keyName = Object.keys(keyNames).find(key => { + const keyName = $event.key + const value = keyNames[key] + return value === keyName || (Array.isArray(value) && value.includes(keyName)) + }) + if (keyName) { + // 避免和其他按键事件冲突 + setTimeout(() => { + this.$emit(keyName, {}) + }, 0) + } + } + document.addEventListener('keyup', listener) + this.$once('hook:beforeDestroy', () => { + document.removeEventListener('keyup', listener) + }) + }, + render: () => {} +} +// #endif \ No newline at end of file diff --git a/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/time-picker.vue b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/time-picker.vue new file mode 100644 index 0000000..699aa63 --- /dev/null +++ b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/time-picker.vue @@ -0,0 +1,927 @@ + + + + + diff --git a/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue new file mode 100644 index 0000000..9bdf8bc --- /dev/null +++ b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue @@ -0,0 +1,1012 @@ + + + + diff --git a/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js new file mode 100644 index 0000000..efa5773 --- /dev/null +++ b/src/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js @@ -0,0 +1,410 @@ +class Calendar { + constructor({ + date, + selected, + startDate, + endDate, + range, + // multipleStatus + } = {}) { + // 当前日期 + this.date = this.getDate(new Date()) // 当前初入日期 + // 打点信息 + this.selected = selected || []; + // 范围开始 + this.startDate = startDate + // 范围结束 + this.endDate = endDate + this.range = range + // 多选状态 + this.cleanMultipleStatus() + // 每周日期 + this.weeks = {} + // this._getWeek(this.date.fullDate) + // this.multipleStatus = multipleStatus + this.lastHover = false + } + /** + * 设置日期 + * @param {Object} date + */ + setDate(date) { + this.selectDate = this.getDate(date) + this._getWeek(this.selectDate.fullDate) + } + + /** + * 清理多选状态 + */ + cleanMultipleStatus() { + this.multipleStatus = { + before: '', + after: '', + data: [] + } + } + + /** + * 重置开始日期 + */ + resetSatrtDate(startDate) { + // 范围开始 + this.startDate = startDate + + } + + /** + * 重置结束日期 + */ + resetEndDate(endDate) { + // 范围结束 + this.endDate = endDate + } + + /** + * 获取任意时间 + */ + getDate(date, AddDayCount = 0, str = 'day') { + if (!date) { + date = new Date() + } + if (typeof date !== 'object') { + date = date.replace(/-/g, '/') + } + const dd = new Date(date) + switch (str) { + case 'day': + dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期 + break + case 'month': + if (dd.getDate() === 31) { + dd.setDate(dd.getDate() + AddDayCount) + } else { + dd.setMonth(dd.getMonth() + AddDayCount) // 获取AddDayCount天后的日期 + } + break + case 'year': + dd.setFullYear(dd.getFullYear() + AddDayCount) // 获取AddDayCount天后的日期 + break + } + const y = dd.getFullYear() + const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0 + const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0 + return { + fullDate: y + '-' + m + '-' + d, + year: y, + month: m, + date: d, + day: dd.getDay() + } + } + + + /** + * 获取上月剩余天数 + */ + _getLastMonthDays(firstDay, full) { + let dateArr = [] + for (let i = firstDay; i > 0; i--) { + const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate() + dateArr.push({ + date: beforeDate, + month: full.month - 1, + disable: true + }) + } + return dateArr + } + /** + * 获取本月天数 + */ + _currentMonthDys(dateData, full) { + let dateArr = [] + let fullDate = this.date.fullDate + for (let i = 1; i <= dateData; i++) { + let isinfo = false + let nowDate = full.year + '-' + (full.month < 10 ? + full.month : full.month) + '-' + (i < 10 ? + '0' + i : i) + // 是否今天 + let isDay = fullDate === nowDate + // 获取打点信息 + let info = this.selected && this.selected.find((item) => { + if (this.dateEqual(nowDate, item.date)) { + return item + } + }) + + // 日期禁用 + let disableBefore = true + let disableAfter = true + if (this.startDate) { + // let dateCompBefore = this.dateCompare(this.startDate, fullDate) + // disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate) + disableBefore = this.dateCompare(this.startDate, nowDate) + } + + if (this.endDate) { + // let dateCompAfter = this.dateCompare(fullDate, this.endDate) + // disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate) + disableAfter = this.dateCompare(nowDate, this.endDate) + } + let multiples = this.multipleStatus.data + let checked = false + let multiplesStatus = -1 + if (this.range) { + if (multiples) { + multiplesStatus = multiples.findIndex((item) => { + return this.dateEqual(item, nowDate) + }) + } + if (multiplesStatus !== -1) { + checked = true + } + } + let data = { + fullDate: nowDate, + year: full.year, + date: i, + multiple: this.range ? checked : false, + beforeMultiple: this.isLogicBefore(nowDate, this.multipleStatus.before, this.multipleStatus.after), + afterMultiple: this.isLogicAfter(nowDate, this.multipleStatus.before, this.multipleStatus.after), + month: full.month, + disable: !(disableBefore && disableAfter), + isDay, + userChecked: false + } + if (info) { + data.extraInfo = info + } + + dateArr.push(data) + } + return dateArr + } + /** + * 获取下月天数 + */ + _getNextMonthDays(surplus, full) { + let dateArr = [] + for (let i = 1; i < surplus + 1; i++) { + dateArr.push({ + date: i, + month: Number(full.month) + 1, + disable: true + }) + } + return dateArr + } + + /** + * 获取当前日期详情 + * @param {Object} date + */ + getInfo(date) { + if (!date) { + date = new Date() + } + const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate) + return dateInfo + } + + /** + * 比较时间大小 + */ + dateCompare(startDate, endDate) { + // 计算截止时间 + startDate = new Date(startDate.replace('-', '/').replace('-', '/')) + // 计算详细项的截止时间 + endDate = new Date(endDate.replace('-', '/').replace('-', '/')) + if (startDate <= endDate) { + return true + } else { + return false + } + } + + /** + * 比较时间是否相等 + */ + dateEqual(before, after) { + // 计算截止时间 + before = new Date(before.replace('-', '/').replace('-', '/')) + // 计算详细项的截止时间 + after = new Date(after.replace('-', '/').replace('-', '/')) + if (before.getTime() - after.getTime() === 0) { + return true + } else { + return false + } + } + + /** + * 比较真实起始日期 + */ + + isLogicBefore(currentDay, before, after) { + let logicBefore = before + if (before && after) { + logicBefore = this.dateCompare(before, after) ? before : after + } + return this.dateEqual(logicBefore, currentDay) + } + + isLogicAfter(currentDay, before, after) { + let logicAfter = after + if (before && after) { + logicAfter = this.dateCompare(before, after) ? after : before + } + return this.dateEqual(logicAfter, currentDay) + } + + /** + * 获取日期范围内所有日期 + * @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.getDate(new Date(parseInt(k))).fullDate) + } + return arr + } + + /** + * 获取多选状态 + */ + setMultiple(fullDate) { + let { + before, + after + } = this.multipleStatus + if (!this.range) return + 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 (this.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._getWeek(fullDate) + } + + /** + * 鼠标 hover 更新多选状态 + */ + setHoverMultiple(fullDate) { + let { + before, + after + } = this.multipleStatus + + if (!this.range) return + if (this.lastHover) return + + if (!before) { + this.multipleStatus.before = fullDate + } else { + this.multipleStatus.after = fullDate + if (this.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._getWeek(fullDate) + } + + /** + * 更新默认值多选状态 + */ + setDefaultMultiple(before, after) { + this.multipleStatus.before = before + this.multipleStatus.after = after + if (before && after) { + if (this.dateCompare(before, after)) { + this.multipleStatus.data = this.geDateAll(before, after); + this._getWeek(after) + } else { + this.multipleStatus.data = this.geDateAll(after, before); + this._getWeek(before) + } + } + } + + /** + * 获取每周数据 + * @param {Object} dateData + */ + _getWeek(dateData) { + const { + fullDate, + year, + month, + date, + day + } = this.getDate(dateData) + let firstDay = new Date(year, month - 1, 1).getDay() + let currentDay = new Date(year, month, 0).getDate() + let dates = { + lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天 + currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数 + nextMonthDays: [], // 下个月开始几天 + weeks: [] + } + let canlender = [] + const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length) + dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData)) + canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays) + let weeks = {} + // 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天 + for (let i = 0; i < canlender.length; i++) { + if (i % 7 === 0) { + weeks[parseInt(i / 7)] = new Array(7) + } + weeks[parseInt(i / 7)][i % 7] = canlender[i] + } + this.canlender = canlender + this.weeks = weeks + } + + //静态方法 + // static init(date) { + // if (!this.instance) { + // this.instance = new Calendar(date); + // } + // return this.instance; + // } +} + + +export default Calendar diff --git a/src/uni_modules/uni-datetime-picker/package.json b/src/uni_modules/uni-datetime-picker/package.json new file mode 100644 index 0000000..60fa1d0 --- /dev/null +++ b/src/uni_modules/uni-datetime-picker/package.json @@ -0,0 +1,90 @@ +{ + "id": "uni-datetime-picker", + "displayName": "uni-datetime-picker 日期选择器", + "version": "2.2.6", + "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": { + "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", + "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/src/uni_modules/uni-datetime-picker/readme.md b/src/uni_modules/uni-datetime-picker/readme.md new file mode 100644 index 0000000..162fbef --- /dev/null +++ b/src/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/src/utils/utils.js b/src/utils/utils.js index 1c06ed6..0b26b3d 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1,6 +1,648 @@ //返回 -function navigateBackFun(){ - uni.navigateBack(); +// function navigateBackFun(){ +// uni.navigateBack(); +// } +export default { + isNotANumber(inputData) { + if (!inputData) { + return false + } + //isNaN(inputData)不能判断空串或一个空格 + //如果是一个空串或是一个空格,而isNaN是做为数字0进行处理的,而parseInt与parseFloat是返回一个错误消息,这个isNaN检查不严密而导致的。 + if (parseFloat(inputData).toString() == "NaN") { + //alert(“请输入数字……”); + return false; + } else { + if (inputData > 0) { + return true; + } else { + return false + } + } + }, + //无图标toast + toast(title) { + uni.showToast({ + title, + icon: 'none', + mask: true, + duration: 2000 + }); + }, + //验证手机号码部分 + chickPhone(phone) { + if (phone.length == 11) { + return true + } else { + return false + } + // let reg = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/; + // //var url="/nptOfficialWebsite/apply/sendSms?mobile="+this.ruleForm.phone; + // if (!phone) { + // return false + // } else if (!reg.test(phone)) { + // return false + // } else { + // return true + // } + }, + formatTime(data) { + if (!data) return '' + let dataArray = data.split(':') + let date0 = dataArray['0'].split('T') + let date1 = dataArray['1'] + return date0[1] + ':' + date1 + }, + toLogin() { + // #ifdef MP-WEIXIN + uni.navigateTo({ + url: "/pages/login/wxLogin/wxLogin" + }) + // #endif + + // #ifndef MP-WEIXIN + uni.navigateTo({ + url: "/pages/login/pasLogin/pasLogin" + }) + // #endif + }, + toastNoIcon(title) { + uni.showToast({ + title: title, + icon: "none", + duration: 2000 + }); + }, + showMyLoading(title = "加载中", mask = true) { + uni.showLoading({ + title, + mask + }) + }, + getTodayYMD() { + let myDate = new Date() + let year = myDate.getFullYear(); //获取完整的年份(4位,1970-????) + let month = myDate.getMonth(); //获取当前月份(0-11,0代表1月) + let date = myDate.getDate(); //获取当前日(1-31) + return `${year}-${month+1}-${date}` + }, + + /** + * 处理富文本里的图片宽度自适应 + * 1.去掉img标签里的style、width、height属性 + * 2.img标签添加style属性:max-width:100%;height:auto + * 3.修改所有style里的width属性为max-width:100% + * 4.去掉
标签 + * @param html + * @returns {void|string|*} + */ + formatRichText(html) { + let newContent = html.replace(/]*>/gi, function(match, capture) { + match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, ''); + match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, ''); + match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, ''); + return match; + }); + newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) { + match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, 'max-width:100%;'); + return match; + }); + newContent = newContent.replace(/]*\/>/gi, ''); + newContent = newContent.replace(/\/g, '/div>'); + let isCms = 'isCMS' + newContent = newContent.split(isCms)[0] + return newContent; + }, + hideMyLoading() { + try { + uni.hideLoading() + } catch (e) { + + } + }, + upLoadImg(filePath, successfn, type = 1) { + // console.log(filePath,"filePath") + // console.log(successfn,"successfn") + uni.uploadFile({ + url: 'https://api.ghniu.com/upload/file/img/account', //仅为示例,非真实的接口地址 + filePath: filePath, + name: 'files', + formData: { + type + }, + success: (uploadFileRes) => { + // console.log(uploadFileRes,"uploadFileRes") + if (uploadFileRes.statusCode != 200) { + this.toast("上传失败") + return + } + if (JSON.parse(uploadFileRes.data).code != "0") { + this.toast("上传失败") + return + } + successfn(JSON.parse(uploadFileRes.data).data[0]) + } + }); + }, + myBackPage(time = 1500) { + setTimeout(() => { + uni.navigateBack() + }, time) + }, + toGoodsInfo(type, id) { + switch (type) { + //普通 + case 1: + uni.navigateTo({ + url: "/pages/goodsInfo/type12Info/type12Info?goodsid=" + id + }) + break; + //大众 + case 2: + uni.navigateTo({ + url: "/pages/goodsInfo/type12Info/type12Info?goodsid=" + id + }) + break; + //服务 + case 3: + uni.navigateTo({ + url: "/pagesA/service/info/info?id=" + id + }) + break; + //汽车 + case 4: + uni.navigateTo({ + url: "/pages/car/info/info?goodsid=" + id + }) + break; + //司机 + case 5: + uni.navigateTo({ + url: "/pagesA/driver/info/info?id=" + id + }) + break; + default: + break; + } + }, + wxMinShare(imageUrl, title, path) { + this.toast("需要小程序先上架才可以分享") + return + console.log(imageUrl) + uni.share({ + provider: 'weixin', + scene: "WXSceneSession", + type: 5, + imageUrl, + title, + miniProgram: { + id: 'wx902fccb81a579f91', + path, + type: 0, + webUrl: 'https://hdc.nbjice.com' + }, + success: ret => { + console.log(JSON.stringify(ret)); + } + }); + }, + toFLList(item) { + const type = item.classType + switch (type) { + case 1: + uni.navigateTo({ + url: "/pages/tabbar-2/classify/classify?threeId=" + item.threeId + "&name=" + item.name + "&oneId=" + item.oneId + + "&twoId=" + item.twoId + "&type=" + type + }) + break; + case 2: + uni.navigateTo({ + url: "/pages/tabbar-2/classify/classify?threeId=" + item.threeId + "&name=" + item.name + "&oneId=" + item.oneId + + "&twoId=" + item.twoId + "&type=" + type + }) + break; + case 3: + uni.setStorageSync("icoImg", item.icoImg) + uni.navigateTo({ + url: "/pages/car/home/home?threeId=" + item.threeId + "&name=" + item.name + "&oneId=" + item.oneId + }) + break; + case 4: + uni.navigateTo({ + url: "/pagesA/service/list/list?threeId=" + item.threeId + "&name=" + item.name + }) + break; + default: + break; + } + }, + bannerClick(item) { + // banner类型(1外链 2.商品列表 3.商品详情 4.个人中心)/ + switch (item.bannerType) { + case -1: + this.toast("该商品或分类已删除") + return + break; + case 1: + uni.setStorageSync("webviewUrl", item.externalUrl) + uni.navigateTo({ + url: "/pages/webview/webview" + }) + break; + case 2: + if (item.classType == 4) { + uni.navigateTo({ + url: "/pagesA/service/sclass/sclass" + }) + + } else { + uni.navigateTo({ + url: "/pages/tabbar/tabbar-1/classinfo/classinfo?className=" + item.className + "&id=" + item.objectKey + + "&name=" + item.name + "&classType=" + item.classType + }) + } + break; + case 3: + this.toGoodsInfo(item.type, item.objectKey) + break; + case 4: + //店铺首页 + uni.navigateTo({ + url: "/pages/shop/home/home?id=" + item.objectKey + }) + break; + case 5: + this.toFLList(item) + break; + default: + break; + } + }, + checkLocToken() { + if (uni.getStorageSync("token")) { + return true + } else { + uni.showModal({ + title: '提示', + confirmText: "去登录", + confirmColor: "#f56e5d", + cancelText: "取消", + content: '登录后才能使用该功能~', + success: (res) => { + if (res.confirm) { + this.toLogin() + } else if (res.cancel) { + console.log('用户点击取消'); + } + } + }); + return false + } + }, + //加法函数 + accAdd(arg1, arg2) { + var r1, r2, m, c; + try { + r1 = arg1.toString().split(".")[1].length; + } catch (e) { + r1 = 0; + } + try { + r2 = arg2.toString().split(".")[1].length; + } catch (e) { + r2 = 0; + } + c = Math.abs(r1 - r2); + m = Math.pow(10, Math.max(r1, r2)); + if (c > 0) { + var cm = Math.pow(10, c); + if (r1 > r2) { + arg1 = Number(arg1.toString().replace(".", "")); + arg2 = Number(arg2.toString().replace(".", "")) * cm; + } else { + arg1 = Number(arg1.toString().replace(".", "")) * cm; + arg2 = Number(arg2.toString().replace(".", "")); + } + } else { + arg1 = Number(arg1.toString().replace(".", "")); + arg2 = Number(arg2.toString().replace(".", "")); + } + return (arg1 + arg2) / m; + }, + //减法函数 + accSub(arg1, arg2) { + var r1, r2, m, n; + try { + r1 = arg1.toString().split(".")[1].length; + } catch (e) { + r1 = 0; + } + try { + r2 = arg2.toString().split(".")[1].length; + } catch (e) { + r2 = 0; + } + m = Math.pow(10, Math.max(r1, r2)); //last modify by deeka //动态控制精度长度 + n = (r1 >= r2) ? r1 : r2; + return ((arg1 * m - arg2 * m) / m).toFixed(n); + }, + /** + ** 乘法函数,用来得到精确的乘法结果 + ** 说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。 + ** 调用:accMul(arg1,arg2) + ** 返回值:arg1乘以 arg2的精确结果 + **/ + accMul(arg1, arg2) { + + var m = 0, + s1 = arg1.toString(), + s2 = arg2.toString(); + try { + m += s1.split(".")[1].length; + } catch (e) {} + try { + m += s2.split(".")[1].length; + } catch (e) {} + console.log(s1) + return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m); + }, + //除法函数 + accDiv(arg1, arg2) { + var t1 = 0, + t2 = 0, + r1, r2; + try { + t1 = arg1.toString().split(".")[1].length; + } catch (e) {} + try { + t2 = arg2.toString().split(".")[1].length; + } catch (e) {} + r1 = Number(arg1.toString().replace(".", "")); + r2 = Number(arg2.toString().replace(".", "")); + return (r1 / r2) * Math.pow(10, t2 - t1); + }, + getSence(data) { + let a = data.split(",") + console.log(a) + let obj = {} + a.forEach(item => { + let sp = item.split(":") + obj[sp[0]] = sp[1] + }) + return obj + }, + getShowOrHide(state) { + switch (state) { + case 0: + return false + break; + case 1: + return true + break; + case 2: + return true + break; + case 3: + return true + break; + case 4: + return true + break; + case 5: + return true + break; + case 6: + return false + break; + case 7: + return false + break; + case 8: + return true + break; + default: + break; + } + }, + getSellShowOrHide(state) { + switch (state) { + case 0: + return false + break; + case 1: + return false + break; + case 2: + return true + break; + case 3: + return false + break; + case 4: + return false + break; + case 5: + return false + break; + case 6: + return true + break; + case 7: + return false + break; + case 8: + return false + break; + default: + break; + } + }, + getBtn1ShowOrHide(state) { + switch (state) { + case 0: + return false + break; + case 1: + return true + break; + case 2: + return true + break; + case 3: + return true + break; + case 4: + return true + break; + case 5: + return false + break; + case 6: + return false + break; + case 7: + return false + break; + case 8: + return true + break; + default: + break; + } + }, + getBtn2ShowOrHide(state) { + switch (state) { + case 0: + return false + break; + case 1: + return true + break; + case 2: + return true + break; + case 3: + return true + break; + case 4: + return true + break; + case 5: + return true + break; + case 6: + return false + break; + case 7: + return false + break; + case 8: + return true + break; + default: + break; + } + }, + getSellBtn1ShowOrHide(item) { + switch (item.state) { + case 0: + return false + break; + case 1: + return false + break; + case 2: + if (item.itemType == '3') { + return true + } else { + return false + } + return false + break; + case 3: + return false + break; + case 4: + return false + break; + case 5: + return false + break; + case 6: + return true + break; + case 7: + return false + break; + case 8: + return false + break; + default: + break; + } + }, + getSellBtn2ShowOrHide(state) { + switch (state) { + case 0: + return false + break; + case 1: + return false + break; + case 2: + return true + break; + case 3: + return false + break; + case 4: + return false + break; + case 5: + return false + break; + case 6: + return true + break; + case 7: + return false + break; + case 8: + return false + break; + default: + break; + } + }, + //保存图片到本地 + saveImgUtils(url) { + this.showMyLoading("保存中") + uni.downloadFile({ + url, + success: (res) => { + uni.saveImageToPhotosAlbum({ + filePath: res.tempFilePath, + success: (dres) => { + this.toast("图片已保存") + }, + fail: (err) => { + this.toast("保存失败,请检查系统权限") + } + }) + } + }) + }, + clearTokenSet() { + if (uni.getStorageSync("setin")) { + let setin = uni.getStorageSync("setin") + clearInterval(setin) + } + }, + toTalk(toId) { + if (this.checkLocToken()) { + uni.navigateTo({ + url: "/pages/im/talkPage/talkPage?toId=" + toId + }) + } + }, + chickCanSee(item) { + if (item.isMyself != 1 && item.state != 3) { + uni.showModal({ + title: '提示', + confirmText: "确定", + confirmColor: "#f56e5d", + showCancel: false, + content: '该商品已下架', + success: (res) => { + if (res.confirm) { + uni.navigateBack() + } + } + }); + } + } }