authorization.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. //根据页面参数跳转相应的页面
  38. switch(this.authorizeType){
  39. case '1':
  40. this.$api.switchTabTo('/pages/tabBar/home/home')
  41. break;
  42. case '2':
  43. this.$api.navigateTo('/market/pages/login/login')
  44. break;
  45. case '3':
  46. this.$api.navigateTo('/pages/login/bindOperator')
  47. break;
  48. }
  49. }
  50. });
  51. })
  52. },
  53. }
  54. }
  55. </script>
  56. <style lang="scss">
  57. .login{
  58. width: 100%;
  59. height: auto;
  60. .model-warp.none{
  61. display: none;
  62. }
  63. .model-warp.show{
  64. display: block;
  65. }
  66. .login-main{
  67. width: 100%;
  68. display: flex;
  69. flex-direction: column;
  70. align-items: center;
  71. height: auto;
  72. padding:200rpx 0 0 0;
  73. .logo{
  74. width: 276rpx;
  75. height: 236rpx;
  76. display: block;
  77. }
  78. .logo-text{
  79. font-size: $font-size-44;
  80. line-height: 44rpx;
  81. color: $color-system;
  82. margin-top: 44rpx;
  83. }
  84. }
  85. .login-input{
  86. width: 654rpx;
  87. height: 40rpx;
  88. padding: 24rpx;
  89. margin: 0 auto;
  90. margin-bottom: 60rpx;
  91. background: #F7F7F7;
  92. border-radius: 14rpx;
  93. .input{
  94. width: 100%;
  95. height: 100%;
  96. background: #F7F7F7;
  97. font-size: $font-size-28;
  98. line-height: 40rpx;
  99. color: #333333;
  100. border-radius: 14rpx;
  101. }
  102. }
  103. .login-btn{
  104. width: 702rpx;
  105. height: 88rpx;
  106. border-radius: 14rpx;
  107. font-size: $font-size-28;
  108. line-height: 88rpx;
  109. color: #FFFFFF;
  110. text-align: center;
  111. background: linear-gradient(135deg,rgba(8,162,103,1) 0%,rgba(5,183,115,1) 100%);
  112. margin: 0 auto;
  113. margin-top: 400rpx;
  114. }
  115. }
  116. </style>