answerList.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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" />
  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="visitor.type === 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="aspectFill"
  40. />
  41. <template v-if="item.answer.isplay || item.answer.ispause">
  42. <text>{{
  43. moment(
  44. item.answer.audioTime - currentAudioMsg.audioCurrentTime
  45. ).format("mm:ss")
  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 } from "@/api/question.js";
  99. export default {
  100. mixins: [mixin],
  101. data() {
  102. return {
  103. questionList: [],
  104. barList: [],
  105. selectKey: "Wait",
  106. visitor: {
  107. type: 2, //1研究员,2客户
  108. },
  109. pauseImgSrc: "../static/audio-pause-2.png",
  110. playImgSrc: "../static/audio-doing.png",
  111. };
  112. },
  113. onLoad() {
  114. this.getVisitor();
  115. this.getBarList();
  116. this.getQuestionData();
  117. },
  118. onReachBottom() {
  119. if (this.finished) return;
  120. this.page++;
  121. this.getQuestionData();
  122. },
  123. methods: {
  124. toDetail(item) {
  125. //reply_status:1-待分配 2-待回答 3-已回答
  126. if (this.visitor.type === 1 && item.reply_status === 2) {
  127. uni.navigateTo({ url: "/pages-question/answerDetail?id=" + item.id });
  128. }
  129. },
  130. //点击bar
  131. changeBar({ key }) {
  132. if (key === this.selectKey) return;
  133. this.selectKey = key;
  134. this.questionList = [];
  135. this.page = 1;
  136. this.getQuestionData();
  137. },
  138. getVisitor() {
  139. if(this.visitor.type===1){
  140. this.selectKey = 'Wait'
  141. }else{
  142. this.selectKey = 'Replied'
  143. }
  144. },
  145. async getBarList() {
  146. const res = await apiBarTotal();
  147. if (res.code !== 200) return;
  148. const { replied, wait, total } = res.data;
  149. //客户: 已回答 未回答 全部
  150. const customBar = [
  151. {
  152. label: "已回答",
  153. key: "Replied",
  154. num: replied,
  155. },
  156. {
  157. label: "未回答",
  158. key: "Wait",
  159. num: wait,
  160. },
  161. {
  162. label: "全部",
  163. key: "Total",
  164. num: total,
  165. },
  166. ];
  167. //研究员: 待回答 已回答 全部
  168. const researBar = [
  169. {
  170. label: "待回答",
  171. key: "Wait",
  172. num: wait,
  173. },
  174. {
  175. label: "已回答",
  176. key: "Replied",
  177. num: replied,
  178. },
  179. {
  180. label: "全部",
  181. key: "Total",
  182. num: total,
  183. },
  184. ];
  185. this.barList = this.visitor.type === 2 ? customBar : researBar;
  186. },
  187. getQuestionData() {
  188. const reply_status = { Wait: 2, Replied: 3, Total: 0 };
  189. this.getQuestionList(reply_status[this.selectKey]);
  190. },
  191. },
  192. };
  193. </script>
  194. <style lang="scss" scoped>
  195. .answer-page {
  196. padding: 30rpx;
  197. .answer-bar {
  198. display: flex;
  199. justify-content: space-between;
  200. .bar-item {
  201. width: 206rpx;
  202. color: #666666;
  203. background-color: #f5f5f5;
  204. height: 70rpx;
  205. line-height: 70rpx;
  206. text-align: center;
  207. &.active {
  208. background-color: #fdf8f2;
  209. color: #e3b377;
  210. }
  211. }
  212. }
  213. .answer-list {
  214. margin-top: 20rpx;
  215. .question-item {
  216. margin-bottom: 20rpx;
  217. &::after {
  218. content: "";
  219. display: block;
  220. height: 10rpx;
  221. margin: 0 -30rpx;
  222. background-color: #f9f9f9;
  223. }
  224. &:last-child {
  225. &::after {
  226. background-color: #ffffff;
  227. }
  228. }
  229. .question-info {
  230. display: flex;
  231. padding: 10rpx 0;
  232. .question-title {
  233. font-size: 32rpx;
  234. color: #333333;
  235. .item-label {
  236. padding: 7rpx 12rpx;
  237. font-size: 22rpx;
  238. text-align: center;
  239. background-color: #333333;
  240. color: #e4b478;
  241. border-radius: 21rpx;
  242. margin-right: 15rpx;
  243. }
  244. }
  245. .item-answer {
  246. display: flex;
  247. align-items: center;
  248. .answer {
  249. width: 150rpx;
  250. height: 97rpx;
  251. box-sizing: border-box;
  252. padding: 30rpx 15rpx;
  253. border-radius: 18rpx;
  254. background: linear-gradient(253deg, #e3b377 0%, #fbca8e 100%);
  255. display: flex;
  256. justify-content: space-between;
  257. color: #ffffff;
  258. font-size: 24rpx;
  259. .load-img {
  260. width: 34rpx;
  261. height: 34rpx;
  262. margin-right: 10rpx;
  263. animation: circle 1s linear infinite;
  264. }
  265. .music-img {
  266. width: 34rpx;
  267. height: 34rpx;
  268. margin-right: 10rpx;
  269. }
  270. @keyframes circle {
  271. 0% {
  272. transform: rotateZ(0);
  273. }
  274. 100% {
  275. transform: rotateZ(360deg);
  276. }
  277. }
  278. }
  279. }
  280. }
  281. .item-time {
  282. color: #999999;
  283. font-size: 24rpx;
  284. margin: 20rpx 0;
  285. display: block;
  286. }
  287. }
  288. }
  289. .global-pup {
  290. .content {
  291. padding: 90rpx 34rpx;
  292. flex-direction: column;
  293. .contact {
  294. text {
  295. margin-left: 15rpx;
  296. color: #e6b77d;
  297. }
  298. }
  299. .apply {
  300. margin-top: 40rpx;
  301. width: 390rpx;
  302. height: 80rpx;
  303. background-color: #e6b77d;
  304. color: #ffffff;
  305. text-align: center;
  306. line-height: 80rpx;
  307. border-radius: 40rpx;
  308. }
  309. }
  310. }
  311. }
  312. </style>