diff --git a/miniprogram/app.json b/miniprogram/app.json index b423578e..de244421 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -29,6 +29,9 @@ "page/component/pages/movable-view/movable-view", "page/component/pages/cover-view/cover-view", "page/component/pages/rich-text/rich-text", + "page/component/pages/live-player/live-player", + "page/component/pages/live-pusher/live-pusher", + "page/component/pages/official-account/official-account", "page/API/index", "page/API/pages/login/login", "page/API/pages/get-user-info/get-user-info", diff --git a/miniprogram/page/component/index.js b/miniprogram/page/component/index.js index 1ed67f14..42e91345 100644 --- a/miniprogram/page/component/index.js +++ b/miniprogram/page/component/index.js @@ -35,7 +35,7 @@ Page({ id: 'media', name: '媒体组件', open: false, - pages: ['image', 'audio', 'video', 'camera'] + pages: ['image', 'audio', 'video', 'camera', 'live-pusher', 'live-player'] }, { id: 'map', name: '地图', @@ -50,7 +50,7 @@ Page({ id: 'open', name: '开放能力', open: false, - pages: ['ad', 'open-data', 'web-view'] + pages: ['ad', 'open-data', 'web-view', 'official-account'] } ] }, diff --git a/miniprogram/page/component/pages/button/button.js b/miniprogram/page/component/pages/button/button.js index 5919317d..5b8dfb4a 100644 --- a/miniprogram/page/component/pages/button/button.js +++ b/miniprogram/page/component/pages/button/button.js @@ -32,6 +32,26 @@ const pageObject = { this.setData({ loading: !this.data.loading }) + }, + + handleContact(e) { + console.log(e.detail) + }, + + handleGetPhoneNumber(e) { + console.log(e.detail) + }, + + handleGetUserInfo(e) { + console.log(e.detail) + }, + + handleOpenSetting(e) { + console.log(e.detail.authSetting) + }, + + handleGetUserInfo(e) { + console.log(e.detail.userInfo) } } diff --git a/miniprogram/page/component/pages/button/button.wxml b/miniprogram/page/component/pages/button/button.wxml index 958660a8..b3d4ba7c 100644 --- a/miniprogram/page/component/pages/button/button.wxml +++ b/miniprogram/page/component/pages/button/button.wxml @@ -27,6 +27,13 @@ + + + + + + + diff --git a/miniprogram/page/component/pages/camera/camera.js b/miniprogram/page/component/pages/camera/camera.js index c0bb2ac4..a4c2922b 100644 --- a/miniprogram/page/component/pages/camera/camera.js +++ b/miniprogram/page/component/pages/camera/camera.js @@ -11,10 +11,24 @@ Page({ videoSrc: '', position: 'back', mode: 'scanCode', - result: {} + result: {}, + frameWidth: 0, + frameHeight: 0 }, onLoad() { this.ctx = wx.createCameraContext() + const listener = this.ctx.onCameraFrame((frame) => { + const { frameWidth, frameHeight } = this.data; + + // you can print buffer data by executing codes below: + // console.log(frame.data) + if (frameWidth === frame.width && frameHeight == frame.height) return; + this.setData({ + frameWidth: frame.width, + frameHeight: frame.height + }) + }) + listener.start() }, takePhoto() { this.ctx.takePhoto({ diff --git a/miniprogram/page/component/pages/camera/camera.wxml b/miniprogram/page/component/pages/camera/camera.wxml index 35d46ed1..f3a73064 100644 --- a/miniprogram/page/component/pages/camera/camera.wxml +++ b/miniprogram/page/component/pages/camera/camera.wxml @@ -12,6 +12,23 @@ binderror="error" > + + + + 帧高度 + + {{ frameHeight }} + + + + 帧宽度 + + {{ frameWidth }} + + + + + diff --git a/miniprogram/page/component/pages/editor/editor.js b/miniprogram/page/component/pages/editor/editor.js index 4456d3a7..3e8618b5 100644 --- a/miniprogram/page/component/pages/editor/editor.js +++ b/miniprogram/page/component/pages/editor/editor.js @@ -3,18 +3,13 @@ const util = require('../../../../util/util.js') const compareVersion = util.compareVersion Page({ - onShareAppMessage() { - return { - title: 'editor', - path: 'page/component/pages/editor/editor' - } - }, - data: { formats: {}, - bottom: 0, readOnly: false, placeholder: '开始输入...', + editorHeight: 300, + keyboardHeight: 0, + isIOS: false }, readOnlyChange() { this.setData({ @@ -22,62 +17,72 @@ Page({ }) }, onLoad() { - this.canUse = true - wx.loadFontFace({ - family: 'Pacifico', - source: 'url("https://sungd.github.io/Pacifico.ttf")', - success: console.log - }) - const {SDKVersion} = wx.getSystemInfoSync() + const platform = wx.getSystemInfoSync().platform + const isIOS = platform === 'ios' + this.setData({ isIOS }) + const that = this + this.updatePosition(0) + let keyboardHeight = 0 + wx.onKeyboardHeightChange(res => { + if (res.height === keyboardHeight) return + const duration = res.height > 0 ? res.duration * 1000 : 0 + keyboardHeight = res.height + setTimeout(() => { + wx.pageScrollTo({ + scrollTop: 0, + success() { + that.updatePosition(keyboardHeight) + that.editorCtx.scrollIntoView() + } + }) + }, duration) - if (compareVersion(SDKVersion, '2.7.0') >= 0) { - // - } else { - this.canUse = false - // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示 - wx.showModal({ - title: '提示', - content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' - }) - } + }) + }, + updatePosition(keyboardHeight) { + const toolbarHeight = 50 + const { windowHeight, platform } = wx.getSystemInfoSync() + let editorHeight = keyboardHeight > 0 ? (windowHeight - keyboardHeight - toolbarHeight) : windowHeight + this.setData({ editorHeight, keyboardHeight }) + }, + calNavigationBarAndStatusBar() { + const systemInfo = wx.getSystemInfoSync() + const { statusBarHeight, platform } = systemInfo + const isIOS = platform === 'ios' + const navigationBarHeight = isIOS ? 44 : 48 + return statusBarHeight + navigationBarHeight }, - onEditorReady() { const that = this wx.createSelectorQuery().select('#editor').context(function (res) { that.editorCtx = res.context }).exec() }, - - undo() { - this.editorCtx.undo() - }, - redo() { - this.editorCtx.redo() + blur() { + this.editorCtx.blur() }, format(e) { - if (!this.canUse) return - const {name, value} = e.target.dataset + let { name, value } = e.target.dataset if (!name) return // console.log('format', name, value) this.editorCtx.format(name, value) - }, + }, onStatusChange(e) { const formats = e.detail - this.setData({formats}) + this.setData({ formats }) }, insertDivider() { this.editorCtx.insertDivider({ - success() { + success: function () { console.log('insert divider success') } }) }, clear() { this.editorCtx.clear({ - success() { - console.log('clear success') + success: function (res) { + console.log("clear success") } }) }, @@ -95,14 +100,15 @@ Page({ const that = this wx.chooseImage({ count: 1, - success() { + success: function (res) { that.editorCtx.insertImage({ - src: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1543767268337&di=5a3bbfaeb30149b2afd33a3c7aaa4ead&imgtype=0&src=http%3A%2F%2Fimg02.tooopen.com%2Fimages%2F20151031%2Ftooopen_sy_147004931368.jpg', + src: res.tempFilePaths[0], data: { id: 'abcd', role: 'god' }, - success() { + width: '80%', + success: function () { console.log('insert image success') } }) diff --git a/miniprogram/page/component/pages/editor/editor.wxml b/miniprogram/page/component/pages/editor/editor.wxml index 36ed9eaf..28dfede3 100644 --- a/miniprogram/page/component/pages/editor/editor.wxml +++ b/miniprogram/page/component/pages/editor/editor.wxml @@ -5,52 +5,22 @@ - + + + + + + - - - - - diff --git a/miniprogram/page/component/pages/editor/editor.wxss b/miniprogram/page/component/pages/editor/editor.wxss index e79e58f6..cbf1fc7f 100644 --- a/miniprogram/page/component/pages/editor/editor.wxss +++ b/miniprogram/page/component/pages/editor/editor.wxss @@ -1,41 +1,49 @@ @import "../../../common/lib/weui.wxss"; @import "./assets/iconfont.wxss" -.wrapper { - padding: 5px; -} - -.iconfont { - display: inline-block; - padding: 8px 8px; - width: 24px; - height: 24px; - cursor: pointer; - font-size: 20px; -} - -.toolbar { - box-sizing: border-box; - /* border: 1px solid #ccc; */ - border-bottom: 0; - font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif; +.container { + position: absolute; + top: 0; + left: 0; + width: 100%; } - .ql-container { box-sizing: border-box; - padding: 12px 15px; width: 100%; - min-height: 30vh; - height: auto; - /* border-top: 1px solid #ccc; - border-bottom: 1px solid #ccc; */ - background: #fff; - margin-top: 20px; + height: 100%; font-size: 16px; line-height: 1.5; + overflow: auto; + padding: 10px 10px 20px 10px; + border: 1px solid #ECECEC; } .ql-active { - color: #06c; + color: #22C704; } + +.iconfont { + display: inline-block; + width: 30px; + height: 30px; + cursor: pointer; + font-size: 20px; +} + +.toolbar { + box-sizing: border-box; + padding: 0 10px; + height: 50px; + width: 100%; + position: fixed; + left: 0; + right: 100%; + bottom: 0; + display: flex; + align-items: center; + justify-content: space-between; + border: 1px solid #ECECEC; + border-left: none; + border-right: none; +} \ No newline at end of file diff --git a/miniprogram/page/component/pages/live-player/live-player.js b/miniprogram/page/component/pages/live-player/live-player.js new file mode 100644 index 00000000..f1094a7b --- /dev/null +++ b/miniprogram/page/component/pages/live-player/live-player.js @@ -0,0 +1,75 @@ +Page({ + data: { + videoSrc: "" + }, + onShareAppMessage() { + return { + title: 'view', + path: 'page/component/pages/live-player/view' + } + }, + onReady(res) { + this.ctx = wx.createLivePlayerContext('player') + }, + handleLivePlayerStateChange(e) { + console.log('live-player code:', e.detail.code) + }, + handleLivePlayerError(e) { + console.error('live-player error:', e.detail.errMsg) + }, + handlePlay() { + this.ctx.play({ + success: res => { + console.log('play success') + }, + fail: res => { + console.log('play fail') + } + }) + }, + handlePause() { + this.ctx.pause({ + success: res => { + console.log('pause success') + }, + fail: res => { + console.log('pause fail') + } + }) + }, + handleStop() { + this.ctx.stop({ + success: res => { + console.log('stop success') + }, + fail: res => { + console.log('stop fail') + } + }) + }, + handleResume() { + this.ctx.resume({ + success: res => { + console.log('resume success') + }, + fail: res => { + console.log('resume fail') + } + }) + }, + handleMute() { + this.ctx.mute({ + success: res => { + console.log('mute success') + }, + fail: res => { + console.log('mute fail') + } + }) + }, + handleVideoSrcInput(e) { + this.setData({ + videoSrc: e.detail.value + }) + } +}) diff --git a/miniprogram/page/component/pages/live-player/live-player.json b/miniprogram/page/component/pages/live-player/live-player.json new file mode 100644 index 00000000..96fabf42 --- /dev/null +++ b/miniprogram/page/component/pages/live-player/live-player.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "live-player" +} diff --git a/miniprogram/page/component/pages/live-player/live-player.wxml b/miniprogram/page/component/pages/live-player/live-player.wxml new file mode 100644 index 00000000..9a82ef0d --- /dev/null +++ b/miniprogram/page/component/pages/live-player/live-player.wxml @@ -0,0 +1,33 @@ + + + + +