<template>
	<view>
		<view class="step">
			<uni-steps active-color="#07c160" :options="options" :active="3"></uni-steps>
		</view>
		<view style="height: 130rpx;"></view>

		<view class="main">
			<view class="mainHeader">
				地理位置
			</view>

			<view class="box-pack-between mainItem">
				<view class="">
					<view class="mainItemJk">
						获取当前的地理位置、速度
					</view>
					<view class="mainItemdesc">
						接口：wx.getLocation
					</view>
					<view class="red" v-if="obj.wx_getLocation_reason">
						{{obj.wx_getLocation_reason}}
					</view>
				</view>
				<view class="flex-center">
					<!-- 已开通 -->
					<!-- 		1	待申请开通
								2	无权限
								3	申请中
								4	申请失败
								5	已开通 -->
					<block v-if="obj.wx_getLocation_status==1">
						<button @click="go_Out('wx.getLocation')" type="primary" size="mini">
							去开通
						</button>
					</block>
					<block v-else-if="obj.wx_getLocation_status==2">
						无权限
					</block>
					<block v-else-if="obj.wx_getLocation_status==3">
						申请中
					</block>
					<block v-else-if="obj.wx_getLocation_status==4">
						<text>申请失败</text>
						<button @click="go_Out('wx.getLocation')" type="primary" size="mini">
							重新开通
						</button>
					</block>
					<block v-else-if="obj.wx_getLocation_status==5">
						已开通
					</block>
				</view>
			</view>

			<view class="box-pack-between mainItem">
				<view class="">
					<view class="mainItemJk">
						打开地图选择位置
					</view>
					<view class="mainItemdesc">
						接口：wx.chooseLocation
					</view>
					<view class="red" v-if="obj.wx_chooseLocation_reason">
						{{obj.wx_chooseLocation_reason}}
					</view>
				</view>
				<view class="flex-center">
					<!-- 已开通 -->
					<block v-if="obj.wx_chooseLocation_status==1">
						<button @click="go_Out('wx.chooseLocation')" type="primary" size="mini">去开通</button>
					</block>
					<block v-else-if="obj.wx_chooseLocation_status==2">
						无权限
					</block>
					<block v-else-if="obj.wx_chooseLocation_status==3">
						申请中
					</block>
					<block v-else-if="obj.wx_chooseLocation_status==4">
						<text>申请失败</text>
						<button @click="go_Out('wx.chooseLocation')" type="primary" size="mini">重新开通</button>
					</block>
					<block v-else-if="obj.wx_chooseLocation_status==5">
						已开通
					</block>
				</view>
			</view>
			<view class="box-pack-between mainItem">
				<view class="">
					<view class="mainItemJk">
						获取用户收货地址
					</view>
					<view class="mainItemdesc">
						接口：wx.chooseAddress
					</view>
					<view class="red" v-if="obj.wx_chooseAddress_reason">
						{{obj.wx_chooseAddress_reason}}
					</view>
				</view>
				<view class="flex-center">
					<!-- 已开通 -->
					<block v-if="obj.wx_chooseAddress_status==1">
						<button @click="go_Out('wx.chooseAddress')" type="primary" size="mini">去开通</button>
					</block>
					<block v-else-if="obj.wx_chooseAddress_status==2">
						无权限
					</block>
					<block v-else-if="obj.wx_chooseAddress_status==3">
						申请中
					</block>
					<block v-else-if="obj.wx_chooseAddress_status==4">
						<text>申请失败</text>
					   <button @click="go_Out('wx.chooseAddress')" type="primary" size="mini">去开通</button>
					</block>
					<block v-else-if="obj.wx_chooseAddress_status==5">
						已开通
					</block>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import optionsData from './data.js'
	export default {
		data() {
			return {
				obj: {},
				options: optionsData.options,

			}
		},
		onShow() {
			this.getData()
		},
		methods: {

			getData() {
				this.request({
					url: "Smdcshop/privacy_interface_info",
					data: {
						admin_id: uni.getStorageSync("admin_id"),
					},
				}).then(res => {
					/* 
						"wx_getLocation_status": 5, //状态码
						1	待申请开通
						2	无权限
						3	申请中
						4	申请失败
						5	已开通
						"wx_chooseLocation_status": 5, //状态码
						1	待申请开通
						2	无权限
						3	申请中
						4	申请失败
						5	已开通
						"wx_chooseAddress_status": 5, //状态码
						1	待申请开通
						2	无权限
						3	申请中
						4	申请失败
						5	已开通
						"wx_getLocation_reason": "", //失败原因  记得做判断 有内容的时候再显示出来
						"wx_chooseLocation_reason": "", //失败原因  记得做判断 有内容的时候再显示出来
						"wx_chooseAddress_reason": "" //失败原因  记得做判断 有内容的时候再显示出来
					   */
					if (res.code == '200' || res.code == 200) {
						console.log(res, "res")
						this.obj = res.data
					}
				})
			},

			go_Out(e) {
				uni.navigateTo({
					url: "./interfaceDetail?api_name=" + e
				})
			},

		}
	}
</script>

<style>
	.main {
		padding: 0 20rpx;
	}

	.mainHeader {
		font-size: 32rpx;
		padding: 20rpx 0;
	}

	.mainItem {
		font-size: 28rpx;
		box-shadow: 0 1px 2px #f0f0f0;
		border: 1px solid #f0f0f0;
		padding: 50rpx 30rpx;
		border-radius: 6rpx;
		margin-bottom: 40rpx;
	}

	.mainItemJk {
		margin-bottom: 20rpx;
	}

	.mainItemdesc {
		color: #999;
		font-size: 26rpx;
	}
	.red{
		margin-top: 6rpx;
		color: red;
	}
</style>
