index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="appBox">
  3. <div class="shading">
  4. <image :src="logoUrl" v-if="logoUrl" />
  5. <image src="/static/images/logo2.png" v-else />
  6. </div>
  7. <mobileLogin :isUp="isUp" :isShow="isShow" :platform="platform" :isPos="isPos" :appleShow="appleShow" :authKey="authKey" @wechatPhone="wechatPhone"></mobileLogin>
  8. </view>
  9. </template>
  10. <script setup>
  11. import { ref } from 'vue'
  12. import { useAppStore } from '@/stores/app'
  13. import { onLoad } from '@dcloudio/uni-app'
  14. import { useSendCode } from '@/hooks/useSendCode'
  15. import { useToast } from '@/hooks/useToast'
  16. import Cache from '@/utils/cache'
  17. import {
  18. registerVerify,
  19. getCodeApi,
  20. getUserInfo,
  21. } from "@/api/user"
  22. import mobileLogin from '@/components/login_mobile/index.vue'
  23. const appStore = useAppStore()
  24. const emit = defineEmits(['close', 'wechatPhone'])
  25. const { Toast } = useToast()
  26. const options = ref({})
  27. const keyCode = ref('')
  28. const account = ref('')
  29. const codeNum = ref('')
  30. const isUp = ref(true)
  31. const authKey = ref('')
  32. const logoUrl = ref('')
  33. const isShow = ref(false)
  34. const isPos = ref(false)
  35. const platform = ref('') // 手机平台
  36. const appleShow = ref('') //是否是苹果登录
  37. const userInfo = ref({})
  38. const { sendCode } = useSendCode()
  39. function wechatPhone() {
  40. Cache.clear('snsapiKey')
  41. if (options.value.back_url) {
  42. let url = uni.getStorageSync('snRouter')
  43. url = url.indexOf('/pages/index/index') != -1 ? '/' : url
  44. if (url.indexOf('/pages/users/wechat_login/index') !== -1) {
  45. url = '/'
  46. }
  47. if (!url) {
  48. url = '/pages/index/index'
  49. }
  50. isUp.value = false
  51. uni.showToast({
  52. title: '登录成功',
  53. icon: 'none'
  54. })
  55. // setTimeout(() => {
  56. // location.href = url
  57. // }, 800)
  58. } else {
  59. uni.navigateBack()
  60. }
  61. }
  62. // 获取验证码
  63. async function code() {
  64. if (!account.value) return Toast({ title: '请填写手机号码' })
  65. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(account.value)) return Toast({ title: '请输入正确的手机号码' })
  66. try {
  67. const res = await registerVerify(account.value)
  68. Toast({ title: res.msg })
  69. sendCode()
  70. } catch (err) {
  71. Toast({ title: err })
  72. }
  73. }
  74. // 获取验证码api
  75. function getCode() {
  76. getCodeApi().then(res => {
  77. keyCode.value = res.data.key
  78. }).catch(res => {
  79. Toast({ title: res })
  80. })
  81. }
  82. function close() {
  83. emit('close', false)
  84. }
  85. // 获取个人用户信息
  86. function getUserInfoFn() {
  87. getUserInfo().then(res => {
  88. uni.hideLoading()
  89. userInfo.value = res.data
  90. appStore.UPDATE_USERINFO(res.data)
  91. // #ifdef MP
  92. Toast({ title: '登录成功', icon: 'success' }, { tab: 3 })
  93. close()
  94. // #endif
  95. // #ifdef H5
  96. emit('wechatPhone', true)
  97. // #endif
  98. })
  99. }
  100. // 页面加载
  101. onLoad((opts) => {
  102. // uni.getSystemInfo({
  103. // success(res) {
  104. // platform.value = res.platform
  105. // }
  106. // })
  107. // options.value = opts
  108. // if (opts.authKey) authKey.value = opts.authKey
  109. // if (opts.appleShow) appleShow.value = opts.appleShow
  110. })
  111. </script>
  112. <style>
  113. page {
  114. height: 100%;
  115. }
  116. </style>
  117. <style lang="scss" scoped>
  118. .appBox {
  119. background-color: #fff;
  120. height: 100%;
  121. display: flex;
  122. flex-direction: column;
  123. justify-content: center;
  124. overflow: hidden;
  125. }
  126. .shading {
  127. display: flex;
  128. align-items: center;
  129. justify-content: center;
  130. width: 100%;
  131. image {
  132. width: 180rpx;
  133. height: 180rpx;
  134. }
  135. }
  136. page {
  137. background-color: #fff !important;
  138. }
  139. .ChangePassword .phone {
  140. font-size: 32rpx;
  141. font-weight: bold;
  142. text-align: center;
  143. margin-top: 55rpx;
  144. }
  145. .ChangePassword .list {
  146. width: 580rpx;
  147. margin: 53rpx auto 0 auto;
  148. }
  149. .ChangePassword .list .item {
  150. width: 100%;
  151. height: 110rpx;
  152. border-bottom: 2rpx solid #f0f0f0;
  153. }
  154. .ChangePassword .list .item input {
  155. width: 100%;
  156. height: 100%;
  157. font-size: 32rpx;
  158. }
  159. .ChangePassword .list .item .placeholder {
  160. color: #b9b9bc;
  161. }
  162. .ChangePassword .list .item input.codeIput {
  163. width: 340rpx;
  164. }
  165. .ChangePassword .list .item .code {
  166. font-size: 32rpx;
  167. background-color: #fff;
  168. }
  169. .ChangePassword .list .item .code.on {
  170. color: #b9b9bc !important;
  171. }
  172. .ChangePassword .confirmBnt {
  173. font-size: 32rpx;
  174. width: 580rpx;
  175. height: 90rpx;
  176. border-radius: 45rpx;
  177. color: #fff;
  178. margin: 92rpx auto 0 auto;
  179. text-align: center;
  180. line-height: 90rpx;
  181. }
  182. </style>