question.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <template>
  2. <view class="question-wrap">
  3. <template v-if="hasAuth">
  4. <view class="question-top" :class="{'noAuth':!(isUserResearcher||userInfo.status&&userAuth)}">
  5. <view @click="showPopup" v-if="isUserResearcher||userInfo.status&&userAuth"
  6. style="display:flex;align-items: center;margin-left:30rpx;">
  7. <image src="../../static/question/select.png" mode="widthFix" class="menu-icon"/>
  8. <text style="color:#E3B377;font-size:28rpx;">筛选</text>
  9. </view>
  10. <van-popup :show="isPopupShow" position="left" :close-on-click-overlay="true"
  11. @close="isPopupShow = false"
  12. custom-style="height: 100%;width:50%;"
  13. @touchmove.stop.prevent>
  14. <view class="pop-wrap">
  15. <view class="pop-option-list">
  16. <van-collapse :value="activeName" @change="changeSelecOption" accordion :border="false">
  17. <van-collapse-item :border="false" :title="item.research_group_name" :name="index" v-for="(item, index) in optionList"
  18. :key="index">
  19. <view class="option-btn-wrap">
  20. <view class="option-btn"
  21. v-for=" i in item.children" :key="i.research_group_id"
  22. @click="handleOptionClick(i)"
  23. :class="{'active':selectName===i.research_group_name,'full':i.research_group_name.length>4}"
  24. >
  25. {{ i.research_group_name }}
  26. </view>
  27. </view>
  28. </van-collapse-item>
  29. </van-collapse>
  30. </view>
  31. </view>
  32. </van-popup>
  33. </view>
  34. <view class="report-empty-box" v-if="questionList.length==0">
  35. <image :src="globalImgUrls.activityNoAuth" mode="widthFix" style="width:100%;"/>
  36. <view>暂无提问<text v-if="userInfo.is_inner!==1">,快试试提问功能吧</text></view>
  37. </view>
  38. <view class="question-list" :class="showAudioPop?showAudioBigPop?'list-bot3':'list-bot2':'list-bot1'">
  39. <view class="question-item" @click="handleGoDetail(item)" v-for="item in questionList" :key="item.community_question_id">
  40. <view class="question-info">
  41. <view style="flex:1;" class="question-title">
  42. <text class="item-label">{{item.variety_tag_name}}</text>
  43. <!-- <text class="item-title"> -->{{ item.question_content }}<!-- </text> -->
  44. </view>
  45. <view class="item-answer">
  46. <!-- 改为背景音频播放 -->
  47. <view class="answer" @click.stop="handlePlayAudioByBg(item)">
  48. <image class="music-img" :src="item.community_question_id==curVoiceId&&!curAudioPaused?playImgSrc:pauseImgSrc" mode="widthFix"/>
  49. <text>{{ moment(item.answer.audioTime).format('mm:ss') }}</text>
  50. </view>
  51. <!-- <view class="answer" @click.stop="handleAudio(item)">
  52. <template v-if="!item.loading">
  53. <image class="music-img" :src="item.answer.isplay?playImgSrc:pauseImgSrc" mode="widthFix"/>
  54. <template v-if="item.answer.isplay || item.answer.ispause">
  55. <text>{{
  56. item.answer.audioTime - currentAudioMsg.audioCurrentTime>0?
  57. moment(item.answer.audioTime - currentAudioMsg.audioCurrentTime).format('mm:ss')
  58. :'00:00'}}
  59. </text>
  60. </template>
  61. <template v-else>
  62. <text>{{ moment(item.answer.audioTime).format('mm:ss') }}</text>
  63. </template>
  64. </template>
  65. <template v-else>
  66. <image class="load-img" src="../../static/loading.png" mode="aspectFill" />
  67. <text>{{ moment(item.answer.audioTime).format('mm:ss') }}</text>
  68. </template>
  69. </view> -->
  70. </view>
  71. </view>
  72. <text class="item-time">提问时间:{{ item.create_time }}</text>
  73. </view>
  74. </view>
  75. <template v-if="isUserResearcher">
  76. <view class="btn-wrap" :class="showAudioPop?showAudioBigPop?'btn-bot3':'btn-bot2':'btn-bot1'">
  77. <view class="btn topage-button" @click="toPage('question')" v-if="userInfo.status&&userAuth">
  78. <image
  79. src="../../static/question/askquestion.png"
  80. mode="scaleToFill"
  81. style="width:34rpx;height:34rpx;"
  82. />
  83. <text>我要提问</text>
  84. </view>
  85. <view class="btn topage-button" @click="toPage('ask')" v-if="userInfo.status&&userAuth">
  86. <view>待回答<text v-if="isUserResearcher" style="margin-left:5rpx;">{{'('+distributeNum+')'}}</text></view>
  87. </view>
  88. </view>
  89. </template>
  90. <template v-else>
  91. <view class="topage-btn topage-button" @click="toPage('question')" v-if="userInfo.status&&userAuth">
  92. <image
  93. src="../../static/question/askquestion.png"
  94. mode="scaleToFill"
  95. style="width:34rpx;height:34rpx;"
  96. />
  97. <text>我要提问</text>
  98. </view>
  99. </template>
  100. <!-- <view class="topage-btn" @click="toPage" v-if="isUserResearcher||userInfo.status&&userAuth">
  101. <image
  102. v-if="!isUserResearcher"
  103. src="../../static/question/askquestion.png"
  104. mode="scaleToFill"
  105. style="width:34rpx;height:34rpx;"
  106. />
  107. {{ isUserResearcher ? '待回答' : '我要提问' }} <text v-if="isUserResearcher" style="margin-left:5rpx;">{{'('+distributeNum+')'}}</text>
  108. </view> -->
  109. </template>
  110. <!-- 没有权限 -->
  111. <template v-else>
  112. <view class="noAuth-wrap">
  113. <image class="img" :src="globalImgUrls.activityNoAuth" mode="widthFix"></image>
  114. <view class="auth-text">您暂无权限查看问答社区</view>
  115. <view class="auth-text" v-if="noAuthInfo.type==='contact'">若想查看可以联系对口销售</view>
  116. <view class="auth-text" v-else>若想查看可以申请开通</view>
  117. <view class="auth-text" v-if="noAuthInfo.type==='contact'">
  118. {{noAuthInfo.name||''}}:<text @click="handleCallPhone(noAuthInfo.mobile+'')">{{noAuthInfo.mobile||''}}</text>
  119. </view>
  120. <view class="apply" @click="handleGoApply" v-else>立即申请</view>
  121. </view>
  122. </template>
  123. <!-- 弹窗 -->
  124. <van-popup :show="pupData.show" round @close="pupData.show = false" closeable :close-on-click-overlay="false">
  125. <view class="global-pup">
  126. <view class="content">
  127. <rich-text style="flex:none;margin-bottom:20rpx;" :nodes="pupData.content"></rich-text>
  128. <view class="contact" v-if="pupData.type == 'contact'">
  129. {{pupData.saleName||''}}:<text @click="handleCallPhone(pupData.mobile)">{{pupData.mobile||''}}</text>
  130. </view>
  131. <view class="apply" v-else-if="pupData.type == 'apply'">
  132. <view @click="handleApply">立即申请</view>
  133. </view>
  134. </view>
  135. </view>
  136. </van-popup>
  137. <!-- 音频悬浮 -->
  138. <view v-if="showPage">
  139. <audioBox v-if="showAudioPop"/>
  140. </view>
  141. </view>
  142. </template>
  143. <script>
  144. import mixin from "../../mixin/questionMixin";
  145. import {apiOptionGroupList,apiBarTotal,apiCountAudioClick} from '@/api/question'
  146. import {apiGetTagTree} from '@/api/common'
  147. import audioBox from '@/components/audioBox/audioBox.vue'
  148. export default {
  149. mixins: [mixin],
  150. components:{
  151. audioBox
  152. },
  153. data() {
  154. return {
  155. questionList: [],
  156. isPopupShow: false,//弹出层是否展示
  157. optionList: [],
  158. activeNames: [],//collapse
  159. activeName:'',
  160. selectName:'',
  161. pauseImgSrc:'../../static/question/recordplay.png',
  162. playImgSrc:'../../static/question/recordpause.png',
  163. distributeNum:0,
  164. /* userInfo:{
  165. is_inner:1,//0:外部客户;1内部员工
  166. status:'试用',
  167. is_suspend:0,
  168. is_researcher:0,
  169. //seal_name:'梁娜',
  170. //seal_mobile:123456,
  171. },//mock用户信息 */
  172. showPage:false
  173. }
  174. },
  175. watch:{
  176. selectName(){
  177. this.getQuestionList(3)
  178. }
  179. },
  180. computed:{
  181. showAudioPop(){//是否显示音频弹窗
  182. return this.$store.state.audio.show
  183. },
  184. showAudioBigPop(){
  185. return this.$store.state.audio.showBig
  186. },
  187. curVoiceId(){//当前正在播放的音频id
  188. return this.$store.state.audio.questionId
  189. },
  190. curAudioPaused(){//当前音频是否暂停状态
  191. return this.$store.state.audio.paused
  192. },
  193. },
  194. onLoad() {
  195. /* this.getVistor()
  196. this.getOptionList()
  197. this.getQuestionList(3) */
  198. },
  199. onShow() {
  200. this.getdistributeNum()
  201. this.getOptionList()
  202. this.getQuestionList(3)
  203. this.showPage=true
  204. },
  205. onHide(){
  206. this.showPage=false
  207. },
  208. onReachBottom() {
  209. if(this.finished) return
  210. this.page++
  211. this.getQuestionList(3)
  212. },
  213. onPullDownRefresh() {
  214. this.resetAudio()
  215. this.refreshPage()
  216. setTimeout(() => {
  217. uni.stopPullDownRefresh()
  218. }, 1500);
  219. },
  220. //转发分享
  221. onShareAppMessage(){
  222. return{
  223. title:'问答社区',
  224. path:'/pages/question/question'
  225. }
  226. },
  227. methods: {
  228. //获取研究员问答列表数量统计
  229. getdistributeNum() {
  230. if(this.userInfo.is_inner!==1) return
  231. //如果是研究员,则请求问答列表数量统计
  232. apiBarTotal().then(res=>{
  233. if(res.code===200){
  234. this.distributeNum = res.data.distribute
  235. }
  236. })
  237. },
  238. //获取筛选列表
  239. async getOptionList(){
  240. /* const res = await apiOptionGroupList()
  241. if(res.code===200){
  242. this.optionList = res.data
  243. } */
  244. const res = await apiGetTagTree()
  245. if(res.code===200){
  246. const result = res.data
  247. this.optionList = result.map((item)=>{
  248. let obj = {}
  249. obj.research_group_name = item.classify_name
  250. obj.children = item.tags.map((i)=>{
  251. return {research_group_id:i.tag_id,research_group_name:i.tag_name}
  252. })
  253. return obj
  254. })
  255. }
  256. },
  257. //点击筛选
  258. showPopup() {
  259. this.isPopupShow = true
  260. },
  261. //点击一级分类
  262. changeSelecOption(e) {
  263. this.activeName = e.detail
  264. },
  265. //点击二级分类
  266. handleOptionClick(item){
  267. //重复点击代表取消
  268. if(this.selectId===item.research_group_id){
  269. this.selectId=-1
  270. this.selectName=''
  271. }else{
  272. this.selectId = item.research_group_id
  273. this.selectName = item.research_group_name
  274. }
  275. this.page = 1
  276. this.isPopupShow = false
  277. },
  278. //点击'我要提问' or '待回答'
  279. toPage(type) {
  280. if(type==='question'){
  281. uni.navigateTo({ url: '/pages-question/hasQuestion' })
  282. }else{
  283. uni.navigateTo({ url: '/pages-question/answerList' })
  284. }
  285. },
  286. refreshPage() {
  287. this.page = 1
  288. this.selectId = -1
  289. this.questionList = []
  290. this.finished = false
  291. this.getQuestionList(3)
  292. },
  293. //跳转详情
  294. handleGoDetail(item){
  295. uni.navigateTo({ url: `/pages-question/answerDetail?id=${item.community_question_id}` })
  296. }
  297. }
  298. }
  299. </script>
  300. <style lang="scss">
  301. .question-wrap {
  302. .van-popup--bottom{
  303. padding-bottom: 0 !important;
  304. }
  305. /deep/ .van-cell__title,
  306. .van-cell__value {
  307. flex: none !important;
  308. }
  309. .van-collapse-item{
  310. &.van-hairline--top{
  311. &::after{
  312. border: none !important;
  313. }
  314. }
  315. .van-cell{
  316. padding-left:0 !important;
  317. }
  318. }
  319. .van-collapse-item__content{
  320. padding:0;
  321. }
  322. }
  323. page {
  324. padding-bottom: env(safe-area-inset-bottom);
  325. }
  326. </style>
  327. <style lang="scss" scoped>
  328. .question-wrap {
  329. padding: 0 30rpx 80rpx 30rpx;
  330. background-color: #FFFFFF;
  331. .question-top {
  332. display: flex;
  333. flex: auto;
  334. align-items: center;
  335. height: 100rpx;
  336. background-color: white;
  337. position: sticky;
  338. top: 0;
  339. left: 0;
  340. margin:0 -30rpx;
  341. z-index: 99;
  342. &.noAuth{
  343. height:20rpx;
  344. }
  345. /* border-top: 1rpx solid rgba(0, 0, 0, 0.1); */
  346. .text{
  347. width:240rpx;
  348. height:70rpx;
  349. line-height: 70rpx;
  350. background-color: #F5F5F5;
  351. border-radius: 4rpx;
  352. color:#666666;
  353. text-align: center;
  354. &.active{
  355. color:#E3B377;
  356. background-color: #FDF8F2;
  357. }
  358. }
  359. .auth-box {
  360. flex: 1;
  361. }
  362. .menu-icon {
  363. width: 34rpx;
  364. height:34rpx;
  365. }
  366. .pop-wrap{
  367. height: 100%;
  368. padding: 50rpx 34rpx;
  369. .pop-option-list {
  370. .option-btn-wrap {
  371. display: flex;
  372. justify-content: space-between;
  373. flex-wrap: wrap;
  374. margin-bottom: 20rpx;
  375. .option-btn {
  376. min-width: 145rpx;
  377. height:76rpx;
  378. line-height: 76rpx;
  379. text-align: center;
  380. color: black;
  381. background-color: #F6F6F6;
  382. border-radius: 4rpx;
  383. margin-top: 10rpx;
  384. &.active{
  385. background-color: #FAEEDE;
  386. }
  387. &.full{
  388. width:100%;
  389. }
  390. }
  391. }
  392. }
  393. .pop-btn{
  394. height:80rpx;
  395. margin:0 -34rpx;
  396. text-align: center;
  397. line-height: 80rpx;
  398. color:#FFFFFF;
  399. background-color: #E6B77D;
  400. }
  401. }
  402. }
  403. .question-list {
  404. padding-bottom: 34rpx;
  405. &.last{
  406. padding-bottom: 260rpx;
  407. }
  408. }
  409. .list-bot1{
  410. padding-bottom: 200rpx;
  411. }
  412. .list-bot2{
  413. padding-bottom: 340rpx;
  414. }
  415. .list-bot3{
  416. padding-bottom: 440rpx;
  417. }
  418. .topage-btn {
  419. position: fixed;
  420. left:50%;
  421. margin-left: -257rpx;
  422. bottom: 215rpx;
  423. width:514rpx;
  424. }
  425. .topage-button{
  426. height: 80rpx;
  427. text-align: center;
  428. line-height: 80rpx;
  429. border-radius: 40rpx;
  430. background-color: #333333;
  431. box-shadow: 0px 4px 20px 1px rgba(160, 126, 84, 0.25);
  432. color: #E3B377;
  433. display: flex;
  434. justify-content: center;
  435. align-items: center;
  436. image{
  437. margin-right: 10rpx;
  438. margin-top: -2rpx;
  439. }
  440. }
  441. .btn-wrap{
  442. position: fixed;
  443. width:100%;
  444. margin-left: -30rpx;
  445. display: flex;
  446. justify-content: center;
  447. bottom: calc(120rpx + constant(safe-area-inset-bottom));
  448. bottom: calc(120rpx + env(safe-area-inset-bottom));
  449. .btn{
  450. width:300rpx;
  451. height:80rpx;
  452. &:first-child{
  453. margin-right: 30rpx;
  454. }
  455. }
  456. }
  457. .btn-bot1{
  458. bottom: calc(120rpx + constant(safe-area-inset-bottom));
  459. bottom: calc(120rpx + env(safe-area-inset-bottom));
  460. }
  461. .btn-bot2{
  462. bottom: calc(260rpx + constant(safe-area-inset-bottom));
  463. bottom: calc(260rpx + env(safe-area-inset-bottom));
  464. }
  465. .btn-bot3{
  466. bottom: calc(355rpx + constant(safe-area-inset-bottom));
  467. bottom: calc(355rpx + env(safe-area-inset-bottom));
  468. }
  469. .global-pup{
  470. .content{
  471. padding:90rpx 34rpx;
  472. flex-direction: column;
  473. .contact{
  474. text{
  475. margin-left: 15rpx;
  476. color:#E6B77D;
  477. }
  478. }
  479. .apply{
  480. margin-top: 40rpx;
  481. width:390rpx;
  482. height:80rpx;
  483. background-color: #E6B77D;
  484. color: #FFFFFF;
  485. text-align: center;
  486. line-height: 80rpx;
  487. border-radius: 40rpx;
  488. }
  489. }
  490. }
  491. }
  492. </style>