index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="login-main">
  3. <view class="login-main-content">
  4. <image class="img" src="../../static/images/logo.png" mode=""></image>
  5. </view>
  6. <view class="login-contont">
  7. <view class="login-contont-info">
  8. <h5>请确认以下信息并授权登录</h5>
  9. <view class="text">获取您的信息(你的头像、信息等)</view>
  10. </view>
  11. <view class="login-contont-button">
  12. <button class="btn" @click="login">授权登录</button>
  13. </view>
  14. <view class="radio">
  15. <u-radio-group v-model="radiovalue">
  16. <u-radio value="1" size="30" name="1" iconSize="25">
  17. <text class="radioText">授权同意《用户服务协议》 和《隐私协议》</text></u-radio>
  18. </u-radio-group>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. requestConfig
  26. } from "@/app.config.js";
  27. export default {
  28. data() {
  29. return {
  30. radiovalue: 0,
  31. shopId: ""
  32. };
  33. },
  34. onLoad(options) {
  35. this.shopId = options.shopId;
  36. // console.log(this.GetQueryString('shopId'));
  37. // this.shopId = this.GetQueryString('shopId')
  38. },
  39. methods: {
  40. GetQueryString(name) {
  41. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  42. var r = window.location.search.substr(1).match(reg);
  43. if (r != null) return unescape(r[2]);
  44. return null;
  45. },
  46. login() {
  47. console.log(this.radiovalue);
  48. if (this.radiovalue == 1) {
  49. // ne.sxdirectpurchase.com
  50. //地址进行编码,微信官方强制要求编码
  51. let redirect_uri = encodeURIComponent(requestConfig.redirect_uri + '?shopId=' + this.shopId)
  52. console.log(redirect_uri);
  53. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?
  54. appid=${requestConfig.appid}
  55. &redirect_uri=${redirect_uri}
  56. &response_type=code
  57. &scope=snsapi_userinfo
  58. &state=STATE
  59. #wechat_redirect`;
  60. window.location = url;
  61. } else {
  62. uni.$u.toast('请先同意用户授权!');
  63. }
  64. },
  65. },
  66. };
  67. </script>
  68. <style scoped lang="scss">
  69. .u-radio-group--row {
  70. justify-content: center;
  71. }
  72. .radioText {
  73. font-weight: 500;
  74. font-size: 24rpx;
  75. color: #999999;
  76. line-height: 34rpx;
  77. text-align: left;
  78. font-style: normal;
  79. }
  80. .login-main {
  81. background: url("../../static/images/back.png") no-repeat;
  82. background-size: 100% 100%;
  83. width: 100%;
  84. display: flex;
  85. flex-direction: column;
  86. justify-content: space-between;
  87. align-items: center;
  88. height: 100vh;
  89. }
  90. .login-contont-button {
  91. .btn {
  92. margin-top: 20px;
  93. width: 90%;
  94. height: 90rpx;
  95. background: linear-gradient(275deg, #01cf6c 0%, #07e278 100%);
  96. border-radius: 44rpx;
  97. color: #fff;
  98. }
  99. }
  100. .login-contont {
  101. width: 100%;
  102. height: 50%;
  103. .login-contont-info {
  104. text-align: center;
  105. .text {
  106. margin-top: 10px;
  107. font-weight: 500;
  108. font-size: 28rpx;
  109. color: #999999;
  110. line-height: 40rpx;
  111. font-style: normal;
  112. }
  113. }
  114. }
  115. .radio {
  116. text-align: center;
  117. margin-top: 10px;
  118. }
  119. .login-main-content {
  120. text-align: center;
  121. padding-top: 100px;
  122. width: 100%;
  123. height: 50%;
  124. .img {
  125. width: 100px;
  126. height: 130px;
  127. }
  128. }
  129. </style>