answerList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <view class="answer-page">
  3. <template v-if="hasAuth">
  4. <view class="answer-bar">
  5. <view
  6. class="bar-item"
  7. :class="{ active: item.key === selectKey }"
  8. @click="changeBar(item)"
  9. v-for="item in barList"
  10. :key="item.key"
  11. >{{ item.label + "(" + item.num + ")" }}</view
  12. >
  13. </view>
  14. <view class="answer-list">
  15. <view class="report-empty-box" v-if="questionList.length == 0">
  16. <image :src="globalImgUrls.activityNoAuth" mode="widthFix" style="width:100%;"/>
  17. <view>暂无数据</view>
  18. </view>
  19. <view
  20. class="question-item"
  21. v-for="item in questionList"
  22. :key="item.community_question_id"
  23. @click="toDetail(item)"
  24. >
  25. <view class="question-info">
  26. <view style="flex: 1" class="question-title">
  27. <text
  28. class="item-label"
  29. >{{ item.variety_tag_name }}</text
  30. >
  31. {{ item.question_content }}
  32. </view>
  33. <view class="item-answer" v-if="item.reply_status === 3">
  34. <view class="answer" @click.stop="handlePlayAudioByBg(item)">
  35. <!-- 改为背景音频播放 -->
  36. <image class="music-img" :src="item.community_question_id==curVoiceId&&!curAudioPaused?playImgSrc:pauseImgSrc" mode="widthFix"/>
  37. <text>{{ dayjs(item.answer.audioTime).format('mm:ss') }}</text>
  38. <!-- <template v-if="!item.loading">
  39. <image
  40. class="music-img"
  41. :src="item.answer.isplay ? playImgSrc : pauseImgSrc"
  42. mode="widthFix"
  43. />
  44. <template v-if="item.answer.isplay || item.answer.ispause">
  45. <text>{{
  46. item.answer.audioTime - currentAudioMsg.audioCurrentTime>0?
  47. dayjs(item.answer.audioTime - currentAudioMsg.audioCurrentTime).format('mm:ss')
  48. :'00:00'}}
  49. </text>
  50. </template>
  51. <template v-else>
  52. <text>{{
  53. dayjs(item.answer.audioTime).format("mm:ss")
  54. }}</text>
  55. </template>
  56. </template>
  57. <template v-else>
  58. <image
  59. class="load-img"
  60. src="../static/loading.png"
  61. mode="aspectFill"
  62. />
  63. <text>{{ dayjs(item.answer.audioTime).format("mm:ss") }}</text>
  64. </template> -->
  65. </view>
  66. </view>
  67. </view>
  68. <text class="item-time">提问时间:{{ item.create_time }}</text>
  69. </view>
  70. </view>
  71. </template>
  72. <!-- 没有权限 -->
  73. <template v-else>
  74. <view class="noAuth-wrap">
  75. <image class="img" :src="globalImgUrls.activityNoAuth" mode="widthFix"></image>
  76. <view class="auth-text">您暂无权限查看问答社区</view>
  77. <view class="auth-text" v-if="noAuthInfo.type==='contact'">若想查看可以联系对口销售</view>
  78. <view class="auth-text" v-else>若想查看可以申请开通</view>
  79. <view class="auth-text" v-if="noAuthInfo.type==='contact'">
  80. {{noAuthInfo.name||''}}:<text @click="handleCallPhone(noAuthInfo.mobile+'')">{{noAuthInfo.mobile||''}}</text>
  81. </view>
  82. <view class="apply" @click="handleGoApply" v-else>立即申请</view>
  83. </view>
  84. </template>
  85. <!-- 弹窗 -->
  86. <van-popup
  87. :show="pupData.show"
  88. round
  89. @close="pupData.show = false"
  90. closeable
  91. :close-on-click-overlay="false"
  92. >
  93. <view class="global-pup">
  94. <view class="content">
  95. <rich-text
  96. style="flex: none; margin-bottom: 20rpx"
  97. :nodes="pupData.content"
  98. ></rich-text>
  99. <view class="contact" v-if="pupData.type === 'contact'">
  100. {{ pupData.saleName || "梁娜" }}:<text
  101. @click="handleCallPhone(pupData.mobile)"
  102. >{{ pupData.mobile || "123456" }}</text
  103. >
  104. </view>
  105. <view class="apply" v-else-if="pupData.type === 'apply'">
  106. <view @click="handleApply">立即申请</view>
  107. </view>
  108. </view>
  109. </view>
  110. </van-popup>
  111. <!-- 音频悬浮 -->
  112. <audioBox v-if="showAudioPop"/>
  113. </view>
  114. </template>
  115. <script>
  116. import mixin from "../mixin/questionMixin";
  117. import { apiBarTotal ,apiSetRead} from "@/api/question.js";
  118. import audioBox from '@/components/audioBox/audioBox.vue'
  119. export default {
  120. mixins: [mixin],
  121. components:{
  122. audioBox
  123. },
  124. computed:{
  125. showAudioPop(){//是否显示音频弹窗
  126. return this.$store.state.audio.show
  127. },
  128. showAudioBigPop(){
  129. return this.$store.state.audio.showBig
  130. },
  131. curVoiceId(){//当前正在播放的音频id
  132. return this.$store.state.audio.questionId
  133. },
  134. curAudioPaused(){//当前音频是否暂停状态
  135. return this.$store.state.audio.paused
  136. },
  137. },
  138. data() {
  139. return {
  140. questionList: [],
  141. barList: [],
  142. selectKey: "Wait",
  143. pauseImgSrc: "../static/question/recordplay.png",
  144. playImgSrc: "../static/question/recordpause.png",
  145. // 列表的状态 0-全部 2-未回答 3-已回答 4-待回答
  146. questionStatus:0,
  147. /* userInfo:{
  148. is_inner:1,//0:外部客户;1内部员工
  149. status:'试用',
  150. is_suspend:0,
  151. is_researcher:0
  152. },//mock用户信息 */
  153. };
  154. },
  155. onLoad() {
  156. /* this.getVisitor();
  157. this.getBarList();
  158. this.getQuestionData(); */
  159. },
  160. onShow() {
  161. this.getSelectKey();
  162. this.getBarList();
  163. this.getQuestionData();
  164. },
  165. onReachBottom() {
  166. if (this.finished) return;
  167. this.page++;
  168. this.getQuestionData();
  169. },
  170. onPullDownRefresh() {
  171. this.resetAudio()
  172. this.refreshPage()
  173. setTimeout(() => {
  174. uni.stopPullDownRefresh()
  175. }, 1500);
  176. },
  177. methods: {
  178. toDetail(item) {
  179. // 未回答的不进行操作
  180. if(this.questionStatus == 2) return
  181. //reply_status:1-待分配 2-待回答 3-已回答
  182. if (this.isUserResearcher && item.reply_status === 2 && item.replier_user_id == this.userInfo.user_id) {
  183. // 是研究员 && 问题是待回答 && 回答者是我
  184. uni.navigateTo({ url: "/pages-question/answerDetail?id=" + item.id });
  185. }
  186. },
  187. //点击bar
  188. changeBar({ key }) {
  189. if (key === this.selectKey) return;
  190. this.selectKey = key;
  191. this.questionList = [];
  192. this.page = 1;
  193. // 重新获取数量
  194. apiBarTotal().then(res=>{
  195. if(res.code == 200){
  196. const { replied, wait, total,distribute,stop } = res.data;
  197. for (const bar of this.barList) {
  198. if(bar.label == '已回答'){
  199. bar.num = replied
  200. }else if(bar.label == '未回答'){
  201. bar.num = wait
  202. }else if(bar.label == '全部'){
  203. bar.num = total
  204. }else if(bar.label == '待回答'){
  205. bar.num = distribute
  206. }else if(bar.label=='已终止'){
  207. bar.num=stop
  208. }
  209. }
  210. }
  211. });
  212. this.resetAudio();
  213. this.getQuestionData();
  214. },
  215. getSelectKey() {
  216. if(this.userInfo.is_inner === 1){
  217. this.selectKey = 'Distribute'
  218. }else{
  219. this.selectKey = 'Replied'
  220. }
  221. },
  222. async getBarList() {
  223. const res = await apiBarTotal();
  224. if (res.code !== 200) return;
  225. const { replied, wait, total,distribute,stop } = res.data;
  226. //客户: 已回答 未回答 全部
  227. const customBar = [
  228. {
  229. label: "已回答",
  230. key: "Replied",
  231. num: replied,
  232. },
  233. {
  234. label: "未回答",
  235. key: "Wait",
  236. num: wait,
  237. },
  238. {
  239. label: "全部",
  240. key: "Total",
  241. num: total,
  242. },
  243. ];
  244. //研究员: 待回答 未回答 已回答 全部
  245. const researBar = [
  246. {
  247. label: "待回答",
  248. key: "Distribute",
  249. num: distribute,
  250. },
  251. {
  252. label:'未回答',
  253. key:'Wait',
  254. num:wait,
  255. },
  256. {
  257. label: "已回答",
  258. key: "Replied",
  259. num: replied,
  260. },
  261. {
  262. label: "已终止",
  263. key: "Stop",
  264. num: stop,
  265. },
  266. {
  267. label: "全部",
  268. key: "Total",
  269. num: total,
  270. },
  271. ];
  272. this.barList = this.isUserResearcher ? researBar : customBar;
  273. },
  274. async getQuestionData() {
  275. const reply_status = { Wait: 2, Replied: 3, Total: 0 ,Distribute:4,Stop:5};
  276. this.questionStatus = reply_status[this.selectKey]
  277. await this.getQuestionList(reply_status[this.selectKey],1);
  278. this.setQuestionsRead()
  279. },
  280. async setQuestionsRead(){
  281. //获取未读的数据,请求未读接口变为已读
  282. let unReadArr = []
  283. this.questionList.forEach(item=>{
  284. /* let isReadKey = this.isUserResearcher?'replier_is_read':'is_read' */
  285. let isReadKey = item.user_id===this.userInfo.user_id?'replier_is_read':'is_read'
  286. if(item[isReadKey]===0){
  287. unReadArr.push(item.community_question_id)
  288. }
  289. })
  290. if(unReadArr.length===0) return
  291. await apiSetRead({
  292. question_ids:unReadArr.join(',')
  293. })
  294. },
  295. refreshPage() {
  296. this.page = 1
  297. this.selectId = -1
  298. this.questionList = []
  299. this.finished = false
  300. this.getQuestionData()
  301. },
  302. },
  303. };
  304. </script>
  305. <style lang="scss" scoped>
  306. .answer-page {
  307. padding: 30rpx;
  308. .answer-bar {
  309. display: flex;
  310. /* justify-content: space-between; */
  311. overflow-x: scroll;
  312. &::-webkit-scrollbar{
  313. width: 0;
  314. display: none;
  315. }
  316. .bar-item {
  317. width: 206rpx;
  318. min-width: 206rpx;
  319. color: #666666;
  320. background-color: #f5f5f5;
  321. height: 70rpx;
  322. line-height: 70rpx;
  323. text-align: center;
  324. margin-right: 20rpx;
  325. &.active {
  326. background-color: #fdf8f2;
  327. color: #e3b377;
  328. }
  329. }
  330. }
  331. .answer-list {
  332. margin-top: 20rpx;
  333. }
  334. .global-pup {
  335. .content {
  336. padding: 90rpx 34rpx;
  337. flex-direction: column;
  338. .contact {
  339. text {
  340. margin-left: 15rpx;
  341. color: #e6b77d;
  342. }
  343. }
  344. .apply {
  345. margin-top: 40rpx;
  346. width: 390rpx;
  347. height: 80rpx;
  348. background-color: #e6b77d;
  349. color: #ffffff;
  350. text-align: center;
  351. line-height: 80rpx;
  352. border-radius: 40rpx;
  353. }
  354. }
  355. }
  356. }
  357. </style>