<template>
  <view class="page-agreement">
    <view class="popup-agreement">
      <view class="a-header">
        <text>隐私政策</text>
      </view>
      <view class="a-body">
        <scroll-view scroll-y="true" show-scrollbar="true">
			<view style="padding-bottom:25rpx">
				<text>尊敬的用户，您好</text>
			</view>
			<view>
				<text>为了加强对您个人信息的保护，根据最新法律法规要求，我们更新了隐私政策，请您仔细阅读并确认</text>
				<text @click="Go(protocols)" style="color: #3877F8">“隐私相关政策”</text>
				<text>及</text>
				<text @click="Go(protocolf)" style="color: #3877F8">“用户注册协议”</text>
				<text>我们将严格按照政策内容使用和保护您的个人信息，为您提供更好的服务，感谢您的信任。</text>
			</view>
        </scroll-view>
      </view>
      <view class="a-footer">
		  <view @click="handleSure" class="a-btn-child">
		   同意，继续使用
		  </view>
		  <view @click="handleReject" class="t-btn-child">
		    <text>不同意，退出app</text>
		  </view>
		 
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name:"Agreement",
  data() {
    return {
      userAgreement: '',
	  protocols:{
		"protocolName":"隐私协议",
		"protocolUrl":"http://ddh.yyhock.com/appStatic/protocol/ddh-private.html"
	  },
	  protocolf:{
		"protocolName":"用户服务协议",
		"protocolUrl":"http://ddh.yyhock.com/appStatic/protocol/ddh-user.html"
	  },
    }
  },
  onLoad() {
    this.init()
  },
  methods: {
    // 拒绝授权
    handleReject() {
      if (uni.getSystemInfoSync().platform === 'ios') {
        plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
      } else if (uni.getSystemInfoSync().platform === 'android') {
        plus.runtime.quit();
      }
    },
    // 同意授权
    handleSure() {
      const that = this;
      uni.setStorage({
        key: "m-agreement",
        data: 'true',
        success: function () {
          // that.Back();
		  uni.navigateBack({
			  delta: 1
		  })
        }
      })
    },

    // 初始化首页信息
    async init() {
		const self=this	
		self.$request('/setting','GET').then(res => {
			console.log(res,'settings');
			const { protocol,phone }=res.result
			if(protocol){
				const protocolList=JSON.parse(protocol)
				protocolList.map((item)=>{
					// console.log(item,'item966')
					if(item.protocolName=='隐私协议'){
						self.protocols=item
					}else if(item.protocolName=='用户服务协议'){
						self.protocolf=item
					}
				})
			}
		}).catch(err=>{
			console.log(err,'请求出错')
		})
    },
	Go(item){
		console.log(item,'items');
		const {protocolUrl,protocolName }=item
		const items={
			name:protocolName,
			url:protocolUrl
		}
		uni.navigateTo({
			url:'/pages/webview/webview?mydata='+encodeURIComponent(JSON.stringify(items))
		})
	}
  },
  onShow() {
  	this.init()
  }
}
</script>

<style lang="less" src='./index.less'></style>
