pickVideo.nvue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="container" :style="'height: '+windowHeight+'px;'">
  3. <jhlive
  4. ref="jhlive" class="jhlive"
  5. :sdkAppID="sdkAppID" :secretKey="secretKey" :userId="userId" :roomId="roomId"
  6. :isAuthor="isAuthor" :linkMic="linkMic"
  7. :showSwitch="true"
  8. :avatar="avatar" :subtitle="num?'已连接':'等待用户进入'" :title="title"
  9. :btns="btns" @onBtnClick="onBtnClick"
  10. @onRemoteUser="handleRemoteUser" />
  11. <uni-popup ref="popup" animation type="bottom">
  12. <view class="popup-box">
  13. <view class="popup-close">
  14. <text class="popup-close-text" @click="$refs.popup.close()">收起</text>
  15. </view>
  16. <scroll-view scroll-y="true" class="good-box">
  17. <view class="goods-row" v-for="(item, index) in goodsList" :key="index">
  18. <view class="goods-img-box">
  19. <image class="goods-img" :src="item.imgPath" mode="aspectFill"></image>
  20. </view>
  21. <view class="goods-info">
  22. <view>
  23. <text class="goods-name">{{item.productName}}</text>
  24. </view>
  25. <text class="goods-sales">{{item.sellCount ? item.sellCount : 0}}人付款</text>
  26. <text class="price">原价:{{item.originalPrice}}</text>
  27. <view class="goods-number-bottom">
  28. <view class="goods-number">
  29. <!-- <text class="goods-number-left">惊爆价:</text> -->
  30. <text class="goods-icon">¥</text>
  31. <text class="goods-spec">{{item.bizPrice}}</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </scroll-view>
  37. </view>
  38. </uni-popup>
  39. </view>
  40. </template>
  41. <script>
  42. import jhlive from "@/jhlive/jhlive";
  43. import permision from "@/utils/permission.js"
  44. const NET = require('@/utils/request')
  45. const API = require('@/config/api')
  46. export default {
  47. components: { jhlive },
  48. data() {
  49. return {
  50. windowWidth: 0,
  51. windowHeight: 0,
  52. userData: {},
  53. orderId: '',
  54. tenantCode: '',
  55. goodsList: [],
  56. liveId: '',
  57. isAuthor: true,
  58. linkMic: false,
  59. sdkAppID:API.sdkAppID,
  60. secretKey:API.secretKey,
  61. btns: [{picture:"../static/images/live-good.png",title:''}],
  62. userId: '',
  63. roomId: '',
  64. title: "暂无",
  65. num: 0,
  66. avatar: "../static/images/loginLogo.png",
  67. }
  68. },
  69. onLoad(options) {
  70. this.orderId = options.orderId
  71. this.userData = uni.getStorageSync("userData");
  72. this.userId = this.userData.userId;
  73. let info = uni.getSystemInfoSync();
  74. this.windowWidth = info.windowWidth;
  75. this.windowHeight = info.windowHeight;
  76. },
  77. onReady() {
  78. this.init();
  79. },
  80. methods: {
  81. init() {
  82. NET.request(API.creatPickVideo, {orderId: this.orderId}, 'GET').then(res => {
  83. this.liveId = res.data.liveId
  84. this.roomId = res.data.roomId;
  85. this.goodsList = res.data.liveProducResVO
  86. this.$nextTick(() => {
  87. permision.checkAndRequestPermissions(['scope.camera', 'scope.record']).then(()=>{
  88. this.enterRoom();
  89. }, ()=>{
  90. uni.showToast({
  91. title: '获取权限失败',
  92. duration: 2000,
  93. })
  94. })
  95. });
  96. }).catch(error => {
  97. uni.showToast({
  98. title: error.data.msg,
  99. duration: 2000
  100. });
  101. })
  102. },
  103. enterRoom() {
  104. this.$refs.jhlive&&this.$refs.jhlive.enterRoom();
  105. },
  106. exitRoom() {
  107. this.$refs.jhlive&&this.$refs.jhlive.exitRoom();
  108. },
  109. handleRemoteUser(users) {
  110. console.log('获取自助采摘观看人数', users)
  111. this.num = users.length;
  112. this.subtitle = users.length;
  113. users.length&&NET.request(API.getMainInfo +"?userId="+ users[0], {}, 'GET').then(res => {
  114. console.log('获取用户信息', res)
  115. this.avatar = res.data.headimg;
  116. this.title = res.data.nickname;
  117. }).catch(error => {
  118. uni.showToast({
  119. title: error.data.msg,
  120. duration: 2000
  121. });
  122. })
  123. },
  124. onBtnClick(index, item) {
  125. if(index === 0) {
  126. this.$refs.popup.open()
  127. }
  128. },
  129. }
  130. }
  131. </script>
  132. <style lang="less" scoped>
  133. .container {
  134. position: relative;
  135. display: flex;
  136. flex-direction: column;
  137. align-items: stretch;
  138. width: 750rpx;
  139. }
  140. .jhlive {
  141. width: 750rpx;
  142. flex: 1;
  143. }
  144. .popup-open {
  145. width: 50px;
  146. height: 50px;
  147. position: fixed;
  148. bottom: 15px;
  149. right: 15px;
  150. background-color: #52A63A;
  151. border-radius: 50%;
  152. text-align: center;
  153. line-height: 50px;
  154. }
  155. .iconzhibo-shangpin {
  156. color: #FFFFFF;
  157. font-size: 34px;
  158. text-align: center;
  159. line-height: 50px;
  160. }
  161. .popup-box {
  162. background-color: #FFFFFF;
  163. width: 750rpx;
  164. height: 750rpx;
  165. border-top-left-radius: 10px;
  166. border-top-right-radius: 10px;
  167. }
  168. .popup-close {
  169. padding: 10px;
  170. line-height: 16px;
  171. }
  172. .popup-close-text {
  173. color: #52A63A;
  174. font-size: 15px;
  175. font-family: PingFang SC;
  176. text-align: left;
  177. }
  178. .good-box {
  179. width: 750rpx;
  180. height: 750rpx;
  181. padding: 0 0 10px 0;
  182. overflow: visible;
  183. }
  184. .goods-row:first-child {
  185. margin-top: 12px;
  186. }
  187. .goods-row {
  188. width: 700rpx;
  189. height: 104px;
  190. display: flex;
  191. flex-direction: row;
  192. flex-wrap: nowrap;
  193. background-color: #FFFFFF;
  194. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.1);
  195. border-radius: 5px;
  196. margin: 0 15px 10px 15px;
  197. }
  198. .goods-img-box {
  199. margin-right: 15px;
  200. }
  201. .goods-img {
  202. width: 104px;
  203. height: 104px;
  204. object-fit: cover;
  205. }
  206. .goods-info {
  207. flex: 1;
  208. padding-top: 10px;
  209. }
  210. .goods-name {
  211. line-height: 15px;
  212. overflow: hidden;
  213. display: -webkit-box;
  214. -webkit-line-clamp: 2;
  215. -webkit-box-orient: vertical;
  216. word-wrap: break-word;
  217. text-overflow: ellipsis;
  218. font-size: 15px;
  219. font-family: PingFang SC;
  220. color: #333333;
  221. }
  222. .goods-sales {
  223. font-size: 12px;
  224. font-family: PingFang SC;
  225. color: #666666;
  226. line-height: 15px;
  227. margin: 8px 0 8px 0;
  228. }
  229. .price {
  230. font-size: 12px;
  231. text-decoration: line-through;
  232. color: #A67954;
  233. }
  234. .goods-number-bottom {
  235. display: flex;
  236. flex-direction: row;
  237. }
  238. .goods-number {
  239. display: flex;
  240. flex-direction: row;
  241. white-space: nowrap;
  242. line-height: 24px;
  243. }
  244. .goods-number-left {
  245. font-size: 12px;
  246. color: #666666;
  247. }
  248. .goods-icon {
  249. font-size: 14px;
  250. font-family: PingFang SC;
  251. color: #52A63A;
  252. }
  253. .goods-spec {
  254. font-size: 24px;
  255. font-family: PingFang SC;
  256. color: #52A63A;
  257. }
  258. </style>