<template>
	<view class="content" v-if="state.list">
		<view class="item" v-for="(item,index) in state.list" :key='index'>
			<view class="title">
				<view>
					<text><text>{{item.productName}}</text>&nbsp;&nbsp;<text>¥{{item.discountPrice * 0.01}}</text></text>
				</view>
				<text class="add" @click="add(item.equtyId)">加购</text>
			</view>
		</view>
	</view>
	<view v-else>
		<empty title='暂无权益列表' />
	</view>
</template>

<script setup lang="ts">
	import empty from "@/components/empty/empty.vue";
	import { onLoad } from "@dcloudio/uni-app";
	import { reactive } from "vue";
	import { equityProductsApi, addEquityListApi } from "@/utils/network/api.js";
	import { stringToJson } from "@/utils/network/encryption";
	import { request } from "@/utils/network/request";
	import { msg, navTo } from "@/utils/utils";
	import { getEquityListApi } from "@/utils/network/api";
	import {
		getItem,
		StorageKeys,
		setItem
	} from "@/utils/storage";

	const state = reactive({
		list: [],  //权益数据
	})

	onLoad((option : any) => {
		// 获取全部权益列表
		getList();

		console.log("option", option)
	})
	const getList = () => {
		const options = {
			type: 2,
			data: {
				"pageNo": 100,
				"pageSize": 1,
			},
			method: 'POST',
			showLoading: true,
		}
		request(getEquityListApi, options).then((res) => {
			const data = stringToJson(res.bizContent);
			state.list = data.data
			console.log("222", data.data)
		})
	}
	const add = (equtyId) => {
		navTo(`/subpackage/after-sale/add-equity/choice-order?equtyId=${equtyId}`, true)
	}
</script>

<style scoped lang="scss">
	.content {
		width: 100%;
	}

	.item {
		width: 90%;
		margin: 20rpx auto;
		background-color: rgb(41, 199, 207);
		border-radius: 20rpx;
		padding: 20rpx;
		box-sizing: border-box;
		color: white;
		font-size: 32rpx;

	}

	.item>.title {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.add {
		background: white;
		border-radius: 10rpx;
		padding: 4rpx 6rpx;
		color: #000;
	}
</style>