login.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <image class="topbg" src="http://106.54.209.120:8188/static/login_top.png" mode="widthFix"></image>
  4. <div class="content adffcacjc">
  5. <button class="zt_btn" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">快速登录</button>
  6. <div class="agree adfacjc" @tap="changeAgree">
  7. <image src="http://106.54.209.120:8188/static/selected_not.png" v-if="!agree"></image>
  8. <image src="http://106.54.209.120:8188/static/selected.png" v-else></image>
  9. <div class="a_text">已阅读并同意 <span>《用户协议》</span><span>《隐私政策》</span></div>
  10. </div>
  11. </div>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. data(){
  17. return {
  18. agree:false
  19. }
  20. },
  21. onShow: () => {
  22. if(uni.getStorageSync('userInfo')){
  23. uni.reLaunch({
  24. url:'/pages/home'
  25. })
  26. }
  27. },
  28. methods:{
  29. changeAgree(){
  30. this.agree = !this.agree;
  31. },
  32. decryptPhoneNumber(e){
  33. if(!this.agree) return this.$showToast('请勾选协议和政策');
  34. uni.reLaunch({
  35. url:'/pages/home'
  36. })
  37. uni.setStorageSync('userInfo',JSON.stringify({id:1,mobile:'13888888888',username:'龙傲天'}))
  38. return
  39. if(e.detail.code) this.wxLogin(e.detail.code);
  40. },
  41. wxLogin(code){
  42. uni.showLoading({ title:'登录中' });
  43. let that = this;
  44. wx.login({
  45. success(res){
  46. that.$api.get('/sys/wx/login',{
  47. code:res.code,
  48. phoneCode:code
  49. },false).then(res=>{
  50. if(res.data.code===0){
  51. uni.setStorageSync('token',res.data.data.token);
  52. uni.setStorageSync('userInfo',JSON.stringify({
  53. id:res.data.data.id,
  54. mobile:res.data.data.mobile,
  55. username:res.data.data.username
  56. }));
  57. uni.hideLoading();
  58. that.$showToast('登录成功');
  59. setTimeout(()=>{
  60. uni.reLaunch({ url:'/pages/home' })
  61. },1500)
  62. }else that.$showToast(res.data.msg)
  63. })
  64. }
  65. })
  66. }
  67. }
  68. }
  69. </script>
  70. <style scoped lang="scss">
  71. .page{
  72. background: #FFFFFF;
  73. display: flex;
  74. flex-direction: column;
  75. box-sizing: border-box;
  76. .topbg{
  77. width: 100%;
  78. position: fixed;
  79. top: 0;
  80. left: 0;
  81. z-index: 0;
  82. }
  83. .content{
  84. position: relative;
  85. display: flex;
  86. flex: 1;
  87. width: calc(100% - 140rpx);
  88. margin: 307rpx 70rpx 0;
  89. .agree{
  90. margin-top: 50rpx;
  91. &>image{
  92. width: 32rpx;
  93. height: 32rpx;
  94. margin-right: 10rpx;
  95. }
  96. .a_text{
  97. font-family: PingFangSC, PingFang SC;
  98. font-weight: 400;
  99. font-size: 24rpx;
  100. color: #A6A6A6;
  101. line-height: 33rpx;
  102. span{
  103. color: #72832B;
  104. }
  105. }
  106. }
  107. }
  108. }
  109. </style>