authorization.vue 2.5 KB

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