login.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <view class="content">
  3. <view class="login-logo">
  4. <view class="login-logo-body">
  5. <image src="/static/image/logo.png"></image>
  6. <view class="logo-text">奥莱优品</view>
  7. </view>
  8. </view>
  9. <view class="test">
  10. <textarea v-model="loginInfo" maxlength="-1" style="height: 120upx;"></textarea>
  11. </view>
  12. <view class="logi-btn">
  13. <button class="u-button full" open-type="getPhoneNumber" @getphonenumber="toLogin" v-if="checkTrueState">手机号一键登录</button>
  14. <button class="u-button full" @click="toLoginCheck" v-else>手机号授权登录</button>
  15. <button class="u-button" @click="reback">返回</button>
  16. </view>
  17. <view class="login-footer">
  18. <view :class="checkTrueState?'checkBox active':'checkBox'" @click="checkTrue"></view>
  19. <view @click="checkTrue">我已阅读并同意</view>
  20. <text @click="$dialog.navTo('/pages/web/web?lk=service')">用户协议、</text><text @click="$dialog.navTo('/pages/web/web?lk=privacy')">隐私协议</text>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import * as Api from "@/static/api/auth.js";
  26. var app;
  27. export default {
  28. data() {
  29. return {
  30. checkTrueState:false,
  31. avatar:"https://yunenv.oss-cn-shenzhen.aliyuncs.com/poem/avatar.jpg",
  32. nickname:"",
  33. loginShow:false,
  34. reUri:null,
  35. reType:"switchTab",
  36. storeId:"",
  37. loginCode:"",
  38. loginInfo:""
  39. }
  40. },
  41. onLoad({store,type,url}) {
  42. app = this;
  43. app.reType = type?type:"switchTab";
  44. app.reUri = url?url:null;
  45. uni.login({
  46. force:true,
  47. success(res){
  48. app.loginCode = res.code;
  49. }
  50. })
  51. // app.storeId = app.$dialog.shopId();
  52. },
  53. methods: {
  54. reback(){
  55. uni.navigateBack();
  56. },
  57. checkTrue(){
  58. app.checkTrueState = !app.checkTrueState;
  59. },
  60. toLoginCheck(){
  61. if (!app.checkTrueState) {
  62. return app.$dialog.showSuccess("请先阅读并同意用户协议以及隐私政策");
  63. }
  64. },
  65. toLogin(e){
  66. var detail = e.detail;
  67. detail.login = app.loginCode;
  68. Api.login(detail).then((res)=>{
  69. if (res.code == 0) {
  70. return app.$dialog.showSuccess(res.msg);
  71. }
  72. uni.setStorageSync("user_token", res.data.access_token)
  73. uni.navigateBack();
  74. })
  75. },
  76. }
  77. }
  78. </script>
  79. <style>
  80. .test{width: 80%;overflow: auto;height: 100upx;}
  81. .content{position: relative;height: 100vh;display: flex;flex-direction: column;}
  82. .login-logo{width: 80%;margin: 60upx auto;text-align: center;height: 40%;display: flex;align-items: center;justify-content: center;}
  83. .login-logo .logo-text{font-size: 32upx;color: #333;font-family: "logofont";margin-top: 20upx;}
  84. .login-logo image{width: 180upx;height: 180upx;}
  85. .logi-btn{width: 50%;margin: 20upx auto;height: 40%;}
  86. .logi-btn .u-button{font-size: 28upx;height: 80upx;border-radius: 40upx;line-height: 80upx;margin-bottom: 40upx;color: #333;border: 2upx solid #007aff;background-color: #fff;}
  87. .logi-btn .u-button.full{background-color: #007aff;color: #fff;}
  88. .login-footer{text-align: center;font-size: 28upx;color: #666;height: 20%;display: flex;align-items: center;justify-content: center;}
  89. .login-footer text{color: #007aff;}
  90. .checkBox{width: 30upx;height: 30upx;margin-right: 20upx;border: 2upx solid #007aff;position: relative;}
  91. .checkBox.active{background-color: #007aff;}
  92. .checkBox.active::after{content: "√";font-size: 24upx;position: absolute;left: 0;top: 0;color: #fff;bottom: 0;right: 0;}
  93. .popup-login{padding: 20upx;}
  94. .popup-login .login-container{margin-top: 20upx;}
  95. .login-control{display: flex;align-items: center;font-size: 28upx;color: #333;border-bottom: 2upx solid #f8f8f8;padding: 20upx 0;}
  96. .login-control .name{margin-right: 40upx;}
  97. .login-control .btn-control{margin-left: 9px;}
  98. .popup-login .mobile-btn{border:2upx solid #fff;background-color: #fff;padding-left: 0;padding-right: 0;font-size: 28upx;color: #999;}
  99. .popup-login .mobile-btn::after{border: 0;}
  100. .avatar-btn-img{width: 80upx;height: 80upx;border-radius: 10upx;}
  101. .popup-login .avatar-btn{width:80upx;height:80upx;line-height:80upx;border-radius:10upx;font-size:24upx;border:0 solid #F6F1E7;background:#fff;padding-left: 0;padding-right: 0;}
  102. .popup-login .avatar-btn::after{border:0}
  103. .popup-login .avatar{margin-left: 9px;}
  104. .popup-login .title-sub{border-bottom: 2upx solid #f8f8f8;font-size: 30upx;color: #000;font-weight: bold;padding: 30upx 0;}
  105. .popup-login .title-sub text{display: block;font-size: 24upx;color: #666;font-weight: normal;margin-top: 20upx;}
  106. .popup-login .title{display: flex;align-items: center;}
  107. .popup-login .title .left{font-size: 28upx;color: #000;font-weight: bold;display: flex;align-items: center;}
  108. .popup-login .title .left image{width: 50upx;height: 50upx;border-radius: 10upx;margin-right: 20upx;}
  109. .popup-login .title .close{margin-left: auto;margin-right: 0;width: 40upx;height: 40upx;background-color: aliceblue;font-size: 24upx;color: #666;border-radius: 40upx;text-align: center;}
  110. </style>