浏览代码

Merge branch 'lyy' of ymy/bc_wx_applet into master

lyy 1 年之前
父节点
当前提交
1c7ffd2abb

+ 1 - 13
components/cartPopup.vue

@@ -57,7 +57,6 @@
 					storeId: e.id
 				}
 				const res = await this.$request('get', `/front/shoppingCart/list`, params)
-				console.log('res.data', res.data)
 				if (res) {
 					this.carList = res.data
 				}
@@ -86,13 +85,11 @@
 				if (this.carList.length > 0) {
 					this.allSelected = this.carList.every(car => car.selected)
 				}
-				console.log('this.carList2222222222222222222', this.carList)
 			},
 			close() {
 				this.show = false;
 			},
 			changeValue(value, v) {
-				console.log('更新后的数量=======:', value, '索引=========:', v)
 				const e = uni.getStorageSync('carl')
 				const userId = uni.getStorageSync('appUserId')
 				const params = {
@@ -104,7 +101,6 @@
 					quantity: value.value,
 					extendProps: userId
 				}
-				console.log('params', params)
 				this.$request('put', `/front/shoppingCart`, params, true)
 
 			},
@@ -116,14 +112,12 @@
 				this.$emit('selected-changed', this.carList)
 				this.totalList = this.carList
 				this.totalPrice()
-				console.log('this.carList111111111111111', this.carList)
 			},
 			clearCart() {
 				const ids = this.carList.map(car => car.id);
-				console.log('ids', ids)
 				this.$request('delete', `/front/shoppingCart/${ids}`).then(response => {
 					// 请求成功
-					if (response.code = 200) {
+					if (response.code == 200) {
 						// 弹出消息
 						uni.showToast({
 							title: '已清空',
@@ -140,7 +134,6 @@
 				})
 			},
 			radioChange(e) {
-				console.log(e)
 				e.selected = !e.selected
 				// 检查是否所有车都被选中了
 				this.allSelected = this.carList.every(car => car.selected)
@@ -149,9 +142,6 @@
 				this.$emit('selected-changed', this.localList);
 				this.totalList = this.localList
 				this.totalPrice()
-				console.log('this.totalList', this.totalList);
-				// 打印结果
-				console.log('this.allSelected', this.allSelected);
 			},
 			//计算selected为true的
 			totalPrice() {
@@ -175,8 +165,6 @@
 
 				// 将总价格转换回浮点数(以元为单位)
 				this.total = (total / 100).toFixed(2);
-
-				console.log('total', this.total);
 			},
 		}
 	}

+ 8 - 6
components/send-type/send-type.vue

@@ -2,7 +2,7 @@
 	<view class="send-type padding-lr-sm dflex-b">
 		<view class="send-label">配送方式</view>
 		<view class="send-radio">
-			<uni-data-checkbox v-model="value" :localdata="list" @change="radioGroupChange" selectedColor="#F54319"></uni-data-checkbox>
+			<uni-data-checkbox v-model="value" :localdata="list" @change="radioChange" selectedColor="#F54319"></uni-data-checkbox>
 		</view>
 	</view>
 </template>
@@ -12,22 +12,24 @@
 		name:"send-type",
 		data() {
 			return {
-				value:null,
+				value:1,
 				list:[
 					{
 						text:"自提",
 						value:1
 					},
-					{
-						text:"配送",
-						value:2
-					}
+					// {
+					// 	text:"配送",
+					// 	value:2,
+					//  disable:true
+					// }
 				]
 			};
 		},
 		methods:{
 			radioChange(v){
 				this.$emit("sendTypeChange", v)
+				
 			}
 		}
 	}

+ 53 - 37
components/specPopup.vue

@@ -49,6 +49,7 @@
 				speL: [],
 				intSkuId: [], // 选择唯一的id
 				caMsg: [], // 根据id查出来的数据
+				isSelected: false,
 			}
 		},
 		methods: {
@@ -101,17 +102,18 @@
 					// 如果没有选中的规格项,返回空字符串
 					this.intSkuId = '';
 				}
-				console.log('speL', this.speL)
+				// console.log('speL', this.speL)
 				// 确定每一个都有选择后发起请求
-				const isSelected = this.specs.every(spec => spec.values.some(value => value.selected))
-				if (isSelected) {
+				this.isSelected = this.specs.every(spec => spec.values.some(value => value.selected))
+				// console.log('isSelected', this.isSelected)
+				if (this.isSelected) {
 					// 如果所有规格都至少有一个选项被选中
 					const res = await this.$request('get', `/item/sku/${this.intSkuId}`)
 					this.caMsg = res.data
 					// 返回选中规格项的label值
-					console.log('intSkuId', this.intSkuId)
-					console.log('items', items)
-					console.log('所有规格都已选择')
+					//console.log('intSkuId', this.intSkuId)
+					//console.log('items', items)
+					//console.log('所有规格都已选择')
 					const itemDetal = {
 						id: this.intSkuId,
 						item: Array.from(items).join(','),
@@ -122,7 +124,7 @@
 			},
 			async open() {
 				this.$refs.popup.open('bottom')
-				console.log("this.cardMsg")
+				// console.log("this.cardMsg")
 				const spuId = this.cardMsg.spuId
 				const res = await this.$request('get', `/item/sku/queryPropMapping?spuId=${spuId}`)
 				this.specs = res.data.filter(item => item.values && item.values.length > 0);
@@ -137,37 +139,51 @@
 				})
 			},
 			toShop() {
-				const e = uni.getStorageSync('carl')
-				const userId = uni.getStorageSync('appUserId')
-				const count = this.vModelValue
-				const params = {
-					storeId: e.id,
-					storeName: e.name,
-					skuId: this.caMsg.skuId,
-					basePrice: this.caMsg.retailPrice,
-					price: this.caMsg.retailPrice,
-					quantity: count,
-					extendProps: userId
-				}
-				console.log('params', params)
-				this.$request('post', `/front/shoppingCart`, params, true).then(response => {
-					// 请求成功
-					if (response.code = 200) {
-						// 弹出消息
-						uni.showToast({
-							title: '加入购物车成功',
-							icon: 'success',
-							duration: 2000
-						})
-						this.$emit('addShop');
+				if (this.isSelected == false) {
+					uni.showToast({
+						title: '还有规格未选择',
+						icon: 'error',
+						duration: 1000
+					});
+				} else {
+					const e = uni.getStorageSync('carl')
+					const userId = uni.getStorageSync('appUserId')
+					const count = this.vModelValue
+					const params = {
+						storeId: e.id,
+						storeName: e.name,
+						skuId: this.caMsg.skuId,
+						basePrice: this.caMsg.retailPrice,
+						price: this.caMsg.retailPrice,
+						quantity: count,
+						extendProps: userId
 					}
-				}).catch(error => {
-					// 请求失败
-					console.error('请求失败:', error);
-				})
-				// this.$emit('update-shopmsg', this.shopMsg);
-				// 关闭弹出层
-				this.$refs.popup.close()
+					// console.log('params', params)
+					this.$request('post', `/front/shoppingCart`, params, true).then(response => {
+						// 请求成功
+						if (response.code == 200) {
+							// 弹出消息
+							uni.showToast({
+								title: '加入购物车成功',
+								icon: 'success',
+								duration: 2000
+							})
+							this.$emit('addShop');
+						} else if (response.code == 500) {
+							uni.showToast({
+								title: response.msg,
+								icon: 'error',
+								duration: 2000
+							});
+						}
+					}).catch(error => {
+						// 请求失败
+						console.error('请求失败:', error);
+					})
+					// this.$emit('update-shopmsg', this.shopMsg);
+					// 关闭弹出层
+					this.$refs.popup.close()
+				}
 			},
 			toBuy() {
 				uni.navigateTo({

+ 14 - 11
main.js

@@ -66,12 +66,10 @@ Vue.prototype.$request = function(method, url, data, isJSON, hideLoading, showEr
 				'Content-Type': isJSON ? 'application/json' : 'application/x-www-form-urlencoded',
 				'Authorization': 'Bearer ' + token,
 				'clientId': 'e5cd7e4891bf95d1d19206ce24a7b32e',
-				//"isEncrypt": false,
 				// 'tenantId': Vue.prototype.tenantId 或者 'tenantId': `${tenantId}`
 				// application/x-www-form-urlencoded application/json
 			},
 			success: (res) => {
-				console.log('resres', res)
 				uni.hideLoading();
 				if (res.statusCode === 200) {
 					resolve(res.data);
@@ -79,18 +77,23 @@ Vue.prototype.$request = function(method, url, data, isJSON, hideLoading, showEr
 					if (showErrMsg) {
 						resolve({
 							result: false,
-							msg: res.data.msg
+							msg: res.data.data.msg
 						})
 					} else {
 						resolve(false);
-						if (this.$refs && this.$refs.uNotify) {
-							this.$refs.uNotify.show({
-								type: 'error',
-								top: 0,
-								message: res.data.msg,
-								icon: 'error-circle'
-							})
-						}
+						uni.showToast({
+							title: res.data.data.msg,
+							icon: 'error',
+							duration: 2000
+						});
+						// if (this.$refs && this.$refs.uNotify) {
+						// 	this.$refs.uNotify.show({
+						// 		type: 'error',
+						// 		top: 0,
+						// 		message: res.data.msg,
+						// 		icon: 'error-circle'
+						// 	})
+						// }
 					}
 				}
 			},

+ 8 - 8
pages.json

@@ -1,5 +1,13 @@
 {
 	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
+		{
+			"path" : "pages/classify/classify",
+			"style" : 
+			{
+				"navigationBarTitleText" : "首页",
+				"enablePullDownRefresh" : false
+			}
+		},
 		{
 			"path" : "pages/login/login",
 			"style" : 
@@ -14,14 +22,6 @@
 				"navigationBarTitleText": "首页"
 			}
 		},
-		{
-			"path" : "pages/classify/classify",
-			"style" : 
-			{
-				"navigationBarTitleText" : "首页",
-				"enablePullDownRefresh" : false
-			}
-		},
 		{
 			"path" : "pages/user/user",
 			"style" : 

+ 31 - 15
pages/classify/classify.vue

@@ -81,7 +81,7 @@
 				shoppingCart: shoppingCart,
 				tags: 1,
 				txts: 1,
-				carList: {},
+				carList: [],
 				goods: [],
 				total: 0,
 				cList: {},
@@ -95,18 +95,23 @@
 			this.cList = e
 			this.fatchDate()
 			this.carListMeg()
+			uni.$on('register_refresh', () => {
+				this.fatchDate()
+				this.carListMeg()
+				this.total = 0
+			})
 		},
 		methods: {
 			// 加购
 			goCart(e) {
-				console.log('================', e)
+				// console.log('================', e)
 				this.cardMsg = e
 				this.$nextTick(() => {
 					this.$refs.specPopup.open();
 				});
 			},
 			handleSelectedChanged(selectedItems) {
-				console.log('选中的数据:', selectedItems)
+				//console.log('选中的数据:', selectedItems)
 				this.carList = selectedItems
 				this.carListMeg()
 				this.totalPrice()
@@ -134,8 +139,6 @@
 
 				// 将总价格转换回浮点数(以元为单位)
 				this.total = (total / 100).toFixed(2);
-
-				console.log('total', this.total);
 			},
 			showCart() {
 				this.$nextTick(() => {
@@ -148,20 +151,36 @@
 				})
 			},
 			toDetial(e) {
-				console.log('eeeeee====================', e)
+				// console.log('eeeeee====================', e)
 				const data = {
 					spuId: e.spuId,
 					tobyC: this.buyCount
 				}
 				uni.navigateTo({
-				  url: `/pages/goodDetail/goodDetail?data=${encodeURIComponent(JSON.stringify(data))}`
+					url: `/pages/goodDetail/goodDetail?data=${encodeURIComponent(JSON.stringify(data))}`
 				})
 			},
 			toBuy() {
-				console.log('e========carList', this.carList)
-				// uni.navigateTo({
-				// 	url: `/pages/order/submitOrder/submitOrder`
-				// })
+				// console.log('e========carList', this.carList)
+				const carlist = {
+					carlist: this.carList,
+					total: this.total
+				}
+				if (carlist.carlist.length <= 0) {
+					// this.$refs.uNotify.show({'请选择'})
+					uni.showToast({
+						title: '请选择',
+						icon: 'error',
+						duration: 2000
+					});
+				} else {
+					uni.navigateTo({
+						url: `/pages/order/submitOrder/submitOrder?data=${encodeURIComponent(JSON.stringify(carlist))}`
+					})
+					this.$nextTick(() => {
+						this.$refs.cartPopup.setShow(false)
+					})
+				}
 			},
 			onOrder() {
 				uni.navigateTo({
@@ -172,7 +191,6 @@
 				const info = {
 					customerPhone: this.cList.customerPhone
 				}
-				console.log('======================', info)
 				uni.setStorageSync("info", info)
 				uni.navigateTo({
 					url: `/pages/user/user`
@@ -183,7 +201,7 @@
 				var queryParmas = {
 					id: this.cList.id
 				}
-				console.log('idididididid', queryParmas)
+				// console.log('idididididid', queryParmas)
 				const result = await this.$request('post', '/sale/diningCarProduct/queryDiningCarProduct', queryParmas,
 					true)
 				if (result) {
@@ -192,14 +210,12 @@
 					const res = await this.$request('get', `/item/spu/queryByIds?spuIds=${spuIds}`)
 					const data = res.data
 					this.goods = data.filter(item => item.status !== 1)
-					console.log('res', res.data)
 				}
 			},
 			async carListMeg() {
 				const res = await this.$request('get', `/front/shoppingCart/list`, {
 					storeId: this.cList.id
 				})
-				console.log('res.data==============', res.data)
 				if (res) {
 					const carList = res.data
 					this.buyCount = carList.length

+ 1 - 1
pages/login/login.vue

@@ -182,7 +182,7 @@
 								// 更新用户信息
 								const id = uni.getStorageSync('appUserId');
 								console.log('id', id)
-
+								uni.setStorageSync("userName", res.userInfo.nickName);
 								const userInfo = {
 									"userId": id,
 									"nickName": res.userInfo.nickName,

+ 57 - 17
pages/order/orderPaid/orderPaid.vue

@@ -15,7 +15,7 @@
 					取餐时间
 				</view>
 			</view>
-			<u-icon slot="icon" size="20" name="arrow-right" label="04:00" labelPos="left"></u-icon>
+			<u-icon slot="icon" size="20" name="arrow-right" :label="goods.arriveCutTime" labelPos="left"></u-icon>
 		</view>
 		<view class="gap"></view>
 		<view class="padding-sm dflex-b bg-main">
@@ -25,7 +25,8 @@
 				</view>
 			</view>
 			<view>
-				<radio style="transform: scale(0.85)" value="r1" :checked="true" color="#ff0000" class="radio">店内用餐
+				<radio style="transform: scale(0.85)" value="r1" :checked="true" color="#ff0000" class="radio">
+					{{goods.pickupType.pickupType ? '店内用餐' : '打包带走'}}
 				</radio>
 			</view>
 		</view>
@@ -34,29 +35,39 @@
 		<view class="goods-order-list padding-lr-sm">
 			<view class="shop dflex-b ">
 				<view class="shop-check">
-					<text class="send-label">店铺名称</text>
+					<text class="send-label">{{goods.storeName}}</text>
 				</view>
-				<view class="total-goods">共计2件商品</view>
+				<view class="total-goods">共计{{goods.itemList.length}}件商品</view>
 			</view>
-			<view class="goods-cart">
+			<view class="goods-cart w-full">
+				<view class="goods-cont padding-tb" v-for="(item, index) in goods.itemList" :key="index">
+					<my-goods :item="item">
+						<view class="good-num">×{{item.quantity}}</view>
+					</my-goods>
+				</view>
+			</view>
+			<!-- <view class="goods-cart" v-for="(item, index)  in goods.itemList" :key="index">
 				<view class="goods-cont dflex-b padding-tb-16">
 					<view class="goods-cart-info dflex-b">
-						<view class="pic"></view>
-						<view class="goods-cart-right">
-							<view class="cart-title">商品名称商品名称</view>
+						 <view class="pic"></view>
+						<my-goods :item="item">
+							<view class="good-num">×{{item.quantity}}</view>
+						</my-goods>
+						 <view class="goods-cart-right">
+							<view class="cart-title">{{item.skuName}}</view>
 							<view class="order-spec">
 								<text>500g</text>
 							</view>
 							<view class="cart-row-info dflex-s">
 								<view class="cart-price">
-									¥<text>12.30</text>
+									¥<text>{{item.price}}</text>
 								</view>
-								<view class="goods-num">×1</view>
+								<view class="goods-num">×{{item.quantity}}</view>
 							</view>
-						</view>
+						</view> 
 					</view>
 				</view>
-				<view class="goods-cont dflex-b padding-tb-16">
+				 <view class="goods-cont dflex-b padding-tb-16">
 					<view class="goods-cart-info dflex-b">
 						<view class="pic"></view>
 						<view class="goods-cart-right">
@@ -72,15 +83,15 @@
 							</view>
 						</view>
 					</view>
-				</view>
-			</view>
+				</view> 
+			</view> -->
 		</view>
 		<view class="gap"></view>
 		<!-- 金额明细 -->
 		<view class="bg-main">
 			<view class="dflex-b padding-lr padding-tb-sm">
 				<view class="flex1 send-label">总金额</view>
-				<view class=""><text style="font-size: 24rpx;">¥</text>46.32</view>
+				<view class=""><text style="font-size: 24rpx;">¥</text>{{goods.payment}}</view>
 			</view>
 		</view>
 		<view class="gap"></view>
@@ -96,11 +107,30 @@
 	export default {
 		data() {
 			return {
-
+				goods: {}
 			}
 		},
+		onLoad(e) {
+			this.fatchDate(e)
+		},
+		onUnload() {
+			uni.navigateBack({
+				delta: 3, //返回上5层
+				success: () => {
+					uni.$emit('register_refresh') // 直接调用上个页面的刷新方法
+				}
+			})
+		},
 		methods: {
-
+			async fatchDate(e) {
+				console.log('e', e)
+				const result = await this.$request('get', `/order/retailOrder/${e.id}`,
+					true)
+				if (result) {
+					console.log('result', result.data)
+					this.goods = result.data
+				}
+			}
 		}
 	}
 </script>
@@ -269,4 +299,14 @@
 			font-size: 14px;
 		}
 	}
+
+	.good-num {
+		font-size: 12px;
+		padding-top: 65rpx;
+	}
+
+	.goods-cont {
+		width: 100%;
+		box-sizing: border-box;
+	}
 </style>

+ 110 - 20
pages/order/submitOrder/submitOrder.vue

@@ -30,10 +30,12 @@
 				</view>
 			</view>
 			<view>
-				<radio style="margin: 0 10px; transform: scale(0.85)" value="r1" :checked="true" color="#ff0000" class="radio">店内用餐
+				<uni-data-checkbox v-model="val" :localdata="list" @change="radioChange"
+					selectedColor="#F54319"></uni-data-checkbox>
+				<!-- <radio style="margin: 0 10px; transform: scale(0.85)" value="r1" :checked="typePicking" color="#ff0000" class="radio">店内用餐
 				</radio >
-				<radio style="transform: scale(0.85)" value="r1" :checked="true" color="#ff0000" class="radio">打包带走
-				</radio>
+				<radio style="transform: scale(0.85)" value="r1" :checked="typePickings" color="#ff0000" class="radio">打包带走
+				</radio> -->
 			</view>
 			<!-- <view class="iconfont iconjiantou-01 fs-sm"></view> -->
 		</view>
@@ -41,23 +43,24 @@
 		<view class="goods-order-list w-full padding-lr-sm">
 			<view class="shop dflex-b ">
 				<view class="shop-check">
-					<text class="shop-name">xxx学校xx年级xx班级</text>
+					<text class="shop-name">{{cList.name}}</text>
 				</view>
 			</view>
 			<view class="goods-cart w-full">
-				<view class="goods-cont padding-tb" v-for="index in 1" :key="index">
-					<my-goods :data="data">
-						<view class="good-num">×1</view>
+				<view class="goods-cont padding-tb" v-for="(item, index) in data.carlist" :key="index">
+					<my-goods :item="item">
+						<view class="good-num">×{{item.quantity}}</view>
 					</my-goods>
 				</view>
 
 			</view>
 		</view>
 		<!-- 金额明细 -->
+		<view class="gap"></view>
 		<view class="bg-main">
 			<view class="dflex-b padding-lr padding-tb-sm">
 				<view class="flex1">总金额</view>
-				<view class=""><text style="font-size: 24rpx;">¥</text>46.32</view>
+				<view class=""><text style="font-size: 24rpx;">¥</text>{{data.total}}</view>
 			</view>
 			<!-- <view class="dflex-b padding-lr padding-tb-sm">
 				<view class="flex1">运费 (总重:4.960 kg )</view>
@@ -82,19 +85,40 @@
 	export default {
 		data() {
 			return {
-				data: {
-					src: '../../static/x0.jpg',
-					title: '标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题',
-					spec: '180cm',
-					price: '53.30'
-				},
+				data: [],
 				show: false,
 				value: '',
+				cList: {},
+				val: null,
+				vals: null,
+				list: [{
+						text: "店内用餐",
+						value: 'A'
+					},
+					{
+						text: "打包带走",
+						value: 'B'
+					}
+				]
 			}
 		},
+		onLoad(option) {
+			const e = uni.getStorageSync('carl')
+			this.cList = e
+			console.log('233333333333333', e)
+			// 解码 URL 编码的字符串
+			var dataString = decodeURIComponent(option.data);
+			// 尝试将字符串转换为 JSON 对象
+			var data = JSON.parse(dataString);
+			this.data = data
+			// 打印解码后的数据
+			console.log('eeeeeeeeeeeee============data', data);
+		},
 		methods: {
-			sendTypeChange(v) {
-				console.log(v)
+			sendTypeChange(v) {},
+			radioChange(v) {
+				console.log('2=================', v)
+				console.log('2=================22222', this.val)
 			},
 			onConfirm(v) {
 				console.log('vvvvvvvvvvvvvvv', v)
@@ -105,8 +129,73 @@
 				this.show = false
 			},
 			toBuy() {
-				uni.navigateTo({
-					url: `/pages/order/orderPaid/orderPaid`
+				console.log('this.val', this.val)
+				if (this.value == '') {
+					uni.showToast({
+						title: '请选择取餐时间',
+						icon: 'error',
+						duration: 1000
+					})
+					return
+				}
+				if (this.val == '' || this.val == null) {
+					uni.showToast({
+						title: '请选择取餐方式',
+						icon: 'error',
+						duration: 1000
+					})
+					return
+				}
+				const userName = uni.getStorageSync('userName');
+				const itemListArray = this.data.carlist.map(item => ({
+					skuId: item.skuId,
+					isGift: false, // 假设所有商品都不是礼物
+					basePrice: item.basePrice,
+					price: item.price,
+					quantity: item.quantity,
+					sellerType: 'C', // 假设所有商品卖家类型都是 'C'
+					isFenxiao: false // 假设所有商品都不是分销商品
+				}))
+
+				const params = {
+					orderType: 'waimai,cod',
+					isCod: true,
+					shippingType: 'SELF_PICKUP',
+					storeId: this.cList.id,
+					storeName: this.cList.name,
+					arriveCutTime: this.value,
+					sellerNick: this.cList.name,
+					buyerNick: userName,
+					itemList: itemListArray,
+					pickupInfo: {
+						pickupType: this.val,
+						isVerify: false
+					}
+				}
+				console.log('params', params);
+				// uni.navigateTo({
+				// 	url: `/pages/order/orderPaid/orderPaid`
+				// })
+				this.$request('post', `/order/retailOrder`, params, true).then(response => {
+					// 请求成功
+					console.log('response', response)
+					if (response.code == 200) {
+						const ids = this.data.carlist.map(car => car.id);
+						this.$request('delete', `/front/shoppingCart/${ids}`)
+						console.log('response.data', response.data)
+						uni.navigateTo({
+							url: `/pages/order/orderPaid/orderPaid?id=${response.data}`
+						})
+					} else if (response.code == 500) {
+						uni.showToast({
+							title: response.msg,
+							icon: 'error',
+							duration: 2000
+						});
+					}
+				}).catch(error => {
+					// 请求失败
+					console.error('请求失败:', error);
 				})
 			}
 		}
@@ -171,9 +260,10 @@
 
 	.good-num {
 		font-size: 12px;
-		padding-top: 40rpx;
+		padding-top: 65rpx;
 	}
-	.send-label{
+
+	.send-label {
 		font-size: 14px;
 		font-weight: 700;
 	}