|
|
@@ -1,22 +1,32 @@
|
|
|
<config>
|
|
|
{
|
|
|
- "navigationBarTitleText": "选择直播商品",
|
|
|
+ "navigationBarTitleText": "",
|
|
|
"navigationBarBackgroundColor": "#ffffff",
|
|
|
"navigationBarTextStyle": "black"
|
|
|
}
|
|
|
</config>
|
|
|
<template>
|
|
|
<div class="list">
|
|
|
- <div class="procuct" v-for="(item, index) in list" :key="index">
|
|
|
- <van-icon
|
|
|
- @click="choose(item.cardCaseId)"
|
|
|
- :color="checkChoose(item.cardCaseId) ? $colors.prim : '#C8C9CC'"
|
|
|
- class="check"
|
|
|
- :name="checkChoose(item.cardCaseId) ? 'checked' : 'circle'"
|
|
|
- size="18px"
|
|
|
- />
|
|
|
- <product-info :info="item" isMine :showBtn="false" startChoose @choose="choose"></product-info>
|
|
|
- </div>
|
|
|
+ <block v-if="isStart">
|
|
|
+ <!-- <div class="page-title">直播商品列表</div> -->
|
|
|
+ <div class="procuct" v-for="(item, index) in list" :key="index">
|
|
|
+ <product-info :info="item" :showBtn="false" startChoose></product-info>
|
|
|
+ </div>
|
|
|
+ </block>
|
|
|
+ <block v-else>
|
|
|
+ <div class="procuct" v-for="(item, index) in list" :key="index">
|
|
|
+ <van-icon
|
|
|
+ @click="choose(item.cardCaseId)"
|
|
|
+ :color="checkChoose(item.cardCaseId) ? $colors.prim : '#C8C9CC'"
|
|
|
+ class="check"
|
|
|
+ :name="checkChoose(item.cardCaseId) ? 'checked' : 'circle'"
|
|
|
+ size="18px"
|
|
|
+ />
|
|
|
+ <div class="product-content">
|
|
|
+ <product-info :info="item" isMine :showBtn="false" startChoose @choose="choose"></product-info>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </block>
|
|
|
<van-empty
|
|
|
v-if="empty"
|
|
|
image="https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/wechat/kong_png_wukabao.png"
|
|
|
@@ -25,9 +35,29 @@
|
|
|
</van-empty>
|
|
|
|
|
|
<div class="bottom">
|
|
|
- <button-bg type="warning">全选</button-bg>
|
|
|
- <button-bg type="prim" isRight :disabled="chooseIds.length === 0" @click="start">确认开启</button-bg>
|
|
|
+ <block v-if="isStart">
|
|
|
+ <button-bg type="warning" @click="getPushUrl(true)">推流地址</button-bg>
|
|
|
+ <button-bg type="prim" isRight @click="end">结束直播</button-bg>
|
|
|
+ </block>
|
|
|
+ <block v-else>
|
|
|
+ <button-bg type="warning" @click="chooseAll">全选</button-bg>
|
|
|
+ <button-bg type="prim" isRight :disabled="chooseIds.length === 0" @click="start">确认开启</button-bg>
|
|
|
+ </block>
|
|
|
</div>
|
|
|
+
|
|
|
+ <van-popup :show="showUrl" @close="showUrl = false">
|
|
|
+ <div class="url-box">
|
|
|
+ <div class="text1">直播间创建成功</div>
|
|
|
+
|
|
|
+ <div class="text2">
|
|
|
+ 您的推流地址为:
|
|
|
+ <span class="active">{{ path }}</span
|
|
|
+ >,请复制地址打开推流服务器开始直播。
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <van-button size="small" type="primary" @click="copy">一键复制</van-button>
|
|
|
+ </div>
|
|
|
+ </van-popup>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -41,28 +71,90 @@ export default {
|
|
|
list: [],
|
|
|
chooseIds: [],
|
|
|
storeInfo: {},
|
|
|
- empty: false
|
|
|
+ empty: false,
|
|
|
+ accessToken: '',
|
|
|
+ isStart: false,
|
|
|
+ showUrl: false,
|
|
|
+ path: 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=5'
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
- loginMethods() {
|
|
|
+ loginMethods(needShow = false) {
|
|
|
this.$store.dispatch('getUserStore').then(res => {
|
|
|
this.storeInfo = res;
|
|
|
+ this.isStart = res.liveNow;
|
|
|
+ wx.setNavigationBarTitle({
|
|
|
+ title: res.liveNow ? '直播详情' : '选择直播商品'
|
|
|
+ });
|
|
|
this.getData();
|
|
|
+ // this.createRoom();
|
|
|
+ if (this.isStart) {
|
|
|
+ this.getPushUrl(needShow);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getPushUrl(needShow = false) {
|
|
|
+ this.showLoading();
|
|
|
+ this.$http
|
|
|
+ .post('/live/getPushUrl', {
|
|
|
+ roomId: this.storeInfo.roomId
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ this.hideLoading();
|
|
|
+ this.path = res.pushAddr;
|
|
|
+ this.showUrl = needShow;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ goIn() {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=5`
|
|
|
});
|
|
|
},
|
|
|
start() {
|
|
|
this.$http
|
|
|
.post('/live/createRoom', {
|
|
|
- cardCaseId: '7638'
|
|
|
+ caseIdsStr: this.chooseIds.join(','),
|
|
|
+ storeId: this.storeInfo.id
|
|
|
})
|
|
|
.then(res => {
|
|
|
- this.showImg = true;
|
|
|
- this.imgInfo = {
|
|
|
- url: res.codeurl
|
|
|
- };
|
|
|
+ if (res.roomId) {
|
|
|
+ this.loginMethods(true);
|
|
|
+ }
|
|
|
+ // this.showImg = true;
|
|
|
+ // this.imgInfo = {
|
|
|
+ // url: res.codeurl
|
|
|
+ // };
|
|
|
});
|
|
|
},
|
|
|
+ end() {
|
|
|
+ wx.showModal({
|
|
|
+ content: '确定要关闭直播吗?',
|
|
|
+ confirmColor: this.$colors.prim,
|
|
|
+ success: res => {
|
|
|
+ if (res.confirm) {
|
|
|
+ this.$http
|
|
|
+ .post('/live/closeLive', {
|
|
|
+ storeId: this.storeInfo.id
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ this.toast('本次直播已结束', 'success');
|
|
|
+ setTimeout(() => {
|
|
|
+ this.navigateBack();
|
|
|
+ }, 1000);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ chooseAll() {
|
|
|
+ if (this.chooseIds.length === this.list.length) {
|
|
|
+ this.chooseIds = [];
|
|
|
+ } else {
|
|
|
+ this.chooseIds = [...this.list].map(item => {
|
|
|
+ return item.cardCaseId;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
checkChoose(id) {
|
|
|
let list = [...this.chooseIds];
|
|
|
return list.includes(id);
|
|
|
@@ -82,11 +174,23 @@ export default {
|
|
|
let data = {
|
|
|
storeId: this.storeInfo.id
|
|
|
};
|
|
|
- data.caseStatuses = 'PROGRESS';
|
|
|
- if (this.sort) {
|
|
|
- data.sortStr = this.sort;
|
|
|
+ if (this.isStart) {
|
|
|
+ data.roomId = this.storeInfo.roomId;
|
|
|
+ } else {
|
|
|
+ data.caseStatuses = 'PROGRESS';
|
|
|
}
|
|
|
this.showLoading();
|
|
|
+ if (this.isStart) {
|
|
|
+ return this.$http.get('/cardCase/showRoomCases', data).then(res => {
|
|
|
+ this.list = res;
|
|
|
+ if (res.length == 0) {
|
|
|
+ this.empty = true;
|
|
|
+ }
|
|
|
+ this.hideLoading();
|
|
|
+ return Promise.resolve();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
return this.$http.post('/store/findStoreCases', data).then(res => {
|
|
|
this.list = res.caseInfo;
|
|
|
if (res.caseInfo.length == 0) {
|
|
|
@@ -95,6 +199,14 @@ export default {
|
|
|
this.hideLoading();
|
|
|
return Promise.resolve();
|
|
|
});
|
|
|
+ },
|
|
|
+ copy() {
|
|
|
+ wx.setClipboardData({
|
|
|
+ data: this.path,
|
|
|
+ success: res => {
|
|
|
+ this.showUrl = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -109,7 +221,7 @@ export default {
|
|
|
|
|
|
.flex();
|
|
|
|
|
|
- .product-card {
|
|
|
+ .product-content {
|
|
|
flex-grow: 1;
|
|
|
}
|
|
|
|
|
|
@@ -130,4 +242,42 @@ export default {
|
|
|
justify-content: space-between;
|
|
|
z-index: 20;
|
|
|
}
|
|
|
+
|
|
|
+.page-title {
|
|
|
+ padding: 20px;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 12px;
|
|
|
+ color: @text2;
|
|
|
+}
|
|
|
+/deep/.van-popup {
|
|
|
+ --popup-background-color: #ffffff00;
|
|
|
+}
|
|
|
+.url-box {
|
|
|
+ background: #ffffff;
|
|
|
+ border-radius: 12px;
|
|
|
+ padding: 30px 20px;
|
|
|
+ .flex-col();
|
|
|
+ align-items: center;
|
|
|
+ .text1 {
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #000000;
|
|
|
+ line-height: 22px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .text2 {
|
|
|
+ font-size: 13px;
|
|
|
+ font-family: PingFangSC-Medium, PingFang SC;
|
|
|
+ font-weight: 500;
|
|
|
+ color: #1a1a1a;
|
|
|
+ line-height: 18px;
|
|
|
+ padding: 25px 0;
|
|
|
+ word-break: break-all;
|
|
|
+ width: 250px;
|
|
|
+
|
|
|
+ .active {
|
|
|
+ color: @prim;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|