authorize.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="container">
  3. <u-cell-group :border="false">
  4. <u-cell-item title="未注册" value="点击注册" @click="goToRegister()" v-if="!haveAuthorizeCode"></u-cell-item>
  5. <u-cell-item title="是否拥有授权码" :arrow="false">
  6. <u-switch v-model="haveAuthorizeCode" active-color="#51A539"></u-switch>
  7. </u-cell-item>
  8. <u-field label="授权码" placeholder="请输入授权码" v-model="authorizeCode" v-if="haveAuthorizeCode"></u-field>
  9. </u-cell-group>
  10. <view class="form-handle" v-if="haveAuthorizeCode">
  11. <u-button type="success" shape="circle" :ripple="true" @click="goToSignIn" class="handle-custom" :disabled="!authorizeCode">登录</u-button>
  12. </view>
  13. <u-top-tips ref="uTips"></u-top-tips>
  14. </view>
  15. </template>
  16. <script>
  17. const NET = require('@/utils/request')
  18. const API = require('@/config/api')
  19. export default {
  20. data() {
  21. return {
  22. haveAuthorizeCode: false,
  23. authorizeCode: '',
  24. }
  25. },
  26. onLoad() {},
  27. methods: {
  28. // 注册
  29. goToRegister() {
  30. uni.navigateTo({
  31. url: '/pages/index/register?type=add'
  32. });
  33. },
  34. // 登录
  35. goToSignIn() {
  36. NET.request(API.authorizeSignIn, {authCode: this.authorizeCode}, 'GET').then(res => {
  37. this.$refs.uTips.show({
  38. title: '授权码登录成功,请重新登录',
  39. type: 'success',
  40. })
  41. setTimeout(() => {
  42. // uni.switchTab({
  43. // url: '/pages/index/index'
  44. // });
  45. uni.navigateTo({
  46. url: '/pages/index/index'
  47. });
  48. }, 2000)
  49. }).catch(res => {
  50. this.$refs.uTips.show({
  51. title: '授权码登录失败',
  52. type: 'warning',
  53. })
  54. })
  55. },
  56. },
  57. }
  58. </script>
  59. <style lang="less" scoped>
  60. page {
  61. width: 100%;
  62. height: 100%;
  63. }
  64. .container {
  65. width: 100%;
  66. height: 100%;
  67. float: left;
  68. box-sizing: border-box;
  69. padding-bottom: 70px;
  70. overflow-y: auto;
  71. .form-handle {
  72. width: calc(100% - 30px);
  73. height: 40px;
  74. position: fixed;
  75. bottom: 20px;
  76. left: 15px;
  77. .handle-custom {
  78. background-color: #51A539;
  79. /deep/button {
  80. background-color: #56a83a;
  81. }
  82. /deep/.u-btn--success--disabled {
  83. background-color: #74bd60 !important;
  84. }
  85. }
  86. /deep/.u-btn--success--disabled {
  87. background-color: #999999 !important;
  88. }
  89. }
  90. }
  91. </style>