authorize.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. }, 2000)
  46. }).catch(res => {
  47. this.$refs.uTips.show({
  48. title: '授权码登录失败',
  49. type: 'warning',
  50. })
  51. })
  52. },
  53. },
  54. }
  55. </script>
  56. <style lang="less" scoped>
  57. page {
  58. width: 100%;
  59. height: 100%;
  60. }
  61. .container {
  62. width: 100%;
  63. height: 100%;
  64. float: left;
  65. box-sizing: border-box;
  66. padding-bottom: 70px;
  67. overflow-y: auto;
  68. .form-handle {
  69. width: calc(100% - 30px);
  70. height: 40px;
  71. position: fixed;
  72. bottom: 20px;
  73. left: 15px;
  74. .handle-custom {
  75. background-color: #51A539;
  76. /deep/button {
  77. background-color: #56a83a;
  78. }
  79. /deep/.u-btn--success--disabled {
  80. background-color: #74bd60 !important;
  81. }
  82. }
  83. /deep/.u-btn--success--disabled {
  84. background-color: #999999 !important;
  85. }
  86. }
  87. }
  88. </style>