<template>
    <view class='container'>
		<view class="list">
			<view class="module">
				<view class="title">
					<text>公共模块</text>
				</view>
				<view>
					<view class="item">
						<u-button type="primary" text="组件" @click="$wskj.to('/pages/com')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="无网络页面" @click="$wskj.to('/pages/no_network')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="检测更新弹窗" @click="onCheckUpdate"></u-button>
						<updateApp :time="Math.random()" :packageUrl="updateContent.downloadurl" :newVersion="updateContent.newversion" :force="updateContent.enforce"></updateApp>
					</view>
					<view class="item">
						<u-button type="primary" text="微信H5定位" @click="onGetLocation"></u-button>
					</view>
				</view>
			</view>
			
			<view class="module">
				<view class="title">
					<text>登录模块</text>
				</view>
				<view>
					<view class="item">
						<u-button type="primary" text="app登录" @click="$wskj.to('/pages/login/applogin/index')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="app注册" @click="$wskj.to('/pages/login/applogin/register')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="app忘记密码" @click="$wskj.to('/pages/login/applogin/forgotpassword')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="小程序登录" @click="$wskj.to('/pages/login/wechatlogin')"></u-button>
					</view>
				</view>
			</view>
			
			<view class="module">
				<view class="title">
					<text>首页模块</text>
				</view>
				<view>
					<view class="item">
						<u-button type="primary" text="搜索页" @click="$wskj.to('/pages/home/search')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="评论列表页" @click="$wskj.to('/pages/home/commentlist')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="消息页" @click="$wskj.to('/pages/home/msg/index')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="选择城市" @click="$wskj.to('/pages/home/selectcity')"></u-button>
					</view>
				</view>
			</view>
			
			<view class="module">
				<view class="title">
					<text>我的模块</text>
				</view>
				<view>
					<view class="item">
						<u-button type="primary" text="个人资料" @click="$wskj.to('/pages/my/userinfo')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="设置页" @click="$wskj.to('/pages/my/setting/index')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="修改密码" @click="$wskj.to('/pages/my/setting/modifypaypassword')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="订单列表页" @click="$wskj.to('/pages/my/order/orderlist')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="收货地址" @click="$wskj.to('/pages/my/address')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="添加收货地址" @click="$wskj.to('/pages/my/addaddress')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="关于我们" @click="$wskj.to('/pages/my/aboutme')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="意见反馈" @click="$wskj.to('/pages/my/feedback')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="足迹" @click="$wskj.to('/pages/my/footprint')"></u-button>
					</view>
					<view class="item">
						<u-button type="primary" text="积分记录" @click="$wskj.to('/pages/my/jifenrecord')"></u-button>
					</view>
				</view>
			</view>
		</view>
    </view>
</template>

<script>
import updateApp from "@/components/updateapp.vue"
export default {
    data() {
        return {
			updateShow: false,
			updateContent: {
				downloadurl: ''
			}
        };
    },
	components: {
		updateApp
	},
	methods: {
		onCheckUpdate(){
			this.$wskj.checkUpdateApp().then(res => {
				// console.log(res)
				this.updateContent = res.data.version_data
			}).catch(err => {
				// console.log(err)
				this.$u.toast(err.msg || '发生错误')
			})
		},
		async onGetLocation(){
			const weixinSdk = await this.$getWeixinSdk()
			this.$wxSdk.ready(() => {
				this.$wxSdk.getLocation({
					type: 'wgs84', // 默认为wgs84的 gps 坐标，如果要返回直接给 openLocation 用的火星坐标，可传入'gcj02'
					success: (res) => {
						console.log('位置', res)
					},
					fail: (err) => {
						console.log('定位错误', err)
					}
				})
			});
		}
	}
};
</script>

<style scoped>
	.list {
		padding: 20rpx
	}
	.module {
		margin-bottom: 50rpx;
	}
	.title {
		margin-bottom: 20rpx;
		font-weight: bold;
	}
	.item {
		margin-bottom: 20rpx;
	}
</style>
