Преглед изворни кода

完成单位代缴接口接入

LinWuTai пре 2 дана
родитељ
комит
7dc0e24612

+ 11 - 3
pages/collect/collect.vue

@@ -132,9 +132,17 @@
 	}
 	
 	function onClickReport(report) {
-		uni.navigateTo({
-			url: `/pages/goOnEdu/course/courseDetail/courseDetail?id=${report.objId}&name=${report.title}`
-		})
+		if (report.objType === '1') {
+			uni.navigateTo({
+				url: `/pages/reportDetail/reportDetail?id=${report.objId}&title=${report.title}`
+			})
+		}
+		if (report.objType === '2') {
+			uni.navigateTo({
+				url: `/pages/goOnEdu/course/courseDetail/courseDetail?id=${report.objId}&name=${report.title}`
+			})
+		}
+		
 	}
 	onPullDownRefresh((e) => {
 		searchForm.value.pageNumber = 1

+ 70 - 3
pages/daiJiaoDanWeiChaXunJieGuo/daiJiaoDanWeiChaXunJieGuo.vue

@@ -64,8 +64,13 @@
 <script setup>
 	import { ref } from 'vue'
 	import { onLoad } from '@dcloudio/uni-app'
+	import { dept, deptPayment } from '@/api/cost.js'
+	import { msgError } from '../../utils/common'
 	
-	const id = ref()
+	import { useAuthStore } from '@/store/authStore'
+	const authStore = useAuthStore()
+	
+	const openid = ref('')
 	
 	const info = ref({
 		name: '某某某机构', // 机构名称
@@ -74,15 +79,77 @@
 		year: '2024', // 年份
 		price: '1000', // 金额
 		periodOfValidity: '2024.1.1-2024.12.31',
+		userIds: null,
 		remark: '根据《协会章程》规定,会费标准如下:<br/>1、副会长单位:50000元/年;<br/>2、常务理事及理事单位:10000元/年;<br/>3、普通会员单位:1000元/年;单位会员会籍为每年1月1日至12月31日。<br/>会员可享受以下权利:<br/>1、协会的选举权、被选举权和表决权;<br/>2、优先参加协会组织开展的各类活动;<br/>3、获得协会服务的优先权;<br/>4、对协会工作的批评建议权和监督权;<br/>5、请求协会维护合法权益;<br/>6、入会自愿、退会自由。'
 	})
 	
+	const params = ref({
+		timeStamp: '',
+		nonceStr: '',
+		package: '',
+		signType: '',
+		paySign: '',
+	})
+	
 	function onSubmit() {
-		console.log('点击缴费');
+		wx.requestPayment({
+		  timeStamp: params.value.timeStamp,
+		  nonceStr: params.value.nonceStr,
+		  package: params.value.package,
+		  signType: params.value.signType,
+		  paySign: params.value.paySign,
+		  success (res) {
+				msgSuccess('支付成功')
+				uni.navigateBack()
+			},
+		  fail (res) {
+				// console.log('支付失败', res)
+				const errMsg = res.errMsg
+				if (errMsg.indexOf('fail cancel')) {
+					msgError('已取消支付')
+				}
+			}
+		})
 	}
 	
 	onLoad((load) => {
-		id.value = load.id
+		const name = load.name
+		const year = load.year
+		const number = load.number
+		const price = load.price
+		const type = Number(price) > 10000 ? '副会长单位' : Number(price) > 1000 ? '常务理事及理事单位' : '普通会员单位'
+		const userId = load.userId
+		
+		openid.value = uni.getStorageSync('openid')
+		
+		info.value = {
+			name: name, // 机构名称
+			payProject: `${year}年度${type}会费`, // 支付项目
+			type: `${type}会费`, // 类型
+			year, // 年份
+			price, // 金额
+			periodOfValidity: `${year}.1.1-${year}.12.31`,
+			userId,
+			remark: '根据《协会章程》规定,会费标准如下:<br/>1、副会长单位:50000元/年;<br/>2、常务理事及理事单位:10000元/年;<br/>3、普通会员单位:1000元/年;单位会员会籍为每年1月1日至12月31日。<br/>会员可享受以下权利:<br/>1、协会的选举权、被选举权和表决权;<br/>2、优先参加协会组织开展的各类活动;<br/>3、获得协会服务的优先权;<br/>4、对协会工作的批评建议权和监督权;<br/>5、请求协会维护合法权益;<br/>6、入会自愿、退会自由。'
+		}
+		
+		const form = {
+			title: `${info.value.payProject}代缴`,
+			year: info.value.year,
+			amount: info.value.price,
+			desc: `${info.value.payProject}代缴`,
+			userId: info.value.userId,
+			openid: openid.value
+		}
+		deptPayment(form).then(res => {
+			if (res && res.message === 'success') {
+				params.value = res.data
+				console.log('支付参数', params.value)
+			} else {
+				msgError(res.message)
+				uni.navigateBack()
+			}
+		})
 	})
 </script>
 

+ 14 - 9
pages/daiJiaoDanWeiHuiFei/daiJiaoDanWeiHuiFei.vue

@@ -18,6 +18,7 @@
 	import { ref, reactive } from 'vue'
 	import { onLoad, onReady } from '@dcloudio/uni-app'
 	import { dept } from '@/api/cost.js'
+import { msgError } from '../../utils/common'
 	
 	const formRef = ref()
 	const formData = reactive({
@@ -71,16 +72,20 @@
 	function onSubmit() {
 		formRef.value.validate((valid) => {
 			if (valid) {
-				// 查询到的ID
-				const id = '1'
-				uni.navigateTo({
-					url: `/pages/daiJiaoDanWeiChaXunJieGuo/daiJiaoDanWeiChaXunJieGuo?id=${id}`
+				dept(formData.form).then(res => {
+					if(res && res.message === 'success') {
+						const data = res.data
+						if (data.canPay) {
+							uni.navigateTo({
+								url: `/pages/daiJiaoDanWeiChaXunJieGuo/daiJiaoDanWeiChaXunJieGuo?name=${formData.form.name}&number=${formData.form.number}&year=${formData.form.year}&price=${data.duePrice}&userId=${data.userId}`
+							})
+						} else {
+							msgError('无法代支付')
+						}
+					} else {
+						msgError(res.message)
+					}
 				})
-				// dept(formData.form).then(res => {
-				// 	if(res && res.message === 'message') {
-				// 		console.log(res)
-				// 	}
-				// })
 			}
 		})
 	}

+ 9 - 2
pages/daiJiaoGeRenChaXunJieGuo/daiJiaoGeRenChaXunJieGuo.vue

@@ -54,6 +54,11 @@
 	import { onLoad } from '@dcloudio/uni-app'
 	import { person, personPayment } from '@/api/cost.js'
 	
+	import { useAuthStore } from '@/store/authStore'
+	const authStore = useAuthStore()
+	
+	const openid = ref('')
+	
 	const form = ref({
 		name: '',
 		idNumber: ''
@@ -87,12 +92,12 @@
 			year: info.value.year,
 			amount: info.value.duePrice,
 			desc: `${info.value.year}年度个人会费代缴`,
-			userId: info.value.userId
+			userId: info.value.userId,
+			openid: openid.value
 		}
 		personPayment(form).then(res => {
 			if (res && res.message === 'success') {
 				const params = res.data
-				console.log('会费缴交params', params)
 				wx.requestPayment({
 				  timeStamp: params.timeStamp,
 				  nonceStr: params.nonceStr,
@@ -114,6 +119,8 @@
 		yearList.value = []
 		const year = new Date().getFullYear()
 		
+		openid.value = uni.getStorageSync('openid')
+		
 		for (let i = 0; i < 10; i++) {
 			yearList.value.push({
 				value: `${year - i}`,

+ 16 - 3
pages/geRenHuiFeiJiaoJiao/geRenHuiFeiJiaoJiao.vue

@@ -67,8 +67,11 @@
 	import { onLoad } from '@dcloudio/uni-app'
 	import { useAuthStore } from '@/store/authStore'
 	import { personPayment } from '@/api/cost.js'
+	import { msgError, msgSuccess } from '../../utils/common'
 	const authStore = useAuthStore()
 	
+	const openid = ref('')
+	
 	// 用户信息
 	const user = ref({
 		userIcon: '1',
@@ -92,7 +95,8 @@
 			title: info.value.payProject,
 			year: info.value.year,
 			amount: info.value.price,
-			desc: info.value.payProject
+			desc: info.value.payProject,
+			openid: openid.value
 		}
 		personPayment(form).then(res => {
 			if (res && res.message === 'success') {
@@ -104,18 +108,27 @@
 				  signType: params.signType,
 				  paySign: params.paySign,
 				  success (res) {
-						console.log('支付成功', res)
+						msgSuccess('支付成功')
+						uni.navigateBack()
 					},
 				  fail (res) {
-						console.log('支付失败', res)
+						// console.log('支付失败', res)
+						const errMsg = res.errMsg
+						if (errMsg.indexOf('fail cancel')) {
+							msgError('已取消支付')
+						}
 					}
 				})
+			} else {
+				msgError(res.message)
+				uni.navigateBack()
 			}
 		})
 	}
 	
 	onLoad((load) => {
 		user.value = authStore.userInfo
+		openid.value = uni.getStorageSync('openid')
 		info.value = {
 			username: user.value.name,
 			payProject: `${load.year}年度个人会费`,