answerList.vue 7.0 KB

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