answerDetail.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  1. <template>
  2. <view class="answerdetail-page flex-column">
  3. <template v-if="questionItem&&hasAuth">
  4. <view class="question-wrap">
  5. <view class="question-item">
  6. <view class="question-info">
  7. <view style="flex: 1" class="question-title">
  8. <text class="item-label">{{
  9. questionItem.research_group_second_name
  10. }}</text>
  11. {{ questionItem.question_content }}
  12. </view>
  13. <view class="item-answer" v-if="questionItem.reply_status === 3&&!isUserResearcher">
  14. <view class="answer" @click.stop="handleAudio(questionItem)">
  15. <template v-if="!questionItem.loading">
  16. <image
  17. class="music-img"
  18. :src="questionItem.answer.isplay ? playImgSrc : pauseImgSrc"
  19. mode="widthFix"
  20. />
  21. <template
  22. v-if="
  23. questionItem.answer.isplay || questionItem.answer.ispause
  24. "
  25. >
  26. <text>{{
  27. questionItem.answer.audioTime -
  28. currentAudioMsg.audioCurrentTime >
  29. 0
  30. ? moment(
  31. (questionItem.answer.audioTime -
  32. currentAudioMsg.audioCurrentTime) *
  33. 1000
  34. ).format("mm:ss")
  35. : "00:00"
  36. }}</text>
  37. </template>
  38. <template v-else>
  39. <text>{{
  40. moment(questionItem.answer.audioTime * 1000).format(
  41. "mm:ss"
  42. )
  43. }}</text>
  44. </template>
  45. </template>
  46. <template v-else>
  47. <image
  48. class="load-img"
  49. src="../static/loading.png"
  50. mode="aspectFill"
  51. />
  52. <text>{{
  53. moment(questionItem.answer.audioTime).format("mm:ss")
  54. }}</text>
  55. </template>
  56. </view>
  57. </view>
  58. </view>
  59. <text class="item-time">提问时间:{{ questionItem.create_time }}</text>
  60. </view>
  61. </view>
  62. <view
  63. class="record-wrap flex-column"
  64. v-if="questionItem.reply_status === 2&&isUserResearcher"
  65. >
  66. <view class="record flex-column" v-if="questionItem.recordStatus !== 4">
  67. <view class="no-record" v-if="questionItem.recordStatus === 1">
  68. <image
  69. src="./static/record.png"
  70. mode="widthFix"
  71. style="width: 90rpx; height: 180rpx"
  72. />
  73. <view>无录音(录音时长超过三分钟自动结束)</view>
  74. </view>
  75. <!-- <view class="record-time" v-else>{{ audioTime }}</view> -->
  76. <view class="recode-image" v-else>
  77. <scroll-view scroll-x style="height: 100rpx" class="scroll-view" :scroll-left="scrollTop" @scrolltolower="handleScrolltolower" :show-scrollbar="false">
  78. <view style="width:100%;height:100rpx;display:inline-block;"></view>
  79. <image
  80. src="./static/record-img.png"
  81. mode="scaleToFill"
  82. />
  83. <image
  84. src="./static/record-img.png"
  85. mode="scaleToFill"
  86. />
  87. <image
  88. src="./static/record-img.png"
  89. mode="scaleToFill"
  90. />
  91. </scroll-view>
  92. </view>
  93. </view>
  94. <view
  95. class="record-tool flex-column"
  96. v-if="questionItem.recordStatus !== 4"
  97. >
  98. <view class="hint" v-if="questionItem.recordStatus === 1"
  99. >点击开始录音</view
  100. >
  101. <view class="record-time" v-else>{{ audioTime }}</view>
  102. <view
  103. class="record-btn-wrap center"
  104. v-if="questionItem.recordStatus === 1"
  105. >
  106. <view class="switch" @click="changeRecodeStatus"> </view>
  107. </view>
  108. <view class="record-btn-wrap" v-else>
  109. <text
  110. @click="questionItem.recordStatus === 3 && handleRecode('delete')"
  111. v-if="questionItem.recordStatus >= 2"
  112. :class="{ active: questionItem.recordStatus === 3 }"
  113. >删除</text
  114. >
  115. <view class="switch" @click="changeRecodeStatus">
  116. <image
  117. v-if="questionItem.recordStatus >= 2"
  118. :src="
  119. questionItem.recordStatus === 2 ? playImgSrc : pauseImgSrc
  120. "
  121. :key="playIconKey"
  122. :style="{
  123. 'margin-left': questionItem.recordStatus !== 2 ? '7rpx' : 0,
  124. width: '36rpx',
  125. height: '44rpx',
  126. }"
  127. mode="widthFix"
  128. />
  129. </view>
  130. <text
  131. @click="handleRecode('finish')"
  132. v-if="questionItem.recordStatus >= 2"
  133. :class="{ active: questionItem.recordStatus >= 2 }"
  134. >完成</text
  135. >
  136. </view>
  137. </view>
  138. <view class="record-play" v-if="questionItem.recordStatus === 4">
  139. <view class="audio-wrap">
  140. <view v-if="pageLoading">音频生成中...</view>
  141. <view class="play" v-else>
  142. <van-icon
  143. :name="isplay ? 'pause' : 'play'"
  144. @click="handleAudioByReplay"
  145. color="#E6B77DFF"
  146. size="64rpx"
  147. style="align-items: flex-start; margin-left: -20rpx"
  148. />
  149. <!-- 进度条 -->
  150. <view class="slider-box">
  151. <slider
  152. :value="currentAudioMsg.audioCurrentTime"
  153. :max="currentAudioMsg.audioTime"
  154. @change="sliderChange($event)"
  155. @changing="sliderChanging"
  156. activeColor="#E6B77DFF"
  157. backgroundColor="#EBEBEBFF"
  158. block-color="#E6B77DFF"
  159. block-size="12"
  160. />
  161. <view class="slider-time">
  162. <text>{{
  163. moment(currentAudioMsg.audioCurrentTime * 1000).format(
  164. "mm:ss.SS"
  165. )
  166. }}</text>
  167. <text>{{
  168. moment(currentAudioMsg.audioTime * 1000).format("mm:ss.SS")
  169. }}</text>
  170. </view>
  171. </view>
  172. </view>
  173. </view>
  174. <view class="audio-delete" @click="handleRecode('delete')">
  175. <image
  176. src="./static/delerecord.png"
  177. mode="heightFix"
  178. style="width: 32rpx; height: 35rpx"
  179. />
  180. <text>删除</text></view
  181. >
  182. <view class="audio-pub" @click="handleRecode('pub')">发布</view>
  183. </view>
  184. </view>
  185. <view class="record-wrap flex-column" v-if="questionItem.reply_status===3&&isUserResearcher">
  186. <view class="record-play" v-if="questionItem.recordStatus === 4">
  187. <view class="audio-wrap">
  188. <view class="play">
  189. <van-icon
  190. :name="isplay ? 'pause' : 'play'"
  191. @click="handleAudioByReplay"
  192. color="#E6B77DFF"
  193. size="64rpx"
  194. style="align-items: flex-start; margin-left: -20rpx"
  195. />
  196. <!-- 进度条 -->
  197. <view class="slider-box">
  198. <slider
  199. :value="currentAudioMsg.audioCurrentTime"
  200. :max="currentAudioMsg.audioTime"
  201. @change="sliderChange($event)"
  202. @changing="sliderChanging"
  203. activeColor="#E6B77DFF"
  204. backgroundColor="#EBEBEBFF"
  205. block-color="#E6B77DFF"
  206. block-size="12"
  207. />
  208. <view class="slider-time">
  209. <text>{{
  210. moment(currentAudioMsg.audioCurrentTime * 1000).format(
  211. "mm:ss"
  212. )
  213. }}</text>
  214. <text>{{
  215. moment(questionItem.answer.audioTime * 1000).format(
  216. "mm:ss"
  217. )
  218. }}</text>
  219. </view>
  220. </view>
  221. </view>
  222. </view>
  223. <view class="audio-pub disable">已发布</view>
  224. </view>
  225. </view>
  226. </template>
  227. <!-- 没有该问题权限 -->
  228. <template v-else-if="!hasAuth">
  229. <view class="noAuth-wrap">
  230. <image class="img" :src="globalImgUrls.activityNoAuth" mode="widthFix"></image>
  231. <view class="auth-text">您暂无权限查看问答社区</view>
  232. <view class="auth-text" v-if="noAuthInfo.type==='contact'">若想查看可以联系对口销售</view>
  233. <view class="auth-text" v-else>若想查看可以申请开通</view>
  234. <view class="auth-text" v-if="noAuthInfo.type==='contact'">
  235. {{noAuthInfo.name||''}}:<text @click="handleCallPhone(noAuthInfo.mobile+'')">{{noAuthInfo.mobile||''}}</text>
  236. </view>
  237. <view class="apply" @click="handleGoApply" v-else>立即申请</view>
  238. </view>
  239. </template>
  240. </view>
  241. </template>
  242. <script>
  243. import mixin from "../mixin/questionMixin";
  244. import { apiReplayAsk, apiGetQuestion, apiSetRead,apiCountAudioClick } from "@/api/question";
  245. import { apiApplyPermission} from '@/api/user';
  246. import { uploadAudioToServer } from "@/utils/upload";
  247. export default {
  248. mixins: [mixin],
  249. data() {
  250. return {
  251. questionItem: null /* {
  252. recordStatus: 1, //1:未录音;2:正在录音;3:已暂停;4:完成录音
  253. permission_info:{
  254. type:'',
  255. name:'梁娜',
  256. mobile:'123456',
  257. customer_info:{
  258. has_apply:false,
  259. company_name:'',
  260. name:'',
  261. status:'流失',
  262. }
  263. }
  264. }, */,
  265. pauseImgSrc: "../static/question/recordplay.png",
  266. playImgSrc: "../static/question/recordpause.png",
  267. innerAudio: null, //该页面的音频
  268. audioCount: 0, //录音计时,毫秒
  269. audioSrc:'',//tempSrc
  270. audioTime: "00:00", //录音时间(格式化后):string
  271. timer: null,
  272. audioItem: null,
  273. pageLoading: false,
  274. playIconKey: 0,
  275. isplay: false,
  276. isSlider: false,
  277. scrollTop:0,
  278. isStart:false,//判断录音是否开始
  279. //globalRecorder:uni.getRecorderManager(),
  280. /* userInfo:{
  281. is_inner:1,//0:外部客户;1内部员工
  282. status:'正式',
  283. is_suspend:1,
  284. is_researcher:0,
  285. }, *///mock用户信息
  286. };
  287. },
  288. onLoad(options) {
  289. this.initAudio();
  290. this.getQuestionItem(options.id);
  291. },
  292. onShow(){
  293. uni.authorize({
  294. scope: 'scope.record',
  295. success() {
  296. },
  297. fail(e){
  298. console.log('fail',e);
  299. }
  300. })
  301. },
  302. onUnload() {
  303. this.resetAudio();
  304. this.destroyAudio();
  305. //录音时误操作退出页面的情况
  306. if(this.questionItem.recordStatus!==4&&this.questionItem.recordStatus!==1){
  307. this.globalRecorder.stop()
  308. }
  309. },
  310. methods: {
  311. //初始化audio,onShow执行
  312. initAudio() {
  313. this.innerAudio = uni.createInnerAudioContext();
  314. this.handleAudioFun();
  315. this.handleRecorderFun();
  316. //录音完成后,切出其他页面再切回来
  317. if(this.questionItem?.recordStatus===4){
  318. console.log('count',this.audioCount,'src',this.audioSrc)
  319. this.setAudio(this.audioSrc,this.audioCount)
  320. }
  321. },
  322. //录音完成or从其他app切回本页面时,初始化音频
  323. setAudio(src,audioCount){
  324. this.innerAudio.stop();
  325. this.isplay = false;
  326. this.innerAudio.src = src;
  327. console.log('秒数',audioCount)
  328. this.changeCurrentAudio({
  329. id: "",
  330. answer: {
  331. source: src,
  332. audioTime: audioCount/1000,
  333. },
  334. });
  335. },
  336. //麦克风被占用,初始化录音相关变量 其他状态->未录音状态
  337. setRecorder(){
  338. this.questionItem.recordStatus = 1;
  339. this.innerAudio.stop();
  340. this.isplay = false;
  341. this.audioItem = null;
  342. this.audioCount = 0;
  343. this.scrollTop = 0;
  344. this.audioTime = this.moment(this.audioCount * 1000).format("mm:ss");
  345. },
  346. //onHide触发
  347. resetAudio(){
  348. this.innerAudio.stop();
  349. this.isplay = false;
  350. this.changeCurrentAudio({
  351. id: '',
  352. answer: {
  353. source: '',
  354. audioTime: 0
  355. }
  356. })
  357. },
  358. //audio事件
  359. handleAudioFun() {
  360. this.innerAudio.onPlay(() => {
  361. this.isplay = true;
  362. console.log("播放录音了");
  363. this.questionItem.loading = false;
  364. });
  365. this.innerAudio.onTimeUpdate(() => {
  366. //console.log("时间更新", this.innerAudio.currentTime);
  367. /* this.currentAudioMsg.audioCurrentTime = parseInt(
  368. this.innerAudio.currentTime
  369. ); */
  370. this.currentAudioMsg.audioCurrentTime = this.innerAudio.currentTime;
  371. });
  372. this.innerAudio.onSeeked(() => {
  373. //取this.innerAudio.currentTime为0
  374. console.log("seek完成");
  375. this.isSlider = false;
  376. });
  377. this.innerAudio.onPause(() => {
  378. this.isplay = false;
  379. console.log("暂停");
  380. console.log(this.innerAudio.paused);
  381. });
  382. this.innerAudio.onEnded(() => {
  383. console.log("音频播放完毕");
  384. this.questionItem.answer.isplay = false;
  385. this.questionItem.answer.ispause = false;
  386. /* this.changeCurrentAudio({
  387. id: "",
  388. answer: {
  389. source: "",
  390. audioTime: 0,
  391. },
  392. }); */
  393. this.currentAudioMsg.audioCurrentTime = 0;
  394. this.isplay = false;
  395. });
  396. },
  397. //录音事件
  398. handleRecorderFun() {
  399. this.globalRecorder.onStart(() => {
  400. console.log("开始录音");
  401. if(this.questionItem.recordStatus===1){
  402. this.questionItem.recordStatus=2
  403. }
  404. uni.hideToast();
  405. this.clockTime();
  406. });
  407. this.globalRecorder.onPause(() => {
  408. console.log("暂停录音");
  409. if(this.questionItem.recordStatus===2){
  410. this.questionItem.recordStatus = 3
  411. }
  412. this.cleanTime();
  413. });
  414. this.globalRecorder.onStop((res) => {
  415. console.log("录音完成");
  416. //录音自动结束 和 暂停时点击删除 的情况
  417. if (this.questionItem.recordStatus === 2) {
  418. this.questionItem.recordStatus = 4;
  419. }
  420. console.log('status',this.questionItem.recordStatus)
  421. console.log("res", JSON.stringify(res));
  422. this.cleanTime();
  423. //初始化音频播放
  424. this.audioSrc = res.tempFilePath
  425. this.setAudio(this.audioSrc ,this.audioCount)
  426. this.pageLoading = false;
  427. });
  428. this.globalRecorder.onError((res) => {
  429. console.log('err',res)
  430. console.log('errMsg',res.errMsg)
  431. /* uni.showToast({
  432. title:res.errMsg,
  433. icon:'none'
  434. }) */
  435. //开始录音失败
  436. if(res.errMsg.includes('start')){
  437. this.questionItem.recordStatus = 1;
  438. }
  439. //麦克风被占用的情况
  440. if(res.errCode===1){
  441. uni.showToast({
  442. title:'麦克风被占用,已停止录音',
  443. icon:'none'
  444. })
  445. this.globalRecorder.stop();
  446. this.setRecorder()
  447. }
  448. });
  449. /* this.globalRecorder.onFrameRecorded((res) => {
  450. console.log("?", res);
  451. }); */
  452. },
  453. async getQuestionItem(id) {
  454. const res = await apiGetQuestion({
  455. question_id: id,
  456. });
  457. if (res.code === 200) {
  458. this.questionItem = res.data;
  459. const { audio_list } = res.data;
  460. let temp = {};
  461. if (audio_list.length > 0) {
  462. temp = {
  463. source: res.data.audio_list[0].audio_url,
  464. audioTime: parseInt(res.data.audio_list[0].audio_play_seconds)||0,
  465. isplay: false,
  466. ispause: false,
  467. };
  468. } else {
  469. temp = {
  470. source: "",
  471. audioTime: 0,
  472. isplay: false,
  473. ispause: false,
  474. };
  475. }
  476. let readKey = "";
  477. //const { is_inner } = this.userInfo;
  478. if (this.isUserResearcher) {
  479. readKey = "replier_is_read";
  480. } else {
  481. readKey = "is_read";
  482. }
  483. console.log('readKey',readKey)
  484. this.questionItem[readKey] !== 1 &&
  485. (await apiSetRead({
  486. question_ids: this.questionItem.community_question_id + "",
  487. }));
  488. this.questionItem.id = res.data.community_question_id;
  489. this.questionItem.answer = temp;
  490. this.questionItem.loading = false;
  491. this.questionItem.recordStatus = res.data.reply_status === 3 ? 4 : 1;
  492. //研究员查看已回复的问题,初始化音频
  493. if(res.data.reply_status===3&&this.isUserResearcher){
  494. this.innerAudio.src = res.data.audio_list[0].audio_url
  495. this.audioSrc = res.data.audio_list[0].audio_url
  496. this.audioCount = parseInt(res.data.audio_list[0].audio_play_seconds)*1000
  497. this.changeCurrentAudio({
  498. id: "",
  499. answer: {
  500. source: res.data.audio_list[0].audio_url,
  501. audioTime: parseInt(res.data.audio_list[0].audio_play_seconds)||0,
  502. },
  503. });
  504. }
  505. }else if(res.code===403){
  506. this.hasAuth=false
  507. this.noAuthInfo = res.data
  508. }else{
  509. //问题被删除的情况,返回小程序首页
  510. setTimeout(()=>{
  511. uni.switchTab({ url:'/pages/report/report' });
  512. },1000)
  513. }
  514. },
  515. changeRecodeStatus() {
  516. console.log('a',this.questionItem.recordStatus)
  517. //根据questionItem.recordStatus
  518. if (this.questionItem.recordStatus === 1) {
  519. const that = this
  520. //检查是否有权限
  521. uni.getSetting({
  522. success(res){
  523. console.log('res',res)
  524. if(res.authSetting['scope.record']){
  525. that.startRecord()
  526. }else{
  527. that.getRecordAuth()
  528. }
  529. }
  530. });
  531. } else if (this.questionItem.recordStatus === 2) {
  532. //暂停录音
  533. this.globalRecorder.pause();
  534. this.questionItem.recordStatus = 3;
  535. } else if (this.questionItem.recordStatus === 3) {
  536. //继续录音
  537. this.globalRecorder.resume();
  538. this.clockTime();
  539. this.questionItem.recordStatus = 2;
  540. } else {
  541. //结束录音
  542. this.globalRecorder.stop();
  543. //this.cleanTime();
  544. }
  545. },
  546. //获取录音授权
  547. getRecordAuth(){
  548. const {community_question_id} = this.questionItem
  549. uni.openSetting({
  550. success(res){
  551. //刷新页面
  552. if(res.authSetting['scope.record']){
  553. uni.redirectTo({url: `/pages-question/answerDetail?id=${community_question_id}`})
  554. }
  555. }
  556. })
  557. //this.questionItem.recordStatus = 1
  558. },
  559. //开启录音
  560. startRecord(){
  561. console.log(this.globalRecorder)
  562. this.globalRecorder.start({ duration: 180000, format: "mp3" });
  563. uni.showToast({
  564. title:'加载中',
  565. icon:'loading'
  566. })
  567. this.questionItem.recordStatus = 2;
  568. },
  569. //上传音频
  570. async uploadAudio() {
  571. const res = await uploadAudioToServer(this.innerAudio.src);
  572. if (res.code === 200) {
  573. this.audioItem = res.data;
  574. } else {
  575. //重新录
  576. this.setRecorder()
  577. }
  578. },
  579. //录音操作:完成/删除/发布
  580. async handleRecode(type) {
  581. if (type==='finish') {
  582. this.questionItem.recordStatus = 4;
  583. this.changeRecodeStatus();
  584. }
  585. if (type === "finish") {
  586. //生成音频,更改页面布局
  587. this.pageLoading = true;
  588. } else if (type === "delete") {
  589. //重新录
  590. if(this.questionItem.recordStatus===3)this.globalRecorder.stop();
  591. this.setRecorder()
  592. } else {
  593. //发布
  594. if (!this.audioItem) {
  595. await this.uploadAudio();
  596. }
  597. //如果上传音频成功
  598. if (this.questionItem.recordStatus === 4) {
  599. //发布回答
  600. const res = await apiReplayAsk({
  601. question_id: this.questionItem.community_question_id,
  602. audio_list: [{ ...this.audioItem, sort: 1 }],
  603. });
  604. if (res.code === 200) {
  605. uni.showToast({
  606. title: "发布成功",
  607. icon: "success",
  608. duration: 500,
  609. });
  610. setTimeout(() => {
  611. //关闭当前页面,跳转到我的回答
  612. //uni.navigateBack({ delta: 1 });
  613. uni.redirectTo({
  614. url: '/pages-question/answerList'
  615. })
  616. }, 500);
  617. }
  618. }
  619. }
  620. },
  621. //(提问者)问题已被回答,点击回答音频
  622. handleAudio(item) {
  623. const { source, isplay, ispause } = item.answer;
  624. if (isplay) {
  625. //说明是播放->暂停
  626. this.innerAudio.pause();
  627. this.questionItem.answer.isplay = false;
  628. this.questionItem.answer.ispause = true;
  629. } else if (ispause) {
  630. //说明是暂停->播放
  631. this.innerAudio.play();
  632. this.questionItem.answer.isplay = true;
  633. this.questionItem.answer.ispause = false;
  634. } else {
  635. //console.log("aaa", source, this.innerAudio.src);
  636. //说明是第一次播放或播放完
  637. this.changeCurrentAudio(item);
  638. this.innerAudio.stop();
  639. this.innerAudio.src = source;
  640. this.handleAudioPlay();
  641. this.questionItem.answer.isplay = true;
  642. //音频点击次数+1
  643. const audio_id = this.questionItem.audio_list[0].community_question_audio_id
  644. apiCountAudioClick({
  645. community_question_audio_id:audio_id,
  646. source_agent:1
  647. }).then((res)=>{
  648. if(res.code===200){
  649. console.log('音频id为'+audio_id+'点击次数+1')
  650. }
  651. })
  652. }
  653. },
  654. //(回答者)问题被回答,点击回答音频
  655. handleAudioByReplay() {
  656. this.isplay = !this.isplay;
  657. if (this.innerAudio.paused) {
  658. this.innerAudio.play();
  659. } else {
  660. this.innerAudio.pause();
  661. }
  662. this.playIconKey++; //更新音频播放图标
  663. },
  664. //拖动音频进度条
  665. sliderChange(e) {
  666. console.log("拖动完成?");
  667. //this.innerAudio.pause();
  668. const value = e.detail.value;
  669. this.innerAudio.seek(value);
  670. this.currentAudioMsg.audioCurrentTime = value;
  671. },
  672. sliderChanging() {
  673. this.isSlider = true;
  674. },
  675. //切换当前播放音频
  676. changeCurrentAudio(item) {
  677. const { id } = item;
  678. const { source, audioTime } = item.answer;
  679. this.currentAudioMsg = {
  680. id: id,
  681. audioCurrentTime: 0 * 1000,
  682. audioTime: audioTime,
  683. audioCurrentUrl: source,
  684. };
  685. if (id) {
  686. this.questionItem.loading = true;
  687. }
  688. },
  689. //录音计时
  690. clockTime() {
  691. console.log("开始录音计时");
  692. this.timer = setInterval(() => {
  693. if (this.timer) {
  694. this.audioCount += 30;
  695. this.audioTime = this.moment(this.audioCount).format("mm:ss.SS");
  696. this.scrollTop+=1;
  697. }
  698. }, 30);
  699. },
  700. //清除录音计时
  701. cleanTime() {
  702. console.log("结束录音计时");
  703. clearTimeout(this.timer);
  704. this.playIconKey++; //更新录音暂停播放图标
  705. //this.audioTime = this.moment(this.audioCount).format("mm:ss.SS");
  706. },
  707. //scroll-view滑动到最右
  708. handleScrolltolower(){
  709. console.log('a',this.scrollTop)
  710. this.scrollTop-=150;
  711. },
  712. //权限相关
  713. handleContact(mobile){
  714. uni.makePhoneCall({
  715. phoneNumber: mobile+''
  716. });
  717. },
  718. async handleGoApply(){
  719. const {customer_info} = this.questionItem.permission_info
  720. const {community_question_id} = this.questionItem
  721. if (customer_info.has_apply) { //已经申请过
  722. uni.showToast({
  723. title:'您已提交过申请,请耐心等待',
  724. icon:'none'
  725. })
  726. } else {
  727. if (!customer_info.status || customer_info.status != '流失') {
  728. uni.navigateTo({
  729. url: "/pages-applyPermission/applyPermission?source=5&form_page=问答社区"
  730. })
  731. } else { //主动调一次申请权限接口
  732. const res = await apiApplyPermission({
  733. company_name: customer_info.company_name,
  734. real_name: customer_info.name,
  735. source: 5,
  736. from_page: '问答社区'
  737. })
  738. if (res.code === 200) {
  739. uni.showToast({
  740. title:'您已提交过申请,请耐心等待',
  741. icon:'none'
  742. })
  743. uni.redirectTo({url: `/pages-question/answerDetail?id=${community_question_id}`})
  744. }
  745. }
  746. }
  747. },
  748. //转发分享
  749. onShareAppMessage(){
  750. const {community_question_id} = this.questionItem
  751. return{
  752. title:'问答详情',
  753. path:`/pages-question/answerDetail?id=${community_question_id}`
  754. }
  755. }
  756. },
  757. };
  758. </script>
  759. <style scoped lang="scss">
  760. .flex-column {
  761. display: flex;
  762. flex-direction: column;
  763. }
  764. .answerdetail-page {
  765. padding: 50rpx 30rpx 0 30rpx;
  766. height: calc(100vh - calc(50px + env(safe-area-inset-bottom)));
  767. box-sizing: border-box;
  768. .question-wrap {
  769. .question-item::after {
  770. height: 0;
  771. }
  772. }
  773. .record-wrap {
  774. margin: 0 -30rpx;
  775. flex: 1;
  776. .record {
  777. flex: 1;
  778. justify-content: center;
  779. align-items: center;
  780. .no-record {
  781. text-align: center;
  782. color: #999999ff;
  783. font-size: 28rpx;
  784. height:130rpx;
  785. image {
  786. width: 94rpx;
  787. }
  788. }
  789. /* .record-time {
  790. justify-self: flex-end;
  791. font-size: 60rpx;
  792. } */
  793. .recode-image {
  794. width: 100%;
  795. height: 100%;
  796. background-color: #fafafaff;
  797. display: flex;
  798. align-items: center;
  799. .scroll-view {
  800. width: 100%;
  801. white-space: nowrap;
  802. ::-webkit-scrollbar{
  803. width:0;
  804. height:0;
  805. display:none;
  806. color:transparent;
  807. }
  808. image {
  809. width: 421rpx;
  810. height: 100rpx;
  811. margin-right: 6rpx;
  812. }
  813. }
  814. }
  815. }
  816. .record-tool {
  817. justify-content: center;
  818. align-items: center;
  819. border-top: 1rpx solid #e6e6e6ff;
  820. height: 400rpx;
  821. position: relative;
  822. .hint {
  823. color: #ee3636ff;
  824. font-size: 28rpx;
  825. position: absolute;
  826. top: 50rpx;
  827. }
  828. .record-time{
  829. font-size: 60rpx;
  830. }
  831. .record-btn-wrap {
  832. margin-top: 38rpx;
  833. display: flex;
  834. width: 100%;
  835. justify-content: space-around;
  836. align-items: center;
  837. &.center {
  838. justify-content: center;
  839. }
  840. text {
  841. color: #999999ff;
  842. font-size: 32rpx;
  843. &.active {
  844. color: #ee3636ff;
  845. }
  846. }
  847. .switch {
  848. width: 118rpx;
  849. height: 118rpx;
  850. padding: 12rpx;
  851. box-sizing: border-box;
  852. border-radius: 50%;
  853. border: 1rpx solid #ee3636ff;
  854. /* background-color: rgb(68, 46, 46); */
  855. position: relative;
  856. display: flex;
  857. align-items: center;
  858. justify-content: center;
  859. image {
  860. position: absolute;
  861. width: 36rpx;
  862. z-index: 5;
  863. }
  864. &::after {
  865. content: "";
  866. display: inline-block;
  867. width: 100%;
  868. height: 100%;
  869. border-radius: 50%;
  870. background-color: #ee3636ff;
  871. }
  872. }
  873. }
  874. }
  875. .record-play {
  876. margin: 20rpx 30rpx;
  877. .audio-wrap {
  878. background-color: #fdf8f2ff;
  879. padding: 30rpx;
  880. border-radius: 16rpx;
  881. }
  882. .play {
  883. display: flex;
  884. justify-content: space-between;
  885. .slider-box {
  886. margin-left: 15rpx;
  887. flex: 1;
  888. slider {
  889. margin: 15rpx 0 0 0;
  890. }
  891. .slider-time {
  892. display: flex;
  893. justify-content: space-between;
  894. text {
  895. color: #999999ff;
  896. font-size: 22rpx;
  897. }
  898. }
  899. }
  900. }
  901. .audio-delete {
  902. margin-top: 20rpx;
  903. width: 100%;
  904. height: 40rpx;
  905. display: flex;
  906. justify-content: flex-end;
  907. align-items: center;
  908. image {
  909. height: 40rpx;
  910. }
  911. text {
  912. margin-left: 10rpx;
  913. color: #999999ff;
  914. font-size: 28rpx;
  915. }
  916. }
  917. .audio-pub {
  918. margin-top: 120rpx;
  919. background-color: #e6b77dff;
  920. color: #fff;
  921. height: 80rpx;
  922. line-height: 80rpx;
  923. border-radius: 40rpx;
  924. text-align: center;
  925. position: relative;
  926. width: 390rpx;
  927. left: 50%;
  928. margin-left: -170rpx;
  929. &.disable{
  930. background-color:#999999ff;
  931. color: #fff;
  932. }
  933. }
  934. }
  935. }
  936. }
  937. </style>