authorization.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. authorizeType:''
  17. }
  18. },
  19. onLoad(option) {
  20. this.authorizeType = option.type
  21. console.log(this.authorizeType)
  22. },
  23. methods:{
  24. ...mapMutations(['wxLogin']),
  25. //授权登录
  26. getuserinfo: function (e) {
  27. if (e.detail.userInfo) {
  28. this.wxGetUserInfo()
  29. }else{
  30. this.$util.msg('授权失败',2000)
  31. }
  32. },
  33. wxGetUserInfo(){
  34. authorize.getCode('weixin').then(wechatcode =>{
  35. wx.getUserInfo({
  36. success: res => {
  37. if(this.authorizeType == 'seller'){
  38. this.$api.navigateTo('/market/pages/login/login')
  39. }else{
  40. uni.switchTab({
  41. url:'/pages/tabBar/home/home'
  42. })
  43. }
  44. }
  45. });
  46. })
  47. },
  48. }
  49. }
  50. </script>
  51. <style lang="scss">
  52. .login{
  53. width: 100%;
  54. height: auto;
  55. .model-warp.none{
  56. display: none;
  57. }
  58. .model-warp.show{
  59. display: block;
  60. }
  61. .login-main{
  62. width: 100%;
  63. display: flex;
  64. flex-direction: column;
  65. align-items: center;
  66. height: auto;
  67. padding:200rpx 0 0 0;
  68. .logo{
  69. width: 276rpx;
  70. height: 236rpx;
  71. display: block;
  72. }
  73. .logo-text{
  74. font-size: $font-size-44;
  75. line-height: 44rpx;
  76. color: $color-system;
  77. margin-top: 44rpx;
  78. }
  79. }
  80. .login-input{
  81. width: 654rpx;
  82. height: 40rpx;
  83. padding: 24rpx;
  84. margin: 0 auto;
  85. margin-bottom: 60rpx;
  86. background: #F7F7F7;
  87. border-radius: 14rpx;
  88. .input{
  89. width: 100%;
  90. height: 100%;
  91. background: #F7F7F7;
  92. font-size: $font-size-28;
  93. line-height: 40rpx;
  94. color: #333333;
  95. border-radius: 14rpx;
  96. }
  97. }
  98. .login-btn{
  99. width: 702rpx;
  100. height: 88rpx;
  101. border-radius: 14rpx;
  102. font-size: $font-size-28;
  103. line-height: 88rpx;
  104. color: #FFFFFF;
  105. text-align: center;
  106. background: linear-gradient(135deg,rgba(8,162,103,1) 0%,rgba(5,183,115,1) 100%);
  107. margin: 0 auto;
  108. margin-top: 400rpx;
  109. }
  110. }
  111. </style>