Browse Source

签到及界面设置 vuex运用

zhengJ_docnet 4 years ago
parent
commit
e8a2700c32

+ 48 - 0
App.vue

@@ -1,13 +1,61 @@
 <script>
+	import {
+		mapState,
+		mapMutations
+	} from "vuex"
 	export default {
 		onLaunch: function() {
 			console.log('App Launch')
+			if(this.setting.forceUpdate) {
+				this.Upload()
+			}
 		},
 		onShow: function() {
 			console.log('App Show')
 		},
 		onHide: function() {
 			console.log('App Hide')
+		},
+		onLoad() {
+			console.log("卸载了")
+			let set = this.setting
+			set[keepscreenon] = false
+			setTimeout(function() {
+				this.setTing(set)
+			}, 100);
+		},
+		computed: {
+			...mapState({
+				setting: state => state.global.setting
+			})
+		},
+		methods:{
+			...mapMutations(["setTing"]),
+			// 更新
+			Upload() {
+				console.log("哈哈")
+				const updateManager = uni.getUpdateManager();
+				updateManager.onCheckForUpdate(function (res) {
+					// 请求完新版本信息的回调
+					console.log(res.hasUpdate,"-------888-------");
+				});
+				updateManager.onUpdateReady(function (res) {
+					uni.showModal({
+						title: '更新提示',
+						content: '新版本已经准备好,是否重启应用?',
+						success(res) {
+							if (res.confirm) {
+								// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+								updateManager.applyUpdate();
+							}
+						}
+					 });
+				});
+				updateManager.onUpdateFailed(function (res) {
+					// 新的版本下载失败
+					console.log(res)
+				});
+			}
 		}
 	}
 </script>

+ 7 - 1
colorui/main.css

@@ -237,7 +237,13 @@ switch .uni-switch-input {
 
 switch .wx-switch-input:not([class*="bg-"]),
 switch .uni-switch-input:not([class*="bg-"]) {
-	background: var(--grey) !important;
+	/*  #ifdef  H5  */
+		background: var(--grey); /*去掉!important*/
+	/* #endif */
+	
+	/* #ifndef H5 */
+		background: var(--grey) !important; 
+	/* #endif */
 }
 
 switch .wx-switch-input::after,

+ 0 - 4
common/utils/https.js

@@ -53,12 +53,8 @@ function getWeather(location) {
 function getFuture(location) {
 	return new Promise((resolve, reject) => {
 		uni.request({
-			// url: "/v/weather/index",
 			url: weather+"/forecast",
 			data: {
-				// cityname:location,
-				// key: QQ_MAP_KEY2
-				
 				location:location,
 				key: QQ_MAP_KEY1
 			},

+ 17 - 2
pages.json

@@ -13,7 +13,10 @@
 		{
 			"path":"pages/mypersonal/personal",
 			"style":{
-				"navigationStyle":"default"
+				// #ifdef H5 
+				"navigationStyle":"custom",
+				// #endif
+				"navigationBarBackgroundColor":"#49A3EE"
 			}
 		}
 	    ,{
@@ -24,7 +27,19 @@
         }
         ,{
             "path" : "pages/setting/setting",
-            "style" : {}
+            "style" : {
+				// #ifdef H5 
+				"navigationStyle":"custom"
+				// #endif
+			}
+        }
+        ,{
+            "path" : "pages/gesture/gesture",
+            "style" : {
+				// #ifdef H5 
+				"navigationStyle":"custom"
+				// #endif
+			}
         }
     ],
 	"tabBar": {

+ 0 - 103
pages/components/personal/index.vue

@@ -1,103 +0,0 @@
-<style lang="scss">
-	.step{ 
-	    width: 100%; 
-	    height: auto; 
-	    padding: 10rpx 30rpx; 
-	    box-sizing: border-box; 
-	    overflow: hidden;
-	    background-color: #fff;
-	    color: #666;
-	  }
-	.step .modle{ 
-	  width: 100%; 
-	  height: 100rpx; 
-	  margin-top: 10rpx; }
-	.step .modle .mol{ 
-	  width: 100%; 
-	  height: 52rpx; 
-	  position: relative;  }
-	.step .mol-line{ 
-	  width: 100%; 
-	  height: 4rpx; 
-	  background-color: #e6e6e6; 
-	  position: absolute; 
-	  left: 0; 
-	  top: 50%; 
-	  transform: translateY(-50%);}
-	.step .mol-ites{ 
-	  width: 100%; 
-	  height: 100%;
-	  position: absolute;}
-	.mol-ites .ite{ 
-	  width: 52rpx; 
-	  height: 52rpx; 
-	  border-radius: 50%; 
-	  border: 1px solid #f5f5f5;
-	  background-color: #fff; 
-	  box-sizing: border-box;  
-	  position: absolute; 
-	  left: 0; 
-	  top: 0; 
-	  z-index: 2;}
-	.mol-ites .ite .n{ 
-	  width: 44rpx; 
-	  height: 44rpx; 
-	  line-height: 44rpx; 
-	  text-align: center; 
-	  border-radius: 50%; 
-	  background-color: #f5f5f5;
-	  position: absolute; 
-	  left: 50%; 
-	  top: 50%; 
-	  transform: translate(-50%,-50%); 
-	  font-size: 22rpx;}
-	.mol-ites .ite::after{ 
-	  content: ""; 
-	  width: 80rpx; 
-	  height: 4rpx; 
-	  background-color: transparent; 
-	  position: absolute; 
-	  left: 52rpx; 
-	  top: 50%; 
-	  margin-top: -2rpx; 
-	  z-index: 2;}
-	.mol-ites .ite:last-of-type::after{ width: 0;}
-	.mol-ites .ite:nth-of-type(2){ left: 107rpx;}
-	.mol-ites .ite:nth-of-type(3){ left: 214rpx;}
-	.mol-ites .ite:nth-of-type(4){ left: 321rpx;}
-	.mol-ites .ite:nth-of-type(5){ left: 428rpx;}
-	.mol-ites .ite:nth-of-type(6){ left: 535rpx;}
-	.mol-ites .ite:nth-of-type(7){ left: 642rpx;}
-	.mol-ites .ite.hover{ border-color: rgb(97, 165, 238);}
-	.mol-ites .ite.hover .n{ background-color: rgb(97, 165, 238); color: #fff;}
-	.mol-ites .ite.hover::after{ background-color: rgb(97, 165, 238); }
-	.moday{ 
-	  width: 100%; 
-	  height:40rpx; 
-	  overflow: hidden; 
-	  position: relative; 
-	  margin-top:16rpx;}
-	.moday .dd{ 
-	  width: 52rpx; 
-	  height: 40rpx; 
-	  line-height: 1; 
-	  text-align: center; 
-	  font-size: 22rpx;
-	  position: absolute; 
-	  left: 0; 
-	  bottom: 0;}
-	.moday .dd:nth-of-type(2){ left: 107rpx;}
-	.moday .dd:nth-of-type(3){ left: 214rpx;}
-	.moday .dd:nth-of-type(4){ left: 321rpx;}
-	.moday .dd:nth-of-type(5){ left: 428rpx;}
-	.moday .dd:nth-of-type(6){ left: 535rpx;}
-	.moday .dd:nth-of-type(7){ left: 642rpx;}
-</style>
-
-<template>
-	<view></view>
-</template>
-
-<script>
-	
-</script>

+ 19 - 0
pages/gesture/gesture.vue

@@ -0,0 +1,19 @@
+<template>
+	<view>
+		
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				
+			};
+		}
+	}
+</script>
+
+<style lang="scss">
+
+</style>

+ 9 - 10
pages/index/index.vue

@@ -79,10 +79,12 @@
 
 <script >
 	import {
-		mapState,
-		mapMutations
+		mapState
 	} from "vuex"
 	import {getWeather, getFuture, gelocation, getAir, getLift} from "@/common/utils/https.js"
+	//#ifdef MP-WEIXIN
+		import amapFile from "@/common/utils/amap-wx.js"
+	//#endif
 	export default {
 		data() {
 			return {
@@ -145,20 +147,17 @@
 			console.log("9")
 		},
 		methods: {
-			// 获取位置信息
+			// 高德地址逆解析
 			getLocation() {
-				// https服务上才能调用
+				// 仅支持https
 				uni.getLocation({
-					success: (res) => {
-						console.log(res, "位置信息")
-						this.city = res.longitude+","+res.latitude
-							
-						// this.getWether(this.city)
+					success: function (res) {
+						console.log(res)
 					}
 				})
 				this.getWether(this.city)
 			},
-			// 獲取頁面數據
+			// 获取页面数据
 			getWether(key) {
 				console.log("-------------------" , key)
 				var that = this

+ 50 - 21
pages/mypersonal/personal.vue

@@ -8,7 +8,7 @@
 			/* justify-content: center;  水平居中*/
 			font-size: 30rpx;
 			color: #fff;
-			background-color: rgb(97, 165, 238);
+			background-color: #49A3EE;
 			.userinfo-avatar{
 				border-radius: 50%;
 				width: 100rpx;
@@ -21,14 +21,14 @@
 				line-height: 60rpx;
 				text-align: center;
 				background-color: #fff;
-				color:  rgb(97, 165, 238);
+				color:  #49A3EE;
 				border-radius: 10rpx;
 				margin: 40rpx;
 				margin-left: auto;  /*子元素靠右 */
 			}
 			.signs{
-				background: #666;
-				color: #fff;
+				background: #fff;
+				color: #666;
 			}
 		}
 		.userlist{
@@ -45,7 +45,6 @@
 				height: 100%;
 				opacity: 0;
 			}
-			
 		}
 	}
 </style>
@@ -55,19 +54,20 @@
 		<view class='portrait'>
 			<image class="userinfo-avatar" :src="userInfo.avatarUrl ? userInfo.avatarUrl : '/static/icon.png'" mode="aspectFit"></image>
 			<view>{{userInfo.nickName}}</view>
-			<view class='sign' :class='signState ? "signs" : ""' @tap='signState?"":"signClick"' :data-num="signNum" :data-min="min" :data-max="max" :data-be="be">{{signState?"已签到":"签到"}}</view>
+			<view class='sign' :class='signState ? "signs" : ""' @tap='signClick'>{{signState?"已签到":"签到"}}</view>
 		</view>
-		<personal/>
 		
-		<view class='userlist cu-list menu'>
+		<view class='userlist cu-list menu'>  
 			<block v-for="(item, index) in list" :key="index">
 				<view class='cu-item arrow' @tap="bind(item.batName)">
 					<view class="content">
-						<icon class='iconfont' :class="item.className"></icon>
+						<text class='iconfont' :class="item.className"></text>
 						<text>{{item.name}}</text>
 					</view>
+					<!--  #ifdef  MP-WEIXIN -->
 					<button open-type="contact" v-if="item.batName === 'bindService'"/>
 					<button open-type="feedback" v-if="item.batName === 'feedback'"/>
+					<!--  #endif -->
 				</view>
 			</block>
 		</view>
@@ -79,14 +79,9 @@
 		mapState,
 		mapMutations
 	} from "vuex"
-	import personal from "@/pages/components/personal/index.vue"
 	export default {
 		data() {
 			return {
-				signNum: 0,       //签到数
-				min: 1,           //默认值日期第一天1
-				max: 7,           //默认值日期最后一天7
-				be: 0,
 				list:[
 					{
 						name: '设置',
@@ -115,32 +110,66 @@
 			...mapState({
 				userInfo: state => state.global.userInfo,
 				signState: state => state.global.signState,
+				sing: state => state.global.sing
 			})
 		},
 		onShow() {
-			
+			console.log(this.sing)
 		},
 		methods: {
+			...mapMutations(["setState", "setSing"]),
 			bind(signClick) {
-				console.log("haha",signClick)
+				switch (signClick){
+					case "bindSeting":
+						this.bindSeting()
+						break;
+					case "bindCopy":
+						this.bindCopy()
+						break;
+					default:
+						break;
+				}
 			},
 			bindSeting() {
-				
+				uni.navigateTo({
+					url:"/pages/setting/setting"
+				})
 			},
 			bindCopy() {
 				let data = "haha"
-				wx.setClipboardData({
+				//#ifdef H5
+					uni.showToast({
+						title: '暂不支持H5端',
+						duration: 2000,
+						icon:"none"
+					})
+				//#endif
+				//#ifndef H5
+				uni.setClipboardData({
 					data: data,
 					success: res => {
-						uni.getToast('复制成功')
-						wx.getClipboardData({
+						uni.showToast({
+							title: '复制成功',
+							duration: 2000
+						})
+						uni.getClipboardData({
 							success: res=> {
 								console.log(res.data)
 							}
 						})
 					}
 				})
-			}
+				//#endif
+			},
+			signClick() {
+				if(this.signState) {
+					return
+				}else{
+					this.setState(true)
+					console.log(++this.sing)
+					this.setSing(++this.sing)
+				}
+			},
 		}
 	}
 </script>

+ 346 - 47
pages/setting/setting.vue

@@ -1,56 +1,141 @@
 <style lang="scss" scoped>
-
+	.setting {
+		font-size: 28rpx;
+		color: #666;
+		.s{
+			.t {
+				overflow: hidden;
+				padding: 0 40rpx;
+				background: #fff;
+				margin-bottom: 20rpx;
+				.title {
+					font-size: 32rpx;
+					color: #40a7e7;
+					margin: 26rpx 0;
+				}
+				.content{
+					padding-left: 20rpx;
+					.subtitle {
+						font-size: 28rpx;
+						color: #40a7e7;
+					}
+					.item {
+						display: flex;
+						justify-content: space-between;
+						align-items: center;
+						height: 100rpx;
+						.tip {
+							font-size: 22rpx;
+							color: #999;
+							display: flex;
+							justify-content: flex-start;
+							align-items: center;
+							&image {
+								width: 24rpx;
+								height: 24rpx;
+								margin-right: 10rpx;
+							}
+						}
+					}
+				}
+			}
+		}
+		.toast{
+			.mask {
+				position: fixed;
+				z-index: 9;
+				top: 0;
+				right: 0;
+				bottom: 0;
+				left: 0;
+				margin: auto;
+				background: rgba(0, 0, 0, .5);
+			}
+			.wrapper {
+				position: fixed;
+				z-index: 10;
+				top: 0;
+				right: 0;
+				bottom: 0;
+				left: 0;
+				margin: auto;
+				background: #fff;
+				font-size: 24rpx;
+				color: #333;
+				width: 60%;
+				height: 400rpx;
+				border-radius: 14rpx;
+				.box {
+					height: 400rpx;
+					padding: 20rpx 28rpx;
+					overflow: scroll;
+					.t {
+						font-size: 28rpx;
+						color: #40a7e7;
+						margin: 20rpx 0;
+						padding: 0;
+					}
+					.content {
+						line-height: 1.8em;
+						text-align: justify;
+						&text {
+							display: block;
+							margin-bottom: 10rpx;
+						}
+					}
+				}
+			}
+		}
+	}
+	.item .tip image {
+		width: 24rpx;
+		height: 24rpx;
+		margin-right: 10rpx;
+	}
+	.more {
+		width: 32rpx;
+		height: 32rpx;
+	}
+	
 </style>
 
 <template>
 	<view class='setting'>
 	<!-- 自定义 -->
 		<view class='s'>
-			<view class='t'>
-				<view class='title'>
-					<view>自定义</view>
-				</view>
-				<!-- <view class='content'>
-					<view class='item'>
-						<view>打开顶部城市天气快捷搜索</view>
-						<switch color='#40a7e7' checked='{{!setting.hiddenSearch}}'  @change='switchChange' data-switchparam='hiddenSearch'></switch>
-					</view>
-					<view class='item'>
-						<view>显示生活指数信息</view>
-						<switch color='#40a7e7' checked='{{!setting.hiddenIndex}}' @change='switchChange' data-switchparam='hiddenIndex'></switch>
-					</view>
-				</view> -->
-			</view>
 			<!-- 检查更新 -->
-			<!-- <view class='t'>
+			<!--  #ifdef  MP-WEIXIN -->
+			<view class='t'>
 				<view class='title'>
 					<view>检查更新</view>
 				</view>
 				<view class='content'>
 					<view class='item'>
-						<block>
-							<view>打开首页更新提醒</view>
-							<view class='tip' @tap='updateInstruc'>
-								<image src='../image/question.png'></image>
+						<view>
+							<view>更新提醒</view>
+							<view class='tip' @tap="updateInstruc">
+								<image src='/static/question.png'></image>
 								<text v-if='enableUpdate'>在首页检测到新版本,会提示更新</text>
-								<text v-if='!enableUpdate' style='flex:1;'>基础库版本需高于 1.9.90,当前基础库版本为 {{SDKVersion}}</text>
+								<text v-if='!enableUpdate'>基础库版本需高于 1.9.90,当前基础库版本为 {{SDKVersion}}</text>
 							</view>
-						</block>
-						<switch color='#40a7e7' checked='{{setting.forceUpdate}}' @change='switchChange' data-switchParam='forceUpdate'></switch>
+						</view>
+						<switch color='#40a7e7' :checked='setting.forceUpdate' @change='switchChange' data-switchParam='forceUpdate'></switch>
 					</view>
 				</view>
-			</view> -->
+			</view>
+			<!-- #endif -->
 			<!-- 小工具 -->
-			<!-- <view class='t'>
+			<view class='t'>
 				<view class='title'>小工具</view>
-				<view class='content sub'>
+				<view class='content'>
 					<view class='subtitle'>NFC</view>
 					<view class='item' @tap='getHCEState'>
 						<view>检测是否支持NFC</view>
-						<image class='more' src='../image/arrow.png'></image>
+						<image class='more' src='/static/arrow.png'></image>
 					</view>
 				</view>
-				<view class='content sub'>
+				<!--  #ifndef  H5 -->
+				<view class='content'>
 					<view class='subtitle'>屏幕亮度</view>
 					<view class='item'>
 						<view>
@@ -60,9 +145,9 @@
 						<view>{{screenBrightness}}</view>
 					</view>
 					<view class='item' @tap='setScreenBrightness'>
-						<view style='width:100%'>
+						<view :style="{width:100+'%'}">
 							<view>设置屏幕亮度</view>
-							<slider :value='screenBrightness' min='0' max='100' step='1' block-size='12' block-color='#40a7e7' activeColor='#40a7e7' show-value='true' @change='screenBrightnessChanging' bindchanging='screenBrightnessChanging'></slider>
+							<slider :value='screenBrightness' min='0' max='100' step='1' block-size='12' block-color='#40a7e7' activeColor='#40a7e7' show-value='true' @change='screenBrightnessChanging' @changing='screenBrightnessChanging'></slider>
 						</view>
 					</view>
 					<view class='item'>
@@ -70,47 +155,55 @@
 							<view>保持常亮</view>
 							<view class='tip'>仅在当前小程序、当次生效,离开小程序后设置失效</view>
 						</view>
-						<switch color='#40a7e7' @change='switchChange' :data-switchparam='keepscreenon' :checked='keepscreenon'></switch>
+						<switch color='#40a7e7' @change='switchChange' data-switchparam='keepscreenon' :checked='setting.keepscreenon'></switch>
 					</view>
 				</view>
-				<view class='content sub'>
+				<!--  #endif -->
+				<view class='content'>
 					<view class='subtitle'>系统信息</view>
 					<view class='item' @tap='getsysteminfo'>
 						<view>查看系统信息</view>
-						<image class='more' src='../image/arrow.png'></image>
+						<image class='more' src='/static/arrow.png'></image>
 					</view>
 				</view>
-			</view> -->
+				<view class='content'>
+					<view class='subtitle'>是否开启手势解锁</view>
+					<view class='item'>
+						<view>开启后,每次都需解锁进入</view>
+						<switch color='#40a7e7' :checked='setting.gesture' @change='switchChange' data-switchParam='gesture'></switch>
+					</view>
+				</view>
+			</view>
 			<!-- 清除数据 -->
-			<!-- <view class='t'>
+			<view class='t'>
 				<view class='title'>清除数据</view>
 				<view class='content'>
-					<view class='item' @tap='removeStorage' :data-type='setting'>
+					<view class='item' @tap='removeStorage' data-type='setting'>
 						<view>
 							<view>恢复初始化设置</view>
 							<view class='tip'>
-								<image src='../image/danger.png'></image>
+								<image src='/static/danger.png'></image>
 								<text>所有设置信息都将被清除</text>
 							</view>
 						</view>
-						<image class='more' src='../image/arrow.png'></image>
+						<image class='more' src='/static/arrow.png'></image>
 					</view>
-					<view class='item'  @tap='removeStorage' :data-type='all'>
+					<view class='item'  @tap='removeStorage' data-type='all'>
 						<view>
 							<view>清除所有本地数据</view>
 							<view class='tip'>
-								<image src='../image/danger.png'></image>
+								<image src='/static/danger.png'></image>
 								<text>所有本地数据都将被清除</text>
 							</view>
 						</view>
-						<image class='more' src='../image/arrow.png'></image>
+						<image class='more' src='/static/arrow.png'></image>
 					</view>
 				</view>
-			</view> -->
+			</view>
 		</view>
 		
 		<!-- toast -->
-		<!-- <view class='toast' v-if='show'>
+		<view class='toast' v-if='show'>
 			<view class='mask' @tap='hide'></view>
 			<view class='wrapper'>
 				<view class='box'>
@@ -128,16 +221,222 @@
 					</view>
 				</view>
 			</view>
-		</view> -->
+		</view>
 	</view>
 </template>
 
 <script>
+	import {
+		mapState,
+		mapMutations
+	} from "vuex"
 	export default {
 		data() {
 			return {
-				
-			};
+				show: false,
+				screenBrightness: '获取中',
+				keepscreenon: false,
+				SDKVersion: '',
+				enableUpdate: true,
+				indexPage: {}
+			}
+		},
+		computed: {
+			...mapState({
+				setting: state => state.global.setting
+			})
+		},
+		onLoad() {
+			
+		},
+		onShow() {
+			//#ifndef H5
+				this.getScreenBrightness()
+			//#endif
+			
+		},
+		mounted() {
+			
+		},
+		methods:{ 
+			...mapMutations(["setTing"]),
+			updateInstruc() {
+				this.show = true
+			},
+			switchChange(e) {
+				console.log(e)
+				let dataset = e.currentTarget.dataset
+				let switchparam = dataset.switchparam
+				let setting = this.setting
+				if (switchparam === 'forceUpdate') {
+					if (this.enableUpdate) {
+						setting[switchparam] = (e.detail || {}).value
+					} else {
+						setting[switchparam] = false
+						uni.showToast({
+							title: '基础库版本较低,无法使用该功能',
+							icon: 'none',
+							duration: 2000,
+						})
+					}
+				} else if (switchparam === 'keepscreenon') {
+					setting[switchparam] = (e.detail || {}).value
+					// #ifndef H5
+					this.setKeepScreenOn()
+					// #endif
+				} else{
+					setting[switchparam] = (e.detail || {}).value
+					if(e.detail.value) {
+						setTimeout(function() {
+							uni.navigateTo({
+								url:"/pages/gesture/gesture"
+							})
+						}, 500);
+					}else{
+						return
+					}
+				}
+				console.log(this.setting)
+				this.setTing(setting)
+			},
+			screenBrightnessChanging(e) {
+				console.log(e.detail.value)
+				//#ifndef H5
+					this.setScreenBrightness(e.detail.value)
+				//#endif
+			},
+			setScreenBrightness (val) {
+				uni.setScreenBrightness({
+				    value: val / 100,
+				    success: function () {
+				        console.log('success')
+						this.screenBrightness = val
+				    }
+				})
+			},
+			getScreenBrightness() {
+				uni.getScreenBrightness({
+					success: (res) => {
+						this.screenBrightness = Number(res.value * 100).toFixed(0)
+					},
+					fail: (res) => {
+						this.screenBrightness = '获取失败'
+					}
+				})
+			},
+			getHCEState () {
+				//#ifdef MP-WEIXIN || APP-PLUS
+				uni.showLoading({title: '检测中...'})
+				uni.getHCEState({
+					success: function (res) {
+						uni.hideLoading()
+						uni.showModal({
+							title: '检测结果',
+							content: '该设备支持NFC功能',
+							showCancel: false,
+							confirmText: '朕知道了',
+							confirmColor: '#40a7e7',
+						})
+					},
+					fail: function (res) {
+						wx.hideLoading()
+						wx.showModal({
+							title: '检测结果',
+							content: '该设备不支持NFC功能',
+							showCancel: false,
+							confirmText: '朕知道了',
+							confirmColor: '#40a7e7',
+						})
+					}
+				})
+				//#endif
+				//#ifndef APP-PLUS || MP-WEIXIN
+				uni.showToast({
+					title:"仅支持App及小程序",
+					icon:"none"
+				})
+				//#endif
+			},
+			removeStorage(e) {
+				let type = e.currentTarget.dataset.type
+				this.clear(type)
+			},
+			clear(type) {
+				switch (type){
+					case "setting":
+						this.setClear()
+						break;
+					case "all":
+						this.locclear()
+						break;
+				}
+			},
+			setClear() {
+				uni.showModal({
+					title: '提示',
+					content: '确认要初始化设置',
+					cancelText: '容朕想想',
+					confirmColor: '#40a7e7',
+					success: (res) => {
+						if (res.confirm) {
+							uni.removeStorage({
+								key: 'setting',
+								success: (res) => {
+									
+									uni.showToast({
+										title: '初始化成功', icon:"none"
+									})
+								}
+							})
+						}
+					}
+				})
+			},
+			locclear() {
+				uni.showModal({
+					title: '提示',
+					content: '确认要删除',
+					cancelText: '容朕想想',
+					confirmColor: '#40a7e7',
+					success: (res) => {
+						if (res.confirm) {
+							uni.clearStorage({
+								success: (res) => {
+									uni.showToast({
+										title: '数据已清除', icon:"none"
+									})
+								}
+							})
+							//返回首页
+							
+						}
+					}
+				})
+			},
+			hide() {
+				this.show = false
+			},
+			ifDisableUpdate () {
+				let systeminfo = getApp().globalData.systeminfo
+				let SDKVersion = systeminfo.SDKVersion
+				let version = cmpVersion(SDKVersion, '1.9.90')
+				if (version >=0) {
+					this.setData({
+						SDKVersion,
+						enableUpdate: true,
+					})
+				} else {
+					this.setData({
+						SDKVersion,
+						enableUpdate: false,
+					})
+				}
+			},
+			setKeepScreenOn() {
+				uni.setKeepScreenOn({
+					keepScreenOn: true
+				})
+			}
 		}
 	}
 </script>

+ 21 - 2
store/modules/global.js

@@ -1,11 +1,30 @@
 const state = {
-	signState:uni.getStorageSync('signState'),
 	userInfo:uni.getStorageSync('suserInfo'),
-	city:"北京"
+	city:"北京",
+	//#ifdef H5
+	signState:uni.getStorageSync('signState') || false,
+	//#endif
+	signState:uni.getStorageSync('signState') || false,
+	sing: uni.getStorageSync("sing") || 0,
+	setting: uni.getStorageSync("setting") || {},
 }
 const mutations = {
 	setCity(state, value){
 		state.city = value
+	},
+	setState(state, value) {
+		uni.setStorageSync("signState", value)
+		state.signState = value
+	},
+	setSing(state, value) {
+		console.log(value)
+		uni.setStorageSync("sing", value)
+		state.sing = value
+	},
+	setTing(state, value) {
+		console.log(value)
+		uni.setStorageSync("setting", value)
+		state.setting = value
 	}
 }
 const actions = {