<template>
	<view class="index">
		<view class="indexone_item flex-between" @click="clickJump(5)">
			<view class="indexone_itemone flex-start">
				<image class="indexone_itemoneimage" :src="form.avatar" mode=""></image>
				<view class="flex-colum-start">
					<text class="flex-colum-start_one">{{form.title}}</text>
					<text class="flex-colum-start_tow">{{form.label || ''}}</text>
				</view>
			</view>
			<u-icon name="arrow-right" color="#999999" size="18"></u-icon>
		</view>
		<view class="indexone_item flex-between" @click="clickJump(3)">
			<view class="indexone_itemone flex-start">
				<image src="https://ointmentweapp.oss-cn-beijing.aliyuncs.com/icon/shop2.png" mode=""></image>
				<text>创建会员卡</text>
			</view>
			<u-icon name="arrow-right" color="#999999" size="18"></u-icon>
		</view>
		<view class="indexone_item flex-between" @click="clickJump(5)">
			<view class="indexone_itemone flex-start">
				<image src="https://ointmentweapp.oss-cn-beijing.aliyuncs.com/icon/shop3.png" mode=""></image>
				<text>门店设置</text>
			</view>
			<u-icon name="arrow-right" color="#999999" size="18"></u-icon>
		</view>
		<view class="indexone_item flex-between" @click="clickJump(6)">
			<view class="indexone_itemone flex-start">
				<image src="@/static/shop/shop4.png" mode=""></image>
				<text>推广二维码</text>
			</view>
			<u-icon name="arrow-right" color="#999999" size="18"></u-icon>
		</view>
		<view class="indexone_item flex-between" @click="clickJump(8)">
			<view class="indexone_itemone flex-start">
				<image src="@/static/shop/shop5.png" mode=""></image>
				<text>商城订单</text>
			</view>
			<u-icon name="arrow-right" color="#999999" size="18"></u-icon>
		</view>
		<view class="indexone_item flex-between" @click="clickJump(9)">
			<view class="indexone_itemone flex-start">
				<image src="@/static/shop/shop6.png" mode=""></image>
				<text>商城管理</text>
			</view>
			<u-icon name="arrow-right" color="#999999" size="18"></u-icon>
		</view>
		<view class="indexone_items" style="background: #6699FF;color: #FFFFFF;" @click="clickJump(7)">
			切换账号
		</view>
		<view class="indexone_items" @click="clickJump(4)">
			退出登录
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				form: {}
			}
		},
		async onShow() {
			this.userstoredetail()
		},
		methods: {
			async userstoredetail() {
				let res = await this.api.userstoredetail()
				this.form = res.data
				this.lnglat = res.data.lat + '-' + res.data.lng
			},
			clickJump(e) {
				switch (e) {
					case 0:
						uni.pro.navigateTo('shop/create')
						break;
					case 1:
						uni.pro.navigateTo('shop/createcap')
						break;
					case 2:
						uni.pro.navigateTo('shop/upload')
						break;
					case 3:
						uni.pro.navigateTo('shop/member')
						break;
					case 4:
						this.userlogout()
						break;
					case 5:
						uni.pro.navigateTo('shop/store')
						break;
					case 6:
						uni.pro.navigateTo('shop/promotion')
						break;
					case 7:
						uni.pro.navigateTo('shop/indexes')
						break;
					case 8:
						uni.pro.navigateTo('mall/index')
						break;
					case 9:
						uni.pro.navigateTo('mailproject/index')
						break;
				}
			},
			async userlogout() { //退出登录
				uni.showModal({
					title: '注意',
					content: '确定要退出登录吗？',
					success: async (res) => {
						console.log(111)
						if (res.confirm) {
							try {
								let data = await this.api.userlogout();
								console.log(data)
								if (data.code == 1) {
									uni.cache.clear();
									uni.reLaunch({
										url: '/pages/login/login'
									});
								}
							} catch (e) {
								//TODO handle the exception
							}

						}
					}
				});

			},

		}
	}
</script>

<style lang="scss">
	page {
		background: #FBFBFA;
	}

	.index {
		.indexone_items {
			width: 80%;
			padding: 16rpx 0;
			margin: 40rpx auto;
			text-align: center;
			background: #E0E0E0;
			border-radius: 16rpx;
			font-size: 32rpx;
			font-family: SourceHanSansCN-Regular, SourceHanSansCN;
			font-weight: 400;
			color: #666666;
		}

		.indexone_item {
			padding: 24rpx 32rpx;
			border-bottom: 2rpx solid #E5E5E5;

			.indexone_itemone {
				image {
					width: 38rpx;
					height: 38rpx;
				}

				.indexone_itemoneimage {
					width: 112rpx;
					height: 112rpx;
				}

				.flex-colum-start {
					.flex-colum-start_one {
						width: 100%;
						overflow: hidden;
						text-overflow: ellipsis;
						font-size: 32rpx;
						font-family: SourceHanSansCN-Medium, SourceHanSansCN;
						font-weight: 500;
						color: #333333;
					}

					.flex-colum-start_tow {
						overflow: hidden;
						margin-top: 16rpx;
						font-size: 32rpx;
						font-family: SourceHanSansCN-Regular, SourceHanSansCN;
						font-weight: 400;
						color: #999999;
					}
				}

				text {
					margin-left: 32rpx;
					font-size: 28rpx;
					font-family: SourceHanSansCN-Regular, SourceHanSansCN;
					font-weight: 400;
					color: #333333;
				}
			}
		}
	}
</style>