diff --git a/components/mip-map/example/mip-map.html b/components/mip-map/example/mip-map.html index 59b74a1c..8d679554 100644 --- a/components/mip-map/example/mip-map.html +++ b/components/mip-map/example/mip-map.html @@ -9,6 +9,7 @@ @@ -17,6 +18,8 @@ - \ No newline at end of file + diff --git a/components/mip-map/mip-map.md b/components/mip-map/mip-map.md index db79c65c..e36fdf6b 100644 --- a/components/mip-map/mip-map.md +++ b/components/mip-map/mip-map.md @@ -17,22 +17,22 @@ @@ -94,5 +94,65 @@ ### data-only-get-sdk 说明:是否只加载地图 SDK -必填:否 +必填:否 格式:Boolean +默认:false + +### hide-map + +说明:是否隐藏地图 +必填:否 +格式:Boolean +默认:false + +### get-position + +说明:是否自动定位 +必填:否 +格式:Boolean +默认:false + +## 触发事件 + +### getPositionComplete + +如设置定位且成功定位,则透传经纬度等信息 +透传数据结构如下: + +```js +{ + "accuracy":30, + "altitude":null, + "altitudeAccuracy":null, + "heading":null, + "latitude":40.050551292543, + "longitude":116.28123645733, + "speed":null, + "timestamp":null, + "point":{ + "lng":116.28123645733, + "lat":40.050551292543 + }, + "address":{ + "city":"北京市", + "city_code":0, + "district":"海淀区", + "province":"北京市", + "street":"软件园西三路辅路", + "street_number":"" + } +} +``` +### getPositionFailed +定位失败 + +### searchLocalFailed + +无法定位值`local`所配位置时,触发此事件,并切换为自动定位 + + +## 暴露方法 + +### getLocal + +获取当前定位 diff --git a/components/mip-map/mip-map.vue b/components/mip-map/mip-map.vue index f2fc2dab..f1f87638 100644 --- a/components/mip-map/mip-map.vue +++ b/components/mip-map/mip-map.vue @@ -4,6 +4,7 @@ @@ -33,16 +34,25 @@ export default { return null } }, + getPosition: { + type: Boolean, + default: false + }, dataOnlyGetSdk: { type: Boolean, default: false + }, + hideMap: { + type: Boolean, + default: false } }, data () { return { map: null, point: {}, - marker: null + marker: null, + currentMarker: null } }, firstInviewCallback () { @@ -51,7 +61,7 @@ export default { methods: { init () { this.getMapJDK().then(() => { - this.handleResult() + this.resolveOptions() }) }, @@ -81,10 +91,55 @@ export default { }, /** - * 初始化地图并加载控件 + * 根据配置执行相应方法 + * + */ + resolveOptions () { + let BMap = window.BMap + + // 仅加载SDK,不初始化地图 + if (this.dataOnlyGetSdk) { + return this.loadSdk() + } + + // 初始化地图 + this.map = new BMap.Map('allmap') + this.map.centerAndZoom(new BMap.Point(116.404, 39.915), 15) + + // 隐藏地图 + this.hideMap && this.hideMapView() + + // 自动定位、或者手动定位 + this.getPosition ? this.getCurrentLocation() : this.searchLocation() + + // 暴露自动定位方法 + this.$on('getLocal', () => { + // 可能会在未完全初始化的时候调用 + this.getMapJDK().then(() => { + this.getCurrentLocation() + }) + }) + // 配置控件 + this.controls && this.addControls() + }, + + /** + * 隐藏地图 + * + */ + hideMapView () { + let mipMap = this.$element + MIP.util.css(mipMap, { + width: 0, + height: 0 + }) + }, + + /** + * 仅加载sdk * */ - handleResult () { + loadSdk () { let BMap = window.BMap // BMap注入沙盒 @@ -97,39 +152,50 @@ export default { // 派发事件 this.$emit('loaded', {}) + }, - // 仅加载SDK,不初始化地图 - if (this.dataOnlyGetSdk) { - return - } - - // 初始化地图 - this.map = new BMap.Map('allmap') - this.map.centerAndZoom(new BMap.Point(116.404, 39.915), 15) + /** + * 自动定位 + * + */ + getCurrentLocation () { + let BMap = window.BMap + let geolocation = new BMap.Geolocation() + geolocation.getCurrentPosition((res) => { + // 无定位权限 + if (!res.accuracy) { + return this.$emit('getPositionFailed', res) + } else if (geolocation.getStatus() === window.BMAP_STATUS_SUCCESS) { + this.currentMarker = new BMap.Marker(res.point) + this.map.addOverlay(this.currentMarker) + this.map.panTo(res.point) - // 创建地址解析器实例 - let address = this.traverseAndConcat(this.location) - if (address && this.location.city) { - this.handlePoint() - } + // 派发事件 + this.$emit('getPositionComplete', res) + } + }, { enableHighAccuracy: true }) }, /** - * 处理定位的函数 + * 定位至local配置的位置 * */ - handlePoint () { + searchLocation () { let BMap = window.BMap let { location, map } = this // 配置地址 let address = this.traverseAndConcat(location) - if (!address) { + + // 没有定位信息,则使用自动定位 + if (!address || !this.location.city) { + this.getCurrentLocation() + this.$emit('searchLocalFailed', {}) return } let options = { onSearchComplete: results => { - if (local.getStatus() !== 0) { + if (local.getStatus() !== window.BMAP_STATUS_SUCCESS) { return } let firstResult = results.getPoi(0) @@ -143,9 +209,7 @@ export default { map.centerAndZoom(point, 15) // 配置弹层 - this.handleInfoWindow() - // 配置控件 - this.handleControls() + this.setInfoWindow() } } @@ -158,7 +222,7 @@ export default { * 配置弹层信息 * */ - handleInfoWindow () { + setInfoWindow () { let BMap = window.BMap let { info, map, marker, point } = this if (!info) { @@ -174,7 +238,7 @@ export default { * 配置地图控件 * */ - handleControls () { + addControls () { let BMap = window.BMap let { controls, map } = this for (let key in controls) { @@ -210,6 +274,11 @@ export default { #allmap { width: 100%; height: 100%; + &.hideMap { + width: 0; + height: 0; + visibility: hidden; + } // mip核心css 会覆盖地图定位图片样式 & /deep/ img { width: auto; diff --git a/components/mip-novel-video/example/mipx-xiaoshuo-1.html b/components/mip-novel-video/example/mipx-xiaoshuo-1.html index 16655af2..2fed0961 100644 --- a/components/mip-novel-video/example/mipx-xiaoshuo-1.html +++ b/components/mip-novel-video/example/mipx-xiaoshuo-1.html @@ -1,3 +1,4 @@ + @@ -17,51 +18,77 @@ } @font-face { font-family: xiaoshuo; + src: url(font/xiaoshuo.eot?t=1515560671046); src: url(font/xiaoshuo.eot?t=1515560671046#iefix) format("embedded-opentype"), url(font/xiaoshuo.woff) format("woff"), url(font/xiaoshuo.ttf?t=1515560671046) format("truetype"), url(font/xiaoshuo.svg?t=1515560671046#xiaoshuo) format("svg"); - } .icon-xiaoshuo { + } + + .icon-xiaoshuo { font-family: xiaoshuo!important; font-size: 16px; font-style: normal; + -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - } .icon-paihangbang:before { + } + + .icon-paihangbang:before { content: "\e663"; - } .icon-mianfei:before { + } + + .icon-mianfei:before { content: "\e665"; - } .icon-tuijian:before { + } + + .icon-tuijian:before { content: "\e668"; - } #header { + } + + #header { height: 44px; - padding-right: 17px; ; + padding-right: 17px;; padding-left: 17px; border-bottom: 1px solid #f1f1f1; line-height: 44px; - } #header .left, + } + + #header .left, #header .right { position: absolute; - z-index: 10; ; + z-index: 10;; top: 0; - } #header .left { + } + + #header .left { left: 17px; text-align: left; - } #header .right { + } + + #header .right { right: 17px; - } #header a { + } + + #header a { width: 22px; height: 44px; line-height: 44px; color: #333; - } #header h4 { + } + + #header h4 { margin: 0; padding: 0 50px; text-align: center; - } #footer { + } + + #footer { font-size: 12px; - line-height: 50px; ; + line-height: 50px;; text-align: center; color: #999; - } .text-box { + } + + .text-box { display: inline-block; overflow: hidden; box-sizing: content-box; @@ -75,35 +102,54 @@ vertical-align: middle; text-decoration: none; border-radius: 2px; - } .text-box.text-box-gray { - border: 1px solid #e3e3e3; ; + } + + .text-box.text-box-gray { + border: 1px solid #e3e3e3;; color: #999; - } .text-right { + } + + .text-right { text-align: right; - } .text-center { + } + + .text-center { text-align: center; - } ul { + } + + ul { list-style: none; - } .btn.btn-black, + } + + .btn.btn-black, button.btn-black { - padding-right: 0; ; + padding-right: 0;; padding-left: 0; border-color: #707379; text-align: center; color: #000; - } .color-gray { + } + + .color-gray { color: #555; - } a { + } + + a { -webkit-tap-highlight-color: rgba(0, 0, 0, .2); - } mip-scrollbox [data-wrapper] [data-inner], + } + + mip-scrollbox [data-wrapper] [data-inner], mip-scrollbox [data-wrapper] [data-item], mip-scrollbox [data-wrapper] [data-scroller] { position: relative; - } .scrollbox-more .scrollbox-more-wrap { + } + + .scrollbox-more .scrollbox-more-wrap { position: absolute; - width: 100%; ; + width: 100%;; height: 100%; } + .link { display: inline-block; margin: 10px 0; @@ -125,11 +171,11 @@ - 打开目录 - 打开设置 - 下一页 -
-

第1章 灵魂重生

+ 打开目录 + 打开设置 + 上一页 +
+

第3章 牛刀小试

“贱人,你竟敢背叛我!”

@@ -323,74 +369,64 @@

第1章 灵魂重生

陆宇眼神坚定,他是魂天师,就算是废武魂,他也一样能搅动天地,称雄万世!

- 下一页 + 上一页 - - + - -© 2018 GitHub, Inc. -Terms -Privacy -Security -Status -Help -Contact GitHub -API -Training -Shop -Blog + \ No newline at end of file diff --git a/components/mip-novel-video/example/mipx-xiaoshuo-2.html b/components/mip-novel-video/example/mipx-xiaoshuo-2.html index 16655af2..2fed0961 100644 --- a/components/mip-novel-video/example/mipx-xiaoshuo-2.html +++ b/components/mip-novel-video/example/mipx-xiaoshuo-2.html @@ -1,3 +1,4 @@ + @@ -17,51 +18,77 @@ } @font-face { font-family: xiaoshuo; + src: url(font/xiaoshuo.eot?t=1515560671046); src: url(font/xiaoshuo.eot?t=1515560671046#iefix) format("embedded-opentype"), url(font/xiaoshuo.woff) format("woff"), url(font/xiaoshuo.ttf?t=1515560671046) format("truetype"), url(font/xiaoshuo.svg?t=1515560671046#xiaoshuo) format("svg"); - } .icon-xiaoshuo { + } + + .icon-xiaoshuo { font-family: xiaoshuo!important; font-size: 16px; font-style: normal; + -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - } .icon-paihangbang:before { + } + + .icon-paihangbang:before { content: "\e663"; - } .icon-mianfei:before { + } + + .icon-mianfei:before { content: "\e665"; - } .icon-tuijian:before { + } + + .icon-tuijian:before { content: "\e668"; - } #header { + } + + #header { height: 44px; - padding-right: 17px; ; + padding-right: 17px;; padding-left: 17px; border-bottom: 1px solid #f1f1f1; line-height: 44px; - } #header .left, + } + + #header .left, #header .right { position: absolute; - z-index: 10; ; + z-index: 10;; top: 0; - } #header .left { + } + + #header .left { left: 17px; text-align: left; - } #header .right { + } + + #header .right { right: 17px; - } #header a { + } + + #header a { width: 22px; height: 44px; line-height: 44px; color: #333; - } #header h4 { + } + + #header h4 { margin: 0; padding: 0 50px; text-align: center; - } #footer { + } + + #footer { font-size: 12px; - line-height: 50px; ; + line-height: 50px;; text-align: center; color: #999; - } .text-box { + } + + .text-box { display: inline-block; overflow: hidden; box-sizing: content-box; @@ -75,35 +102,54 @@ vertical-align: middle; text-decoration: none; border-radius: 2px; - } .text-box.text-box-gray { - border: 1px solid #e3e3e3; ; + } + + .text-box.text-box-gray { + border: 1px solid #e3e3e3;; color: #999; - } .text-right { + } + + .text-right { text-align: right; - } .text-center { + } + + .text-center { text-align: center; - } ul { + } + + ul { list-style: none; - } .btn.btn-black, + } + + .btn.btn-black, button.btn-black { - padding-right: 0; ; + padding-right: 0;; padding-left: 0; border-color: #707379; text-align: center; color: #000; - } .color-gray { + } + + .color-gray { color: #555; - } a { + } + + a { -webkit-tap-highlight-color: rgba(0, 0, 0, .2); - } mip-scrollbox [data-wrapper] [data-inner], + } + + mip-scrollbox [data-wrapper] [data-inner], mip-scrollbox [data-wrapper] [data-item], mip-scrollbox [data-wrapper] [data-scroller] { position: relative; - } .scrollbox-more .scrollbox-more-wrap { + } + + .scrollbox-more .scrollbox-more-wrap { position: absolute; - width: 100%; ; + width: 100%;; height: 100%; } + .link { display: inline-block; margin: 10px 0; @@ -125,11 +171,11 @@ - 打开目录 - 打开设置 - 下一页 -
-

第1章 灵魂重生

+ 打开目录 + 打开设置 + 上一页 +
+

第3章 牛刀小试

“贱人,你竟敢背叛我!”

@@ -323,74 +369,64 @@

第1章 灵魂重生

陆宇眼神坚定,他是魂天师,就算是废武魂,他也一样能搅动天地,称雄万世!

- 下一页 + 上一页
小说网 © 2018 - 冀ICP备xxxx号
- - + - -© 2018 GitHub, Inc. -Terms -Privacy -Security -Status -Help -Contact GitHub -API -Training -Shop -Blog + \ No newline at end of file diff --git a/components/mip-novel-video/example/mipx-xiaoshuo-3.html b/components/mip-novel-video/example/mipx-xiaoshuo-3.html index 16655af2..2fed0961 100644 --- a/components/mip-novel-video/example/mipx-xiaoshuo-3.html +++ b/components/mip-novel-video/example/mipx-xiaoshuo-3.html @@ -1,3 +1,4 @@ + @@ -17,51 +18,77 @@ } @font-face { font-family: xiaoshuo; + src: url(font/xiaoshuo.eot?t=1515560671046); src: url(font/xiaoshuo.eot?t=1515560671046#iefix) format("embedded-opentype"), url(font/xiaoshuo.woff) format("woff"), url(font/xiaoshuo.ttf?t=1515560671046) format("truetype"), url(font/xiaoshuo.svg?t=1515560671046#xiaoshuo) format("svg"); - } .icon-xiaoshuo { + } + + .icon-xiaoshuo { font-family: xiaoshuo!important; font-size: 16px; font-style: normal; + -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - } .icon-paihangbang:before { + } + + .icon-paihangbang:before { content: "\e663"; - } .icon-mianfei:before { + } + + .icon-mianfei:before { content: "\e665"; - } .icon-tuijian:before { + } + + .icon-tuijian:before { content: "\e668"; - } #header { + } + + #header { height: 44px; - padding-right: 17px; ; + padding-right: 17px;; padding-left: 17px; border-bottom: 1px solid #f1f1f1; line-height: 44px; - } #header .left, + } + + #header .left, #header .right { position: absolute; - z-index: 10; ; + z-index: 10;; top: 0; - } #header .left { + } + + #header .left { left: 17px; text-align: left; - } #header .right { + } + + #header .right { right: 17px; - } #header a { + } + + #header a { width: 22px; height: 44px; line-height: 44px; color: #333; - } #header h4 { + } + + #header h4 { margin: 0; padding: 0 50px; text-align: center; - } #footer { + } + + #footer { font-size: 12px; - line-height: 50px; ; + line-height: 50px;; text-align: center; color: #999; - } .text-box { + } + + .text-box { display: inline-block; overflow: hidden; box-sizing: content-box; @@ -75,35 +102,54 @@ vertical-align: middle; text-decoration: none; border-radius: 2px; - } .text-box.text-box-gray { - border: 1px solid #e3e3e3; ; + } + + .text-box.text-box-gray { + border: 1px solid #e3e3e3;; color: #999; - } .text-right { + } + + .text-right { text-align: right; - } .text-center { + } + + .text-center { text-align: center; - } ul { + } + + ul { list-style: none; - } .btn.btn-black, + } + + .btn.btn-black, button.btn-black { - padding-right: 0; ; + padding-right: 0;; padding-left: 0; border-color: #707379; text-align: center; color: #000; - } .color-gray { + } + + .color-gray { color: #555; - } a { + } + + a { -webkit-tap-highlight-color: rgba(0, 0, 0, .2); - } mip-scrollbox [data-wrapper] [data-inner], + } + + mip-scrollbox [data-wrapper] [data-inner], mip-scrollbox [data-wrapper] [data-item], mip-scrollbox [data-wrapper] [data-scroller] { position: relative; - } .scrollbox-more .scrollbox-more-wrap { + } + + .scrollbox-more .scrollbox-more-wrap { position: absolute; - width: 100%; ; + width: 100%;; height: 100%; } + .link { display: inline-block; margin: 10px 0; @@ -125,11 +171,11 @@ - 打开目录 - 打开设置 - 下一页 -
-

第1章 灵魂重生

+ 打开目录 + 打开设置 + 上一页 +
+

第3章 牛刀小试

“贱人,你竟敢背叛我!”

@@ -323,74 +369,64 @@

第1章 灵魂重生

陆宇眼神坚定,他是魂天师,就算是废武魂,他也一样能搅动天地,称雄万世!

- 下一页 + 上一页
小说网 © 2018 - 冀ICP备xxxx号
- - + - -© 2018 GitHub, Inc. -Terms -Privacy -Security -Status -Help -Contact GitHub -API -Training -Shop -Blog + \ No newline at end of file diff --git a/components/mip-novel-video/mip-novel-video.vue b/components/mip-novel-video/mip-novel-video.vue index 3bae602b..7cdcd66b 100644 --- a/components/mip-novel-video/mip-novel-video.vue +++ b/components/mip-novel-video/mip-novel-video.vue @@ -64,7 +64,7 @@ const css = MIP.util.css const VIDEOINDEX = 'ad-video' const COUNTDOWNINDEX = 10 const PINZHUANGURL = 'https://www.vivo.com/vivo/nexs/?cid=w-1-baidu_ada-xs' -const PRETIME = 'ad-time' +const PREDATE = 'ad-time' const isSF = !window.MIP.standalone @@ -91,8 +91,7 @@ export default { }, computed: { isShow: function () { - let isShow = isSF && detector.getMobileSystemVersion() && !this.played && isShouldVideo - return !isShow + return isSF && detector.getMobileSystemVersion() && isShouldVideo }, isOriginalVideo: function () { return detector.isRenderVideoElement() @@ -102,13 +101,13 @@ export default { this.timeExpired() this.initVideoIndex() isShouldVideo = +customStorage.get(VIDEOINDEX) === 2 || false - console.log('是否SF:' + (isSF || false) + ';页数:' + customStorage.get(VIDEOINDEX)) - if (isShouldVideo) { + if (this.isShow) { + console.log('是否SF:' + (isSF || false) + ';页数:' + customStorage.get(VIDEOINDEX)) this.readContainerNoScroll() } }, firstInviewCallback () { - if (isShouldVideo) { + if (this.isShow) { this.creatVideo() this.openVideo() } @@ -117,39 +116,44 @@ export default { openVideo () { let self = this document.body.addEventListener('touchstart', e => { - if (self.isShow) { - self.$element.setAttribute('style', 'display: none !important') - self.readContainerScroll() - return - } - if (!self.forbidClick) { + if (!self.forbidClick || self.played) { return } e && e.preventDefault() - e && e.stopPropagation() - e && e.stopImmediatePropagation() self.startPlayer() }, false) }, startPlayer () { let self = this this.$element.setAttribute('style', 'display: block !important') + let forceClose = setTimeout(() => { + this.closeVideo() + }, 15000) if (player && this.isOriginalVideo) { + player.addEventListener('playing', () => { + self.startTimer() + clearTimeout(forceClose) + }) player.play() - this.startTimer() } if (jSMpegPlayer && !this.isOriginalVideo) { jSMpegPlayer.on('playing', () => { let event = new Event('playing') this.$element.dispatchEvent(event) css(canvas, {opacity: '1'}) - // 初始化倒计时器 - this.startTimer() + self.startTimer() + clearTimeout(forceClose) }) jSMpegPlayer.play() } /* global _hmt */ _hmt && _hmt.push(['_trackEvent', 'video', 'show', 'vivo']) + this.noVideoMaskScroll() + setTimeout(() => { + self.forbidClick = false + }, 500) + }, + noVideoMaskScroll () { let videoMask = this.$element.querySelector('.video-mask') videoMask.addEventListener('touchmove', e => { e && e.preventDefault() @@ -163,9 +167,6 @@ export default { e && e.stopImmediatePropagation() return false }) - setTimeout(() => { - self.forbidClick = false - }, 500) }, creatVideo () { if (this.isOriginalVideo) { @@ -185,6 +186,7 @@ export default { } }, initCanvasVideo () { + let self = this let videoCover = this.$refs.videoCover if (videoCover) { css(videoCover, {backgroundImage: 'url(' + POSTER + ')'}) @@ -202,7 +204,7 @@ export default { jSMpegPlayer.on('ended', () => { let event = new Event('ended') this.$element.dispatchEvent(event) - this.closeVideo() + self.closeVideo() }) } }, @@ -250,7 +252,6 @@ export default { closeVideo (e, isClick) { e && e.stopPropagation() e && e.preventDefault() - let self = this let container = this.$element.querySelector('.video-container') let content = this.$element.querySelector('.content') let isClosed = false @@ -261,10 +262,11 @@ export default { jSMpegPlayer.pause() } if (!isClosed) { - self.readContainerScroll() - self.forbidClick = true - self.played = true + this.readContainerScroll() + this.forbidClick = true + this.played = true container.classList.add('close-container') + let self = this setTimeout(() => { content.classList.add('close-content') /* global _hmt */ @@ -279,20 +281,16 @@ export default { isClosed = true }, timeExpired () { - let myDate = new Date().getTime() - let preTime = customStorage.get(PRETIME) - if (preTime == null) { - customStorage.set(PRETIME, myDate) + let myDate = new Date().getDate() + let preDate = customStorage.get(PREDATE) + if (preDate == null) { + customStorage.set(PREDATE, myDate) return } - let currentTime = myDate - let diffTime = currentTime - preTime - // let hoursDiff = parseInt(Math.abs(diffTime) / 1000 / 60 / 60) - let secondsDiff = parseInt(Math.abs(diffTime) / 1000) - if (secondsDiff >= 30) { - // if (hoursDiff >= 24) { + let currentDate = myDate + if (currentDate !== preDate) { customStorage.rm(VIDEOINDEX) - customStorage.rm(PRETIME) + customStorage.rm(PREDATE) } } } diff --git a/components/mip-novel-video/video-detector.js b/components/mip-novel-video/video-detector.js index b8c64d65..8cd920a8 100644 --- a/components/mip-novel-video/video-detector.js +++ b/components/mip-novel-video/video-detector.js @@ -42,10 +42,10 @@ const detector = { const version = system.match(num) // ios要求版本8.X以上 if (platform.isIos()) { - return version && version[0] && version[0] >= IOSVERSION + return version && version[0] && version[0] >= IOSVERSION && !platform.isUc() } else { // android要求版本5.X以上 - return version && version[0] && version[0] >= ANDROIDVERSION + return version && version[0] && version[0] >= ANDROIDVERSION && !platform.isUc() } } } diff --git a/components/mip-shell-xiaoshuo/example/mipx-xiaoshuo-1.html b/components/mip-shell-xiaoshuo/example/mipx-xiaoshuo-1.html index 6a476437..b3d6e79b 100644 --- a/components/mip-shell-xiaoshuo/example/mipx-xiaoshuo-1.html +++ b/components/mip-shell-xiaoshuo/example/mipx-xiaoshuo-1.html @@ -5,7 +5,8 @@ 第1章灵魂重生_神武天帝_小说网 - + +