Browse Source

no message

seamwang 2 years ago
parent
commit
2383ee5cc3
6 changed files with 262 additions and 264 deletions
  1. 37 37
      src/main.js
  2. 8 13
      src/pages/mine/mine.vue
  3. 102 102
      src/pages/mine/onlineService.vue
  4. 2 2
      src/pages/mine/setting.vue
  5. 107 104
      src/pages/studentcenter/evaluate.vue
  6. 6 6
      src/store/user.js

+ 37 - 37
src/main.js

@@ -1,37 +1,37 @@
1
-import Vue from 'vue'
2
-import commonMethods from '@/common/commonMethods.js'
3
-import commonData from '@/common/commonData.js'
4
-import App from './App'
5
-import store from './store/index.js'
6
-
7
-import floatTab from '@/components/float-tab.vue'
8
-import cuCustom from './components/cu-custom.vue'
9
-import pageLoading from './components/page-loading.vue'
10
-import mpTabbar from './components/mp-tabbar.vue'
11
-import mixin from '@/common/utils/mixin.js'
12
-Vue.mixin(mixin)
13
-Vue.component('cu-custom', cuCustom)
14
-Vue.component('page-loading', pageLoading)
15
-Vue.component('mp-tabbar', mpTabbar)
16
-Vue.component('float-tab', floatTab)
17
-
18
-// 公共方法挂载在vue原型上
19
-for (const key in commonMethods) {
20
-  Vue.prototype[key] = commonMethods[key]
21
-}
22
-
23
-// 公共方法挂载在vue原型上
24
-for (const key in commonData) {
25
-  Vue.prototype[key] = commonData[key]
26
-}
27
-
28
-Vue.config.productionTip = false
29
-// 需要全局注册一下store
30
-Vue.prototype.$store = store
31
-App.mpType = 'app'
32
-
33
-const app = new Vue({
34
-  store,
35
-  ...App
36
-})
37
-app.$mount()
1
+import Vue from 'vue'
2
+import commonMethods from '@/common/commonMethods.js'
3
+import commonData from '@/common/commonData.js'
4
+import App from './App'
5
+import store from './store/index.js'
6
+
7
+import floatTab from '@/components/float-tab.vue'
8
+import cuCustom from './components/cu-custom.vue'
9
+import pageLoading from './components/page-loading.vue'
10
+import mpTabbar from './components/mp-tabbar.vue'
11
+import mixin from '@/common/utils/mixin.js'
12
+Vue.mixin(mixin)
13
+Vue.component('cu-custom', cuCustom)
14
+Vue.component('page-loading', pageLoading)
15
+Vue.component('mp-tabbar', mpTabbar)
16
+Vue.component('float-tab', floatTab)
17
+
18
+// 公共方法挂载在vue原型上
19
+for (const key in commonMethods) {
20
+  Vue.prototype[key] = commonMethods[key]
21
+}
22
+
23
+// 公共方法挂载在vue原型上
24
+for (const key in commonData) {
25
+  Vue.prototype[key] = commonData[key]
26
+}
27
+
28
+Vue.config.productionTip = false
29
+// 需要全局注册一下store
30
+Vue.prototype.$store = store
31
+App.mpType = 'app'
32
+
33
+const app = new Vue({
34
+  store,
35
+  ...App
36
+})
37
+app.$mount()

+ 8 - 13
src/pages/mine/mine.vue

@@ -11,10 +11,13 @@
11 11
 			 <view class="user-info flex">
12 12
 				 		<image mode="scaleToFill" :src="user.avatarUrl||defaultAvatar" class="avatar"></image>
13 13
 						<view class="study-info">
14
-							  <view class="user-name" @tap="switchStudent">
15
-									{{ kid_info.name ? kid_info.name + '-' + kid_info.school_name  : '切换学生' }}
16
-									<!-- <image :src="isLogin?switchIcon:loginIcon" mode="aspectFit" class="switch-icon"></image> -->
17
-									<text class="iconfont margin-left-xs" style="font-size:18px;" @tap="login">{{isLogin?'&#xe600;':'&#xe716;'}}</text>
14
+							  <view class="user-name" @tap="switchStudent" v-if="isLogin&&user.nickName">
15
+									{{ kid_info.name + '-' + kid_info.school_name }}
16
+									<text class="iconfont margin-left-xs" style="font-size:18px;">&#xe600;</text>
17
+								</view>
18
+								<view  class="user-name"  @tap="login" v-else>
19
+									 	 切换学生
20
+										 <text class="iconfont margin-left-xs" style="font-size:18px;">&#xe716;</text>
18 21
 								</view>
19 22
 								 <view class="user-learn">已学习{{info.parent_data.learn_day}}天</view>
20 23
 						</view>
@@ -22,14 +25,12 @@
22 25
 			 <view class="user-relative flex justify-between" v-if="isLogin">
23 26
 				  <view v-for="(relate,index) in courseRelates" :key="index" class="course-item" :style="'background:'+relate.background"
24 27
 					@tap="goto(relate.page)">
25
-						 <!-- <image :src="relate.img"  mode="widthFix" class="back-img relate-img"> -->
26 28
 						 <text class="iconfont back-img" style="font-size:32px;">{{relate.icon}}</text>
27 29
 						 <view class="text-df">{{relate.name}}</view>
28 30
 					</view>
29 31
 			 </view>
30 32
 			 <view class="user-relative flex justify-between" v-else>
31 33
 				  <view class="course-item relate-item" v-for="(course,index) in courses" :key="index" :style="'background:'+course.background">
32
-						<!-- <image :src="course.img" mode="widthFix" class="back-img"> -->
33 34
 						<text class="iconfont back-img" style="font-size:40px;">{{course.icon}}</text>
34 35
 						<view class="text-lg">{{course.title}}</view>
35 36
 						<view class="text-xxl margin-top-xs">{{course.name}}</view>
@@ -41,7 +42,6 @@
41 42
 				 <view class="order-info flex justify-between">
42 43
 					  <view v-for="(order,index) in menuList" :key="index" @tap="toOrder(index)">
43 44
 							  <view class="order-image">
44
-									<!-- <image :src="order.img" mode="aspectFill"></image> -->
45 45
 									<text class="iconfont text-student" style="font-size:32px;">{{order.icon}}</text>
46 46
 								</view>
47 47
 							  {{order.title}}
@@ -191,7 +191,6 @@ export default {
191 191
   },
192 192
   methods: {
193 193
     login() {
194
-      if (this.isLogin) return false
195 194
       this.globalNavigateTo('login')
196 195
     },
197 196
     get_info() {
@@ -222,11 +221,7 @@ export default {
222 221
       this.kid_info = this.students.find(item => item.id === kid)
223 222
     },
224 223
     switchStudent() {
225
-      if (!this.isLogin) {
226
-        this.globalNavigateTo('login')
227
-      } else {
228
-        this.modalName = 'showStudent'
229
-      }
224
+      this.modalName = 'showStudent'
230 225
     },
231 226
     goto(page) {
232 227
       if (!this.isLogin) {

+ 102 - 102
src/pages/mine/onlineService.vue

@@ -1,102 +1,102 @@
1
-<template>
2
-	<view class="page">
3
-		  <cu-custom :isBack="true" title="在线客服"></cu-custom>
4
-			<view class="flex justify-center bg-white padding-tb-sm">
5
-				 <view class="link" style="background-color:#9aed6f;">
6
-					  <button class="button" open-type="contact" @contact="handleContact"></button>
7
-					 	<!-- <image src="/static/imgs/mine/wechat.png" mode="widthFix"></image> -->
8
-						<text class="iconfont" style="font-size:32px;">&#xe6c7;</text>
9
-				 </view>
10
-				 <view class="link" @tap="call" style="background-color:#5fcfe0;margin-left:160rpx;">
11
-					 <!-- <image src="/static/imgs/mine/tel.png" mode="widthFix"></image> -->
12
-					 <text class="iconfont" style="font-size:32px;">&#xe612;</text>
13
-				 </view>
14
-			</view>
15
-			<scroll-view class="questions margin-top-sm pardding-lr-sm  bg-white">
16
-				 <view class="cu-list menu">
17
-					<view class="questions-title margin-top">热点问题</view>
18
-					<view class="cu-item arrow solid-bottom" v-for="(item,index) in list" :key="index" @tap="answer(item)">
19
-						<view class="content margin-left-sm">
20
-							<text class="text-black">{{item.title}}</text>
21
-						</view>
22
-					</view>
23
-				 </view>
24
-			</scroll-view>
25
-	</view>
26
-</template>
27
-
28
-<script>
29
-export default {
30
-  data() {
31
-    return {
32
-      phoneNumber: '07592222030',
33
-      list: [
34
-        {
35
-          id: 1,
36
-          title: '报课注意事项?',
37
-          content: '1、购买本课程后第三节课起不接受退课、退费申请;\n' +
38
-            '2、因节假日冲突未上的课程,会进行调课补回;\n' +
39
-            '3、请假两次以内可安排补课,第三次起不予补课及退费;\n' +
40
-            '4、本平台对以上细则有最终解释权。'
41
-        },
42
-        { id: 2, title: '怎么得到报课结果?', content: '报课成功之后会有消息提醒,请您耐心等待即可' },
43
-        { id: 3, title: '如何退课?', content: '发起退课之后,经过审核通过,退课金额会自动转到您的微信,请您放心就好了' },
44
-        { id: 4, title: '如何接送?', content: '进入当天课程即可进行接送,还可以看到最新课堂动态喔' }
45
-      ]
46
-    }
47
-  },
48
-  methods: {
49
-    answer(item) {
50
-      uni.showModal({
51
-        title: item.title,
52
-        content: item.content,
53
-        showCancel: false,
54
-        success: res => {
55
-          if (res.confirm) {
56
-
57
-          }
58
-        }
59
-      })
60
-    },
61
-    call() {
62
-      uni.makePhoneCall({
63
-        phoneNumber: this.phoneNumber
64
-      })
65
-    }
66
-  }
67
-}
68
-</script>
69
-
70
-<style lang="scss" scoped>
71
-@import '~@/common/css/mixin.scss';
72
-.page{
73
-	height:100vh;
74
-}
75
-.link{
76
-	position:relative;
77
-	width:60px;
78
-	height:60px;
79
-	line-height:60px;
80
-	color:#fff;
81
-	text-align:center;
82
-	border-radius:40%;
83
-	.button{
84
-    height: 75px;
85
-    width: 75px;
86
-    text-align: center;
87
-    position: absolute;
88
-    z-index: 2;
89
-    background: #fff;
90
-    border: none;
91
-    outline: none;
92
-    opacity: 0;
93
-	}
94
-}
95
-.questions{
96
-	height:calc(100vh - 240px);
97
-	&-title{
98
-		@include title(0,16px);
99
-		padding-left:40rpx;
100
-	}
101
-}
102
-</style>
1
+<template>
2
+	<view class="page">
3
+		  <cu-custom :isBack="true" title="在线客服"></cu-custom>
4
+			<view class="flex justify-center bg-white padding-tb-sm">
5
+				 <view class="link" style="background-color:#9aed6f;">
6
+					  <button class="button" open-type="contact" @contact="handleContact"></button>
7
+					 	<!-- <image src="/static/imgs/mine/wechat.png" mode="widthFix"></image> -->
8
+						<text class="iconfont" style="font-size:32px;">&#xe6c7;</text>
9
+				 </view>
10
+				 <view class="link" @tap="call" style="background-color:#5fcfe0;margin-left:160rpx;">
11
+					 <!-- <image src="/static/imgs/mine/tel.png" mode="widthFix"></image> -->
12
+					 <text class="iconfont" style="font-size:32px;">&#xe612;</text>
13
+				 </view>
14
+			</view>
15
+			<scroll-view class="questions margin-top-sm pardding-lr-sm  bg-white">
16
+				 <view class="cu-list menu">
17
+					<view class="questions-title margin-top">热点问题</view>
18
+					<view class="cu-item arrow solid-bottom" v-for="(item,index) in list" :key="index" @tap="answer(item)">
19
+						<view class="content margin-left-sm">
20
+							<text class="text-black">{{item.title}}</text>
21
+						</view>
22
+					</view>
23
+				 </view>
24
+			</scroll-view>
25
+	</view>
26
+</template>
27
+
28
+<script>
29
+export default {
30
+  data() {
31
+    return {
32
+      phoneNumber: '07592222030',
33
+      list: [
34
+        {
35
+          id: 1,
36
+          title: '报课注意事项?',
37
+          content: '1、购买本课程后第三节课起不接受退课、退费申请;\n' +
38
+            '2、因节假日冲突未上的课程,会进行调课补回;\n' +
39
+            '3、请假两次以内可安排补课,第三次起不予补课及退费;\n' +
40
+            '4、本平台对以上细则有最终解释权。'
41
+        },
42
+        { id: 2, title: '怎么得到报课结果?', content: '报课成功之后会有消息提醒,请您耐心等待即可' },
43
+        { id: 3, title: '如何退课?', content: '发起退课之后,经过审核通过,退课金额会自动转到您的微信,请您放心就好了' },
44
+        { id: 4, title: '如何接送?', content: '进入当天课程即可进行接送,还可以看到最新课堂动态喔' }
45
+      ]
46
+    }
47
+  },
48
+  methods: {
49
+    answer(item) {
50
+      uni.showModal({
51
+        title: item.title,
52
+        content: item.content,
53
+        showCancel: false,
54
+        success: res => {
55
+          if (res.confirm) {
56
+
57
+          }
58
+        }
59
+      })
60
+    },
61
+    call() {
62
+      uni.makePhoneCall({
63
+        phoneNumber: this.phoneNumber
64
+      })
65
+    }
66
+  }
67
+}
68
+</script>
69
+
70
+<style lang="scss" scoped>
71
+@import '~@/common/css/mixin.scss';
72
+.page{
73
+	height:100vh;
74
+}
75
+.link{
76
+	position:relative;
77
+	width:60px;
78
+	height:60px;
79
+	line-height:60px;
80
+	color:#fff;
81
+	text-align:center;
82
+	border-radius:40%;
83
+	.button{
84
+    height: 75px;
85
+    width: 75px;
86
+    text-align: center;
87
+    position: absolute;
88
+    z-index: 2;
89
+    background: #fff;
90
+    border: none;
91
+    outline: none;
92
+    opacity: 0;
93
+	}
94
+}
95
+.questions{
96
+	height:calc(100vh - 240px);
97
+	&-title{
98
+		@include title(0,16px);
99
+		padding-left:40rpx;
100
+	}
101
+}
102
+</style>

+ 2 - 2
src/pages/mine/setting.vue

@@ -15,12 +15,12 @@
15 15
           </view>
16 16
 					<view>{{user.nickName}}</view>
17 17
         </view>
18
-        <view class="cu-item flex justify-between">
18
+        <!-- <view class="cu-item flex justify-between">
19 19
           <view class="content margin-left-sm">
20 20
             <text class="text-black">性别</text>
21 21
           </view>
22 22
           <view>{{user.gender?'女':'男'}}</view>
23
-        </view>
23
+        </view> -->
24 24
         <view class="cu-item" :class="phone?'':'arrow'" @tap="toBind">
25 25
           <view class="content margin-left-sm">
26 26
             <text class="text-black">手机号</text>

+ 107 - 104
src/pages/studentcenter/evaluate.vue

@@ -1,104 +1,107 @@
1
-<template>
2
-	<view class="page">
3
-		<cu-custom :isBack="true" title="评价"></cu-custom>
4
-		<view class="teacher flex bg-white padding">
5
-			<image mode="scaleToFill" :src="teacher_avatar" class="avatar lg"></image>
6
-				<view class="flex-sub margin-left">
7
-					<view class="teacher-title">{{teacher.username||''}}老师授课</view>
8
-					<view class="teacher-item">所属机构:{{teacher.agency_name||''}}</view>
9
-				<view class="teacher-exp flex">
10
-					<view class="exp-item">{{teacher.honor||''}}</view>
11
-					<view class="exp-item">{{teacher.introduce||''}}</view>
12
-				</view>
13
-			</view>
14
-		</view>
15
-		<view class="comment bg-white margin-top padding-lr padding-tb-lg">
16
-			<view>请评价(已对班主任匿名,请放心评价)</view>
17
-			<view class="flex text-center margin-top" style="padding-left:80rpx;">
18
-					<view class="flex-sub">
19
-						<img src="/static/imgs/class/satisfaction.png" mode="widthFix" style="width:70px;">
20
-						<view>满意</view>
21
-					</view>
22
-					<view class="flex-sub">
23
-						<img src="/static/imgs/class/unsatisfaction.png" mode="widthFix" style="width:70px;">
24
-						<view>一般</view>
25
-					</view>
26
-			</view>
27
-			<view class="flex margin-top-sm">
28
-				<view style="width:80rpx;line-height:32px;">课程</view>
29
-				<view class="flex-sub text-center">
30
-					<button class="cu-btn" :class="params.agency_statisfaction===2?'bg-cyan':'line-cyan'"  @tap="evaluate('agency_statisfaction',2)">满意</button>
31
-				</view>
32
-				<view class="flex-sub text-center">
33
-					<button class="cu-btn" :class="params.agency_statisfaction===1?'bg-cyan':'line-cyan'"  @tap="evaluate('agency_statisfaction',1)">一般</button>
34
-				</view>
35
-			</view>
36
-			<view class="flex margin-top-sm">
37
-				<view style="width:80rpx;line-height:32px;">老师</view>
38
-				<view class="flex-sub text-center"  @tap="params.statisfaction=2">
39
-					<button class="cu-btn" :class="params.statisfaction===2?'bg-cyan':'line-cyan'"  @tap="evaluate('statisfaction',2)">满意</button>
40
-				</view>
41
-				<view class="flex-sub text-center" @tap="params.statisfaction=1">
42
-					<button class="cu-btn" :class="params.statisfaction===1?'bg-cyan':'line-cyan'"  @tap="evaluate('statisfaction',1)">一般</button>
43
-				</view>
44
-			</view>
45
-			<view class="margin-top-lg">
46
-				<button class="cu-btn bg-cyan lg" style="width:100%;" @tap="comment">提交评价</button>
47
-			</view>
48
-		</view>
49
-	</view>
50
-</template>
51
-
52
-<script>
53
-import { _commentDetail, _tocomment } from '@/api/course'
54
-export default {
55
-  data() {
56
-    return {
57
-      teacher: {},
58
-      satisfaction: {},
59
-      params: {
60
-        agency_statisfaction: 2,
61
-        statisfaction: 2,
62
-        plan_id: '',
63
-        teacher_id: ''
64
-      },
65
-      teacher_avatar: '/static/imgs/class/logo0.png'
66
-    }
67
-  },
68
-  onLoad(options) {
69
-    const id = decodeURIComponent(options.plan_id)
70
-    if (!id) uni.navigateBack()
71
-    this.params.plan_id = id
72
-    this.init()
73
-  },
74
-  methods: {
75
-    init() {
76
-      _commentDetail({ plan_id: this.params.plan_id }).then(res => {
77
-        this.teacher = res.teacher_data
78
-        this.satisfaction = res.satisfaction_data
79
-      })
80
-    },
81
-    evaluate(type, value) { // 评价
82
-      this.params[type] = value
83
-    },
84
-    comment() {
85
-      _tocomment(this.params).then(res => {
86
-        uni.showToast({ title: res.msg, icon: 'success' })
87
-        uni.navigateBack()
88
-      })
89
-    }
90
-  }
91
-}
92
-</script>
93
-
94
-<style lang="scss" scoped>
95
-@import '~@/common/css/mixin.scss';
96
-.page{
97
-	height:100vh;
98
-}
99
-.teacher{
100
-	&-title{
101
-		@include title(4px,18px);
102
-	}
103
-}
104
-</style>
1
+<template>
2
+	<view class="page">
3
+		<cu-custom :isBack="true" title="评价"></cu-custom>
4
+		<view class="teacher flex bg-white padding">
5
+			<image mode="scaleToFill" :src="teacher_avatar" class="avatar lg"></image>
6
+				<view class="flex-sub margin-left">
7
+					<view class="teacher-title">{{teacher.username||''}}老师授课</view>
8
+					<view class="teacher-item">所属机构:{{teacher.agency_name||''}}</view>
9
+				<view class="teacher-exp flex">
10
+					<view class="exp-item">{{teacher.honor||''}}</view>
11
+					<view class="exp-item">{{teacher.introduce||''}}</view>
12
+				</view>
13
+			</view>
14
+		</view>
15
+		<view class="comment bg-white margin-top padding-lr padding-tb-lg">
16
+			<view>请评价(已对班主任匿名,请放心评价)</view>
17
+			<view class="flex text-center margin-top" style="padding-left:80rpx;">
18
+					<view class="flex-sub">
19
+						<img src="/static/imgs/class/satisfaction.png" mode="widthFix" style="width:70px;">
20
+						<view>满意</view>
21
+					</view>
22
+					<view class="flex-sub">
23
+						<img src="/static/imgs/class/unsatisfaction.png" mode="widthFix" style="width:70px;">
24
+						<view>一般</view>
25
+					</view>
26
+			</view>
27
+			<view class="flex margin-top-sm">
28
+				<view style="width:80rpx;line-height:32px;">课程</view>
29
+				<view class="flex-sub text-center">
30
+					<button class="cu-btn" :class="params.agency_statisfaction===2?'bg-cyan':'line-cyan'"  @tap="evaluate('agency_statisfaction',2)">满意</button>
31
+				</view>
32
+				<view class="flex-sub text-center">
33
+					<button class="cu-btn" :class="params.agency_statisfaction===1?'bg-cyan':'line-cyan'"  @tap="evaluate('agency_statisfaction',1)">一般</button>
34
+				</view>
35
+			</view>
36
+			<view class="flex margin-top-sm">
37
+				<view style="width:80rpx;line-height:32px;">老师</view>
38
+				<view class="flex-sub text-center"  @tap="params.statisfaction=2">
39
+					<button class="cu-btn" :class="params.statisfaction===2?'bg-cyan':'line-cyan'"  @tap="evaluate('statisfaction',2)">满意</button>
40
+				</view>
41
+				<view class="flex-sub text-center" @tap="params.statisfaction=1">
42
+					<button class="cu-btn" :class="params.statisfaction===1?'bg-cyan':'line-cyan'"  @tap="evaluate('statisfaction',1)">一般</button>
43
+				</view>
44
+			</view>
45
+			<view class="margin-top-lg">
46
+				<button class="cu-btn bg-cyan lg" style="width:100%;" @tap="comment">提交评价</button>
47
+			</view>
48
+		</view>
49
+	</view>
50
+</template>
51
+
52
+<script>
53
+import { _commentDetail, _tocomment } from '@/api/course'
54
+export default {
55
+  data() {
56
+    return {
57
+      teacher: {},
58
+      satisfaction: {},
59
+      params: {
60
+        agency_statisfaction: 2,
61
+        statisfaction: 2,
62
+        plan_id: '',
63
+        teacher_id: ''
64
+      },
65
+      teacher_avatar: '/static/imgs/class/logo0.png'
66
+    }
67
+  },
68
+  onLoad(options) {
69
+    const id = decodeURIComponent(options.plan_id)
70
+    if (!id) uni.navigateBack()
71
+    this.params.plan_id = id
72
+    this.init()
73
+  },
74
+  methods: {
75
+    init() {
76
+      _commentDetail({ plan_id: this.params.plan_id }).then(res => {
77
+        this.teacher = res.teacher_data
78
+        this.params.teacher_id = this.teacher ? this.teacher.teacher_id : 'undefined'
79
+        this.satisfaction = res.satisfaction_data
80
+      })
81
+    },
82
+    evaluate(type, value) { // 评价
83
+      this.params[type] = value
84
+    },
85
+    comment() {
86
+      _tocomment(this.params).then(res => {
87
+        uni.showToast({ title: res.msg, icon: 'success' })
88
+        setTimeout(() => {
89
+          uni.navigateBack()
90
+        }, 800)
91
+      })
92
+    }
93
+  }
94
+}
95
+</script>
96
+
97
+<style lang="scss" scoped>
98
+@import '~@/common/css/mixin.scss';
99
+.page{
100
+	height:100vh;
101
+}
102
+.teacher{
103
+	&-title{
104
+		@include title(4px,18px);
105
+	}
106
+}
107
+</style>

+ 6 - 6
src/store/user.js

@@ -1,6 +1,6 @@
1 1
 export default {
2 2
   state: {
3
-    user: null,
3
+    user: {},
4 4
     token: '',
5 5
     session: '',
6 6
     kid: 0,
@@ -9,7 +9,7 @@ export default {
9 9
   },
10 10
   getters: {
11 11
     user(state) {
12
-      return state.user || JSON.parse(uni.getStorageSync('user'))
12
+      return state.user.nickName ? state.user : JSON.parse(uni.getStorageSync('user'))
13 13
     },
14 14
     kid(state) {
15 15
       return state.kid || uni.getStorageSync('kid')
@@ -24,20 +24,20 @@ export default {
24 24
       return state.session || uni.getStorageSync('session')
25 25
     },
26 26
     carts(state) {
27
-      return state.carts || JSON.parse(uni.getStorageSync('carts'))
27
+      return state.carts.length > 0 ? state.carts : JSON.parse(uni.getStorageSync('carts'))
28 28
     }
29 29
   },
30 30
   mutations: {
31 31
     CLEAR(state) {
32
-      state.user = null
32
+      state.user = {}
33 33
       state.token = ''
34 34
       state.session = ''
35 35
       state.phone = ''
36 36
       state.kid = 0
37
-      state.carts = null
37
+      state.carts = []
38 38
       uni.clearStorageSync()
39 39
     },
40
-    SET_USER(state, user) {
40
+    SET_USER(state, user = {}) {
41 41
       state.user = user
42 42
       uni.setStorage({
43 43
         key: 'user',