answerList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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>{{ moment(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. moment(item.answer.audioTime - currentAudioMsg.audioCurrentTime).format('mm:ss')
  49. :'00:00'}}
  50. </text>
  51. </template>
  52. <template v-else>
  53. <text>{{
  54. moment(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>{{ moment(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. export default {
  120. mixins: [mixin],
  121. computed:{
  122. showAudioPop(){//是否显示音频弹窗
  123. return this.$store.state.audio.show
  124. },
  125. showAudioBigPop(){
  126. return this.$store.state.audio.showBig
  127. },
  128. curVoiceId(){//当前正在播放的音频id
  129. return this.$store.state.audio.questionId
  130. },
  131. curAudioPaused(){//当前音频是否暂停状态
  132. return this.$store.state.audio.paused
  133. },
  134. },
  135. data() {
  136. return {
  137. questionList: [],
  138. barList: [],
  139. selectKey: "Wait",
  140. pauseImgSrc: "../static/question/recordplay.png",
  141. playImgSrc: "../static/question/recordpause.png",
  142. // 列表的状态 0-全部 2-未回答 3-已回答 4-待回答
  143. questionStatus:0,
  144. /* userInfo:{
  145. is_inner:1,//0:外部客户;1内部员工
  146. status:'试用',
  147. is_suspend:0,
  148. is_researcher:0
  149. },//mock用户信息 */
  150. };
  151. },
  152. onLoad() {
  153. /* this.getVisitor();
  154. this.getBarList();
  155. this.getQuestionData(); */
  156. },
  157. onShow() {
  158. this.getSelectKey();
  159. this.getBarList();
  160. this.getQuestionData();
  161. },
  162. onReachBottom() {
  163. if (this.finished) return;
  164. this.page++;
  165. this.getQuestionData();
  166. },
  167. onPullDownRefresh() {
  168. this.resetAudio()
  169. this.refreshPage()
  170. setTimeout(() => {
  171. uni.stopPullDownRefresh()
  172. }, 1500);
  173. },
  174. methods: {
  175. toDetail(item) {
  176. // 未回答的不进行操作
  177. if(this.questionStatus == 2) return
  178. //reply_status:1-待分配 2-待回答 3-已回答
  179. if (this.isUserResearcher && item.reply_status === 2 && item.replier_user_id == this.userInfo.user_id) {
  180. // 是研究员 && 问题是待回答 && 回答者是我
  181. uni.navigateTo({ url: "/pages-question/answerDetail?id=" + item.id });
  182. }
  183. },
  184. //点击bar
  185. changeBar({ key }) {
  186. if (key === this.selectKey) return;
  187. this.selectKey = key;
  188. this.questionList = [];
  189. this.page = 1;
  190. // 重新获取数量
  191. apiBarTotal().then(res=>{
  192. if(res.code == 200){
  193. const { replied, wait, total,distribute } = res.data;
  194. for (const bar of this.barList) {
  195. if(bar.label == '已回答'){
  196. bar.num = replied
  197. }else if(bar.label == '未回答'){
  198. bar.num = wait
  199. }else if(bar.label == '全部'){
  200. bar.num = total
  201. }else if(bar.label == '待回答'){
  202. bar.num = distribute
  203. }
  204. }
  205. }
  206. });
  207. this.resetAudio();
  208. this.getQuestionData();
  209. },
  210. getSelectKey() {
  211. if(this.userInfo.is_inner === 1){
  212. this.selectKey = 'Distribute'
  213. }else{
  214. this.selectKey = 'Replied'
  215. }
  216. },
  217. async getBarList() {
  218. const res = await apiBarTotal();
  219. if (res.code !== 200) return;
  220. const { replied, wait, total,distribute } = res.data;
  221. //客户: 已回答 未回答 全部
  222. const customBar = [
  223. {
  224. label: "已回答",
  225. key: "Replied",
  226. num: replied,
  227. },
  228. {
  229. label: "未回答",
  230. key: "Wait",
  231. num: wait,
  232. },
  233. {
  234. label: "全部",
  235. key: "Total",
  236. num: total,
  237. },
  238. ];
  239. //研究员: 待回答 未回答 已回答 全部
  240. const researBar = [
  241. {
  242. label: "待回答",
  243. key: "Distribute",
  244. num: distribute,
  245. },
  246. {
  247. label:'未回答',
  248. key:'Wait',
  249. num:wait,
  250. },
  251. {
  252. label: "已回答",
  253. key: "Replied",
  254. num: replied,
  255. },
  256. {
  257. label: "全部",
  258. key: "Total",
  259. num: total,
  260. },
  261. ];
  262. this.barList = this.isUserResearcher ? researBar : customBar;
  263. },
  264. async getQuestionData() {
  265. const reply_status = { Wait: 2, Replied: 3, Total: 0 ,Distribute:4};
  266. this.questionStatus = reply_status[this.selectKey]
  267. await this.getQuestionList(reply_status[this.selectKey],1);
  268. this.setQuestionsRead()
  269. },
  270. async setQuestionsRead(){
  271. //获取未读的数据,请求未读接口变为已读
  272. let unReadArr = []
  273. this.questionList.forEach(item=>{
  274. /* let isReadKey = this.isUserResearcher?'replier_is_read':'is_read' */
  275. let isReadKey = item.user_id===this.userInfo.user_id?'replier_is_read':'is_read'
  276. if(item[isReadKey]===0){
  277. unReadArr.push(item.community_question_id)
  278. }
  279. })
  280. if(unReadArr.length===0) return
  281. await apiSetRead({
  282. question_ids:unReadArr.join(',')
  283. })
  284. },
  285. refreshPage() {
  286. this.page = 1
  287. this.selectId = -1
  288. this.questionList = []
  289. this.finished = false
  290. this.getQuestionData()
  291. },
  292. },
  293. };
  294. </script>
  295. <style lang="scss" scoped>
  296. .answer-page {
  297. padding: 30rpx;
  298. .answer-bar {
  299. display: flex;
  300. /* justify-content: space-between; */
  301. overflow-x: scroll;
  302. &::-webkit-scrollbar{
  303. width: 0;
  304. display: none;
  305. }
  306. .bar-item {
  307. width: 206rpx;
  308. min-width: 206rpx;
  309. color: #666666;
  310. background-color: #f5f5f5;
  311. height: 70rpx;
  312. line-height: 70rpx;
  313. text-align: center;
  314. margin-right: 20rpx;
  315. &.active {
  316. background-color: #fdf8f2;
  317. color: #e3b377;
  318. }
  319. }
  320. }
  321. .answer-list {
  322. margin-top: 20rpx;
  323. }
  324. .global-pup {
  325. .content {
  326. padding: 90rpx 34rpx;
  327. flex-direction: column;
  328. .contact {
  329. text {
  330. margin-left: 15rpx;
  331. color: #e6b77d;
  332. }
  333. }
  334. .apply {
  335. margin-top: 40rpx;
  336. width: 390rpx;
  337. height: 80rpx;
  338. background-color: #e6b77d;
  339. color: #ffffff;
  340. text-align: center;
  341. line-height: 80rpx;
  342. border-radius: 40rpx;
  343. }
  344. }
  345. }
  346. }
  347. </style>