root 7 сар өмнө
parent
commit
3d05156e6e

+ 14 - 7
.env

@@ -1,9 +1,16 @@
-NODE_ENV = 'development'
-VITE_SERVE = 'http://10.113.248.3:8443' # 开发阶段服务器地址
-VITE_MEDIA = 'https://test.jue-ming.com:8084'
-VITE_PORT = 8443
 
-# NODE_ENV = 'production'
-# VITE_SERVE = 'https://jinhong-credit.com:8443' # 开发阶段服务器地址
+# NODE_ENV = 'development'
+# VITE_SERVE = 'http://10.113.248.3:8443' # 开发阶段服务器地址
 # VITE_MEDIA = 'https://test.jue-ming.com:8084'
-# VITE_PORT = 8443
+# VITE_PORT = 8443
+
+# NODE_ENV = 'test'
+# VITE_SERVE = 'https://jinhong-credit.com:8445' # 开发阶段服务器地址
+# VITE_IMG_URL = 'https://jinhong-credit.com:8443'
+# VITE_MEDIA = 'https://jinhong-credit.com:8445'
+# VITE_PORT = 8445
+
+NODE_ENV = 'production'
+VITE_SERVE = 'https://jinhong-credit.com:8443' # 开发阶段服务器地址
+VITE_MEDIA = 'https://test.jue-ming.com:8084'
+VITE_PORT = 8443

+ 3 - 3
src/pages/index/inviteUser.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-	import { imgUrl } from "@/utils/http";
+	import { mediaUrl } from "@/utils/http";
 	import { ref } from "vue";
 	import { useMemberStore } from "@/stores/";
 	import { createPosterApi } from "@/services/home";
@@ -27,7 +27,7 @@
 					filePath: tempFilePaths[0],
 					name: "file",
 					success: (uploadFileRes) => {
-						let photo = `${imgUrl}${JSON.parse(uploadFileRes.data).data}`;
+						let photo = `${mediaUrl}${JSON.parse(uploadFileRes.data).data}`;
 						placard.value = photo;
 						isCreatePaster.value = false;
 					},
@@ -102,7 +102,7 @@
 			});
 		} else {
 			// console.log(res.data);
-			placard.value = `${imgUrl}${res.data}`;
+			placard.value = `${mediaUrl}${res.data}`;
 			isCreatePaster.value = true;
 		}
 	};

+ 39 - 35
src/pages/index/pay.vue

@@ -8,6 +8,7 @@ import {
 	queryOrderStatusApi,
 	queryParamsApi,
 	saveReportApi,
+	cancelPayApi
 } from "@/services/home";
 import type { QueryPa } from "@/types/home";
 import HomeList from "./components/HomeList.vue";
@@ -30,6 +31,12 @@ const userInfo = useMemberStore();
  *
  */
 
+/**
+ * flag = 1 表示未支付
+ * flag = 4 表示已支付,且当前扫码用户userId = 已支付用户userId
+ * flag = 5 已支付,且当前扫码用户userId != 已支付用户userId
+*/
+
 //获取到的传输过来的唯一值
 const params = reactive<any>({
 	title: "", //标题
@@ -184,61 +191,60 @@ const formatterData = (date: any, day: any) => {
 	return y + "-" + m + "-" + d;
 };
 
-//1先生成订单号
-//2订单号生成后调用后台获取核心参数  核心参数获取到以后
-//3调用位置支付、、 查看成功与否
-//4如果是成功支付和用户取消了订单
-//5否则循环调用查询支付接口
-//支付完成后进行下边的逻辑--开始查询报告
-
 //点击支付按钮生成的方法
 const payButton = () => {
 	//先调用订单生成
-	creatOrderFun(orderParams)
+	creatOrderFun({ 'linkId': orderParams.linId, 'userId': orderParams.userId })
 };
-//生成订单号
+
+// 预支付,生成支付信息
 const creatOrderFun = async (val: any) => {
 	const res = await createOrderApi(val);
+	// 预支付成功,拉起微信支付
 	if (res.code == '200') {
-		uni.showToast({
-			title: '支付成功'
-		})
-		queryParams(scene.value)
+		let payInfo = {
+			"timeStamp": res.data.timeStamp,
+			"nonceStr": res.data.nonceStr,
+			"package": res.data.package,
+			"signType": "RSA",
+			"paySign": res.data.paySign,
+		}
+		payFun(payInfo);
 	}
-	//获取到订单号了
-
-	//然后调用预支付接口后去核心数据
-	//payFun(val)
 };
-//支付接口调用
-//调用后台接口返回订单号
-//调用后台接口返回  下单核心数据
+
+// 拉起微信支付收银台
 const payFun = async (val: any) => {
-	const res = await payAppointmentApi(val);
-	//调用微信支付方法
 	uni.requestPayment({
 		...val,
 		success: (res: any) => {
 			if (res) {
-				console.log(res);
 				if (res.errMsg == "requestPayment:ok") {
+					params.flag = 4;
 					// console.log("支付成功");
 				}
 			}
 		},
-		fail: (res: any) => {
-			console.log(res);
-			if (res.errMsg == "requestPayment:fail cancel") {
-				console.log("用户取消了支付");
+		fail: (err: any) => {
+			console.log(err);
+			if (err.errMsg == "requestPayment:fail cancel") {
+				cancelPay(orderParams.linId)
 			} else {
-				queryOrderFor();
-				//调用支付失败的具体原因
-				//这时是不是就应该定时器调用订单状态
 			}
 		},
 	});
 };
 
+// 查询支付结果
+const queryPayResult = () => {
+
+}
+
+// 用户取消支付
+const cancelPay = async (val: any) => {
+	const res = await cancelPayApi(val);
+}
+
 //点击税务风险检测--弹出输入税务号的信息
 const swGet = ref<any>();
 const openSW = () => {
@@ -252,21 +258,19 @@ const goCheck = () => {
 //查询订单状态
 const queryOrderStatus = async (val: any) => {
 	const res = await queryOrderStatusApi(val);
-	//判定返回参数
-	//如果订单完成了
-	//如果是满了返回了
-	//需要去掉定时器
 	clearInterval(timeMe.value);
 };
+
 //定时器参数
 const timeMe = ref<any>();
 //创建一个定时器
+
 const queryOrderFor = () => {
 	//进来的时候清除定时器
 	clearInterval(timeMe.value);
 	timeMe.value = setInterval(() => {
 		//嗲用方法
-		queryOrderStatus({});
+		queryOrderStatus(orderParams.linId);
 	}, 3000);
 };
 

+ 1 - 1
src/pages/my/my.vue

@@ -55,11 +55,11 @@ const report = () => {
 const exit = () => {
 	uni.showToast({ title: "已退出" });
 	//跳转到报告页面
-
 	setTimeout(() => {
 		uni.switchTab({
 			url: "/pages/index/index",
 		});
+		memberStore.saveUserInfo({});
 	}, 550);
 };
 

+ 18 - 7
src/services/home.ts

@@ -21,12 +21,16 @@ const createPosterUrl = '/link/save'
 //根据scene 查询传输参数路径
 const queryParamsUrl = '/link/check'
 
-//生成订单号
-const createOrderUrl = '/order/save'
+//生成订单
+const createOrderUrl = '/api/wx-pay/aspiPay'
+// const createOrderUrl = '/order/save'
 
 //预支付接口
 const payAppointmentUrl = ''
 
+// 取消支付
+const cancelPayUrl = '/api/wx-pay/cancel'
+
 // 保存报告
 const saveReportUrl = '/report/save'
 
@@ -39,8 +43,8 @@ const queryReportListByUserUrl = '/report/findByUser/'
 // 我的邀约
 const queryMyInvitesUrl = '/link/find'
 
-//订单号查询
-const queryOrderStatusUrl = ''
+// 查询订单状态
+const queryOrderStatusUrl = '/api/wx-pay/queryOrder'
 
 //报错登录用户信息
 const saveUserSWUrl = ''
@@ -139,6 +143,14 @@ export const createOrderApi = (val: any) => {
   })
 }
 
+// 取消支付
+export const cancelPayApi = (val: any) => {
+  return http<any>({
+    method: 'GET',
+    url: `${cancelPayUrl}/${val}`,
+  })
+}
+
 //调用后去后台核心参数--预支付
 export const payAppointmentApi = (val: any) => {
   return http<any>({
@@ -178,9 +190,8 @@ export const queryReportListByUserApi = (id: string, val: any) => {
 //根据订单号查询用户订单状况
 export const queryOrderStatusApi = (val: any) => {
   return http<any>({
-    method: 'POST',
-    url: queryOrderStatusUrl,
-    data: { ...val },
+    method: 'GET',
+    url: `queryOrderStatusUrl/${val}`,
   })
 }
 

+ 2 - 2
src/utils/http.ts

@@ -5,8 +5,8 @@ import { userLoginApi } from '@/services/home'
 //引入 pinia 。。登录后将信息储存到pinia
 
 const baseUrl = import.meta.env.VITE_SERVE
-export const imgUrl = `${import.meta.env.VITE_SERVE}/file/show?filePath=`
-export const mediaUrl = `${import.meta.env.VITE_MEDIA}/file/show/media?filePath=`
+export const imgUrl = `${import.meta.env.VITE_IMG_URL}/file/show?filePath=`
+export const mediaUrl = `${import.meta.env.VITE_MEDIA}/file/show?filePath=`
 
 let temp_request: any[] = [],
   is_freshing = false