authorization.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view class="container login">
  3. <view class="login-main">
  4. <image class="logo" src="../../static/login-logo@3x.png" mode=""></image>
  5. <text class="logo-text">生美/医美采购服务平台</text>
  6. </view>
  7. <button class="login-btn" type="primary" size="small" open-type="getUserInfo" lang="zh_CN" @getuserinfo="getuserinfo">微信授权</button>
  8. </view>
  9. </template>
  10. <script>
  11. import {mapState,mapMutations } from 'vuex';
  12. import authorize from '@/common/config/authorize.js'
  13. export default{
  14. data() {
  15. return{
  16. }
  17. },
  18. onLoad() {
  19. },
  20. methods:{
  21. ...mapMutations(['wxLogin']),
  22. //授权登录
  23. getuserinfo: function (e) {
  24. if (e.detail.userInfo) {
  25. this.wxGetUserInfo()
  26. }else{
  27. this.$util.msg('授权失败',2000)
  28. }
  29. },
  30. wxGetUserInfo(){
  31. authorize.getCode('weixin').then(wechatcode =>{
  32. wx.getUserInfo({
  33. success: res => {
  34. uni.switchTab({
  35. url:'/pages/tabBar/home/home'
  36. })
  37. }
  38. });
  39. })
  40. },
  41. }
  42. }
  43. </script>
  44. <style lang="scss">
  45. .login{
  46. width: 100%;
  47. height: auto;
  48. .model-warp.none{
  49. display: none;
  50. }
  51. .model-warp.show{
  52. display: block;
  53. }
  54. .login-main{
  55. width: 100%;
  56. display: flex;
  57. flex-direction: column;
  58. align-items: center;
  59. height: auto;
  60. padding:200rpx 0 0 0;
  61. .logo{
  62. width: 276rpx;
  63. height: 236rpx;
  64. display: block;
  65. }
  66. .logo-text{
  67. font-size: $font-size-44;
  68. line-height: 44rpx;
  69. color: $color-system;
  70. margin-top: 44rpx;
  71. }
  72. }
  73. .login-input{
  74. width: 654rpx;
  75. height: 40rpx;
  76. padding: 24rpx;
  77. margin: 0 auto;
  78. margin-bottom: 60rpx;
  79. background: #F7F7F7;
  80. border-radius: 14rpx;
  81. .input{
  82. width: 100%;
  83. height: 100%;
  84. background: #F7F7F7;
  85. font-size: $font-size-28;
  86. line-height: 40rpx;
  87. color: #333333;
  88. border-radius: 14rpx;
  89. }
  90. }
  91. .login-btn{
  92. width: 702rpx;
  93. height: 88rpx;
  94. border-radius: 14rpx;
  95. font-size: $font-size-28;
  96. line-height: 88rpx;
  97. color: #FFFFFF;
  98. text-align: center;
  99. background: linear-gradient(135deg,rgba(8,162,103,1) 0%,rgba(5,183,115,1) 100%);
  100. margin: 0 auto;
  101. margin-top: 400rpx;
  102. }
  103. }
  104. </style>