liujiaxin 3 weken geleden
bovenliggende
commit
c3194aa54b

+ 4 - 4
common/request.js

@@ -10,11 +10,11 @@ export default class Request {
 		// let path = 'https://test.userapp.store.cdwjyyh.com';
 		// let path = 'https://user.test.ylrztop.com/api';
 
-		let path = 'https://userapp.klbycp.com/store'; //百域承品
-		let path2 = 'https://userapp.klbycp.com'; //百域承品
+		// let path = 'https://userapp.klbycp.com/store'; //百域承品
+		// let path2 = 'https://userapp.klbycp.com'; //百域承品
 
-		// let path = 'http://qeeaf625.natappfree.cc/store'; //本地
-		// let path2 = 'http://qeeaf625.natappfree.cc'; //本地
+		let path = 'http://qeeaf625.natappfree.cc/store'; //本地
+		let path2 = 'http://qeeaf625.natappfree.cc'; //本地
 
 		let type = 0
 		uni.setStorageSync('requestPath', path2)

+ 1 - 1
pages/home/index.vue

@@ -9,7 +9,7 @@
 					<!-- 这里是状态栏 -->
 					<view class="status_bar" :style="{height: statusBarHeight}"></view>
 					<view class="top-title">
-						<view class="name">百域承品</view>
+						<view class="name" >百域承品</view>
 						<!-- <view class="dot">•</view><view class="sub-name">七彩互联网医院</view> -->
 					</view>
 					<!-- 搜索框、购物车、客服 -->

+ 93 - 172
pages/shopping/paymentOrder.vue

@@ -181,63 +181,50 @@
 				user: null,
 				payParams: null,
 				userinfo: {},
-				 isPaying: false, // 防止重复支付
-				    payDebounceTimer: null // 防抖定时器
+				isPaying: false, // 防止重复支付
+				payDebounceTimer: null // 防抖定时器
 			}
 		},
 		onLoad(option) {
-			 this.getSafeUserInfo();
-			  this.orderId = JSON.parse(option.orderId);
-			  // this.orderBindUser(this.orderId)
-			  this.getStoreOrderById();
-			  this.getStoreConfig();
-			  this.getUserInfo();
+			this.getSafeUserInfo();
+			this.orderId = JSON.parse(option.orderId);
+			// this.orderBindUser(this.orderId)
+			this.getStoreOrderById();
+			this.getStoreConfig();
+			this.getUserInfo();
 		},
 		onUnload() {
 			this.clearPayTypeFun()
 		},
-		//发送给朋友
-		// onShareAppMessage(res) {
-		// 	return {
-		// 		title: "帮TA支付",
-		// 		path: '/pages_user/user/otherPaymentOrder?orderId='+this.orderId,
-		// 		imageUrl: this.$store.state.imgpath+'/app/image/logo.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
-		// 	}
-
-		// },
-		methods: {getSafeUserInfo() {
-  try {
-    const userInfoStr = uni.getStorageSync('userInfo');
-    if (!userInfoStr) {
-      this.userinfo = {};
-      return;
-    }
-    
-    // 如果是字符串,解析为对象
-    if (typeof userInfoStr === 'string') {
-      this.userinfo = JSON.parse(userInfoStr);
-    } else {
-      // 如果是对象,直接使用
-      this.userinfo = userInfoStr;
-    }
-    
-    console.log('获取到的用户信息:', this.userinfo);
-  } catch (error) {
-    console.error('获取用户信息失败:', error);
-    this.userinfo = {};
-  }
-},clearTokenAndRedirect() {
-  // 清除 token
-  uni.removeStorageSync('AppToken');
-  uni.removeStorageSync('userInfo');
-  
-  // 跳转到登录页
-  setTimeout(() => {
-    uni.reLaunch({
-      url: '/pages/auth/login'
-    });
-  }, 500);
-},
+		methods: {
+			getSafeUserInfo() {
+				try {
+					const userInfoStr = uni.getStorageSync('userInfo');
+					if (!userInfoStr) {
+						this.userinfo = {};
+						return;
+					}
+
+					// 如果是字符串,解析为对象
+					if (typeof userInfoStr === 'string') {
+						this.userinfo = JSON.parse(userInfoStr);
+					} else {
+						// 如果是对象,直接使用
+						this.userinfo = userInfoStr;
+					}
+
+					console.log('获取到的用户信息:', this.userinfo);
+				} catch (error) {
+					console.error('获取用户信息失败:', error);
+					this.userinfo = {};
+				}
+			},
+			redirectToLogin() {
+				// 直接跳转到登录页,不删除token和userInfo
+				uni.navigateTo({
+					url: '/pages/auth/login'
+				});
+			},
 			async clearPayTypeFun() {
 				this.payParams && this.payParams.orderId && await clearPayType(this.payParams)
 			},
@@ -269,11 +256,6 @@
 						this.getStoreOrderById();
 						this.getStoreConfig();
 						this.getUserInfo();
-						// uni.showShareMenu({
-						// 	withShareTicket:true,
-						// 	//小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
-						// 	menus:["shareAppMessage"] //不设置默认发送给朋友
-						// })
 					} else {
 						uni.showToast({
 							icon: 'none',
@@ -399,60 +381,62 @@
 			// 防抖后的支付方法
 			// 修复后的支付方法
 			payOrder() {
-			  // 1. 安全地获取用户信息
-			  this.getSafeUserInfo();
-			  
-			  // 2. 检查 maOpenId,但不要直接修改字符串
-			  console.log('支付前检查用户信息:', this.userinfo);
-			  
-			  // 3. 检查用户信息是否有效
-			  if (!this.userinfo || Object.keys(this.userinfo).length === 0) {
-			    uni.showToast({
-			      title: '用户信息异常,请重新登录',
-			      icon: 'none'
-			    });
-			    
-			    // 清除 token 并跳转到登录页
-			    this.clearTokenAndRedirect();
-			    return;
-			  }
-			  // 4. 检查 maOpenId,如果不存在则提示重新登录
-			  if (!this.userinfo.maOpenId) {
-			    uni.showModal({
-			      title: '提示',
-			      content: '用户信息不完整,需要重新登录',
-			      success: (res) => {
-			        if (res.confirm) {
-			          this.clearTokenAndRedirect();
-			        }
-			      }
-			    });
-			    return;
-			  }
-			
-			  
-			  // 5. 检查登录状态
-			  this.utils.isLogin().then(res => {
-			    if (res) {
-			      // 创建防抖函数实例
-			      const debouncedPay = this.debounce(function() {
-			        this.executePay();
-			      }, 1000); // 1秒防抖时间
+				// 1. 安全地获取用户信息
+				this.getSafeUserInfo();
+
+				// 2. 检查 maOpenId,但不要直接修改字符串
+				// 3. 检查用户信息是否有效
+				if (!this.userinfo || Object.keys(this.userinfo).length === 0) {
+					uni.showToast({
+						title: '用户信息异常,请重新登录',
+						icon: 'none'
+					});
+					
+					// 直接跳转到登录页
+					this.redirectToLogin();
+					return;
+				}
+				
+				// 4. 检查 maOpenId,如果不存在则提示重新登录
+				if (!this.userinfo.maOpenId) {
+					uni.showModal({
+						title: '提示',
+						content: '用户信息不完整,需要重新登录',
+						success: (res) => {
+							if (res.confirm) {
+								this.redirectToLogin();
+							}
+						}
+					});
+					return;
+				}
+
+				// 5. 检查登录状态
+				this.utils.isLogin().then(res => {
+					if (res) {
+						// 创建防抖函数实例
+						const debouncedPay = this.debounce(function() {
+							this.executePay();
+						}, 1000); // 1秒防抖时间
+
+						// 执行防抖函数
+						debouncedPay();
+					} else {
+						// 未登录,直接跳转到登录页
+						this.redirectToLogin();
+					}
+				}).catch(err => {
+					console.error('检查登录状态失败:', err);
+					uni.showToast({
+						title: '登录状态异常',
+						icon: 'none'
+					});
+					// 登录状态异常,也跳转到登录页
+					this.redirectToLogin();
+				});
+			},
 			
-			      // 执行防抖函数
-			      debouncedPay();
-			    } else {
-			      // 未登录,跳转到登录页
-			      this.clearTokenAndRedirect();
-			    }
-			  }).catch(err => {
-			    console.error('检查登录状态失败:', err);
-			    uni.showToast({
-			      title: '登录状态异常',
-			      icon: 'none'
-			    });
-			  });
-			}, // 实际的支付执行逻辑
+			// 实际的支付执行逻辑
 			executePay() {
 				var data = {
 					orderId: this.order.id,
@@ -514,70 +498,7 @@
 						});
 					}
 				);
-			},
-			// payOrder(){
-			// 	var data = {orderId:this.order.id,payType:this.order.payType};
-			// 	var that=this;
-			// 	uni.showLoading();
-			// 	pay(data).then(
-			// 		res => {
-			// 			if(res.code==200){
-			// 				 console.log(res);
-			// 				 if(res.payType==1||res.payType==2||res.payType==3){
-			// 					 uni.requestPayment({
-			// 					 	provider: 'wxpay',
-			// 					 	timeStamp: res.result.timeStamp,
-			// 					 	nonceStr:res.result.nonceStr,
-			// 					 	package: res.result.packageValue,
-			// 					 	signType: res.result.signType,
-			// 					 	paySign: res.result.paySign,
-			// 					 	success: function(res) {
-			// 							console.log('yess:' + JSON.stringify(res));
-			// 					 		 uni.hideLoading();
-			// 							  uni.redirectTo({
-			// 							  	url:"success?order="+JSON.stringify(that.order)
-			// 							  }) 
-			// 					 	},
-			// 					 	fail: function(err) {
-			// 							uni.showToast({
-			// 								icon:'none',
-			// 								title:'fail:' + JSON.stringify(err),
-			// 							});
-			// 					 		console.log('fail:' + JSON.stringify(err));
-			// 					 		uni.hideLoading();
-			// 					 	},
-			// 						complete: (err) => {
-			// 							console.log('fail:' + JSON.stringify(err));
-			// 						}
-			// 					 });
-			// 				 }
-			// 				 // else if(res.payType==3){
-			// 					//  uni.hideLoading();
-			// 					//  if(that.order.isPrescribe){
-			// 					// 	 //如果是处方订单开处方
-			// 					// 	uni.redirectTo({
-			// 					// 		url:"prescribe?orderId="+that.order.id
-			// 					// 	})
-			// 					//  }
-			// 					//  else{
-			// 					// 	//如果是普通订单
-			// 					// 	uni.redirectTo({
-			// 					// 		url:"success?order="+JSON.stringify(that.order)
-			// 					// 	}) 
-			// 					//  }
-			// 				 // }
-
-			// 			}else{
-			// 				uni.showToast({
-			// 					icon:'none',
-			// 					title: res.msg,
-			// 				});
-			// 			}
-			// 		},
-			// 		rej => {}
-			// 	);
-
-			// }
+			}
 		}
 	}
 </script>

+ 2 - 2
pages/user/index.vue

@@ -181,12 +181,12 @@
 
 
 							<!-- 测试用下面的 -->
-							<!-- <view class="item no-marin-bottom align-top" @click="navgetTo('/pages_course/livingList')">
+							<view class="item no-marin-bottom align-top" @click="navgetTo('/pages_course/livingList')">
 								<image
 									src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/integral.png"
 									mode=""></image>
 								<text class="text">直播</text>
-							</view> -->
+							</view>
 
 							<view class="item no-marin-bottom" @click="toManager()">
 								<image

File diff suppressed because it is too large
+ 482 - 356
pages_course/living.vue


+ 1 - 1
pages_shopping/live/complaint.vue

@@ -3,7 +3,7 @@
 		<view class="mt60 p34">
 			<view class="color#{$5} ">投诉对象</view>
 			<view class="align-center mt30 mb50">
-				<image class="w100 h100 mr30" style="border-radius: 50%;" src="/static/logo.png"></image>
+				<image class="w98 h98 mr30" style="border-radius: 50%;" src="/static/logo.png"></image>
 				<text>百域承品</text>
 			</view>
 		</view>

+ 117 - 53
pages_shopping/live/paymentOrder.vue

@@ -56,8 +56,6 @@
 				</view>
 				<view class="item">
 					<text class="label">订单金额</text>
-					<!-- <text class="text"
-						v-if="order!=null">{{order ? (Number(order.totalPrice) || 0).toFixed(2) : "0.00"}}</text> -->
 					<text class="text"
 						v-if="order!=null">{{order ? (Number(order.payPrice) || 0).toFixed(2) : "0.00"}}</text>
 				</view>
@@ -89,22 +87,24 @@
 	import {
 		payConfirmReward,
 	} from '@/api/order'
+	
 	export default {
 		data() {
 			return {
 				type: '',
 				payPrice: null,
 				newOrder: {},
-				payType: 2,
+				payType: 1, // 默认微信支付
 				order: null,
 				orderId: null,
 				payDelivery: 0,
 				payMoney: 0,
 				config: null,
-				payType: 1,
 				user: null,
 				couponUserId: null,
-				payParams: null
+				payParams: null,
+				userinfo: {}, // 添加用户信息存储
+				isPaying: false // 防止重复支付
 			}
 		},
 		computed: {
@@ -118,17 +118,13 @@
 			}
 		},
 		onLoad(options) {
-			// if (options.payPrice) {
-			// 	this.payPrice = options.payPrice;
-			// }
+			this.getSafeUserInfo(); // 页面加载时获取用户信息
+			
 			if (options.couponUserId) {
 				this.couponUserId = options.couponUserId;
 			}
 			console.log("支付订单是>>", options)
 			this.type = options.type;
-			// this.liveId = options.liveId
-			// this.productId=options.productId
-			// console.log("支付订单",options)
 
 			if (options.orderList) {
 				try {
@@ -143,21 +139,41 @@
 		onUnload() {
 			this.clearPayTypeFun()
 		},
-		// //发送给朋友
-		// onShareAppMessage(res) {
-		// 	const combinationOrderId = this.combinationOrderId ?
-		// 		`&combinationOrderId=${encodeURIComponent(this.combinationOrderId)}` : ''
-		// 	return {
-		// 		title: "帮TA支付",
-		// 		path: '/pages_user/user/otherPaymentOrder?orderId=' + this.orderId + combinationOrderId,
-		// 		imageUrl: 'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/logo.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
-		// 	}
-
-		// },
 		methods: {
+			getSafeUserInfo() {
+				try {
+					const userInfoStr = uni.getStorageSync('userInfo');
+					if (!userInfoStr) {
+						this.userinfo = {};
+						return;
+					}
+
+					// 如果是字符串,解析为对象
+					if (typeof userInfoStr === 'string') {
+						this.userinfo = JSON.parse(userInfoStr);
+					} else {
+						// 如果是对象,直接使用
+						this.userinfo = userInfoStr;
+					}
+
+					console.log('获取到的用户信息:', this.userinfo);
+				} catch (error) {
+					console.error('获取用户信息失败:', error);
+					this.userinfo = {};
+				}
+			},
+			
+			redirectToLogin() {
+				// 直接跳转到登录页
+				uni.navigateTo({
+					url: '/pages/auth/login'
+				});
+			},
+			
 			async clearPayTypeFun() {
 				this.payParams && this.payParams.orderId && await clearPayType(this.payParams)
 			},
+			
 			weixinPayOrder() {
 				var data = {
 					orderId: this.order.orderId,
@@ -182,17 +198,14 @@
 									paySign: result.paySign,
 									success: function(res) {
 										uni.hideLoading();
-
 										uni.redirectTo({
 											url: "./success?order=" + JSON.stringify(that.newOrder)
 										})
-
-
 									},
 									fail: function(err) {
 										uni.showToast({
 											icon: 'none',
-											title: 'fail:' + JSON.stringify(err),
+											title: '支付失败',
 										});
 										uni.hideLoading();
 									}
@@ -210,37 +223,84 @@
 				);
 
 			},
-
-
-
-
-
-
-
-
-
-
+			
+			// 修改后的支付方法
 			payOrder() {
-				if (this.type == 'win') {
-					this.toPayConfirmReward()
+				// 1. 防止重复点击
+				if (this.isPaying) return;
+				
+				// 2. 安全地获取用户信息
+				this.getSafeUserInfo();
+
+				// 3. 检查用户信息是否有效
+				if (!this.userinfo || Object.keys(this.userinfo).length === 0) {
+					uni.showToast({
+						title: '用户信息异常,请重新登录',
+						icon: 'none'
+					});
+					
+					// 直接跳转到登录页
+					this.redirectToLogin();
+					return;
+				}
+				// 4. 检查 maOpenId,如果不存在则提示重新登录
+				if (!this.userinfo.maOpenId) {
+					uni.showModal({
+						title: '提示',
+						content: '用户信息不完整,需要重新登录',
+						success: (res) => {
+							if (res.confirm) {
+								this.redirectToLogin();
+							}
+						}
+					});
+					return;
+				}
 
-				} else {
-					if (this.payType == 1) {
-						console.log("这个order", this.order)
-						const {
-							itemJson,
-							...newOrder
-						} = this.order;
-						this.newOrder = newOrder;
-						console.log("这个newOrder", this.newOrder)
-						this.weixinPayOrder()
+				// 5. 检查登录状态
+				this.utils.isLogin().then(res => {
+					if (res) {
+						// 设置支付状态防止重复点击
+						this.isPaying = true;
+						
+						// 执行支付逻辑
+						if (this.type == 'win') {
+							this.toPayConfirmReward()
+						} else {
+							if (this.payType == 1) {
+								console.log("这个order", this.order)
+								const {
+									itemJson,
+									...newOrder
+								} = this.order;
+								this.newOrder = newOrder;
+								console.log("这个newOrder", this.newOrder)
+								this.weixinPayOrder()
+							} else {
+								uni.showToast({
+									title: "暂时无可用支付",
+									icon: 'none'
+								})
+							}
+						}
+						
+						// 支付完成后重置状态
+						setTimeout(() => {
+							this.isPaying = false;
+						}, 2000);
 					} else {
-						uni.showToast({
-							title: "暂时无可用支付",
-							icon: 'none'
-						})
+						// 未登录,直接跳转到登录页
+						this.redirectToLogin();
 					}
-				}
+				}).catch(err => {
+					console.error('检查登录状态失败:', err);
+					uni.showToast({
+						title: '登录状态异常',
+						icon: 'none'
+					});
+					// 登录状态异常,也跳转到登录页
+					this.redirectToLogin();
+				});
 			},
 
 			// 选微信支付或者支付宝支付
@@ -248,6 +308,7 @@
 				this.payType = e.detail.value; // 获取选中的 value
 				console.log('当前选中:', this.payType);
 			},
+			
 			toPayConfirmReward() {
 				let data = {
 					orderId: this.order.orderId
@@ -294,6 +355,7 @@
 					rej => {}
 				);
 			},
+			
 			getStoreConfig() {
 				getStoreConfig().then(
 					res => {
@@ -305,6 +367,7 @@
 					rej => {}
 				);
 			},
+			
 			payTypeChange(e) {
 				if (this.combinationOrderId) {
 					this.editPayTypeByCombinationId(e.detail.value)
@@ -312,6 +375,7 @@
 					this.editPayType(e.detail.value)
 				}
 			},
+			
 			editPayType(payType) {
 				var data = {
 					orderId: this.orderId,

Some files were not shown because too many files changed in this diff