lilei 4 年 前
コミット
a8cd9d5fb6

+ 9 - 11
components/uni-cart-fix/uni-cart-fix.vue

@@ -42,17 +42,15 @@
 			methods: {
 				toCart() {
 					let _this = this
-					this.$bindClick(function(){
-						if(_this.closeCurPage){
-							uni.redirectTo({
-								url:"/pages/cart/cart"
-							})
-						}else{
-							uni.navigateTo({
-								url:"/pages/cart/cart"
-							})
-						}
-					})
+					if(_this.closeCurPage){
+						uni.redirectTo({
+							url:"/pages/cart/cart"
+						})
+					}else{
+						uni.navigateTo({
+							url:"/pages/cart/cart"
+						})
+					}
 				},
 				btnClick() {
 					console.log('btnClick');

+ 1 - 5
components/uni-coods/uni-coods.vue

@@ -79,12 +79,8 @@
 			},
 			// 加入购物车
 			addCart(item) {
-				console.log('addCart0')
 				if(this.hasZgKucun(item)){
-					this.$bindClick(function(){
-						console.log('addCart1')
-						uni.$emit("addCart",{goodsNo:item.goodsNo,buyQty:1,time:new Date().getTime()})
-					})
+					uni.$emit("addCart",{goodsNo:item.goodsNo,buyQty:1,time:new Date().getTime()})
 				}else{
 					uni.showToast({
 						icon: 'none',

+ 1 - 39
main.js

@@ -9,45 +9,7 @@ Vue.use(uView)
 
 let vuexStore = require("@/store/$u.mixin.js")
 Vue.mixin(vuexStore)
-/*
-* 提示信息
-*/ 
-Vue.prototype.toashMsg = function (title) {
-	title = title == undefined ? "系统繁忙" : title;
-	uni.showToast({
-		title:title,
-		icon:'none',
-		duration: 2000
-	})
-}
-/**
- * 权限检查
- */
-Vue.prototype.$hasPermissions = function (value) {
- let isExist = false;
- let permissionsStr = store.state.vuex_userData.permCodes;
- // console.log(permissionsStr,'permissionsStr')
- if (permissionsStr == undefined || permissionsStr == null) {
-  return false;
- }
- let has = permissionsStr.find(item => {
-   return item == value
- })
- if (has) {
-  isExist = true;
- }
- return isExist;
-}
-// 防止重复触发事件
-Vue.prototype.$bindClick = function (fun) {
-	if(!store.state.vuex_isClick){
-		store.state.vuex_isClick = true
-		fun()
-		setTimeout(()=>{
-			store.state.vuex_isClick = false
-		},2000)
-	}
-}
+
 const app = new Vue({
 	store,
     ...App

+ 3 - 0
pages/goods/goods.vue

@@ -37,6 +37,9 @@
 			})
 			this.getGoods()
 		},
+		onUnload() {
+			uni.$off('addCart')
+		},
 		// 下拉刷新
 		onPullDownRefresh() {
 			console.log('refresh')

+ 4 - 3
pages/goods/goodsDetail.vue

@@ -88,6 +88,9 @@
 			this.goldLimit = opts.goldLimit
 			this.getDetail()
 		},
+		onUnload() {
+			uni.$off('addCart')
+		},
 		methods: {
 			// 查详情
 			getDetail(){
@@ -106,9 +109,7 @@
 			addCart(){
 				let _this = this
 				let item = this.goodContent
-				this.$bindClick(function(){
-					uni.$emit("addCart",{goodsNo:item.goodsNo,buyQty:_this.nums})
-				})
+				uni.$emit("addCart",{goodsNo:item.goodsNo,buyQty:_this.nums})
 			},
 			// 立即下单
 			toOrder(){

+ 3 - 0
pages/goods/index.vue

@@ -42,6 +42,9 @@
 		onLoad() {
 			this.pageInit()
 		},
+		onUnload() {
+			uni.$off('addCart')
+		},
 		// 下拉刷新
 		onPullDownRefresh() {
 			console.log('refresh')

+ 1 - 0
pages/index/index.vue

@@ -210,6 +210,7 @@
 					if(res.status == 200){
 						// 刷新购物车
 						this.getCartList()
+						uni.hideLoading()
 					}else{
 						uni.hideLoading()
 					}