<template>
	<view class="">
		<no-none v-if='list.length<=0'></no-none>
		
		<view class="list" v-else>
			
			<navigator :url="`./addXcx?id=${item.id}`" class="item" style="border: none;" v-for="(item,index) in list" :key="index">
				
				<view class="box-pack-between">
					<view class="name box-pack-between flex-grow-1">
						<text>{{item.name}}</text>
						
						<view class="flex-y-center">
							<view class="del" @click.stop="del(item.id)">删除</view>
						</view>
						
		<!-- 				<view class="flex-center ft28" 
						:style="{color:item.type==1?'#07c160':'#1E9FFF'}" 
						style="padding-right: 20rpx;"
						  >
							{{item.type==1?'微信':item.type==2?'支付宝':''}}
						</view> -->
					</view>
				</view>
				
				<view class="content">
					<view class="flex flex-y-center">
						<view class="cell flex flex-y-center " style="width:100%">
							<view class="title">来源：</view>
							<view class="desc" :style="{color:item.type==1?'#07c160':'#1E9FFF'}">
							{{item.type==1?'微信':item.type==2?'支付宝':''}}</view>
						</view>
					</view>
					
					<view class="flex flex-y-center"  style="margin-top: 16rpx;">
						<view class="cell flex flex-y-center">
							<view class="title">介绍：</view>
							<view class="desc">{{item.desc}}</view>
						</view>
					</view>
	
					<view class="flex flex-y-center" style="margin-top: 16rpx;">
						<view class="cell flex flex-y-center " style="width:100%">
							<view class="title">appid：</view>
							<view class="desc">{{item.appid}}</view>
						</view>
					</view>

					<view class="flex flex-y-center" style="margin-top: 16rpx;">
						<view class="cell flex flex-y-center " style="width:100%">
							<view class="title">跳转路径：</view>
							<view class="desc">{{item.pages}}</view>
						</view>
					</view>

					<view class="flex flex-y-center" style="margin-top: 16rpx;">
						<view class="cell flex flex-y-center " style="width:100%">
							<view class="title">时间：</view>
							<view class="desc">{{item.create_time}}</view>
						</view>
					</view>
				</view>
			</navigator>
		</view>
		<view style="height: 150rpx;"></view>
		<view class="footer-bar">
			<view class="content flex flex-center">
				<navigator url="./addXcx" class="btn">添加跳转小程序</navigator>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],				
				admin_id:'',
			}
		},
		
		onLoad() {
			this.admin_id = uni.getStorageSync("admin_id");
		},
		onShow() {
			this.getData();
		},
		methods:{
			
			getData() {
				this.request({
					url: 'Smdcshop/applet_data',
					data: {
						admin_id: this.admin_id,
					}
				}).then(res => {
					if (res.code == 200) {
						this.list = res.data;
					}
				})
			},
			
			
			del(id) {
				uni.showModal({
					title: '提示',
					content: '是否要删除？',
					showCancel: true,
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.request({
								url: 'Smdcshop/applet_delect',
								data: {
									id: id,
								},
							}).then(res => {
								console.log(res, "res")
								if (res.code === 200 || res.code === "200") {
									uni.showToast({
										title: "删除成功",
										icon: "none",
									})
									setTimeout(() => {
										this.getData()
									}, 2000)
								}
							}).catch((res) => {
								uni.showToast({
									title: res.message,
									icon: "none",
								})
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
		}
	}
</script>

<style>
	@import url("../static/css/common.css");
	page {
		background-color: #F4F5F7;
	}
	.del {
		height: 44rpx;
		line-height: 44rpx;
		padding: 0 15rpx;
		font-size: 24rpx;
		background-color: #FF5722;
		margin-right: 25rpx;
		color: #fff;
		border-radius: 4rpx;
	}
	.list {
		padding: 10rpx 25rpx;
	}
	
	.list .item {
		border-radius: 8rpx;
		overflow: hidden;
		padding-left: 30rpx;
		border-left: 8rpx solid #247EFF;
		background-color: #fff;
		margin-bottom: 30rpx;
	}
	
	.list .item .name {
		height: 80rpx;
		border-bottom: 1rpx solid #f5f5f5;
		font-size: 30rpx;
		line-height: 80rpx;
		font-weight: bold;
	}
	
	.list .item .content {
		padding: 20rpx 0 24rpx;
	}
	
	.list .item .content .cell {
		/* flex: none; */
		/* width: 50%; */
		box-sizing: border-box;
		padding-right: 30rpx;
		font-size: 26rpx;
		line-height: 37rpx;
		color: #666;
	}
	
	.list .item .content .cell .title {
		color: #99A0AD;
	}
</style>
