<template>
	<view class="page" style="background:url('../../static/bg.png');">
		<!-- 优惠券tab -->
		<view class="coupon-tab">
			<view class="tab" :class="{'action':TabShow==='1'}" @click="Gettbtraininfo('1')">
				<view class="tab-title">品牌培训</view>
				<view class="tab-title-small">免费培训</view>
				<view class="line"></view>
			</view>
			<view class="tab" :class="{'action':TabShow==='2'}" @click="Gettbtraininfo('2')">
				<view class="tab-title">技能培训</view>
				<view class="tab-title-small">提高技能</view>
				<view class="line"></view>
			</view>
			<view class="tab" :class="{'action':TabShow==='3'}" @click="Gettbtraininfo('3')">
				<view class="tab-title">等级证书</view>
				<view class="tab-title-small">初中高级</view>
				<view class="line"></view>
			</view>
		</view>
		<!-- 优惠券列表 -->
		<view class="coupon-list">
			<view class="list">
				<view class="integral-payment">
					<view class="list" @click="GoodsDetails(item.id)" v-for="item in dataList">
						<view class="title">
							<image :src="BASE_URL+ item.icon[0].url||' ../../static/home4-icon.png'"></image>
						</view>
						<view class="mess">
							<text>{{item.name}}</text>
							<image src="../../static/right1.png"></image>
						</view>
					</view>
				</view>
				<view class="my-phone">
					<view>客服电话：654564</view>
					<view>彭州市人社局监督电话：541516</view>
					<view>备案号：6556121212</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
		import BASE_URL from '@/common/config.js'
	export default {
		data() {
			return {
				BASE_URL,
				TabShow: "1",
				isDes: false,
				dataList: [],
				query: {
					type: "1",
					currentPage: 1,
					pageSize: 10
				}
			};
		},
		onLoad() {
			this.Gettbtraininfo("1");
		},
		methods: {
			Gettbtraininfo(nameType) {
				this.query.type = nameType;
				this.TabShow = nameType;
				this.dataList = [];
				console.log(this.query);
				this.API.Gettbtraininfo(this.query).then(res => {
					if (res.code == 200) {
						//this.dataList = res.data.list;
						this.dataList = res.data.list.map(res => {
							res.icon= JSON.parse(res.icon);
							return res;
						});
						console.log(this.dataList);
					}
				});
			},
			/**
			 * 优惠券tab点击
			 * @param {Number} type
			 */
			onCouponTab(type) {
				this.TabShow = type;
			},
			/**
			 * 去使用点击
			 */
			GoodsDetails(id) {
				uni.navigateTo({
					url: '/pages/GoodsDetails/GoodsDetails?id=' + id
				})
			}
		}
	};
</script>

<style scoped lang="scss">
	@import 'MyCoupon.scss';
</style>
