answerList.vue 11 KB

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