From 8771da2ccf6f7c3fd2a8c89a1a0e230c6386db7f Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期一, 17 十一月 2025 15:40:48 +0800
Subject: [PATCH] feat(api): 新增多个API接口并优化配置

---
 pages/pay/register.vue |  218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 218 insertions(+), 0 deletions(-)

diff --git a/pages/pay/register.vue b/pages/pay/register.vue
new file mode 100644
index 0000000..c44068a
--- /dev/null
+++ b/pages/pay/register.vue
@@ -0,0 +1,218 @@
+<template>
+	<view class="u-p-h-50">
+		<view class="title">鎮ㄥソ锛屾杩庢敞鍐岋紒</view>
+		<u-form labelPosition="top" :model="form" :rules="rules" labelWidth="200"
+			:labelStyle="{fontSize:'34rpx',fontWeight:'bold'}" ref="uForm">
+			<u-form-item label="濮撳悕" prop="memberName" borderBottom>
+				<u-input v-model="form.memberName" border="none" placeholder="璇疯緭鍏ュ鍚�"></u-input>
+			</u-form-item>
+			<u-form-item label="韬唤璇佸彿" prop="idcard" borderBottom>
+				<u-input v-model="form.idcard" border="none" placeholder="璇疯緭鍏ヨ韩浠借瘉鍙�"></u-input>
+			</u-form-item>
+			<u-form-item label="鎵嬫満鍙�" prop="mobile" borderBottom>
+				<u-input v-model="form.mobile" border="none" placeholder="璇疯緭鍏ユ墜鏈哄彿"></u-input>
+			</u-form-item>
+			<u-form-item label="鍥惧舰楠岃瘉鐮�" prop="captchaCode" borderBottom>
+				<u-input v-model="form.captchaCode" border="none" placeholder="璇疯緭鍏ュ浘褰㈤獙璇佺爜"></u-input>
+				<image @click="getImgCode" class="img-code" slot="right" :src="imgCode.bg" mode=""></image>
+			</u-form-item>
+			<u-form-item label="鐭俊楠岃瘉鐮�" prop="verificationCode" borderBottom>
+				<u-input v-model="form.verificationCode" maxlength="6" border="none" placeholder="璇疯緭鍏ョ煭淇¢獙璇佺爜"></u-input>
+				<u-button slot="right" @tap="getCode" color="#de2d35" plain>{{tips}}</u-button>
+			</u-form-item>
+		</u-form>
+		<view class="u-text-center u-m-t-40 color-999 u-font-24">
+			<label @click="checked = !checked" class="radio">
+				<radio style="transform: scale(0.7);" color="#de2d35" :checked="checked" /><text>鎴戝凡闃呰骞跺悓鎰�</text>
+				<text style="color: #de2d35;" @click.stop="show = true">銆婇噾铻嶇敓鎬佸湀骞冲彴浼氬憳娉ㄥ唽鍗忚銆�</text>
+			</label>
+
+		</view>
+		<u-modal confirmText="闃呰骞跺悓鎰�" confirmColor="#de2d35" @confirm="show = false;checked = true" :show="show" title="閲戣瀺鐢熸�佸湀骞冲彴浼氬憳娉ㄥ唽鍗忚">
+			<scroll-view scroll-y style="height: 60vh;">
+				<user-agreement></user-agreement>
+			</scroll-view>
+		</u-modal>
+		<u-code :seconds="seconds" ref="uCode" @change="codeChange"></u-code>
+		<view class="btn-box">
+			<u-button @click="submit" text="娉ㄥ唽" type="error" color="#de2d35" shape="circle"></u-button>
+		</view>
+	</view>
+</template>
+
+<script>
+	import {
+		getVerify,
+		getH5PayCheckVerifyCode,
+		h5PayLogin
+	} from '@/common/api/index'
+	export default {
+		data() {
+			return {
+				show: false,
+				checked: true,
+				cid: '',
+				imgCode: {},
+				tips: '',
+				// refCode: null,
+				seconds: 60,
+				form: {
+					memberName: '',
+					idcard: '',
+					mobile: '',
+					captchaCode: '',
+					verificationCode: '',
+				},
+				rules: {
+					memberName: [{
+						type: 'string',
+						required: true,
+						message: '濮撳悕涓嶈兘涓虹┖',
+						trigger: ['blur']
+					}],
+					idcard: [{
+						type: 'string',
+						required: true,
+						message: '韬唤璇佸彿涓嶈兘涓虹┖',
+						trigger: ['blur']
+					}, {
+						validator: (rule, value, callback) => {
+							return uni.$u.test.idCard(value);
+						},
+						message: '韬唤璇佸彿涓嶆纭�',
+						// 瑙﹀彂鍣ㄥ彲浠ュ悓鏃剁敤blur鍜宑hange
+						trigger: ['blur'],
+					}],
+					mobile: [{
+							type: 'string',
+							required: true,
+							message: '鎵嬫満鍙蜂笉鑳戒负绌�',
+							trigger: ['blur']
+						},
+						{
+							validator: (rule, value, callback) => {
+								return uni.$u.test.mobile(value);
+							},
+							message: '鎵嬫満鍙风爜涓嶆纭�',
+							// 瑙﹀彂鍣ㄥ彲浠ュ悓鏃剁敤blur鍜宑hange
+							trigger: ['change'],
+						}
+					],
+					captchaCode: [{
+						type: 'string',
+						required: true,
+						message: '鍥惧舰楠岃瘉鐮佷笉鑳戒负绌�',
+						trigger: ['blur', 'change']
+					}],
+					verificationCode: [{
+						type: 'string',
+						required: true,
+						message: '鐭俊楠岃瘉鐮佷笉鑳戒负绌�',
+						trigger: ['blur', 'change']
+					}],
+				},
+			};
+		},
+		onLoad(opt) {
+			this.cid = opt.cid
+			this.getImgCode()
+		},
+		methods: {
+			codeChange(text) {
+				this.tips = text;
+			},
+			getCode() {
+				if (!this.form.captchaCode) {
+					uni.showToast({
+						icon: 'none',
+						title: '璇疯緭鍏ュ浘褰㈤獙璇佺爜'
+					})
+					return
+				}
+				if (!this.form.mobile) {
+					uni.showToast({
+						icon: 'none',
+						title: '璇疯緭鍏ユ墜鏈哄彿'
+					})
+					return
+				}
+				if (this.$refs.uCode.canGetCode) {
+					// 妯℃嫙鍚戝悗绔姹傞獙璇佺爜
+					uni.showLoading({
+						title: '姝e湪鑾峰彇楠岃瘉鐮�'
+					})
+					getH5PayCheckVerifyCode({
+						mobile: this.form.mobile,
+						captchaCode: this.form.captchaCode,
+						verifyToken: this.imgCode.token
+					}).then(res => {
+						uni.hideLoading();
+						// 杩欓噷姝ゆ彁绀轰細琚玹his.start()鏂规硶涓殑鎻愮ず瑕嗙洊
+						uni.$u.toast('楠岃瘉鐮佸凡鍙戦��');
+						// 閫氱煡楠岃瘉鐮佺粍浠跺唴閮ㄥ紑濮嬪�掕鏃�
+						this.$refs.uCode.start();
+					}).catch(() => {
+						// uni.hideLoading();
+						this.getImgCode()
+					})
+				} else {
+					uni.$u.toast('鍊掕鏃剁粨鏉熷悗鍐嶅彂閫�');
+				}
+			},
+			getImgCode() {
+				uni.showLoading()
+				getVerify().then(res => {
+					uni.hideLoading();
+					res.bg = 'data:image/jpeg;base64,' + res.bg
+					this.imgCode = res
+				}).catch(() => {
+					uni.hideLoading();
+				})
+			},
+			submit() {
+				if(!this.checked){
+					uni.showToast({
+						icon: 'none',
+						title: '璇峰厛闃呰骞跺悓鎰忕敤鎴峰崗璁�'
+					})
+					return
+				}
+				this.$refs.uForm.validate().then(res => {
+					uni.showLoading()
+					h5PayLogin(this.form).then(res => {
+						uni.hideLoading();
+						uni.setStorageSync('IS_NEW', false)
+						uni.redirectTo({
+							url: '/pages/pay/scanpay?cid=' + this.cid
+						})
+					}).catch(() => {
+						uni.hideLoading();
+					})
+				}).catch(errors => {
+					// uni.$u.toast('鏍¢獙澶辫触')
+				})
+			}
+		},
+	}
+</script>
+<style>
+	page {
+		background-color: #fff;
+	}
+</style>
+<style lang="scss">
+	.title {
+		font-size: 44rpx;
+		font-weight: bold;
+		padding: 50rpx 0;
+	}
+
+	.btn-box {
+		margin-top: 40rpx;
+	}
+
+	.img-code {
+		width: 140rpx;
+		height: 70rpx;
+	}
+</style>

--
Gitblit v1.9.1