py 2 лет назад
Родитель
Сommit
a5af4f3c31
3 измененных файлов с 304 добавлено и 91 удалено
  1. 3 1
      api/common.js
  2. 41 2
      pages-takeout/shop-mod/menu.vue
  3. 260 88
      pages/order/index.vue

+ 3 - 1
api/common.js

@@ -32,4 +32,6 @@ export const getDeliveryMoney = (data) => request(commonUrl + 'delivery_money',
 // 是否是小程序上架审核
 export const commonApplet = (data) => request(commonUrl + 'applet', 'post', { ...data })
 // 获取弹窗通知公告
-export const commonPopNotice = (data) => request(commonUrl + 'pop_notice', 'post', { ...data })
+export const commonPopNotice = (data) => request(commonUrl + 'pop_notice', 'post', { ...data })
+// 获取退款原因
+export const commonRefundReason = (data) => request(commonUrl + 'refund_reason', 'post', { ...data })

+ 41 - 2
pages-takeout/shop-mod/menu.vue

@@ -189,7 +189,8 @@
 					spec_list: [],
 					spec_attr: [],
 				},
-				selectedNum: 1
+				selectedNum: 1,
+				selectedSpecification: []
 			}
 		},
 		watch: {
@@ -205,24 +206,32 @@
 		methods: {
 			setSpecNum(type) {
 				if (!this.popData.goods_spec_id) {
+					console.log('被阻挡');
 					tools.error('请选择规格')
 					return;
 				}
 				if (type === 1) {
 					// 减
+					console.log('减');
 					if (this.popData.num > 0) {
 						--this.popData.num;
+						this.$forceUpdate()
 					} else {
 						this.isAjax = false
 					}
 				} else {
+					console.log('加');
 					if (this.popData.is_infinite === 0 && this.popData.payNum > this.popData.stock) {
+						console.log('加1');
 						tools.error('商品库存' + this.popData.stock + '件')
 					} else if (this.popData.is_quota > 0 && this.popData.payNum > this.popData.quota_num) {
+						console.log('加2');
 						tools.error('限购' + this.popData.quota_num + '件')
 					} else {
 						// 加
+						console.log('加3');
 						++this.popData.num;
+						this.$forceUpdate()
 					}
 				}
 
@@ -252,6 +261,17 @@
 					}
 					this.popData.spec_list = res.data.spec_list
 					this.popData.spec_attr = res.data.spec_attr
+					console.log(this.selectedSpecification,'+++++++++++++++++');
+					this.selectedSpecification.forEach((v, k) => {
+						if (v.goods_id === item.goods_id) {
+							v.goodsItem = item
+							v.spec_list = res.data.spec_list
+							v.spec_attr = res.data.spec_attr
+							let data = JSON.parse(JSON.stringify(v))
+							this.popData = data
+						}
+					})
+					console.log(this.popData, '********************');
 					this.$refs.popupGG.open();
 					this.setGoodsSpecPrice()
 					this.isAjax = false
@@ -296,6 +316,7 @@
 			},
 			setShopIngList(cartData) {
 				this.cartData = cartData
+				this.selectedSpecification = []
 				this.setGoodsNum()
 			},
 			getShopIngList(isStart) {
@@ -304,6 +325,14 @@
 				}).then(res => {
 					if (res.code === 1) {
 						this.cartData = res.data
+						let data = res.data
+						data.goods_list.forEach((v,k) => {
+							let ge = JSON.parse(JSON.stringify(v))
+							ge.spec_ids = ge.spec_sku_id.split('_').map(item => Number(item.trim()))
+							ge.spec_name = ge.goods_attr.split(',').map(item => item.trim())
+							this.selectedSpecification.push(ge)
+						})
+						console.log(this.selectedSpecification, '初始回显已选数据');
 						this.$emit('setCartData', this.cartData)
 						this.setGoodsNum()
 					}
@@ -450,6 +479,13 @@
 				} else if (type === 3) {
 					// 选规格
 					console.log(item)
+					this.selectedSpecification.forEach((v,k) => {
+						if(v.goods_id === item.goods_id ) {
+							v.quota_num = item.quota_num
+							v.payNum = item.num
+							v.stock = item.stock
+						}
+					})
 					this.popData.is_quota = item.is_quota
 					this.popData.quota_num = item.quota_num
 					this.popData.is_infinite = item.is_infinite
@@ -457,9 +493,12 @@
 					this.popData.stock = item.stock
 					this.getShopGoodsSpec(item)
 				} else {
+					let data = JSON.parse(JSON.stringify(this.popData))
+					this.selectedSpecification.push(data)
 					this.$refs.popupGG.close();
 					console.log('this.popData.goods_spec_id')
-					console.log(this.popData.goods_spec_id)
+					console.log(this.popData)
+					console.log(this.selectedSpecification, 'this.___________________________');
 					if (this.popData.goods_spec_id) {
 						if (this.popData.is_infinite === 0 && this.popData.payNum > this.popData.stock) {
 							tools.error('商品库存' + this.popData.stock + '件')

+ 260 - 88
pages/order/index.vue

@@ -167,6 +167,27 @@
 				</view>
 			</view>
 		</uni-popup>
+		<uni-popup ref="popupReason" type="bottom" background-color="#fff" border-radius="10px 10px 0 0">
+			<view class="popup-reason-box flex-direction">
+				<view class="text-align-center fs-38 fw-600 fc-3 mb-18">
+					选择取消原因
+				</view>
+				<picker-view @change="bindChange" class="picker-view flex-1" :immediate-change='true'>
+					<picker-view-column>
+						<view class="picker-view-item" v-for="(item,index) in refundReason" :key="index">
+							{{item.refund_msg}}</view>
+					</picker-view-column>
+				</picker-view>
+				<view class="align-items-center flex-justify-space">
+					<view class="flex-1 mr-20 pop-b text-align-center fs-36 b-r-ccc" @click="popCancel">
+						取消
+					</view>
+					<view class="flex-1 pop-b text-align-center bgc-41ABF5 fc-f fs-36" @click="popSure">
+						确定
+					</view>
+				</view>
+			</view>
+		</uni-popup>
 	</view>
 </template>
 
@@ -174,6 +195,9 @@
 	// import UniQrcode from 'uniapp-qrcode'
 	import tools from '@/service/tools';
 	import EnBlank from "@/components/en-utils/en-blank/en-blank";
+	import {
+		commonRefundReason
+	} from "@/api/common.js"
 	import {
 		orderStatus,
 		orderList,
@@ -244,7 +268,11 @@
 				isAjax: false,
 				qrcodeData: '',
 				options2: {},
-				onlyCode: ''
+				onlyCode: '',
+				refundReason: [],
+				order_id: 0,
+				refund_msg: '', // 退款理由
+				sureType: 0
 			};
 		},
 		onShow() {
@@ -412,104 +440,219 @@
 						item.shop_logo
 				})
 			},
+			popCancel() {
+				// 退款取消
+				this.$refs.popupReason.close()
+				uni.showTabBar()
+			},
+			popSure() {
+				// 退款确认
+				if (this.sureType === 1) {
+					// 外卖退款
+					if (this.isAJAX) {
+						return
+					}
+					this.isAJAX = true;
+					orderCancel({
+						order_id: this.order_id,
+						refund_msg: this.refund_msg
+					}).then((res) => {
+						if (res.code == 1) {
+							tools.success(res.msg)
+							this.$refs.popupReason.close()
+							uni.showTabBar()
+							setTimeout(() => {
+								this.page = 1;
+								this.list = [];
+								this.orderList()
+							}, 1500)
+							this.isAJAX = false;
+						} else {
+							tools.error(res.msg)
+							this.isAJAX = false;
+						}
+					})
+				} else if (this.sureType === 2) {
+					// 代取退款
+					if (this.isAJAX) {
+						return
+					}
+					this.isAJAX = true;
+					expressOrderCancel({
+						order_id: this.order_id,
+						refund_msg: this.refund_msg
+					}).then((res) => {
+						if (res.code == 1) {
+							tools.success(res.msg)
+							this.$refs.popupReason.close()
+							uni.showTabBar()
+							setTimeout(() => {
+								this.page = 1;
+								this.list = [];
+								this.expressOrderList()
+							}, 1500)
+							this.isAJAX = false;
+						} else {
+							tools.error(res.msg)
+							this.isAJAX = false;
+						}
+					})
+				} else if(this.sureType === 3) {
+					//干洗退款
+					if (this.isAJAX) {
+						return
+					}
+					this.isAJAX = true;
+					laundryOrderCancel({
+						order_id: this.order_id,
+						refund_msg: this.refund_msg
+					}).then((res) => {
+						if (res.code == 1) {
+							tools.success(res.msg)
+							this.$refs.popupReason.close()
+							uni.showTabBar()
+							setTimeout(() => {
+								this.page = 1;
+								this.list = [];
+								this.laundryOrderList()
+							}, 1500)
+							this.isAJAX = false;
+						} else {
+							tools.error(res.msg)
+							this.isAJAX = false;
+						}
+					})
+				}
+			},
+			bindChange(e) {
+				let num = e.detail.value[0]
+				this.refund_msg = this.refundReason[num].refund_msg
+			},
 			tackOut(item) {
 				// 外卖取消订单
-				uni.showModal({
-					title: '提示',
-					content: '是否取消订单?',
-					confirmText: '确定',
-					confirmColor: '#FB3D03',
-					success: (res) => {
-						if (res.confirm === true) {
-							if (this.isAJAX) {
-								return
-							}
-							this.isAJAX = true;
-							orderCancel({
-								order_id: item.id
-							}).then((res) => {
-								if (res.code == 1) {
-									tools.success(res.msg)
-									setTimeout(() => {
-										this.page = 1;
-										this.list = [];
-										this.orderList()
-									}, 1500)
-									this.isAJAX = false;
-								} else {
-									tools.error(res.msg)
-									this.isAJAX = false;
-								}
-							})
-						}
+				uni.hideTabBar()
+				this.sureType = 1
+				this.order_id = item.id
+				commonRefundReason().then((res) => {
+					if (res.code === 1) {
+						this.refundReason = res.data
 					}
-				});
+				})
+				this.$refs.popupReason.open()
+				// uni.showModal({
+				// 	title: '提示',
+				// 	content: '是否取消订单?',
+				// 	confirmText: '确定',
+				// 	confirmColor: '#FB3D03',
+				// 	success: (res) => {
+				// 		if (res.confirm === true) {
+				// 			if (this.isAJAX) {
+				// 				return
+				// 			}
+				// 			this.isAJAX = true;
+				// 			orderCancel({
+				// 				order_id: item.id
+				// 			}).then((res) => {
+				// 				if (res.code == 1) {
+				// 					tools.success(res.msg)
+				// 					setTimeout(() => {
+				// 						this.page = 1;
+				// 						this.list = [];
+				// 						this.orderList()
+				// 					}, 1500)
+				// 					this.isAJAX = false;
+				// 				} else {
+				// 					tools.error(res.msg)
+				// 					this.isAJAX = false;
+				// 				}
+				// 			})
+				// 		}
+				// 	}
+				// });
 			},
 			expressCancel(item) {
 				// 代取取消订单
-				uni.showModal({
-					title: '提示',
-					content: '是否取消订单?',
-					confirmText: '确定',
-					confirmColor: '#FB3D03',
-					success: (res) => {
-						if (res.confirm === true) {
-							if (this.isAJAX) {
-								return
-							}
-							this.isAJAX = true;
-							expressOrderCancel({
-								order_id: item.id
-							}).then((res) => {
-								if (res.code == 1) {
-									tools.success(res.msg)
-									setTimeout(() => {
-										this.page = 1;
-										this.list = [];
-										this.expressOrderList()
-									}, 1500)
-									this.isAJAX = false;
-								} else {
-									tools.error(res.msg)
-									this.isAJAX = false;
-								}
-							})
-						}
+				uni.hideTabBar()
+				this.sureType = 2
+				this.order_id = item.id
+				commonRefundReason().then((res) => {
+					if (res.code === 1) {
+						this.refundReason = res.data
 					}
-				});
+				})
+				this.$refs.popupReason.open()
+				// uni.showModal({
+				// 	title: '提示',
+				// 	content: '是否取消订单?',
+				// 	confirmText: '确定',
+				// 	confirmColor: '#FB3D03',
+				// 	success: (res) => {
+				// 		if (res.confirm === true) {
+				// 			if (this.isAJAX) {
+				// 				return
+				// 			}
+				// 			this.isAJAX = true;
+				// 			expressOrderCancel({
+				// 				order_id: item.id
+				// 			}).then((res) => {
+				// 				if (res.code == 1) {
+				// 					tools.success(res.msg)
+				// 					setTimeout(() => {
+				// 						this.page = 1;
+				// 						this.list = [];
+				// 						this.expressOrderList()
+				// 					}, 1500)
+				// 					this.isAJAX = false;
+				// 				} else {
+				// 					tools.error(res.msg)
+				// 					this.isAJAX = false;
+				// 				}
+				// 			})
+				// 		}
+				// 	}
+				// });
 			},
 			cancel(item) {
 				// 干洗取消订单
-				uni.showModal({
-					title: '提示',
-					content: '是否取消订单?',
-					confirmText: '确定',
-					confirmColor: '#FB3D03',
-					success: (res) => {
-						if (res.confirm === true) {
-							if (this.isAJAX) {
-								return
-							}
-							this.isAJAX = true;
-							laundryOrderCancel({
-								order_id: item.id
-							}).then((res) => {
-								if (res.code == 1) {
-									tools.success(res.msg)
-									setTimeout(() => {
-										this.page = 1;
-										this.list = [];
-										this.laundryOrderList()
-									}, 1500)
-									this.isAJAX = false;
-								} else {
-									tools.error(res.msg)
-									this.isAJAX = false;
-								}
-							})
-						}
+				uni.hideTabBar()
+				this.sureType = 3
+				this.order_id = item.id
+				commonRefundReason().then((res) => {
+					if (res.code === 1) {
+						this.refundReason = res.data
 					}
-				});
+				})
+				this.$refs.popupReason.open()
+				// uni.showModal({
+				// 	title: '提示',
+				// 	content: '是否取消订单?',
+				// 	confirmText: '确定',
+				// 	confirmColor: '#FB3D03',
+				// 	success: (res) => {
+				// 		if (res.confirm === true) {
+				// 			if (this.isAJAX) {
+				// 				return
+				// 			}
+				// 			this.isAJAX = true;
+				// 			laundryOrderCancel({
+				// 				order_id: item.id
+				// 			}).then((res) => {
+				// 				if (res.code == 1) {
+				// 					tools.success(res.msg)
+				// 					setTimeout(() => {
+				// 						this.page = 1;
+				// 						this.list = [];
+				// 						this.laundryOrderList()
+				// 					}, 1500)
+				// 					this.isAJAX = false;
+				// 				} else {
+				// 					tools.error(res.msg)
+				// 					this.isAJAX = false;
+				// 				}
+				// 			})
+				// 		}
+				// 	}
+				// });
 			},
 			scrolltolower() {
 				++this.page
@@ -829,6 +972,35 @@
 </script>
 
 <style lang="scss" scoped>
+	.pop-b {
+		height: 80rpx;
+		line-height: 80rpx;
+		border-radius: 20rpx;
+		// border: 1rpx solid #F9F9F9;
+	}
+
+	.popup-reason-box {
+		width: 100%;
+		height: 45vh;
+		overflow: auto;
+		border-radius: 20rpx 20rpx 0 0;
+		background: #fff;
+		padding: 24rpx 0 0;
+		box-sizing: border-box;
+	}
+
+	.picker-view {
+		width: 100%;
+		// height: 70%;
+	}
+
+	.picker-view-item {
+		// height: 90rpx;
+		line-height: 68rpx;
+		text-align: center;
+		background: #F5F5F5;
+	}
+
 	.nav-b {
 		position: relative;
 		z-index: -1 !important;