liveDetail.nvue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <view class="container" :style="'height: '+windowHeight+'px;'">
  3. <jhlive ref="jhlive" class="jhlive" :sdkAppID="sdkAppID" :secretKey="secretKey" :userId="userId" :roomId="roomId"
  4. :isAuthor="isAuthor" :linkMic="linkMic" :avatar="avatar" :num="num" :likes="likes" :name="name" />
  5. <jhimlive ref="jhimlive" class="jhimlive" :sdkAppID="sdkAppID" :secretKey="secretKey" :userId="userId" :roomId="roomId"
  6. :isAuthor="isAuthor" :avatar="avatar" :name="name" @onMemberCount="num=$event" />
  7. <view class="popup-open" @click="openPop()">
  8. <!-- #ifdef APP-PLUS -->
  9. <text class="nvue-iconfont" :style="{fontFamily:'nvueIconfont'}">&#xe63f;</text>
  10. <!-- #endif -->
  11. <!-- #ifdef MP-WEIXIN -->
  12. <text class="iconfont iconzhibo-shangpin"></text>
  13. <!-- #endif -->
  14. </view>
  15. <uni-popup ref="popup" animation type="bottom">
  16. <view class="popup-box">
  17. <view class="popup-close">
  18. <text class="popup-close-text" @click="closePop()">收起</text>
  19. <text class="popup-close-text">绑定</text>
  20. </view>
  21. <scroll-view v-if="true" scroll-y="true" class="good-box2">
  22. <view class="goods-row2" v-for="(item, index) in goodsList" :key="index">
  23. <view class="good-check">
  24. <view @click="checkGoods(item)">
  25. <!-- #ifdef MP-WEIXIN -->
  26. <text class="iconfont good-check-iconfont" :class="item.check ? 'iconqueding' : 'iconfeigouxuan'" ></text>
  27. <!-- #endif -->
  28. </view>
  29. <!-- #ifdef APP-PLUS -->
  30. <text class="nvue-iconfont good-check-iconfont" :style="{fontFamily:'nvueIconfont'}">{{item.check ? '&#xe626;' : '&#xe646;'}}</text>
  31. <!-- #endif -->
  32. </view>
  33. <view class="good-card2">
  34. <view class="goods-img-box2">
  35. <image class="goods-img2" :src="item.imgPath" mode="aspectFill"></image>
  36. </view>
  37. <view class="goods-info2">
  38. <view>
  39. <text class="goods-name2">{{item.productName}}</text>
  40. </view>
  41. <text class="goods-sales2">销量:{{item.sellCount}}</text>
  42. <text class="price2">原价:{{item.originalPrice}}</text>
  43. <view class="goods-number2">
  44. <text class="goods-icon2">¥</text>
  45. <text class="goods-icon2">{{item.bizPrice}}/{{item.unit}}</text>
  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: '1',
  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: [],
  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. domModule.addRule('fontFace', {
  96. 'fontFamily': "nvueIconfont",
  97. 'src': "url('https://at.alicdn.com/t/font_2119167_43jbldmjpr3.ttf')"
  98. });
  99. },
  100. onLoad(options) {
  101. this.liveId = options.liveId
  102. this.userData = uni.getStorageSync("userData");
  103. this.userId = this.userData.userId;
  104. let info = uni.getSystemInfoSync();
  105. this.windowWidth = info.windowWidth;
  106. this.windowHeight = info.windowHeight;
  107. // 假数据
  108. this.goodsList.push({
  109. productId: 1336146105292816384,
  110. tenantCode: null,
  111. imgPath: 'https: //www.qianjiadi.com:443/file/2020/12/2af4eb48-35c4-4aa7-80c9-ab7a7cb49984.jpg',
  112. productName: '测试拍卖商品zxw111',
  113. sellCount: 0,
  114. owner: 1,
  115. productType: 2,
  116. originalPrice: 1.00,
  117. bizPrice: 0.01,
  118. unit: '个'
  119. },{
  120. productId: 1336146105292816386,
  121. tenantCode: null,
  122. imgPath: 'https: //www.qianjiadi.com:443/file/2020/12/2af4eb48-35c4-4aa7-80c9-ab7a7cb49984.jpg',
  123. productName: '测试拍卖商品zxw222',
  124. sellCount: 0,
  125. owner: 1,
  126. productType: 2,
  127. originalPrice: 1.00,
  128. bizPrice: 0.01,
  129. unit: '个'
  130. })
  131. this.goodsIds = this.goodsList.map(site => {
  132. return site.productId
  133. }).join(',')
  134. this.goodsList.forEach(site => {
  135. site.check = this.goodsIds.indexOf(site.productId) != -1
  136. })
  137. },
  138. onReady() {
  139. // this.isAuthor = false;
  140. // this.linkMic = true;
  141. // this.userId = "123";
  142. // this.name = 'test';
  143. // this.roomId = '1';
  144. // this.$nextTick(() => this.enterRoom());
  145. // return;
  146. this.init();
  147. },
  148. onUnload() {
  149. this.exitRoom();
  150. },
  151. methods: {
  152. init() {
  153. NET.request(API.startStream + 2, 'GET').then(res => {
  154. this.avatar = res.data.imgUrl;
  155. this.name = res.data.liveName;
  156. this.roomId = Number(res.data.roomId);
  157. this.$nextTick(() => this.enterRoom());
  158. }).catch(res => {
  159. uni.showToast({
  160. title: error.data.msg,
  161. duration: 2000
  162. });
  163. })
  164. },
  165. enterRoom() {
  166. this.$refs.jhimlive && this.$refs.jhimlive.enterRoom();
  167. this.$refs.jhlive && this.$refs.jhlive.enterRoom();
  168. },
  169. exitRoom() {
  170. this.$refs.jhimlive && this.$refs.jhimlive.exitRoom();
  171. this.$refs.jhlive && this.$refs.jhlive.exitRoom();
  172. NET.request(API.creatLive, {
  173. liveId: this.liveId,
  174. liveStatus: 2
  175. }, 'GET');
  176. },
  177. handleShop(msg) {},
  178. openPop() {
  179. this.$refs.popup.open()
  180. },
  181. closePop() {
  182. this.$refs.popup.close()
  183. },
  184. // 勾选商品
  185. checkGoods(site) {
  186. site.check = !site.check
  187. }
  188. },
  189. }
  190. </script>
  191. <style>
  192. .nvue-iconfont {
  193. font-family: "nvueIconfont";
  194. font-size: 16px;
  195. font-style: normal;
  196. -webkit-font-smoothing: antialiased;
  197. -moz-osx-font-smoothing: grayscale;
  198. }
  199. </style>
  200. <style lang="less" scoped>
  201. .container {
  202. position: relative;
  203. display: flex;
  204. flex-direction: column;
  205. align-items: stretch;
  206. width: 750rpx;
  207. }
  208. .jhlive {
  209. width: 750rpx;
  210. flex: 1;
  211. }
  212. .jhimlive {
  213. width: 400rpx;
  214. position: absolute;
  215. bottom: 10px;
  216. left: 10px;
  217. // background-color: blue;
  218. }
  219. .popup-open {
  220. width: 50px;
  221. height: 50px;
  222. position: fixed;
  223. bottom: 15px;
  224. right: 15px;
  225. background-color: #52A63A;
  226. border-radius: 50%;
  227. text-align: center;
  228. line-height: 50px;
  229. }
  230. .iconzhibo-shangpin {
  231. color: #FFFFFF;
  232. font-size: 34px;
  233. }
  234. .popup-box {
  235. background-color: #FFFFFF;
  236. width: 750rpx;
  237. height: 265px;
  238. // border-radius: 10px 10px 0 0;
  239. border-top-left-radius:10px;
  240. border-top-right-radius: 10px;
  241. }
  242. .popup-close {
  243. padding: 10px;
  244. line-height: 16px;
  245. display: flex;
  246. flex-direction: row;
  247. justify-content: space-between;
  248. }
  249. .popup-close-text{
  250. color: #52A63A;
  251. font-size: 15px;
  252. font-family: PingFang SC;
  253. }
  254. // 商户端直播样式,暂时在用户端里调试
  255. .good-check {
  256. width: 30px;
  257. height: 104px;
  258. line-height: 104px;
  259. margin-right: 10px;
  260. }
  261. .good-check-iconfont {
  262. font-size: 40px;
  263. text-align: center;
  264. color: #51A539;
  265. line-height: 104px;
  266. }
  267. .good-box2 {
  268. width: 750rpx;
  269. height: 230px;
  270. padding: 0 0 10px 0;
  271. overflow: visible;
  272. }
  273. .goods-row2:first-child {
  274. margin-top: 12px;
  275. }
  276. .goods-row2 {
  277. width: 700rpx;
  278. height: 104px;
  279. display: flex;
  280. flex-direction: row;
  281. flex-wrap: nowrap;
  282. background-color: #FFFFFF;
  283. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.1);
  284. border-radius: 5px;
  285. margin: 0 15px 10px 15px;
  286. }
  287. .good-card2 {
  288. display: flex;
  289. flex-direction: row;
  290. flex-wrap: nowrap;
  291. }
  292. .goods-img-box2 {
  293. margin-right: 15px;
  294. }
  295. .goods-img2 {
  296. width: 104px;
  297. height: 104px;
  298. object-fit: cover;
  299. }
  300. .goods-info2 {
  301. width: 180px;
  302. flex: 1;
  303. padding-top: 10px;
  304. }
  305. .goods-name2 {
  306. line-height: 15px;
  307. overflow: hidden;
  308. display: -webkit-box;
  309. -webkit-line-clamp: 2;
  310. -webkit-box-orient: vertical;
  311. word-wrap: break-word;
  312. text-overflow: ellipsis;
  313. font-size: 15px;
  314. font-family: PingFang SC;
  315. color: #333333;
  316. }
  317. .goods-sales2 {
  318. font-size: 12px;
  319. font-family: PingFang SC;
  320. color: #666666;
  321. line-height: 15px;
  322. margin: 8px 0 8px 0;
  323. }
  324. .price2 {
  325. font-size: 12px;
  326. text-decoration: line-through;
  327. color: #A67954;
  328. }
  329. .goods-number-bottom2 {
  330. display: flex;
  331. flex-direction: row;
  332. }
  333. .goods-number2 {
  334. display: flex;
  335. flex-direction: row;
  336. white-space: nowrap;
  337. line-height: 24px;
  338. }
  339. .goods-number-left2 {
  340. font-size: 12px;
  341. color: #666666;
  342. }
  343. .goods-icon2 {
  344. font-size: 14px;
  345. font-family: PingFang SC;
  346. color: #52A63A;
  347. }
  348. .goods-spec2 {
  349. font-size: 24px;
  350. font-family: PingFang SC;
  351. color: #52A63A;
  352. }
  353. </style>