setting-container.vue 6.5 KB
<template>
	<view class="setting">
		<view class="cell top">
			<u-cell-group :border="false">
				<u-cell-item @click="link('account')" :border-bottom="true" title="账号安全中心"
					:title-style="{padding:'0 0 0 14rpx', color:'rgba(0,0,0,0.9)', fontSize:'34rpx'}" :arrow="true"
					arrow-direction="right">
				</u-cell-item>
				<!-- <u-cell-item @click="link('identity')" :border-bottom="true" title="我的身份"
					:title-style="{padding:'0 0 0 14rpx', color:'rgba(0,0,0,0.9)', fontSize:'34rpx'}" :arrow="true"
					arrow-direction="right" value="求职者">
				</u-cell-item> -->
				<u-cell-item @click="link('policy')" :border-bottom="true" title="用户政策"
					:title-style="{padding:'0 0 0 14rpx', color:'rgba(0,0,0,0.9)', fontSize:'34rpx'}" :arrow="true"
					arrow-direction="right">
				</u-cell-item>
				<u-cell-item @click="link('agreement')" :border-bottom="true" title="隐私协议"
					:title-style="{padding:'0 0 0 14rpx', color:'rgba(0,0,0,0.9)', fontSize:'34rpx'}" :arrow="true"
					arrow-direction="right">
				</u-cell-item>
				<u-cell-item @click="link('zs')" :border-bottom="true" title="知识产权保护规则"
					:title-style="{padding:'0 0 0 14rpx', color:'rgba(0,0,0,0.9)', fontSize:'34rpx'}" :arrow="true"
					arrow-direction="right">
				</u-cell-item>
				<!-- <u-cell-item @click="link('cancel')" :border-bottom="true" title="注销账号"
					:title-style="{padding:'0 0 0 14rpx', color:'rgba(0,0,0,0.9)', fontSize:'34rpx'}" :arrow="true"
					arrow-direction="right">
				</u-cell-item> -->
			</u-cell-group>
		</view>

		<view class="cell bottom">
			<u-cell-group :border="false">
				<u-cell-item :border-bottom="true" :title="version"
					:title-style="{padding:'0 0 0 14rpx', color:'rgba(0,0,0,0.9)', fontSize:'34rpx'}" :arrow="false">
				</u-cell-item>
				<u-cell-item @click="link('loginOut')" :border-bottom="true" title="退出登录"
					:title-style="{padding:'0 0 0 14rpx', color:'rgba(0,0,0,0.9)', fontSize:'34rpx'}" :arrow="true"
					arrow-direction="right">
				</u-cell-item>
			</u-cell-group>

		</view>

	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	export default {
		data() {
			return {
				version: '',
				service: "https://hropublic.oss-cn-beijing.aliyuncs.com/APP/yxly/%E6%A0%A1%E4%BC%81%E8%81%8C%E9%80%9A%E8%BD%A6%E7%94%A8%E6%88%B7%E6%9C%8D%E5%8A%A1%E5%8D%8F%E8%AE%AE.html",
				policy: "https://hropublic.oss-cn-beijing.aliyuncs.com/APP/yxly/%E6%A0%A1%E4%BC%81%E8%81%8C%E9%80%9A%E8%BD%A6%E9%9A%90%E7%A7%81%E6%94%BF%E7%AD%96.html",
				zs: "https://hropublic.oss-cn-beijing.aliyuncs.com/APP/yxly/%E6%A0%A1%E4%BC%81%E8%81%8C%E9%80%9A%E8%BD%A6%E7%9F%A5%E8%AF%86%E4%BA%A7%E6%9D%83%E4%BF%9D%E6%8A%A4%E8%A7%84%E5%88%99.html"
			}
		},
		onLoad() {
			this.version = `版本号:v${this.vuex_version}`;
			if (this.vuex_appId == 'wx2a515776284cae17') {
				// 新华
				this.service = "https://hropublic.oss-cn-beijing.aliyuncs.com/APP/xhsx/1-%20%E6%96%B0%E5%8D%8E%E5%AE%9E%E4%B9%A0%E7%94%A8%E6%88%B7%E6%9C%8D%E5%8A%A1%E5%8D%8F%E8%AE%AE(%E6%B8%85%E6%B4%81%E7%89%88).html"
				this.policy = "https://hropublic.oss-cn-beijing.aliyuncs.com/APP/xhsx/1.1-%20%E6%96%B0%E5%8D%8E%E5%AE%9E%E4%B9%A0%E9%9A%90%E7%A7%81%E6%94%BF%E7%AD%96(%E6%B8%85%E6%B4%81%E7%89%88).html"
				this.zs = "https://hropublic.oss-cn-beijing.aliyuncs.com/APP/xhsx/1.2-%E6%96%B0%E5%8D%8E%E5%AE%9E%E4%B9%A0%E7%9F%A5%E8%AF%86%E4%BA%A7%E6%9D%83%E4%BF%9D%E6%8A%A4%E8%A7%84%E5%88%99(%E6%B8%85%E6%B4%81%E7%89%88).html"
			}
		},
		computed: {
			...mapState({
				vuex_token: "vuex_token",
				student: (state) => state.vuex_user.student,
			}),
		},

		methods: {
			linkService() {
				console.log(this)
				this.$u.route({
					url: `/pages/common/webview/webview?navtitle=服务协议&url=${this.service}`,
				})
			},

			linkPolicy() {
				this.$u.route({
					url: `/pages/common/webview/webview?navtitle=隐私政策&url=${this.policy}`,
				})
			},

			link(type) {
				if (type == 'identity') {
					this.$u.route('/pages/recruit/my/checkIdentity/checkIdentity?source=c');
					return;
				} else if (type == 'policy') {
					this.$u.route({
						url: `/pages/common/webview/webview?navtitle=服务协议&url=${this.service}`,
					})
					return;
				} else if (type == 'agreement') {
					this.$u.route({
						url: `/pages/common/webview/webview?navtitle=隐私政策&url=${this.policy}`,
					})
					return;
				} else if (type == 'zs') {
					this.$u.route({
						url: `/pages/common/webview/webview?navtitle=知识产权保护规则&url=${this.zs}`,
					})
					return;
				}
				
				if (JSON.stringify(this.vuex_user) == '{}') {
					// this.$u.toast('未登录,请重新登录!');
					// setTimeout(() => {
					// 	// 此为uView的方法,详见路由相关文档
					// 	this.$u.route('/pages/student/my/login/login')
					// }, 1500)
					// uni.$u.route({
					// 	url: 'pages/student/tabBar/home/home',
					// 	type: 'switchTab',
					// 	params: {
					
					// 	}
					// })
					uni.showToast({
						title: '未登录,请先登录',
						icon:'none',
						duration: 1500
					})
					return;
				}

				switch (type) {
					case 'account':
						this.$u.route('/pages/student/my/account-center/account-center');
						break;

						// case 'identity':
						// 	this.$u.route('/pages/recruit/my/checkIdentity/checkIdentity?source=c');
						// 	break;

						// case 'policy':
						// 	this.$u.route(`/pages/common/webview/webview?navtitle=服务协议&url=${this.service}`);
						// 	break;

						// case 'agreement':
						// 	this.$u.route('/pages/student/my/agreement/agreement');
						// 	break;

					case 'cancel':
						this.$u.route('/pages/student/my/remove-account/remove-account');
						break;

					case 'loginOut':
						const {
							dispatch
						} = this.$store;
						
						if (JSON.stringify(this.vuex_user) != '{}') {
							dispatch(`user/loginOut`).then(res => {
								uni.showToast({
									title: '退出登录成功',
									icon:'none',
									duration: 1000
								})
								setTimeout(() => {
									uni.$u.route({
										url: 'pages/student/tabBar/home/home',
										type: 'switchTab',
									})
								}, 1000)
							});
						}else {
							uni.showToast({
								title: '未登录,请先登录',
								icon:'none',
								duration: 1500
							})
						}
						
						break;
				}

			},
		}
	}
</script>

<style lang="scss" scoped>
	.setting {
		width: 100%;
		height: 100%;
		background-color: #F7F7F7;

		.top {
			margin: 32rpx 0;
		}

		.cell /deep/ .u-cell {
			padding: 56rpx 32rpx;
		}
	}
</style>