liveDetail.nvue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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="name"
  8. :imMsgs="imMsgs" @onImSend="onImSend" />
  9. <!-- <view class="popup-open" @click="openPop()"> -->
  10. <!-- #ifdef APP-PLUS -->
  11. <!-- <text class="nvue-iconfont iconzhibo-shangpin" :style="{fontFamily:'nvueIconfont'}">&#xe63f;</text> -->
  12. <!-- #endif -->
  13. <!-- #ifdef MP-WEIXIN -->
  14. <!-- <text class="iconfont iconzhibo-shangpin"></text> -->
  15. <!-- #endif -->
  16. <!-- </view> -->
  17. <uni-popup ref="popup" animation type="bottom">
  18. <view class="popup-box">
  19. <view class="popup-close">
  20. <text class="popup-close-text" @click="closePop()">收起</text>
  21. </view>
  22. <scroll-view scroll-y="true" class="good-box">
  23. <view class="goods-row" v-for="(item, index) in goodsList" :key="index" @click="goToGoodDetails(item)">
  24. <view class="goods-img-box">
  25. <image class="goods-img" :src="item.imgPath" mode="aspectFill"></image>
  26. </view>
  27. <view class="goods-info">
  28. <view>
  29. <text class="goods-name">{{item.productName}}</text>
  30. </view>
  31. <text class="goods-sales">{{item.sellCount}}人付款</text>
  32. <text class="price">原价:{{item.originalPrice}}</text>
  33. <view class="goods-number-bottom">
  34. <view class="goods-number">
  35. <!-- <text class="goods-number-left">惊爆价:</text> -->
  36. <text class="goods-icon">¥</text>
  37. <text class="goods-spec">{{item.bizPrice}}</text>
  38. </view>
  39. <view class="more-button">
  40. <!-- #ifdef APP-PLUS -->
  41. <text class="nvue-iconfont more-button-iconfont" :style="{fontFamily:'nvueIconfont'}">&#xe623;</text>
  42. <!-- #endif -->
  43. <!-- #ifdef MP-WEIXIN -->
  44. <text class="iconfont more-button-iconfont icongengduo"></text>
  45. <!-- #endif -->
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. </uni-popup>
  53. </view>
  54. </template>
  55. <script>
  56. import jhlive from "@/jhlive/jhlive";
  57. import jhimlive from "@/jhim/jhimlive";
  58. const NET = require('@/utils/request')
  59. const API = require('@/config/api')
  60. export default {
  61. components: {
  62. jhlive,
  63. jhimlive
  64. },
  65. data() {
  66. return {
  67. isAuthor: true,
  68. linkMic: false,
  69. sdkAppID: API.sdkAppID,
  70. secretKey: API.secretKey,
  71. windowWidth: 0,
  72. windowHeight: 0,
  73. userId: '',
  74. roomId: '',
  75. liveId: '',
  76. num: 0,
  77. likes: 0,
  78. name: "",
  79. avatar: "../static/images/loginLogo.png",
  80. userData: {},
  81. enabledIM: false,
  82. imReady: false,
  83. imMsgs: [{name: '小鱼小鱼', text:'好吃'}, {name: '小鱼小鱼hh', text:'还想买哈哈哈哈'}],
  84. videoUrl: '',
  85. goodsList: [],
  86. goodsIds:[]
  87. }
  88. },
  89. beforeCreate() {
  90. uni.showToast({
  91. title: '222',
  92. duration: 2000
  93. })
  94. const domModule = uni.requireNativePlugin('dom')
  95. console.log(111111111111111111, domModule)
  96. domModule.addRule('fontFace', {
  97. 'fontFamily': "nvueIconfont",
  98. 'src': "url('https://at.alicdn.com/t/font_2119167_43jbldmjpr3.ttf')"
  99. });
  100. console.log(222222222222222)
  101. },
  102. onLoad(options) {
  103. this.roomId = options.roomId;
  104. this.liveId = options.liveId
  105. this.userData = uni.getStorageSync("userData");
  106. this.userId = this.userData.userId;
  107. let info = uni.getSystemInfoSync();
  108. this.windowWidth = info.windowWidth;
  109. this.windowHeight = info.windowHeight;
  110. this.videoUrl = uni.getStorageSync("videoUrl").replace("http://", "https://")
  111. NET.request(API.getLiveGoodsDetail + options.liveId, {}, 'GET').then(res => {
  112. this.goodsList = res.data
  113. }).catch(res => {
  114. this.$refs.uTips.show({
  115. title: '获取商品列表失败',
  116. type: 'warning',
  117. })
  118. })
  119. },
  120. onReady() {
  121. this.isAuthor = false;
  122. this.linkMic = true;
  123. this.userId = "123";
  124. this.name = 'test';
  125. this.roomId = '1';
  126. this.$nextTick(() => this.enterRoom());
  127. return;
  128. this.init();
  129. },
  130. onUnload() {
  131. this.exitRoom();
  132. },
  133. methods: {
  134. init() {
  135. this.avatar = uni.getStorageSync("liveImgUrl");
  136. this.name = uni.getStorageSync("liveName");
  137. this.$nextTick(() => this.enterRoom());
  138. },
  139. enterRoom() {
  140. this.$refs.jhimlive && this.$refs.jhimlive.enterRoom();
  141. this.$refs.jhlive && this.$refs.jhlive.enterRoom();
  142. },
  143. exitRoom() {
  144. this.$refs.jhimlive && this.$refs.jhimlive.exitRoom();
  145. this.$refs.jhlive && this.$refs.jhlive.exitRoom();
  146. },
  147. handleShop(msg) {},
  148. openPop() {
  149. this.$refs.popup.open()
  150. },
  151. closePop() {
  152. this.$refs.popup.close()
  153. },
  154. goToGoodDetails(item) {
  155. uni.navigateTo({
  156. url: '/pagesGood/goodDetails?goodId=' + item.productId
  157. });
  158. },
  159. onImSend(text) {
  160. this.imMsgs.push({name: 'xxx', text})
  161. }
  162. },
  163. }
  164. </script>
  165. <style>
  166. .nvue-iconfont {
  167. font-family: "nvueIconfont";
  168. font-size: 16px;
  169. font-style: normal;
  170. -webkit-font-smoothing: antialiased;
  171. -moz-osx-font-smoothing: grayscale;
  172. }
  173. </style>
  174. <style lang="less" scoped>
  175. .container {
  176. position: relative;
  177. display: flex;
  178. flex-direction: column;
  179. align-items: stretch;
  180. width: 750rpx;
  181. }
  182. .jhlive {
  183. width: 750rpx;
  184. flex: 1;
  185. }
  186. .jhimlive {
  187. width: 400rpx;
  188. position: absolute;
  189. bottom: 10px;
  190. left: 10px;
  191. }
  192. .popup-open {
  193. width: 50px;
  194. height: 50px;
  195. position: fixed;
  196. bottom: 15px;
  197. right: 15px;
  198. background-color: #52A63A;
  199. border-radius: 50%;
  200. text-align: center;
  201. line-height: 50px;
  202. }
  203. .iconzhibo-shangpin {
  204. color: #FFFFFF;
  205. font-size: 34px;
  206. text-align: center;
  207. line-height: 50px;
  208. }
  209. .popup-box {
  210. background-color: #FFFFFF;
  211. width: 750rpx;
  212. height: 265px;
  213. border-top-left-radius: 10px;
  214. border-top-right-radius: 10px;
  215. }
  216. .popup-close {
  217. padding: 10px;
  218. line-height: 16px;
  219. }
  220. .popup-close-text {
  221. color: #52A63A;
  222. font-size: 15px;
  223. font-family: PingFang SC;
  224. text-align: left;
  225. }
  226. .good-box {
  227. width: 750rpx;
  228. height: 230px;
  229. padding: 0 0 10px 0;
  230. overflow: visible;
  231. }
  232. .goods-row:first-child {
  233. margin-top: 12px;
  234. }
  235. .goods-row {
  236. width: 700rpx;
  237. height: 104px;
  238. display: flex;
  239. flex-direction: row;
  240. flex-wrap: nowrap;
  241. background-color: #FFFFFF;
  242. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.1);
  243. border-radius: 5px;
  244. margin: 0 15px 10px 15px;
  245. }
  246. .goods-img-box {
  247. margin-right: 15px;
  248. }
  249. .goods-img {
  250. width: 104px;
  251. height: 104px;
  252. object-fit: cover;
  253. }
  254. .goods-info {
  255. flex: 1;
  256. padding-top: 10px;
  257. }
  258. .goods-name {
  259. line-height: 15px;
  260. overflow: hidden;
  261. display: -webkit-box;
  262. -webkit-line-clamp: 2;
  263. -webkit-box-orient: vertical;
  264. word-wrap: break-word;
  265. text-overflow: ellipsis;
  266. font-size: 15px;
  267. font-family: PingFang SC;
  268. color: #333333;
  269. }
  270. .goods-sales {
  271. font-size: 12px;
  272. font-family: PingFang SC;
  273. color: #666666;
  274. line-height: 15px;
  275. margin: 8px 0 8px 0;
  276. }
  277. .price {
  278. font-size: 12px;
  279. text-decoration: line-through;
  280. color: #A67954;
  281. }
  282. .goods-number-bottom {
  283. display: flex;
  284. flex-direction: row;
  285. }
  286. .goods-number {
  287. display: flex;
  288. flex-direction: row;
  289. white-space: nowrap;
  290. line-height: 24px;
  291. }
  292. .goods-number-left {
  293. font-size: 12px;
  294. color: #666666;
  295. }
  296. .goods-icon {
  297. font-size: 14px;
  298. font-family: PingFang SC;
  299. color: #52A63A;
  300. }
  301. .goods-spec {
  302. font-size: 24px;
  303. font-family: PingFang SC;
  304. color: #52A63A;
  305. }
  306. .more-button {
  307. width: 24px;
  308. height: 24px;
  309. position: absolute;
  310. right: 16px;
  311. }
  312. .more-button-iconfont {
  313. font-size: 36px;
  314. color: #999999;
  315. text-align: center;
  316. }
  317. </style>