diff --git a/build/build.js b/build/build.js index dde324179687b70b5ccd41c871ad5a5dd0c655fd..d0a60e8417c763ff84a84f731fcf0d16474ea4ad 100644 --- a/build/build.js +++ b/build/build.js @@ -41,8 +41,12 @@ service.run('build', { entry, clean: !process.env.UNI_VIEW, mode: process.env.NODE_ENV -}).then(function () { - if (process.env.UNI_UI !== 'true' && process.env.UNI_VIEW !== 'true') { +}).then(function() { + if ( + process.env.UNI_WATCH !== 'true' && + process.env.UNI_UI !== 'true' && + process.env.UNI_VIEW !== 'true' + ) { generateApiManifest( JSON.parse(JSON.stringify(process.UNI_SERVICE_API_MANIFEST)), JSON.parse(JSON.stringify(process.UNI_SERVICE_API_PROTOCOL)) @@ -58,7 +62,7 @@ if (process.env.UNI_PLATFORM === 'h5' && process.env.UNI_WATCH === 'false') { const packageJsonPath = path.join(packagePath, 'package.json') del(path.join(packagePath, '{lib,src}')) .then(() => { - copy([path.join(__dirname, '../{lib,src}/**/*')], packagePath, function (err, file) { + copy([path.join(__dirname, '../{lib,src}/**/*')], packagePath, function(err, file) { if (err) { throw err } diff --git a/package.json b/package.json index 8e89db02c9816721d65aad29c76cf96100b29ae8..37e338ce30bd5b70f39717f5f47921f40d7bb698 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,7 @@ "wx": true, "my": true, "swan": true, + "tt": true, "weex": true, "__id__": true, "__uniConfig": true, diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 231429991b28940b938c4ec79673aea2a2bd73f4..6e33c0b1360867c04b9bf7a3d8567e4d891b3d98 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -436,6 +436,7 @@ function wrapper (methodName, method) { const todoApis = Object.create(null); const TODOS = [ + 'onTabBarMidButtonTap', 'subscribePush', 'unsubscribePush', 'onPush', @@ -519,8 +520,13 @@ function wrapper$1 (webview) { return } const maskColor = webview.__uniapp_mask; - let maskWebview = plus.webview.getWebviewById(webview.__uniapp_mask_id); - maskWebview = maskWebview.parent() || maskWebview;// 再次检测父 + let maskWebview = webview.__uniapp_mask_id === '0' ? { + setStyle ({ mask }) { + requireNativePlugin('uni-tabview').setMask({ + color: mask + }); + } + } : plus.webview.getWebviewById(webview.__uniapp_mask_id); const oldShow = webview.show; const oldHide = webview.hide; const oldClose = webview.close; diff --git a/packages/uni-app-plus/dist/view.umd.js b/packages/uni-app-plus/dist/view.umd.js index 512910edbd34f8f86553f7c864fb6bf15fccce01..5f2c0264aab4f5668e6e1e0c6704866a2a167c50 100644 --- a/packages/uni-app-plus/dist/view.umd.js +++ b/packages/uni-app-plus/dist/view.umd.js @@ -11478,6 +11478,8 @@ Scroller.prototype.isScrolling = function () { if (n.onTouchStart) { n.onTouchStart(); } + + event.preventDefault(); } }, _handleTouchMove: function _handleTouchMove(event) { @@ -21370,6 +21372,26 @@ var Spring = __webpack_require__(42); + +function onClick(dom, callback) { + var MAX_MOVE = 20; + var hasTouchSupport = navigator.maxTouchPoints; + var x = 0; + var y = 0; + dom.addEventListener(hasTouchSupport ? 'touchstart' : 'mousedown', function (event) { + var info = hasTouchSupport ? event.changedTouches[0] : event; + x = info.clientX; + y = info.clientY; + }); + dom.addEventListener(hasTouchSupport ? 'touchend' : 'mouseup', function (event) { + var info = hasTouchSupport ? event.changedTouches[0] : event; + + if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) { + callback(info); + } + }); +} + /* harmony default export */ var picker_view_columnvue_type_script_lang_js_ = ({ name: 'PickerViewColumn', mixins: [touchtrack["a" /* default */], scroller["a" /* default */]], @@ -21416,7 +21438,8 @@ var Spring = __webpack_require__(42); this.indicatorStyle = $parent.indicatorStyle; this.indicatorClass = $parent.indicatorClass; this.maskStyle = $parent.maskStyle; - this.maskClass = $parent.maskClass; // this.__pageRerender = this._pageRerender.bind(this) + this.maskClass = $parent.maskClass; + this.deltaY = 0; }, mounted: function mounted() { var _this = this; @@ -21428,6 +21451,7 @@ var Spring = __webpack_require__(42); _this.update(); }); + onClick(this.$el, this._handleTap.bind(this)); }, methods: { _setItemHeight: function _setItemHeight(height) { @@ -21455,23 +21479,39 @@ var Spring = __webpack_require__(42); } } }, - _handleTap: function _handleTap(e) { - if (e.target !== e.currentTarget && !this._scroller.isScrolling()) { - var t = e.touches && e.touches[0] && e.touches[0].clientY; - var n = typeof t === 'number' ? t : e.detail.y - document.body.scrollTop; - var i = this.$el.getBoundingClientRect(); - var r = n - i.top - this._height / 2; + _handleTap: function _handleTap(_ref) { + var clientY = _ref.clientY; + + if (!this._scroller.isScrolling()) { + var rect = this.$el.getBoundingClientRect(); + var r = clientY - rect.top - this.height / 2; var o = this.indicatorHeight / 2; if (!(Math.abs(r) <= o)) { var a = Math.ceil((Math.abs(r) - o) / this.indicatorHeight); var s = r < 0 ? -a : a; - this.current += s; + var current = Math.min(this.current + s, this.length - 1); + this.current = current = Math.max(current, 0); - this._scroller.scrollTo(this.current * this.indicatorHeight); + this._scroller.scrollTo(current * this.indicatorHeight); } } }, + _handleWheel: function _handleWheel($event) { + var deltaY = this.deltaY + $event.deltaY; + + if (Math.abs(deltaY) > 10) { + this.deltaY = 0; + var current = Math.min(this.current + (deltaY < 0 ? -1 : 1), this.length - 1); + this.current = current = Math.max(current, 0); + + this._scroller.scrollTo(current * this.indicatorHeight); + } else { + this.deltaY = deltaY; + } + + $event.preventDefault(); + }, setCurrent: function setCurrent(current) { if (current !== this.current) { this.current = current; @@ -21503,14 +21543,14 @@ var Spring = __webpack_require__(42); var _this3 = this; this.$nextTick(function () { - var index = Math.max(_this3.length - 1, 0); - var current = Math.min(_this3.current, index); + var current = Math.min(_this3.current, _this3.length - 1); + current = Math.max(current, 0); _this3._scroller.update(current * _this3.indicatorHeight, undefined, _this3.indicatorHeight); }); }, - _resize: function _resize(_ref) { - var height = _ref.height; + _resize: function _resize(_ref2) { + var height = _ref2.height; this.indicatorHeight = height; } }, @@ -21518,7 +21558,7 @@ var Spring = __webpack_require__(42); this.length = this.$slots.default && this.$slots.default.length || 0; return createElement('uni-picker-view-column', { on: { - tap: this._handleTap + wheel: this._handleWheel } }, [createElement('div', { ref: 'main', diff --git a/packages/uni-cli-shared/lib/cache.js b/packages/uni-cli-shared/lib/cache.js index 69e10165026e3d5b0a7704191c4b4dda297f0131..7b526016b476ef9dcafd05bea6e930996432ed72 100644 --- a/packages/uni-cli-shared/lib/cache.js +++ b/packages/uni-cli-shared/lib/cache.js @@ -53,21 +53,30 @@ function getChangedJsonFileMap (clear = true) { } function updateAppJson (name, jsonObj) { - updateComponentJson(name, jsonObj) + updateComponentJson(name, jsonObj, true, 'App') } function updatePageJson (name, jsonObj) { pageSet.add(name) - updateComponentJson(name, jsonObj) + updateComponentJson(name, jsonObj, true, 'Page') } function updateProjectJson (name, jsonObj) { - updateComponentJson(name, jsonObj, false) + updateComponentJson(name, jsonObj, false, 'Project') } const supportGlobalUsingComponents = process.env.UNI_PLATFORM === 'mp-weixin' || process.env.UNI_PLATFORM === 'mp-qq' -function updateComponentJson (name, jsonObj, usingComponents = true) { +function updateComponentJson (name, jsonObj, usingComponents = true, type = 'Component') { + if (type === 'Component') { + jsonObj.component = true + } + if (type === 'Page') { + if (process.env.UNI_PLATFORM === 'mp-baidu') { + jsonObj.component = true + } + } + const oldJsonStr = getJsonFile(name) if (oldJsonStr) { // update if (usingComponents) { // merge usingComponents diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js index b9671ba6b936fc01a522d9badecb9ab918955a64..8bc5201e5efeb872efcb1ec9b127d17f075fbfd3 100644 --- a/packages/uni-mp-alipay/dist/index.js +++ b/packages/uni-mp-alipay/dist/index.js @@ -836,6 +836,7 @@ function wrapper (methodName, method) { const todoApis = Object.create(null); const TODOS = [ + 'onTabBarMidButtonTap', 'subscribePush', 'unsubscribePush', 'onPush', diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index c62d5d875103744b33644cf2d2c1b0cab1c61438..71b6d665634c6eda4194012ff4ec5633c1283fa7 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -579,6 +579,7 @@ function wrapper (methodName, method) { const todoApis = Object.create(null); const TODOS = [ + 'onTabBarMidButtonTap', 'subscribePush', 'unsubscribePush', 'onPush', diff --git a/packages/uni-mp-qq/dist/index.js b/packages/uni-mp-qq/dist/index.js index 1e4bc0ec2a32c62230a71abbeab2a99a9e909916..dc737347bdf738cf9062803a7808a2b60e462bae 100644 --- a/packages/uni-mp-qq/dist/index.js +++ b/packages/uni-mp-qq/dist/index.js @@ -539,6 +539,7 @@ function wrapper (methodName, method) { const todoApis = Object.create(null); const TODOS = [ + 'onTabBarMidButtonTap', 'subscribePush', 'unsubscribePush', 'onPush', diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index 22e409e02f9de00a38f3aeae935ae2942d2da092..c1464b00a2a9cc20743469608b284d311b8fecdf 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -536,9 +536,10 @@ const protocols = { timeout: false } }, - requestPayment: { + requestPayment: { + name: tt.canIUse && tt.canIUse('pay') ? 'pay' : 'requestPayment', args: { - orderInfo: 'data' + orderInfo: tt.canIUse && tt.canIUse('pay') ? 'orderInfo' : 'data' } }, getFileInfo: { @@ -630,6 +631,7 @@ function wrapper (methodName, method) { const todoApis = Object.create(null); const TODOS = [ + 'onTabBarMidButtonTap', 'subscribePush', 'unsubscribePush', 'onPush', diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index de5a7f5e39292011201ce491bb00c23caebda0e4..5770debb66b5cc37697124613a57352477cc6e38 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -474,6 +474,7 @@ function wrapper (methodName, method) { const todoApis = Object.create(null); const TODOS = [ + 'onTabBarMidButtonTap', 'subscribePush', 'unsubscribePush', 'onPush', diff --git a/src/core/view/components/picker-view-column/index.vue b/src/core/view/components/picker-view-column/index.vue index f6791bbb0df61d47f8a505c0659fa01b88fe3e37..02d4c34a00bf37d09fe1cebe3c0c4a749d2bf3fc 100644 --- a/src/core/view/components/picker-view-column/index.vue +++ b/src/core/view/components/picker-view-column/index.vue @@ -4,6 +4,24 @@ import scroller from 'uni-mixins/scroller/index' import { Friction } from 'uni-mixins/scroller/Friction' import { Spring } from 'uni-mixins/scroller/Spring' +function onClick (dom, callback) { + const MAX_MOVE = 20 + const hasTouchSupport = navigator.maxTouchPoints + let x = 0 + let y = 0 + dom.addEventListener(hasTouchSupport ? 'touchstart' : 'mousedown', (event) => { + const info = hasTouchSupport ? event.changedTouches[0] : event + x = info.clientX + y = info.clientY + }) + dom.addEventListener(hasTouchSupport ? 'touchend' : 'mouseup', (event) => { + const info = hasTouchSupport ? event.changedTouches[0] : event + if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) { + callback(info) + } + }) +} + export default { name: 'PickerViewColumn', mixins: [touchtrack, scroller], @@ -50,7 +68,7 @@ export default { this.indicatorClass = $parent.indicatorClass this.maskStyle = $parent.maskStyle this.maskClass = $parent.maskClass - // this.__pageRerender = this._pageRerender.bind(this) + this.deltaY = 0 }, mounted: function () { this.touchtrack(this.$refs.main, '_handleTrack', true) @@ -59,6 +77,7 @@ export default { this.init() this.update() }) + onClick(this.$el, this._handleTap.bind(this)) }, methods: { _setItemHeight (height) { @@ -81,21 +100,32 @@ export default { } } }, - _handleTap: function (e) { - if (e.target !== e.currentTarget && !this._scroller.isScrolling()) { - var t = e.touches && e.touches[0] && e.touches[0].clientY - var n = typeof t === 'number' ? t : e.detail.y - document.body.scrollTop - var i = this.$el.getBoundingClientRect() - var r = n - i.top - this._height / 2 + _handleTap: function ({ clientY }) { + if (!this._scroller.isScrolling()) { + var rect = this.$el.getBoundingClientRect() + var r = clientY - rect.top - this.height / 2 var o = this.indicatorHeight / 2 if (!(Math.abs(r) <= o)) { var a = Math.ceil((Math.abs(r) - o) / this.indicatorHeight) var s = r < 0 ? -a : a - this.current += s - this._scroller.scrollTo(this.current * this.indicatorHeight) + var current = Math.min(this.current + s, this.length - 1) + this.current = current = Math.max(current, 0) + this._scroller.scrollTo(current * this.indicatorHeight) } } }, + _handleWheel ($event) { + const deltaY = this.deltaY + $event.deltaY + if (Math.abs(deltaY) > 10) { + this.deltaY = 0 + var current = Math.min(this.current + (deltaY < 0 ? -1 : 1), this.length - 1) + this.current = current = Math.max(current, 0) + this._scroller.scrollTo(current * this.indicatorHeight) + } else { + this.deltaY = deltaY + } + $event.preventDefault() + }, setCurrent: function (current) { if (current !== this.current) { this.current = current @@ -122,8 +152,8 @@ export default { }, update: function () { this.$nextTick(() => { - var index = Math.max(this.length - 1, 0) - var current = Math.min(this.current, index) + var current = Math.min(this.current, this.length - 1) + current = Math.max(current, 0) this._scroller.update(current * this.indicatorHeight, undefined, this.indicatorHeight) }) }, @@ -137,10 +167,9 @@ export default { this.length = (this.$slots.default && this.$slots.default.length) || 0 return createElement('uni-picker-view-column', { on: { - tap: this._handleTap + wheel: this._handleWheel } - }, - [ + }, [ createElement('div', { ref: 'main', staticClass: 'uni-picker-view-group' diff --git a/src/core/view/mixins/scroller/index.js b/src/core/view/mixins/scroller/index.js index 780b7469d2d7c73f04eb1ed088533514b303fc24..41862dea6f2901daf66ab8678149fe0024aa79cd 100644 --- a/src/core/view/mixins/scroller/index.js +++ b/src/core/view/mixins/scroller/index.js @@ -46,6 +46,7 @@ export default { if (n.onTouchStart) { n.onTouchStart() } + event.preventDefault() } }, _handleTouchMove: function (event) { diff --git a/src/platforms/h5/view/components/picker/index.vue b/src/platforms/h5/view/components/picker/index.vue index f1c8f09de51e647cdbcde8b65ef77cab650147e2..c1c5ae97d5e3a4ea27b21cbc1a63a3a66dd0fa27 100644 --- a/src/platforms/h5/view/components/picker/index.vue +++ b/src/platforms/h5/view/components/picker/index.vue @@ -319,7 +319,7 @@ export default { } }, _resetFormData () { - this.valueSync = '' + this.valueSync = 0 }, _createTime () { var hours = [] diff --git a/src/platforms/mp-toutiao/runtime/api/protocols.js b/src/platforms/mp-toutiao/runtime/api/protocols.js index 745bad5d8974d7dc3246a16e18ef19f4e3e05ebe..de292cb54589458c34dd04797d80c0e70bab2545 100644 --- a/src/platforms/mp-toutiao/runtime/api/protocols.js +++ b/src/platforms/mp-toutiao/runtime/api/protocols.js @@ -152,9 +152,10 @@ const protocols = { timeout: false } }, - requestPayment: { + requestPayment: { + name: tt.canIUse && tt.canIUse('pay') ? 'pay' : 'requestPayment', args: { - orderInfo: 'data' + orderInfo: tt.canIUse && tt.canIUse('pay') ? 'orderInfo' : 'data' } }, getFileInfo: {