halfScreen.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view>
  3. <uni-popup ref="loginPop" type="bottom" border-radius="10px 10px 0 0" background-color="#ffffff" :mask-click="false">
  4. <view class="login-popup">
  5. <view class="login-title">
  6. <view class="login-logo">
  7. <view class="logo"><image src="/static/logo.jpg" mode="widthFix"></image></view>
  8. <view class="name">奥莱优品</view>
  9. </view>
  10. <view class="login-close" @click="closeLogin"><text class="cuIcon-close"></text></view>
  11. </view>
  12. <view class="login-desc" v-if="loginType==1">为了更好的为您提供服务,本次操作需要您关联手机号码</view>
  13. <view class="login-desc" v-else>为了更好的区分完善信息,还需授权获取到您的头像、昵称信息</view>
  14. <view class="login-footer">
  15. <view :class="checkTrueState?'checkBox active':'checkBox'" @click="checkTrue">
  16. <text class="cuIcon-check"></text>
  17. </view>
  18. <view @click="checkTrue">我已阅读并同意</view>
  19. <text @click="toWeb('privacy')">用户协议、</text><text @click="toWeb('privacy')">隐私协议</text>
  20. </view>
  21. <view class="logi-btn" v-if="loginType==1">
  22. <button class="u-button full" open-type="getPhoneNumber" @getphonenumber="getPhoneNumberData" v-if="checkTrueState">快捷一键登录</button>
  23. <button class="u-button full" @click="toLoginCheck" v-else>快捷登录</button>
  24. <button class="u-button" @click="closeLogin">暂不登录</button>
  25. </view>
  26. <view class="logi-btn" v-else>
  27. <button class="u-button full" open-type="getUserInfo" @click="getUserInfo" v-if="checkTrueState">快捷一键获取</button>
  28. <button class="u-button full" @click="toLoginCheck" v-else>快捷获取</button>
  29. <button class="u-button" @click="closeLogin">再看看</button>
  30. </view>
  31. </view>
  32. </uni-popup>
  33. </view>
  34. </template>
  35. <script>
  36. import { show } from '@/utils/js/index.js';
  37. export default {
  38. data() {
  39. return {
  40. checkTrueState:false,
  41. loginType:1
  42. }
  43. },
  44. methods: {
  45. closeLogin(){
  46. uni.showTabBar()
  47. this.$nextTick(()=>{
  48. this.$refs.loginPop.close()
  49. })
  50. },
  51. checkTrue(){
  52. this.checkTrueState = !this.checkTrueState;
  53. },
  54. toWeb(type){
  55. uni.navigateTo({
  56. url:"/pages/web/web?type="+type
  57. })
  58. },
  59. toLoginCheck(){
  60. if (!this.checkTrueState) {
  61. uni.showToast({
  62. title: "请先阅读同意用户协议",
  63. icon:"none"
  64. })
  65. return ;
  66. }
  67. },
  68. getUserInfo(e){
  69. uni.getUserProfile({
  70. force: true,
  71. success: async (resp)=> {
  72. if (resp.errMsg == 'getUserProfile:ok') {
  73. var detail = {};
  74. detail.avatar = resp.userInfo.avatarUrl
  75. detail.nickname = resp.userInfo.nickName
  76. var aresp = await this.$api.auth.nick.post(detail);
  77. if (aresp.code !== 1) {
  78. return show(aresp.msg);
  79. }
  80. uni.showTabBar()
  81. this.$nextTick(()=>{
  82. this.$refs.loginPop.close()
  83. })
  84. this.$emit('success',null);
  85. }
  86. },
  87. fail(e) {
  88. console.log(e)
  89. }
  90. })
  91. },
  92. getPhoneNumberData(event){
  93. uni.login({
  94. success: async (resp)=> {
  95. if (event.detail.errNo) {
  96. return uni.showToast({
  97. title: "请重试一次",
  98. icon:"none"
  99. })
  100. }
  101. var detail = event.detail
  102. detail.login = resp.code;
  103. var aresp = await this.$api.auth.mobile.post(detail);
  104. if (aresp.code !== 1) {
  105. return show(aresp.msg);
  106. }
  107. uni.setStorageSync("user_token", aresp.data.access_token)
  108. uni.showTabBar()
  109. this.$nextTick(()=>{
  110. this.$refs.loginPop.close()
  111. })
  112. this.$emit('success',aresp.data.access_token);
  113. }
  114. })
  115. },
  116. open(type = 1) {
  117. uni.hideTabBar();
  118. this.loginType = type;
  119. this.$nextTick(()=>{
  120. this.$refs.loginPop.open()
  121. })
  122. }
  123. }
  124. }
  125. </script>
  126. <style>
  127. .login-popup{padding: 20rpx;min-height: 30vh;}
  128. .login-popup .login-title{display: flex;align-items: center;justify-content: space-between;}
  129. .login-popup .login-title .login-logo{display: flex;align-items: center;gap: 15rpx;}
  130. .login-popup .login-title .login-logo image{width: 50rpx;height: 50rpx;border-radius: 100%;}
  131. .login-popup .login-title .name{font-weight: bold;font-family: "bluevBold";color: #000;font-size: 28rpx;}
  132. .login-desc{line-height: 2;color: #666;font-size: 24rpx;margin: 20rpx 0;text-align: center;}
  133. .login-footer{font-size: 28rpx;color: #666;height: 20%;display: flex;align-items: center;justify-content: center;}
  134. .login-footer text{color: #ff5a25;}
  135. .checkBox{width: 36upx;height: 36upx;margin-right: 20upx;border: 2upx solid #ff5a25;position: relative;border-radius: 36upx;display: flex;align-items: center;justify-content: center;}
  136. .checkBox text{display: block;color: #fff;}
  137. .checkBox.active{background-color: #ff5a25;}
  138. .checkBox.active text{color: #fff;}
  139. .logi-btn{width: 60%;margin: 20upx auto;height: 40%;}
  140. .logi-btn .u-button{font-size: 28upx;height: 80upx;border-radius: 40upx;line-height: 80upx;margin-top: 40upx;color: #333;border: 2upx solid rgba(33, 34, 38, 1);background-color: #fff;}
  141. .logi-btn .u-button::after{border: 0;}
  142. .logi-btn .u-button.full{background-color: rgba(33, 34, 38, 1);color: #fff;}
  143. </style>