index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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="login">
  7. <button open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">登录</button>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. }
  17. },
  18. onLoad() {
  19. uni.clearStorageSync();
  20. },
  21. methods: {
  22. //获取手机号进行登录
  23. decryptPhoneNumber(e){
  24. if(e.detail.code) this.wxLogin(e.detail.code);
  25. },
  26. //登录
  27. wxLogin(code){
  28. uni.showLoading({ title:'登录中' });
  29. let that = this;
  30. wx.login({
  31. success(res){
  32. that.$api.post('/auth/oauth/token',{
  33. code:res.code,
  34. phoneCode:code,
  35. grant_type:'merchantWeChat',
  36. captcha:'aaa'
  37. },false).then(result=>{
  38. if(result.data.code===0){
  39. uni.setStorageSync('authorization',result.data.token_type+' '+result.data.access_token);
  40. uni.setStorageSync('access_token',result.data.access_token);
  41. that.$api.get('/sys/user/info').then(resu=>{
  42. if(resu.data.code===0){
  43. that.$showToast('登录成功');
  44. setTimeout(()=>{
  45. uni.reLaunch({
  46. url:'/pages/login/select?userInfo='+encodeURIComponent(JSON.stringify(resu.data.data))
  47. })
  48. },1500)
  49. }else that.$showToast(resu.data.msg)
  50. })
  51. }else that.$showToast(result.data.msg)
  52. })
  53. }
  54. })
  55. }
  56. }
  57. }
  58. </script>
  59. <style scoped lang="less">
  60. .page{
  61. background: url(https://i.ringzle.com/file/20240109/472b6b7b9ea44652b85e73c796876378.png) no-repeat;
  62. background-size: 100% 100%;
  63. display: flex;
  64. align-items: center;
  65. justify-content: center;
  66. .box{
  67. width: calc(100% - 180rpx);
  68. display: flex;
  69. flex-direction: column;
  70. align-items: center;
  71. image{
  72. width: 480rpx;
  73. height: 520rpx;
  74. }
  75. .text{
  76. text-align: center;
  77. font-size: 56rpx;
  78. font-family: PingFang SC, PingFang SC;
  79. font-weight: 800;
  80. color: #FFFFFF;
  81. line-height: 96rpx;
  82. }
  83. .login{
  84. margin-top: 80rpx;
  85. width: 100%;
  86. height: 96rpx;
  87. button{
  88. width: 100%;
  89. height: 100%;
  90. background: #FFFFFF;
  91. border-radius: 48rpx 48rpx 48rpx 48rpx;
  92. line-height: 96rpx;
  93. text-align: center;
  94. font-size: 34rpx;
  95. font-family: PingFang SC, PingFang SC;
  96. font-weight: 400;
  97. color: #145EE6;
  98. }
  99. }
  100. }
  101. }
  102. </style>