club-register.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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. 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. methods: {
  173. onConfirm() {
  174. this.$router.push(this.routePrefix)
  175. },
  176. async onNextStep() {
  177. const validateAction = {
  178. 1: this.$refs.userForm?.validate,
  179. 2: this.$refs.clubInfoForm?.validate,
  180. 3: this.$refs.clubDeviceForm?.validate,
  181. }
  182. try {
  183. // 表单校验
  184. validateAction[this.step] && (await validateAction[this.step]())
  185. // 提交
  186. if (this.step === 3) {
  187. this.onSubmit()
  188. }
  189. // 下一步
  190. if (this.step < 3) {
  191. this.step++
  192. }
  193. } catch (error) {
  194. console.log(error)
  195. }
  196. console.log('userForm', this.clubUserInfo)
  197. },
  198. onPrevStep() {
  199. this.step > 1 && this.step--
  200. },
  201. async onSubmit() {
  202. const params = {
  203. registerType: this.registerType.join(','),
  204. authUserId: this.authUserId,
  205. authId: this.authId,
  206. clubUserId: this.clubUserId,
  207. clubUserInfo: this.clubUserInfo,
  208. authInfo: this.authInfo,
  209. productInfo: this.productInfo,
  210. }
  211. console.log(params)
  212. try {
  213. const res = await this.$http.api.clubUserRegisterAll(params)
  214. console.log(res)
  215. this.$router.push(`${this.routePrefix}/record/message`)
  216. } catch (error) {
  217. console.log(error)
  218. this.$toast(error.msg)
  219. }
  220. },
  221. onUserFormStep(data) {
  222. console.log(data)
  223. this.clubUserInfo = data
  224. },
  225. onClubInfoFormStep(data) {
  226. console.log(data)
  227. this.authInfo = data
  228. },
  229. onclubDeviceFormStep(data) {
  230. console.log(data)
  231. this.productInfo = data
  232. },
  233. toRecord() {
  234. if (!this.accessToken) {
  235. this.$toast('请登录后查看')
  236. setTimeout(() => {
  237. this.$router.push(`${this.routePrefix}`)
  238. }, 1500)
  239. return
  240. }
  241. this.$router.push(`${this.routePrefix}/record/club/detail`)
  242. },
  243. // 初始化从页面进入的表单
  244. async initFormWithLink() {
  245. const authId = this.$route.query.authId
  246. if (this.accessToken) {
  247. // 已登录
  248. this.step = 2
  249. this.stepList = this.stepList.filter((item) => item.id !== 1)
  250. } else {
  251. this.registerType.push(1)
  252. }
  253. await this.initClubInfo({
  254. authUserId: this.authUserId,
  255. authId: authId,
  256. })
  257. this.isRequest = false
  258. },
  259. // 初始化从正常页面进入的表单
  260. async initFormWithNormal() {
  261. if (this.accessToken) {
  262. // 已登录
  263. this.step = 2
  264. this.stepList = this.stepList.filter((item) => item.id !== 1)
  265. await this.initClubInfo({
  266. authUserId: this.authUserId,
  267. mobile: this.userInfo.mobile,
  268. })
  269. } else {
  270. // 未登录
  271. this.registerType.push(1, 2)
  272. }
  273. this.isRequest = false
  274. },
  275. // 初始化表单
  276. initPageForm() {
  277. const linkType = this.$route.query.type || 'normal'
  278. const taskMap = {
  279. link: this.initFormWithLink,
  280. normal: this.initFormWithNormal,
  281. }
  282. taskMap[linkType]()
  283. },
  284. // 判断用户手机号是否绑定机构
  285. async initClubInfo(data) {
  286. try {
  287. const res = await this.$http.api.fetchClubAuthInfo(data)
  288. if (res.data.auth) {
  289. this.autidStatus = res.data.auth.auditStatus
  290. this.authId = res.data.auth.authId
  291. } else {
  292. this.registerType.push(2)
  293. }
  294. return Promise.resolve(res)
  295. } catch (error) {
  296. console.log(error)
  297. return Promise.reject(error)
  298. }
  299. },
  300. },
  301. }
  302. </script>
  303. <style lang="scss" scoped>
  304. // pc 端
  305. @media screen and (min-width: 768px) {
  306. .page {
  307. background: #fff;
  308. }
  309. .page-top {
  310. height: 360px;
  311. @include themify($themes) {
  312. background: themed('pc-banner-register');
  313. background-size: auto 360px;
  314. }
  315. .logo {
  316. display: block;
  317. width: 120px;
  318. height: 120px;
  319. border-radius: 50%;
  320. background: #fff;
  321. }
  322. .name {
  323. font-size: 30px;
  324. color: #fff;
  325. }
  326. }
  327. .page-content {
  328. width: 1200px;
  329. margin: 0 auto;
  330. overflow: hidden;
  331. min-height: calc(100vh - 80px - 80px - 360px);
  332. box-sizing: border-box;
  333. padding-bottom: 40px;
  334. .message {
  335. display: flex;
  336. justify-content: center;
  337. align-items: center;
  338. flex-direction: column;
  339. margin-top: 60px;
  340. .status-icon {
  341. width: 88px;
  342. height: 88px;
  343. background-repeat: no-repeat;
  344. background-size: 75px auto;
  345. background-position: center;
  346. &.success {
  347. background-image: url(~assets/theme-images/common/icon-auth-primary.png);
  348. }
  349. &.warning {
  350. background-image: url(~assets/theme-images/common/icon-auth-warning.png);
  351. }
  352. &.danger {
  353. background-image: url(~assets/theme-images/common/icon-auth-danger.png);
  354. }
  355. }
  356. .status {
  357. font-size: 18px;
  358. color: #282828;
  359. margin: 12px 0;
  360. }
  361. .tip {
  362. color: #999999;
  363. font-size: 14px;
  364. }
  365. }
  366. .control {
  367. margin-top: 62px;
  368. .button {
  369. width: 295px;
  370. height: 50px;
  371. border-radius: 4px;
  372. cursor: pointer;
  373. &.prev {
  374. @include themify($themes) {
  375. border: 1px solid themed('color');
  376. color: themed('color');
  377. }
  378. }
  379. &.next {
  380. @include themify($themes) {
  381. background-color: themed('color');
  382. color: #fff;
  383. }
  384. }
  385. }
  386. .record {
  387. font-size: 14px;
  388. cursor: pointer;
  389. @include themify($themes) {
  390. color: themed('color');
  391. }
  392. }
  393. }
  394. .step-list {
  395. width: 700px;
  396. margin: 0 auto;
  397. }
  398. }
  399. }
  400. // 移动端
  401. @media screen and (max-width: 768px) {
  402. .page {
  403. background: #fff;
  404. }
  405. .page-top {
  406. height: 46vw;
  407. @include themify($themes) {
  408. background: themed('h5-banner-register');
  409. background-size: auto 46vw;
  410. }
  411. .logo {
  412. display: block;
  413. width: 14.8vw;
  414. height: 14.8vw;
  415. border-radius: 50%;
  416. background: #fff;
  417. }
  418. .name {
  419. font-size: 4vw;
  420. color: #fff;
  421. }
  422. }
  423. .page-content {
  424. padding: 0 7vw 7vw;
  425. .message {
  426. display: flex;
  427. justify-content: center;
  428. align-items: center;
  429. flex-direction: column;
  430. margin: 22.8vw 0;
  431. .status-icon {
  432. width: 23.6vw;
  433. height: 23.6vw;
  434. background-repeat: no-repeat;
  435. background-size: 20vw auto;
  436. background-position: center;
  437. &.success {
  438. background-image: url(~assets/theme-images/common/icon-auth-primary.png);
  439. }
  440. &.warning {
  441. background-image: url(~assets/theme-images/common/icon-auth-warning.png);
  442. }
  443. &.danger {
  444. background-image: url(~assets/theme-images/common/icon-auth-danger.png);
  445. }
  446. }
  447. .status {
  448. font-size: 4.2vw;
  449. color: #282828;
  450. margin: 3.2vw 0 2.4vw;
  451. }
  452. .tip {
  453. color: #999999;
  454. font-size: 3.2vw;
  455. }
  456. }
  457. .control {
  458. .button {
  459. width: 85.6vw;
  460. height: 12vw;
  461. border-radius: 4px;
  462. cursor: pointer;
  463. &.prev {
  464. @include themify($themes) {
  465. border: 1px solid themed('color');
  466. color: themed('color');
  467. }
  468. }
  469. &.next {
  470. @include themify($themes) {
  471. background-color: themed('color');
  472. color: #fff;
  473. }
  474. }
  475. }
  476. .record {
  477. margin-top: 4.8vw;
  478. font-size: 3.4vw;
  479. cursor: pointer;
  480. @include themify($themes) {
  481. color: themed('color');
  482. }
  483. }
  484. }
  485. }
  486. }
  487. </style>