From 59f4dc012a2c42eebd31301444e0f8df9af088e0 Mon Sep 17 00:00:00 2001 From: wjt <1797368093@qq.com> Date: 星期三, 26 六月 2024 10:13:12 +0800 Subject: [PATCH] Merge branch 'master' of http://218.28.192.34:9999/r/sqys/sqys_xcx --- pages/registerCompany/registerCompany.vue | 219 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 197 insertions(+), 22 deletions(-) diff --git a/pages/registerCompany/registerCompany.vue b/pages/registerCompany/registerCompany.vue index 223df09..1710cf7 100644 --- a/pages/registerCompany/registerCompany.vue +++ b/pages/registerCompany/registerCompany.vue @@ -4,34 +4,44 @@ <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> - <view class="top-box"> + <view class="top-box" style="margin-top: 20rpx;"> <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> - <input type="text" placeholder="璇疯緭鍏�"/> + </view> + </view> + <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="aspectFit" class="sc border" v-else></image> + </view> + </view> <!-- <view class="form"> <view class="form-item"> @@ -63,43 +73,160 @@ <input type="text" placeholder="璇疯緭鍏�" v-model="form.companyAddress"/> </view> </view> --> - <u-button @click="register"> - 娉ㄥ唽 - </u-button> + <view class="bottom"> + <view @click="register" class="button"> + 娉ㄥ唽 + </view> + </view> + </view> </template> <script> - import { registerCompany, checkCode } from '@/api/auth.js' + import { registerCompany, checkCode, getNewVerify } 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湪鑾峰彇楠岃瘉鐮�' + }) + getNewVerify({phone: this.form.companyPhone }).then(val => { + if(val.data.code == 200) { + 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]) + }, + fail: err => { + uni.showToast({ + title: "涓婁紶鍑洪敊", + icon: 'none' + }) + } + }) + }, // 鏍¢獙瀛楁 authField(){ - + if(!this.form.companyUser) { + return '璇疯緭鍏ュ鍚�' + } + if(!this.form.companyPhone) { + return '璇疯緭鍏ユ墜鏈哄彿' + } + if(!this.form.code){ + return '璇疯緭鍏ラ獙璇佺爜' + } + if(!this.form.companyName) { + return "璇疯緭鍏ヤ紒涓氬悕绉�" + } + if(!this.form.companyCode){ + return '璇疯緭鍏ョ粺涓�绀句細淇$敤浠g爜' + } + if(!this.form.companyAddress){ + return "璇疯緭鍏ヤ紒涓氬湴鍧�" + } + if(!this.form.companyImg || !this.form.companyImg.length){ + return '璇蜂笂浼犺惀涓氭墽鐓�' + } + return false }, // 鏍¢獙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 "鏍¢獙澶辫触" } }, + // 娉ㄥ唽鎺ュ彛 async register(){ try{ + const value = this.authField() + if(value){ + uni.showToast({ + title: value, + icon: 'none' + }) + return + } await this.checkCode() // this.form.companyStatus = 1 registerCompany(this.form).then(val=>{ @@ -126,15 +253,18 @@ } </style> <style scoped lang="scss"> - .page-content{ - padding: 30rpx; - } +.page-content{ + padding: 32rpx; +} .form{ + padding: 24rpx; .form-item{ + margin-top: 20rpx; display: flex; justify-content: space-between; align-items: center; - margin-bottom: 20rpx; + padding-bottom: 20rpx; + border-bottom: 1px solid #F1F1F1; input{ text-align: right; font-size: 26rpx; @@ -144,6 +274,7 @@ } .require{ + color: #4A4E60; position: relative; &::after{ content: '*'; @@ -153,5 +284,49 @@ } } } + .form-item:last-child{ + padding-bottom: 0; + border-bottom: none; + } + .form-item:first-child{ + margin-top: 0; + } +} + +.top-box{ + background: #fff; + border-radius: 5px; +} +.bottom{ + position: fixed; + bottom: 0; + width: 100%; + background: #fff; + height: 132rpx; + left: 0; + display: flex; + align-items: center; + .button{ + margin: 0 32rpx; + height: 88rpx; + border-radius: 20rpx; + border: 1px solid #1171E0; + background: #1171E0; + color: #fff; + line-height: 88rpx; + width: 100%; + text-align: center; + font-size: 32rpx; + } +} +.sc{ + width: 90%; + height: 346rpx; + margin-bottom: 20rpx; + border-radius: 20rpx; + +} +.border{ + border: 2rpx solid #efefef; } </style> -- Gitblit v1.9.1