club-register.vue 13 KB

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