index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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({ title:'登录中' });
  35. let that = this;
  36. wx.login({
  37. success(res){
  38. that.$api.post('/auth/oauth/token',{
  39. code:res.code,
  40. phoneCode:code,
  41. grant_type:'merchantWeChat',
  42. captcha:'aaa'
  43. },false).then(result=>{
  44. if(result.data.code===0){
  45. uni.setStorageSync('authorization',result.data.token_type+' '+result.data.access_token);
  46. uni.setStorageSync('access_token',result.data.access_token);
  47. that.$api.get('/sys/user/info').then(resu=>{
  48. if(resu.data.code===0){
  49. that.$showToast('登录成功');
  50. uni.setStorageSync('userInfo',resu.data.data);
  51. setTimeout(()=>{
  52. uni.reLaunch({
  53. url:'/pages/login/select?userInfo='+encodeURIComponent(JSON.stringify(resu.data.data))
  54. })
  55. },1500)
  56. }else that.$showToast(resu.data.msg)
  57. })
  58. }else that.$showToast(result.data.msg)
  59. })
  60. }
  61. })
  62. }
  63. }
  64. }
  65. </script>
  66. <style scoped lang="less">
  67. .page{
  68. background: url(https://i.ringzle.com/file/20240109/472b6b7b9ea44652b85e73c796876378.png) no-repeat;
  69. background-size: 100% 100%;
  70. display: flex;
  71. align-items: center;
  72. justify-content: center;
  73. .box{
  74. width: calc(100% - 180rpx);
  75. display: flex;
  76. flex-direction: column;
  77. align-items: center;
  78. image{
  79. width: 480rpx;
  80. height: 520rpx;
  81. }
  82. .text{
  83. text-align: center;
  84. font-size: 56rpx;
  85. font-family: PingFang SC, PingFang SC;
  86. font-weight: 800;
  87. color: #FFFFFF;
  88. line-height: 96rpx;
  89. }
  90. .login{
  91. margin-top: 80rpx;
  92. width: 100%;
  93. height: 96rpx;
  94. button{
  95. width: 100%;
  96. height: 100%;
  97. background: #FFFFFF;
  98. border-radius: 48rpx 48rpx 48rpx 48rpx;
  99. line-height: 96rpx;
  100. text-align: center;
  101. font-size: 34rpx;
  102. font-family: PingFang SC, PingFang SC;
  103. font-weight: 400;
  104. color: #145EE6;
  105. }
  106. }
  107. }
  108. }
  109. </style>