index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div class="mianBox">
  3. <van-row class="contentBox">
  4. <van-row>
  5. <van-col span="24" class="logo"><van-image width="75" height="75" :src="require('../img/logo.png')" /></van-col>
  6. <van-col span="24" class="authorized_app">申请获取以下权限</van-col>
  7. <van-col span="24" class="authorized_text">获取你的昵称、头像、地区及性别</br>
  8. (用于园区内一卡通余额充值)</van-col>
  9. </van-row>
  10. <div class="authorize_wrap">
  11. <van-button class="authorize authorize_y" color="#F22E3C" open-type="getUserInfo" lang="zh_CN" @getuserinfo="checkLogin" >授权登录</van-button>
  12. </div>
  13. <van-toast id="van-toast" />
  14. </van-row>
  15. </div>
  16. </template>
  17. <script>
  18. // import { login } from '@/utils/api/login.js';
  19. // import { wxCode } from '@/utils/api/modules/index.js'
  20. import Toast from '../../wxcomponents/vant/weapp/dist/toast/toast';
  21. export default {
  22. data() {
  23. return {
  24. data:{
  25. money:undefined,
  26. openid:undefined,
  27. },
  28. }
  29. },
  30. onLoad(options) {
  31. let _this = this
  32. // money=${this.money}&scene=3&userId=${localStorage.getItem("user_wt")}&channelId=null&openid=null
  33. let data = JSON.parse(options.params)
  34. _this.data = data
  35. },
  36. methods: {
  37. checkLogin(e){
  38. let _this = this
  39. if(e.detail.userInfo) {
  40. uni.login({
  41. success: function(res) {
  42. if(res.code){
  43. uni.setStorage({
  44. key: 'code',
  45. data: res.code,
  46. })
  47. }
  48. uni.request({
  49. // url: `http://172.16.120.104:8085/wxLogin?jsCode=${res.code}`,
  50. url: `https://smartpark.caih.com/dxapi/wxLogin?jsCode=${res.code}`,
  51. method: 'GET',
  52. // header: {
  53. // 'content-type': 'application/x-www-form-urlencoded'
  54. // },
  55. success: function (res2) {
  56. uni.setStorage({
  57. key: 'openid',
  58. data: res2.data.data,
  59. success: function () {
  60. _this.data.openid= res2.data.data
  61. uni.navigateTo({
  62. url: `../order/index?params=${JSON.stringify(_this.data)}`
  63. });
  64. }
  65. })
  66. }
  67. })
  68. },
  69. })
  70. }else{
  71. //console.log('拒绝授权')
  72. uni.navigateTo({
  73. url: '../index/index'
  74. });
  75. }
  76. },
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. .mianBox{
  82. height: 100%;
  83. width: 100%;
  84. color: #000;
  85. padding-top: 20px;
  86. box-sizing: border-box;
  87. .contentBox{
  88. width: 100%;
  89. height: auto;
  90. padding: 15px 20px;
  91. box-sizing: border-box;
  92. overflow: hidden;
  93. .logo{
  94. /deep/ .van-image{
  95. margin:0 auto;
  96. display: block;
  97. }
  98. }
  99. .authorized_app{
  100. text-align: center;
  101. color: #000;
  102. display: block;
  103. /deep/ .van-col{
  104. font-size: 30rpx;
  105. font-weight: 700;
  106. margin-top:30px;
  107. }
  108. }
  109. .authorized_text{
  110. width:80%;
  111. margin-left:10%;
  112. display: block;
  113. text-align: center;
  114. line-height: 30px;
  115. color: #777;
  116. /deep/ .van-col{
  117. font-size: 30rpx;
  118. margin-top: 20px;
  119. }
  120. }
  121. /deep/ .van-button{
  122. border-radius: 6px;
  123. width: 100% !important;
  124. margin-top:25px;
  125. letter-spacing: 2px;
  126. font-size: 18px;
  127. height: 50px;
  128. }
  129. .authorize_wrap{
  130. width:95%;
  131. margin:70px 2.5% 0;
  132. .authorize{
  133. height: 50px;
  134. font-size: 18px;
  135. border-radius: 10px;
  136. margin-top:40px;
  137. }
  138. }
  139. }
  140. }
  141. </style>