club-register.vue 12 KB

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