answerList.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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="(item.reply_status === 3 || item.replier_user_id == userInfo.user_id) && questionStatus!=2"
  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. // 列表的状态 0-全部 2-未回答 3-已回答 4-待回答
  124. questionStatus:0,
  125. /* userInfo:{
  126. is_inner:1,//0:外部客户;1内部员工
  127. status:'试用',
  128. is_suspend:0,
  129. is_researcher:0
  130. },//mock用户信息 */
  131. };
  132. },
  133. onLoad() {
  134. /* this.getVisitor();
  135. this.getBarList();
  136. this.getQuestionData(); */
  137. },
  138. onShow() {
  139. this.getSelectKey();
  140. this.getBarList();
  141. this.getQuestionData();
  142. },
  143. onReachBottom() {
  144. if (this.finished) return;
  145. this.page++;
  146. this.getQuestionData();
  147. },
  148. onPullDownRefresh() {
  149. this.resetAudio()
  150. this.refreshPage()
  151. setTimeout(() => {
  152. uni.stopPullDownRefresh()
  153. }, 1500);
  154. },
  155. methods: {
  156. toDetail(item) {
  157. // 未回答的不进行操作
  158. if(this.questionStatus == 2) return
  159. //reply_status:1-待分配 2-待回答 3-已回答
  160. if (this.isUserResearcher && item.reply_status === 2 && item.replier_user_id == this.userInfo.user_id) {
  161. // 是研究员 && 问题是待回答 && 回答者是我
  162. uni.navigateTo({ url: "/pages-question/answerDetail?id=" + item.id });
  163. }
  164. },
  165. //点击bar
  166. changeBar({ key }) {
  167. if (key === this.selectKey) return;
  168. this.selectKey = key;
  169. this.questionList = [];
  170. this.page = 1;
  171. this.resetAudio();
  172. this.getQuestionData();
  173. },
  174. getSelectKey() {
  175. if(this.userInfo.is_inner === 1){
  176. this.selectKey = 'Wait'
  177. }else{
  178. this.selectKey = 'Replied'
  179. }
  180. },
  181. async getBarList() {
  182. const res = await apiBarTotal();
  183. if (res.code !== 200) return;
  184. const { replied, wait, total,distribute } = res.data;
  185. //客户: 已回答 未回答 全部
  186. const customBar = [
  187. {
  188. label: "已回答",
  189. key: "Replied",
  190. num: replied,
  191. },
  192. {
  193. label: "未回答",
  194. key: "Wait",
  195. num: wait,
  196. },
  197. {
  198. label: "全部",
  199. key: "Total",
  200. num: total,
  201. },
  202. ];
  203. //研究员: 待回答 未回答 已回答 全部
  204. const researBar = [
  205. {
  206. label: "待回答",
  207. key: "Distribute",
  208. num: distribute,
  209. },
  210. {
  211. label:'未回答',
  212. key:'Wait',
  213. num:wait,
  214. },
  215. {
  216. label: "已回答",
  217. key: "Replied",
  218. num: replied,
  219. },
  220. {
  221. label: "全部",
  222. key: "Total",
  223. num: total,
  224. },
  225. ];
  226. this.barList = this.isUserResearcher ? researBar : customBar;
  227. },
  228. async getQuestionData() {
  229. const reply_status = { Wait: 2, Replied: 3, Total: 0 ,Distribute:4};
  230. this.questionStatus = reply_status[this.selectKey]
  231. await this.getQuestionList(reply_status[this.selectKey],1);
  232. this.setQuestionsRead()
  233. },
  234. async setQuestionsRead(){
  235. //获取未读的数据,请求未读接口变为已读
  236. let unReadArr = []
  237. this.questionList.forEach(item=>{
  238. /* let isReadKey = this.isUserResearcher?'replier_is_read':'is_read' */
  239. let isReadKey = item.user_id===this.userInfo.user_id?'replier_is_read':'is_read'
  240. if(item[isReadKey]===0){
  241. unReadArr.push(item.community_question_id)
  242. }
  243. })
  244. if(unReadArr.length===0) return
  245. await apiSetRead({
  246. question_ids:unReadArr.join(',')
  247. })
  248. },
  249. refreshPage() {
  250. this.page = 1
  251. this.selectId = -1
  252. this.questionList = []
  253. this.finished = false
  254. this.getQuestionData()
  255. },
  256. },
  257. };
  258. </script>
  259. <style lang="scss" scoped>
  260. .answer-page {
  261. padding: 30rpx;
  262. .answer-bar {
  263. display: flex;
  264. /* justify-content: space-between; */
  265. overflow-x: scroll;
  266. &::-webkit-scrollbar{
  267. width: 0;
  268. display: none;
  269. }
  270. .bar-item {
  271. width: 206rpx;
  272. min-width: 206rpx;
  273. color: #666666;
  274. background-color: #f5f5f5;
  275. height: 70rpx;
  276. line-height: 70rpx;
  277. text-align: center;
  278. margin-right: 20rpx;
  279. &.active {
  280. background-color: #fdf8f2;
  281. color: #e3b377;
  282. }
  283. }
  284. }
  285. .answer-list {
  286. margin-top: 20rpx;
  287. }
  288. .global-pup {
  289. .content {
  290. padding: 90rpx 34rpx;
  291. flex-direction: column;
  292. .contact {
  293. text {
  294. margin-left: 15rpx;
  295. color: #e6b77d;
  296. }
  297. }
  298. .apply {
  299. margin-top: 40rpx;
  300. width: 390rpx;
  301. height: 80rpx;
  302. background-color: #e6b77d;
  303. color: #ffffff;
  304. text-align: center;
  305. line-height: 80rpx;
  306. border-radius: 40rpx;
  307. }
  308. }
  309. }
  310. }
  311. </style>