<template>
	<view class="u-m-b-30 goods">
		<view class="u-flex color-999">
			<text class="">{{data.createTime}}</text>
		</view>


		<view class="u-m-t-20 u-flex u-col-top ">
			<image :src="data.coverImg" lazy-load class="img"></image>
			<view class=" u-p-l-24 h-100 u-flex u-flex-1 u-col-top u-flex-col u-row-between">
				<view class="u-flex">
					<view class="color-333"> <text class="font-bold">{{data.name}}</text></view>
					<view class="price u-m-l-20">¥{{data.price}}</view>
				</view>
				<view class="u-flex u-row-between  w-full">
					<view>
						<text class="color-999">盈亏数量:</text>
						<text>{{data.phaseNum}}</text>
					</view>
					<view>
						<text class="color-999">盈亏金额:</text>
						<text>{{data.phasePrice}}</text>
					</view>
				</view>
				<view class="u-flex u-row-between  w-full">
					<view>
						<text class="color-999">账存库存:</text>
						<text>{{data.stock}}</text>
					</view>
					<view>
						<text class="color-999">实际库存:</text>
						<text>{{data.inventoryStock}}</text>
					</view>
				</view>

			</view>
		</view>
		
		<view class="u-m-t-20 u-flex " v-if="data.note">
			<view class="color-333">备注:</view>
			<view class="bg-gray u-m-l-20 u-p-t-10 u-p-b-10 u-p-l-20 u-p-r-20 color-999">{{data.note}}</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		watchEffect
	} from 'vue';
	import {
		$goodsIsHot
	} from '@/http/yskApi/goods.js'
	import mySwitch from '@/components/my-components/my-switch.vue'
	import go from '@/commons/utils/go.js';
	import {
		ColorMain
	} from '@/commons/color.js'
	const emits = defineEmits(['radioClick', 'xiajia', 'del'])
	const props = defineProps({
		index: {
			type: Number
		},
		data: {
			type: Object,
			default: () => {
				return {}
			}
		}
	})


	function isHotChange(e) {
		$goodsIsHot({
			id: props.data.id,
			isHot: props.data.isHot
		}).then(res => {
			uni.showToast({
				title: '修改成功',
				icon: 'none'
			})
		})
	}

	let isSellNone = ref(false)
	isSellNone.value = props.isSellNone

	function isSellNoneChange() {
		console.log(isSellNone.value);
		console.log('isSellNoneChange');
	}

	let checked = ref(false)


	function radioClick() {
		console.log(props.index);
		emits('radioClick', props.index)
	}


	function xiajia() {
		emits('xiajia', props.index)
	}

	function del() {
		emits('del', props.index)
	}

	//携带参数type edit跳转到商品添加页面，编辑与添加同一页面，根据type值来判断
	function toEdit() {
		go.to('PAGES_PRODUCT_ADD', {
			type: 'edit',
			productId: props.data.id
		})
	}
</script>

<style lang="scss" scoped>
	$imgSize: 126rpx;
	$price-color: #F02C45;

	.btn {
		padding: 6rpx 28rpx;
		border-radius: 100rpx;
		border: 2rpx solid transparent;
	}

	.btn-primary {
		border-color: $my-main-color;
		;
		color: $my-main-color;
	}

	.btn-default {
		border-color: #F4F4F4;
		color: #999;
	}

	.price {
		color: $price-color;
	}

	.h-100 {
		height: $imgSize;
	}

	.img {
		width: $imgSize;
		height: $imgSize;
	}

	.icon-arrow-right {
		width: 32rpx;
		height: 32rpx;
	}

	.stock {
		position: relative;
	}


	.goods {
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		background-color: #fff;
		padding: 24rpx 28rpx 16rpx 28rpx;
		font-size: 28rpx;


	}
</style>