<template>
	<view>
		<!-- 状态栏 -->
		<status-nav :titleVal="title" :statusTitle="true"></status-nav>
		<view :style="{paddingTop: statusHeight+'px'}" class="pad-x20">
			<view v-if="customObj" class="fon30">
				<view class="dis bacf mar-s20 radius10 pad20 pad-zy40">
					<image class="flexs" :src="customObj.headimgurl" mode="aspectFill" lazy-load style="width: 160rpx;height: 160rpx;"></image>
					<view class="mar-z20 line-h56">
						<view class="col9 clips1">昵称：<span class="colb">{{customObj.nickname}}</span></view>
						<view class="col9 clips1">恒美ID：<span class="colb">{{customObj.coding}}</span></view>
						<view class="col9 clips1">性别：<span class="colb">{{customObj.gender ? '男' : '女'}}</span></view>
					</view>
				</view>
				<view class=" bacf mar-s20 radius10 pad20 pad-zy40">
					<view class="mar-sx20 bold colb fon36">用户信息：</view>
					<view class="line-h56">
						<view class="dis">
							<view class="col9 flexs">真实姓名：</view>
							<view class="">{{customObj.real_name || ''}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">电话：</view>
							<view class="">{{customObj.mobile}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">地址：</view>
							<view class="">{{customObj.country||''}}{{customObj.province ||''}}{{customObj.city||''}}{{customObj.county||''}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">出生日期：</view>
							<view class="">{{customObj.birthday}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">积分：</view>
							<view class="">{{customObj.score}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">孔雀币：</view>
							<view class="">{{customObj.coin}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">会员等级：</view>
							<view class="">{{customObj.level_info.name}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">会员值：</view>
							<view class="">{{customObj.level_info.value}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">是否到店：</view>
							<view class="">{{customObj.is_sign?'是':'否'}}</view>
						</view>
					</view>
				</view>
				<view class=" bacf mar-s20 radius10 pad20 pad-zy40">
					<view class="mar-sx20 bold colb fon36">用户来源：</view>
					<view class="line-h56">
						<view class="dis">
							<view class="col9 flexs">客户来源：</view>
							<view class="">{{customObj.channel_text}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">详细来源：</view>
							<view class="">{{customObj.source_text}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">所属客服：</view>
							<view class="">{{customObj.customer_service}}</view>
						</view>
						<!-- <view class="dis">
							<view class="col9 flexs">成为客户时间：</view>
							<view class="">{{customObj.source_text}}</view>
						</view> -->
					</view>
				</view>
				<view class=" bacf mar-s20 radius10 pad20 pad-zy40">
					<view class="mar-sx20 bold colb fon36">消费信息：</view>
					<view class="line-h56">
						<view class="dis">
							<view class="col9 flexs">累计消费金额：</view>
							<view class="">{{customObj.total_price}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">累计消费积分：</view>
							<view class="">{{customObj.total_score}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">累计消费孔雀币：</view>
							<view class="">{{customObj.total_coin}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">累计商城订单数：</view>
							<view class="">{{customObj.order_num}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">累计积分订单数：</view>
							<view class="">{{customObj.order_score_num}}</view>
						</view>
						<view class="dis">
							<view class="col9 flexs">最近消费时间：</view>
							<view class="">{{customObj.order_newest}}</view>
						</view>
					</view>
				</view>
				<view class=" bacf mar-s20 radius10 pad20 pad-zy40">
					<view class="mar-s20 bold colb fon36">他的足迹：</view>
					<view class="">
						<view class="bbot pad-sx20" v-for="(item,index) in dataList" :key="index">
							<view class="">
								<text class="bold col3">{{item.name}}</text>
								<text style="color: #B3B3B3;">{{item.action}}</text>
								<text class="bold col3" v-if="item.title!=null && item.title!=''">【{{item.title}}】</text>
								<text style="color: #B3B3B3;" v-if="item.zwhat!=null && item.zwhat!=''">{{item.zwhat}}</text>
							</view>
							<view class="dis col9 mar-s10">{{item.time}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 底部客服 -->
		<public-customer :nbottom="100"></public-customer>
		<!-- 用户信息授权，手机号授权 -->
		<auth-userInfo-mobileInfo></auth-userInfo-mobileInfo>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgSrc:'',
				isBtn:false,
				title:'详情',//标题
				customObj:'',
				customId:'',//客户id
				page:1,
				size:10,
				total:0,
				dataList:[],
				isZanw:true
			}
		},
		computed:{
			statusHeight() {
				return this.$store.state.statusHeight
			}
		},
		onLoad(op) {
			if(uni.getStorageSync('phone_active')!=0 && uni.getStorageSync('is_active')!=0){
				this.customId = op.id;
				this.checkCustomDetail(op.id);
				this.checkList();
			}
		},
		onShareAppMessage(e) {
			let shareObj = {
				title: '',
				path: `/pagesB/customDetail/customDetail?invite_code=${uni.getStorageSync('invite_code')}&id=${this.customId}`, // 默认是当前页面，必须是以‘/’开头的完整路径
			};
			return shareObj;
		},
		onReachBottom() {//触底事件
			if(this.total!=this.dataList.length){
				this.page++
				this.checkList()
			} else {
				if(this.isZanw) this.$toolAll.tools.showToast('暂无更多足迹内容')
				this.isZanw = false
			}
		},
		methods: {
			// 客户详情
			checkCustomDetail(id){
				this.$requst.get('user/customer-detail',{customer_id:id}).then(res=>{
					if(res.code==0){
						this.customObj = res.data;
					}
				})
			},
			checkList(){//查询列表事件
				let params = {
					page:this.page,
					size:this.size,
					customer_id:this.customId,//客户ID
				}
				this.$requst.post('user/footmarks',params).then(res=>{
					// console.log('足迹列表查询：',res);
					if(this.page==1) this.dataList = []
					this.total = res.data.total
					if(res.data.list.length!=0){
						res.data.list.forEach(item=>{
							let newCate = ''
							if(item.content_id > 0) newCate = item.category
							else newCate = ''
							let obj = {
								id:item.account_id,
								name:item.nickname,
								action:item.action,
								title:item.title,
								time:item.created_at,
								zwhat:newCate,
								mobile:item.mobile
							}
							this.dataList.push(obj)
						})
					}
				})
			},
		}
	}
</script>

<style>
</style>
