123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527 |
- <template>
- <div class="page">
- <div class="page-top"></div>
- <div class="page-content" v-if="!isRequest">
- <template>
- <!-- 进步条 -->
- <SimpleStep :list="stepList" :active="step" v-if="showStepBar" />
- <div class="step-list py-4">
- <!-- 账号注册表单 -->
- <keep-alive>
- <FormClubRegister
- v-if="step === 1"
- ref="userForm"
- @step="onUserFormStep"
- />
- </keep-alive>
- <!-- 机构认证表单 -->
- <keep-alive>
- <FormClubInfo
- v-if="step === 2 && registerType.indexOf(2) !== -1"
- ref="clubInfoForm"
- @step="onClubInfoFormStep"
- />
- </keep-alive>
- <!-- 设备认证表单 -->
- <keep-alive>
- <FormClubDevice
- v-if="step === 3"
- ref="clubDeviceForm"
- @step="onclubDeviceFormStep"
- />
- </keep-alive>
- </div>
- </template>
- <!-- 机构已认证 || 机构认证中 || 机构认证失败 -->
- <template v-if="step === 2 && registerType.indexOf(2) === -1">
- <div class="message">
- <div class="status-icon" :class="autidStatusClass"></div>
- <div class="status">
- <span v-if="autidStatus === 0">机构认证失败</span>
- <span v-if="autidStatus === 1">机构认证成功</span>
- <span v-if="autidStatus === 2">机构认证中</span>
- </div>
- <div class="tip">提示:可点击认证记录看查看详情</div>
- </div>
- </template>
- <!-- 操作 -->
- <div class="control flex flex-col items-center">
- <div
- class="button next flex justify-center items-center mb-2"
- @click="onNextStep"
- >
- {{ step === 3 ? '提交' : '下一步' }}
- </div>
- <div
- class="button prev flex justify-center items-center"
- @click="onPrevStep"
- v-if="showPreButton"
- >
- 上一步
- </div>
- <div class="record mt-2" @click="toRecord">认证记录</div>
- </div>
- </div>
- <SimpleDialog
- v-model="active"
- @confirm="onConfirm"
- :cancel="false"
- description="抱歉,该用户已进行过正品授权申请"
- :center="true"
- />
- </div>
- </template>
- <script>
- import SimpleStep from '@/components/SimpleStep'
- import FormClubRegister from './components/form-club-register.vue'
- import FormClubInfo from './components/form-club-info.vue'
- import FormClubDevice from './components/form-club-device.vue'
- import { mapGetters } from 'vuex'
- export default {
- layout: 'app-hyt',
- components: {
- SimpleStep,
- FormClubRegister,
- FormClubInfo,
- FormClubDevice,
- },
- data() {
- return {
- isRequest: true,
- active: false,
- isSubmit: false,
- registerType: [3],
- step: 1,
- stepList: [
- {
- label: '账号注册',
- id: 1,
- recordRoute: '/record/club/detail',
- },
- {
- label: '机构认证',
- id: 2,
- recordRoute: '/record/club/detail',
- auditStatus: '',
- },
- {
- label: '设备认证',
- id: 3,
- recordRoute: '/record/device',
- auditStatus: '',
- },
- ],
- // 机构用户信息
- clubUserInfo: {},
- // 机构授权信息
- authInfo: {},
- // 机构认证设备列表信息
- productInfo: [],
- // 机构授权id
- authId: '',
- autidStatus: 0,
- }
- },
- computed: {
- ...mapGetters([
- 'supplierInfo',
- 'authUserId',
- 'routePrefix',
- 'accessToken',
- 'userInfo',
- 'clubUserId',
- ]),
- autidStatusClass() {
- if (this.autidStatus === 0) return 'danger'
- if (this.autidStatus === 1) return 'success'
- if (this.autidStatus === 2) return 'warning'
- },
- showStepBar() {
- if (this.step === 2) {
- if (this.registerType.indexOf(2) > -1) {
- return true
- } else {
- return false
- }
- }
- return true
- },
- showPreButton() {
- if (this.step === 1) return false
- if (this.step === 2) {
- if (this.registerType.indexOf(1) > -1) {
- return true
- } else {
- return false
- }
- }
- return true
- },
- },
- created() {
- this.authId = this.$route.query.authId || ''
- this.isRequest = true
- this.initPageForm()
- },
- beforeDestroy() {
- this.$toast.clear()
- this.isSubmit = false
- },
- methods: {
- onConfirm() {
- this.$router.push(this.routePrefix)
- },
- async onNextStep() {
- const validateAction = {
- 1: this.$refs.userForm?.validate,
- 2: this.$refs.clubInfoForm?.validate,
- 3: this.$refs.clubDeviceForm?.validate,
- }
- try {
- // 表单校验
- validateAction[this.step] && (await validateAction[this.step]())
- // 提交
- if (this.step === 3) {
- this.onSubmit()
- }
- // 下一步
- if (this.step < 3) {
- this.step++
- }
- } catch (error) {
- console.log(error)
- }
- console.log('userForm', this.clubUserInfo)
- },
- onPrevStep() {
- this.step > 1 && this.step--
- },
- async onSubmit() {
- this.$toast.loading({
- message: '正在提交注册信息,请勿操作...',
- duration: 0,
- })
- if (this.isSubmit) return
- this.isSubmit = true
- const params = {
- registerType: this.registerType.join(','),
- authUserId: this.authUserId,
- authId: this.authId,
- clubUserId: this.clubUserId,
- clubUserInfo: this.clubUserInfo,
- authInfo: this.authInfo,
- productInfo: this.productInfo,
- }
- console.log(params)
- try {
- const res = await this.$http.api.clubUserRegisterAll(params)
- console.log(res)
- this.$router.push(`${this.routePrefix}/record/message`)
- } catch (error) {
- console.log(error)
- this.$toast(error.msg)
- } finally {
- this.$toast.clear()
- this.isSubmit = false
- }
- },
- onUserFormStep(data) {
- console.log(data)
- this.clubUserInfo = data
- },
- onClubInfoFormStep(data) {
- console.log(data)
- this.authInfo = data
- },
- onclubDeviceFormStep(data) {
- console.log(data)
- this.productInfo = data
- },
- toRecord() {
- if (!this.accessToken) {
- this.$toast('请登录后查看')
- setTimeout(() => {
- this.$router.push(`${this.routePrefix}`)
- }, 1500)
- return
- }
- this.$router.push(`${this.routePrefix}/record/club/detail`)
- },
- // 初始化从页面进入的表单
- async initFormWithLink() {
- const authId = this.$route.query.authId
- if (this.accessToken) {
- // 已登录
- this.step = 2
- this.stepList = this.stepList.filter((item) => item.id !== 1)
- } else {
- this.registerType.push(1)
- }
- await this.initClubInfo({
- authUserId: this.authUserId,
- authId: authId,
- })
- this.isRequest = false
- },
- // 初始化从正常页面进入的表单
- async initFormWithNormal() {
- if (this.accessToken) {
- // 已登录
- this.step = 2
- this.stepList = this.stepList.filter((item) => item.id !== 1)
- await this.initClubInfo({
- authUserId: this.authUserId,
- mobile: this.userInfo.mobile,
- })
- } else {
- // 未登录
- this.registerType.push(1, 2)
- }
- this.isRequest = false
- },
- // 初始化表单
- initPageForm() {
- const linkType = this.$route.query.type || 'normal'
- const taskMap = {
- link: this.initFormWithLink,
- normal: this.initFormWithNormal,
- }
- taskMap[linkType]()
- },
- // 判断用户手机号是否绑定机构
- async initClubInfo(data) {
- try {
- const res = await this.$http.api.fetchClubAuthInfo(data)
- if (res.data.auth) {
- this.autidStatus = res.data.auth.auditStatus
- this.authId = res.data.auth.authId
- } else {
- this.registerType.push(2)
- }
- return Promise.resolve(res)
- } catch (error) {
- console.log(error)
- return Promise.reject(error)
- }
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- // pc 端
- @media screen and (min-width: 768px) {
- .page {
- background: #fff;
- }
- .page-top {
- height: 360px;
- background: url(~assets/theme-images/hyt/pc/banner-register.png);
- background-size: auto 360px;
- background-position: center;
- .logo {
- display: block;
- width: 120px;
- height: 120px;
- border-radius: 50%;
- background: #fff;
- }
- .name {
- font-size: 30px;
- color: #fff;
- }
- }
- .page-content {
- width: 1200px;
- margin: 0 auto;
- overflow: hidden;
- min-height: calc(100vh - 80px - 80px - 360px);
- box-sizing: border-box;
- padding-bottom: 40px;
- .message {
- display: flex;
- justify-content: center;
- align-items: center;
- flex-direction: column;
- margin-top: 60px;
- .status-icon {
- width: 88px;
- height: 88px;
- background-repeat: no-repeat;
- background-size: 75px auto;
- background-position: center;
- &.success {
- background-image: url(~assets/theme-images/common/icon-auth-primary.png);
- }
- &.warning {
- background-image: url(~assets/theme-images/common/icon-auth-warning.png);
- }
- &.danger {
- background-image: url(~assets/theme-images/common/icon-auth-danger.png);
- }
- }
- .status {
- font-size: 18px;
- color: #282828;
- margin: 12px 0;
- }
- .tip {
- color: #999999;
- font-size: 14px;
- }
- }
- .control {
- margin-top: 62px;
- .button {
- width: 295px;
- height: 50px;
- border-radius: 4px;
- cursor: pointer;
- &.prev {
- border: 1px solid #4093B5;
- color: #4093B5;
- }
- &.next {
- background-color: #4093B5;
- color: #fff;
- }
- }
- .record {
- font-size: 14px;
- cursor: pointer;
- color: #4093B5;
- }
- }
- .step-list {
- width: 700px;
- margin: 0 auto;
- }
- }
- }
- // 移动端
- @media screen and (max-width: 768px) {
- .page {
- background: #fff;
- }
- .page-top {
- height: 46vw;
- background: url(~assets/theme-images/hyt/h5/banner-register.png);
- background-size: auto 46vw;
- background-position: center;
- .logo {
- display: block;
- width: 14.8vw;
- height: 14.8vw;
- border-radius: 50%;
- background: #fff;
- }
- .name {
- font-size: 4vw;
- color: #fff;
- }
- }
- .page-content {
- padding: 0 7vw 7vw;
- .message {
- display: flex;
- justify-content: center;
- align-items: center;
- flex-direction: column;
- margin: 22.8vw 0;
- .status-icon {
- width: 23.6vw;
- height: 23.6vw;
- background-repeat: no-repeat;
- background-size: 20vw auto;
- background-position: center;
- &.success {
- background-image: url(~assets/theme-images/common/icon-auth-primary.png);
- }
- &.warning {
- background-image: url(~assets/theme-images/common/icon-auth-warning.png);
- }
- &.danger {
- background-image: url(~assets/theme-images/common/icon-auth-danger.png);
- }
- }
- .status {
- font-size: 4.2vw;
- color: #282828;
- margin: 3.2vw 0 2.4vw;
- }
- .tip {
- color: #999999;
- font-size: 3.2vw;
- }
- }
- .control {
- .button {
- width: 85.6vw;
- height: 12vw;
- border-radius: 4px;
- cursor: pointer;
- &.prev {
- border: 1px solid #4093B5;
- color: #4093B5;
- }
- &.next {
- background-color: #4093B5;
- color: #fff;
- }
- }
- .record {
- margin-top: 4.8vw;
- font-size: 3.4vw;
- cursor: pointer;
- color: #4093B5;
- }
- }
- }
- }
- </style>
|