<template>
	<view class="reward-test">
		<view class="reward-test_tauto">
			<view class="reward-test_top">
				<text class="reward-test_top-tp1">分润规则测试</text>
				<text class="reward-test_top-tp2">快速测试分润规则,可以通过此功能来调试分润规则,测试结果不会保存到数据库，不会影响会员的资产,请放心使用……</text>
			</view>
		</view>
		<view class="reward-test_ul">
			<view class="reward-test_ul-li">
				<view class="reward-test_ul-li-lable">
					<text class="reward-test_ul-li-lable_t2">订单用户名</text>
					<text class="reward-test_ul-li-lable_t1">*</text>
				</view>
				<view class="reward-test_ul-li-ipt"><input v-model="form.userName" class="reward-test_ul-li-ipt_p" placeholder="请输入" /></view>
			</view>
			<view class="reward-test_ul-li">
				<view class="reward-test_ul-li-lable">
					<text class="reward-test_ul-li-lable_t2">订单金额</text>
					<text class="reward-test_ul-li-lable_t1">*</text>
				</view>
				<view class="reward-test_ul-li-ipt"><input v-model="form.amount" type="number" class="reward-test_ul-li-ipt_p" placeholder="请输入" /></view>
			</view>
			<view class="reward-test_ul-li">
				<view class="reward-test_ul-li-lable">
					<text class="reward-test_ul-li-lable_t2">测试维度</text>
					<text class="reward-test_ul-li-lable_t1">*</text>
				</view>
				<view class="reward-test_ul-li-ipt">
					<x-select v-model="form.entityId" label="测试" placeholder="请选择" type="TriggerType"></x-select>
				</view>
			</view>
			<view class="reward-test_ul-li">
				<view class="reward-test_ul-li-lable">
					<text class="reward-test_ul-li-lable_t2">实体Id</text>
				</view>
				<view class="reward-test_ul-li-ipt"><input v-model="form.ruleId" class="reward-test_ul-li-ipt_p" placeholder="请输入" /></view>
			</view>
		</view>
		<view class="reward-test_but">
			<text class="reward-test_but-t" @click="onSubmit">测试</text>
		</view>
	</view>
</template>
<script>
import ala from '@/service/ala';
export default {
	props: {
		widget: {}
	},
	data() {
		return {
			form: {
				userName: '',
				entityId: '',
				amount: 1000,
				ruleId: ''
			},
			typeOption: '',
			selectList: '',
			tableData: [],
			tableFool: false
		};
	},
	mounted() {
		this.init();
	},
	methods: {
		async init() {
			this.tableData = []
			var repones = await ala.httpGet('Api/Type/GetKeyValue?type=TriggerType')
			this.typeOption = repones
			var select = await ala.httpGet('Api/RewardRule/QueryList')
			this.selectList = select
			if (this.$route.query.id) {
				this.form.ruleId = ala.getId(this.widget.route)
			}
		},
		async onSubmit() {
			var submiyRepones = await ala.httpPost('Api/Reward/Test', this.form)
			if (submiyRepones) {
				uni.showToast({
				    title: '执行成功',
				    duration: 2000
				})
				this.tableData = submiyRepones
				this.tableFool = true
			}
		}
	}
};
</script>
<style lang="scss">
@import './var.scss';
</style>
