pickVideo.nvue 5.9 KB

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