index.vue 1.6 KB
<template>
	<view class="main">
		<p>欢迎使用设备乐</p>
		<view class="top" @click="have(1)">
			<image src="http://equiphappy.shs.broing.cn/assets/miniprogram/bg1.png" style="width: 686rpx;
height: 320rpx;" mode=""></image>
		</view>
		<view class="top" @click="have(2)">
			<image src="http://equiphappy.shs.broing.cn/assets/miniprogram/bg2.png" style="width: 686rpx;
height: 320rpx;" mode=""></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				code: "",
			}
		},
		onShow() {
			wx.login({
				provider: 'weixin', //使用微信登录
				success(res) {
					console.log(res);
				},
				complete(res) {
					console.log(res);
					this.code = res.code
					uni.$u.http.get(`/api/common/code?code=${this.code}`).then((res) => {
						uni.hideLoading()
						uni.setStorageSync('token', res.data.token || '')
					}).catch(err => {
						console.log(err);
					})
				}
			});
		},
		methods: {
			have(val) {

				uni.$u.http.post('/api/common/choose_group', {
					type: val
				}).then(r => {
					wx.hideLoading()
					console.log(r);
					if (val == 1) {
						uni.navigateTo({
							url: `/pages/index/choose?val=买`
						})
					} else {
						uni.navigateTo({
							url: `/pages/index/choose?val=卖`
						})
					}

				}).catch(err => {
					console.log(err);
				})


			},
		}
	}
</script>

<style scoped lang="scss">
	.main {
		background: #f6f6f6ff;
		height: 100vh;
		margin-left: 5%;

		p {
			color: #000000e6;
			font-size: 56rpx;
			font-weight: 500;
			margin: 132rpx 0 74rpx 0;
		}

		.top {
			height: 320rpx;
			margin: auto;
			border-radius: 16rpx;
			margin-bottom: 64rpx;
		}
	}
</style>