Browse Source

bug修改

1004749546@qq.com 4 years ago
parent
commit
9341c9289c
1 changed files with 30 additions and 1 deletions
  1. 30 1
      components/uni-cart-fix/uni-cart-fix.vue

+ 30 - 1
components/uni-cart-fix/uni-cart-fix.vue

@@ -15,6 +15,7 @@
 </template>
 	<script>
 		import dragButton from "@/components/drag-button/drag-button.vue";
+		import {checkLogin} from '@/api/login.js'
 		export default {
 			components: {
 			    dragButton
@@ -32,11 +33,39 @@
 			computed: {
 				count() {
 					return this.$store.state.vuex_cartNums
-				},
+				}
+			},
+			data() {
+				return {
+					hasLogin: false
+				}
+			},
+			mounted() {
+				// 是否登录
+				checkLogin().then(res => {
+					console.log(res,'checkLogin')
+					this.hasLogin = res.status == 200
+				})
 			},
 			methods: {
 				toCart() {
 					let _this = this
+					if(!this.hasLogin) {
+						uni.showModal({
+						  title: '提示',
+						  content: '您尚未登录或登录已过期,请先进行登录',
+						  success (res) {
+						    if (res.confirm) {
+						      uni.navigateTo({
+						          url: '/pages/login/login'
+						      });
+						    } else if (res.cancel) {
+						      console.log('用户点击取消');
+						    }
+						  }
+						});
+						return
+					}
 					if(_this.closeCurPage){
 						uni.redirectTo({
 							url:"/pagesA/cart/cart"