<template>
	<view class="box">
		<view class="headbox">
			<view class="tit-tiem">{{luyinList[csdFileindex].receptionTime}}</view>
			<view class="call_record_time_one">接待时长  {{alltimeStr}}
				<view class="audoioyouxiao"  @click="alllogo()" v-if="Menulistisshow==true">
					{{userlistobj.validInvalidName||''}}
				</view>
				<view class="diangweitupian" v-if="jiaoseshow" >
					<image v-if="essenceis==1" @click="tappick()" style="width: 100%;height: 100%;" src="../../static/images/pike.png" mode=""></image>
					<image v-if="essenceis==0"  @click="notappick()" style="width: 100%;height: 100%;" src="../../static/images/nopike.png" mode=""></image>
				</view>
			</view>
			<view class="pingfenbox" style="margin-top: 10rpx;">
				<view :class="{ activecllasscet: kehuyixiangcenterindex == 0 }" @click="customerofintention(0)">音频识别</view>
				<view :class="{ activecllasscet: kehuyixiangcenterindex == 1 }" @click="customerofintention(1)">执行率{{totalRate||0}}%</view>
			</view>
		</view>
			<scroll-view v-if="kehuyixiangcenterindex==0"  scroll-y="true"  :scroll-into-view="scrollId" :scroll-top="scrollTop"
			 class="zhuti text scroll-Y">
				<!-- 聊天记录-->
				<view class="dialog-block" v-for="(dialog,i) in dialogList" :key="i">
					<view class="text" :id="'dialog'+csdFileindex+'text'+item.bg"
						:class="{active: item.bg < playNow &&  item.ed > playNow &&  i==0}"
						v-for="(item,index) in dialog.message" :key="index" :data-speaker="item.speaker">
						<view class="avatar">
							<text v-if="item.speaker == 1" style="color: #60CBEC;">A</text>
							<text v-if="item.speaker == 2" style="color: #EC8B47;">B</text>
							<text v-if="item.speaker == 3" style="color: #4F861E;">C</text>
							<text v-if="item.speaker == 4" style="color: #9F61C8;">D</text>
							<text v-if="item.speaker == 5" style="color: #4980C8;">E</text>
							<text v-if="item.speaker == 6" style="color: #60CBEC;">F</text>
							<text v-if="item.speaker == 7" style="color: #EC8B47;">G</text>
							<text v-if="item.speaker == 8" style="color: #4F861E;">H</text>
							<text v-if="item.speaker == 9" style="color: #9F61C8;">I</text>
						</view>
						<view class="content">
							<view @longpress="changanxiaoguo(item,index,i)" v-html="item.onebest"></view>
							<view class="tankuangcss" v-if="item.isshow">
								<view @click="clickcopy()"
									style="width: 60rpx;font-size: 24rpx;text-align: center;margin-left: 24rpx;">复制
								</view>
								<view @click="Oftenthewrongword()"
									style="width: 80rpx;font-size: 24rpx;text-align: center;margin-left: 22rpx;">常错词
								</view>
								<view  @click="Addtheessence()" v-if="jiaoseshow"
									style="width: 80rpx;font-size: 24rpx;text-align: center;margin-left: 22rpx;">加精华
								</view>
								<view @click="clickbofang(dialog.backindex,item)"
									style="width: 80rpx;font-size: 24rpx;text-align: center;margin-left: 14rpx;">播放
								</view>
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
			
			<view class="zhuti" v-if="kehuyixiangcenterindex==1">
				<view style="width: 100%;height: 80rpx;border-bottom: 1rpx solid #E0E0E0;display: flex;align-items: center;">
					<view style="flex: 1;font-size: 28rpx;color: #333333;font-weight: 600;text-indent: 20rpx;">指标</view>
					<view style="flex: 1;font-size: 28rpx;color: #333333;font-weight: 600;text-indent: 170rpx;">执行率</view>
				</view>
					<view class="Level-box"   v-for="(item,index) in ratelist" :key="index">
						<view class="Level1che"  @click="changeshow(item,1)">
							<view class="title1">{{item.name.substring(0,8)}}</view>
							<view class="leve1-jindu">
								<view class="jindutiao">
									<view class="huanxing"  :style="{width: item.ratepercent/item.rate*100+'%'}"></view>
									<view class="text">{{((item.ratepercent/item.rate).toFixed(2)*100).toFixed()}}%</view>
								</view>
							</view>
							<view class="jiantobox">
								<image  v-if="!item.show" class="arrow rotatearrow"  src="/static/images/down.png" mode="" />
								<image  v-else class="arrow" src="/static/images/up.png" mode="" />
							</view>
						</view>
						<view class="hhhbox" v-if="item.show"  v-for="(subitem,i) in item.children" :key="i">
							<view class="Level2che" @click="changeshow2(subitem,1)" >
								<view class="title1" >{{subitem.name.substring(0,8)}}</view>
								<view class="leve1-jindu">
									<view class="zhixing"  v-if="!subitem.selected">已执行</view>
									<view class="zhixing2" v-else>未执行</view>
								</view>
								<view class="jiantobox">
									<image   v-if="!subitem.show" class="arrow rotatearrow"  src="/static/images/down.png" mode="" />
									<image  v-else class="arrow" src="/static/images/up.png" mode="" />
								</view>
							</view>
							<view class="hsnrtest" v-if="subitem.show">话术内容</view>
							<view  class="Level3che" @tap="clickaudeopal(che)"  v-if="subitem.show" v-for="(che,inc) in subitem.children" :key='inc'>
								<view class="title1" >{{inc+1}}.{{che.name}}</view>
								<view class="jiantobox">
									<image v-if="che.selected==0" class="arrow" src="/static/images/rate-checked.png" mode="" />
								</view>
							</view>
							<view v-if="subitem.show" style="width: 100%;height: 30rpx;"></view>
						</view>
					</view>
			</view>
		<view class="bottombox">
			<!-- 播放块 -->
			<view class="audio">
				<view class="audio-wrapper">
					<view class="audio-number">{{format(current)}}</view>
					<slider class="audio-slider"   @change="seek($event.detail.value)"
					 activeColor="#E0E0E0" step="1" block-size="16" :value="current" :max="duration"></slider>
					<view class="audio-number">{{format(duration)}}</view>
				</view>
				
				<view class="audio-control-wrapper" >
					<view class="audio-control" style="border: none;">
						{{csdFileindex+1}}/{{luyinList.length}}
					</view>
					<view class="audio-control audio-control-prev" @click="Inasong()">
						<u-icon name="skip-back-left" color="#333" size="48"></u-icon>
					</view>
					<view class="audio-control audio-control-switch" @click="!status.playing?play():pausePlay()">
						<!-- <image v-if="status.playing && status.waiting" style="width: 30rpx;height: 30rpx;" src="../../static/images/jiazaizhong.gif" mode=""></image> -->
						<u-icon v-if="status.playing"  name="pause-circle" color="#333" size="72"></u-icon>
						<u-icon v-else  name="play-circle" color="#333" size="72"></u-icon>
					</view>
					<view class="audio-control audio-control-next" @click="Thenextsong()">
						<u-icon name="skip-forward-right" color="#333" size="48"></u-icon>
					</view>
					<view class="audio-control" style="border: none;" @click="showFile">
						<u-icon name="list-dot" color="#333" size="52"></u-icon>
					</view>
				</view>
				<view class="file-change" v-if="isshowFile">
					<view class="file-item" @click="filechange(item,index)"
						:class="csdFileindex == index ? 'fileactive' : ''" v-for="(item,index) in luyinList"
						:key="index">录音文件{{index+1}}</view>
				</view>
			</view>
		</view>
		
		
		<!-- 接待标记 -->
		<view class="zhezhoa" v-if="effective"></view>
		<view class="bounced" v-if="effective">
			<view class="jiajinghuatit">选择</view>
			<view>
			<view class="uni-list">
				<radio-group @change="radioChange">
					<label style="display: flex;align-items: center;font-size: 30rpx;
					width: 94%;height: 80rpx;margin: 0 auto;" v-for="(item, index) in effectiveitems" :key="item.value">
						<view style="margin-top: 2rpx;flex: 1; text-indent: 20rpx;">{{item.name}}</view>
						<view style="width: 80rpx;">
							<radio :value="item.value" :checked="index == effectiveindex" />
						</view>
					</label>
				</radio-group>
			</view>
			<view v-if="effectiveindex==4">
				<textarea class="ffectivetext" v-model="effectiveitext" placeholder="备注" />
			</view>
			</view>
			<view class="bounced3">
				<view class="bounced3-1" @click="effective=false">取消</view>
				<view class="bounced3-2" @click="effectiveAdd()">确认</view>
			</view>
		</view>
		<!-- 加入常错词 -->
		<view class="zhezhoa" v-if="isshow2" @tap="Cancelout"></view>
		<view class="bounced" v-if="isshow2">
			<view class="tian-view">
				<viwe class="tian-view-t1"></viwe>
				<viwe class="tian-view-t2">常错词：</viwe>
				<viwe class="tian-view-t3">
					<input type="text" v-model="thewrongword" class="tian-input" placeholder="请输入" />
				</viwe>
			</view>
			<view class="tian-view">
				<viwe class="tian-view-t1"></viwe>
				<viwe class="tian-view-t2">正确词：</viwe>
				<viwe class="tian-view-t3">
					<input class="tian-input" v-model="reswrongword" type="text" placeholder="请输入" />
				</viwe>
			</view>
			<view class="bounced3">
				<view class="bounced3-1" @tap="Cancelout">取消</view>
				<view class="bounced3-2" @tap="Confirmtheexit">确认</view>
			</view>
		</view>
		
		<!-- 加精华 -->
		<view class="zhezhoa" v-if="isshow3" @tap="Cancelout2"></view>
		<view class="bounced" v-if="isshow3">
			<view class="jiajinghuatit">加精华</view>
			<view style="width: 100%;text-indent: 20rpx;font-size: 28rpx;">选择标签</view>
			<view class="jiajinghuaview">
				<view class="jighuaview2" v-for="(item,index) in biaoqianlist" :key="index"
					:class="biaoqianindex == index ? 'biaoqiantom' : ''">
					<view class="view1-text" @click="tapbiaoqianclisck(index)">{{item.name}}</view>
				</view>
			</view>
			<view class="bounced3">
				<view class="bounced3-1" @tap="Cancelout2">取消</view>
				<view class="bounced3-2" @tap="Confirmtheexit2">确认</view>
			</view>
		</view>
	</view>
</template>

<script>
	var util = require("../../utils/util.js");
	var config = require("../../config");
	export default {
		data() {
			return {
				Aimg: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAMAAAC5zwKfAAACqVBMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9/f3////9/f39/f3////////9/f3////////////9/f3////9/f39/f3////9/f3////////9/f3////9/f3////////////////9/f39/f3////////9/f39/f3////9/f39/f3////////9/f39/f3////////9/f39/f39/f3////////////////+/v7+/v7////+/v7////+/v7////+/v7+/v7////////+/v7+/v7////+/v7////+/v7////////////////////////////+/v7////+/v7////+/v7+/v7////////////+/v7////+/v7////+/v7+/v7////////+/v7////+/v7////////+/v7////////+/v7////+/v7+/v7+/v7////////+/v7+/v7////+/v7+/v7////+/v7////+/v7////+/v7////+/v7+/v7////+/v7+/v7////+/v7////+/v7////+/v7+/v7////+/v5jdC9iAAAA4nRSTlMAAQIDBAUGBwgLDA0ODxARExQVFhgbHB4fICEiIyQmJygpKy4wMTIzNDY3ODk6Oz0+P0BBQkRGR0lKTE5PUFFTVFVXWFlcXV9gYWJjZWZnaGlqa2xtbm9wcXJzdHV2d3h6e319foGBgoODh4mKiouMjI2QkZKSk5OUlpeYmZmam5ycnZ+foKGio6SmqKmpq6yur7CwsbGytba5uru8wMDBwcLCw8XGx8jJysrLzM7P0dLT1dXW1tfY2drc3N7f4OHh5Obm5+jp6uvs7vDx8vLz8/T09fX29/f4+fn6+vz8/f7+RVDt+wAAA55JREFUGBntwf9/1HMAB/DX7XYbuXWV1cyMoixfugrRGNXytW33pbVdJ83XkiMLSb4LJd/zZUi0SKT5FmGS77HUVaixnHP2+kt8vt3Zbp/3+7P3XR5+8XziP1E4uiYcrh1bjMNi6NzXumnoeX3eSOSrpHUv+zi0ogJ5qd3JLN1XuJGzwqW0sW4oclT0Im19XIqcuNdQ4D0vcnEDhdYgB2f+SbFZUHbEdkrsLYeqFko9CEVH7qJUohxqLqODO6BmLR18XwAVRQfpZDxUnExHjVBRR0eroGIZHX0AFe10tA8qdtNZIRR00VEPVLxLRzuh4jk62gIVy+joSaiI0tECqPDT0blQ4f6RDpI+KHmYDjZBzWQ6aIaibZSK+6BoOqViUOXqoER8BJSdlqJYFDm4h0LveJAD7+cUiFciJ1U/01aiGjk65zfaSF6EnE3azQEO1iAPFZuZZes45MUT3cM+emLFyNfwK3fQ8k1sFA6L0cElTzx9d1OVC/8bNG/gzY+GQaKk461gCQZr8iMHSNZD4nySv6wYj0EYFv2UhqcgcTsN70ePhtzER3+lJe6BxXP9jTctvrl1yS1jkLaNlkTbBR6IlF3dyT78sHh+oqkSlrJe/uOH1jGw4apem2I/1yLtGRo6kRZiP73t57mQxb+Z2dqRdikNtyLtBWb78Cz05bomyQH+KIGljIYaWNxxDtC72ouMgsdpZzosHhqqYDmFdraOQNpttHUfLKU0TITlKtra6IZpCu3tgMVPQx0sG2ivDqaVFDgOppk0LIbJm6C9DTB1UCAMU4SGZ2GqocAumL6jQBtMMRq2wLScAik3dMV/UWB/EQwrafgSpk6KlEJ3LIXOgGE9DQdgqKDQSdBNoNAiGL6i6SjowhSaAt1UCm2CzpOk6QTonqfQJdBdSKGkD5pKWqZCU7iHQtdB10KxWmjOpqUJmtMp9gB091LsIWiCtCyFZiHFXoZuHcW+hiZGy0vQvE2xT6DbTolKAI/R8hmA4SmKdUG3jxIhAG/QkigAZlAi6QJQTJk2AF1MGwXcRRkfgJGU2V8EHzP8wBeUqQQwllKTcCozpuFESk0AMJNSC3AxM8KYT6lpAFootRGLmLEQ6ynVCCBAqcSQ1cy4f8ghSs0HcMzvlKp+lRmvVFMqNQ6aaIoyd3Yy49vllOmuh+H4WZFIpFnTpJmjadTM1oQ1oVAgFNQENA0N9f01BIKh8OzGOU3NkbmXzwuV41/wNztgHKhu7WKTAAAAAElFTkSuQmCC",
				luyinList:[],//文件列表
				essenceis:0,//是否加精
				csdFileindex:0,//下标位置
				audio: null,
				scrollTop: 0,
				scrollId:"dialog",
				current: 0, //当前进度(s)
				duration: 0, //总时长(s)
				startTime:0,//播放起点
				playNow: 0,
				/**逻辑状态**/
				status:{
					playing:false,//只有点击控制面板和播放结束可修改此状态
					waiting: false, //等待加载数据
					afterseek:false
				},
				customerId:"",//客户id
				buildingID:'',//项目id
				debug:true,
				dialogList:[],//转写内容区域
				isshowFile:false,//文件切换状态
				alltimeStr:'',//文件总时长
				userlistobj:{},//用户信息
				Menulist:[],//权限数组
				Menulistisshow:false,//更改接待权限
				effective:false,//无效接待弹框
				effectiveindex:'0',//无效接待下标
				effectiveitems: [
					{value: '1',name: '没电指派无录音',checked:true},
					{value: '2',name: '离线指派无录音',},
					{value: '3',name: '系统测试误操作'},
					{value: '4',name: '非接访场景录音'},
					{value: '5',name: '其他'}
				],
				effectiveitext:'',
				userInfo:{},
				jiaoseshow:true,//是否显示加精
				thewrongword: "", //错误词
				reswrongword: "", //正确词
				isshow2:false,//常错词弹框
				messagelisy:[],
				textItself:'',
				argtextindex1:0,
				argtextindex2:0,
				isshow3:false,//分点加精
				biaoqianlist: [],
				biaoqianindex: 0,
				changanitem: {},
				duihuawenjianid: "",
				biaoqianid: "",
				itemobj:{},	
				kehuyixiangcenterindex:0,
				ratelist:[],
				totalRate:""
				
			};
		},
		onLoad: function(options) {
			this.essenceis = options.status;
			this.customerId = options.customerId;
			this.buildingID = uni.getStorageSync('buildingID').id;
			this.itemobj=uni.getStorageSync('searchobj')
			this.gituserlist()
			this.getlist()
		},
		onShow() {
			this.Menulist = uni.getStorageSync('weapp_session_Menu_data');
			this.Menulist.forEach(item=>{
				if(item.name=='标记有效无效接待'){
					this.Menulistisshow=true;
				}
			})
			this.userInfo = uni.getStorageSync('weapp_session_userInfo_data');
			if (this.userInfo.dataCode == 6) {
				this.jiaoseshow = false
			}
		},
		beforeDestroy() {
			this.audio.destroy()
		},
		methods: {
			customerofintention(i){
				this.kehuyixiangcenterindex=i;
				if(this.kehuyixiangcenterindex!=0){
					this.pausePlay()
					this.getRatelist()
				}
			},
			//评分上下显隐
			changeshow(item, type) {
				item.show=!item.show;
			},
			changeshow2(item, type){
				item.show=!item.show;
			},
			// 获取评分
			getRatelist() {
				if (this.ratelist.length == 0) {
					uni.showLoading({
						title: '加载中'
					});
					this.$u.get("/customer/findzkMByCusId", {
						cusId: this.customerId
					}).then(res => {
						if (res.length) {
							let level1 = []
							let level2rate = 0
							res.forEach(item => {
								if (item.pid == 0) {
									level1.push({
										id: item.marketingId,
										rate: item.fraction,
										name: item.name,
										sort: item.sort,
										show: false,
										ratepercent: 0,
										children: []
									})
								} else {
									if (item.selected == 0) {
										level2rate += item.fraction
									}
								}
							})
							this.totalRate = level2rate;
							res.forEach(subitem => {
								let subitempid = subitem.pid
								level1.forEach(item => {
									if (subitempid == item.id) {
										if (subitem.selected == 0) {
											item.ratepercent += subitem.fraction
										}
										item.children.push({
											id: subitem.id,
											rate: subitem.fraction,
											selected: subitem.selected,
											name: subitem.name,
											show: false,
											marketingId:subitem.marketingId,
											children: []
										})
									}
								})
							})
							res.forEach(subitem => {
								let subitempid = subitem.pid
								level1.forEach(chen=>{
									chen.children.forEach(zxc=>{
										if(subitempid == zxc.marketingId){
											zxc.children.push({
											id: subitem.id,
											rate: subitem.fraction,
											selected: subitem.selected,
											name: subitem.name,
											marketingId:subitem.marketingId,
										})
										}
									})
								})
							})
							level1[0].show = true;
							level1[0].children[0].show = true;
							this.ratelist = level1
						}
						setTimeout(function() {
							uni.hideLoading();
						}, 1000);
					})
				}
			},
			//标签选择
			tapbiaoqianclisck(index) {
				this.biaoqianindex = index;
				this.biaoqianid = this.biaoqianlist[index].id
			},
			//加精华
			Addtheessence() {
				this.isshow3 = true;
				this.biaoqianlist = []
				let parames={
					"itemId":this.buildingID
				}
				this.$u.post("/addtodigest/findAllYi", parames).then(data => {
					this.biaoqianlist = data
					this.biaoqianlist.unshift({
						name: "逼单话术",
						id: 0
					})
				})
			},
			// 取消加精
			Cancelout2() {
				this.isshow3 = false;
				this.dialogList.forEach(res => {
					res.message.forEach(asd => {
						asd.isshow = false;
					})
				})
			},
			// 确认加精
			Confirmtheexit2() {
				if (this.biaoqianid) {
					this.biaoqianid = this.biaoqianid
				} else {
					this.biaoqianid = 0
				}
				this.isshow3 = false;
				this.dialogList.forEach(res => {
					res.message.forEach(asd => {
						asd.isshow = false;
					})
				})
				let objdata = {
					"carId": this.customerId, //客户id
					"startTime": this.changanitem.bg, //开始时间
					"startFile": this.duihuawenjianid, //对话所在录音文件id
					"endTime": this.changanitem.ed, //结束时间
					"marketingId": this.biaoqianid, //对应一级父id
					"jjTransfer": this.changanitem.onebest, //选中对话
					"status": 1
				}
				uni.request({
					url: config.service.addATD,
					method: "POST",
					header: {
						'content-type': 'application/json',
						'Access-Token': uni.getStorageSync('weapp_session_login_data').token
					},
					data: objdata,
					success: (data) => {
						if (data.data.code == 10000) {
							uni.showToast({
								title: '加精成功',
								duration: 2000
							});
						} else {
							uni.showToast({
								title: data.data.message,
								duration: 2000
							});
						}
					}
				})
			},
			//加入长错词
			Oftenthewrongword() {
				this.reswrongword = "";
				this.isshow2 = true;
			},
			//取消加入常错词
			Cancelout() {
				this.isshow2 = false;
				this.dialogList.forEach(res => {
					res.message.forEach(asd => {
						asd.isshow = false;
					})
				})
			},
			//确认加入常错词
			Confirmtheexit() {
				if (this.thewrongword) {
					if (this.reswrongword) {
						let parames = {
							customerId:this.customerId,
							cupid: this.luyinList[this.csdFileindex].id,
							wrongWord: this.thewrongword, //错误词
							correctWord: this.reswrongword, //正确词
							translateHtmlContent: this.messagelisy,
			
						}
						this.isshow2 = false;
						let sas=this.textItself.replace(this.thewrongword,this.reswrongword)
						this.dialogList[this.argtextindex1].message[this.argtextindex2].onebest=sas
						this.dialogList.forEach(res => {
							res.message.forEach(asd => {
								asd.isshow = false;
							})
						})
						this.$u.post("/corpus/addCorrectWord", parames).then(data => {
							this.thewrongword = "";
							this.reswrongword = "";
						})
					} else {
						uni.showToast({
							title: '正确值不能为空',
							duration: 2000
						});
						return
					}
				} else {
					uni.showToast({
						title: '错误词不能为空',
						duration: 2000
					});
					return
				}
			},
			//复制
			clickcopy() {
				var that = this;
				uni.setClipboardData({
					data: that.thewrongword,
					success: function() {
						that.dialogList.forEach(res => {
							res.message.forEach(asd => {
								asd.isshow = false;
							})
						})
						that.$forceUpdate();
					}
				});
			},
			// 取消全部加精
			notappick() {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '确认取消加精？',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							uni.request({
								url: config.service.delATD + "?carId=" + that.customerId,
								method: "GET",
								header: {
									'content-type': 'application/json',
									'Access-Token': uni.getStorageSync('weapp_session_login_data')
										.token
								},
								success: (data) => {
									if (data.data.code == 10000) {
										that.essenceis = 1
										uni.showToast({
											title: '取消成功',
											duration: 2000
										});
									} else {
										uni.showToast({
											title: data.data.message,
											duration: 2000
										});
									}
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			//全部加精
			tappick(i) {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '确认加精？',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							let objdata = {
								"carId": that.customerId, //客户id
								"status": 0,
								"itemId":that.buildingID,
							}
							uni.request({
								url: config.service.addATD,
								method: "POST",
								header: {
									'content-type': 'application/json',
									'Access-Token': uni.getStorageSync('weapp_session_login_data')
										.token
								},
								data: objdata,
								success: (data) => {
									if (data.data.code == 10000) {
										that.essenceis = 0
										uni.showToast({
											title: '加精成功',
											duration: 2000
										});
									} else {
										uni.showToast({
											title: data.data.message,
											duration: 2000
										});
									}
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			//获取用户信息
			gituserlist(){
				this.$u.get("/matchKeywords/personalReceptionRecord", {
					customerId: this.customerId
				}).then(res => {
					this.userlistobj=res;	
				})
			},
			//无效接待
			effectiveAdd(){
				if(this.effectiveindex==4){
					if(this.effectiveitext.length==0){
						uni.showToast({
						    title: '备注不能为空',
							icon:"none",
						    duration: 2000
						});
						return
					}
				}
				this.effective=false;
				let parames={
					id:this.customerId,
					validInvalid:'',
					validInvalid:1,
					invalidReason:Number(this.effectiveindex)+1,
					invalidNote:this.effectiveitext
				}
				this.$u.post("/customer/updateValidInvalid", parames).then(res => {
					console.log(res)
					this.gituserlist()
				})	
			},
			//单选
			radioChange(evt) {
				 this.effectiveitext="";
				for (let i = 0; i < this.effectiveitems.length; i++) {
					if (this.effectiveitems[i].value === evt.detail.value) {
						this.effectiveindex = i;	
						break;
					}
				}
			},
			//标记
			alllogo(){
				this.pausePlay()
				var that=this;
				let msg='';
				if(this.userlistobj.validInvalid!=0){
					msg='是否标记为"有效录音"？';
					uni.showModal({
					    title: '提示',
					    content: msg,
					    success: function (res) {
					        if (res.confirm) {
								let parames={
									id:that.customerId,
									validInvalid:'',
									invalidReason:0
								}
								if(that.userlistobj.validInvalid==0){
									parames.validInvalid=1;
								}else{
									parames.validInvalid=0;
								}
								that.$u.post("/customer/updateValidInvalid", parames).then(res => {
									console.log(res)
									that.gituserlist()
								})
					        } 
					    }
					});
				}else{
					this.effective=true;
				}
			},
			
			//录音列表显示隐藏
			showFile() {
				this.isshowFile = !this.isshowFile;
				this.pausePlay()
			},
			// 文件切换播放
			filechange(item, i) {
				this.startTime=0;
				this.csdFileindex = i;
				this.isshowFile=false;
				this.getCorpusAnalysis()
				this.init();
			},
			//长按对话
			changanxiaoguo(item, index, i) {
				this.messagelisy = [];
				this.changanitem = {};
				this.dialogList.forEach(res => {
					res.message.forEach(asd => {
						asd.isshow = false;
					})
				})
				this.changanitem = item;
				this.duihuawenjianid = this.luyinList[this.csdFileindex].id;
				this.dialogList[i].message[index].isshow = !this.dialogList[i].message[index].isshow;
				this.textItself=item.onebest;
				let onebest=item.onebest;
				this.thewrongword =onebest.replace(/<.*?>/ig,"");
				this.messagelisy = this.dialogList[i].message;
				this.argtextindex1=i;
				this.argtextindex2=index;
				this.$forceUpdate()
			},
			//获取文件列表
			getlist(){
				const parames = {
						pageNum: 1,
						pageSize: 100,
						query: {
							customerId: this.customerId
						}
					}
					this.$u.post("/corpus/findByPage", parames).then(res => {
						if (res && res.length) {
							let alltime = 1;
							console.log(res)
							res.forEach(item => {
								alltime += item.recordDuration
							})
							this.alltimeStr = this.getTime(alltime)
							if(this.itemobj){
								res.forEach((item,index) => {
									if(item.id==this.itemobj.customerId){
										this.csdFileindex=index;
										this.startTime=this.itemobj.bg/1000
									}
								})	
							}
							this.luyinList = res;
							this.getCorpusAnalysis()
						}
					})
			},
			// 获取转义后的对话结果
			getCorpusAnalysis(info) {
				this.dialogList = [];
				uni.request({
					url: config.service.getCorpusAnalysis + '?corpusId=' + this.luyinList[this.csdFileindex].id+"&customerId="+this.customerId, //仅为示例，并非真实接口地址。
					method: "GET",
					header: {
						'content-type': 'application/json',
						'Access-Token': uni.getStorageSync('weapp_session_login_data').token
					},
					success: (data) => {
						if (data.data.code == 10000) {
							if (data.data.data.audioContent.length != 0) {
								const jsonInfo = JSON.parse(data.data.data.audioContent);
								this.dialogList.push({
									message: jsonInfo,
									backindex:this.csdFileindex
								});
								this.dialogList.forEach((asd, idx) => {
									asd.message.forEach((qwe, inde) => {
										qwe.isshow = false;
									})
								})
								this.init();
							}
			
						} else {
							uni.hideLoading();
							uni.showModal({
								title: '提示',
								content: '请求数据失败，请重新尝试',
								showCancel: false
							});
						}
					}
				});
			},	
			getTime(time) {
				return util.formatSecond(time)
			},
			init(){
				if(this.audio){
					this.audio.destroy();
				}
				this.resetStatus();
				this.audio = uni.createInnerAudioContext();
				this.audio.obeyMuteSwitch = false;
				this.audio.startTime=this.startTime;//播放开始时间
				this.audio.autoplay=false;
				this.duration=this.luyinList[this.csdFileindex].recordDuration;
				this.audio.src=this.luyinList[this.csdFileindex].recordPath;
				if(this.autoplay){
					this.status.playing=true;
				}
				//音频进度更新事件
				this.audio.onTimeUpdate(() => {
					if (!this.duration) {
						this.duration = this.audio.duration
					}
					this.current = this.audio.currentTime
					this.playNow = parseInt(this.current * 1000)
					if (this.dialogList.length == 0) {
						return
					} else {
						const message = this.dialogList[0].message;
						for (let i = 0; i < message.length; i++) {
							if (Number(message[i].bg) < this.playNow && Number(message[i].ed) > this.playNow) {
								this.scrollId = "dialog" + this.csdFileindex + "text" + message[i].bg;
								break;
							}
						}
					}
					this.$forceUpdate()
				})
				//音频播放事件
				this.audio.onPlay(() => {
					this.debug && console.log('开始播放,当前播放器状态='+this.audio.paused);
					if(this.status.afterseek==true){
						this.status.afterseek=false;
						this.seek(this.current);
					}
					
				})
				//音频暂停事件
				this.audio.onPause(() => {
					this.debug && console.log('暂停播放,当前播放器状态='+this.audio.paused);
					console.log("是",this.status.afterseek)
					if(this.status.afterseek==true){
						console.log("走跳转")
						this.audio.seek(this.current);
					}
				
				})
				this.audio.onStop(() => {
					this.debug && console.log('停止播放,当前播放器状态='+this.audio.paused);
				})
			
				//音频等待
				this.audio.onWaiting(() => {
				
				})
				this.audio.onCanplay(() => {
					this.debug && console.log('数据准备就绪,当前播放器状态='+this.audio.paused)
					this.play()
				})
				
				this.audio.onSeeking(()=>{
					console.log("进行跳转");
				})
				this.audio.onSeeked(() => {
					console.log("结束跳转");
					this.status.afterseek=false;
					this.play()
				})
				
				//音频结束事件
				this.audio.onEnded(() => {
					this.debug && console.log('播放结束,当前播放器状态='+this.audio.paused)
					this.Thenextsong()//结束播放下一条
				})
				
				this.audio.onError((err) => {
					this.debug && console.log('播放出错,当前播放器状态='+this.audio.paused)
					this.debug && console.error(err)
				})
			},
			seek(value){
				if(value<=0){
					value=0
				}
				if(value>=this.duration){
					value=this.duration;
				}
				this.debug && console.log('调用Seek，当前audio状态='+this.audio.paused+',value='+value);
				this.status.playing=true;
				this.current = value;
				if(this.audio.paused==false){//暂停事件里调用this.audio.seek
					console.log("播放中")
					this.status.afterseek=true;
					this.pausePlay()
				}else{//已经是停止状态 必须先播放后再调用this.seek
				console.log("暂停")
					this.status.afterseek=true;
					this.play();
				}
			
			},
			//点击播放按钮
			play() {
				this.status.playing=true;
				if(this.audio.paused){
					this.audio.play();
				}
			},
			//暂停
			pausePlay(){
				this.status.playing=false;
				if(!this.audio.paused){
					this.audio.pause();
				}
			},
			//上一曲
			Inasong(){
				this.startTime=0;
				this.pausePlay()
				if(this.csdFileindex==0){
					uni.showToast({
						icon: "none",
						title: "已是第一条！"
					})
					return
				}else{
					this.csdFileindex=this.csdFileindex-1;
					this.getCorpusAnalysis()
					this.init();
				}
			},
			//下一曲
			Thenextsong(){
				this.startTime=0;
				this.pausePlay()
				if(this.csdFileindex>this.luyinList.length-1){
					return
				}else if(this.csdFileindex==this.luyinList.length-1){
					uni.showToast({
						icon: "none",
						title: "已到最大条数！"
					})
				}else{
					this.csdFileindex=this.csdFileindex+1;
					this.getCorpusAnalysis()
					this.init();
				}
			},
			//长按播放
			clickbofang(dialog,item){
				this.pausePlay()
				this.dialogList.forEach(res => {
					res.message.forEach(asd => {
						asd.isshow = false;
					})
				})
				this.$forceUpdate()
				let time = parseInt(item.bg / 1000)
				this.seek(time)
			},
			// 重置状态
			resetStatus(){
				this.status.playing = false;
				this.current = 0;
			},
			//格式化时长
			format(num) {
				return '0'.repeat(2 - String(Math.floor(num / 60)).length) + Math.floor(num / 60) + ':' + '0'.repeat(2 -
					String(Math.floor(num % 60)).length) + Math.floor(num % 60)
			}
		}
	}
</script>


<style lang="scss" scoped>
.box{
	width: 100%;
	height: 100vh;
	display:flex;
	flex-direction:column;
}
.headbox{
	width: 100%;
	min-height: 120rpx;
	border-bottom: 1px solid #E0E0E0;
	.tit-tiem{
		font-size: 30rpx;
		color: #303030;
		padding-left: 30rpx;
		padding-right: 30rpx;
	}
	.call_record_time_one {
		padding-left: 30rpx;
		padding-right: 30rpx;
		height: 48rpx;
		font-size: 28rpx;
		font-weight: 500;
		color: #70798d;
		line-height: 48rpx;
		display: flex;
		justify-content: space-between;
		position: relative;
		margin-top: 10rpx;
		.audoioyouxiao{
			height: 46rpx;
			position: absolute;
			top: 0rpx;
			right: 120rpx;
		}
		.diangweitupian {
			width: 46rpx;
			height: 46rpx;
			position: absolute;
			top: 0rpx;
			right: 30rpx;
		}
	}
}
.zhuti{
	flex:1;
	overflow:auto;
}
.bottombox{
	width: 100%;
	height: 170rpx;
	border-top: 1px solid #E0E0E0;
}
.audio {
	width: 100%;
	padding: 10rpx 0;
	background: #fff;
	.audio-wrapper {
		margin-top: 10rpx;
		display: flex;
		align-items: center;
		margin-top: 16rpx;
		color: #70798D;
	}
	.audio-number {
		width: 120upx;
		font-size: 24upx;
		line-height: 1;
		color: #333;
		text-align: center;
	}
	.audio-slider {
		flex: 1;
		margin: 0;
	}
}


.audio-control-wrapper {
	margin-top: 20upx;
	display: flex;
	justify-content: center;
	align-items: center;
	.audio-control {
		line-height: 1;
	}
	.audio-control-switch {
		margin: 0 60rpx;
	}
	.audio-control-prev{
		margin: 0 50rpx;
	}
	.audio-control-next{
		margin: 0 50rpx;
	}
}
.file-change {
		position: fixed;
		width: 184rpx;
		bottom: 80rpx;
		width: 184rpx;
		right: 10rpx;
		background: #FFFFFF;
		border-radius: 4rpx;
		z-index: 99;
		height: 600rpx;
		overflow: auto;
		border: 1px solid #e0e0e0;
	}
	.file-item {
		width: 100%;
		height: 60rpx;
		line-height: 60rpx;
		text-align: center;
		font-size: 30rpx;
		font-weight: 400;
		color: #333333;
		border-bottom: 1rpx solid #E2E2E2;
	}
	.file-item:last-child {
		border: 0
	}
	.fileactive {
		color: #008EF2
	}
	.ffectivetext{
		width: 85%;
		margin: 10rpx auto;
		height: 100rpx;
		padding: 20rpx;
		border: 1rpx solid #E4F0FF;
	}
	
	.zhezhoa {
		position: fixed;
		top: 0;
		left: 0;
		z-index: 999;
		width: 100%;
		height: 100vh;
		opacity: 0.5;
		background-color: #666666;
	}
	.bounced {
		width: 570upx;
		background: #FFFFFF;
		z-index: 1000;
		border-radius: 10upx;
		position: fixed;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);
		/* 50%为自身尺寸的一半 */
		.jiajinghuatit {
			width: 100%;
			height: 68rpx;
			font-size: 30rpx;
			text-align: center;
			line-height: 68rpx;
		}
		.jiajinghuaview {
			padding: 18rpx 18rpx 18rpx 18rpx;
			display: flex;
			flex-wrap: wrap;
			.jiajinghuaview1 {
				padding: 8rpx 8rpx 8rpx 8rpx;
				font-size: 26rpx;
				border-radius: 12rpx;
				border: 1px solid #979797;
				margin-left: 8rpx;
			}
			.jighuaview2 {
				padding: 8rpx 18rpx 8rpx 18rpx;
				font-size: 26rpx;
				border-radius: 12rpx;
				border: 1px solid #979797;
				margin-left: 20rpx;
				margin-top: 10rpx;
				display: flex;
				.view1-text {
					text-align: center;
				}
				.view1-img {
					width: 50rpx;
				}
			}
		}
		.bounced3 {
			height: 100upx;
			width: 100%;
			margin-top: 40upx;
			border-top: 1px solid #dddddd;
			display: flex;
		}
		.bounced3-1 {
			width: 50%;
			height: 100%;
			text-align: center;
			line-height: 100upx;
			border-right: 1px solid #dddddd;
			font-size: 36upx;
			color: #999999;
		}
		.bounced3-2 {
			width: 50%;
			height: 100%;
			text-align: center;
			line-height: 100upx;
			font-size: 36upx;
			color: #108ee9;
		}
	}
	
.scroll-Y {
	font-size: 36upx;
	color: #999999;
	background: #FFFFFF;
	margin-top: 30upx;
	flex: 1;
	overflow-y: scroll;
	width: 100%;
}
.scroll-Y .text {
	margin: 50upx 30upx;
	line-height: 80upx;
	display: flex;
	align-items: center;
}
.scroll-Y .text[data-speaker="2"],
.scroll-Y .text[data-speaker="4"],
.scroll-Y .text[data-speaker="6"] {
	flex-direction: row-reverse;
	text-align: right;
	.content {
		margin-left: 0;
		margin-right: 30upx;
		background: #F6F6F6;
		color: #999999;
	}
}
.scroll-Y .text .avatar {
	width: 64upx;
	height: 64upx;
	line-height: 64upx;
	text-align: center;
	font-size: 36rpx;
	border-radius: 50%;
	background: #F2F2F2;
	color: #008EF2;
	image {
		width: 40upx;
	}
}
.scroll-Y .text .content {
	margin-left: 30upx;
	line-height: 60rpx;
	text-align: left;
	padding: 0 5px;
	background: #2BC805;
	border-radius: 8upx;
	max-width: 442rpx;
	color: #FFFFFF;
	position: relative;
	.tankuangcss {
		position: absolute;
		top: -140rpx;
		left: 120rpx;
		width: 308rpx;
		height: 130rpx;
		background-color: #333333;
		font-size: 24rpx;
		color: #FFFFFF;
		padding-top: 4rpx;
		padding-bottom: 4rpx;
		display: flex;
		flex-wrap: wrap;
		border-radius: 15rpx;
		z-index: 1000;
	}
}
.scroll-Y .text.active .content {
	color: #38FFF1;
	position: relative;
}
.scroll-Y .text.active[data-speaker="2"] .content,
.scroll-Y .text.active[data-speaker="4"] .content,
.scroll-Y .text.active[data-speaker="6"] .content {
	color: #FF7538;
	position: relative;
}
	// 表单
	.tian-view {
		width: 570upx;
		background-color: #FFFFFF;
		border-bottom: 1px solid #ededee;
		display: flex;
		min-height: 96rpx;
		.tian-view-t1 {
			width: 20rpx;
			font-size: 34rpx;
			height: 34rpx;
			line-height: 110rpx;
			letter-spacing: 0px;
			color: red;
		}
		.tian-view-t2 {
			width: 30%;
			min-height: 96rpx;
			line-height: 96rpx;
			font-size: 34rpx;
			color: #333;
		}
		.tian-view-t3 {
			width: 61%;
			padding-top: 31rpx;
			padding-bottom: 31rpx;
			display: flex;
			.tian-input {
				width: 98%;
				font-size: 34rpx;
				border: none;
			}
		}
	}
	.biaoqiantom {
		background-color: #008EF2;
		color: #FFFFFF;
		border: none;
	}
	.pingfenbox{
		width: 100%;
		height: 70rpx;
		line-height: 70rpx;
		border-bottom: 1px solid #E0E0E0;
		display: flex;
	}
	.pingfenbox view{
		flex: 1;
		text-align: center;
		font-size: 28rpx;
		text-indent: 20rpx;
	}
	.activecllasscet{
		background: #2671E2;
		color: #FFFFFF;
	}
	.Level-box{
		padding-bottom: 2rpx;
		.hhhbox{
			width:100%;
			padding-left: 30rpx;
			padding-right: 30rpx;
			border-bottom: 1rpx solid #E0E0E0;
			background: #FFFFFF;
			// padding-bottom: 32rpx;
			.hsnrtest{
				height: 24rpx;
				font-size: 24rpx;
				font-weight: 400;
				color: #666666;
				line-height: 24rpx;
			}
			.Level3che{
				width:100%;
				height:28rpx;
				display: flex;
				line-height: 28rpx;
				align-items: center;
				margin-top: 30rpx;
				.title1{
					flex: 1;
					font-size: 28rpx;
					color:#2671E2;
					font-weight: 400;
				}
				.jiantobox{
					width: 30rpx;
					height: 30rpx;
					display: flex;
					align-items: center;
					.arrow{
						width: 28rpx;
						height:28rpx;
					}
				}
			}
		}
		.Level2che{
			width:100%;
			height: 88rpx;
			display: flex;
			line-height: 88rpx;
			align-items: center;
			.title1{
				flex: 2;
				font-size: 28rpx;
				color: #333333;
				font-weight: 400;
			}
			.leve1-jindu{
				flex: 3;
				display: flex;
				justify-content: center;
				align-items: center;
				.zhixing{
					width: 108rpx;
					height: 44rpx;
					background: #2671E2;
					border-radius: 4rpx;
					font-size: 28rpx;
					text-align: center;
					line-height: 44rpx;
					color: #FFFFFF;
				}
				.zhixing2{
					width: 108rpx;
					height: 44rpx;
					background: #F8F8F8;
					border-radius: 4rpx;
					font-size: 28rpx;
					text-align: center;
					line-height: 44rpx;
					color: #999999;
				}
			}
			.jiantobox{
				width: 30rpx;
				height: 30rpx;
				display: flex;
				align-items: center;
				.arrow{
					width: 30rpx;
					height:18rpx;
				}
			}
		}
		.Level1che{
			width:100%;
			height: 94rpx;
			background: #F5F5F5;
			display: flex;
			line-height: 94rpx;
			align-items: center;
			padding-left: 30rpx;
			padding-right: 30rpx;
			.title1{
				flex: 2;
				font-size: 30rpx;
				color: #333333;
				font-weight: 400;
			}
			.leve1-jindu{
				flex: 3;
				.jindutiao{
					width: 96%;
					height: 28rpx;
					background: #D5EEE2;
					line-height: 28rpx;
					border-radius: 14rpx;
					position: relative;
					.huanxing{
						height: 100%;
						background: #4FC78F;
						border-radius: 14rpx;
					}
					.text{
						position: absolute;
						top: 0rpx;
						right: 0rpx;
						font-size: 28rpx;
						font-weight: 400;
						color: #333333;
					}
				}
			}
			.jiantobox{
				width: 30rpx;
				height: 30rpx;
				display: flex;
				align-items: center;
				.arrow{
					width: 30rpx;
					height:18rpx;
				}
			}
		}
	}
</style>