From b668b85e312acc4cfaecc423ff53cf7d919b7cf1 Mon Sep 17 00:00:00 2001
From: wjt <1797368093@qq.com>
Date: 星期六, 22 六月 2024 15:18:28 +0800
Subject: [PATCH] 注册接口对接

---
 pages/registerCompany/registerCompany.vue |  115 +++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 99 insertions(+), 16 deletions(-)

diff --git a/pages/registerCompany/registerCompany.vue b/pages/registerCompany/registerCompany.vue
index be5a83f..8efc6a1 100644
--- a/pages/registerCompany/registerCompany.vue
+++ b/pages/registerCompany/registerCompany.vue
@@ -4,16 +4,16 @@
 			<view class="form">
 				<view class="form-item">
 					<text class="label require">濮撳悕</text>
-					<input type="text" placeholder="璇疯緭鍏�"/>
+					<input type="text" placeholder="璇疯緭鍏�" v-model="form.companyUser"/>
 				</view>
 				<view class="form-item">
 					<text class="label require">鎵嬫満鍙�</text>
-					<input type="text" placeholder="璇疯緭鍏�"/>
+					<input type="number" placeholder="璇疯緭鍏�" v-model="form.companyPhone"/>
 				</view>
 				<view class="form-item">
 					<text class="label require">楠岃瘉鐮�</text>
-					<input type="text" placeholder="璇疯緭鍏�"/>
-					<text>鑾峰彇楠岃瘉鐮�</text>
+					<input type="text" placeholder="璇疯緭鍏�" v-model="form.code"/>
+					<text @click="getCode">{{tips}}</text>
 				</view>
 			</view>
 		</view>
@@ -21,21 +21,27 @@
 			<view class="form">
 				<view class="form-item">
 					<text class="label require">浼佷笟鍚嶇О</text>
-					<input type="text" placeholder="璇疯緭鍏�"/>
+					<input type="text" placeholder="璇疯緭鍏�" v-model="form.companyName"/>
 				</view>
 				<view class="form-item">
 					<text class="label require">缁熶竴绀句細淇$敤浠g爜</text>
-					<input type="text" placeholder="璇疯緭鍏�"/>
+					<input type="text" placeholder="璇疯緭鍏�" v-model="form.companyCode"/>
+				</view>
+				<view class="form-item">
+					<text class="label require">浼佷笟鍦板潃</text>
+					<input type="text" placeholder="璇疯緭鍏�" v-model="form.companyAddress"/>
 				</view>
 				<view class="form-item">
 					<text class="label require">钀ヤ笟鎵х収</text>
-
+					
 				</view>
-		
+				
 			</view>
-			<view style="text-align: center;">
-				<img src="/static/i07.png" alt="" class="sc"/>
+			<view style="text-align: center;" @click="startUpload">
+				<img src="/static/i07.png" v-if="!form.companyImg" alt="" class="sc" />
+				<image :src="config + form.companyImg" mode="widthFix" class="sc" v-else></image>
 			</view>
+			
 		</view>
 		<!-- <view class="form">
 			<view class="form-item">
@@ -77,16 +83,86 @@
 </template>
 
 <script>
-	import { registerCompany, checkCode } from '@/api/auth.js'
+	import { registerCompany, checkCode, getCode } from '@/api/auth.js'
+	import { upload } from '@/common/upload'
+	import { config } from '@/common/config.js'
 	export default {
 		data() {
 			return {
 				form: {
-					
-				}
+					companyImg: ''
+				},
+				config: config.baseUrl,
+				isSendCode: false,
+				countdownTime: 20,
+				timer: null,
+				tips: '鑾峰彇楠岃瘉鐮�',
 			}
 		},
 		methods: {
+			startCountdown() {
+				if(this.timer) {
+					clearTimeout(this.timer)
+					this.timer = null
+				}
+				if(this.countdownTime <= 0) {
+					this.tips = "閲嶆柊鑾峰彇"
+					this.isSendCode = false
+					this.countdownTime = 20
+					return
+				}
+				this.timer = setTimeout(() => {
+					this.countdownTime--
+					this.tips = `${this.countdownTime}s鍚庨噸鏂拌幏鍙朻
+					this.startCountdown()
+				}, 1000)
+			},
+			getCode() {
+				if(!this.form.companyPhone){
+					uni.showToast({
+						title: '璇疯緭鍏ユ墜鏈哄彿',
+						icon: 'none'
+					})
+					return
+				}
+				if(!this.$u.test.mobile(this.form.companyPhone)){
+					uni.showToast({
+						title: '璇疯緭鍏ユ纭殑鎵嬫満鍙�',
+						icon: 'none'
+					})
+					return
+				}
+				if (!this.isSendCode) {
+					this.isSendCode = true
+					uni.showLoading({
+						title: '姝e湪鑾峰彇楠岃瘉鐮�'
+					})
+					getCode({phone: this.form.companyPhone }).then(val => {
+							this.startCountdown()
+							uni.hideLoading();
+							this.tips = `${this.countdownTime}s鍚庨噸鏂拌幏鍙朻
+							uni.$u.toast('楠岃瘉鐮佸凡鍙戦��');
+					})
+				} else {
+					uni.$u.toast('鍊掕鏃剁粨鏉熷悗鍐嶅彂閫�');
+				}
+			},
+			uploadImage(file) {
+				upload(file).then(val => {
+					// console.log(val.fileName)
+					this.form.companyImg = val.fileName
+				})
+			},
+			// 鍥剧墖涓婁紶鎺ュ彛
+			startUpload() {
+				uni.chooseImage({
+					count: 1,
+					success: val => {
+						// console.log(val.tempFilePaths[0])
+						this.uploadImage(val.tempFilePaths[0])
+					}
+				})
+			},
 			// 鏍¢獙瀛楁
 			authField(){
 				
@@ -94,14 +170,20 @@
 			// 鏍¢獙code
 			async checkCode() {
 				try {
-					const { code, data } = await checkCode({ code: this.form.code, phone: this.form.companyPhone, userType: '02' })
-					if(code == 200) {
+					const { data } = await checkCode({ code: this.form.code, phone: this.form.companyPhone, userType: '02' })
+					console.log(data.data)
+					if(data.code == 200 && data.data != false) {
 						return Promise.resolve()
 					} else {
+						uni.showToast({
+							title: '楠岃瘉鐮侀敊璇�',
+							icon: 'none'
+						})
+						throw "鏍¢獙澶辫触"
 						return Promise.refject()
 					}
 				}catch(err){
-					
+					throw "鏍¢獙澶辫触"
 				}
 			},
 			// 娉ㄥ唽鎺ュ彛
@@ -203,5 +285,6 @@
 	width: 90%;
 	height: 346rpx;
 	margin-bottom: 20rpx;
+	border-radius: 20rpx;
 }
 </style>

--
Gitblit v1.9.1