bind.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <div id="bind">
  3. <el-row>
  4. <el-col :span="24" class="info">
  5. <el-col :span="24" class="top">
  6. <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
  7. </el-col>
  8. <el-col :span="24" class="mess" style="padding-top:10vh;">
  9. <writeStu :form="form" @onSubmit="onSubmit"></writeStu>
  10. </el-col>
  11. </el-col>
  12. </el-row>
  13. </div>
  14. </template>
  15. <script>
  16. import NavBar from '@/layout/common/topInfo.vue';
  17. import writeStu from '@/layout/common/writeStu.vue';
  18. import Vue from 'vue';
  19. import _ from 'lodash';
  20. import { mapState, createNamespacedHelpers } from 'vuex';
  21. const { mapActions } = createNamespacedHelpers('login');
  22. export default {
  23. metaInfo: { title: '学生注册' },
  24. name: 'bind',
  25. props: {},
  26. components: {
  27. NavBar, //底部信息
  28. writeStu, //填写学生绑定信息
  29. },
  30. data: () => ({
  31. form: {},
  32. title: '填写信息',
  33. isleftarrow: '',
  34. transitionName: 'fade',
  35. navShow: true,
  36. }),
  37. created() {},
  38. computed: {
  39. openid() {
  40. return this.$route.query.openid;
  41. },
  42. },
  43. methods: {
  44. ...mapActions(['login', 'bind']),
  45. async onSubmit(form) {
  46. form.openid = this.openid;
  47. let res = await this.bind(form);
  48. if (res.errcode === 0) {
  49. this.$notify({
  50. message: '绑定成功',
  51. type: 'success',
  52. });
  53. sessionStorage.setItem('user', JSON.stringify(res.data));
  54. window.history.replaceState({}, '首页', `${Vue.config.weixin.baseUrl}/api/train/auth?redirect_uri=${Vue.config.weixin.target}/login&type=0`);
  55. } else {
  56. this.$notify({
  57. message: res.errmsg,
  58. type: 'danger',
  59. });
  60. }
  61. },
  62. },
  63. };
  64. </script>
  65. <style lang="less" scoped></style>