index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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{
  64. if(result.data.msg.indexOf('请先申请成为商家')>-1){
  65. uni.navigateTo({ url: '/pages/login/apply' })
  66. }else that.$showToast(result.data.msg)
  67. }
  68. })
  69. }
  70. })
  71. }
  72. }
  73. }
  74. </script>
  75. <style scoped lang="less">
  76. .page {
  77. background: url(https://i.ringzle.com/file/20240523/474a7a2656cb499d851cf7665f9d7d6a.png) no-repeat;
  78. background-size: 100% 100%;
  79. display: flex;
  80. align-items: center;
  81. justify-content: center;
  82. .box {
  83. width: calc(100% - 180rpx);
  84. display: flex;
  85. flex-direction: column;
  86. align-items: center;
  87. image {
  88. width: 480rpx;
  89. height: 520rpx;
  90. }
  91. .text {
  92. text-align: center;
  93. font-size: 56rpx;
  94. font-family: PingFang SC, PingFang SC;
  95. font-weight: 800;
  96. color: #FFFFFF;
  97. line-height: 96rpx;
  98. }
  99. .login {
  100. margin-top: 780rpx;
  101. width: 100%;
  102. height: 96rpx;
  103. button {
  104. width: 100%;
  105. height: 100%;
  106. background: #1372FF;
  107. border-radius: 48rpx 48rpx 48rpx 48rpx;
  108. line-height: 96rpx;
  109. text-align: center;
  110. font-size: 32rpx;
  111. font-family: PingFang SC, PingFang SC;
  112. font-weight: 400;
  113. color: #FFFFFF;
  114. }
  115. }
  116. }
  117. }
  118. </style>