Blame view

pages/mine/setting/setting.vue 2.68 KB
46b6767c   刘淇   init 提交到库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
  <template>
  	<view class="container">
  		<tui-list-cell arrow :size="32" :hover="false" padding="30rpx" @click="toSetPwd">修改密码</tui-list-cell>
  		<tui-list-cell arrow :size="32" :hover="false" padding="30rpx" @click="displayModal('upgradation')">检查更新</tui-list-cell>
  		<tui-list-cell arrow unlined :size="32" :hover="false" padding="30rpx" @click="displayModal('clearCache')">
  			<view class="fs-flex__between fs-pr20">
  				<view>清理缓存</view><view class="fs-size__h4 fs-color__label">0kb</view>
  			</view>
  		</tui-list-cell>
  		<view class="fs-flex__center fs-mt96">
  			<tui-button width="560rpx" height="86rpx" shadow shape="circle" @click="loginOutBtn">退出登录</tui-button>
  		</view>
  		<tui-modal :show="showModal" @click="handleModal" @cancel="hideModal" :content="content"></tui-modal>
  		<tui-actionsheet :show="showAction" :item-list="actionList" @click="handleAction" @cancel="hideAction" tips="退出登录会清除您的登录信息,确认退出吗?"></tui-actionsheet>
  	</view>
  </template>
  
  <script>
  import { version, OSSURL } from '@/config/app'
  import { apiAccountLogOut, apiVersion } from '@/api/app'
  export default {
  	data() {
  		return {
  			showModal: false,
  			showAction: false,
  			type: '',
  			content: '',
  			downloadUrl: '',
  			actionList: [{text:"退出登录", color:"#577ee3"}]
  		}
  	},
  	onLoad() {
  
  	},
  	methods: {
  		// 修改密码
  		toSetPwd() {
  			uni.$tui.href('/pages/mine/setting/setPwd')
  		},
  		// 检查升级/清理缓存
  		displayModal(type) {
  			this.type = type
  			if (this.type == 'upgradation') {
  				// 检查版本更新
  				apiVersion().then(res => {
  					const newVersion = res.data.version
  					this.downloadUrl = OSSURL + res.data.url
  					if (version < newVersion) {
  						this.content = '发现新版本,是否升级到最新版本?'
  						this.showModal = true
  					} else {
  						uni.$tui.toast('已是最新版本')
  					}
  				})
  			} else if (this.type == 'clearCache') {
  				this.content = '您确定要清理缓存吗?'
  				this.showModal = true
  			}
  		},
  		// 确定升级/清理
  		handleModal(event) {
  			this.hideModal()
  			if (event.index == 1) {
  				if (this.type == 'upgradation') {
  					// 打开系统浏览器下载
  					plus.runtime.openURL(this.downloadUrl)
  				} else if (this.type == 'clearCache') {
  					uni.$tui.toast('清理成功')
  				}
  			}
  		},
  		// 取消升级/清理
  		hideModal() {
  			this.showModal = false
  		},
  		// 退登录出
  		loginOutBtn() {
  			this.showAction = true
  		},
  		// 确定退出
  		handleAction() {
  			apiAccountLogOut().then(res => {
  				this.loginOut()
  				uni.$tui.href('/pages/login', 3)
  			})
  		},
  		// 取消退出
  		hideAction() {
  			this.showAction = false
  		}
  	}
  }
  </script>
  
  <style lang="scss" scoped>
  
  </style>