settings.vue 4.8 KB
<template>
	<view style="background-color: #F5F7FC; padding-top: 15rpx; height: 100vh; ">
		<view class="qh-list-c" @click="onLogout()">
			<view style="display: flex;">
				<text class="list-text">账号注销</text>
			</view>
			<image src="@/static/mine_icons/arrow_right.png"
				style="width: 50rpx; height: 50rpx; margin-right: 30rpx;" />
		</view>

		<view class="qh-list-c" @click="onUserAgreement()">
			<view style="display: flex;">

				<text class="list-text">用户协议</text>
			</view>
			<image src="@/static/mine_icons/arrow_right.png"
				style="width: 50rpx; height: 50rpx; margin-right: 30rpx;" />
		</view>
		<view class="qh-list-c" @click="onPrivacyPolicy()">
			<view style="display: flex;">
				<text class="list-text">隐私政策</text>
			</view>
			<image src="@/static/mine_icons/arrow_right.png"
				style="width: 50rpx; height: 50rpx; margin-right: 30rpx;" />
		</view>
		<view class="qh-list-c" @click="showUpdateVersion()">
			<text class="update_text">{{this.versionName}}</text>
			<view style="display: flex; " >
				<text style="font-size: 27rpx;">{{this.updateInfoStr}}</text>
				<image src="@/static/mine_icons/arrow_right.png"
					style="width: 50rpx; height: 50rpx; margin-right: 30rpx;" />
			</view>
		</view>

		<button style="background-color: white; margin: 35rpx; color: #469bf4;" @click="bindLogout()"> 
		{{ this.hasLogin ? "退出登录" : '登陆/注册' }}</button>

	</view>
</template>

<script>
	import {
		default as http
	} from "@/utils/http.js";
	import {
		updateUseModal,
		compare
	} from '@/utils/check_update.js';
	import {
		default as app_config
	} from '@/utils/app.js';
	import loginHelper from "../../utils/loginHelper.js"
	export default {
		data() {
			return {
				app_config,
				hasLogin : false,
				updateInfoStr : "已是最新版本",
				versionData : null,
				versionName : app_config.app_info.AppName,
			}
		},
		onShow() {
			this.hasLogin = loginHelper.hasLogin()
			console.log("onShow");
			// this.updateVersion();
		},
		methods: {
			bindLogout() {
				{
					loginHelper.logout();
					uni.reLaunch({
						url: '/pages/mine/mine'
					})
				}
			},
			onLogout() {
				if (!loginHelper.hasLogin()) {
					uni.navigateTo({
						url: '/pages/login_pwd/login_pwd',
					});
				} else {
					uni.navigateTo({
						url: "/pages/logout/logout",
					});
				}
			},
			onUserAgreement() {
				let tempData = {
					url: app_config.ppolicy_user,
					title: "用户协议"
				}
				uni.navigateTo({
					url: `/pages/normal_webview/normal_webview?info=${encodeURIComponent(JSON.stringify(tempData))}`
				})
			},
			onPrivacyPolicy() {
				let tempData = {
					url: app_config.ppolicy_app,
					title: "隐私政策"
				}
				uni.navigateTo({
					url: `/pages/normal_webview/normal_webview?info=${encodeURIComponent(JSON.stringify(tempData))}`
				})
			},
			showUpdateVersion() {
				if(this.versionData) {
					updateUseModal({
						title: "更新",
						contents: this.versionData.Version_Content || '',
						is_mandatory: false,
						url: this.versionData.Package_Url,
						platform: 'android',
						type: "pkg" // 安装包类型
					});
				}
			},
			async updateVersion() {
				let appInfo = app_config.app_info;
				// #ifdef APP-PLUS
				let query_data = `query{
								update_app_version(App_Code:${JSON.stringify(appInfo.Version)}) {
								  App_Code
								  App_Name
								  Sys_Code
								  Sys_Name
								  Version_Code
								  Version_Type
								  Version_Content
								  Package_Url
								  Package_Weight
								  Version_Num
								  Update_Way
								  Download_Way
								  Update_Time
								  Publish_Time
								  Sys_Version
								  Promoter_Id
								}
							  }`;
				console.info(query_data);
				let result = await http.gql({
					query: query_data
				})

				console.info(result);
				//处理返回请求
				if (result && result.data && result.data.update_app_version) {
					if (result.data.update_app_version.Error) {
						uni.showToast({
							icon: "none",
							title: result.data.update_app_version.Error,
						});
					} else {
						this.versionData = result.data.update_app_version;
						if (this.versionData && this.versionData.Package_Url) {
							this.updateInfoStr = "更新版本";
						} else {
							this.updateInfoStr = "已是最新版本";
						}
					}
				}
				// #endif
				// #ifdef MP-WEIXIN
				this.versionName = app_config.app_info.AppName
				this.updateInfoStr = appInfo.Version
				// #endif
			}
		}

	}
</script>

<style>
	button::after {
		border: none
	}

	.qh-list-c {
		margin-top: 4rpx;
		background-color: white;
		display: flex;
		height: 100rpx;
		font-weight: bold;
		justify-content: space-between;
		align-items: center;
	}
	
	.update_text {
		font-size: 33rpx; 
		color: black; font-weight: bold;
		margin-left: 35rpx;
	}

	.list-text {
		margin-left: 35rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: black;
	}
</style>