answerList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. /* userInfo:{
  109. is_inner:0,//0:外部客户;1内部员工
  110. status:'正式'
  111. },//mock用户信息 */
  112. };
  113. },
  114. onLoad() {
  115. /* this.getVisitor();
  116. this.getBarList();
  117. this.getQuestionData(); */
  118. },
  119. onShow() {
  120. this.getSelectKey();
  121. this.getBarList();
  122. this.getQuestionData();
  123. },
  124. onReachBottom() {
  125. if (this.finished) return;
  126. this.page++;
  127. this.getQuestionData();
  128. },
  129. methods: {
  130. toDetail(item) {
  131. //reply_status:1-待分配 2-待回答 3-已回答
  132. if (this.userInfo.is_inner === 1 && item.reply_status === 2) {
  133. uni.navigateTo({ url: "/pages-question/answerDetail?id=" + item.id });
  134. }
  135. },
  136. //点击bar
  137. changeBar({ key }) {
  138. if (key === this.selectKey) return;
  139. this.selectKey = key;
  140. this.questionList = [];
  141. this.page = 1;
  142. this.resetAudio();
  143. this.getQuestionData();
  144. },
  145. getSelectKey() {
  146. if(this.userInfo.is_inner === 1){
  147. this.selectKey = 'Wait'
  148. }else{
  149. this.selectKey = 'Replied'
  150. }
  151. },
  152. async getBarList() {
  153. const res = await apiBarTotal();
  154. if (res.code !== 200) return;
  155. const { replied, wait, total } = res.data;
  156. //客户: 已回答 未回答 全部
  157. const customBar = [
  158. {
  159. label: "已回答",
  160. key: "Replied",
  161. num: replied,
  162. },
  163. {
  164. label: "未回答",
  165. key: "Wait",
  166. num: wait,
  167. },
  168. {
  169. label: "全部",
  170. key: "Total",
  171. num: total,
  172. },
  173. ];
  174. //研究员: 待回答 已回答 全部
  175. const researBar = [
  176. {
  177. label: "待回答",
  178. key: "Wait",
  179. num: wait,
  180. },
  181. {
  182. label: "已回答",
  183. key: "Replied",
  184. num: replied,
  185. },
  186. {
  187. label: "全部",
  188. key: "Total",
  189. num: total,
  190. },
  191. ];
  192. this.barList = this.userInfo.is_inner === 1 ? researBar : customBar;
  193. },
  194. async getQuestionData() {
  195. const reply_status = { Wait: 2, Replied: 3, Total: 0 };
  196. await this.getQuestionList(reply_status[this.selectKey],1);
  197. this.setQuestionsRead()
  198. },
  199. async setQuestionsRead(){
  200. //获取未读的数据,请求未读接口变为已读
  201. let unReadArr = []
  202. this.questionList.forEach(item=>{
  203. let isReadKey = this.userInfo.is_inner===1?'replier_is_read':'is_read'
  204. if(item[isReadKey]===0){
  205. unReadArr.push(item.community_question_id)
  206. }
  207. })
  208. if(unReadArr.length===0) return
  209. await apiSetRead({
  210. question_ids:unReadArr.join(',')
  211. })
  212. }
  213. },
  214. };
  215. </script>
  216. <style lang="scss" scoped>
  217. .answer-page {
  218. padding: 30rpx;
  219. .answer-bar {
  220. display: flex;
  221. justify-content: space-between;
  222. .bar-item {
  223. width: 206rpx;
  224. color: #666666;
  225. background-color: #f5f5f5;
  226. height: 70rpx;
  227. line-height: 70rpx;
  228. text-align: center;
  229. &.active {
  230. background-color: #fdf8f2;
  231. color: #e3b377;
  232. }
  233. }
  234. }
  235. .answer-list {
  236. margin-top: 20rpx;
  237. }
  238. .global-pup {
  239. .content {
  240. padding: 90rpx 34rpx;
  241. flex-direction: column;
  242. .contact {
  243. text {
  244. margin-left: 15rpx;
  245. color: #e6b77d;
  246. }
  247. }
  248. .apply {
  249. margin-top: 40rpx;
  250. width: 390rpx;
  251. height: 80rpx;
  252. background-color: #e6b77d;
  253. color: #ffffff;
  254. text-align: center;
  255. line-height: 80rpx;
  256. border-radius: 40rpx;
  257. }
  258. }
  259. }
  260. }
  261. </style>