club-register.vue 12 KB

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