You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

201 lines
3.9 KiB

4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
3 months ago
4 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
4 months ago
  1. <template>
  2. <view class="content">
  3. <view class="padding">
  4. <view class="logoCon">
  5. <view class="logo">
  6. <image src="@/static/images/logo.png" mode=""></image>
  7. </view>
  8. <view class="name">事务通</view>
  9. </view>
  10. <view class="oneBtnBox" v-if="!isCheck">
  11. <oneBtn text="手机号快捷登录" @oneBtnClick="handleBtnClick"></oneBtn>
  12. </view>
  13. <view class="oneBtnBox" v-else>
  14. <button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" class="cotactzz">手机号快捷登录</button>
  15. <oneBtn text="手机号快捷登录"></oneBtn>
  16. </view>
  17. <view style="padding-top: 30rpx;">
  18. <privacyRadion style="margin-top: 40rpx;" @changeRadio="changeRadio" :isCheck="isCheck" />
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script setup>
  24. import { ref } from 'vue'
  25. import {
  26. weixinLogin
  27. } from '@/config/api.js'
  28. import {
  29. toast
  30. } from '@/uni_modules/uview-plus'
  31. import {
  32. userStore
  33. } from '@/store/index.js';
  34. import privacyRadion from '@/components/privacyRadion/privacyRadion.vue'
  35. let FormData = ref({
  36. phone: '',
  37. code: ''
  38. })
  39. let isCheck = ref(false)
  40. function handleBtnClick() {
  41. toast('请先勾先勾选用户协议与隐私政策')
  42. }
  43. // 是否选择协议
  44. function changeRadio(val) {
  45. uni.hideKeyboard();
  46. isCheck.value = val
  47. }
  48. function loginFn() {
  49. // 微信登录
  50. return new Promise((resolve, reject) => {
  51. uni.login({
  52. provider: 'weixin',
  53. success: loginRes => {
  54. if (loginRes.code) {
  55. // 登录成功,获取用户信息
  56. console.log('loginRes.code')
  57. console.log(loginRes.code)
  58. resolve(loginRes.code)
  59. // this.getUserInfo(loginRes.code);
  60. } else {
  61. console.error('微信登录失败');
  62. }
  63. },
  64. fail: err => {
  65. reject(null)
  66. console.error('微信登录失败', err);
  67. uni.hideLoading()
  68. }
  69. });
  70. })
  71. }
  72. async function getPhoneNumber(e) {
  73. if (!isCheck.value) return toast('请勾选产品协议与隐私政策');
  74. let phoneCode = e.detail.code
  75. uni.showLoading({
  76. title: '正在加载...'
  77. })
  78. console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
  79. console.log(e.detail) // 错误码(失败时返回)
  80. const loginCode = await loginFn()
  81. if (!loginCode || !phoneCode) return
  82. let obj = {
  83. phoneCode,
  84. socialCode: loginCode
  85. }
  86. const {
  87. data: res
  88. } = await weixinLogin(obj)
  89. const counterStore = userStore();
  90. await counterStore.upDateToken(res.accessToken)
  91. await counterStore.upDateLoginInfo(res)
  92. // this.$goPage('/pages/userCenter/login/face')
  93. uni.hideLoading()
  94. uni.$u.toast('登录成功')
  95. setTimeout(()=>{
  96. uni.switchTab({
  97. url: '/pages/tabbar/index/index'
  98. })
  99. },1500)
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. image {
  104. display: block;
  105. width: 100%;
  106. height: 100%;
  107. }
  108. .other {
  109. display: flex;
  110. flex-direction: column;
  111. align-items: center;
  112. justify-content: center;
  113. font-size: 22rpx;
  114. color: #9C9C9C;
  115. position: fixed;
  116. bottom: 80rpx;
  117. left: 0;
  118. width: 100%;
  119. .lineTxt {
  120. position: relative;
  121. &::before {
  122. content: '';
  123. position: absolute;
  124. width: 240rpx;
  125. height: 1rpx;
  126. top: 50%;
  127. background: #e6e6e6;
  128. right: 150rpx;
  129. transform: translateY(50%);
  130. z-index: 99;
  131. }
  132. &::after {
  133. content: '';
  134. position: absolute;
  135. width: 240rpx;
  136. height: 1rpx;
  137. top: 50%;
  138. background: #e6e6e6;
  139. left: 150rpx;
  140. transform: translateY(50%);
  141. z-index: 99;
  142. }
  143. }
  144. .icon {
  145. width: 80rpx;
  146. height: 80rpx;
  147. margin: 20rpx 0;
  148. }
  149. .txt {}
  150. }
  151. .content {
  152. .logoCon {
  153. display: flex;
  154. flex-direction: column;
  155. align-items: center;
  156. justify-content: center;
  157. padding-top: 150rpx;
  158. .logo {
  159. width: 160rpx;
  160. height: 160rpx;
  161. }
  162. .name {
  163. font-size: 32rpx;
  164. margin-top: 20rpx;
  165. font-weight: 700;
  166. }
  167. }
  168. .oneBtnBox {
  169. margin-top: 40rpx;
  170. position: relative;
  171. .cotactzz {
  172. position: absolute;
  173. left: 0;
  174. right: 0;
  175. top: 0;
  176. opacity: 0;
  177. }
  178. }
  179. }
  180. </style>