Browse Source

加入购物车数量变化

lilei 4 years ago
parent
commit
a14d612f25

+ 3 - 8
components/uni-cart-fix/uni-cart-fix.vue

@@ -6,14 +6,9 @@
 </template>
 	<script>
 		export default {
-			props: {
-				count: {
-					type: Number,
-					default: 0
-				},
-			},
-			data() {
-				return {
+			computed: {
+				count() {
+					return this.$store.state.vuex_cartNums
 				}
 			},
 			methods: {

+ 10 - 2
components/uni-coods/uni-coods.vue

@@ -7,7 +7,7 @@
 		<view class="name">{{data.name}}</view>
 		<view class="price">
 			<view><text>{{data.price}}</text>乐豆</view>
-			<view><u-image width="48rpx" height="48rpx" src="/static/add-cart.png"></u-image></view>
+			<view @click="addCart"><u-image width="48rpx" height="48rpx" src="/static/add-cart.png"></u-image></view>
 		</view>
 	</view>
 </template>
@@ -31,7 +31,15 @@
 				loadingImg: '/static/loading.gif',
 				errorImg: '/static/imgError.png'
 			}
-		}
+		},
+		methods: {
+			// 加入购物车
+			addCart() {
+				console.log('add')
+				// 请求接口
+				this.$store.state.vuex_cartNums = Number(this.$store.state.vuex_cartNums) + 1
+			}
+		},
 	}
 </script>
 

+ 1 - 1
pages/goods/goods.vue

@@ -5,7 +5,7 @@
 			<uni-coods v-for="item in goodsList" :key="item.id" :data="item"></uni-coods>
 		</view>
 		<!-- 购物车 -->
-		<uni-cart-fix :count="15"></uni-cart-fix>
+		<uni-cart-fix></uni-cart-fix>
 	</view>
 </template>
 

+ 1 - 1
pages/index/index.vue

@@ -13,7 +13,7 @@
 			</view>
 		</view>
 		<!-- 购物车 -->
-		<uni-cart-fix :count="15"></uni-cart-fix>
+		<uni-cart-fix></uni-cart-fix>
 	</view>
 </template>
 

+ 5 - 20
store/index.js

@@ -18,16 +18,11 @@ let saveStateKeys = [
 	'vuex_userData',
 	'vuex_payType',
 	'vuex_payStatus',
-	'vuex_storeLabel',
 	'vuex_storeId',
 	'vuex_bizId',
-	'vuex_itemCode',
-	'vuex_itemTime',
 	'vuex_orderNo',
 	'vuex_orderStatus',
-	'vuex_workStatus',
-	'vuex_orderDjs',
-	'vuex_workStep',
+	'vuex_cartNums'
 ];
 
 // 保存变量到本地存储中
@@ -107,31 +102,21 @@ const store = new Vuex.Store({
 		vuex_userData: lifeData.vuex_userData ? lifeData.vuex_userData : '',
 		vuex_payType: lifeData.vuex_payType ? lifeData.vuex_payType : [], // 支付方式数据字典
 		vuex_payStatus: lifeData.vuex_payStatus ? lifeData.vuex_payStatus : [], // 支付状态数据字典
-		vuex_storeLabel: lifeData.vuex_storeLabel ? lifeData.vuex_storeLabel : [], // 网点标签数据字典
-		vuex_workStatus: lifeData.vuex_workStatus ? lifeData.vuex_workStatus : 'linking',// 设备是否正在运行中
-		// 设备运行页面的计时器
-		vuex_orderDjs: lifeData.vuex_orderDjs ? lifeData.vuex_orderDjs : 0, // 订单完成倒计时
-		vuex_workStep: lifeData.vuex_workStep ? lifeData.vuex_workStep : 0, // 进度条步骤
 		// 订单信息
 		vuex_storeId: lifeData.vuex_storeId ? lifeData.vuex_storeId : '',// 网点id
 		vuex_bizId: lifeData.vuex_bizId ? lifeData.vuex_bizId : '',// 设备编号
-		vuex_itemCode: lifeData.vuex_itemCode ? lifeData.vuex_itemCode : '',// 服务类型
-		vuex_itemTime: lifeData.vuex_itemTime ? lifeData.vuex_itemTime : '',// 服务时长
 		vuex_orderNo: lifeData.vuex_orderNo ? lifeData.vuex_orderNo : '',// 订单编号
 		vuex_orderStatus: lifeData.vuex_orderStatus ? lifeData.vuex_orderStatus : '',// 订单状态
+		// 购物车数量
+		vuex_cartNums: 5,
 		// 如果无需保存到本地永久存储,无需lifeData.xx方式
 		vuex_socket: null,
 		vuex_wsMessageData: '',
 		vuex_heartInterId: null,
 		// 当前网络连接状态
 		vuex_netStatus: '',
-		// 优惠券相关信息
-		vuex_couponInfo: {
-			storeId: '', // 网点id
-			customerType: '', // 客户类型
-			couponCode: '' // 优惠券码
-		},
-		vuex_kfMobile: '17792302576'
+		// 客服电话
+		vuex_kfMobile: ''
 	},
 	mutations: {
 		$uStore(state, payload) {