answerList.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="answer-page">
  3. <view class="answer-bar">
  4. <view
  5. class="bar-item"
  6. :class="{ active: item.key === selectKey }"
  7. @click="changeBar(item)"
  8. v-for="item in barList"
  9. :key="item.key"
  10. >{{ item.label + "(" + item.num + ")" }}</view
  11. >
  12. </view>
  13. <view class="answer-list">
  14. <view class="report-empty-box" v-if="questionList.length == 0">
  15. <image :src="globalImgUrls.activityNoAuth" mode="widthFix" style="width:100%;"/>
  16. <view>暂无数据</view>
  17. </view>
  18. <view
  19. class="question-item"
  20. v-for="item in questionList"
  21. :key="item.community_question_id"
  22. @click="toDetail(item)"
  23. >
  24. <view class="question-info">
  25. <view style="flex: 1" class="question-title">
  26. <text
  27. class="item-label"
  28. v-if="userInfo.is_inner === 1 || item.reply_status === 3"
  29. >{{ item.chart_permission_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="handleAudio(item)">
  35. <template v-if="!item.loading">
  36. <image
  37. class="music-img"
  38. :src="item.answer.isplay ? playImgSrc : pauseImgSrc"
  39. mode="widthFix"
  40. />
  41. <template v-if="item.answer.isplay || item.answer.ispause">
  42. <text>{{
  43. item.answer.audioTime - currentAudioMsg.audioCurrentTime>0?
  44. moment(item.answer.audioTime - currentAudioMsg.audioCurrentTime).format('mm:ss')
  45. :'00:00'}}
  46. </text>
  47. </template>
  48. <template v-else>
  49. <text>{{
  50. moment(item.answer.audioTime).format("mm:ss")
  51. }}</text>
  52. </template>
  53. </template>
  54. <template v-else>
  55. <image
  56. class="load-img"
  57. src="../static/loading.png"
  58. mode="aspectFill"
  59. />
  60. <text>{{ moment(item.answer.audioTime).format("mm:ss") }}</text>
  61. </template>
  62. </view>
  63. </view>
  64. </view>
  65. <text class="item-time">提问时间:{{ item.create_time }}</text>
  66. </view>
  67. </view>
  68. <!-- 弹窗 -->
  69. <van-popup
  70. :show="pupData.show"
  71. round
  72. @close="pupData.show = false"
  73. closeable
  74. :close-on-click-overlay="false"
  75. >
  76. <view class="global-pup">
  77. <view class="content">
  78. <rich-text
  79. style="flex: none; margin-bottom: 20rpx"
  80. :nodes="pupData.content"
  81. ></rich-text>
  82. <view class="contact" v-if="pupData.type === 'contact'">
  83. {{ pupData.saleName || "梁娜" }}:<text
  84. @click="handleCallPhone(pupData.mobile)"
  85. >{{ pupData.mobile || "123456" }}</text
  86. >
  87. </view>
  88. <view class="apply" v-else-if="pupData.type === 'apply'">
  89. <view @click="handleApply">立即申请</view>
  90. </view>
  91. </view>
  92. </view>
  93. </van-popup>
  94. </view>
  95. </template>
  96. <script>
  97. import mixin from "../mixin/questionMixin";
  98. import { apiBarTotal ,apiSetRead} from "@/api/question.js";
  99. export default {
  100. mixins: [mixin],
  101. data() {
  102. return {
  103. questionList: [],
  104. barList: [],
  105. selectKey: "Wait",
  106. pauseImgSrc: "../static/question/recordplay.png",
  107. playImgSrc: "../static/question/recordpause.png",
  108. };
  109. },
  110. onLoad() {
  111. /* this.getVisitor();
  112. this.getBarList();
  113. this.getQuestionData(); */
  114. },
  115. onShow() {
  116. this.getSelectKey();
  117. this.getBarList();
  118. this.getQuestionData();
  119. },
  120. onReachBottom() {
  121. if (this.finished) return;
  122. this.page++;
  123. this.getQuestionData();
  124. },
  125. methods: {
  126. toDetail(item) {
  127. //reply_status:1-待分配 2-待回答 3-已回答
  128. if (this.userInfo.is_inner === 1 && item.reply_status === 2) {
  129. uni.navigateTo({ url: "/pages-question/answerDetail?id=" + item.id });
  130. }
  131. },
  132. //点击bar
  133. changeBar({ key }) {
  134. if (key === this.selectKey) return;
  135. this.selectKey = key;
  136. this.questionList = [];
  137. this.page = 1;
  138. this.getQuestionData();
  139. },
  140. getSelectKey() {
  141. if(this.userInfo.is_inner === 1){
  142. this.selectKey = 'Wait'
  143. }else{
  144. this.selectKey = 'Replied'
  145. }
  146. },
  147. async getBarList() {
  148. const res = await apiBarTotal();
  149. if (res.code !== 200) return;
  150. const { replied, wait, total } = res.data;
  151. //客户: 已回答 未回答 全部
  152. const customBar = [
  153. {
  154. label: "已回答",
  155. key: "Replied",
  156. num: replied,
  157. },
  158. {
  159. label: "未回答",
  160. key: "Wait",
  161. num: wait,
  162. },
  163. {
  164. label: "全部",
  165. key: "Total",
  166. num: total,
  167. },
  168. ];
  169. //研究员: 待回答 已回答 全部
  170. const researBar = [
  171. {
  172. label: "待回答",
  173. key: "Wait",
  174. num: wait,
  175. },
  176. {
  177. label: "已回答",
  178. key: "Replied",
  179. num: replied,
  180. },
  181. {
  182. label: "全部",
  183. key: "Total",
  184. num: total,
  185. },
  186. ];
  187. this.barList = this.userInfo.is_inner === 1 ? researBar : customBar;
  188. },
  189. async getQuestionData() {
  190. const reply_status = { Wait: 2, Replied: 3, Total: 0 };
  191. await this.getQuestionList(reply_status[this.selectKey],1);
  192. this.setQuestionsRead()
  193. },
  194. async setQuestionsRead(){
  195. //获取未读的数据,请求未读接口变为已读
  196. let unReadArr = []
  197. this.questionList.forEach(item=>{
  198. let isReadKey = this.userInfo.is_inner===1?'replier_is_read':'is_read'
  199. if(item[isReadKey]===0){
  200. unReadArr.push(item.community_question_id)
  201. }
  202. })
  203. if(unReadArr.length===0) return
  204. await apiSetRead({
  205. question_ids:unReadArr.join(',')
  206. })
  207. }
  208. },
  209. };
  210. </script>
  211. <style lang="scss" scoped>
  212. .answer-page {
  213. padding: 30rpx;
  214. .answer-bar {
  215. display: flex;
  216. justify-content: space-between;
  217. .bar-item {
  218. width: 206rpx;
  219. color: #666666;
  220. background-color: #f5f5f5;
  221. height: 70rpx;
  222. line-height: 70rpx;
  223. text-align: center;
  224. &.active {
  225. background-color: #fdf8f2;
  226. color: #e3b377;
  227. }
  228. }
  229. }
  230. .answer-list {
  231. margin-top: 20rpx;
  232. }
  233. .global-pup {
  234. .content {
  235. padding: 90rpx 34rpx;
  236. flex-direction: column;
  237. .contact {
  238. text {
  239. margin-left: 15rpx;
  240. color: #e6b77d;
  241. }
  242. }
  243. .apply {
  244. margin-top: 40rpx;
  245. width: 390rpx;
  246. height: 80rpx;
  247. background-color: #e6b77d;
  248. color: #ffffff;
  249. text-align: center;
  250. line-height: 80rpx;
  251. border-radius: 40rpx;
  252. }
  253. }
  254. }
  255. }
  256. </style>