index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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/home/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. setTimeout(()=>{
  51. uni.reLaunch({
  52. url:'/pages/login/select?userInfo='+encodeURIComponent(JSON.stringify(resu.data.data))
  53. })
  54. },1500)
  55. }else that.$showToast(resu.data.msg)
  56. })
  57. }else that.$showToast(result.data.msg)
  58. })
  59. }
  60. })
  61. }
  62. }
  63. }
  64. </script>
  65. <style scoped lang="less">
  66. .page{
  67. background: url(https://i.ringzle.com/file/20240109/472b6b7b9ea44652b85e73c796876378.png) no-repeat;
  68. background-size: 100% 100%;
  69. display: flex;
  70. align-items: center;
  71. justify-content: center;
  72. .box{
  73. width: calc(100% - 180rpx);
  74. display: flex;
  75. flex-direction: column;
  76. align-items: center;
  77. image{
  78. width: 480rpx;
  79. height: 520rpx;
  80. }
  81. .text{
  82. text-align: center;
  83. font-size: 56rpx;
  84. font-family: PingFang SC, PingFang SC;
  85. font-weight: 800;
  86. color: #FFFFFF;
  87. line-height: 96rpx;
  88. }
  89. .login{
  90. margin-top: 80rpx;
  91. width: 100%;
  92. height: 96rpx;
  93. button{
  94. width: 100%;
  95. height: 100%;
  96. background: #FFFFFF;
  97. border-radius: 48rpx 48rpx 48rpx 48rpx;
  98. line-height: 96rpx;
  99. text-align: center;
  100. font-size: 34rpx;
  101. font-family: PingFang SC, PingFang SC;
  102. font-weight: 400;
  103. color: #145EE6;
  104. }
  105. }
  106. }
  107. }
  108. </style>