<template>
	<view>
		<!-- <list>
		    注意事项: 不能使用 index 作为 key 的唯一标识 -->
		    <!-- <cell v-for="(item, index) in sugarList" :key="item.id">
		      <text>{{item.productName}}</text>
		    </cell>
		  </list> --> 
		  <view class="" style="padding: 10upx;">
		  	
		  </view>
		  <view class="sugar" v-for="(item,index) in sugarList" :key="index">
		  	{{item.productName}}
		  </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				sugarList:[]
			}
		},
		onShow() {
			var token = uni.getStorageSync("token");
			if (token.length > 1) {
				this.selectSugarList();
			} else {
				uni.reLaunch({
					url: '../Login/Login',
				});
			}
		},
		methods: {
			selectSugarList(){
				var globalUser = uni.getStorageSync("globalUser");
				var token = uni.getStorageSync("token");
				uni.request({
					url: this.serverurl + '/TSugarDo/selectSugarList',
					data: {
						"adminId": globalUser.id
					},
					header: {
						'token': token
					},
					method: "GET",
					success: (res) => {
						this.sugarList = res.data.data;
					},
				});
			}
		}
	}
</script>

<style>
	.sugar{
		padding-top: 8upx;
		padding-bottom: 8upx;
		text-align:center;
		color: #363D44;
		font-size: 28upx;
		font-family: "PingFang-SC-Medium";
	}
</style>
