diff --git a/.eslintrc b/.eslintrc index 4e9c2ccb..bae0af3a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,7 +2,9 @@ "extends": "airbnb", "globals": { "getApp": false, + "getCurrentPages": false, "Page": false, + "Component": false, "App": false, "wx": false }, @@ -16,13 +18,7 @@ "vars-on-top": 0, "new-cap": 0, "no-used-var": 0, - "semi": [ - 1, - "always", - { - "omitLastInOneLineBlock": true - } - ], + "semi": [2, "always"], "camelcase": 1, "prefer-template": 0, "eqeqeq": 0, @@ -39,6 +35,9 @@ "no-underscore-dangle": 0, "no-use-before-define": 0, "no-new": 0, - "import/no-extraneous-dependencies": 0 + "no-multi-assign": 0, + "class-methods-use-this": 0, + "no-plusplus": 0, + "prefer-promise-reject-errors": 0 } } diff --git a/dist/cell/index.js b/dist/cell/index.js index 76b818f5..e9bdee4d 100644 --- a/dist/cell/index.js +++ b/dist/cell/index.js @@ -1,6 +1,59 @@ const warn = (msg, getValue) => { console.warn(msg) - return; + }; + +Component({ + options: { + multipleSlots: true + }, + relations: { + '../cell-group/index': { + type: 'parent' + } + }, + properties: { + title: { + type: String, + description: '左侧标题' + }, + label: { + type: String, + description: '标题下方的描述信息' + }, + value: { + type: String, + description: '右侧内容' + }, + onlyTapFooter: { + type: Boolean, + description: '只有点击 footer 区域才触发 tab 事件' + }, + isLink: { + type: null, + value: '', + description: '是否展示右侧箭头并开启尝试以 url 跳转' + }, + linkType: { + type: String, + value: 'navigateTo', + description: '链接类型,可选值为 navigateTo,redirectTo,switchTab,reLaunch' + }, + url: { + type: String, + value: '' + } + }, + data: { + isLastCell: true + }, + methods: { + navigateTo () { + const url = this.data.url + const type = typeof this.data.isLink + + this.triggerEvent('tap', {}) + + if (!this.data.isLink || !url || url === 'true' || url === 'false') return; if (type !== 'boolean' && type !== 'string') { warn('isLink 属性值必须是一个字符串或布尔值', this.data.isLink) diff --git a/package-lock.json b/package-lock.json index 4e28541a..4c06770b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,12 +14,12 @@ } }, "@babel/generator": { - "version": "7.0.0-beta.42", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.0.0-beta.42.tgz", - "integrity": "sha512-9x3zS4nG/6GAvJWB8fAK+5g/Di36xdubB43dMNSucNJTwPvmyfCippir/0I8zyG+ID66hLCLi8V9bomlWRYaHA==", + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.0.0-beta.44.tgz", + "integrity": "sha512-5xVb7hlhjGcdkKpMXgicAVgx8syK5VJz193k0i/0sLP6DzE6lRrU1K3B/rFefgdo9LPGMAOOOAWW4jycj07ShQ==", "dev": true, "requires": { - "@babel/types": "7.0.0-beta.42", + "@babel/types": "7.0.0-beta.44", "jsesc": "2.5.1", "lodash": "4.17.5", "source-map": "0.5.7", @@ -41,32 +41,32 @@ } }, "@babel/helper-function-name": { - "version": "7.0.0-beta.42", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.42.tgz", - "integrity": "sha512-6IZ+kkPypwJrnmNzI3y31qAps2kXoPtCE241SvBva2YzB0n/YORWx2YM0jHPYOJBU9Xx5KkUhOKuWkeXZQgtTA==", + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.44.tgz", + "integrity": "sha512-MHRG2qZMKMFaBavX0LWpfZ2e+hLloT++N7rfM3DYOMUOGCD8cVjqZpwiL8a0bOX3IYcQev1ruciT0gdFFRTxzg==", "dev": true, "requires": { - "@babel/helper-get-function-arity": "7.0.0-beta.42", - "@babel/template": "7.0.0-beta.42", - "@babel/types": "7.0.0-beta.42" + "@babel/helper-get-function-arity": "7.0.0-beta.44", + "@babel/template": "7.0.0-beta.44", + "@babel/types": "7.0.0-beta.44" } }, "@babel/helper-get-function-arity": { - "version": "7.0.0-beta.42", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.42.tgz", - "integrity": "sha512-hF5KKcn+V/5PwU7KZ1aVwo535woLC9eV+djaoyNPZeMMJ2s+8bZlEa66Tarei0T68VRL5LXIs1Ao4hSabSkpBg==", + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.44.tgz", + "integrity": "sha512-w0YjWVwrM2HwP6/H3sEgrSQdkCaxppqFeJtAnB23pRiJB5E/O9Yp7JAAeWBl+gGEgmBFinnTyOv2RN7rcSmMiw==", "dev": true, "requires": { - "@babel/types": "7.0.0-beta.42" + "@babel/types": "7.0.0-beta.44" } }, "@babel/helper-split-export-declaration": { - "version": "7.0.0-beta.42", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.42.tgz", - "integrity": "sha512-2r8pZG6SAJTTaI2OhxCmz5PKlMUPY5adOHrHtb1gM3ibJPDOzPAeOQNzItdxNnM33jjRakEGitXX6iYg7Sz73w==", + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.44.tgz", + "integrity": "sha512-aQ7QowtkgKKzPGf0j6u77kBMdUFVBKNHw2p/3HX/POt5/oz8ec5cs0GwlgM8Hz7ui5EwJnzyfRmkNF1Nx1N7aA==", "dev": true, "requires": { - "@babel/types": "7.0.0-beta.42" + "@babel/types": "7.0.0-beta.44" } }, "@babel/highlight": { @@ -81,47 +81,87 @@ } }, "@babel/template": { - "version": "7.0.0-beta.42", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.0.0-beta.42.tgz", - "integrity": "sha512-EK7YdTe47j4VxlwNvz5bnlk5Jx/wWublnqfgOY2IuSNdxCQgXrLD34PfTnabGxywNSkJkcSo6jwr2JGT+S48dA==", + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.0.0-beta.44.tgz", + "integrity": "sha512-w750Sloq0UNifLx1rUqwfbnC6uSUk0mfwwgGRfdLiaUzfAOiH0tHJE6ILQIUi3KYkjiCDTskoIsnfqZvWLBDng==", "dev": true, "requires": { - "@babel/code-frame": "7.0.0-beta.42", - "@babel/types": "7.0.0-beta.42", - "babylon": "7.0.0-beta.42", + "@babel/code-frame": "7.0.0-beta.44", + "@babel/types": "7.0.0-beta.44", + "babylon": "7.0.0-beta.44", "lodash": "4.17.5" }, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz", + "integrity": "sha512-cuAuTTIQ9RqcFRJ/Y8PvTh+paepNcaGxwQwjIDRWPXmzzyAeCO4KqS9ikMvq0MCbRk6GlYKwfzStrcP3/jSL8g==", + "dev": true, + "requires": { + "@babel/highlight": "7.0.0-beta.44" + } + }, + "@babel/highlight": { + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.44.tgz", + "integrity": "sha512-Il19yJvy7vMFm8AVAh6OZzaFoAd0hbkeMZiX3P5HGD+z7dyI7RzndHB0dg6Urh/VAFfHtpOIzDUSxmY6coyZWQ==", + "dev": true, + "requires": { + "chalk": "2.3.2", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + } + }, "babylon": { - "version": "7.0.0-beta.42", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.42.tgz", - "integrity": "sha512-h6E/OkkvcBw/JimbL0p8dIaxrcuQn3QmIYGC/GtJlRYif5LTKBYPHXYwqluJpfS/kOXoz0go+9mkmOVC0M+zWw==", + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.44.tgz", + "integrity": "sha512-5Hlm13BJVAioCHpImtFqNOF2H3ieTOHd0fmFGMxOJ9jgeFqeAwsv3u5P5cR7CSeFrkgHsT19DgFJkHV0/Mcd8g==", "dev": true } } }, "@babel/traverse": { - "version": "7.0.0-beta.42", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.0.0-beta.42.tgz", - "integrity": "sha512-DZwMuZBfYVIn/cxpXZzHDgKmarW/MWqplLv1k7QJYhK5r5l6GAac/DkKl75A0CjPYrD3VGco6H6ZQp12QaYKSw==", + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.0.0-beta.44.tgz", + "integrity": "sha512-UHuDz8ukQkJCDASKHf+oDt3FVUzFd+QYfuBIsiNu/4+/ix6pP/C+uQZJ6K1oEfbCMv/IKWbgDEh7fcsnIE5AtA==", "dev": true, "requires": { - "@babel/code-frame": "7.0.0-beta.42", - "@babel/generator": "7.0.0-beta.42", - "@babel/helper-function-name": "7.0.0-beta.42", - "@babel/helper-split-export-declaration": "7.0.0-beta.42", - "@babel/types": "7.0.0-beta.42", - "babylon": "7.0.0-beta.42", + "@babel/code-frame": "7.0.0-beta.44", + "@babel/generator": "7.0.0-beta.44", + "@babel/helper-function-name": "7.0.0-beta.44", + "@babel/helper-split-export-declaration": "7.0.0-beta.44", + "@babel/types": "7.0.0-beta.44", + "babylon": "7.0.0-beta.44", "debug": "3.1.0", - "globals": "11.3.0", + "globals": "11.5.0", "invariant": "2.2.4", "lodash": "4.17.5" }, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz", + "integrity": "sha512-cuAuTTIQ9RqcFRJ/Y8PvTh+paepNcaGxwQwjIDRWPXmzzyAeCO4KqS9ikMvq0MCbRk6GlYKwfzStrcP3/jSL8g==", + "dev": true, + "requires": { + "@babel/highlight": "7.0.0-beta.44" + } + }, + "@babel/highlight": { + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.44.tgz", + "integrity": "sha512-Il19yJvy7vMFm8AVAh6OZzaFoAd0hbkeMZiX3P5HGD+z7dyI7RzndHB0dg6Urh/VAFfHtpOIzDUSxmY6coyZWQ==", + "dev": true, + "requires": { + "chalk": "2.3.2", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + } + }, "babylon": { - "version": "7.0.0-beta.42", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.42.tgz", - "integrity": "sha512-h6E/OkkvcBw/JimbL0p8dIaxrcuQn3QmIYGC/GtJlRYif5LTKBYPHXYwqluJpfS/kOXoz0go+9mkmOVC0M+zWw==", + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.44.tgz", + "integrity": "sha512-5Hlm13BJVAioCHpImtFqNOF2H3ieTOHd0fmFGMxOJ9jgeFqeAwsv3u5P5cR7CSeFrkgHsT19DgFJkHV0/Mcd8g==", "dev": true }, "debug": { @@ -134,17 +174,17 @@ } }, "globals": { - "version": "11.3.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.3.0.tgz", - "integrity": "sha512-kkpcKNlmQan9Z5ZmgqKH/SMbSmjxQ7QjyNqfXVc8VJcoBV2UEg+sxQD15GQofGRh2hfpwUb70VC31DR7Rq5Hdw==", + "version": "11.5.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.5.0.tgz", + "integrity": "sha512-hYyf+kI8dm3nORsiiXUQigOU62hDLfJ9G01uyGMxhc6BKsircrUhC4uJPQPUSuq2GrTmiiEt7ewxlMdBewfmKQ==", "dev": true } } }, "@babel/types": { - "version": "7.0.0-beta.42", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.0.0-beta.42.tgz", - "integrity": "sha512-+pmpISmTHQqMMpHHtDLxcvtRhmn53bAxy8goJfHipS/uy/r3PLcuSdPizLW7DhtBWbtgIKZufLObfnIMoyMNsw==", + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.0.0-beta.44.tgz", + "integrity": "sha512-5eTV4WRmqbaFM3v9gHAIljEQJU4Ssc6fxL61JN+Oe2ga/BwyjzjamwkCVVAQjHGuAX8i0BWo42dshL8eO5KfLQ==", "dev": true, "requires": { "esutils": "2.0.2", @@ -702,23 +742,43 @@ } }, "babel-eslint": { - "version": "8.2.2", - "resolved": "http://registry.npmjs.org/babel-eslint/-/babel-eslint-8.2.2.tgz", - "integrity": "sha512-Qt2lz2egBxNYWqN9JIO2z4NOOf8i4b5JS6CFoYrOZZTDssueiV1jH/jsefyg+86SeNY3rB361/mi3kE1WK2WYQ==", + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-8.2.3.tgz", + "integrity": "sha512-0HeSTtaXg/Em7FCUWxwOT+KeFSO1O7LuRuzhk7g+1BjwdlQGlHq4OyMi3GqGxrNfEq8jEi6Hmt5ylEQUhurgiQ==", "dev": true, "requires": { - "@babel/code-frame": "7.0.0-beta.42", - "@babel/traverse": "7.0.0-beta.42", - "@babel/types": "7.0.0-beta.42", - "babylon": "7.0.0-beta.42", + "@babel/code-frame": "7.0.0-beta.44", + "@babel/traverse": "7.0.0-beta.44", + "@babel/types": "7.0.0-beta.44", + "babylon": "7.0.0-beta.44", "eslint-scope": "3.7.1", "eslint-visitor-keys": "1.0.0" }, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz", + "integrity": "sha512-cuAuTTIQ9RqcFRJ/Y8PvTh+paepNcaGxwQwjIDRWPXmzzyAeCO4KqS9ikMvq0MCbRk6GlYKwfzStrcP3/jSL8g==", + "dev": true, + "requires": { + "@babel/highlight": "7.0.0-beta.44" + } + }, + "@babel/highlight": { + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.44.tgz", + "integrity": "sha512-Il19yJvy7vMFm8AVAh6OZzaFoAd0hbkeMZiX3P5HGD+z7dyI7RzndHB0dg6Urh/VAFfHtpOIzDUSxmY6coyZWQ==", + "dev": true, + "requires": { + "chalk": "2.3.2", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + } + }, "babylon": { - "version": "7.0.0-beta.42", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.42.tgz", - "integrity": "sha512-h6E/OkkvcBw/JimbL0p8dIaxrcuQn3QmIYGC/GtJlRYif5LTKBYPHXYwqluJpfS/kOXoz0go+9mkmOVC0M+zWw==", + "version": "7.0.0-beta.44", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.44.tgz", + "integrity": "sha512-5Hlm13BJVAioCHpImtFqNOF2H3ieTOHd0fmFGMxOJ9jgeFqeAwsv3u5P5cR7CSeFrkgHsT19DgFJkHV0/Mcd8g==", "dev": true } } @@ -16983,7 +17043,7 @@ "requires": { "autoprefixer": "7.2.6", "babel-core": "6.26.0", - "babel-eslint": "8.2.2", + "babel-eslint": "8.2.3", "babel-helper-vue-jsx-merge-props": "2.0.3", "babel-jest": "21.2.0", "babel-loader": "7.1.4", diff --git a/package.json b/package.json index e976d0d6..2876e520 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,10 @@ ], "homepage": "https://github.com/youzan/zanui-weapp#readme", "devDependencies": { + "babel-eslint": "^8.2.3", "cross-env": "^5.1.4", "eslint-config-airbnb": "^16.1.0", + "eslint-plugin-jsx-a11y": "^6.0.3", "fs-extra": "^4.0.2", "gh-pages": "^1.1.0", "gulp": "^3.9.1", diff --git a/packages/btn-group/index.js b/packages/btn-group/index.js index 3497ac16..89d8800e 100644 --- a/packages/btn-group/index.js +++ b/packages/btn-group/index.js @@ -2,7 +2,7 @@ Component({ relations: { '../btn/index': { type: 'child', - linked () { + linked() { updateBtnChild.call(this); }, linkChange() { @@ -16,10 +16,10 @@ Component({ }); function updateBtnChild() { - let btns = this.getRelationNodes('../btn/index') - + let btns = this.getRelationNodes('../btn/index'); + if (btns.length > 0) { - let lastIndex = btns.length - 1 + let lastIndex = btns.length - 1; btns.forEach((btn, index) => { btn.switchLastButtonStatus(index === lastIndex); diff --git a/packages/btn/index.js b/packages/btn/index.js index 257012e8..85044876 100644 --- a/packages/btn/index.js +++ b/packages/btn/index.js @@ -1,4 +1,3 @@ - Component({ externalClasses: ['custom-class'], relations: { @@ -53,4 +52,4 @@ Component({ this.setData({ isLast }); } } -}); \ No newline at end of file +}); diff --git a/packages/capsule/index.js b/packages/capsule/index.js index 9826f235..a950d011 100644 --- a/packages/capsule/index.js +++ b/packages/capsule/index.js @@ -10,19 +10,19 @@ Component({ value: '' }, // 自定义颜色 - color :{ - type : String, - value : '' + color: { + type: String, + value: '' }, // 左侧内容 - leftText :{ - type : String , - value : '' + leftText: { + type: String, + value: '' }, // 右侧内容 - rightText :{ - type : String , - value : '' + rightText: { + type: String, + value: '' } } -}) +}); diff --git a/packages/cell-group/index.js b/packages/cell-group/index.js index ddfa1d33..aa146cde 100644 --- a/packages/cell-group/index.js +++ b/packages/cell-group/index.js @@ -2,18 +2,18 @@ Component({ relations: { '../cell/index': { type: 'child', - linked (target) {} + linked() {} } }, - ready () { - let cells = this.getRelationNodes('../cell/index') - + ready() { + let cells = this.getRelationNodes('../cell/index'); + if (cells.length > 0) { - let lastIndex = cells.length - 1 - + let lastIndex = cells.length - 1; + cells.forEach((cell, index) => { - if (index < lastIndex) cell.notLastCell() + if (index < lastIndex) cell.notLastCell(); }); } } -}) \ No newline at end of file +}); diff --git a/packages/cell/index.js b/packages/cell/index.js index 92b62534..5c5a055c 100644 --- a/packages/cell/index.js +++ b/packages/cell/index.js @@ -1,7 +1,7 @@ const warn = (msg, getValue) => { - console.warn(msg) - console.log('接受到的值为:', getValue) -} + console.warn(msg); + console.log('接受到的值为:', getValue); +}; Component({ options: { @@ -48,32 +48,32 @@ Component({ isLastCell: true }, methods: { - navigateTo () { - const url = this.data.url - const type = typeof this.data.isLink + navigateTo() { + const { url = '' } = this.data; + const type = typeof this.data.isLink; - this.triggerEvent('tap', {}) + this.triggerEvent('tap', {}); if (!this.data.isLink || !url || url === 'true' || url === 'false') return; if (type !== 'boolean' && type !== 'string') { - warn('isLink 属性值必须是一个字符串或布尔值', this.data.isLink) - return + warn('isLink 属性值必须是一个字符串或布尔值', this.data.isLink); + return; } if (['navigateTo', 'redirectTo', 'switchTab', 'reLaunch'].indexOf(this.data.linkType) === -1) { - warn('linkType 属性可选值为 navigateTo,redirectTo,switchTab,reLaunch', this.data.linkType) - return + warn('linkType 属性可选值为 navigateTo,redirectTo,switchTab,reLaunch', this.data.linkType); + return; } - wx[this.data.linkType].call(wx, { url }) + wx[this.data.linkType].call(wx, { url }); }, - cellTap () { + cellTap() { if (!this.data.onlyTapFooter) { - this.navigateTo() + this.navigateTo(); } }, - notLastCell () { - this.setData({ isLastCell: false }) + notLastCell() { + this.setData({ isLastCell: false }); } } -}) \ No newline at end of file +}); diff --git a/packages/dialog/dialog.js b/packages/dialog/dialog.js index 45242ad1..55184de3 100644 --- a/packages/dialog/dialog.js +++ b/packages/dialog/dialog.js @@ -22,7 +22,7 @@ function Dialog(options, pageCtx) { // 处理默认按钮的展示 // 纵向排布确认按钮在上方 - const buttons = parsedOptions.buttons; + const { buttons = [] } = parsedOptions; let showCustomBtns = false; if (buttons.length === 0) { if (parsedOptions.showConfirmButton) { @@ -59,6 +59,6 @@ function Dialog(options, pageCtx) { promiseFunc: { resolve, reject } }); }); -}; +} -module.exports = Dialog; \ No newline at end of file +module.exports = Dialog; diff --git a/packages/dialog/index.js b/packages/dialog/index.js index 9b870c20..67f2d126 100644 --- a/packages/dialog/index.js +++ b/packages/dialog/index.js @@ -1,6 +1,6 @@ const defaultData = require('./data'); -const _f = function() {}; +const _f = function () {}; Component({ properties: {}, diff --git a/packages/field/index.js b/packages/field/index.js index 933c6844..534c16ef 100644 --- a/packages/field/index.js +++ b/packages/field/index.js @@ -32,17 +32,17 @@ Component({ console.info('[zan:field:change]', event); this.triggerEvent('change', event); }, - + handleZanFieldFocus(event) { console.info('[zan:field:focus]', event); - + this.triggerEvent('focus', event); }, - + handleZanFieldBlur(event) { console.info('[zan:field:blur]', event); - + this.triggerEvent('blur', event); } } -}) +}); diff --git a/packages/loading/index.js b/packages/loading/index.js index 89fbaabe..fa40a9f1 100644 --- a/packages/loading/index.js +++ b/packages/loading/index.js @@ -8,4 +8,4 @@ Component({ type: String } } -}) \ No newline at end of file +}); diff --git a/packages/noticebar/index.js b/packages/noticebar/index.js index 7c0c67f2..27112b52 100644 --- a/packages/noticebar/index.js +++ b/packages/noticebar/index.js @@ -86,66 +86,69 @@ Component({ _init() { wx.createSelectorQuery() - .in(this) - .select('.zan-noticebar__content') - .boundingClientRect(rect => { - if (!rect || !rect.width) { - throw new Error('页面缺少 noticebar 元素'); - return; - } - this.setData({ - width: rect.width - }); + .in(this) + .select('.zan-noticebar__content') + .boundingClientRect((rect) => { + if (!rect || !rect.width) { + throw new Error('页面缺少 noticebar 元素'); + } + this.setData({ + width: rect.width + }); - wx.createSelectorQuery() - .in(this) - .select('.zan-noticebar__content-wrap') - .boundingClientRect((rect) => { - if (!rect || !rect.width) { - return; - } + wx.createSelectorQuery() + .in(this) + .select('.zan-noticebar__content-wrap') + .boundingClientRect((rect) => { + if (!rect || !rect.width) { + return; + } - const wrapWidth = rect.width; - const { width, speed, scrollable, delay } = this.data; + const wrapWidth = rect.width; + const { + width, speed, scrollable, delay + } = this.data; - if (scrollable && wrapWidth < width) { - const elapse = width / speed * 1000; - const animation = wx.createAnimation({ - duration: elapse, - timeingFunction: 'linear', - delay - }); - const resetAnimation = wx.createAnimation({ - duration: 0, - timeingFunction: 'linear' - }); + if (scrollable && wrapWidth < width) { + const elapse = width / speed * 1000; + const animation = wx.createAnimation({ + duration: elapse, + timeingFunction: 'linear', + delay + }); + const resetAnimation = wx.createAnimation({ + duration: 0, + timeingFunction: 'linear' + }); - this.setData({ - elapse, - wrapWidth, - animation, - resetAnimation - }, () => { - this._scroll(); - }); - } - }) - .exec(); - }) - .exec(); + this.setData({ + elapse, + wrapWidth, + animation, + resetAnimation + }, () => { + this._scroll(); + }); + } + }) + .exec(); + }) + .exec(); }, _scroll() { - const { animation, resetAnimation, wrapWidth, elapse, speed } = this.data; - const resetAnimationData = resetAnimation.translateX(wrapWidth).step(); - const animationData = animation.translateX(-elapse * speed / 1000).step(); + const { + animation, resetAnimation, wrapWidth, elapse, speed + } = this.data; + resetAnimation.translateX(wrapWidth).step(); + const animationData = animation.translateX(-(elapse * speed) / 1000).step(); this.setData({ animationData: resetAnimation.export() }); setTimeout(() => { this.setData({ animationData: animationData.export() - }) + }); }, 100); const timer = setTimeout(() => { @@ -166,4 +169,4 @@ Component({ }); } } -}) +}); diff --git a/packages/panel/index.js b/packages/panel/index.js index 32c20610..6778cae3 100644 --- a/packages/panel/index.js +++ b/packages/panel/index.js @@ -10,14 +10,14 @@ Component({ value: '' }, // 内容区顶部是否取消10像素的间距 - hideTop :{ - type : Boolean , - value : false + hideTop: { + type: Boolean, + value: false }, // 内容区顶部是否取消边框 - hideBorder :{ - type : Boolean , - value : false + hideBorder: { + type: Boolean, + value: false } } -}) +}); diff --git a/packages/stepper/index.js b/packages/stepper/index.js index 9155aad0..f462a1da 100644 --- a/packages/stepper/index.js +++ b/packages/stepper/index.js @@ -21,10 +21,10 @@ Component({ methods: { handleZanStepperChange(e, type) { - const dataset = e.currentTarget.dataset; - const disabled = dataset.disabled; + const { dataset = {} } = e.currentTarget; + const { disabled } = dataset; const { step } = this.data; - let stepper = this.data.stepper; + let { stepper } = this.data; if (disabled) return null; @@ -41,30 +41,29 @@ Component({ handleZanStepperMinus(e) { this.handleZanStepperChange(e, 'minus'); }, - + handleZanStepperPlus(e) { - this.handleZanStepperChange( e, 'plus'); + this.handleZanStepperChange(e, 'plus'); }, - + handleZanStepperBlur(e) { - const dataset = e.currentTarget.dataset; - let value = e.detail.value; + let { value } = e.detail; const { min, max } = this.data; - + if (!value) { setTimeout(() => { this.triggerEvent('change', min); }, 16); return; } - + value = +value; if (value > max) { value = max; } else if (value < min) { value = min; } - + this.triggerEvent('change', value); } } diff --git a/packages/steps/index.js b/packages/steps/index.js index 651992f4..7e096916 100644 --- a/packages/steps/index.js +++ b/packages/steps/index.js @@ -17,4 +17,4 @@ Component({ className: String } -}) +}); diff --git a/packages/switch/index.js b/packages/switch/index.js index 8b99051a..27e8d7b4 100644 --- a/packages/switch/index.js +++ b/packages/switch/index.js @@ -17,7 +17,7 @@ Component({ }, methods: { - handleZanSwitchChange(event) { + handleZanSwitchChange() { if (this.data.loading || this.data.disabled) { return; } diff --git a/packages/tab/index.js b/packages/tab/index.js index 23568383..3483f190 100644 --- a/packages/tab/index.js +++ b/packages/tab/index.js @@ -36,4 +36,4 @@ Component({ this.triggerEvent('tabchange', selectedId); } } -}) +}); diff --git a/packages/tag/index.js b/packages/tag/index.js index 9f1bcbd2..24ea440e 100644 --- a/packages/tag/index.js +++ b/packages/tag/index.js @@ -12,4 +12,4 @@ Component({ value: false, } } -}); \ No newline at end of file +}); diff --git a/packages/toast/toast.js b/packages/toast/toast.js index b2f57b4e..e62ff282 100644 --- a/packages/toast/toast.js +++ b/packages/toast/toast.js @@ -1,7 +1,7 @@ let timeoutData = { timeoutId: 0, toastCtx: null -} +}; function Toast(options = {}, pageCtx) { let ctx = pageCtx; @@ -32,29 +32,31 @@ function Toast(options = {}, pageCtx) { timeoutData = { timeoutId, toastCtx - } -}; + }; +} // 清理所有 toast -Toast.clear = function() { +Toast.clear = function () { clearTimeout(timeoutData.timeoutId); try { timeoutData.toastCtx && timeoutData.toastCtx.clear(); - } catch (e) {} + } catch (e) { + console.log(e); + } timeoutData = { timeoutId: 0, toastCtx: null - } -} + }; +}; // 显示 loading -Toast.loading = function(options = {}) { +Toast.loading = function (options = {}) { Toast({ ...options, type: 'loading' }); -} +}; module.exports = Toast; diff --git a/packages/toptips/index.js b/packages/toptips/index.js index b34ca615..9367db05 100644 --- a/packages/toptips/index.js +++ b/packages/toptips/index.js @@ -24,7 +24,7 @@ Component({ methods: { show() { - const duration = this.data.duration; + const { duration } = this.data; this._timer && clearTimeout(this._timer); this.setData({ @@ -56,7 +56,7 @@ function Toptips(options = {}) { duration: 3000 }; - options = Object.assign(defaultOptions,parseParam(options)); + options = Object.assign(defaultOptions, parseParam(options)); const $toptips = ctx.selectComponent(options.selector); delete options.selector; @@ -71,4 +71,4 @@ function parseParam(params) { return typeof params === 'object' ? params : { content: params }; } -module.exports = Toptips; \ No newline at end of file +module.exports = Toptips;