club-register.vue 12 KB

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