index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px'}">
  3. <view class="box">
  4. <!-- <image src="https://i.ringzle.com/file/20240109/d6c4691423cf40c2bdf9210d389cdd1e.png"></image>
  5. <view class="text">您好!欢迎使用<br>游嵊泗商家服务平台</view> -->
  6. <!-- <view class="" @click="aa()">核销</view> -->
  7. <view class="login">
  8. <button open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">授权手机号登录</button>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. }
  18. },
  19. onLoad() {
  20. uni.clearStorageSync();
  21. },
  22. methods: {
  23. aa() {
  24. uni.reLaunch({
  25. url: "/pagesHouse/hexiao/index"
  26. })
  27. },
  28. //获取手机号进行登录
  29. decryptPhoneNumber(e) {
  30. if (e.detail.code) this.wxLogin(e.detail.code);
  31. },
  32. // 登录
  33. wxLogin(code) {
  34. uni.showLoading({
  35. title: '登录中'
  36. });
  37. let that = this;
  38. wx.login({
  39. success(res) {
  40. that.$api.post('/auth/oauth/token', {
  41. code: res.code,
  42. phoneCode: code,
  43. grant_type: 'merchantWeChat',
  44. captcha: 'aaa'
  45. }, false).then(result => {
  46. if (result.data.code === 0) {
  47. uni.setStorageSync('authorization', result.data.token_type + ' ' + result
  48. .data.access_token);
  49. uni.setStorageSync('access_token', result.data.access_token);
  50. that.$api.get('/sys/user/info').then(resu => {
  51. if (resu.data.code === 0) {
  52. that.$showToast('登录成功');
  53. uni.setStorageSync('userInfo', resu.data.data);
  54. setTimeout(() => {
  55. uni.reLaunch({
  56. url: '/pages/login/select?userInfo=' +
  57. encodeURIComponent(JSON
  58. .stringify(resu.data.data))
  59. })
  60. }, 1500)
  61. } else that.$showToast(resu.data.msg)
  62. })
  63. } else that.$showToast(result.data.msg)
  64. })
  65. }
  66. })
  67. }
  68. }
  69. }
  70. </script>
  71. <style scoped lang="less">
  72. .page {
  73. background: url(https://i.ringzle.com/file/20240523/474a7a2656cb499d851cf7665f9d7d6a.png) no-repeat;
  74. background-size: 100% 100%;
  75. display: flex;
  76. align-items: center;
  77. justify-content: center;
  78. .box {
  79. width: calc(100% - 180rpx);
  80. display: flex;
  81. flex-direction: column;
  82. align-items: center;
  83. image {
  84. width: 480rpx;
  85. height: 520rpx;
  86. }
  87. .text {
  88. text-align: center;
  89. font-size: 56rpx;
  90. font-family: PingFang SC, PingFang SC;
  91. font-weight: 800;
  92. color: #FFFFFF;
  93. line-height: 96rpx;
  94. }
  95. .login {
  96. margin-top: 780rpx;
  97. width: 100%;
  98. height: 96rpx;
  99. button {
  100. width: 100%;
  101. height: 100%;
  102. background: #1372FF;
  103. border-radius: 48rpx 48rpx 48rpx 48rpx;
  104. line-height: 96rpx;
  105. text-align: center;
  106. font-size: 32rpx;
  107. font-family: PingFang SC, PingFang SC;
  108. font-weight: 400;
  109. color: #FFFFFF;
  110. }
  111. }
  112. }
  113. }
  114. </style>