Răsfoiți Sursa

优化toc订单

ymy 6 luni în urmă
părinte
comite
29fb791166

+ 1 - 0
env/dev.js

@@ -6,6 +6,7 @@ const ENV_PATH = {
   name: '销售系统', // 小程序名称
   // webSocketURL: 'wss://lsfdev.benyuntech.com/ws/websocket', // websocket url
   logo: '/1679883944003-logo1.png', // 登录页面显示的 logo
+  tenantId: '000000'
 }
 
 module.exports = ENV_PATH

+ 3 - 3
pages/home/home.vue

@@ -167,9 +167,9 @@
 			},
 			toBuy() {
 				console.log('e========carList', this.carList)
-				// uni.navigateTo({
-				// 	url: `/pages/order/submitOrder/submitOrder`
-				// })
+				uni.navigateTo({
+					url: `/pages/order/submitOrder/submitOrder`
+				})
 			},
 			onOrder() {
 				uni.navigateTo({

+ 35 - 7
pages/order/paySuccess/paySuccess.vue

@@ -1,10 +1,15 @@
 <template>
 	<view class="wh-full">
-		<topNavBar title="支付成功" />
+		<topNavBar title="支付成功" :leftIcon="false" />
 		<view class="pay-sucess">
-			<view class="pay-sucess-text">订单支付成功</view>
-			<uni-icons type="checkbox-filled" size="90" color="#27B148"></uni-icons>
-			<view class="go-btn">确认</view>
+			<view class="pay-sucess-text">
+				<u-icon name="checkmark-circle-fill" color="#06A103"></u-icon>支付成功
+			</view>
+			<!-- <uni-icons type="checkbox-filled" size="90" color="#27B148"></uni-icons> -->
+			<view class="pay-price">
+				¥<text>{{price}}</text>
+			</view>
+			<view class="go-btn" @click="jump">确认</view>
 		</view>
 	</view>
 </template>
@@ -13,11 +18,23 @@
 	export default {
 		data() {
 			return {
-				
+				price:0
+			}
+		},
+		onLoad(e) {
+			if(e.price){
+				this.price = e.price
 			}
 		},
 		methods: {
-			
+			jump(){
+				uni.redirectTo({
+					url: '/pages/order/myOrder/myOrder?type=3'
+				});
+				// uni.redirectTo({
+				// 	url: '/pages/order/myOrder/myOrder?type=0'
+				// });
+			}
 		}
 	}
 </script>
@@ -30,9 +47,20 @@
 		justify-content: center;
 		align-items: center;
 		.pay-sucess-text{
-			font-size: 24px;
+			font-size: 16px;
 			padding-top: 130upx;
 			padding-bottom: 90upx;
+			display: flex;
+			justify-content: center;
+			align-items: center;
+			color: #06A103;
+		}
+		.pay-price{
+			font-size: 24px;
+			text-align: center;
+			>text{
+				font-size: 44px;
+			}
 		}
 		.go-btn{
 			height: 76upx;

+ 168 - 42
pages/order/submitOrder/submitOrder.vue

@@ -47,7 +47,7 @@
 				</view>
 			</view>
 			<view class="goods-cart w-full">
-				<view class="goods-cont padding-tb" v-for="(item, index) in data.carlist" :key="index">
+				<view class="goods-cont padding-tb" v-for="(item, index) in cartData" :key="index">
 					<my-goods :item="item">
 						<view class="good-num">×{{item.quantity}}</view>
 					</my-goods>
@@ -60,7 +60,7 @@
 		<view class="bg-main">
 			<view class="dflex-b padding-lr padding-tb-sm">
 				<view class="flex1">总金额</view>
-				<view class="price">{{data.total}}</view>
+				<view class="price">{{total}}</view>
 			</view>
 			<!-- <view class="dflex-b padding-lr padding-tb-sm">
 				<view class="flex1">运费 (总重:4.960 kg )</view>
@@ -88,12 +88,16 @@
 	export default {
 		data() {
 			return {
+				cartData:[],
+				total: 0,
 				data: [],
 				show: false,
 				value: '',
+				bussinessInfo:{},
 				cList: {},
 				val: null,
 				vals: null,
+				tenantId:'',
 				list: [{
 						text: "店内用餐",
 						value: 0
@@ -108,20 +112,44 @@
 		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);
-			if(data.carlist[0].imgUrl.url) {
-				data.carlist[0].imgUrl = data.carlist[0].imgUrl.url;
-			}
+			// console.log('233333333333333', e)
+			// // 解码 URL 编码的字符串
+			// var dataString = decodeURIComponent(option.data);
+			// // 尝试将字符串转换为 JSON 对象
+			// var data = JSON.parse(dataString);
+			// if(data.carlist[0].imgUrl.url) {
+			// 	data.carlist[0].imgUrl = data.carlist[0].imgUrl.url;
+			// }
+			
+			// this.data = data
+			// // 打印解码后的数据
+			// console.log('eeeeeeeeeeeee============data', data);
 			
-			this.data = data
-			// 打印解码后的数据
-			console.log('eeeeeeeeeeeee============data', data);
+			const config = process.env.ENV_PATH ? require('../../../' + process.env.ENV_PATH) : require(
+				'../../../env/dev.js');
+			this.tenantId = config.tenantId;
+			this.initCart()
+			// this.loadBussinessInfo()
 		},
 		methods: {
+			initCart() {
+				let cartInfo = uni.getStorageSync('cartInfo');
+				if(cartInfo){
+					try{
+						this.cartData = JSON.parse(cartInfo)
+						this.totalPrice()
+					}catch(e){}
+				}
+			},
+			totalPrice() {
+				let total = 0;
+				for (let i = 0; i < this.cartData.length; i++) {
+					let priceInCents = Math.round(this.carList[i].price * 100);
+					let quant = this.carList[i].quantity;
+					total += priceInCents * quant;
+				}
+				this.total = (total / 100).toFixed(2);
+			},
 			sendTypeChange(v) {},
 			radioChange(v) {
 				console.log('2=================', v)
@@ -155,7 +183,7 @@
 				}
 				const userId = uni.getStorageSync('appUserId');
 				const userName = uni.getStorageSync('userName');
-				const itemListArray = this.data.carlist.map(item => ({
+				const itemListArray = this.cartData.map(item => ({
 					skuId: item.skuId,
 					gift: 1, // 假设所有商品都不是礼物
 					basePrice: Number(item.basePrice),
@@ -168,32 +196,42 @@
 					picUrl: item.imgUrl,
 					skuProperties: item.skuProperties,
 					totalFee: multiply(Number(item.price), item.quantity),
-					adjustFee: 0
+					adjustFee: 0,
+					skuCode: item.skuCode,
+					splitMergeId: item.splitMergeId,
+					productWeight: item.productWeight,
+					freightTemplateId: item.freightTemplateId
 				}))
 
 				const params = {
-					orderState: 1,
+					buyerRate:'1',
+					distributionOrder:'1',
+					orderState: 'WaitPay',
+					partConsign:'1',
 					orderType: 1,
-					serviceType: 1,
-					payAmount: Number(this.data.total),
-					totalAmount: Number(this.data.total),
+					serviceType: '1',
+					payAmount: Number(this.total),
+					totalAmount: Number(this.total),
 					discountAmount: 0,
 					adjustAmount: 0,
 					postAmount: 0,
-					receivedAmount: Number(this.data.total),
+					receivedAmount: Number(this.total),
 					commissionAmount: 0,
 					payOnDeliveryAmount: 0,
-					payOnDelivery: 1,
-					payType: 1,
-					payChannel: 1,
-					invoice: 1,
+					payOnDelivery: '1',
+					payType: '1',
+					payChannel: '1',
+					invoice: '1',
+					orderSource:'2',
 					storeId: this.cList.id,
 					storeName: this.cList.name,
 					sellerNick: this.cList.name,
+					sellerId: this.bussinessInfo.id,
 					buyerNick: userName,
 					customerId: userId,
+					sellerRate:'1',
 					orderItemList: itemListArray,
-					shippingType: 4,
+					shippingType: '4',
 					orderPickup: {
 						pickupType: this.val,
 						verify: 2,
@@ -204,28 +242,32 @@
 				// uni.navigateTo({
 				// 	url: `/pages/order/orderPaid/orderPaid`
 				// })
+				return
+				const that = this;
 				this.$request('post', `/order/tradeOrder/addTradeOrder`, 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.$emit('register_refresh');
-						uni.showToast({
-							title: '已下单,因目前是演示阶段,暂时不能付款',
-							icon: 'success',
-							duration: 2000,
-							complete: () => {
-								// 页面跳转放在complete回调中
-								uni.navigateTo({
-									url: `/pages/order/myOrder/myOrder?type=0`
-								})
-							}
-						})
-						// uni.navigateTo({
-						// 	url: `/pages/order/orderPaid/orderPaid?id=${response.data}`
+						// const ids = this.data.carlist.map(car => car.id);
+						// this.$request('delete', `/front/shoppingCart/${ids}`)
+						// console.log('response.data', response.data)
+						// uni.$emit('register_refresh');
+						// uni.showToast({
+						// 	title: '已下单,因目前是演示阶段,暂时不能付款',
+						// 	icon: 'success',
+						// 	duration: 2000,
+						// 	complete: () => {
+						// 		// 页面跳转放在complete回调中
+						// 		uni.navigateTo({
+						// 			url: `/pages/order/myOrder/myOrder?type=0`
+						// 		})
+						// 	}
 						// })
+						// // uni.navigateTo({
+						// // 	url: `/pages/order/orderPaid/orderPaid?id=${response.data}`
+						// // })
+						uni.removeStorageSync('cartInfo');
+						that.pay(response.msg)
 					} else if (response.code == 500) {
 						uni.showToast({
 							title: response.msg,
@@ -237,6 +279,90 @@
 					// 请求失败
 					console.error('请求失败:', error);
 				})
+			},
+			//获取商家信息
+			loadBussinessInfo() {
+				const that = this;
+				this.$req({
+					url: '/sale/business/queryBusiness',
+					method: 'GET',
+					data: {
+						pageNum: 1, //当前页
+						pageSize: 20 //每页条数
+					},
+					success: res => {
+						that.bussinessInfo = res.rows[0]
+					},
+					fail: err => {
+						let msg = ''
+						if (err && err.msg && err.msg.length < 15) {
+							msg = err.msg
+						} else {
+							msg = '系统繁忙'
+						}
+						that.$refs.uToast.show({
+							message: msg
+						})
+					},
+					complete: () => {
+			
+					}
+				})
+			},
+			//支付
+			pay(id) {
+				let that = this;
+				const openId = uni.getStorageSync("openId");
+				// let outTradeNo = this.uuid()
+				this.$req({
+					url: '/weChatPay/payment/miniPay',
+					method: 'POST',
+					data: {
+						tenantId: this.tenantId,
+						outTradeNo: id,
+						openId: openId,
+						total: this.totalPrice * 100,
+					},
+					other: res => {
+						wx.requestPayment({
+							"timeStamp": res.timeStamp,
+							"nonceStr": res.nonceStr,
+							"package": res.packageValue,
+							"signType": "RSA",
+							"paySign": res.paySign,
+							"success": function(res) {
+								// console.log('调用支付接口成功', res)
+								// that.$refs.uToast.show({
+								// 	type:'success',
+								// 	message: '操作成功!'
+								// })
+								uni.redirectTo({
+									url: '/pages/order/paySuccess/paySuccess?price=' + that
+										.totalPrice
+								});
+			
+							},
+							"fail": function(res) {
+								that.$refs.uToast.show({
+									type: 'error',
+									message: '支付失败!'
+								})
+								setTimeout(() => {
+									uni.redirectTo({
+										url: '/pages/order/myOrder/myOrder?type=1'
+									});
+								}, 1000)
+								console.log('调用支付接口fail', res)
+							},
+							"complete": function(res) {
+								console.log('调用支付接口完成', res)
+							}
+						})
+					},
+					complete: () => {
+						this.load = false
+					}
+				})
 			}
 		}
 	}

+ 4 - 4
utils/request.js

@@ -60,10 +60,10 @@ const request = parames => {
 					icon:'none',
 					duration: 2000
 				});
-				uni.removeStorageSync('token');
-				uni.reLaunch({
-					url: '/pages/login/login'
-				});
+				// uni.removeStorageSync('token');
+				// uni.reLaunch({
+				// 	url: '/pages/login/login'
+				// });
 			}else{
 				if(parames.fail){
 					parames.fail(data)