<template>
	<view class="mt" style="overflow-x: hidden;">
		<!-- <image :src="gbyh" class="mt50" style="width: 400rpx;height: 54rpx;margin-left: 50rpx;" mode=""></image> -->
		<view class="flex_column flex_items" style="width: 100%;">
			<!-- <text class="bolder mt120" style="font-size:170rpx;color: #333;">美团</text> -->
			<view class="mt120 flex_column flex_items" style="color: #4d4d4d;">
				<image :src="mtwz" style="width: 330rpx;height: 162rpx;" mode=""></image>
				<view class="flex_start flex_items f36 mt60">
					<text>美食一键送达</text>
					<text class="ml10">让生活更有滋味</text>
				</view>
			</view>
			<view class="flex_items flex_center pos" style="overflow: hidden;width: 100%;margin-top: -120rpx;">
				<image class="" :src="dsimg" style="width:776rpx;" mode="widthFix"></image>
			</view>
			<view @click="goout('1')" class="f-center btnn f36 pos"
				style="margin-top: -150rpx;color: #FF8300;line-height: 146rpx;z-index: 5;">
				我要点外卖
			</view>
			<view @click="goout('2')" class="f-center btnn f36 mt40 pos"
				style="color: #FF8300;line-height: 146rpx;z-index: 5;">
				我要到店吃
			</view>
			<view class="f24 mt30 pb40" style="color: #4d4d4d;">本页面内的服务由成都蓝色兄弟网络科技有限公司提供</view>
		</view>
		<!-- tk -->
		<view v-if="modalShow" class="flex_items flex_center"
			style="width: 100%;height: 100vh;background: rgba(0,0,0,.5);position: fixed;left: 0;top: 0;z-index: 5;">
			<view class="bgwhite tkk flex_column flex_items ptb30">
				<text class="f36 bold" style="color: #585858;">请输入账号</text>
				<input type="text" class="mt30 ptb20 plr20" v-model="usernumber" placeholder="账号"
					style="text-align: left;border: 1px solid #e9e9e9;background:#d4d4d4;width:70%;">
				<view class="mt10 f24" style="color:#a9a6a6;width: 65%;">访客登陆账号为：13902、13903、13904、13905、13906</view>
				<view class="flex_start flex_items mt20 bte9s ptb20" style="width: 80%;">
					<view @click="out" class="flex_items flex_center"
						style="width: 49%;height: 40rpx;border-right: 1px solid #e9e9e9;">
						<text>取消</text>
					</view>
					<view @click="yes" style="width: 50%;height: 40rpx;color: #167eef;">
						<text>确认</text>
					</view>
				</view>
			</view>
		</view>
		<Ywatermark :info="'蓝色兄弟'"></Ywatermark>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				usernumber: "",
				modalShow: false,
				types: 1,
				imgUrl: "",
				mtwz: require("@/static/mtwz.png"),
				dsimg: require("@/static/ds.png"),
				gbyh: require("@/static/gbyh.png"),
			}
		},
		onLoad(options) {
			console.log(options)
			this.usernumber = options.user
			this.imgUrl = this.api.imgUrl
		},
		methods: {
			goout(types) {
				if (types == '1') {
					uni.navigateTo({
						url: "/pages/mt/preferential2?user=" + this.usernumber
					})
					// uni.showLoading({
					// 	title: "登录中..."
					// })
					// this.api.mtlogin({
					// 	account: "zhangsan",
					// 	password: "123456"
					// }).then((res) => {
					// 	console.log(res)
					// 	if (res.data.code == '200') {
					// 		uni.setStorageSync('token', res.data.data.token)
					// 		if (types == '2') {
					// 			this.qudian(res.data.data.user_number)
					// 		} else {
					// 			uni.navigateTo({
					// 				url: "/pages/mt/preferential?user=" + res.data.data.user_number
					// 			})
					// 		}
					// 	} else {
					// 		uni.showToast({
					// 			title: res.data.message,
					// 			icon: 'none'
					// 		})
					// 	}
					// })
				} else {
					// this.modalShow = true
					this.qudian(this.usernumber)
				}
				return false
				let that = this
				this.types = types
				this.usernumber = ""
				that.modalShow = true
			},
			qudian(user) {
				this.api.gomt({
					user_number: user,
					type: 2,
					dinner_type: ''
				}).then((res) => {
					console.log(res)
					if (res.data.code == 200) {
						uni.hideLoading()
						var href = res.data.url
						window.open(href, '_self')
					} else {
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}
				})
			},
			out() {
				this.modalShow = false
			},
			yes() {
				if (this.usernumber == "") {
					uni.showToast({
						title: "账号不能为空",
						icon: "none"
					})
					return false
				}
				this.submit(this.types, this.usernumber)
			},
			submit(types, usernumber) {
				uni.showLoading({
					title: "登录中..."
				})
				// https://mtapi.86698.cn
				uni.request({
					url: "https://mtapi.86698.cn/api/login?user_number=" + usernumber + "&type=" + types,
					method: 'get',
					header: {
						'content-type': 'application/json',
					},
					success: res => {
						console.log(res)
						uni.hideLoading()
						var href = res.data.url
						window.open(href, '_self')
					},
					fail: (error) => {
						console.log(error);
					},
				})
			}
		}
	}
</script>

<style>
	.mt {
		background-image: url('https://mtweb.86698.cn/static/images/mtbg.png');
		background-size: 100% 100%;
		width: 100%;
		height: 100vh;
		position: fixed;
		left: 0;
		top: 0;
		overflow-y: auto;
	}

	.mask {
		width: 100%;
		height: 100vh;
		position: fixed;
		left: 0;
		top: 0;
		z-index: 10;
		background: rgba(0, 0, 0, .5);
	}

	.tkk {
		width: 80%;
		background-color: #fff;
		text-align: center;
		border-radius: 3px;
		overflow: hidden;
	}

	.btnn {
		background-image: url('~@/static/btnn.png');
		background-size: 100% 100%;
		width: 488rpx;
		height: 146rpx;
	}
</style>