<template>
	<view>
		<view class="titlelist" style="position: relative;" v-for="weixin in weixinList" :key="weixin.id">
			<uni-list-item :title="weixin.workName" @click="tranByWorkName(weixin.id,weixin.workName)"></uni-list-item>
		</view>
	</view>
</template>

<script>
	import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
	export default {
		components: {
			uniListItem,
		},
		data() {
			return {
				weixinList:[]
			}
		},
		onShow() {
			this.globalUser = uni.getStorageSync("globalUser");
			var token = uni.getStorageSync("token");
			this.level = uni.getStorageSync("level");
			if (token.length > 1) {
				this.worker();
			} else {
				uni.reLaunch({
					url: '../Login/Login',
				});
			}
		},
		methods: {
			worker(){
				var newparm = uni.getStorageSync("newparm");
				if (newparm.toString().length > 1) {
					if (newparm.openId.length > 1) {
						var that = this;
						var serverUrl = that.serverurl;
						var token = uni.getStorageSync("token");
						var openId = newparm.openId;
						uni.request({
							url: serverUrl + "/TWeixin/getWeixinList?openId="+openId,
							method: "GET",
							header: {
								'token': token
							},
							success: (Result) => {
								var res = Result;
								if (res.data.code == true) {
									this.weixinList = res.data.data;
								} else {
									uni.showModal({
										title: '提示',
										content: res.data.message,
									});
								}
							}
						});
					}
				}
			},
			tranByWorkName(id,workName){
				uni.navigateTo({
				    url: './worker?id='+ id + "&workName= "+workName
				});
			}
		}
	}
</script>

<style>
.titlelist {
		color: #363D44;
		font-size: 16upx;
		font-family: "PingFang-SC-Medium";
	}
</style>
