club-register.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <div class="page">
  3. <div class="page-top flex flex-col justify-center items-center">
  4. <!-- <img class="logo" :src="supplierInfo.logo" /> -->
  5. <!-- <div
  6. class="name mt-2"
  7. v-text="supplierInfo.shopName + '正品授权申请'"
  8. ></div> -->
  9. <div class="name mt-2">正品授权申请</div>
  10. </div>
  11. <div class="page-content" v-if="!isRequest">
  12. <template>
  13. <!-- 进步条 -->
  14. <SimpleStep :list="stepList" :active="step" v-if="showStepBar" />
  15. <div class="step-list py-4">
  16. <!-- 账号注册表单 -->
  17. <keep-alive>
  18. <FormClubRegister
  19. v-if="step === 1"
  20. ref="userForm"
  21. @step="onUserFormStep"
  22. />
  23. </keep-alive>
  24. <!-- 机构认证表单 -->
  25. <keep-alive>
  26. <FormClubInfo
  27. v-if="step === 2 && registerType.indexOf(2) !== -1"
  28. ref="clubInfoForm"
  29. @step="onClubInfoFormStep"
  30. />
  31. </keep-alive>
  32. <!-- 设备认证表单 -->
  33. <keep-alive>
  34. <FormClubDevice
  35. v-if="step === 3"
  36. ref="clubDeviceForm"
  37. @step="onclubDeviceFormStep"
  38. />
  39. </keep-alive>
  40. </div>
  41. </template>
  42. <!-- 机构已认证 || 机构认证中 || 机构认证失败 -->
  43. <template v-if="step === 2 && registerType.indexOf(2) === -1">
  44. <div class="message">
  45. <div class="status-icon" :class="autidStatusClass"></div>
  46. <div class="status">
  47. <span v-if="autidStatus === 0">机构认证失败</span>
  48. <span v-if="autidStatus === 1">机构认证成功</span>
  49. <span v-if="autidStatus === 2">机构认证中</span>
  50. </div>
  51. <div class="tip">提示:可点击认证记录看查看详情</div>
  52. </div>
  53. </template>
  54. <!-- 操作 -->
  55. <div class="control flex flex-col items-center">
  56. <div
  57. class="button next flex justify-center items-center mb-2"
  58. @click="onNextStep"
  59. >
  60. {{ step === 3 ? '提交' : '下一步' }}
  61. </div>
  62. <div
  63. class="button prev flex justify-center items-center"
  64. @click="onPrevStep"
  65. v-if="showPreButton"
  66. >
  67. 上一步
  68. </div>
  69. <div class="record mt-2" @click="toRecord">认证记录</div>
  70. </div>
  71. </div>
  72. <SimpleDialog
  73. v-model="active"
  74. @confirm="onConfirm"
  75. :cancel="false"
  76. description="抱歉,该用户已进行过正品授权申请"
  77. :center="true"
  78. />
  79. </div>
  80. </template>
  81. <script>
  82. import SimpleStep from '@/components/SimpleStep'
  83. import FormClubRegister from './components/form-club-register.vue'
  84. import FormClubInfo from './components/form-club-info.vue'
  85. import FormClubDevice from './components/form-club-device.vue'
  86. import { mapGetters } from 'vuex'
  87. export default {
  88. layout: 'app-ross',
  89. components: {
  90. SimpleStep,
  91. FormClubRegister,
  92. FormClubInfo,
  93. FormClubDevice,
  94. },
  95. data() {
  96. return {
  97. isRequest: true,
  98. active: false,
  99. isSubmit: false,
  100. registerType: [3],
  101. step: 1,
  102. stepList: [
  103. {
  104. label: '账号注册',
  105. id: 1,
  106. recordRoute: '/record/club/detail',
  107. },
  108. {
  109. label: '机构认证',
  110. id: 2,
  111. recordRoute: '/record/club/detail',
  112. auditStatus: '',
  113. },
  114. {
  115. label: '设备认证',
  116. id: 3,
  117. recordRoute: '/record/device',
  118. auditStatus: '',
  119. },
  120. ],
  121. // 机构用户信息
  122. clubUserInfo: {},
  123. // 机构授权信息
  124. authInfo: {},
  125. // 机构认证设备列表信息
  126. productInfo: [],
  127. // 机构授权id
  128. authId: '',
  129. autidStatus: 0,
  130. }
  131. },
  132. computed: {
  133. ...mapGetters([
  134. 'supplierInfo',
  135. 'authUserId',
  136. 'routePrefix',
  137. 'accessToken',
  138. 'userInfo',
  139. 'clubUserId',
  140. ]),
  141. autidStatusClass() {
  142. if (this.autidStatus === 0) return 'danger'
  143. if (this.autidStatus === 1) return 'success'
  144. if (this.autidStatus === 2) return 'warning'
  145. },
  146. showStepBar() {
  147. if (this.step === 2) {
  148. if (this.registerType.indexOf(2) > -1) {
  149. return true
  150. } else {
  151. return false
  152. }
  153. }
  154. return true
  155. },
  156. showPreButton() {
  157. if (this.step === 1) return false
  158. if (this.step === 2) {
  159. if (this.registerType.indexOf(1) > -1) {
  160. return true
  161. } else {
  162. return false
  163. }
  164. }
  165. return true
  166. },
  167. },
  168. created() {
  169. this.authId = this.$route.query.authId || ''
  170. this.isRequest = true
  171. this.initPageForm()
  172. },
  173. beforeDestroy() {
  174. this.$toast.clear()
  175. this.isSubmit = false
  176. },
  177. methods: {
  178. onConfirm() {
  179. this.$router.push(this.routePrefix)
  180. },
  181. async onNextStep() {
  182. const validateAction = {
  183. 1: this.$refs.userForm?.validate,
  184. 2: this.$refs.clubInfoForm?.validate,
  185. 3: this.$refs.clubDeviceForm?.validate,
  186. }
  187. try {
  188. // 表单校验
  189. validateAction[this.step] && (await validateAction[this.step]())
  190. // 提交
  191. if (this.step === 3) {
  192. this.onSubmit()
  193. }
  194. // 下一步
  195. if (this.step < 3) {
  196. this.step++
  197. }
  198. } catch (error) {
  199. console.log(error)
  200. }
  201. console.log('userForm', this.clubUserInfo)
  202. },
  203. onPrevStep() {
  204. this.step > 1 && this.step--
  205. },
  206. async onSubmit() {
  207. this.$toast.loading({
  208. message: '正在提交注册信息,请勿操作...',
  209. duration: 0,
  210. })
  211. if (this.isSubmit) return
  212. this.isSubmit = true
  213. const params = {
  214. registerType: this.registerType.join(','),
  215. authUserId: this.authUserId,
  216. authId: this.authId,
  217. clubUserId: this.clubUserId,
  218. clubUserInfo: this.clubUserInfo,
  219. authInfo: this.authInfo,
  220. productInfo: this.productInfo,
  221. }
  222. console.log(params)
  223. try {
  224. const res = await this.$http.api.clubUserRegisterAll(params)
  225. console.log(res)
  226. this.$router.push(`${this.routePrefix}/record/message`)
  227. } catch (error) {
  228. console.log(error)
  229. this.$toast(error.msg)
  230. } finally {
  231. this.$toast.clear()
  232. this.isSubmit = false
  233. }
  234. },
  235. onUserFormStep(data) {
  236. console.log(data)
  237. this.clubUserInfo = data
  238. },
  239. onClubInfoFormStep(data) {
  240. console.log(data)
  241. this.authInfo = data
  242. },
  243. onclubDeviceFormStep(data) {
  244. console.log(data)
  245. this.productInfo = data
  246. },
  247. toRecord() {
  248. if (!this.accessToken) {
  249. this.$toast('请登录后查看')
  250. setTimeout(() => {
  251. this.$router.push(`${this.routePrefix}`)
  252. }, 1500)
  253. return
  254. }
  255. this.$router.push(`${this.routePrefix}/record/club/detail`)
  256. },
  257. // 初始化从页面进入的表单
  258. async initFormWithLink() {
  259. const authId = this.$route.query.authId
  260. if (this.accessToken) {
  261. // 已登录
  262. this.step = 2
  263. this.stepList = this.stepList.filter((item) => item.id !== 1)
  264. } else {
  265. this.registerType.push(1)
  266. }
  267. await this.initClubInfo({
  268. authUserId: this.authUserId,
  269. authId: authId,
  270. })
  271. this.isRequest = false
  272. },
  273. // 初始化从正常页面进入的表单
  274. async initFormWithNormal() {
  275. if (this.accessToken) {
  276. // 已登录
  277. this.step = 2
  278. this.stepList = this.stepList.filter((item) => item.id !== 1)
  279. await this.initClubInfo({
  280. authUserId: this.authUserId,
  281. mobile: this.userInfo.mobile,
  282. })
  283. } else {
  284. // 未登录
  285. this.registerType.push(1, 2)
  286. }
  287. this.isRequest = false
  288. },
  289. // 初始化表单
  290. initPageForm() {
  291. const linkType = this.$route.query.type || 'normal'
  292. const taskMap = {
  293. link: this.initFormWithLink,
  294. normal: this.initFormWithNormal,
  295. }
  296. taskMap[linkType]()
  297. },
  298. // 判断用户手机号是否绑定机构
  299. async initClubInfo(data) {
  300. try {
  301. const res = await this.$http.api.fetchClubAuthInfo(data)
  302. if (res.data.auth) {
  303. this.autidStatus = res.data.auth.auditStatus
  304. this.authId = res.data.auth.authId
  305. } else {
  306. this.registerType.push(2)
  307. }
  308. return Promise.resolve(res)
  309. } catch (error) {
  310. console.log(error)
  311. return Promise.reject(error)
  312. }
  313. },
  314. },
  315. }
  316. </script>
  317. <style lang="scss" scoped>
  318. // pc 端
  319. @media screen and (min-width: 768px) {
  320. .page {
  321. background: #fff;
  322. }
  323. .page-top {
  324. height: 360px;
  325. @include themify($themes) {
  326. background: themed('pc-banner-register');
  327. background-size: auto 360px;
  328. }
  329. .logo {
  330. display: block;
  331. width: 120px;
  332. height: 120px;
  333. border-radius: 50%;
  334. background: #fff;
  335. }
  336. .name {
  337. font-size: 30px;
  338. color: #fff;
  339. }
  340. }
  341. .page-content {
  342. width: 1200px;
  343. margin: 0 auto;
  344. overflow: hidden;
  345. min-height: calc(100vh - 80px - 80px - 360px);
  346. box-sizing: border-box;
  347. padding-bottom: 40px;
  348. .message {
  349. display: flex;
  350. justify-content: center;
  351. align-items: center;
  352. flex-direction: column;
  353. margin-top: 60px;
  354. .status-icon {
  355. width: 88px;
  356. height: 88px;
  357. background-repeat: no-repeat;
  358. background-size: 75px auto;
  359. background-position: center;
  360. &.success {
  361. background-image: url(~assets/theme-images/common/icon-auth-primary.png);
  362. }
  363. &.warning {
  364. background-image: url(~assets/theme-images/common/icon-auth-warning.png);
  365. }
  366. &.danger {
  367. background-image: url(~assets/theme-images/common/icon-auth-danger.png);
  368. }
  369. }
  370. .status {
  371. font-size: 18px;
  372. color: #282828;
  373. margin: 12px 0;
  374. }
  375. .tip {
  376. color: #999999;
  377. font-size: 14px;
  378. }
  379. }
  380. .control {
  381. margin-top: 62px;
  382. .button {
  383. width: 295px;
  384. height: 50px;
  385. border-radius: 4px;
  386. cursor: pointer;
  387. &.prev {
  388. @include themify($themes) {
  389. border: 1px solid themed('color');
  390. color: themed('color');
  391. }
  392. }
  393. &.next {
  394. @include themify($themes) {
  395. background-color: themed('color');
  396. color: #fff;
  397. }
  398. }
  399. }
  400. .record {
  401. font-size: 14px;
  402. cursor: pointer;
  403. @include themify($themes) {
  404. color: themed('color');
  405. }
  406. }
  407. }
  408. .step-list {
  409. width: 700px;
  410. margin: 0 auto;
  411. }
  412. }
  413. }
  414. // 移动端
  415. @media screen and (max-width: 768px) {
  416. .page {
  417. background: #fff;
  418. }
  419. .page-top {
  420. height: 46vw;
  421. @include themify($themes) {
  422. background: themed('h5-banner-register');
  423. background-size: auto 46vw;
  424. }
  425. .logo {
  426. display: block;
  427. width: 14.8vw;
  428. height: 14.8vw;
  429. border-radius: 50%;
  430. background: #fff;
  431. }
  432. .name {
  433. font-size: 4vw;
  434. color: #fff;
  435. }
  436. }
  437. .page-content {
  438. padding: 0 7vw 7vw;
  439. .message {
  440. display: flex;
  441. justify-content: center;
  442. align-items: center;
  443. flex-direction: column;
  444. margin: 22.8vw 0;
  445. .status-icon {
  446. width: 23.6vw;
  447. height: 23.6vw;
  448. background-repeat: no-repeat;
  449. background-size: 20vw auto;
  450. background-position: center;
  451. &.success {
  452. background-image: url(~assets/theme-images/common/icon-auth-primary.png);
  453. }
  454. &.warning {
  455. background-image: url(~assets/theme-images/common/icon-auth-warning.png);
  456. }
  457. &.danger {
  458. background-image: url(~assets/theme-images/common/icon-auth-danger.png);
  459. }
  460. }
  461. .status {
  462. font-size: 4.2vw;
  463. color: #282828;
  464. margin: 3.2vw 0 2.4vw;
  465. }
  466. .tip {
  467. color: #999999;
  468. font-size: 3.2vw;
  469. }
  470. }
  471. .control {
  472. .button {
  473. width: 85.6vw;
  474. height: 12vw;
  475. border-radius: 4px;
  476. cursor: pointer;
  477. &.prev {
  478. @include themify($themes) {
  479. border: 1px solid themed('color');
  480. color: themed('color');
  481. }
  482. }
  483. &.next {
  484. @include themify($themes) {
  485. background-color: themed('color');
  486. color: #fff;
  487. }
  488. }
  489. }
  490. .record {
  491. margin-top: 4.8vw;
  492. font-size: 3.4vw;
  493. cursor: pointer;
  494. @include themify($themes) {
  495. color: themed('color');
  496. }
  497. }
  498. }
  499. }
  500. }
  501. </style>