shop.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view>
  3. <web-view src="@/hybrid/html/local.html"></web-view>
  4. <!-- <view class="uni-padding-wrap uni-common-mt">-->
  5. <!-- <view>-->
  6. <!-- <video id="myVideo" src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4"-->
  7. <!-- @error="videoErrorCallback" :danmu-list="danmuList" enable-danmu danmu-btn controls></video>-->
  8. <!-- </view>-->
  9. <!-- &lt;!&ndash; #ifndef MP-ALIPAY &ndash;&gt;-->
  10. <!-- <view class="uni-list uni-common-mt">-->
  11. <!-- <view class="uni-list-cell">-->
  12. <!-- <view>-->
  13. <!-- <view class="uni-label">弹幕内容</view>-->
  14. <!-- </view>-->
  15. <!-- <view class="uni-list-cell-db">-->
  16. <!-- <input v-model="danmuValue" class="uni-input" type="text" placeholder="在此处输入弹幕内容" />-->
  17. <!-- </view>-->
  18. <!-- </view>-->
  19. <!-- </view>-->
  20. <!-- <view class="uni-btn-v">-->
  21. <!-- <button @click="sendDanmu" class="page-body-button">发送弹幕</button>-->
  22. <!-- </view>-->
  23. <!-- &lt;!&ndash; #endif &ndash;&gt;-->
  24. <!-- </view>-->
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. src: '',
  32. danmuList: [{
  33. text: '第 1s 出现的弹幕',
  34. color: '#ff0000',
  35. time: 1
  36. },
  37. {
  38. text: '第 3s 出现的弹幕',
  39. color: '#ff00ff',
  40. time: 3
  41. }
  42. ],
  43. danmuValue: ''
  44. }
  45. },
  46. onReady: function(res) {
  47. // #ifndef MP-ALIPAY
  48. this.videoContext = uni.createVideoContext('myVideo')
  49. // #endif
  50. },
  51. methods: {
  52. sendDanmu: function() {
  53. this.videoContext.sendDanmu({
  54. text: this.danmuValue,
  55. color: this.getRandomColor()
  56. });
  57. this.danmuValue = '';
  58. },
  59. videoErrorCallback: function(e) {
  60. uni.showModal({
  61. content: e.target.errMsg,
  62. showCancel: false
  63. })
  64. },
  65. getRandomColor: function() {
  66. const rgb = []
  67. for (let i = 0; i < 3; ++i) {
  68. let color = Math.floor(Math.random() * 256).toString(16)
  69. color = color.length == 1 ? '0' + color : color
  70. rgb.push(color)
  71. }
  72. return '#' + rgb.join('')
  73. }
  74. }
  75. }
  76. </script>
  77. <!--<template>-->
  78. <!-- <view class="content">-->
  79. <!-- <view class="player-content">-->
  80. <!-- <live-player id="livePlayer" class="live-player" catchtouchmove :src="currentUrl" autoplay-->
  81. <!-- background-mute sound-mode="speaker" mode='RTC' @statechange="statechange" @click="handleControlbar">-->
  82. <!-- <view class="player-tool" :style="{bottom:(showControlbar?'0':'-60rpx')}">-->
  83. <!-- <view class="tools">-->
  84. <!-- <view class="full-screen" @tap.stop="handleFullScreen()">-->
  85. <!-- <text class="iconfont" v-if="!fullScreenFlag">进入全屏</text>-->
  86. <!-- <text class="iconfont" v-else>&#xe67e;</text>-->
  87. <!-- </view>-->
  88. <!-- <view class="cruise" @tap.stop="handleCruise()" v-if="streamIndex == 2">-->
  89. <!-- <text class="iconfont">退出全屏</text>-->
  90. <!-- </view>-->
  91. <!-- </view>-->
  92. <!-- </view>-->
  93. <!-- </live-player>-->
  94. <!-- </view>-->
  95. <!-- </view>-->
  96. <!--</template>-->
  97. <!--<script>-->
  98. <!--export default {-->
  99. <!-- data() {-->
  100. <!-- return {-->
  101. <!-- isPlaySource: false, //是否有播放源-->
  102. <!-- isVideoLive: false, //是否是直播-->
  103. <!-- isAutoplay: true, //是否自动播放-->
  104. <!-- videoMsg: '', //video消息-->
  105. <!-- currentUrl: '', //播放路径-->
  106. <!-- showControlbar: true,-->
  107. <!-- timer:null,-->
  108. <!-- }-->
  109. <!-- },-->
  110. <!-- watch: {-->
  111. <!-- showControlbar(val, oldVal) {-->
  112. <!-- if(val){-->
  113. <!-- this.timer = setTimeout(()=>{-->
  114. <!-- this.showControlbar = false-->
  115. <!-- },5000)-->
  116. <!-- }else{-->
  117. <!-- clearTimeout(this.timer);-->
  118. <!-- }-->
  119. <!-- }-->
  120. <!-- },-->
  121. <!-- onLoad() {-->
  122. <!-- this.playerCtx = uni.createLivePlayerContext('livePlayer');-->
  123. <!-- },-->
  124. <!-- created() {-->
  125. <!-- this.getLiveList() //视频流列表-->
  126. <!-- setTimeout(()=>{-->
  127. <!-- this.showControlbar = false-->
  128. <!-- },10000)-->
  129. <!-- },-->
  130. <!-- methods: {-->
  131. <!-- handleControlbar() {-->
  132. <!-- this.showControlbar = !this.showControlbar-->
  133. <!-- },-->
  134. <!-- getLiveList() {-->
  135. <!-- this.$api.livePage.getLiveList().then(res => {-->
  136. <!-- //业务逻辑-->
  137. <!-- }).catch(err => {-->
  138. <!-- console.log('err');-->
  139. <!-- });-->
  140. <!-- },-->
  141. <!-- // 巡航-->
  142. <!-- handleCruise() {-->
  143. <!-- // #ifdef MP-WEIXIN-->
  144. <!-- uni.vibrateShort();-->
  145. <!-- // #endif-->
  146. <!-- },-->
  147. <!-- //全屏功能的实现-->
  148. <!-- handleFullScreen() {-->
  149. <!-- var that = this-->
  150. <!-- if (!that.fullScreenFlag) {-->
  151. <!-- //全屏-->
  152. <!-- that.playerCtx.requestFullScreen({-->
  153. <!-- success: res => {-->
  154. <!-- that.fullScreenFlag = true-->
  155. <!-- console.log('我要执行了');-->
  156. <!-- },-->
  157. <!-- fail: res => {-->
  158. <!-- console.log('fullscreen fail');-->
  159. <!-- },-->
  160. <!-- direction: 90-->
  161. <!-- });-->
  162. <!-- } else {-->
  163. <!-- //缩小-->
  164. <!-- that.playerCtx.exitFullScreen({-->
  165. <!-- success: res => {-->
  166. <!-- that.fullScreenFlag = false-->
  167. <!-- console.log('我要执行了');-->
  168. <!-- },-->
  169. <!-- fail: res => {-->
  170. <!-- console.log('exit fullscreen success');-->
  171. <!-- }-->
  172. <!-- });-->
  173. <!-- }-->
  174. <!-- },-->
  175. <!-- }-->
  176. <!--}-->
  177. <!--</script>-->
  178. <!--<style lang="scss" scoped>-->
  179. <!--.content {-->
  180. <!-- width: 100%;-->
  181. <!-- height: 100%;-->
  182. <!-- display: flex;-->
  183. <!-- flex-direction: column;-->
  184. <!-- .player-content {-->
  185. <!-- position: relative;-->
  186. <!-- width: 100%;-->
  187. <!-- height: 450rpx;-->
  188. <!-- display: flex;-->
  189. <!-- background-size: 100% 100%;-->
  190. <!-- .live-player {-->
  191. <!-- width: 100%;-->
  192. <!-- height: 100%;-->
  193. <!-- position: relative;-->
  194. <!-- }-->
  195. <!-- }-->
  196. <!--}-->
  197. <!--//播放器弹出工具-->
  198. <!--.player-tool {-->
  199. <!-- width: 100%;-->
  200. <!-- height: 60rpx;-->
  201. <!-- background-image: linear-gradient(0deg, rgba(0, 0, 0, .6), transparent);-->
  202. <!-- display: flex;-->
  203. <!-- align-items: center;-->
  204. <!-- justify-content: space-between;-->
  205. <!-- position: absolute;-->
  206. <!-- left: 0;-->
  207. <!-- padding: 0 45rpx;-->
  208. <!-- transition: all 0.3s;-->
  209. <!-- .tools {-->
  210. <!-- height: 100%;-->
  211. <!-- width: auto;-->
  212. <!-- display: flex;-->
  213. <!-- align-items: center;-->
  214. <!-- .full-screen {-->
  215. <!-- height: 100%;-->
  216. <!-- display: flex;-->
  217. <!-- align-items: center;-->
  218. <!-- justify-content: center;-->
  219. <!-- .iconfont {-->
  220. <!-- color: #fff;-->
  221. <!-- font-weight: bold;-->
  222. <!-- }-->
  223. <!-- }-->
  224. <!-- .cruise {-->
  225. <!-- display: flex;-->
  226. <!-- align-items: center;-->
  227. <!-- justify-content: center;-->
  228. <!-- margin-left: 25rpx;-->
  229. <!-- .iconfont {-->
  230. <!-- color: #E45A3E;-->
  231. <!-- font-size: 45rpx;-->
  232. <!-- }-->
  233. <!-- }-->
  234. <!-- }-->
  235. <!--}-->
  236. <!--</style>-->
  237. <!--&lt;!&ndash;<template>&ndash;&gt;-->
  238. <!--&lt;!&ndash; <view>&ndash;&gt;-->
  239. <!--&lt;!&ndash;&lt;!&ndash; <my-grid></my-grid>&ndash;&gt;&ndash;&gt;-->
  240. <!--&lt;!&ndash; <video&ndash;&gt;-->
  241. <!--&lt;!&ndash; id="myVideo"&ndash;&gt;-->
  242. <!--&lt;!&ndash; :src="src"&ndash;&gt;-->
  243. <!--&lt;!&ndash; :controls="controls"&ndash;&gt;-->
  244. <!--&lt;!&ndash; :autoplay="autoplay"&ndash;&gt;-->
  245. <!--&lt;!&ndash; style="width: 100%; height: 300px;"&ndash;&gt;-->
  246. <!--&lt;!&ndash; ></video>&ndash;&gt;-->
  247. <!--&lt;!&ndash; </view>&ndash;&gt;-->
  248. <!--&lt;!&ndash;</template>&ndash;&gt;-->
  249. <!--&lt;!&ndash;<script>&ndash;&gt;-->
  250. <!--&lt;!&ndash; export default {&ndash;&gt;-->
  251. <!--&lt;!&ndash; data() {&ndash;&gt;-->
  252. <!--&lt;!&ndash; return {&ndash;&gt;-->
  253. <!--&lt;!&ndash; src: '../../static/vedio/1.mp4', // 视频地址&ndash;&gt;-->
  254. <!--&lt;!&ndash; controls: true, // 是否显示控制条&ndash;&gt;-->
  255. <!--&lt;!&ndash; autoplay: false, // 是否自动播放&ndash;&gt;-->
  256. <!--&lt;!&ndash; };&ndash;&gt;-->
  257. <!--&lt;!&ndash; }&ndash;&gt;-->
  258. <!--&lt;!&ndash; }&ndash;&gt;-->
  259. <!--&lt;!&ndash;</script>&ndash;&gt;-->
  260. <!--&lt;!&ndash;<style lang="scss">&ndash;&gt;-->
  261. <!--&lt;!&ndash;</style>&ndash;&gt;-->