index.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. <template>
  2. <div class="live-config-container">
  3. <!-- 根tabs -->
  4. <el-tabs v-model="rootActiveName" @tab-click="handleClick" class="white-bg-tabs">
  5. <el-tab-pane v-for="item in rootTabs" :key="item.name" :label="item.label" :name="item.name">
  6. <!-- 营销内容 start -->
  7. <el-tabs v-if="item.name == 'market'" v-model="marketActiveName" type="card" @tab-click="handleTabClick">
  8. <el-tab-pane v-for="marketItem in marketTabs" :key="marketItem.name" :label="marketItem.label" :name="marketItem.name" class="market-tab-pane">
  9. <!-- 观看奖励 start -->
  10. <template>
  11. <div v-if="marketItem.name == 'watchReward'">
  12. <!-- 提示信息 -->
  13. <div class="tip-message">
  14. 设置观看奖励,用户达到直播观看时长后可领取奖励
  15. </div>
  16. <!-- 开启观看奖励开关 -->
  17. <div class="reward-switch">
  18. <span class="switch-label">开启观看奖励</span>
  19. <el-switch v-model="watchRewardForm.enabled"></el-switch>
  20. </div>
  21. <!-- 观看奖励设置 -->
  22. <div v-if="watchRewardForm.enabled" class="section-block">
  23. <div class="section-title">观看奖励设置</div>
  24. <!-- 表单内容 -->
  25. <el-form
  26. :model="watchRewardForm"
  27. :rules="rules"
  28. ref="watchRewardForm"
  29. label-width="130px"
  30. >
  31. <!-- 参与条件 -->
  32. <el-form-item label="参与条件" prop="participateCondition">
  33. <el-radio v-model="watchRewardForm.participateCondition" label="1">
  34. 达到指定观看时长
  35. </el-radio>
  36. </el-form-item>
  37. <!-- 观看时长 -->
  38. <el-form-item label="观看时长" prop="watchDuration">
  39. <el-input v-model="watchRewardForm.watchDuration" placeholder="请输入观看时长" class="duration-input">
  40. <template #append>分钟</template>
  41. </el-input>
  42. </el-form-item>
  43. <!-- 实施动作 -->
  44. <el-form-item label="实施动作" prop="action">
  45. <el-select v-model="watchRewardForm.action" placeholder="请选择实施动作" style="width: 300px;">
  46. <el-option
  47. v-for="item in actionOptions"
  48. :key="item.value"
  49. :label="item.label"
  50. :value="item.value"
  51. ></el-option>
  52. </el-select>
  53. </el-form-item>
  54. <!-- 领取提示语 -->
  55. <el-form-item label="领取提示语" prop="receivePrompt">
  56. <el-input v-model="watchRewardForm.receivePrompt" placeholder="请输入领取提示语"></el-input>
  57. </el-form-item>
  58. <!-- 红包设置 -->
  59. <div>
  60. <div class="section-title">红包设置</div>
  61. <!-- 根据实施动作类型显示不同的表单内容 -->
  62. <template v-if="watchRewardForm.action === '1'">
  63. <!-- 现金红包设置 -->
  64. <!-- 红包发放方式 1固定金额 2随机金额 -->
  65. <el-form-item label="红包发放方式" prop="redPacketType">
  66. <el-radio-group v-model="watchRewardForm.redPacketType">
  67. <el-radio label="1">固定金额</el-radio>
  68. <el-radio label="2">随机金额</el-radio>
  69. </el-radio-group>
  70. </el-form-item>
  71. <!-- 红包金额 -->
  72. <el-form-item label="红包金额" prop="redPacketAmount">
  73. <el-input v-model="watchRewardForm.redPacketAmount" placeholder="请输入红包金额"></el-input>
  74. </el-form-item>
  75. <!-- 红包发放数量 -->
  76. <el-form-item label="红包发放数量" prop="redPacketCount">
  77. <el-input v-model="watchRewardForm.redPacketCount" placeholder="红包数量+28888人数"></el-input>
  78. </el-form-item>
  79. <!-- 红包领取方式 1二维码核销 2微信提现 -->
  80. <el-form-item label="红包领取方式" prop="receiveMethod">
  81. <el-radio-group v-model="watchRewardForm.receiveMethod">
  82. <el-radio label="1">二维码领取</el-radio>
  83. <el-radio label="2">微信发放</el-radio>
  84. </el-radio-group>
  85. </el-form-item>
  86. </template>
  87. <template v-else>
  88. <!-- 积分红包设置 -->
  89. <!-- 积分值 -->
  90. <el-form-item label="积分值" prop="scoreAmount">
  91. <el-input
  92. v-model="watchRewardForm.scoreAmount"
  93. placeholder="请输入积分值" style="width: 300px;"
  94. ></el-input>
  95. </el-form-item>
  96. <!-- 最大领取人数 -->
  97. <el-form-item label="最大领取人数" prop="maxReceivers">
  98. <el-input
  99. v-model="watchRewardForm.maxReceivers"
  100. placeholder="请输入最大领取人数" style="width: 300px;"
  101. ></el-input>
  102. </el-form-item>
  103. </template>
  104. </div>
  105. <!-- 其他设置 -->
  106. <div >
  107. <div class="section-title">其他设置</div>
  108. <template v-if="watchRewardForm.action === '1'">
  109. <!-- 客服引导 1跟进企业微信 2不设置 -->
  110. <el-form-item label="客服引导" prop="showGuide">
  111. <el-radio-group v-model="watchRewardForm.showGuide">
  112. <el-radio label="1">跟进企业微信</el-radio>
  113. <el-radio label="2">不设置</el-radio>
  114. </el-radio-group>
  115. </el-form-item>
  116. <!-- 客服引导语 -->
  117. <el-form-item label="客服引导语" prop="guideText">
  118. <el-input
  119. v-model="watchRewardForm.guideText"
  120. placeholder="请输入客服引导语" style="width: 300px;"
  121. ></el-input>
  122. </el-form-item>
  123. </template>
  124. <template v-else>
  125. <!-- 积分使用引导语 -->
  126. <el-form-item label="积分使用引导语" prop="scoreGuideText">
  127. <el-input
  128. v-model="watchRewardForm.scoreGuideText"
  129. placeholder="请输入积分使用引导语" style="width: 300px;"
  130. ></el-input>
  131. </el-form-item>
  132. <!-- 积分使用引导链接 -->
  133. <el-form-item label="积分使用引导链接" prop="scoreGuideLink">
  134. <el-input
  135. v-model="watchRewardForm.scoreGuideLink"
  136. placeholder="请输入积分使用引导链接" style="width: 300px;"
  137. ></el-input>
  138. </el-form-item>
  139. <!-- 引导语 -->
  140. <el-form-item label="引导语" prop="guideText">
  141. <el-input
  142. v-model="watchRewardForm.guideText"
  143. placeholder="请输入引导语" style="width: 300px;"
  144. ></el-input>
  145. </el-form-item>
  146. </template>
  147. </div>
  148. <!-- 保存按钮 -->
  149. <div class="form-actions">
  150. <el-button type="primary" @click="saveWatchReward">保存</el-button>
  151. </div>
  152. </el-form>
  153. </div>
  154. </div>
  155. </template>
  156. <!-- 答题 start -->
  157. <div v-if="marketItem.name == 'answer'">
  158. <div class="tip-box">
  159. 选择用于本节直播课程的题库试题,试题可用于直播间内发送
  160. <el-link
  161. type="primary"
  162. style="margin-left: 5px;"
  163. @click="handleToQuestionBank"
  164. >配置题库试题 >></el-link>
  165. </div>
  166. <el-button type="primary" icon="el-icon-plus" style="margin: 20px 0;" @click="handleAddQuestion">添加试题</el-button>
  167. <!-- 试题列表表格 -->
  168. <el-table
  169. :data="questionLiveList"
  170. style="width: 100%"
  171. v-loading="loading"
  172. >
  173. <!-- 题干列:显示试题的主要内容 -->
  174. <el-table-column
  175. prop="title"
  176. label="题干"
  177. show-overflow-tooltip
  178. ></el-table-column>
  179. <!-- 题型列:显示是单选还是多选 -->
  180. <el-table-column
  181. prop="type"
  182. label="题型"
  183. >
  184. <template slot-scope="scope">
  185. {{ scope.row.type === 1 ? '单选题' : '多选题' }}
  186. </template>
  187. </el-table-column>
  188. <!-- 创建时间列:显示试题创建的时间 -->
  189. <el-table-column
  190. prop="createTime"
  191. label="创建时间"
  192. ></el-table-column>
  193. <!-- 操作列:包含编辑和删除按钮 -->
  194. <el-table-column
  195. label="操作"
  196. width="180"
  197. fixed="right"
  198. >
  199. <template slot-scope="scope">
  200. <!-- 删除按钮:用于移除试题 -->
  201. <el-button
  202. type="text"
  203. size="small"
  204. style="color: #F56C6C;"
  205. @click="handleDelete(scope.row)"
  206. >删除</el-button>
  207. </template>
  208. </el-table-column>
  209. </el-table>
  210. <!-- 分页组件:用于分页展示试题列表 -->
  211. <pagination
  212. v-show="questionTotal > 0"
  213. :total="questionTotal"
  214. :page.sync="questionParams.pageNum"
  215. :limit.sync="questionParams.pageSize"
  216. @pagination="getLiveQuestionLiveList"
  217. style="margin-top: 20px;"
  218. />
  219. <!-- 添加试题弹窗 -->
  220. <el-dialog
  221. title="添加试题"
  222. :visible.sync="questionDialogVisible"
  223. width="800px"
  224. :close-on-click-modal="false"
  225. :close-on-press-escape="false"
  226. >
  227. <div class="dialog-content">
  228. <div style="text-align: right; margin-bottom: 20px;">
  229. <el-input
  230. v-model="searchTitle"
  231. placeholder="请输入搜索内容"
  232. style="width: 300px;"
  233. @input="handleQuestionSearch"
  234. ></el-input>
  235. </div>
  236. <el-table
  237. ref="questionTable"
  238. :data="questionList"
  239. style="width: 100%"
  240. v-loading="questionLoading"
  241. @selection-change="handleSelectionChange"
  242. @row-click="handleRowClick"
  243. row-key="id"
  244. >
  245. <!-- 复选框列:用于多选试题 -->
  246. <el-table-column
  247. type="selection"
  248. width="55"
  249. >
  250. </el-table-column>
  251. <!-- 题干列:显示试题的主要内容 -->
  252. <el-table-column
  253. prop="title"
  254. label="题干"
  255. class-name="clickable-column"
  256. ></el-table-column>
  257. <!-- 题型列:显示单选或多选 -->
  258. <el-table-column
  259. prop="type"
  260. label="题型"
  261. class-name="clickable-column"
  262. >
  263. <template slot-scope="scope">
  264. {{ scope.row.type === 1 ? '单选题' : '多选题' }}
  265. </template>
  266. </el-table-column>
  267. <!-- 创建人列 -->
  268. <el-table-column
  269. prop="createBy"
  270. label="创建人"
  271. class-name="clickable-column"
  272. ></el-table-column>
  273. <!-- 创建时间列 -->
  274. <el-table-column
  275. prop="createTime"
  276. label="创建时间"
  277. width="150"
  278. class-name="clickable-column"
  279. ></el-table-column>
  280. </el-table>
  281. <pagination
  282. v-show="total > 0"
  283. :total="total"
  284. :page.sync="queryParams.pageNum"
  285. :limit.sync="queryParams.pageSize"
  286. @pagination="getQuestionList"
  287. style="margin-top: 20px;"
  288. />
  289. </div>
  290. <div slot="footer" class="dialog-footer">
  291. <div style="display: flex; justify-content: space-between; align-items: center;">
  292. <span class="selected-count">当前已选择 <span style="color: #00BFFF; font-style: italic;">{{ selectedQuestions.length }}</span> 题</span>
  293. <div>
  294. <el-button @click="questionDialogVisible = false">取 消</el-button>
  295. <el-button type="primary" @click="confirmAddQuestion">确 定</el-button>
  296. </div>
  297. </div>
  298. </div>
  299. </el-dialog>
  300. </div>
  301. <!-- 答题 end -->
  302. <!-- 直播商品start -->
  303. <div v-if="marketItem.name == 'goods'">
  304. <el-button type="primary" icon="el-icon-plus" style="margin: 20px 0;" @click="handleAddLiveGoods">添加商品</el-button>
  305. <!-- 试题列表表格 -->
  306. <el-table
  307. :data="goodsLiveList"
  308. style="width: 100%"
  309. v-loading="loading"
  310. >
  311. <!-- 题干列:显示试题的主要内容 -->
  312. <el-table-column
  313. prop="goodsId"
  314. label="商品id"
  315. show-overflow-tooltip
  316. ></el-table-column>
  317. <!-- 题型列:显示是单选还是多选 -->
  318. <el-table-column
  319. prop="storeId"
  320. label="店铺id"
  321. >
  322. </el-table-column>
  323. <!-- 创建时间列:显示试题创建的时间 -->
  324. <el-table-column
  325. prop="productId"
  326. label="商品id"
  327. ></el-table-column>
  328. <!-- 操作列:包含编辑和删除按钮 -->
  329. <el-table-column
  330. label="操作"
  331. width="180"
  332. fixed="right"
  333. >
  334. <template slot-scope="scope">
  335. <!-- 删除按钮:用于移除试题 -->
  336. <el-button
  337. type="text"
  338. size="small"
  339. style="color: #F56C6C;"
  340. @click="handleGoodDelete(scope.row)"
  341. >删除</el-button>
  342. </template>
  343. </el-table-column>
  344. </el-table>
  345. <!-- 分页组件:用于分页展示试题列表 -->
  346. <pagination
  347. v-show="goodsTotal > 0"
  348. :total="goodsTotal"
  349. :page.sync="goodsParams.pageNum"
  350. :limit.sync="goodsParams.pageSize"
  351. @pagination="getLiveGoodsList"
  352. style="margin-top: 20px;"
  353. />
  354. <!-- 添加商品弹窗 -->
  355. <el-dialog
  356. title="添加商品"
  357. :visible.sync="goodsDialogVisible"
  358. width="800px"
  359. :close-on-click-modal="false"
  360. :close-on-press-escape="false"
  361. >
  362. <div class="dialog-content">
  363. <div style="text-align: right; margin-bottom: 20px;">
  364. <el-input
  365. v-model="searchTitle"
  366. placeholder="请输入搜索内容"
  367. style="width: 300px;"
  368. @input="handleGoodsSearch"
  369. ></el-input>
  370. </div>
  371. <el-table
  372. ref="goodsTable"
  373. :data="goodsList"
  374. style="width: 100%"
  375. v-loading="goodsLoading"
  376. @selection-change="handleGoodsChange"
  377. @row-click="handleGoodsRowClick"
  378. row-key="id"
  379. >
  380. <!-- 复选框列:用于多选试题 -->
  381. <el-table-column
  382. type="selection"
  383. width="55"
  384. >
  385. </el-table-column>
  386. <!-- 题干列:显示试题的主要内容 -->
  387. <el-table-column
  388. prop="storeName"
  389. label="商铺名称"
  390. class-name="clickable-column"
  391. ></el-table-column>
  392. <el-table-column
  393. prop="productName"
  394. label="产品"
  395. class-name="clickable-column"
  396. ></el-table-column>
  397. <el-table-column
  398. prop="price"
  399. label="价格"
  400. class-name="clickable-column"
  401. ></el-table-column>
  402. <el-table-column
  403. prop="stock"
  404. label="库存"
  405. class-name="clickable-column"
  406. ></el-table-column>
  407. </el-table>
  408. <pagination
  409. v-show="total > 0"
  410. :total="total"
  411. :page.sync="queryParams.pageNum"
  412. :limit.sync="queryParams.pageSize"
  413. @pagination="getStoreProductLists"
  414. style="margin-top: 20px;"
  415. />
  416. </div>
  417. <div slot="footer" class="dialog-footer">
  418. <div style="display: flex; justify-content: space-between; align-items: center;">
  419. <span class="selected-count">当前已选择 <span style="color: #00BFFF; font-style: italic;">{{ selectedGoods.length }}</span> 商品</span>
  420. <div>
  421. <el-button @click="goodsDialogVisible = false">取 消</el-button>
  422. <el-button type="primary" @click="confirmAddGoods">确 定</el-button>
  423. </div>
  424. </div>
  425. </div>
  426. </el-dialog>
  427. </div>
  428. <!-- 直播商品end -->
  429. </el-tab-pane>
  430. </el-tabs>
  431. <!-- 营销内容 end -->
  432. </el-tab-pane>
  433. </el-tabs>
  434. <!-- 根tabs end -->
  435. </div>
  436. </template>
  437. <script>
  438. import {
  439. listLiveQuestionLive,
  440. listLiveQuestionOptionList,
  441. addLiveQuestionLive,
  442. deleteLiveQuestionLive,
  443. getConfig,
  444. addConfig,
  445. updateConfig
  446. } from '@/api/live/liveQuestionLive'
  447. import {listLiveGoods, delLiveGoods, listStoreProduct} from '@/api/live/liveGoods'
  448. export default {
  449. name: 'LiveConfig',
  450. data() {
  451. return {
  452. liveId: null,
  453. loading: true,
  454. rootActiveName: 'market',
  455. rootTabs: [
  456. {
  457. label: '营销内容',
  458. name: 'market'
  459. }
  460. ],
  461. marketActiveName: 'watchReward',
  462. marketTabs: [
  463. {
  464. label: '观看奖励',
  465. name: 'watchReward'
  466. },
  467. {
  468. label: '答题红包',
  469. name: 'answerRedPacket'
  470. },
  471. {
  472. label: '答题',
  473. name: 'answer'
  474. },
  475. {
  476. label: '直播商品',
  477. name: 'goods'
  478. },
  479. {
  480. label: '观看积分 ',
  481. name: 'watchScore'
  482. }
  483. ],
  484. questionDialogVisible: false,
  485. goodsDialogVisible: false,
  486. questionLoading: false,
  487. goodsLoading: false,
  488. searchTitle: '',
  489. questionList: [],
  490. selectedQuestions: [],
  491. selectedGoods: [],
  492. total: 0,
  493. queryParams: {
  494. pageNum: 1,
  495. pageSize: 10,
  496. title: null,
  497. liveId: null
  498. },
  499. questionTotal: 0,
  500. questionParams: {
  501. pageNum: 1,
  502. pageSize: 10,
  503. liveId: null
  504. },
  505. goodsList: [],
  506. goodsTotal: 0,
  507. questionLiveList: [],
  508. goodsLiveList: [],
  509. goodsLiveTotal: 0,
  510. goodsParams: {
  511. pageNum: 1,
  512. pageSize: 10,
  513. liveId: null
  514. },
  515. queryGoodParams: {
  516. pageNum: 1,
  517. pageSize: 10,
  518. title: null,
  519. liveId: null
  520. },
  521. rules:{
  522. participateCondition:[
  523. { required: true, message: '请选择参与条件', trigger: 'blur'}
  524. ],
  525. watchDuration:[
  526. { required: true, message: '请输入观看时长', trigger: 'blur'}
  527. ],
  528. action:[
  529. { required: true, message: '请选择实施动作', trigger: 'blur'}
  530. ],
  531. receivePrompt:[
  532. { required: true, message: '请输入领取提示语', trigger: 'blur'}
  533. ],
  534. redPacketType:[
  535. { required: true, message: '请选择红包发放方式', trigger: 'blur'}
  536. ],
  537. redPacketAmount:[
  538. { required: true, message: '请输入红包金额', trigger: 'blur'}
  539. ],
  540. receiveMethod:[
  541. { required: true, message: '请选择红包领取方式', trigger: 'blur'}
  542. ],
  543. guideText:[
  544. { required: true, message: '请输入客服引导语', trigger: 'blur'}
  545. ],
  546. showGuide:[
  547. { required: true, message: '请选择是否显示客服引导', trigger: 'blur'}
  548. ]
  549. },
  550. watchRewardForm: {
  551. id: null,
  552. liveId: null,
  553. // 是否启用观看奖励
  554. enabled: false,
  555. // 参与条件
  556. participateCondition: '1',
  557. // 观看时长
  558. watchDuration: '',
  559. // 实施动作
  560. action: '1',
  561. // 领取提示语
  562. receivePrompt: '',
  563. // 红包发放方式(固定金额/随机金额)
  564. redPacketType: '1',
  565. // 红包金额
  566. redPacketAmount: '',
  567. // 红包发放数量
  568. redPacketCount: '',
  569. // 红包领取方式
  570. receiveMethod: '1',
  571. // 是否显示客服引导
  572. showGuide: '1',
  573. // 客服引导语
  574. guideText: '',
  575. // 积分值
  576. scoreAmount: '',
  577. // 最大领取人数
  578. maxReceivers: '',
  579. // 积分使用引导语
  580. scoreGuideText: '',
  581. // 积分使用引导链接
  582. scoreGuideLink: ''
  583. },
  584. // 添加实施动作选项
  585. actionOptions: [
  586. {
  587. label: '现金红包',
  588. value: '1'
  589. },
  590. {
  591. label: '积分红包',
  592. value: '2'
  593. }
  594. ]
  595. }
  596. },
  597. created() {
  598. this.liveId = this.$route.params.liveId
  599. this.queryParams.liveId = this.liveId
  600. this.goodsParams.liveId = this.liveId
  601. this.questionParams.liveId = this.liveId
  602. this.watchRewardForm.liveId = this.liveId
  603. // this.getLiveQuestionLiveList()
  604. this.getLiveConfig();
  605. },
  606. methods: {
  607. getLiveConfig(){
  608. getConfig(this.liveId).then(response => {
  609. if(response.code === 200){
  610. this.watchRewardForm = JSON.parse(response.data)
  611. }
  612. })
  613. },
  614. handleClick(tab, event) {
  615. console.info(tab, event)
  616. },
  617. handleToQuestionBank() {
  618. this.$router.push('/live/liveQuestionBank')
  619. },
  620. handleTabClick(tab) {
  621. if(tab.name === 'answer') {
  622. // this.getLiveQuestionLiveList()
  623. }
  624. if(tab.name === 'goods'){
  625. this.getLiveGoodsList();
  626. }
  627. },
  628. getLiveGoodsList() {
  629. this.loading = true
  630. listLiveGoods().then(response => {
  631. this.goodsLiveList = response.rows
  632. this.goodsLiveTotal = response.total
  633. this.loading = false
  634. })
  635. },
  636. getLiveQuestionLiveList() {
  637. this.loading = true
  638. listLiveQuestionLive(this.questionParams).then(response => {
  639. this.questionLiveList = response.rows
  640. this.questionTotal = response.total
  641. this.loading = false
  642. })
  643. },
  644. handleAddQuestion() {
  645. this.questionDialogVisible = true
  646. this.getQuestionList()
  647. },
  648. handleAddLiveGoods(){
  649. this.goodsDialogVisible = true;
  650. this.getStoreProductLists()
  651. },
  652. getQuestionList() {
  653. this.questionLoading = true
  654. listLiveQuestionOptionList(this.queryParams).then(response => {
  655. this.questionList = response.rows
  656. this.total = response.total
  657. this.questionLoading = false
  658. })
  659. },
  660. handleQuestionSearch() {
  661. this.queryParams.pageNum = 1
  662. this.queryParams.title = this.searchTitle
  663. this.getQuestionList()
  664. },
  665. handleGoodsSearch(){
  666. this.queryParams.pageNum = 1
  667. this.queryParams.title = this.searchTitle
  668. this.getQuestionList()
  669. },
  670. handleSelectionChange(selection) {
  671. this.selectedQuestions = selection
  672. },
  673. handleGoodsChange(goods) {
  674. this.selectedGoods = goods
  675. },
  676. handleCurrentChange() {
  677. this.getQuestionList()
  678. },
  679. confirmAddQuestion() {
  680. if (this.selectedQuestions.length === 0) {
  681. this.$message({
  682. message: '请选择要添加的试题',
  683. type: 'warning'
  684. })
  685. return
  686. }
  687. // 调用添加直播间试题接口
  688. addLiveQuestionLive({
  689. liveId: this.liveId,
  690. questionIds: this.selectedQuestions.map(item => item.id).join(',')
  691. }).then(response => {
  692. this.questionDialogVisible = false
  693. this.getLiveQuestionLiveList()
  694. })
  695. },
  696. confirmAddGoods(){
  697. if (this.selectedGoods.length === 0) {
  698. this.$message({
  699. message: '请选择要添加的商品',
  700. type: 'warning'
  701. })
  702. return
  703. }
  704. addLiveGoods({
  705. liveId: this.liveId,
  706. goodsIds: this.selectedGoods.map(item => item.goodsId).join(',')
  707. }).then(response => {
  708. this.goodsDialogVisible = false
  709. this.getLiveGoodsList()
  710. })
  711. },
  712. handleDelete(row) {
  713. // 调用删除直播间试题接口
  714. deleteLiveQuestionLive({
  715. liveId: this.liveId,
  716. ids: row.id
  717. }).then(response => {
  718. this.getLiveQuestionLiveList()
  719. })
  720. },
  721. handleGoodDelete(row){
  722. delLiveGoods(row.goodsId).then(response => {
  723. this.getLiveGoodsList()
  724. })
  725. },
  726. /** 处理行点击事件 */
  727. handleRowClick(row, column) {
  728. // 如果点击的是复选框列,不进行处理
  729. if (column.type === 'selection') {
  730. return
  731. }
  732. // 获取表格实例
  733. const table = this.$refs.questionTable[0]
  734. if (!table) {
  735. return
  736. }
  737. // 判断当前行是否已经被选中
  738. const isSelected = this.selectedQuestions.some(item => item.id === row.id)
  739. // 切换选中状态
  740. table.toggleRowSelection(row, !isSelected)
  741. },
  742. /** 处理行点击事件 */
  743. handleGoodsRowClick(row, column) {
  744. // 如果点击的是复选框列,不进行处理
  745. if (column.type === 'selection') {
  746. return
  747. }
  748. // 获取表格实例
  749. const table = this.$refs.goodsTable[0]
  750. if (!table) {
  751. return
  752. }
  753. // 判断当前行是否已经被选中
  754. const isSelected = this.selectedGoods.some(item => item.id === row.id)
  755. // 切换选中状态
  756. table.toggleRowSelection(row, !isSelected)
  757. },
  758. saveWatchReward() {
  759. this.$refs["watchRewardForm"][0].validate(valid => {
  760. if (valid) {
  761. if (this.watchRewardForm.id == null) {
  762. // 调用保存观看奖励接口
  763. // 实现保存逻辑
  764. addConfig(this.watchRewardForm).then(res => {
  765. if (res.code == 200) {
  766. this.msgSuccess("修改成功");
  767. }
  768. })
  769. } else {
  770. updateConfig(this.watchRewardForm).then(response => {
  771. this.msgSuccess("修改成功");
  772. });
  773. }
  774. }
  775. })
  776. },
  777. getStoreProductLists() {
  778. listStoreProduct().then(response => {
  779. this.goodsList = response.rows
  780. this.goodsTotal = response.total
  781. this.loading = false
  782. })
  783. }
  784. }
  785. }
  786. </script>
  787. <style scoped>
  788. .live-config-container {
  789. padding: 10px 20px;
  790. height: calc(100vh - 84px); /* 减去头部导航的高度 */
  791. }
  792. .white-bg-tabs {
  793. background-color: #fff;
  794. padding: 10px 20px;
  795. border-radius: 4px;
  796. height: 100%;
  797. }
  798. .market-tab-pane {
  799. height: 74vh;
  800. overflow-y: auto;
  801. }
  802. .tip-box {
  803. padding: 12px 16px;
  804. background-color: #FFF6F2;
  805. border-radius: 4px;
  806. color: #666;
  807. font-size: 14px;
  808. }
  809. /* 修改弹窗相关样式 */
  810. ::v-deep .el-dialog {
  811. height: 90%;
  812. margin: 0 !important;
  813. width: 900px !important;
  814. }
  815. ::v-deep .el-dialog__body {
  816. padding: 20px;
  817. height: calc(100% - 110px); /* 减去header和footer的高度 */
  818. overflow: hidden;
  819. }
  820. .dialog-content {
  821. height: 100%;
  822. overflow-y: auto;
  823. }
  824. ::v-deep .el-dialog__footer {
  825. position: absolute;
  826. bottom: 0;
  827. width: 100%;
  828. background: #fff;
  829. z-index: 1;
  830. border-top: 1px solid #e4e7ed;
  831. padding: 15px 20px;
  832. }
  833. ::v-deep .el-dialog__header {
  834. padding: 15px 20px;
  835. border-bottom: 1px solid #e4e7ed;
  836. }
  837. .selected-count {
  838. color: #999;
  839. font-size: 14px;
  840. }
  841. /* 可点击列的样式 */
  842. ::v-deep .clickable-column {
  843. cursor: pointer;
  844. }
  845. /* 提示信息样式 */
  846. .tip-message {
  847. padding: 12px 16px;
  848. background-color: #FFF6F2;
  849. border-radius: 4px;
  850. color: #666;
  851. font-size: 14px;
  852. margin-bottom: 20px;
  853. }
  854. /* 开关容器样式 */
  855. .reward-switch {
  856. margin-left: 200px;
  857. margin-bottom: 20px;
  858. padding: 20px;
  859. background-color: #fff;
  860. border-radius: 4px;
  861. display: flex;
  862. align-items: center;
  863. }
  864. /* 开关标签样式 */
  865. .reward-switch .switch-label {
  866. margin-right: 10px;
  867. font-size: 14px;
  868. color: #333;
  869. margin-left: 50px;
  870. }
  871. /* 表单区块样式 */
  872. .section-block {
  873. width: 50%;
  874. background-color: #fff;
  875. padding: 20px;
  876. border-radius: 4px;
  877. margin-left: 50px;
  878. margin-bottom: 20px;
  879. }
  880. /* 标题样式 */
  881. .section-block .section-title {
  882. font-size: 14px;
  883. color: #333;
  884. margin-bottom: 20px;
  885. border-left: 4px solid #409EFF;
  886. padding-left: 10px;
  887. line-height: 1;
  888. }
  889. /* 表单样式 */
  890. .reward-form {
  891. margin-top: 20px;
  892. }
  893. /* 表单项样式 */
  894. .reward-form .el-form-item {
  895. margin-bottom: 22px;
  896. padding-left: 50px;
  897. }
  898. .reward-form .el-form-item:last-child {
  899. margin-bottom: 0;
  900. }
  901. /* 表单标签样式 */
  902. .reward-form .el-form-item .el-form-item__label {
  903. color: #606266;
  904. }
  905. /* 输入框统一宽度 */
  906. .reward-form .el-form-item .el-input {
  907. width: 300px;
  908. }
  909. /* 必填项星号样式 */
  910. .reward-form .el-form-item.is-required .el-form-item__label:before {
  911. color: #F56C6C;
  912. }
  913. /* 观看时长输入框样式 */
  914. .reward-form .el-form-item .duration-input {
  915. width: 300px;
  916. }
  917. .reward-form .el-form-item .duration-input .el-input__inner {
  918. text-align: left;
  919. }
  920. /* 保存按钮样式 */
  921. .form-actions {
  922. width: 600px;
  923. text-align: center;
  924. margin-top: 30px;
  925. }
  926. .form-actions .el-button {
  927. padding: 8px 20px;
  928. font-size: 13px;
  929. }
  930. </style>