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.

183 lines
3.8 KiB

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