login.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <image class="topbg" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/b1d0d573-3a9d-4a08-8f0f-592bbab5a731.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="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/e2c98493-2b1a-4138-aa7e-2b2a0be3abf3.png" v-if="!agree"></image>
  8. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/05/29/720de1ea-0c99-4cf3-b728-50674303f952.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. methods:{
  22. changeAgree(){
  23. this.agree = !this.agree;
  24. },
  25. decryptPhoneNumber(e){
  26. if(!this.agree) return this.$showToast('请勾选协议和政策');
  27. if(e.detail.code) this.wxLogin(e.detail.code);
  28. },
  29. wxLogin(code){
  30. uni.showLoading({ title:'登录中' });
  31. let that = this;
  32. wx.login({
  33. success(res){
  34. that.$api.get('/sys/wx/login',{
  35. code:res.code,
  36. phoneCode:code
  37. },false).then(res=>{
  38. if(res.data.code===0){
  39. uni.setStorageSync('token',res.data.data.token);
  40. uni.setStorageSync('userInfo',JSON.stringify({
  41. id:res.data.data.id,
  42. mobile:res.data.data.mobile,
  43. username:res.data.data.username
  44. }));
  45. uni.hideLoading();
  46. that.$showToast('登录成功');
  47. setTimeout(()=>{
  48. uni.reLaunch({ url:'/pages/home' })
  49. },1500)
  50. }else that.$showToast(res.data.msg)
  51. })
  52. }
  53. })
  54. }
  55. }
  56. }
  57. </script>
  58. <style scoped lang="scss">
  59. .page{
  60. background: #FFFFFF;
  61. display: flex;
  62. flex-direction: column;
  63. box-sizing: border-box;
  64. .topbg{
  65. width: 100%;
  66. position: fixed;
  67. top: 0;
  68. left: 0;
  69. z-index: 0;
  70. }
  71. .content{
  72. position: relative;
  73. display: flex;
  74. flex: 1;
  75. width: calc(100% - 140rpx);
  76. margin: 307rpx 70rpx 0;
  77. .agree{
  78. margin-top: 50rpx;
  79. &>image{
  80. width: 32rpx;
  81. height: 32rpx;
  82. margin-right: 10rpx;
  83. }
  84. .a_text{
  85. font-family: PingFangSC, PingFang SC;
  86. font-weight: 400;
  87. font-size: 24rpx;
  88. color: #A6A6A6;
  89. line-height: 33rpx;
  90. span{
  91. color: #72832B;
  92. }
  93. }
  94. }
  95. }
  96. }
  97. </style>