answerList.vue 8.2 KB

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