学员端小程序
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.

215 lines
5.7 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <template>
  2. <view class="main" :style="{ background: `url(${imgUrl}) no-repeat`, backgroundSize: backgroundSize }">
  3. <view class="h1Img">
  4. <image src="../../../static/images/userCenter/loginTitle.png" mode=""></image>
  5. </view>
  6. <view class="btnCon">
  7. <!-- <button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">手机号</button> -->
  8. <view class="btn" @click="loginFn">手机号快捷登录</view>
  9. <!-- <button type="success" size="mini" style="margin-top: 15rpx;" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" text="获取手机号">获取手机号</button> -->
  10. <view class="btn border" @click="$goPage('/pages/userCenter/login/loginByPhone');">手机号登录/注册</view>
  11. </view>
  12. <view style="margin-top: 40rpx;">
  13. <privacyRadion :isCheck="isCheck" @changeRadio="changeRadio"></privacyRadion>
  14. </view>
  15. <u-popup :show="show" :round="10" mode="center" >
  16. <view class="">
  17. <view class="popupCon">
  18. <view class="h1"> </view>
  19. <view class="msg">授权手机号我们才能继续为您 <br>提供服务哦~</view>
  20. <view class="oneBtn">我知道了</view>
  21. </view>
  22. </view>
  23. </u-popup>
  24. </view>
  25. </template>
  26. <script>
  27. import { imgUrl } from '@/config/site.config'
  28. import privacyRadion from '@/components/privacyRadion/privacyRadion'
  29. export default {
  30. components: {privacyRadion},
  31. data() {
  32. return {
  33. isCheck: false,
  34. show: false,
  35. decodePhoneParams: {},
  36. imgUrl: imgUrl+'loginTopBg.png',
  37. backgroundSize: '100% 360rpx',
  38. }
  39. },
  40. onLoad() {
  41. this.getCode()
  42. // uni.getLocation({
  43. // type: 'wgs84',
  44. // success: function (res) {
  45. // console.log(res)
  46. // console.log('当前位置的经度:' + res.longitude);
  47. // console.log('当前位置的纬度:' + res.latitude);
  48. // }
  49. // });
  50. },
  51. methods: {
  52. getPhoneNumber (e) {
  53. console.log(e.detail.code) // 动态令牌
  54. console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
  55. console.log(e.detail.errno) // 错误码(失败时返回)
  56. },
  57. loginFn() {
  58. // 微信登录
  59. uni.login({
  60. provider: 'weixin',
  61. success: loginRes => {
  62. if (loginRes.code) {
  63. // 登录成功,获取用户信息
  64. this.getUserInfo(loginRes.code);
  65. } else {
  66. console.error('微信登录失败');
  67. }
  68. },
  69. fail: err => {
  70. console.error('微信登录失败', err);
  71. }
  72. });
  73. },
  74. getUserInfo(code) {
  75. // 获取用户信息
  76. uni.getUserInfo({
  77. provider: 'weixin',
  78. success: userInfoRes => {
  79. // 在这里处理获取到的用户信息
  80. console.log('用户信息', userInfoRes);
  81. // 发送 code 和用户信息到后台进行登录操作
  82. this.loginBackend(code, userInfoRes);
  83. },
  84. fail: err => {
  85. console.error('获取用户信息失败', err);
  86. }
  87. });
  88. },
  89. loginBackend(code, userInfo) {
  90. // 在这里发送 code 和用户信息到后台进行登录操作
  91. // 可以使用 uni.request 或其他 HTTP 库发送请求
  92. },
  93. // 获取code
  94. getCode() {
  95. uni.login({
  96. provider: 'weixin',
  97. success: loginRes => {
  98. this.decodePhoneParams.code = loginRes.code
  99. console.log('loginRes')
  100. console.log(loginRes)
  101. }
  102. });
  103. },
  104. // 获取手机号
  105. // async getPhoneNumber(e) {
  106. // await this.getCode();
  107. // console.log('获取手机号')
  108. // console.log(e)
  109. // if(!this.decodePhoneParams.code || !e.detail.encryptedData){
  110. // return false;
  111. // }
  112. // },
  113. // 是否选择协议
  114. changeRadio(val) {
  115. this.isCheck = val
  116. },
  117. init() {
  118. uni.login({
  119. provider: 'weixin',
  120. "onlyAuthorize": true,
  121. success: function (loginRes) {
  122. console.log('11')
  123. console.log(loginRes)
  124. // 登录成功
  125. uni.getUserInfo({
  126. provider: 'weixin',
  127. success: function(info) {
  128. // 获取用户信息成功, info.authResult保存用户信息
  129. console.log('11')
  130. console.log(info)
  131. }
  132. })
  133. },
  134. fail: function (err) {
  135. // 登录授权失败
  136. // err.code是错误码
  137. }
  138. });
  139. },
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. .main {
  145. width: 100%;
  146. display: flex;
  147. flex-direction: column;
  148. align-items: center;
  149. // background: url('../../../static/images/userCenter/loginTopBg.png') no-repeat;
  150. // background-size: 100% 360rpx;
  151. .h1Img {
  152. width: 658rpx;
  153. height: 94rpx;
  154. margin: 288rpx 0 120rpx 0;
  155. }
  156. .btnCon {
  157. .btn {
  158. width: 396rpx;
  159. height: 72rpx;
  160. background: #1989FA;
  161. border-radius: 8rpx;
  162. color: #fff;
  163. margin-bottom: 32rpx;
  164. text-align: center;
  165. line-height: 72rpx;
  166. font-size: 28rpx;
  167. &.border {
  168. background: rgba(25,137,250,0.1);
  169. border: 2rpx solid #1989FA;
  170. color: $themC;
  171. }
  172. }
  173. }
  174. }
  175. .popupCon {
  176. width: 558rpx;
  177. height: 344rpx;
  178. border-radius: 16rpx;
  179. overflow: hidden;
  180. .h1 {
  181. line-height: 124rpx;
  182. text-align: center;
  183. font-size: 36rpx;
  184. font-weight: 600;
  185. height: 124rpx;
  186. width: 100%;
  187. background: linear-gradient(180deg, #C1DFFE 0%, #FFFFFF 100%);
  188. }
  189. .msg {
  190. font-size: 28rpx;
  191. color: #686B73;
  192. padding: 0 0 30rpx 0;
  193. text-align: center;
  194. }
  195. .oneBtn {
  196. line-height: 112rpx;
  197. height: 112rpx;
  198. border-top: 1px solid #E8E9EC;
  199. text-align: center;
  200. font-size: 36rpx;
  201. color: $themC;
  202. font-weight: 600;
  203. }
  204. }
  205. </style>