wjt
2024-06-22 b668b85e312acc4cfaecc423ff53cf7d919b7cf1
注册接口对接
4个文件已修改
148 ■■■■ 已修改文件
api/index.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/companyLogin/companyLogin.vue 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/index.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/registerCompany/registerCompany.vue 115 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/index.js
@@ -12,4 +12,8 @@
// 惠企政策 
export function doc(id){
    return http.get('/system/doc/'+id, {params: data}, { custom: { loading: true }});
}
// 企业注册
export function companyRegister(data) {
    return http.post('/system/company/add', {params: data}, { custom: { loading: true }});
}
pages/companyLogin/companyLogin.vue
@@ -1,8 +1,13 @@
<!-- 企业登录 -->
<template>
    <view class="companylogin">
        <u-navbar title="" :autoBack="true" bgColor="transparent">
            <template slot="center">
            </template>
        </u-navbar>
        <view class="image-box">
            <image src="https://picsum.photos/760/345" mode="aspectFit" ></image>
            <image src="/static/policy/loginHeader.png" mode="widthFix" ></image>
        </view>
        <view class="content-box">
            <!-- <u-form label-width="60" labelAlign="right" >
@@ -43,8 +48,7 @@
            <view style="margin-top: 56rpx;">
                <view class="per-button" @click="loging">登录</view>
            </view>
             <!-- v-if="form.userType == '02'" -->
             <view @click="goRegister" class="company-register">
             <view @click="goRegister" class="company-register" v-if="form.userType == '02'">
                 企业注册
             </view>
            <!-- <u--text text="企业注册" type="primary" @click="goRegister"></u--text> -->
@@ -105,6 +109,7 @@
                    getCode({phone: this.form.phone }).then(val => {
                            this.startCountdown()
                            uni.hideLoading();
                            this.tips = `${this.countdownTime}s后重新获取`
                            uni.$u.toast('验证码已发送');
                    })
                } else {
@@ -139,14 +144,16 @@
            },
            getInfo() {
                getInfo().then(val => {
                    console.log(val)
                    uni.setStorageSync('userInfo',  val.data.data)
                    if(this.form.userType == '02') {
                        uni.redirectTo({
                            url:`/pages/companyIndex/companyIndex`
                            url:`/qiye/qiyeIndex/qiyeIndex`
                        })
                    } else if(this.form.userType == '01'){
                        uni.redirectTo({
                            url:`/policy/policyIndex/policyIndex`
                        })
                    } else {
                        uni.redirectTo({
                            url:`/policy/policyIndex/policyIndex`
                        })
@@ -178,7 +185,7 @@
            border-radius: 40rpx 40rpx 0 0;
            padding: 40rpx 32rpx;
            position: relative;
            top: -40rpx;
            top: 80rpx;
            background-color: white;
            .form {
                .form-item{
pages/index/index.vue
@@ -12,10 +12,10 @@
            <img src="/static/i06.png" class="more" @click="more1()" alt="" />
        </view>
        <view class="btnbox">
            <img src="/static/i01.png" class="more" alt="" style="margin-right: 18rpx;" />
            <img src="/static/i02.png" class="more" alt="" />
            <img src="/static/i03.png" class="more" alt="" style="margin-right: 18rpx;" />
            <img src="/static/i04.png" class="more" alt="" />
            <img src="/static/i01.png" class="more" alt="" style="margin-right: 18rpx;" @click="goMyCompany('01')"/>
            <img src="/static/i02.png" class="more" alt="" @click="goMyCompany('02')"/>
            <img src="/static/i03.png" class="more" alt="" style="margin-right: 18rpx;" @click="goMyCompany('01')"/>
            <img src="/static/i04.png" class="more" alt="" @click="goMyCompany('00')"/>
                <!-- <u-button @click="goMyCompany('01')">我是执法人员</u-button>
                <u-button @click="goMyCompany('02')">我是企业</u-button>
                <u-button @click="goMyCompany('00')">运营管理</u-button> -->
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">统一社会信用代码</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: '正在获取验证码'
                    })
                    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>