Browse Source

commit 购物车 订单下单

zhengjinyi 2 years ago
parent
commit
30a45b1afa

+ 97 - 252
components/cm-module/cm-cart-temp/index.vue

@@ -78,7 +78,7 @@
 													</view>
 													<view
 														class="count"
-														v-if="pros.validFlag == 2"
+														v-if="pros.validFlag == 1"
 														:class="[isshowDelbtn ? 'none' : 'show']"
 													>
 														<text class="count-tips" v-if="pros.number < pros.min"
@@ -151,7 +151,7 @@
 									<view class="pros-product">
 										<view class="producttitle">{{ failure.name }}</view>
 										<view class="productspec">规格:{{ failure.unit ? failure.unit : '' }}</view>
-										<view class="productstate">{{ failureStateText(failure.status) }}</view>
+										<view class="productstate">{{ failure.status | failurefilters }}</view>
 									</view>
 									<view class="pros-marks" v-if="failure.isFailureLayer"></view>
 								</view>
@@ -268,7 +268,7 @@ export default {
 	},
 	data() {
 		return {
-			staticUrl:this.global.staticUrl,
+			staticUrl: this.global.staticUrl,
 			CustomBar: this.CustomBar, // 顶部导航栏高度
 			isIphoneX: this.$store.state.isIphoneX,
 			userId: 0,
@@ -278,9 +278,9 @@ export default {
 			handlerPros: {}, // 监听单挑促销商品
 			failureList: [], // 失效商品列表
 			goodsList: [], // 购物车的商品
-			promotionsList: [], // 促销列表
-			totalCouponList: [], // 优惠券算列表
-			eligibleCoupons: [], // 最终需要用到优惠券
+			// promotionsList: [], // 促销列表
+			// totalCouponList: [], // 优惠券算列表
+			// eligibleCoupons: [], // 最终需要用到优惠券
 			setGoodData: '', // 确认订单的商品
 			isCheckAll: false, // 是否全选
 			kindCount: 0, // 购物车宝贝数量
@@ -303,11 +303,8 @@ export default {
 			submitIds: [],
 			checkenProsList: [],
 			popupShow: false,
-			popupShow0: false,
-			popupShow1: false,
 			popupShow2: false,
 			currentTab: 1,
-			navbar: [{ name: '未领取', num: 0 }, { name: '已领取', num: 0 }],
 			couponParam: {
 				// 获取弹窗优惠券领取参数
 				userId: 0,
@@ -326,10 +323,10 @@ export default {
 					plain: true //是否空心
 				},
 				{
-					text: '去升级',
+					text: '确认',
 					customStyle: {
 						color: '#fff',
-						bgColor: 'linear-gradient(90deg, #F28F31 0%, #FF5B00 100%)'
+						bgColor: '#F3B574'
 					},
 					plain: false
 				}
@@ -355,6 +352,12 @@ export default {
 		}
 	},
 	filters: {
+		failurefilters(state) {
+			const map = {
+				3: '商品已下架'
+			}
+			return map[state]
+		},
 		NumFormat(value) {
 			//处理金额
 			return Number(value).toFixed(2)
@@ -371,101 +374,60 @@ export default {
 			this.isCheckAll = false //是否全选
 			this.submitIds = []
 			this.checkenProsList = []
-			this.eligibleCoupons = []
-			this.userId = this.couponParam.userId = userInfo.userId ? userInfo.userId : 0
-			this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
-			this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
+			this.userId = userInfo.userId ? userInfo.userId : 0
 			this.initGetCartGoodsList()
 		},
-		isShowVipFlag(pros) {
-			if (pros.priceFlag != 1) {
-				if (this.userIdentity == 4 && this.vipFlag == 1) {
-					return true
-				} else if (this.userIdentity == 2) {
-					return true
-				}
+		async initGetCartGoodsList() {
+			//初始化购物车 index:1
+			const res = await this.ProductService.QueryShoppingCartList({ userId: this.userId, source: 2 })
+			let data = res.data
+			console.log('data', data)
+			this.kindCount = data.kindCount
+			this.$store.commit('updateAllNum', data.kindCount)
+			if (data.list.length === 0 && data.invalid.length === 0) {
+				this.isEmpty = true
 			}
+			this.infoCartData(data.list)
+			this.infoInvalidData(data.invalid)
+			this.skeletonShow = false
 		},
-		initLogin() {
-			this.$api.redirectTo('/pages/login/login')
-		},
-		clickPopupShow(pros, type) {
-			this.popupShow = true
-			this.handlerPros = pros
-		},
-		setScrollHeight() {
-			// 窗口高度-footer高度
-			const { windowHeight, pixelRatio } = uni.getSystemInfoSync()
-			setTimeout(() => {
-				const query = uni.createSelectorQuery().in(this)
-				query.selectAll('.footer').boundingClientRect()
-				query.exec(res => {
-					this.windowHeight = windowHeight
-					if (res[0][0]) {
-						this.scrollHeight = windowHeight - res[0][0].height
-					}
-				})
-			}, 500)
-		},
-		initGetCartGoodsList() {
-			//初始化购物车 index:1
-			this.ProductService.QueryShoppingCartList({ userId: this.userId, source: 2 })
-				.then(response => {
-					this.skeletonShow = false
-					let data = response.data
-					this.kindCount = data.kindCount
-					this.promotionsList = data.promotions
-					this.totalCouponList = data.couponList
-					this.$store.commit('updateAllNum', data.kindCount)
-					if (data.list.length > 0 || data.invalid.length > 0) {
-						this.isEmpty = false
-					} else {
-						this.isEmpty = true
-					}
-					if (data.list && data.list.length > 0) {
-						this.goodsList = data.list
-						this.goodsList.forEach((supplier, index) => {
-							supplier.cartList.forEach(pros => {
-								pros.shopId = supplier.shopId
-								pros.isStep = false
-								if (pros.stock === 0 || pros.number > pros.stock) {
-									supplier.isDisable = true
-									pros.isDisable = true
-								} else {
-									pros.isDisable = false
-								}
-								if (pros.step === 2) {
-									if (pros.number % pros.min != 0) {
-										pros.number = pros.min
-										this.totalShopPeice()
-										this.updateShoppogNum(pros)
-									}
-								}
-							})
-						})
-						this.totalShopPeice()
+		infoCartData(data) {
+			//初始化有效商品
+			this.goodsList = data.map((supplier, index) => {
+				supplier.cartList.forEach(pros => {
+					pros.shopId = supplier.shopId
+					pros.isStep = false
+					if (pros.stock === 0 || pros.number > pros.stock) {
+						supplier.isDisable = true
+						pros.isDisable = true
 					} else {
-						this.goodsList = []
+						pros.isDisable = false
 					}
-					if (data.invalid && data.invalid.length > 0) {
-						let newFailureList = [],
-							isFailureLayer
-						data.invalid.forEach((failure, index) => {
-							if (failure.status == 1 || failure.status == 2) {
-								isFailureLayer = true
-							} else {
-								isFailureLayer = false
-							}
-							newFailureList.push(Object.assign({}, failure, { isFailureLayer: isFailureLayer }))
-						})
-						this.failureList = newFailureList
-					} else {
-						this.failureList = []
+					if (pros.step === 2) {
+						if (pros.number % pros.min != 0) {
+							pros.number = pros.min
+							this.totalShopPeice()
+							this.updateShoppogNum(pros)
+						}
 					}
 				})
-				.catch(error => {
-					this.$util.msg(error.msg, 2000)
-				})
+				return supplier
+			})
+			this.totalShopPeice()
+		},
+		infoInvalidData(data) {
+			// 初始化失效商品
+			this.failureList = data.map((failure, index) => {
+				failure.isFailureLayer = false
+				if (failure.status == 1 || failure.status == 2) {
+					failure.isFailureLayer = true
+				}
+				return failure
+			})
+		},
+		clickPopupShow(pros, type) {
+			this.popupShow = true
+			this.handlerPros = pros
 		},
 		handleCheckFailure(failure) {
 			//  选择失效商品
@@ -517,23 +479,21 @@ export default {
 		},
 		updateCheckAllBtn() {
 			// 全选勾选判断
-			let goodsCheckedLength = 0,
-				goodsList = this.goodsList,
-				failureList = this.failureList
-			goodsList.forEach(item => {
+			let goodsCheckedLength = 0
+			this.goodsList.forEach(item => {
 				if (item.isChecked) {
 					goodsCheckedLength++
 				}
 			})
-			failureList.forEach(failureItem => {
+			this.failureList.forEach(failureItem => {
 				if (failureItem.isChecked) {
 					goodsCheckedLength++
 				}
 			})
 			if (this.isshowDelbtn) {
-				this.isCheckAll = goodsCheckedLength === goodsList.length + failureList.length
+				this.isCheckAll = goodsCheckedLength === this.goodsList.length + this.failureList.length
 			} else {
-				this.isCheckAll = goodsCheckedLength === goodsList.length
+				this.isCheckAll = goodsCheckedLength === this.goodsList.length
 			}
 		},
 		handleCheckShop(supplier) {
@@ -607,20 +567,16 @@ export default {
 		handleCheckAll() {
 			//全选方法内调用方法
 			this.isCheckAll = !this.isCheckAll
-			if (!this.isCheckAll) {
-				this.popupShow1 = false
-			}
 			this.updateBothCheckBtn()
 		},
 		totalShopPeice() {
 			//每次所属会所下的商品增减重新计算合计价格&减去含有下架的商品
 			this.goodsList.map((item, index) => {
-				let _totalPrice = 0
+				let totalPrice = 0
 				item.cartList.forEach(pros => {
-					let _price = pros.price * pros.number
-					_totalPrice += pros.price * pros.number
+					totalPrice += pros.price * pros.number
 				})
-				item.totalPrice = _totalPrice
+				item.totalPrice = totalPrice
 			})
 		},
 		totalPeice() {
@@ -832,24 +788,20 @@ export default {
 				this.$api.navigateTo(`/pages/goods/product?id=${failure.productId}`)
 			}
 		},
-		failureStateText(state) {
-			let stateText = '',
-				stateTextObject = {
-					1: '商品已丢失',
-					2: '商品已停售',
-					3: '商品已下架',
-					4: '商品已售罄',
-					5: '价格仅会员可见,您不能购买',
-					6: '未公开价格',
-					7: '库存不足',
-					8: '价格仅医美机构可见'
-				}
-			Object.keys(stateTextObject).forEach(key => {
-				if (key == state) {
-					stateText = stateTextObject[key]
-				}
-			})
-			return stateText
+		handleShouUnitPopup(pros) {
+			// 规格弹窗
+			this.popupShow2 = true
+			this.handlePros = pros
+		},
+		hideMobel() {
+			this.modal = false
+		},
+		handleClick(e) {
+			//个人机构跳转升级页面
+			if (e.index == 1) {
+				this.shoppingCartDelete({ userId: this.userId, skuIds: this.delSkuIds })
+			}
+			this.modal = false
 		},
 		setHeaderBtnPosi() {
 			// 获得胶囊按钮位置信息
@@ -866,126 +818,19 @@ export default {
 			})
 			return systeminfo
 		},
-		PromotionsFormat(promo) {
-			//促销活动类型数据处理
-			if (promo != null) {
-				if (promo.type == 1 && promo.mode == 1) {
-					return true
-				} else {
-					return false
-				}
-			}
-			return false
-		},
-		queryPopupCoupons() {
-			// 获取优惠券列表调用 apisMixins -> apiShoppingCartGetCoupon
-			this.apiShoppingCartGetCoupon(this.couponParam)
-		},
-		receiveCoupon(coupon) {
-			// 点击优惠券领取按钮,友盟埋点收集领取优惠券
-			if (process.env.NODE_ENV != 'development') {
-				this.$uma.trackEvent('Um_Event_cartCouponReceive', {
-					Um_Key_PageName: '机构购物车',
-					Um_Key_EvenName: '领取优惠券',
-					Um_Key_CouponId: `${coupon.couponId}`
-				})
-			}
-			// 领取优惠券调用 apisMixins -> apiReceiveCoupon
-			this.apiReceiveCoupon({ userId: this.couponParam.userId, couponId: coupon.couponId, source: 1 })
-		},
-		handleToDeductCoupon(coupon) {
-			// 点击采美豆抵扣优惠券
-			if (process.env.NODE_ENV != 'development') {
-				this.$uma.trackEvent('Um_Event_userCouponCollectionBuy', {
-					Um_Key_PageName: '领券中心',
-					Um_Key_EvenName: '抵扣优惠券',
-					Um_Key_CouponId: `${coupon.couponId}`
-				})
-			}
-			if (this.hasLogin) {
-				if (this.userIdentity === 1 || this.userIdentity === 3) {
-					this.$util.msg('您的身份暂不支持领取优惠券', 2000)
-					return
-				}
-				// 调用 apisMixins -> apiWeChatPayCouponBeans
-				this.apiWeChatPayCouponBeans({ source: 1, userId: this.couponParam.userId, couponId: coupon.couponId })
-			} else {
-				this.$api.navigateTo('/pages/login/login')
-			}
-		},
-		handlePayCoupon(coupon) {
-			// 点击购买优惠券,友盟埋点收集购买优惠券
-			if (process.env.NODE_ENV != 'development') {
-				this.$uma.trackEvent('Um_Event_cartCouponBuy', {
-					Um_Key_PageName: '机构购物车',
-					Um_Key_EvenName: '购买优惠券',
-					Um_Key_CouponId: `${coupon.couponId}`
-				})
-			}
-			// 生成购买优惠券记录Id调用 apisMixins -> apiReceiveCoupon
-			this.apiWeChatCouponRecord({ userId: this.userId, couponId: coupon.couponId }, coupon)
-		},
-		hideMobel() {
-			this.modal = false
-		},
-		handleClick(e) {
-			//个人机构跳转升级页面
-			if (e.index == 1) {
-				this.$api.navigateTo('/pages/login/apply')
-			}
-			this.modal = false
-		},
-		showPopup(index, shop) {
-			// 显示popup弹窗
-			switch (index) {
-				case 0:
-					// 友盟埋点收集领券按钮
-					if (process.env.NODE_ENV != 'development') {
-						this.$uma.trackEvent('Um_Event_cartCouponButton', {
-							Um_Key_PageName: '机构购物车',
-							Um_Key_EvenName: '点击领券按钮',
-							Um_Key_userId: `${this.userId}`
-						})
+		setScrollHeight() {
+			// 窗口高度-footer高度
+			const { windowHeight, pixelRatio } = uni.getSystemInfoSync()
+			setTimeout(() => {
+				const query = uni.createSelectorQuery().in(this)
+				query.selectAll('.footer').boundingClientRect()
+				query.exec(res => {
+					this.windowHeight = windowHeight
+					if (res[0][0]) {
+						this.scrollHeight = windowHeight - res[0][0].height
 					}
-					this.currentTab = 0
-					this.couponParam.status = 1
-					this.couponParam.shopId = shop.shopId
-					this.queryPopupCoupons()
-					this.popupShow0 = true
-					break
-				case 1:
-					this.popupShow1 = true
-					break
-			}
-		},
-		handleShouUnitPopup(pros) {
-			// 规格弹窗
-			this.popupShow2 = true
-			this.handlePros = pros
-		},
-		hidePopup(index) {
-			// 隐藏popup弹窗
-			switch (index) {
-				case 0:
-					this.popupShow0 = false
-					break
-				case 1:
-					this.popupShow1 = false
-					break
-			}
-		},
-		couponChange(e) {
-			this.currentTab = e.index
-			switch (this.currentTab) {
-				case 0:
-					this.couponParam.status = 1
-					this.queryPopupCoupons()
-					break
-				case 1:
-					this.couponParam.status = 2
-					this.queryPopupCoupons()
-					break
-			}
+				})
+			}, 500)
 		}
 	}
 }
@@ -1888,7 +1733,7 @@ page {
 			width: 200rpx;
 			height: 100%;
 			background: $btn-confirm;
-			font-size: $font-size-28;
+			font-size: $font-size-26;
 			line-height: 84rpx;
 			color: #ffffff;
 			display: flex;
@@ -1924,8 +1769,8 @@ page {
 			border-radius: 40rpx;
 		}
 		.btn.btn-cancel {
-			background: #F7F7F7;
-			color: #B2B2B2;
+			background: #f7f7f7;
+			color: #b2b2b2;
 		}
 		.btn.btn-confirm {
 			background: #ff2a2a;

+ 109 - 112
components/cm-module/cm-cart-temp/mixins/apisMixins.js

@@ -1,128 +1,125 @@
 import Vue from 'vue'
 const apisMixins = {
     methods: {
-        apiUserClubCheckSku(params){
-            this.ProductService.ShoppingCheckSku(params)
-			    .then(response => {
-			        setTimeout(() => {
-			           this.initGetCartGoodsList()
-			        }, 1500)
-			    })
-			    .catch(error => {
-			        this.$util.msg(error.msg, 2000)
-			    })
+        // 购物车修改SKU规格
+        async apiUserClubCheckSku(params) {
+            try {
+                await this.ProductService.ShoppingCheckSku(params)
+                setTimeout(() => {
+                    this.initGetCartGoodsList()
+                }, 1500)
+            } catch (error) {
+                console.log('error', error)
+            }
         },
-        apiWeChatCouponRecord(params,coupon){
-            //调用购买优惠券
-            this.PayService.WeChatCouponRecord(params)
-                .then(response => {
-                    this.MiniWxPayFor(coupon, response.data.couponRecordId)
-                })
-                .catch(error => {
-                    if (error.code == -1) {
-                        //个人机构不能购买
-                        this.contentModalText = '该优惠券仅限医美机构购买,请升级为医美机构后再次购买。'
-                        this.modal = true
-                    } else if (error.code == -2) {
-                        //会员机构不是医美机构不能购买
-                        this.$util.msg('该优惠券仅限医美机构购买', 2000)
-                    }
-                })
-			
+        //调用购买优惠券
+        async apiWeChatCouponRecord(params, coupon) {
+            try {
+                const res = await this.PayService.WeChatCouponRecord(params)
+                this.MiniWxPayFor(coupon, res.data.couponRecordId)
+                setTimeout(() => {
+                    this.initGetCartGoodsList()
+                }, 1500)
+            } catch (error) {
+                if (error.code == -1) {
+                    //个人机构不能购买
+                    this.contentModalText = '该优惠券仅限医美机构购买,请升级为医美机构后再次购买。'
+                    this.modal = true
+                } else if (error.code == -2) {
+                    //会员机构不是医美机构不能购买
+                    this.$util.msg('该优惠券仅限医美机构购买', 2000)
+                }
+            }
         },
         async MiniWxPayFor(coupon, couponRecordId) {
             // 微信支付
-		    const wechatcode = await authorize.getCode('weixin')
-		    const params = {
-		        userId: this.userId,
-		        couponId: coupon.couponId,
-		        couponRecordId: couponRecordId,
-		        payType: 'XCX',
-		        code: wechatcode,
-		        source: 1 //支付来源 1 小程序 2 WWW
-		    }
-		    this.weChatMiniCouponWxPay(
-		        params,
-		        'Um_Event_cartCouponPay',
-		        '机构购物车',
-		        '线上支付优惠券',
-		        coupon.couponId,
-		        this.userId
-		    )
+            const wechatcode = await authorize.getCode('weixin')
+            const params = {
+                userId: this.userId,
+                couponId: coupon.couponId,
+                couponRecordId: couponRecordId,
+                payType: 'XCX',
+                code: wechatcode,
+                source: 1 //支付来源 1 小程序 2 WWW
+            }
+            this.weChatMiniCouponWxPay(
+                params,
+                'Um_Event_cartCouponPay',
+                '机构购物车',
+                '线上支付优惠券',
+                coupon.couponId,
+                this.userId
+            )
         },
-        apiWeChatPayCouponBeans(params){
-            //调用采美豆抵扣优惠券
-            this.PayService.WeChatPayCouponBeans(params)
-                .then(response => {
-                    this.$util.msg('抵扣成功', 1500)
-                    setTimeout(() => {
-                        this.currentTab = 1
-                        this.couponParam.status = 2
-                        this.queryPopupCoupons()
-                    }, 1500)
-                })
-                .catch(error => {
-                    this.$util.msg(error.msg, 2000)
-                })
+        //调用采美豆抵扣优惠券
+        async apiWeChatPayCouponBeans(params) {
+            try {
+                await this.PayService.WeChatPayCouponBeans(params)
+                this.$util.msg('抵扣成功', 1500)
+                setTimeout(() => {
+                    this.currentTab = 1
+                    this.couponParam.status = 2
+                    this.queryPopupCoupons()
+                }, 1500)
+            } catch (error) {
+                this.$util.msg(error.msg, 2000)
+            }
         },
-        apiReceiveCoupon(params){
-            //领取优惠券
-            this.ProductService.ReceiveCoupon(params)
-                .then(response => {
-                    this.$util.msg('领取成功', 1500, true, 'success')
-                    setTimeout(() => {
-                        this.currentTab = 1
-                        this.couponParam.status = 2
-                        this.queryPopupCoupons()
-                    }, 1500)
-                })
-                .catch(error => {
-                    this.$util.msg(error.msg, 2000)
-                })
+        //领取优惠券
+        async apiReceiveCoupon(params) {
+            try {
+                await this.ProductService.ReceiveCoupon(params)
+                this.$util.msg('领取成功', 1500, true, 'success')
+                setTimeout(() => {
+                    this.currentTab = 1
+                    this.couponParam.status = 2
+                    this.queryPopupCoupons()
+                }, 1500)
+            } catch (error) {
+                this.$util.msg(error.msg, 2000)
+            }
         },
-        apiShoppingCartGetCoupon(params){
-            // 获取弹窗优惠券列表
-            this.ProductService.ShoppingCartGetCoupon(params)
-                .then(response => {
-                    let data = response.data
-                    this.navbar[0].num = data.notCouponNum
-                    this.navbar[1].num = data.couponNum
-                    if (data.couponList && data.couponList.length > 0) {
-                        this.productCouponList = data.couponList
-                        this.isCouponEmpty = false
-                    } else {
-                        this.isCouponEmpty = true
-                    }
-                })
-                .catch(error => {
-                    console.log('获取优惠券列表失败')
-                })
+        // 获取弹窗优惠券列表
+        async apiShoppingCartGetCoupon(params) {
+            try {
+                const res = await this.ProductService.ShoppingCartGetCoupon(params)
+                let data = res.data
+                this.navbar[0].num = data.notCouponNum
+                this.navbar[1].num = data.couponNum
+                if (data.couponList && data.couponList.length > 0) {
+                    this.productCouponList = data.couponList
+                    this.isCouponEmpty = false
+                } else {
+                    this.isCouponEmpty = true
+                }
+            } catch (error) {
+                
+            }
         },
-        apiShoppingCartUpdate(params) {
-            //更新购物车商品
-            this.ProductService.ShoppingCartUpdate(params)
-                .then(response => {
-                    this.isshowDelbtn = false
-                })
-                .catch(error => {
-                    this.$util.msg(error.msg, 2000)
-                })
+        //更新购物车商品
+        async apiShoppingCartUpdate(params) {
+            try{
+                await this.ProductService.ShoppingCartUpdate(params)
+                this.isshowDelbtn = false
+            }catch(error){
+			   console.log('更新购物车商品数量失败')
+            }
         },
-        shoppingCartDelete(params) { 
-            // 删除购物车商品
-            this.ProductService.ShoppingCartDelete(params)
-                .then(response => {
-                    this.$util.msg('删除成功', 2000)
-                    setTimeout(() => {
-                        this.isshowDelbtn = false
-                        this.initGetCartGoodsList()
-                    }, 2000)
-                })
-                .catch(error => {
-                    this.$util.msg(error.msg, 2000)
-                })
+		 // 删除购物车商品
+        async shoppingCartDelete(params) {
+            try{
+            	await this.ProductService.ShoppingCartDelete(params)
+                this.$util.msg('删除成功', 2000)
+                setTimeout(() => {
+				    this.isshowDelbtn = false
+				    this.initGetCartGoodsList()
+                }, 2000)
+            }catch(error){
+            	console.log('购物车删除失败')
+            }
+
         }
     }
 }
 
-export default apisMixins
+export default apisMixins

+ 9 - 19
components/cm-module/cm-cart-temp/mixins/cartMixins.js

@@ -4,7 +4,7 @@ import Vue from 'vue'
 const cartMixins = {
     data() {
         return {
-			
+			delSkuIds:''
         }
     },
     methods: {
@@ -40,12 +40,6 @@ const cartMixins = {
                 return
             }
             // 友盟埋点购物车去结算点击事件
-            if (process.env.NODE_ENV != 'development') {
-                this.$uma.trackEvent('Um_Event_shoppingCartConfirmOrder', {
-                    Um_Key_PageName: '去结算',
-                    Um_Key_SourcePage: '底部菜单购物车'
-                })
-            }
             let cartSkuIds = { skuIds: skuIds.substring(0, skuIds.lastIndexOf(',')) }
             this.$api.navigateTo(
                 `/pages/user/order/create-order?type=2&data=${JSON.stringify({ data: cartSkuIds })}`
@@ -67,35 +61,31 @@ const cartMixins = {
             this.apiShoppingCartUpdate(params)
         },
         handleDeleteCart() { //删除购物车商品
-            let delSkuIds = ''
             this.goodsList.forEach(delitem => {
                 delitem.cartList.forEach(pros => {
                     if (pros.isChecked) {
-                        delSkuIds += pros.skuId + ','
+                        this.delSkuIds += pros.skuId + ','
                     }
                 })
             })
             this.failureList.forEach(failure => {
                 if (failure.isChecked) {
-                    delSkuIds += failure.skuId + ','
+                    this.delSkuIds += failure.skuId + ','
                 }
             })
-            if (delSkuIds.length == 0) {
+            if (this.delSkuIds.length === 0) {
                 this.$util.msg('请选择要删除的商品~', 2000)
                 return
             }
-            this.$util.modal('', '确定删除选中的商品吗?', '确定', '取消', true, () => {
-                this.shoppingCartDelete({ userId: this.userId, skuIds: delSkuIds })
-            })
+			this.modal = true
+			this.contentModalText = '确定删除选中的商品吗?'
         },
         handleDeletefailures() { // 一键清楚所有失效商品
-            let delSkuIds = ''
             this.failureList.forEach(failure => {
-                delSkuIds += failure.skuId + ','
-            })
-            this.$util.modal('', '确定清空全部失效商品吗?', '确定', '取消', true, () => {
-                this.shoppingCartDelete({ userId: this.userId, skuIds: delSkuIds })
+                this.delSkuIds += failure.skuId + ','
             })
+			this.modal = true
+			this.contentModalText = '确定清空全部失效商品吗?'
         }
     }
 }

+ 12 - 4
components/cm-module/orderDetails/orderButton.vue

@@ -5,6 +5,7 @@
 			<!-- <view class="btn btn-payment" v-if="order.affirmPaymentFlag == 10" @click.stop="btnConfirm('payment',order)">确认打款<text>供应商</text></view> -->
 			<!-- <view class="btn btn-confirm" v-if="btnState.isConfirmation" @click.stop="btnConfirm('confirmation',order)">确认订单</view> -->
 			<view class="btn btn-pay" v-if="btnState.isPay" @click.stop="btnConfirm('pay',order)">付款</view>
+			<view class="btn btn-upload" v-if="btnState.isUpload" @click.stop="btnConfirm('pay',order)">上传凭证</view>
 			<view class="btn btn-share" @click.stop="onShareCode">
 				<view class="tips" v-if="shareCode">分享码:{{shareCode}}</view>
 				分享订单
@@ -14,8 +15,8 @@
 			<view class="btn btn-query" v-if="btnState.isQuery && order.secondHandOrderFlag!=1" @click.stop="btnConfirm('query',order)">查看物流</view>
 			<view class="btn btn-firm" v-if="btnState.isConfirm" @click.stop="btnConfirm('confirm',order)">
 				确认收货
-				<view class="tips">采美豆<text class="line"></text></view>
 			</view>
+			
 		</view>
 	</view>
 </template>
@@ -49,10 +50,11 @@
 				mapStateArr:[
 					{label:'isQuery',val:[4,5,12,13,33,22,23,32,77],status: true},
 					{label:'isDelete',val:[6],status: true},
-					{label:'isCancel',val:[0,111],status: true},
+					{label:'isCancel',val:[0,111,333],status: true},
 					{label:'isConfirm',val:[33],status: true},
 					{label:'isConfirmation',val:[0],status: true},
-					{label:'isPay',val:[11,12,13,21,22,23,111],status: true},
+					{label:'isPay',val:[11,12,13,21,22,23,111,333],status: true},
+					{label:'isUpload',val:[11,12,13,21,22,23,111,333],status: true},
 				]
 			}
 		},
@@ -137,7 +139,7 @@
 				top: 24rpx;
 			}
 			.btn{
-				width: 160rpx;
+				width: 150rpx;
 				height:  64rpx;
 				margin:22rpx 22rpx 22rpx 0;
 				line-height: 64rpx;
@@ -173,6 +175,12 @@
 				border: 2rpx solid $btn-confirm;
 				color: #fff;
 			}
+			.btn-upload{
+				background:#0ABC64;
+				margin-right: 0;
+				border: 2rpx solid #0ABC64;
+				color: #fff;
+			}
 			.btn-firm{
 				position:relative;
 				.tips{

+ 10 - 3
components/cm-module/orderDetails/orderListButton.vue

@@ -3,6 +3,7 @@
 		<!-- 底部按钮 -->
 		<view class="button-content">
 			<view class="btn btn-pay" v-if="btnState.isPay" @click.stop="btnConfirm('pay',order)">付款</view>
+			<view class="btn btn-upload" v-if="btnState.isUpload" @click.stop="btnConfirm('pay',order)">上传凭证</view>
 			<!-- <view class="btn btn-confirm" v-if="btnState.isConfirmation" @click.stop="btnConfirm('confirmation',order)">确认订单</view> -->
 			<view class="btn btn-share"  @click.stop="onShareCode(order.orderId)">分享订单</view>
 			<view class="btn btn-cancel" v-if="btnState.isCancel" @click.stop="btnConfirm('cancel',order)">取消订单</view>
@@ -10,7 +11,6 @@
 			<view class="btn btn-query" v-if="btnState.isQuery && order.secondHandOrderFlag!=1" @click.stop="btnConfirm('query',order)">查看物流</view>
 			<view class="btn btn-firm" v-if="btnState.isConfirm" @click.stop="btnConfirm('confirm',order)">
 				确认收货
-				<view class="tips">采美豆<text class="line"></text></view>
 			</view>
 		</view>
 	</view>
@@ -35,10 +35,11 @@
 				mapStateArr:[
 					{label:'isQuery',val:[4,5,12,13,33,22,23,32,77],status: true},
 					{label:'isDelete',val:[6],status: true},
-					{label:'isCancel',val:[0,111],status: true},
+					{label:'isCancel',val:[0,111,333],status: true},
 					{label:'isConfirm',val:[33],status: true},
 					{label:'isConfirmation',val:[0],status: true},
-					{label:'isPay',val:[11,12,13,21,22,23,111],status: true},
+					{label:'isPay',val:[11,12,13,21,22,23,111,333],status: true},
+					{label:'isUpload',val:[11,12,13,21,22,23,111,333],status: true},
 				]
 			}
 		},
@@ -180,6 +181,12 @@
 				border: 2rpx solid $btn-confirm;
 				color: #fff;
 			}
+			.btn-upload{
+				background:#0ABC64;
+				margin-right: 0;
+				border: 2rpx solid #0ABC64;
+				color: #fff;
+			}
 			.btn-firm{
 				position:relative;
 				.tips{

+ 11 - 2
mixins/appMixins.js

@@ -2,6 +2,15 @@ import Vue from 'vue'
 import { mapState,mapMutations} from 'vuex'
 import authorize from '@/common/config/authorize.js'
 const appMixins = {
+	data() {
+	    return {
+			authParams: {
+			    code: '',
+			    encryptedData: '',
+			    iv: ''
+			}
+	    }
+	},
     computed: {
         ...mapState(['hasLogin','isWxAuthorize'])
     },
@@ -38,12 +47,12 @@ const appMixins = {
             let date = Date.now()
             return (date -t) < 2*60*1000 ? false : true
         },
-        initSetSystemInfo() {
+        async initSetSystemInfo() {
             let self = this
             uni.getSystemInfo({
                 success: function(e) {
                     let modelmes = e.model
-                    console.log(e)
+                    console.log('System',e)
                     if (modelmes.search('iPhone 11') !== -1 || modelmes.search('iPhone 11 Pro Max') !==
 						-1 || modelmes.search('iPhone X') != -1) { //XS,XR,XS MAX均可以适配
                         self.$store.dispatch('setVariableFun', true)

+ 1 - 1
pages/goods/cart.vue

@@ -58,7 +58,7 @@
 			if(this.hasLogin){
 				this.$refs.cart.initData()
 			}else{
-				this.$refs.cart.initLogin()
+				this.$api.redirectTo('/pages/login/login')
 			}
 		},
 	}

+ 0 - 7
pages/goods/mixins/proMixins.js

@@ -19,13 +19,6 @@ const proMixins = {
         buyProductCart() {
 		    //底部购物车按钮点击
 		    if (this.hasLogin) {
-		        // 友盟埋点商品详情购物车入口点击事件
-		        if (process.env.NODE_ENV != 'development') {
-		            this.$uma.trackEvent('Um_Event_ProductShoppingCart', {
-		                Um_Key_PageName: '去购物车',
-		                Um_Key_SourcePage: '商品详情购物车入口'
-		            })
-		        }
 		        this.$api.navigateTo('/pages/goods/cart')
 		    } else {
 		        this.$api.navigateTo('/pages/login/login?type=1')

+ 7 - 8
pages/goods/product.vue

@@ -396,15 +396,14 @@ export default {
 					break
 			}
 		},
-		ProductCartNumber() {
+		async ProductCartNumber() {
 			// 获取用户购物车储量
-			this.ProductService.ProductCartNumber({ userId: this.userId })
-				.then(response => {
-					this.bottomCartNumber = response.data
-				})
-				.catch(error => {
-					console.log('获取购物车数量失败')
-				})
+			try {
+			    const res = await this.OrderService.ShoppingCartCount({ userId: this.userId })
+			    this.bottomCartNumber = res.data
+			} catch (error) {
+			    console.log('获取购物车数量异常')
+			}
 		},
 		hideMobel() {
 			this.modal = false

+ 1 - 1
pages/tabBar/cart/index.vue

@@ -32,7 +32,7 @@
 			if(this.hasLogin){
 				this.$refs.cart.initData()
 			}else{
-				this.$refs.cart.initLogin()
+				this.$api.redirectTo('/pages/login/login')
 			}
 		},
 	}

+ 9 - 2
pages/tabBar/user/user.vue

@@ -19,7 +19,7 @@
 					</view>
 					<view class="header-text">
 						<view class="user-item"
-							><text class="u-none">{{ underInfo.name }}</text></view
+							><text class="user-item-none">{{ underInfo.name }}</text></view
 						>
 					</view>
 				</view>
@@ -391,7 +391,7 @@ page {
 		display: flex;
 		flex-direction: column;
 		box-sizing: border-box;
-		padding: 10rpx 0 0 20rpx;
+		padding: 10rpx 0 0 0rpx;
 		.user-item {
 			flex: 1;
 			height: 64rpx;
@@ -413,6 +413,13 @@ page {
 					background: #f85050;
 				}
 			}
+			.user-item-none{
+				font-size: $font-size-32;
+				line-height: 50rpx;
+				color: #ffffff;
+				text-align: left;
+				display: inline-block;
+			}
 			.u-none {
 				font-size: $font-size-32;
 				line-height: 120rpx;

+ 86 - 86
pages/user/order/create-order.vue

@@ -205,38 +205,35 @@ export default {
 					this.GetOrderClubProductSupporting()
 			}
 		},
-		GetProductCreateOrderInfo() {
-			// 商品立即购买确认订单数据初始化
-			this.OrderService.ProductCreateOrderInfo(this.productParam)
-				.then(response => {
-					this.setCreatDataInfo(response.data)
-				})
-				.catch(error => {
-					this.$util.msg(error.msg, 2000)
-				})
+		// 商品立即购买确认订单数据初始化
+		async GetProductCreateOrderInfo() {
+			try{
+				const res = await this.OrderService.ProductCreateOrderInfo(this.productParam)
+				this.setCreatDataInfo(res.data)
+			}catch(error){
+				console.log('商品立即购买订单初始化异常')
+			}
 		},
-		GetOrderClubProductSupporting() {
-			// 组合商品立即购买确认订单数据初始化
-			this.OrderService.OrderClubProductSupporting(this.supportParm)
-				.then(response => {
-					this.setCreatDataInfo(response.data)
-				})
-				.catch(error => {
-					this.$util.msg(error.msg, 2000)
-				})
+		// 组合商品立即购买确认订单数据初始化
+		async GetOrderClubProductSupporting() {
+			try{
+				const res = await this.OrderService.OrderClubProductSupporting(this.supportParm)
+				this.setCreatDataInfo(res.data)
+			}catch(error){
+				console.log('组合商品立即购买订单初始化异常')
+			}
 		},
-		CartCreateOrderInfo() {
-			// 购物车去结算确认订单数据初始化
-			this.OrderService.CartCreateOrderInfo(this.cartParam)
-				.then(response => {
-					this.setCreatDataInfo(response.data)
-				})
-				.catch(error => {
-					this.$util.msg(error.msg, 2000)
-				})
+		// 购物车去结算确认订单数据初始化
+		async CartCreateOrderInfo() {
+			try{
+				const res = await this.OrderService.CartCreateOrderInfo(this.cartParam)
+				this.setCreatDataInfo(res.data)
+			}catch(error){
+				console.log('购物车结算订单初始化异常')
+			}
 		},
+		// 公共初始化数据
 		setCreatDataInfo(data) {
-			// 公共初始化数据
 			this.isRequest = true
 			this.goodsData = data.list
 			this.couponList = data.couponList
@@ -258,12 +255,12 @@ export default {
 			// console.log(list);
 			return skuId.join(',')
 		},
-
-		getFreightData() {
-			// 获取邮费信息
-			this.isFreight = false
-			this.OrderService.GetOrderPostage(this.postageParam).then(response => {
-				const data = response.data
+		// 获取邮费信息
+		async getFreightData() {
+			try{
+				this.isFreight = false
+				const res = await this.OrderService.GetOrderPostage(this.postageParam)
+				const data = res.data
 				this.isFreight = true
 				this.freightData = data
 				this.hanldFreePostFlag = data.postageFlag
@@ -285,17 +282,16 @@ export default {
 					this.orderShouldPayFee = this.allPrice
 					this.attributePallPrice()
 				}
-			})
+			}catch(error){
+				console.log('获取订单运费异常')
+			}
 		},
+		//获取地址信息
 		async getAddressData() {
-			//获取地址信息
-			const userInfo = await this.$api.getStorage()
-			this.UserService.QueryAddressList({
-				pageNum: 1,
-				pageSize: 1,
-				userId: userInfo.userId
-			}).then(response => {
-				let data = response.data
+			try{
+				const userInfo = await this.$api.getStorage()
+				const res = await this.UserService.QueryAddressList({ pageNum: 1,pageSize: 1,userId: this.postageParam.userId })
+				const data = res.data
 				this.isAddress = true
 				this.addressData = {}
 				if (data.list && data.list.length > 0) {
@@ -306,18 +302,20 @@ export default {
 				} else {
 					this.addressData = this.addressData
 				}
-			})
+			}catch(error){
+				console.log('error',error)
+			}
 		},
+		//对应供应商的留言信息
 		handChangeInputGoodsList(data) {
-			//对应供应商的留言信息
 			this.goodsData = data
 		},
+		//获取发票信息
 		handleChoiceaInvoiceData(data) {
-			//获取发票信息
 			this.confirmParam.orderInvoice = data
 		},
+		//显示邮费弹窗
 		hanldFreightFn(data) {
-			//显示邮费弹窗
 			console.log('邮费信息', data)
 			switch (data.postageFlag) {
 				case 1:
@@ -336,33 +334,31 @@ export default {
 					break
 			}
 		},
+		// 计算价格
 		attributePallPrice() {
-			// 计算价格
 			if (this.hanldFreePostFlag == 1 || this.hanldFreePostFlag == '1') {
 				this.attributeHashfreight(this.freightData.postage)
 			} else {
 				this.attributeNofreight()
 			}
 		},
+		// 计算没有邮费的支付价格
 		attributeNofreight() {
-			// 计算没有邮费的支付价格
 			this.orderShouldPayFee = this.allPrice
 			console.log('最终订单支付金额', this.orderShouldPayFee)
 		},
+		// 计算需要邮费的支付价格
 		attributeHashfreight(postage) {
-			// 计算需要邮费的支付价格
 			this.orderShouldPayFee = this.allPrice + parseInt(postage) //计算不包邮的价格 总价等于商品价格+邮费
 			console.log('最终订单支付金额', this.orderShouldPayFee)
 		},
+		// 提交订单按钮点击事件
 		orderSubmitMit() {
-			// 提交订单按钮点击事件
 			this.handleClickOrderSubmitMit()
 		},
+		// 提交订单
 		handleClickOrderSubmitMit() {
-			// 提交订单
-			if (this.isSubLoading) {
-				return
-			}
+			if (this.isSubLoading) { return }
 			if (this.confirmParam.addressId == '') {
 				this.$util.msg('请先添加收货地址~', 2000)
 				return
@@ -394,35 +390,41 @@ export default {
 			this.isSubLoading = true
 			this.hanldeOrderSubmit(this.confirmParam)
 		},
-		hanldeOrderSubmit(params) {
+		async hanldeOrderSubmit(params) {
 			// 提交订单
-			this.OrderService.CreatedOrderSubmit(params)
-				.then(response => {
-					let data = response.data
-					if (data.code === 1) {
-						this.submitState = 'success'
-						setTimeout(() => {
-							this.isSubLoading = false
-						}, 2000)
-						this.$api.redirectTo(
-							`/pages/user/order/success?data=${JSON.stringify({ data: { orderId: data.orderId } })}`
-						)
-					} else {
-						this.submitState = 'confirm'
-						this.$util.msg('订单提交成功', 2000, true, 'success')
-						setTimeout(() => {
-							this.isSubLoading = false
-							if (data.onlinePayFlag === 1) {
-								this.$api.redirectTo(`/pages/user/pay/card-under?orderId=${data.orderId}`)
-							} else {
-								this.$api.redirectTo(`/pages/user/order/order-pay-list?orderId=${data.orderId}`)
-							}
-						}, 2000)
-					}
-				})
-				.catch(error => {
-					this.isSubLoading = false
-				})
+			try{
+				const res =await this.OrderService.CreatedOrderSubmit(params)
+				const data = res.data
+				if (data.code === 1) {
+					this.submitState = 'success'
+					setTimeout(() => {
+						this.isSubLoading = false
+					}, 2000)
+					this.$api.redirectTo(
+						`/pages/user/order/success?data=${JSON.stringify({ data: { orderId: data.orderId } })}`
+					)
+				} else {
+					this.submitState = 'confirm'
+					this.$util.msg('订单提交成功', 2000, true, 'success')
+					setTimeout(() => {
+						this.isSubLoading = false
+						if (data.onlinePayFlag === 1) {
+							this.$api.redirectTo(`/pages/user/pay/card-under?orderId=${data.orderId}`)
+						} else {
+							this.$api.redirectTo(`/pages/user/order/order-pay-list?orderId=${data.orderId}`)
+						}
+					}, 2000)
+				}
+			}catch(error){
+				console.log(error)
+				this.formatConfirmParam()
+				this.isSubLoading = false
+			}
+		},
+		formatConfirmParam(){// 还原提交订单参数格式
+			this.confirmParam.payInfo = JSON.parse(this.confirmParam.payInfo)
+			this.confirmParam.orderInfo = JSON.parse(this.confirmParam.orderInfo)
+			this.confirmParam.orderInvoice = JSON.parse(this.confirmParam.orderInvoice)
 		},
 		handFreightAlertShow() {
 			//显示邮费弹窗
@@ -486,8 +488,6 @@ export default {
 			this.postageParam.townId = SelectData.townId
 			this.addressData = SelectData
 			this.getFreightData()
-		} else {
-			this.getAddressData()
 		}
 	}
 }
@@ -670,7 +670,7 @@ page {
 			width: 100%;
 			height: 100%;
 			color: #ffffff;
-			background: linear-gradient(135deg, rgba(242, 143, 49, 1) 0%, rgba(225, 86, 22, 1) 100%);
+			background: $btn-confirm;
 			font-size: $font-size-26;
 			text-align: center;
 			line-height: 80rpx;

+ 1 - 1
pages/user/order/order-details.vue

@@ -141,7 +141,7 @@ export default {
 					text: '确定',
 					customStyle: {
 						color: '#fff',
-						bgColor: 'linear-gradient(90deg, #F28F31 0%, #F3B574 100%)'
+						bgColor: '#F3B574'
 					},
 					plain: false
 				}

+ 2 - 2
pages/user/order/order-list.vue

@@ -245,7 +245,7 @@ export default {
 					text: '确定',
 					customStyle: {
 						color: '#fff',
-						bgColor: 'linear-gradient(90deg, #F28F31 0%, #F3B574 100%)'
+						bgColor: '#F3B574'
 					},
 					plain: false
 				}
@@ -421,7 +421,7 @@ export default {
 		async orderPaymentValidation(){
 			//监听根据付款状态做操作
 			try{
-				const res = this.OrderService.OrderPaymentValidation({ orderId: this.handleOrderId })
+				const res = await this.OrderService.OrderPaymentValidation({ orderId: this.handleOrderId })
 				if (res.data.onlinePayFlag == 1) {// 只能线下
 					this.$api.navigateTo(`/pages/user/pay/card-under?orderId=${this.handleOrderId}`)
 				} else {

+ 7 - 28
pages/user/pay/card-under.vue

@@ -8,7 +8,6 @@
 			:loadingType="5"
 		></tui-skeleton>
 		<view class="container-cash clearfix" v-else>
-			<view class="pay-bring-title" v-if="onlinePay == 2">{{payBringTitle}}</view>
 			<view class="container-wrapper">
 				<view class="pay-content">
 					<view class="pay-p"><text>待付金额</text></view>
@@ -40,22 +39,9 @@
 			return{
 				orderId:'',
 				payableAmount:0,
-				emptyWrapperH: '',
-				bankNumber:'6230 2100 9221 2400',
 				payOrderId:'',
 				isIphoneX:this.$store.state.isIphoneX,
 				CustomBar:this.CustomBar,// 顶部导航栏高度
-				tabCurrentIndex:0,
-				isReceiptStatus:false,
-				buttonText:'使用微信支付',
-				btnColor:'#09BB07',
-				receiptStatus:'',
-				onlinePay:1,
-				optionType:'',
-				onlinePayFlag:'',
-				payBringTitle:'本次交易暂不支持线上支付,请使用线下转账方式付款',
-				payStatusText:'使用任何一种线上支付方式支付全部金额后,供应商会在24小时后发货(周末、节假日顺延)。',
-				pageType:'',
 				skeletonShow:true,
 				productImage:['https://static.caimei365.com/app/img/icon/icon-vxkecode.png'],
 			}
@@ -94,24 +80,17 @@
 				this.cmGetBankTypeLists()	
 				this.PayOrderCheckoutCounter(this.orderId)
 			},
-			PayOrderCheckoutCounter(orderId){
-				this.PayService.PayOrderCheckoutCounter({orderId:orderId}).then(response =>{
-					let data = response.data.order
+			async PayOrderCheckoutCounter(orderId){
+				try{
+					const res = await this.PayService.PayOrderCheckoutCounter({orderId:orderId})
+					const data = res.data.order
 					this.payableAmount = data.payableAmount - data.receiptAmount  //待付金额
-					this.receiptStatus =  data.receiptStatus
-					this.onlinePayFlag = data.onlinePayFlag			
-					//判断线上线下显示
-					if(this.optionType == 'onlinePay'){
-						this.onlinePay = 2
-					}else{
-						this.onlinePay = response.data.onlinePay
-					}
 					setTimeout(()=>{
 						this.skeletonShow = false
 					},500)
-				}).catch(error =>{
-					this.$util.msg(error.msg,2000)
-				})
+				}catch(error){
+					console.log('error',error)
+				}
 			},
 			clipboard(data) {
 				thorui.getClipboardData(data, (res) => {

+ 1 - 1
services/order.service.js

@@ -166,7 +166,7 @@ export default class OrderService {
      */
     ShoppingCartCount (data = {}) {
         return this.AjaxService.get({ 
-            url:'/order/club/cart/count', 
+            url:'/order/club/cart/organizeCount', 
             data, 
             isLoading: false ,