answerList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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. v-if="(item.reply_status === 3 || item.replier_user_id == userInfo.user_id) && questionStatus!=2"
  30. >{{ item.variety_tag_name }}</text
  31. >
  32. {{ item.question_content }}
  33. </view>
  34. <view class="item-answer" v-if="item.reply_status === 3">
  35. <view class="answer" @click.stop="handlePlayAudioByBg(item)">
  36. <!-- 改为背景音频播放 -->
  37. <image class="music-img" :src="item.community_question_id==curVoiceId&&!curAudioPaused?playImgSrc:pauseImgSrc" mode="widthFix"/>
  38. <text>{{ dayjs(item.answer.audioTime).format('mm:ss') }}</text>
  39. <!-- <template v-if="!item.loading">
  40. <image
  41. class="music-img"
  42. :src="item.answer.isplay ? playImgSrc : pauseImgSrc"
  43. mode="widthFix"
  44. />
  45. <template v-if="item.answer.isplay || item.answer.ispause">
  46. <text>{{
  47. item.answer.audioTime - currentAudioMsg.audioCurrentTime>0?
  48. dayjs(item.answer.audioTime - currentAudioMsg.audioCurrentTime).format('mm:ss')
  49. :'00:00'}}
  50. </text>
  51. </template>
  52. <template v-else>
  53. <text>{{
  54. dayjs(item.answer.audioTime).format("mm:ss")
  55. }}</text>
  56. </template>
  57. </template>
  58. <template v-else>
  59. <image
  60. class="load-img"
  61. src="../static/loading.png"
  62. mode="aspectFill"
  63. />
  64. <text>{{ dayjs(item.answer.audioTime).format("mm:ss") }}</text>
  65. </template> -->
  66. </view>
  67. </view>
  68. </view>
  69. <text class="item-time">提问时间:{{ item.create_time }}</text>
  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="apply" @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 } = 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. }
  208. }
  209. }
  210. });
  211. this.resetAudio();
  212. this.getQuestionData();
  213. },
  214. getSelectKey() {
  215. if(this.userInfo.is_inner === 1){
  216. this.selectKey = 'Distribute'
  217. }else{
  218. this.selectKey = 'Replied'
  219. }
  220. },
  221. async getBarList() {
  222. const res = await apiBarTotal();
  223. if (res.code !== 200) return;
  224. const { replied, wait, total,distribute } = res.data;
  225. //客户: 已回答 未回答 全部
  226. const customBar = [
  227. {
  228. label: "已回答",
  229. key: "Replied",
  230. num: replied,
  231. },
  232. {
  233. label: "未回答",
  234. key: "Wait",
  235. num: wait,
  236. },
  237. {
  238. label: "全部",
  239. key: "Total",
  240. num: total,
  241. },
  242. ];
  243. //研究员: 待回答 未回答 已回答 全部
  244. const researBar = [
  245. {
  246. label: "待回答",
  247. key: "Distribute",
  248. num: distribute,
  249. },
  250. {
  251. label:'未回答',
  252. key:'Wait',
  253. num:wait,
  254. },
  255. {
  256. label: "已回答",
  257. key: "Replied",
  258. num: replied,
  259. },
  260. {
  261. label: "全部",
  262. key: "Total",
  263. num: total,
  264. },
  265. ];
  266. this.barList = this.isUserResearcher ? researBar : customBar;
  267. },
  268. async getQuestionData() {
  269. const reply_status = { Wait: 2, Replied: 3, Total: 0 ,Distribute:4};
  270. this.questionStatus = reply_status[this.selectKey]
  271. await this.getQuestionList(reply_status[this.selectKey],1);
  272. this.setQuestionsRead()
  273. },
  274. async setQuestionsRead(){
  275. //获取未读的数据,请求未读接口变为已读
  276. let unReadArr = []
  277. this.questionList.forEach(item=>{
  278. /* let isReadKey = this.isUserResearcher?'replier_is_read':'is_read' */
  279. let isReadKey = item.user_id===this.userInfo.user_id?'replier_is_read':'is_read'
  280. if(item[isReadKey]===0){
  281. unReadArr.push(item.community_question_id)
  282. }
  283. })
  284. if(unReadArr.length===0) return
  285. await apiSetRead({
  286. question_ids:unReadArr.join(',')
  287. })
  288. },
  289. refreshPage() {
  290. this.page = 1
  291. this.selectId = -1
  292. this.questionList = []
  293. this.finished = false
  294. this.getQuestionData()
  295. },
  296. },
  297. };
  298. </script>
  299. <style lang="scss" scoped>
  300. .answer-page {
  301. padding: 30rpx;
  302. .answer-bar {
  303. display: flex;
  304. /* justify-content: space-between; */
  305. overflow-x: scroll;
  306. &::-webkit-scrollbar{
  307. width: 0;
  308. display: none;
  309. }
  310. .bar-item {
  311. width: 206rpx;
  312. min-width: 206rpx;
  313. color: #666666;
  314. background-color: #f5f5f5;
  315. height: 70rpx;
  316. line-height: 70rpx;
  317. text-align: center;
  318. margin-right: 20rpx;
  319. &.active {
  320. background-color: #fdf8f2;
  321. color: #e3b377;
  322. }
  323. }
  324. }
  325. .answer-list {
  326. margin-top: 20rpx;
  327. }
  328. .global-pup {
  329. .content {
  330. padding: 90rpx 34rpx;
  331. flex-direction: column;
  332. .contact {
  333. text {
  334. margin-left: 15rpx;
  335. color: #e6b77d;
  336. }
  337. }
  338. .apply {
  339. margin-top: 40rpx;
  340. width: 390rpx;
  341. height: 80rpx;
  342. background-color: #e6b77d;
  343. color: #ffffff;
  344. text-align: center;
  345. line-height: 80rpx;
  346. border-radius: 40rpx;
  347. }
  348. }
  349. }
  350. }
  351. </style>