login.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view class="container">
  3. <view class="logo"><image src="https://wx.fujinyangche.com/nvrnetwork/images/accredit_logo.png"></image></view>
  4. <!-- 横线 -->
  5. <view class="line"></view>
  6. <view class="title">申请获取以下权限</view>
  7. <view class="title title1">您暂未授权附近养车网获取你的信息,将无法正常使用小程序的功能,如需要正常使用,请点击"授权按钮",打开头像昵称等信息的授权</view>
  8. <button class="login" open-type="getUserInfo" @getuserinfo="getUserInfo">授权登录</button>
  9. <view class="no_login" @tap="navBack">取消</view>
  10. </view>
  11. </template>
  12. <script>
  13. let app = getApp();
  14. export default {
  15. data() {
  16. return {
  17. params:'',//接收路径传递过来的参数
  18. }
  19. },
  20. onLoad(options) {
  21. console.log(options);
  22. this.params = options.params;
  23. },
  24. methods: {
  25. //授权登陆
  26. getUserInfo(e){
  27. app.globalData.userInfo = e.detail.userInfo;
  28. uni.setStorageSync('userInfo',e.detail.userInfo);
  29. let pages = getCurrentPages(); //获取当前页面信息栈
  30. // let beforePage = pages[pages.length - 2];
  31. uni.login({
  32. success: (res) => {
  33. uni.request({
  34. url:'http://192.168.3.136/nvrnetwork/user',
  35. data:{
  36. code:res.code,
  37. nickName:e.detail.userInfo.nickName,
  38. img:e.detail.userInfo.avatarUrl
  39. },
  40. success: (res) => {
  41. console.log(res);
  42. let token = res.data.data.data;
  43. app.globalData.token = token;
  44. uni.setStorageSync('token',token);
  45. if(pages[0].route == 'pages/packageOne/service/serviceView/serviceView'){ //说明是从首页跳转过来
  46. uni.reLaunch({
  47. url:"/pages/packageOne/service/serviceView/serviceView?index=" + this.params
  48. })
  49. }else{
  50. uni.navigateBack({
  51. delta:1
  52. })
  53. }
  54. }
  55. })
  56. }
  57. })
  58. }
  59. }
  60. }
  61. </script>
  62. <style>
  63. .container {
  64. height: 100%;
  65. display: flex;
  66. flex-direction: column;
  67. align-items: center;
  68. justify-content: space-between;
  69. padding: 200rpx 0;
  70. box-sizing: border-box;
  71. overflow: hidden;
  72. }
  73. .logo{
  74. width:138rpx;
  75. height:138rpx;
  76. }
  77. .logo image{
  78. display: block;
  79. width:100%;
  80. height:100%;
  81. }
  82. .line{
  83. width:80%;
  84. height:2rpx;
  85. background-color: #000000;
  86. margin-top:100rpx;
  87. }
  88. .title{
  89. width:80%;
  90. color:#333333;
  91. font-size: 24rpx;
  92. text-align: left;
  93. margin-top:60rpx;
  94. }
  95. .title1{
  96. margin-top:10rpx;
  97. }
  98. .login{
  99. width: 574rpx;
  100. height: 74rpx;
  101. background:linear-gradient(270deg,rgba(254,107,21,1) 0%,rgba(254,163,48,1) 100%);
  102. text-align: center;
  103. line-height: 74rpx;
  104. color:#ffffff;
  105. font-size: 26rpx;
  106. border-radius: 56rpx;
  107. margin-top:100rpx;
  108. }
  109. .no_login{
  110. width: 574rpx;
  111. height: 74rpx;
  112. background-color: #ffffff;
  113. color:#E77817;
  114. text-align: center;
  115. line-height: 74rpx;
  116. font-size: 26rpx;
  117. border-radius: 56rpx;
  118. margin-top:40rpx;
  119. border:1px solid rgba(231,120,23,1);
  120. }
  121. </style>