<template class="bc#f6f6f6">
	<view style="width: 100%;height: 100%;">
		<view class="title">
			<!-- 头像 -->
			<image :src="img" style="width: 100rpx;height: 100rpx;border-radius: 50%;"></image>
			<!-- 名字 -->
			<view style="font-size: 34rpx;font-weight: bold;margin-left: 30rpx;">{{name}}</view>
			<view class="cu-tag round bg-orange sm" v-if="remark!=null">{{remark}}</view>
		</view>
		<view style="height: 100rpx;background-color: #FFF;padding: 0 40rpx;font-size: 34rpx;font-weight: bold;" class="flex align-center">
			通话记录		</view>
		<view v-for="(item,index) in list" :key="index" style="padding: 30rpx 30rpx;background-color: #FFF;border-top: 1rpx solid #d0d0d0;" class="flex justify-between align-end">
			<view>
				<view style="margin-bottom: 10rpx;">
					<text style="font-size: 28rpx;margin-right: 10rpx;">订单号:</text>
					<text style="font-size: 24rpx;">{{item.order}}</text>
				</view>
				<view >
					<text style="font-size: 28rpx;margin-right: 10rpx">拨入时间:</text>
					<text style="font-size: 24rpx;">{{item.time}}</text>
				</view>
			</view>
			<view style="height: 100%;">
				<text style="font-size: 28rpx;margin-right: 10rpx">通话时长:</text>
				<text style="font-size: 24rpx;">{{item.duration}}</text>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	export default {
		components: {

		},
		// onLoad() {
		// 	console.log(callObject)
		// 	this.img = callObject.img
		// 	this.name = callObject.name
		// 	this.getLists();
		// },
		onLoad: function(options) {
			let object = JSON.parse(options.callObject); //注意，此赋值方法不是微信官方赋值方法，页面奖无法获取数据
			console.log(object);
			this.img = object.img
			this.name = object.name
			this.id = object.id
			this.remark = object.remark
			this.getLists()
		},
		mounted() {

		},
		data() {
			return {
				id: 0,
				img: '',
				name: '',
				object: '',
				list: []
			}
		},
		methods: {
			getLists: async function() {
				console.log(this.id)
				let res = await this.$request.post("Doctor/user_call", {
					user_id: this.id
				});
				if (res.status == 0) {
					if (res.data.length != 0) {
						for (let k = 0; k < res.data.length; k++) {
							this.list.push({
								time: res.data[k].time,
								duration: this.getDuration(res.data[k].talk_time),
								order: res.data[k].order_sn
							})
						}
					}
				}
				console.log("res", res);
			},
			getDuration(second) {
				// var hours = Math.floor((second % 86400) / 3600);
				// var minutes = Math.floor(((second % 86400) % 3600) / 60);
				// var seconds = Math.floor(((second % 86400) % 3600) % 60);
				// var duration = hours + ":" + minutes + ":" + seconds;
				// return duration;
				 var theTime = parseInt(second);// 需要转换的时间秒 
				 var theTime1 = 0;// 分 
				 var theTime2 = 0;// 小时 
				 var theTime3 = 0;// 天
				 if(theTime > 60) { 
				  theTime1 = parseInt(theTime/60); 
				  theTime = parseInt(theTime%60); 
				  if(theTime1 > 60) { 
				   theTime2 = parseInt(theTime1/60); 
				   theTime1 = parseInt(theTime1%60); 
				   if(theTime2 > 24){
				    //大于24小时
				    theTime3 = parseInt(theTime2/24);
				    theTime2 = parseInt(theTime2%24);
				   }
				  } 
				 } 
				 var result = '';
				 if(theTime > 0){
				  result = ""+parseInt(theTime)+"秒";
				 }
				 if(theTime1 > 0) { 
				  result = ""+parseInt(theTime1)+"分"+result; 
				 } 
				 if(theTime2 > 0) { 
				  result = ""+parseInt(theTime2)+"小时"+result; 
				 } 
				 if(theTime3 > 0) { 
				  result = ""+parseInt(theTime3)+"天"+result; 
				 }
				 return result; 
			}
		}
	};
</script>

<style>
	.title {
		display: flex;
		align-items: center;
		border-radius: 30rpx;
		margin: 30rpx 50rpx;
		padding: 20rpx;
		box-shadow: 0 0 50rpx 0 rgba(0, 0, 0, 0.1);
	}
</style>
