RightPopup.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <!-- 右侧弹框 -->
  3. <van-popup :value="levitatedSphereVisible" @input="showChange" position="right" class="levitated-sphere-drawer"
  4. overlay-class="levitated-sphere-overlay" :overlay-style="{'background-color': 'transparent !important'}">
  5. <div class="flex-column" style="min-width: 50px;">
  6. <div class="flex-column-container">
  7. <div>
  8. <div v-for="item in definitionList" :key="item.key"
  9. :class="['tc drawer-item mb-4', {active: actDefinition === item.name}]"
  10. @click.prevent="definitionFun(item)">
  11. {{item.name}}
  12. </div>
  13. <!-- <div class="tc drawer-item mb-4" @click.prevent="resolutionRatio">
  14. 分辨率
  15. </div> -->
  16. <div class="tc drawer-item mb-4" @click.prevent="volumeControl(24)">
  17. 音量 +
  18. </div>
  19. <div class="tc drawer-item" @click.prevent="volumeControl(25)">
  20. 音量 -
  21. </div>
  22. </div>
  23. </div>
  24. <div class="exit">
  25. <template v-for="(item, index) in exitList">
  26. <div :key="item.key" :class="['tc', {'mb-4': index !== exitList.length - 1}, item.key]"
  27. @click.prevent="exitFun(item.key)">
  28. <img :src="item.img" alt="">
  29. <div class="drawer-item">
  30. {{item.name}}
  31. </div>
  32. </div>
  33. </template>
  34. </div>
  35. </div>
  36. </van-popup>
  37. </template>
  38. <script>
  39. export default {
  40. name: 'RightPopup',
  41. props: {
  42. // 拉流渲染引擎实例
  43. engine: {
  44. type: Object,
  45. default: () => ({})
  46. },
  47. // popup是否显示
  48. levitatedSphereVisible: {
  49. type: Boolean,
  50. default: false
  51. },
  52. // 清晰度默认值
  53. definitionValue: {
  54. type: String,
  55. default: ()=> localStorage.getItem('definitionValue') ?? '标清',
  56. },
  57. // 清晰度列表
  58. definitionList: {
  59. type: Array,
  60. default: () => [{
  61. name: '自动',
  62. value: 2800
  63. }, {
  64. name: '高清',
  65. value: 2800
  66. }, {
  67. name: '标清',
  68. value: 1500,
  69. }, {
  70. name: '流畅',
  71. value: 1000,
  72. }]
  73. },
  74. // 清晰度对应分辨率和帧率列表
  75. resolutionRatioList: {
  76. type: Object,
  77. default: () => ({
  78. '自动': { width: 720, height: 1280, fps: 30 },
  79. '高清': { width: 720, height: 1280, fps: 30 },
  80. '标清': { width: 540, height: 960, fps: 25 },
  81. '流畅': { width: 450, height: 800, fps: 20 },
  82. })
  83. },
  84. // url中获取的参数, 父组件传递
  85. parametersData: {
  86. type: Object,
  87. default: () => ({})
  88. },
  89. },
  90. data() {
  91. return {
  92. // 当前清晰度
  93. actDefinition: this.definitionValue,
  94. }
  95. },
  96. computed: {
  97. // 右侧弹框退出相关按钮
  98. exitList() {
  99. let arr = [{
  100. name: '剪贴版',
  101. key: "shearplate",
  102. img: '../static/img/wx/jianqieban_icon.png'
  103. }, {
  104. name: '退出',
  105. key: 'signout',
  106. img: '../static/img/wx/tuichu_icon.png'
  107. }]
  108. if ([1, 2, 3].includes(+this.parametersData.userCardType)) {
  109. arr.push({
  110. name: '退出并下机',
  111. key: 'dormant',
  112. img: '../static/img/wx/tuichu_icon.png'
  113. })
  114. }
  115. return arr
  116. }
  117. },
  118. methods: {
  119. showChange(val){
  120. this.$emit('update:levitatedSphereVisible', val);
  121. },
  122. // 清晰度 画质
  123. definitionFun(item) {
  124. try {
  125. this.actDefinition = item.name;
  126. // 设置日志参数 推流质量
  127. // logReportObj.setParams({ imageQuality: item.name });
  128. localStorage.setItem('definitionValue', item.name);
  129. // 设置码率
  130. this.setBitrate(item);
  131. this.$emit('update:levitatedSphereVisible', false);
  132. } catch (err) {
  133. console.log(err)
  134. }
  135. },
  136. // 设置码率
  137. setBitrate(item) {
  138. // 设置码率和是否允许自动
  139. this.engine?.setCustomBitrate(item.value, item.name === '自动');
  140. // 获取并设置编码器分辨率和帧率
  141. const config = this.resolutionRatioList[item.name];
  142. if (config) {
  143. this.engine?.setEncoderSize(config);
  144. }
  145. },
  146. // 分辨率 已无用,2.0sdk只能固定的几个分辨率值 resolutionRatioList
  147. resolutionRatio() {
  148. request.get('/api/resources/v5/machine/resolution/getResolvingPower', { params: { userCardId: this.parametersData.userCardId } }).then(res => {
  149. if (res.success) {
  150. this.resolutionRatioList = res.data.map(item => {
  151. item.height = item.high
  152. return item
  153. })
  154. }
  155. })
  156. },
  157. // 音量控制 24: 音量+ 25: 音量-
  158. volumeControl(value) {
  159. this.engine.sendKey && this.engine.sendKey(value)
  160. // this.$refs.rtcMediaPlayer && (this.$refs.rtcMediaPlayer.muted = false)
  161. },
  162. // 退出相关按钮操作
  163. exitFun(key) {
  164. console.log(key)
  165. switch (key) {
  166. case 'dormant': // 退出并下机
  167. this.$dialog.alert({
  168. title: '提示',
  169. message: '确定退出云手机并下机',
  170. confirmButtonText: '确定',
  171. confirmButtonColor: '#3cc51f',
  172. showCancelButton: true,
  173. beforeClose: (action, done) => {
  174. if (action === 'cancel') done()
  175. if (action === 'confirm') {
  176. // this.downline(done)
  177. }
  178. }
  179. })
  180. break;
  181. case 'shearplate': // 剪贴板
  182. // 打开剪贴板
  183. this.$emit('shearplate');
  184. // 关闭popup
  185. this.$emit('update:levitatedSphereVisible', false);
  186. break;
  187. case 'signout':
  188. // 关闭popup
  189. this.$emit('update:levitatedSphereVisible', false);
  190. break;
  191. }
  192. },
  193. close() {
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang="less" scoped>
  199. .levitated-sphere-drawer {
  200. height: 100%;
  201. max-height: none !important;
  202. min-width: 1rem;
  203. color: #fff;
  204. background-color: rgba(2, 2, 6, 0.5);
  205. padding: 30px 10px 0;
  206. box-sizing: border-box;
  207. }
  208. .levitated-sphere-drawer .drawer-item {
  209. line-height: 30px;
  210. border-radius: 3px;
  211. -moz-user-select: none;
  212. -webkit-user-select: none;
  213. -ms-user-select: none;
  214. -khtml-user-select: none;
  215. user-select: none;
  216. }
  217. .levitated-sphere-drawer .drawer-item.active {
  218. background: rgb(255, 255, 255);
  219. color: #000;
  220. }
  221. .levitated-sphere-drawer .exit {
  222. line-height: 30px;
  223. }
  224. .levitated-sphere-drawer .exit img {
  225. width: 24px;
  226. height: 24px;
  227. }
  228. .flex-column {
  229. height: 100%;
  230. display: flex;
  231. flex-direction: column;
  232. }
  233. .flex-column-container {
  234. flex: 1;
  235. overflow-y: auto;
  236. }
  237. .tc {
  238. text-align: center;
  239. }
  240. </style>