club-register.vue 11 KB

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