123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- import {
- apiQuestionList
- } from '@/api/question'
- import { apiApplyPermission, apiUserInfo } from '@/api/user'
- import {apiCountAudioClick} from '@/api/question'
- const moment = require('@/utils/moment-with-locales.min')
- moment.locale('zh-cn');
- export default {
- data() {
- return {
- moment: moment,
- innerAudio: null,
- currentAudioMsg: {
- id: '',
- audioCurrentTime: 0,
- audioTime: 0,
- audioCurrentUrl: '',
- },
- pupData: {
- show: false,
- content: '',
- type: '',
- mobile: "",
- customer_info: {}
- },
- page: 1,
- pageSize: 20,
- finished: false,
- selectId: -1,
- noAuth:['潜在','流失','冻结'],
- hasAuth:true,
- noAuthInfo:null,
- }
- },
- computed:{
- userAuth(){
-
- if(this.userInfo.status==='试用'&&this.userInfo.is_suspend===1){
- return false
- }
-
- if(this.noAuth.includes(this.userInfo.status)){
- return false
- }
-
- return true
- },
- isUserResearcher(){
-
- if(this.userInfo.is_inner===1&&this.userInfo.is_researcher===1){
- return true
- }
- return false
- }
- },
- onLoad() {
-
- },
- onShow(){
- this.initAudio()
- },
- onHide(){
- this.resetAudio()
- this.destroyAudio()
- },
- onUnload() {
-
- },
- methods: {
-
- initAudio() {
- this.innerAudio = uni.createInnerAudioContext()
- this.handleAudioFun()
- },
-
- destroyAudio() {
- if (this.innerAudio) {
- this.innerAudio.destroy()
- }
- },
-
- resetAudio(){
- this.innerAudio.pause();
- this.questionList.map((i) => {
- if(i.id===this.currentAudioMsg.id){
- i.answer.isplay = false
- i.answer.ispause = false
- }
- })
- this.changeCurrentAudio({
- id: '',
- answer: {
- source: '',
- audioTime: 0
- }
- })
- },
-
- handleAudioFun() {
- this.innerAudio.onPlay(() => {
- console.log('开始了')
- this.questionList.map(i => {
- if (i.id === this.currentAudioMsg.id) {
- i.loading = false
- }
- })
- })
- this.innerAudio.onTimeUpdate(() => {
-
- this.currentAudioMsg.audioCurrentTime = this.innerAudio.currentTime * 1000
- })
- this.innerAudio.onPause(() => {
- console.log("暂停");
- })
- this.innerAudio.onEnded(() => {
- console.log('音频播放完毕')
- const {
- id
- } = this.currentAudioMsg
- this.questionList.map(i => {
- if (i.id === id) {
- i.answer.isplay = false
- i.answer.ispause = false
- }
- })
- this.changeCurrentAudio({
- id: '',
- answer: {
- source: '',
- audioTime: 0
- }
- })
- })
- },
-
- handleAudioPlay() {
- this.innerAudio.onCanplay(() => {
- this.innerAudio.play()
- })
- },
-
- changeCurrentAudio(item) {
- const {
- id
- } = item
- const {
- source,
- audioTime
- } = item.answer
- this.currentAudioMsg = {
- id: id,
- audioCurrentTime: 0 * 1000,
- audioTime: audioTime,
- audioCurrentUrl: source
- }
- this.questionList.map(i => {
- if (i.id === item.id) {
- i.loading = true
- }
- })
- },
-
- async getQuestionList(status,onlyMine=0) {
- let questionData = []
- const res = await apiQuestionList({
- page_index: this.page,
- page_size: this.pageSize,
-
- group_id: this.selectId === -1 ? '' : this.selectId,
- reply_status: status,
- only_mine:onlyMine
- })
- if (res.code === 200) {
- if (res.data) {
- questionData = res.data
- } else {
- this.finished = true
- }
- }
-
- if(res.code ===403){
- this.hasAuth = false
- this.noAuthInfo = res.data
- }
- let tempArr = []
- questionData.forEach(item => {
- let temp = item
- let audio_url = '',
- audio_play_seconds = 0;
-
- if (item.reply_status === 3) {
- audio_url = item.audio_list[0].audio_url
- audio_play_seconds = item.audio_list[0].audio_play_seconds
- }
-
- temp.answer = {
- source: audio_url,
- audioTime: parseInt(audio_play_seconds) * 1000,
- isplay: false,
- ispause: false
- }
- temp.id = item.community_question_id
- temp.loading = false
- tempArr.push(temp)
- })
- if (this.page > 1) {
- this.questionList = this.questionList.concat(tempArr)
- } else {
- this.questionList = tempArr
- }
- },
-
- handleAudio(item) {
-
-
- const {
- source,
- isplay
- } = item.answer
- if (isplay) {
-
- this.innerAudio.pause()
- } else if (item.id === this.currentAudioMsg.id) {
-
- this.innerAudio.play()
- } else {
-
- if(!source) return
-
- this.changeCurrentAudio(item)
- this.innerAudio.stop()
- this.innerAudio.src = source
-
- this.handleAudioPlay()
-
- const audio_id = item.audio_list[0].community_question_audio_id
- apiCountAudioClick({
- community_question_audio_id:audio_id,
- source_agent:1
- }).then((res)=>{
- if(res.code===200){
- console.log('音频id为'+audio_id+'点击次数+1')
- }
-
- })
- }
- this.questionList.map((i) => {
- if (i.id === item.id) {
- if (i.answer.isplay) {
- i.answer.ispause = true
- }
- i.answer.isplay = !i.answer.isplay
- } else {
- i.answer.isplay = false
- i.answer.ispause = false
- i.loading = false
- }
- })
- },
-
- initPupData(item) {
- let str = '<p>您暂无权限查看语音回复</p>'
- const {
- type,
- mobile,
- name,
- customer_info
- } = item.permission_info
- if (type === 'apply') {
- this.pupData.type = 'apply'
- str += '<p>若想查看可以申请开通</p>'
- }
- if (type === 'contact') {
- this.pupData.mobile = mobile + ''
- this.pupData.saleName = name
- this.pupData.type = 'contact'
- str += `<p>若想查看可以联系对口销售</p>`
- }
- this.pupData.customer_info = customer_info
- this.pupData.content = str
- this.pupData.show = true
- },
-
- handleCallPhone(tel) {
- uni.makePhoneCall({
- phoneNumber: tel ? tel : ' ',
- success: () => {
- this.pupData.show = false
- }
- });
- },
-
- async handleApply() {
- if (this.pupData.customer_info.has_apply) {
- this.pupData.content = `<p>您已提交过申请,请耐心等待</p>`
- this.pupData.type = ''
- } else {
- if (!this.pupData.customer_info.status || this.pupData.customer_info.status != '流失') {
- uni.navigateTo({
- url: "/pages-applyPermission/applyPermission?source=5&form_page=问答社区"
- })
- } else {
- const res = await apiApplyPermission({
- company_name: this.pupData.customer_info.company_name,
- real_name: this.pupData.customer_info.name,
- source: 5,
- from_page: '问答社区'
- })
- if (res.code === 200) {
-
- const pages = getCurrentPages();
- const page = pages[pages.length - 1];
-
- page.onShow();
- }
- this.pupData.content = `<p>申请已提交</p><p>请等待销售人员与您联系</p>`
- this.pupData.type = ''
- }
- }
- },
-
- async handleGoApply(){
- const {customer_info} = this.noAuthInfo
- if (customer_info.has_apply) {
- uni.showToast({
- title:'您已提交过申请,请耐心等待',
- icon:'none'
- })
- } else {
- if (!customer_info.status || customer_info.status != '流失') {
- uni.navigateTo({
- url: "/pages-applyPermission/applyPermission?source=5&form_page=问答社区"
- })
- } else {
- const res = await apiApplyPermission({
- company_name: customer_info.company_name,
- real_name: customer_info.name,
- source: 5,
- from_page: '问答社区'
- })
- if (res.code === 200) {
- uni.showToast({
- title:'您已提交过申请,请耐心等待',
- icon:'none'
- })
- const pages = getCurrentPages();
- const page = pages[pages.length - 1];
- page.onShow();
- }
- }
- }
- },
- }
- }
|