index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px'}">
  3. <view class="box">
  4. <!-- <image src="https://fsy.shengsi.gov.cn/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. <button class="normal" @tap="goLogin" >账号密码登录</button>
  10. </view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. data() {
  17. return {
  18. }
  19. },
  20. onLoad() {
  21. uni.clearStorageSync();
  22. },
  23. methods: {
  24. goLogin(){
  25. uni.navigateTo({
  26. url: "/pages/login/appIndex"
  27. })
  28. },
  29. aa() {
  30. uni.reLaunch({
  31. url: "/pagesHouse/hexiao/index"
  32. })
  33. },
  34. //获取手机号进行登录
  35. decryptPhoneNumber(e) {
  36. if (e.detail.code) this.wxLogin(e.detail.code);
  37. },
  38. // 登录
  39. wxLogin(code) {
  40. uni.showLoading({
  41. title: '登录中'
  42. });
  43. let that = this;
  44. wx.login({
  45. success(res) {
  46. that.$api.post('/auth/oauth/token', {
  47. code: res.code,
  48. phoneCode: code,
  49. grant_type: 'merchantWeChat',
  50. captcha: 'aaa'
  51. }, false).then(result => {
  52. if (result.data.code === 0) {
  53. uni.setStorageSync('authorization', result.data.token_type + ' ' + result
  54. .data.access_token);
  55. uni.setStorageSync('access_token', result.data.access_token);
  56. that.$api.get('/sys/user/info').then(resu => {
  57. if (resu.data.code === 0) {
  58. that.$showToast('登录成功');
  59. uni.setStorageSync('userInfo', resu.data.data);
  60. setTimeout(() => {
  61. uni.reLaunch({
  62. url: '/pages/login/select?userInfo=' +
  63. encodeURIComponent(JSON
  64. .stringify(resu.data.data))
  65. })
  66. }, 1500)
  67. } else that.$showToast(resu.data.msg)
  68. })
  69. } else{
  70. if(result.data.msg.indexOf('请先申请成为商家')>-1){
  71. uni.navigateTo({ url: '/pages/login/apply' })
  72. }else that.$showToast(result.data.msg)
  73. }
  74. })
  75. }
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped lang="less">
  82. .page {
  83. background: url(https://fsy.shengsi.gov.cn/file/20240523/474a7a2656cb499d851cf7665f9d7d6a.png) no-repeat;
  84. background-size: 100% 100%;
  85. display: flex;
  86. align-items: center;
  87. justify-content: center;
  88. .box {
  89. width: calc(100% - 180rpx);
  90. display: flex;
  91. flex-direction: column;
  92. align-items: center;
  93. image {
  94. width: 480rpx;
  95. height: 520rpx;
  96. }
  97. .text {
  98. text-align: center;
  99. font-size: 56rpx;
  100. font-family: PingFang SC, PingFang SC;
  101. font-weight: 800;
  102. color: #FFFFFF;
  103. line-height: 96rpx;
  104. }
  105. .login {
  106. margin-top: 780rpx;
  107. width: 100%;
  108. height: 96rpx;
  109. button {
  110. width: 100%;
  111. height: 100%;
  112. background: #1372FF;
  113. border-radius: 48rpx 48rpx 48rpx 48rpx;
  114. line-height: 96rpx;
  115. text-align: center;
  116. font-size: 32rpx;
  117. font-family: PingFang SC, PingFang SC;
  118. font-weight: 400;
  119. color: #FFFFFF;
  120. }
  121. .normal {
  122. background-color: #FFFFFF;
  123. color: #1372FF;
  124. border: 1px solid #1372FF;
  125. margin-top: 40rpx;
  126. }
  127. }
  128. }
  129. }
  130. </style>