index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. <template>
  2. <view class="question-box">
  3. <JHeader title="我的问答" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view class="tabsbox">
  5. <tui-tabs
  6. style="width: 750upx;padding: 0 0upx 0 0upx;overflow: hidden;" :slider-width="375" :padding="0"
  7. item-width="375rpx" selected-color="#C5AA7B" bold slider-bg-color="#ffffff"
  8. :tabs="questionTypeList"
  9. :current-tab="questionTypeFlag" @change="questionTypeActive"
  10. ></tui-tabs>
  11. </view>
  12. <view v-if="questionTypeFlag == 0">
  13. <view v-if="problemInfo.data.length > 0">
  14. <view class="wid function-box">
  15. <view v-if="allCheckShow" class="finishbox" @click="finishClick">完成</view>
  16. <view v-else class="flex-row-plus editicon-box flex-items fs28" @click="editClick">
  17. <tui-icon name="edit" :size="40" unit="upx" color="#333333"></tui-icon>
  18. <text class="mar-left-10">编辑</text>
  19. </view>
  20. </view>
  21. <view class="swipe-box">
  22. <tui-swipe-action
  23. v-for="(item, index) in problemInfo.data" :key="item.problemId" :params="{ index }"
  24. :open="item.show" :forbid="allCheckShow" :actions="options" :closable="false"
  25. @click="problemClick"
  26. >
  27. <template #content>
  28. <view class="flex-item itemBox">
  29. <view class="item wid flex-row-plus flex-items">
  30. <view v-show="allCheckShow">
  31. <tui-icon
  32. v-if="item.selected == 1" name="circle-fill" :size="40" unit="upx"
  33. color="#c5aa7b"
  34. margin="30upx" @click="problemItemSel(index, 0)"
  35. ></tui-icon>
  36. <tui-icon
  37. v-else name="circle" :size="40" unit="upx"
  38. color="#cccccc" margin="30upx"
  39. @click="problemItemSel(index, 1)"
  40. ></tui-icon>
  41. </view>
  42. <view
  43. class="title-wrap replynum-box"
  44. @click="go(`/another-tf/another-serve/qADetail/index?productId=${item.productId}&problemId=${item.problemId}`)"
  45. >
  46. <view class="flex-items">
  47. <label>问</label>
  48. <text
  49. class="title font-weight-bold fs28"
  50. style="overflow: hidden;word-break: break-all;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;"
  51. >
  52. {{
  53. item.problem }}
  54. </text>
  55. </view>
  56. <view class="flex-items reply">
  57. <label>答</label>
  58. <text v-if="item.count > 0" class="font-color-666 fs24">{{ item.count }}条回复</text>
  59. <text v-else class="font-color-666 fs24">暂无回复</text>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. </tui-swipe-action>
  66. </view>
  67. <view v-show="allCheckShow" class="allcheck-box flex-row-plus flex-sp-between flex-items">
  68. <view class="left">
  69. <tui-icon
  70. v-if="isAllProblemCheck" name="circle-fill" :size="40" unit="upx"
  71. color="#c5aa7b"
  72. margin="0 30upx 0 0" @click="allProblemSel(0)"
  73. ></tui-icon>
  74. <tui-icon
  75. v-else name="circle" :size="40" unit="upx"
  76. color="#cccccc" margin="0 30upx 0 0"
  77. @click="allProblemSel(1)"
  78. ></tui-icon>
  79. <text>全选</text>
  80. </view>
  81. <view class="right">
  82. <view class="btn-delete" @click="questionDel(0)">删除</view>
  83. </view>
  84. </view>
  85. <view v-if="allCheckShow" class="pad-bot-140"></view>
  86. </view>
  87. <view style="padding-bottom: 45upx;">
  88. <LoadingMore
  89. :status="!problemInfo.isEmpty && !problemInfo.data.length
  90. ? 'loading' : !problemInfo.isEmpty && problemInfo.data.length && (problemInfo.data.length >= problemInfo.listTotal) ? 'no-more' : ''"
  91. >
  92. </LoadingMore>
  93. <tui-no-data v-if="problemInfo.isEmpty" :fixed="false" style="margin-top: 60upx;">暂无提问内容</tui-no-data>
  94. </view>
  95. </view>
  96. <view v-if="questionTypeFlag == 1">
  97. <view v-if="answerInfo.data.length > 0">
  98. <view v-if="allCheckShow" class="finishbox" @click="finishClick">完成</view>
  99. <view v-else class="flex-row-plus editicon-box flex-items fs28" @click="editClick">
  100. <tui-icon name="edit" :size="40" unit="upx" color="#333333"></tui-icon>
  101. <text class="mar-left-10">编辑</text>
  102. </view>
  103. <view class="swipe-box">
  104. <tui-swipe-action
  105. v-for="(item, index) in answerInfo.data" :key="item.answerId" :params="{ index }"
  106. :open="item.show" :forbid="allCheckShow" :actions="options" :closable="false"
  107. @click="answerClick"
  108. >
  109. <template #content>
  110. <view class="item itemBox flex-item">
  111. <view class="wid" style="border-radius: 50%;">
  112. <view class="flex-items-plus flex-row wid">
  113. <view v-show="allCheckShow">
  114. <tui-icon
  115. v-if="item.selected == 1" name="circle-fill" :size="40" unit="upx"
  116. color="#c5aa7b"
  117. margin="0 30upx 0 0" @click="answerItemSel(index, 0)"
  118. ></tui-icon>
  119. <tui-icon
  120. v-else name="circle" :size="40" unit="upx"
  121. color="#cccccc" margin="0 30upx 0 0"
  122. @click="answerItemSel(index, 1)"
  123. ></tui-icon>
  124. </view>
  125. <view
  126. class="title-wrap replynum-box wid"
  127. @click="go(`/another-tf/another-serve/qADetail/index?productId=${item.productId}&problemId=${item.problemId}`)"
  128. >
  129. <view class="flex-items">
  130. <label>问</label>
  131. <text
  132. class="title fs28 font-weight-bold"
  133. style="overflow: hidden;word-break: break-all;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;"
  134. >
  135. {{
  136. item.problem }}
  137. </text>
  138. </view>
  139. <view class="replyBox">
  140. <view class="flex-items reply">
  141. <label>答</label>
  142. <text v-if="allCheckShow" style="width: 270rpx;" class="font-color-666 fs24 overflow">
  143. {{ item.name }} :
  144. {{ item.answer }}
  145. </text>
  146. <text v-else style="width: 360rpx;" class="font-color-999 fs24 overflow">
  147. {{ item.name }} :
  148. {{ item.answer }}
  149. </text>
  150. </view>
  151. <view class="qAarrow mar-top-30 flex-items">
  152. <text class="fs24 font-color-C5AA7B">共{{ item.count }}个回答</text>
  153. <tui-icon :size="24" color="#a7916a" name="arrowright" margin="0 0 0 15upx"></tui-icon>
  154. </view>
  155. </view>
  156. </view>
  157. </view>
  158. </view>
  159. </view>
  160. </template>
  161. </tui-swipe-action>
  162. </view>
  163. <view v-show="allCheckShow" class="allcheck-box flex-row-plus flex-sp-between flex-items">
  164. <view class="left">
  165. <tui-icon
  166. v-if="isAllAnswerCheck" name="circle-fill" :size="40" unit="upx"
  167. color="#c5aa7b"
  168. margin="0 30upx 0 0" @click="allAnswerSel(0)"
  169. ></tui-icon>
  170. <tui-icon
  171. v-else name="circle" :size="40" unit="upx"
  172. color="#cccccc" margin="0 30upx 0 0"
  173. @click="allAnswerSel(1)"
  174. ></tui-icon>
  175. <text>全选</text>
  176. </view>
  177. <view class="right">
  178. <view class="btn-delete" @click="questionDel(1)">删除</view>
  179. </view>
  180. </view>
  181. <view v-if="allCheckShow" class="pad-bot-140"></view>
  182. </view>
  183. <view style="padding-bottom: 45upx;">
  184. <LoadingMore
  185. :status="!answerInfo.isEmpty && !answerInfo.data.length
  186. ? 'loading' : !answerInfo.isEmpty && answerInfo.data.length && (answerInfo.data.length >= answerInfo.listTotal) ? 'no-more' : ''"
  187. >
  188. </LoadingMore>
  189. <tui-no-data v-if="answerInfo.isEmpty" :fixed="false" style="margin-top: 60upx;">暂无问答内容</tui-no-data>
  190. </view>
  191. </view>
  192. <!-- 删除确认弹窗 -->
  193. <tui-modal :show="delshow" :custom="true" :fadein="true">
  194. <view class="Put-box1">
  195. <view class="text-align fs34 fs-bold">
  196. 删除回答?
  197. </view>
  198. <view class="mar-top-40 text-align">
  199. 删除回答后无法恢复
  200. </view>
  201. <view class="flex-display flex-sp-between">
  202. <view class="btn submit" @click="delClick">继续删除</view>
  203. </view>
  204. </view>
  205. <view class="cancelDel" @click="cancelClick">
  206. <tui-icon name="circle-fill" :size="60" unit="upx" color="#fafafa"></tui-icon>
  207. </view>
  208. </tui-modal>
  209. </view>
  210. </template>
  211. <script>
  212. import { deleteProblemAnswerApi, deleteAnswerProblemApi, getProblemSeckillApi, getAnswerSeckillApi } from '../../../api/anotherTFInterface'
  213. export default {
  214. name: 'QuestionList',
  215. data() {
  216. return {
  217. questionTypeList: [{
  218. name: '我的提问(0)'
  219. }, {
  220. name: '我的回答(0)'
  221. }],
  222. questionTypeFlag: 0,
  223. options: [ {
  224. name: '删除',
  225. color: '#fff',
  226. fontsize: 32,
  227. width: 80,
  228. background: '#C83732'
  229. } ],
  230. isAllProblemCheck: false,
  231. isAllAnswerCheck: false,
  232. allCheckShow: false,
  233. delshow: false,
  234. problemInfo: {
  235. query: {
  236. page: 1,
  237. pageSize: 10
  238. },
  239. data: [],
  240. listTotal: 0,
  241. isEmpty: false
  242. },
  243. answerInfo: {
  244. query: {
  245. page: 1,
  246. pageSize: 10
  247. },
  248. data: [],
  249. listTotal: 0, // 列表数据总数
  250. isEmpty: false // 列表是否为空
  251. },
  252. delType: 0
  253. }
  254. },
  255. onLoad() {
  256. this.getProblemList()
  257. },
  258. methods: {
  259. // 确定批量删除
  260. delClick() {
  261. this.delshow = false
  262. if (this.delType == 0) {
  263. const ids = []
  264. this.problemInfo.data.forEach((value, index) => {
  265. if (value.selected == 1) {
  266. ids.push(value.problemId)
  267. }
  268. })
  269. deleteProblemAnswerApi({
  270. ids
  271. }).then((res) => {
  272. this.$showToast(`删除成功`)
  273. setTimeout(() => {
  274. this.problemInfo.query.page = 1
  275. this.getProblemList()
  276. }, 1000)
  277. })
  278. } else if (this.delType == 1) {
  279. const ids = []
  280. this.answerInfo.data.forEach((value, index) => {
  281. if (value.selected == 1) {
  282. ids.push(value.answerId)
  283. }
  284. })
  285. deleteAnswerProblemApi({
  286. ids
  287. }).then((res) => {
  288. this.$showToast(`删除成功`)
  289. setTimeout(() => {
  290. this.answerInfo.query.page = 1
  291. this.getAnswerList()
  292. }, 1000)
  293. })
  294. }
  295. },
  296. // 全选
  297. allProblemSel(type) {
  298. this.isAllProblemCheck = !this.isAllProblemCheck
  299. this.problemInfo.data.forEach((value, index) => {
  300. this.problemInfo.data[index].selected = type
  301. })
  302. },
  303. allAnswerSel(type) {
  304. this.isAllAnswerCheck = !this.isAllAnswerCheck
  305. this.answerInfo.data.forEach((value, index) => {
  306. this.answerInfo.data[index].selected = type
  307. })
  308. },
  309. // 单个选中
  310. problemItemSel(index, number) {
  311. this.problemInfo.data[index].selected = number
  312. let proSelectNum = 0
  313. this.problemInfo.data.forEach((value, index) => {
  314. if (this.problemInfo.data[index].selected == 0) {
  315. this.isAllProblemCheck = false
  316. } else {
  317. proSelectNum++
  318. }
  319. })
  320. if (this.problemInfo.data.length == proSelectNum) {
  321. this.isAllProblemCheck = true
  322. }
  323. },
  324. answerItemSel(index, number) {
  325. this.answerInfo.data[index].selected = number
  326. let ansSelectNum = 0
  327. this.answerInfo.data.forEach((value, index) => {
  328. if (this.answerInfo.data[index].selected == 0) {
  329. this.isAllAnswerCheck = false
  330. } else {
  331. ansSelectNum++
  332. }
  333. })
  334. if (this.answerInfo.data.length == ansSelectNum) {
  335. this.isAllAnswerCheck = true
  336. }
  337. },
  338. // 删除提问
  339. problemClick(e) {
  340. if (e.index == 0) {
  341. const ids = this.problemInfo.data[e.item.index].problemId
  342. deleteProblemAnswerApi({
  343. ids: [ ids ]
  344. }).then((res) => {
  345. this.problemInfo.query.page = 1
  346. this.getProblemList()
  347. this.$showToast(`删除成功`)
  348. })
  349. }
  350. },
  351. // 删除回答
  352. answerClick(e) {
  353. if (e.index == 0) {
  354. const ids = this.answerInfo.data[e.item.index].answerId
  355. deleteAnswerProblemApi({
  356. ids: [ ids ]
  357. }).then((res) => {
  358. this.answerInfo.query.page = 1
  359. this.getAnswerList()
  360. this.$showToast(`删除成功`)
  361. })
  362. }
  363. },
  364. // 我的提问列表
  365. getProblemList(isLoadmore) {
  366. uni.showLoading({
  367. title: '加载中'
  368. })
  369. getProblemSeckillApi({ ...this.problemInfo.query })
  370. .then((res) => {
  371. this.questionTypeList[0].name = '我的提问(' + res.data.total + ')'
  372. this.problemInfo.listTotal = res.data.total
  373. if (isLoadmore) {
  374. this.problemInfo.data.push(...res.data.list)
  375. } else {
  376. this.problemInfo.data = res.data.list
  377. }
  378. this.problemInfo.isEmpty = this.problemInfo.data.length === 0
  379. uni.hideLoading()
  380. })
  381. .catch(() => {
  382. uni.hideLoading()
  383. })
  384. },
  385. // 我的回答列表
  386. getAnswerList(isLoadmore) {
  387. uni.showLoading({
  388. title: '加载中'
  389. })
  390. getAnswerSeckillApi({ ...this.answerInfo.query })
  391. .then((res) => {
  392. this.questionTypeList[1].name = '我的回答(' + res.data.total + ')'
  393. this.answerInfo.listTotal = res.data.total
  394. if (isLoadmore) {
  395. this.answerInfo.data.push(...res.data.list)
  396. } else {
  397. this.answerInfo.data = res.data.list
  398. }
  399. this.answerInfo.isEmpty = this.answerInfo.data.length === 0
  400. uni.hideLoading()
  401. })
  402. .catch(() => {
  403. uni.hideLoading()
  404. })
  405. },
  406. questionTypeActive(e) {
  407. this.questionTypeFlag = e.index
  408. // 缓存每个tab里的数据
  409. if (this.questionTypeFlag === 0) {
  410. } else if (this.questionTypeFlag === 1) {
  411. if (!this.answerInfo.isEmpty && !this.answerInfo.data.length) this.getAnswerList()
  412. }
  413. // 每点一个tab就重新进行对它的请求
  414. // if (this.questionTypeFlag === 0) {
  415. // this.problemInfo.query.page = 1
  416. // this.problemInfo.data = []
  417. // this.problemInfo.listTotal = 0
  418. // this.problemInfo.isEmpty = false
  419. // this.getApplyByStoreList()
  420. // } else if (this.questionTypeFlag === 1) {
  421. // this.answerInfo.query.page = 1
  422. // this.answerInfo.data = []
  423. // this.answerInfo.listTotal = 0
  424. // this.answerInfo.isEmpty = false
  425. // this.getApplyByUserList()
  426. // }
  427. },
  428. editClick() {
  429. this.allCheckShow = true
  430. this.problemInfo.data = this.problemInfo.data.map((item) => ({ ...item, show: false }))
  431. this.answerInfo.data = this.answerInfo.data.map((item) => ({ ...item, show: false }))
  432. },
  433. finishClick() {
  434. this.allCheckShow = false
  435. },
  436. cancelClick() {
  437. this.delshow = false
  438. },
  439. questionDel(num) {
  440. let quNum = 0
  441. let anNum = 0
  442. this.problemInfo.data.forEach((value, index) => {
  443. if (this.problemInfo.data[index].selected == 1) quNum++
  444. })
  445. this.answerInfo.data.forEach((value, index) => {
  446. if (this.answerInfo.data[index].selected == 1) anNum++
  447. })
  448. if (num == 0) {
  449. if (quNum < 1) {
  450. uni.showToast({
  451. title: '至少选择一条提问!',
  452. icon: 'none'
  453. })
  454. } else {
  455. this.delType = num
  456. this.delshow = true
  457. }
  458. } else if (anNum < 1) {
  459. uni.showToast({
  460. title: '至少选择一条回答!',
  461. icon: 'none'
  462. })
  463. } else {
  464. this.delType = num
  465. this.delshow = true
  466. }
  467. }
  468. },
  469. onReachBottom() {
  470. if (this.questionTypeFlag === 0) {
  471. if (this.problemInfo.data.length < this.problemInfo.listTotal) {
  472. ++this.problemInfo.query.page
  473. this.getProblemList(true)
  474. }
  475. } else if (this.questionTypeFlag === 1) {
  476. if (this.answerInfo.data.length < this.answerInfo.listTotal) {
  477. ++this.answerInfo.query.page
  478. this.getAnswerList(true)
  479. }
  480. }
  481. }
  482. }
  483. </script>
  484. <style lang="less" scoped>
  485. page {
  486. background-color: #F7F7F7;
  487. }
  488. .question-box {
  489. .empty-box {
  490. display: flex;
  491. justify-content: center;
  492. flex-direction: column;
  493. align-items: center;
  494. padding-top: 40%;
  495. .tohome-box {
  496. color: #999999;
  497. margin-top: 50rpx;
  498. }
  499. .question-empty {
  500. width: 198rpx;
  501. height: 183rpx;
  502. }
  503. }
  504. .Put-box1 {
  505. .btn {
  506. text-align: center;
  507. margin-top: 40rpx;
  508. border: 1px solid #333333;
  509. height: 80upx;
  510. line-height: 80upx;
  511. width: 100%;
  512. color: #333333;
  513. }
  514. .submit {
  515. background-color: #333333;
  516. color: #FFEBC4;
  517. }
  518. }
  519. .cancelDel {
  520. position: absolute;
  521. bottom: -50px;
  522. left: 45%;
  523. }
  524. .function-box {
  525. background-color: #F7F7F7;
  526. }
  527. .tabsbox {
  528. margin-top: 4rpx;
  529. background-color: #FFFFFF;
  530. }
  531. .editicon-box {
  532. display: flex;
  533. justify-content: flex-end;
  534. position: relative;
  535. left: -30rpx;
  536. padding: 16rpx 0;
  537. }
  538. .finishbox {
  539. display: flex;
  540. justify-content: flex-end;
  541. position: relative;
  542. left: -30rpx;
  543. padding: 16rpx 0;
  544. }
  545. .swipe-box {
  546. width: 100%;
  547. padding: 0 24rpx;
  548. .itemBox {
  549. background: #FFFFFF;
  550. }
  551. .replynum-box {
  552. display: flex;
  553. flex-direction: column;
  554. justify-content: space-between;
  555. padding: 10rpx 0;
  556. }
  557. .item {
  558. display: flex;
  559. padding: 20rpx 20rpx 20rpx 40rpx;
  560. width: 700rpx;
  561. .qAarrow {
  562. image {
  563. width: 16rpx;
  564. height: 24rpx;
  565. margin-left: 10rpx;
  566. }
  567. }
  568. }
  569. label {
  570. width: 36rpx;
  571. height: 36rpx;
  572. display: block;
  573. line-height: 36rpx;
  574. text-align: center;
  575. background: #C83732;
  576. color: #FFFFFF;
  577. font-size: 20rpx;
  578. margin-right: 20rpx;
  579. }
  580. .reply {
  581. margin-top: 20rpx;
  582. label {
  583. background: #C5AA7B;
  584. }
  585. }
  586. .title {
  587. text-align: left;
  588. font-size: 28rpx;
  589. color: #606266;
  590. }
  591. }
  592. .allcheck-box {
  593. background-color: #FFFFFF;
  594. width: 100%;
  595. position: fixed;
  596. bottom: 0upx;
  597. .left {
  598. display: flex;
  599. flex-direction: row;
  600. align-items: center;
  601. font-size: 28upx;
  602. color: #666;
  603. }
  604. .right {
  605. display: flex;
  606. flex-direction: row;
  607. align-items: center;
  608. box-sizing: border-box;
  609. }
  610. .btn-delete {
  611. width: 230upx;
  612. height: 100upx;
  613. line-height: 100upx;
  614. text-align: center;
  615. font-size: 30upx;
  616. color: #FFFFFF;
  617. background: #C83732;
  618. }
  619. }
  620. }
  621. </style>