club-register.vue 9.7 KB

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