index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="Home">
  3. <div class="Home-overlay"> </div>
  4. <div class="home-content">
  5. <view class="empty" :style="{height: statusBarHeight + 2 +'px'}"/>
  6. <view class="title">
  7. 中德智慧教育 <br/>
  8. 全球儿童思维教育专家
  9. </view>
  10. <view class="line"/>
  11. <view class="clause">
  12. <view class="clause-first">
  13. 内部系统,我们需要您授权以下信息
  14. </view>
  15. <view class="clause-seconed">
  16. <view class="dot" />
  17. 获取您的公开信息(昵称、头像等)
  18. </view>
  19. </view>
  20. <button
  21. class="auth-btn"
  22. open-type="getPhoneNumber"
  23. @getphonenumber="getPhoneNumber"
  24. :loading="loading"
  25. :disabled="loading"
  26. >
  27. 授权登录
  28. </button>
  29. <view class="rule">
  30. 仅限中德智慧内部代理商使用
  31. </view>
  32. </div>
  33. <view class="logo">
  34. <image :src="staticPicture.logo" mode="aspectFit"/>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import { Login } from '@/api/user.js'
  40. import { setLocalStorage } from '@/utils/wxTool.js'
  41. import { staticPicture } from '@/utils/global.js'
  42. import Tip from '@/utils/tip'
  43. export default {
  44. name: 'Home',
  45. computed: {
  46. statusBarHeight () {
  47. return this.$store.state.systemInfo.statusBarHeight
  48. },
  49. },
  50. onReady () {
  51. this.wxLogin()
  52. },
  53. data () {
  54. return {
  55. code: '',
  56. staticPicture,
  57. loading: false
  58. }
  59. },
  60. methods: {
  61. // wx.login
  62. async wxLogin () {
  63. const res = await wx.login()
  64. console.log(res);
  65. const { code } = res
  66. if (code) {
  67. this.code = code
  68. }
  69. },
  70. //获取手机号
  71. getPhoneNumber (e) {
  72. console.log(e);
  73. const { encryptedData, iv} = e.detail
  74. this.Login(encryptedData, iv)
  75. },
  76. // 用户登录
  77. async Login (encryptedData, iv) {
  78. this.loading = true
  79. const {data, status} = await Login({encryptedData, iv, code: this.code})
  80. this.loading = false
  81. if (status === 200) {
  82. Tip.success('登录成功')
  83. setLocalStorage('token', data.token)
  84. this.$store.commit('set_userInfo', data)
  85. // const routes = getCurrentPages()
  86. // console.log(routes, 'routes');
  87. // const route = routes[routes.length - 2]
  88. // const param = route.__displayReporter.showOptions.query
  89. // uni.redirectTo({
  90. // url: '/' + route.route + '?' + param
  91. // })
  92. uni.reLaunch({
  93. url: '/pages/user/index'
  94. })
  95. } else {
  96. this.code = ''
  97. this.wxLogin()
  98. }
  99. }
  100. }
  101. }
  102. </script>
  103. <style scoped lang="less">
  104. .Home {
  105. width: 100vw;
  106. height: 100vh;
  107. background-color: #CFD0DE;
  108. padding: 12% 6% 34%;
  109. box-sizing: border-box;
  110. position: relative;
  111. .Home-overlay {
  112. position: absolute;
  113. top: 0;
  114. left: 0;
  115. right: 0;
  116. bottom: 0;
  117. background: rgba(38, 38, 58, 0.8);
  118. z-index: 3;
  119. }
  120. .home-content {
  121. position: absolute;
  122. z-index: 4;
  123. }
  124. .title {
  125. width: 600rpx;
  126. height: 160rpx;
  127. font-size: 60rpx;
  128. font-family: PingFangSC-Medium, PingFang SC;
  129. font-weight: 500;
  130. color: #FFFFFF;
  131. line-height: 80rpx;
  132. margin-bottom: 48rpx;
  133. }
  134. .line {
  135. width: 100rpx;
  136. height: 8rpx;
  137. background-color: #44CEB6;
  138. margin-bottom: 186rpx;
  139. }
  140. .clause {
  141. margin-bottom: 84rpx;
  142. .clause-first {
  143. font-size: 32rpx;
  144. font-family: PingFangSC-Regular, PingFang SC;
  145. font-weight: 400;
  146. color: #FFFFFF;
  147. }
  148. .clause-seconed {
  149. margin-top: 16rpx;
  150. font-size: 32rpx;
  151. font-family: PingFangSC-Regular, PingFang SC;
  152. font-weight: 400;
  153. color: rgba(255, 255, 255, 0.8);
  154. display: flex;
  155. align-items: center;
  156. .dot {
  157. width: 8rpx;
  158. height: 8rpx;
  159. border-radius: 50%;
  160. background-color: #fff;
  161. margin-right: 20rpx;
  162. }
  163. }
  164. }
  165. .auth-btn {
  166. width: 656rpx;
  167. height: 96rpx;
  168. background: #1677FF;
  169. border-radius: 200rpx;
  170. font-size: 32rpx;
  171. font-family: PingFangSC-Medium, PingFang SC;
  172. font-weight: 500;
  173. color: #FFFFFF;
  174. margin-left: -0%;
  175. display: flex;
  176. justify-content: center;
  177. align-items: center;
  178. }
  179. .rule {
  180. width: 100%;
  181. text-align: center;
  182. font-size: 24rpx;
  183. font-family: PingFangSC-Regular, PingFang SC;
  184. font-weight: 400;
  185. color: rgba(255, 255, 255, 0.8);
  186. text-align: center;
  187. margin-top: 20rpx;
  188. margin-bottom: 98rpx;
  189. }
  190. .logo {
  191. width: 100%;
  192. height: 266rpx;
  193. margin-left: -53rpx;
  194. position: fixed;
  195. bottom: 12%;
  196. z-index: 1;
  197. image {
  198. width: 42.96%;
  199. height: 100%;
  200. object-fit: cover;
  201. display: block;
  202. margin: 0 auto;
  203. }
  204. }
  205. }
  206. </style>