index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="container">
  3. <view class="container-title u-font-40">diboot-workflow mobile-UI</view>
  4. <view class="u-m-b-60 container-type u-flex">
  5. <view v-for="(item,index) in typeList" :key="item.name">
  6. <text :class="{'u-font-40': item.value === currentType}"
  7. @click="currentType = item.value">{{item.name}}</text>
  8. <text class="u-m-l-10 u-m-r-10" v-if="index !== typeList.length - 1">/</text>
  9. </view>
  10. </view>
  11. <view>
  12. <login-form v-if="currentType === 'login'" @login="login" @signUp="currentType = 'register'"></login-form>
  13. <register-form v-if="currentType === 'register'" @register="register" @signIn="currentType = 'login'">
  14. </register-form>
  15. </view>
  16. <view class="u-m-t-80 ">
  17. <u-divider margin-bottom="40">其他方式登陆</u-divider>
  18. <view class="u-flex u-row-center">
  19. <u-icon @click="weiLogin" size="90" name="weixin-circle-fill" color="rgb(83,194,64)"></u-icon>
  20. </view>
  21. </view>
  22. <u-top-tips ref="uTips" navbar-height="0"/>
  23. </view>
  24. </template>
  25. <script>
  26. import loginForm from './loginForm.vue'
  27. import registerForm from './registerForm.vue'
  28. export default {
  29. components: {
  30. loginForm,
  31. registerForm
  32. },
  33. data() {
  34. return {
  35. typeList: [{
  36. name: '登录',
  37. value: 'login'
  38. },
  39. {
  40. name: '注册',
  41. value: 'register'
  42. }
  43. ],
  44. currentType: ''
  45. }
  46. },
  47. onShow() {
  48. if(uni.getStorageSync("authtoken")) {
  49. uni.switchTab({
  50. url: '/pages/home/home'
  51. })
  52. }
  53. },
  54. onLoad() {
  55. this.currentType = 'login'
  56. },
  57. methods: {
  58. /**
  59. * 注册
  60. */
  61. register(data) {
  62. // 注册逻辑
  63. this.$tip(this.$refs.uTips, '注册成功,请重新登陆').then(() => {
  64. this.currentType = 'login'
  65. })
  66. },
  67. /**
  68. * 登陆成功
  69. */
  70. login(data) {
  71. // 密码登陆
  72. this.$pwdLogin
  73. // .setTip(this.$refs.uTips)
  74. .go(data)
  75. .then(() => {
  76. // 跳转到首页
  77. uni.switchTab({
  78. url: '/pages/home/home'
  79. })
  80. })
  81. },
  82. /**
  83. * 微信登陆:
  84. */
  85. weiLogin() {
  86. // 小程序登陆
  87. // #ifdef MP-WEIXIN
  88. this.$miniLogin.setTip(this.$refs.uTips).setBindWx(false).setUrlPath('/pages/home/home').go()
  89. //#endif
  90. // 微信公众号登陆
  91. // #ifdef H5
  92. this.$mpLogin.redirect()
  93. //#endif
  94. }
  95. }
  96. }
  97. </script>
  98. <style scoped lang="scss">
  99. .container {
  100. padding: 160rpx 24rpx 40rpx;
  101. background-image: url('https://dibootm.oss-cn-shanghai.aliyuncs.com/login_bg3.png'),
  102. url('https://dibootm.oss-cn-shanghai.aliyuncs.com/login_bg3.png'),
  103. url('https://dibootm.oss-cn-shanghai.aliyuncs.com/login_bg3.png'),
  104. linear-gradient($u-type-success-dark 0rpx, $u-type-success-light 400rpx, rgba(255, 255, 255, 0) 500rpx);
  105. background-position: -360rpx 250rpx, -120rpx 250rpx, 0 250rpx, 0 0;
  106. background-repeat: no-repeat;
  107. background-size: 115% 500rpx;
  108. &-title {
  109. text-align: center;
  110. margin-bottom: 160rpx;
  111. font-weight: bold;
  112. color: #fff;
  113. }
  114. &-type {
  115. font-weight: bold;
  116. }
  117. }
  118. </style>