<template>
	<view class="content">
		<view class="mbr-info">
			<image :src="vdata.record.avatarUrl" />
			<text class="mbr-info-name">{{ vdata.record.mbrName }}</text>
			<text class="mbr-info-amount">{{ vdata.record.changeAmount > 0 ? '+'+cal.cert2Dollar(vdata.record.changeAmount) : cal.cert2Dollar(vdata.record.changeAmount) }}</text>
		</view>
		<view class="account-line"></view>
		<view class="account-history">
			<view class="account-history-item"><text>业务类型</text>
				<text>{{ vdata.record.bizType==1?'支付充值':vdata.record.bizType==2?'现金充值':vdata.record.bizType==3?'会员消费':vdata.record.bizType==4?'消费退款':vdata.record.bizType==5?'人工调账':'其他' }}</text>
			</view>
			<view class="account-history-item"><text>流水ID</text><text>{{ vdata.record.hid }}</text></view>
			<view class="account-history-item"><text>会员ID</text><text>{{ vdata.record.mbrId }}</text></view>
			<view class="account-history-item"><text>会员手机号</text><text>{{ vdata.record.mbrTel }}</text></view>
			<view class="account-history-item"><text>变动前余额</text><text>￥{{ cal.cert2Dollar(vdata.record.beforeAmount) }}</text></view>
			<view class="account-history-item"><text>变动金额</text><text>￥{{ cal.cert2Dollar(vdata.record.changeAmount) }}</text></view>
			<view class="account-history-item"><text>变动后余额</text><text>￥{{ cal.cert2Dollar(vdata.record.afterAmount) }}</text></view>
			<view v-if="vdata.record.relaBizOrderId && vdata.record.bizType == 1" class="account-history-item">
				<text>充值订单号</text>
				<text>{{ vdata.record.relaBizOrderId }}
					<text class="info-copy" @tap="copyInfo(vdata.record.relaBizOrderId)">复制</text>
				</text>
			</view>
			<view class="account-history-item"><text>变动时间</text><text>{{ vdata.record.createdAt }}</text></view>
		</view>
	</view>
</template>

<script setup>
import { reactive, ref } from 'vue'
import { onLoad, onUnload } from '@dcloudio/uni-app'
import { reqLoad, API_URL_MEMBER_ACCOUNT_HISTORY } from '@/http/apiManager.js'
import infoBox from '@/commons/utils/infoBox.js';
import cal from '@/commons/utils/cal.js'
import go from '@/commons/utils/go.js'
import emit from '@/commons/utils/emit.js'
import ent from '@/commons/utils/ent.js'

onLoad((options) => {
	refData(options.hid)
})

const vdata = reactive({
	record : { }
})

// 监听 更新事件 
onUnload(() => uni.$off(emit.ENAME_REF_MEMBER_ACCOUNT_HISTORY_DETAIL))
uni.$on(emit.ENAME_REF_MEMBER_ACCOUNT_HISTORY_DETAIL, function(data){
	refData(vdata.record.hid)
}) 

function refData(hid){
	reqLoad.getById(API_URL_MEMBER_ACCOUNT_HISTORY, hid).then(({bizData}) => {
		vdata.record = bizData
	})
}

const copyInfo = (val) => {
  uni.setClipboardData({ data: val}).then(() => {
  	 infoBox.showSuccessToast('复制成功')
  })
}

</script>


<style lang="scss" scoped>
	.content {
		width: 630rpx;
		margin: 0 auto;
	}
	.mbr-info {
		height: 376rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		
		image {
			width: 100rpx;
			height: 100rpx;
			border-radius: 50%;
		}
		.mbr-info-name {
			padding-top: 10rpx;
			color: #828282ff;
			font-size: 30rpx;
		}
		.mbr-info-amount {
			padding-top: 10rpx;
			color: #000000ff;
			font-size: 50rpx;
			font-weight: 500;
		}
	}
	.account-line {
		border-bottom: 1rpx solid #0000001a;
	}
	.account-history {
		padding-top: 60rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: flex-start;
		
		.account-history-item {
			display: flex;
			flex-direction: row;
			justify-content: flex-start;
			opacity: 1;
			padding: 13rpx 0 12rpx;
			
			text:first-child {
				width: 180rpx;
				color: #999999;
				font-size: 26rpx;
				font-weight: 400;
			}
			text:nth-child(2) {
				width: 450rpx;
				color: #000000;
				font-size: 26rpx;
				font-weight: 400;
				word-break: break-all;
				
				.info-copy {
					padding-left: 20rpx;
					opacity: 1;
					color: #2d6dccff;
					font-size: 26rpx;
				}
			}
		}
	}


</style>
