<template>
	<view class="container">
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="top flex flex-y-center box-pack-between">
					<view class="name">松鼠屋配送</view>
					
					<view class="flex-y-center">
						<block  v-if="item.status==1">
						   <view class="del">已激活</view>
						   <view class="del" @click="getActivation(item.id,2)">重新激活</view>
						</block>
						
						<block v-else>
						    <view class="del" @click="getActivation(item.id,1)">激活</view>
						</block>
					</view>
					
				</view>
		<!-- 		<navigator :url="`/saomaDiancan/editPrinter/editPrinter?id=${item.id}`"
					class="content flex flex-y-center" hover-class="nav-hover">
					<view class="cell flex flex-y-center">
						<view class="title">打印机类型：</view>
						<view class="desc">{{item.type==1?'1-365':item.type==2?'易联云(型号:k4)':
						item.type==3?'飞鹅(型号:FP-58W)':item.type==4?'喜讯(型号:XP58IIQR)':''}}</view>
					</view>
					<view class="cell flex flex-y-center arr-r">
						<view class="title">打印机位置：</view>
						<view class="desc">{{item.location==1?'前台':'后厨'}}</view>
					</view>
				</navigator> -->
			</view>
			<view class="no-more">---没有更多内容了---</view>
		</view>
<!-- 		<view class="footer-bar">
			<view class="content flex flex-center">
				<navigator url="/saomaDiancan/editPrinter/editPrinter" class="btn">+新增设备</navigator>
			</view>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				store_id: "",
				list: [],
				page: 1,
				is_bottom: false
			}
		},
		onLoad(options) {
			this.store_id = options.store_id;
			this.getData()
		},
		methods: {
			
			
			getActivation(id,type) {
				
				if(type==1){
					var url= 'Smdcshop/squirrel_wecashier';
				}else{
					var url= 'Smdcshop/squirrel_update';
				}
				
				uni.showModal({
					title: '提示',
					content:type==1? '是否要激活？':'是否要重新激活？',
					showCancel: true,
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.request({
								url:url,
								data: {
									admin_id: uni.getStorageSync('admin_id'),
									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: () => {}
				});
			},

			getData() {
				this.request({
					url: 'Smdcshop/squirrel_index',
					data: {
						admin_id: uni.getStorageSync('admin_id'),
					},
				}).then(res => {
					if (res.code == 200 && res.data.length) {
						this.list =res.data
					}
				})
			}

		}
	}
</script>

<style>
	@import url("./static/css/common.css");

	.del {
		height: 44rpx;
		line-height: 44rpx;
		padding: 0 25rpx;
		font-size: 24rpx;
		background-color: #FF5722;
		margin-right: 25rpx;
		color: #fff;
		border-radius: 20rpx;
	}

	page {
		background-color: #F4F5F7;
	}

	.list {
		padding: 30rpx 25rpx;
	}

	.list .item {
		border-radius: 8rpx;
		overflow: hidden;
		padding-left: 30rpx;
		border-left: 8rpx solid #247EFF;
		background-color: #fff;
		margin-bottom: 30rpx;
	}

	.list .item .top {
		height: 120rpx;
		border-bottom: 1rpx solid #f5f5f5;

	}

	.list .item .top .name {
		font-size: 30rpx;
		line-height: 80rpx;
		font-weight: bold;
	}

	.list .item .top .type-btn {
		zoom: 0.7;
		margin-right: 25rpx;
	}

	.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>
