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.

184 lines
3.8 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 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 type="default" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" class="cotact">联系客服</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>
  24. import { weixinLogin } from '@/config/api.js'
  25. import { toast} from '@/uni_modules/uview-plus'
  26. export default {
  27. data() {
  28. return {
  29. FormData: {
  30. phone: '',
  31. code: ''
  32. },
  33. isCheck: false
  34. }
  35. },
  36. methods: {
  37. handleBtnClick() {
  38. this.$u.toast('请先勾先勾选用户协议与隐私政策')
  39. },
  40. // 是否选择协议
  41. changeRadio(val) {
  42. uni.hideKeyboard();
  43. this.isCheck = val
  44. },
  45. async getPhoneNumber (e) {
  46. if(!this.isCheck) return this.$u.toast('请勾选产品协议与隐私政策');
  47. let phoneCode = e.detail.code
  48. console.log('来到这里了吗?')
  49. console.log(phoneCode)
  50. console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
  51. console.log(e.detail) // 错误码(失败时返回)
  52. const loginCode = await this.loginFn()
  53. if(!loginCode||!phoneCode) return
  54. console.log('登录验证码')
  55. console.log(loginCode)
  56. let obj = {
  57. phoneCode,
  58. socialCode: loginCode
  59. }
  60. const {data: res} = await weixinLogin(obj)
  61. console.log(res)
  62. // this.$goPage('/pages/userCenter/login/face')
  63. // uni.switchTab({
  64. // url: '/pages/tabbar/index/index'
  65. // })
  66. },
  67. loginFn() {
  68. // 微信登录
  69. return new Promise((resolve,reject)=>{
  70. uni.login({
  71. provider: 'weixin',
  72. success: loginRes => {
  73. if (loginRes.code) {
  74. // 登录成功,获取用户信息
  75. console.log('loginRes.code')
  76. console.log(loginRes.code)
  77. resolve(loginRes.code)
  78. // this.getUserInfo(loginRes.code);
  79. } else {
  80. console.error('微信登录失败');
  81. }
  82. },
  83. fail: err => {
  84. reject(null)
  85. console.error('微信登录失败', err);
  86. }
  87. });
  88. })
  89. },
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. image {
  95. display: block;
  96. width: 100%;
  97. height: 100%;
  98. }
  99. .other {
  100. display: flex;
  101. flex-direction: column;
  102. align-items: center;
  103. justify-content: center;
  104. font-size: 22rpx;
  105. color: #9C9C9C;
  106. position: fixed;
  107. bottom: 80rpx;
  108. left: 0;
  109. width: 100%;
  110. .lineTxt {
  111. position: relative;
  112. &::before {
  113. content: '';
  114. position: absolute;
  115. width: 240rpx;
  116. height: 1rpx;
  117. top: 50%;
  118. background: #e6e6e6;
  119. right: 150rpx;
  120. transform: translateY(50%);
  121. z-index: 99;
  122. }
  123. &::after {
  124. content: '';
  125. position: absolute;
  126. width: 240rpx;
  127. height: 1rpx;
  128. top: 50%;
  129. background: #e6e6e6;
  130. left: 150rpx;
  131. transform: translateY(50%);
  132. z-index: 99;
  133. }
  134. }
  135. .icon {
  136. width: 80rpx;
  137. height: 80rpx;
  138. margin: 20rpx 0;
  139. }
  140. .txt {
  141. }
  142. }
  143. .content {
  144. .logoCon {
  145. display: flex;
  146. flex-direction: column;
  147. align-items: center;
  148. justify-content: center;
  149. padding-top: 150rpx;
  150. .logo {
  151. width: 160rpx;
  152. height: 160rpx;
  153. }
  154. .name {
  155. font-size: 32rpx;
  156. margin-top: 20rpx;
  157. font-weight: 700;
  158. }
  159. }
  160. .oneBtnBox {
  161. margin-top: 40rpx;
  162. position: relative;
  163. .cotact {
  164. position: absolute;
  165. left: 0;
  166. right: 0;
  167. top: 0;
  168. opacity: 0;
  169. }
  170. }
  171. }
  172. </style>