welcome.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="welcome">
  3. <fs-empty :text="errMsg" v-if="errMsg">
  4. <fs-button type="primary" @click="handleRefresh">刷新</fs-button>
  5. </fs-empty>
  6. <view class="wrap" v-else>
  7. <view class="circle"></view>
  8. <view class="circle"></view>
  9. <view class="circle"></view>
  10. <view class="shadow"></view>
  11. <view class="shadow"></view>
  12. <view class="shadow"></view>
  13. <text>加载中...</text>
  14. </view>
  15. </view>
  16. <PrivacyAgreement ref="privacyAgreementRef" @change="handleChange"></PrivacyAgreement>
  17. </template>
  18. <script setup>
  19. import { convertUrlParams, convertObjParams } from '@/utils/share'
  20. import { useUserStore } from '@/stores/user'
  21. import PrivacyAgreement from '@/business/PrivacyAgreement'
  22. const user = useUserStore()
  23. const argument = ref({})
  24. const errMsg = ref('')
  25. const privacyAgreementRef = ref(null)
  26. const isShowPopup = ref(true)
  27. const handleChange = (val) => {
  28. isShowPopup.value = val
  29. if (val) {
  30. errMsg.value = '您还没有同意隐私协议哦,请点击刷新重新加载'
  31. } else {
  32. tautology()
  33. }
  34. }
  35. const tautology = async () => {
  36. errMsg.value = ''
  37. if (isShowPopup.value) return false
  38. // uni.switchTab({
  39. // url: `/pages/index/index`
  40. // })
  41. try {
  42. await user.login()
  43. let shareParamsObj = argument.value
  44. if (argument.value.sharePath) {
  45. const codeArr = (argument.value.sharePath || '').replace(/\\u0026/g, '&').split('&')
  46. codeArr[0] = 'sharePath=' + codeArr[0]
  47. shareParamsObj = Object.assign({}, argument.value, convertObjParams(codeArr.join('&')))
  48. }
  49. getApp().globalData.shareParams = shareParamsObj || {}
  50. console.log('shareParamsObj', shareParamsObj)
  51. const params = convertUrlParams(shareParamsObj)
  52. const sharePath = shareParamsObj.sharePath || ''
  53. if (sharePath) {
  54. const data = { url: `${sharePath}${params}` }
  55. uni.redirectTo(data)
  56. } else {
  57. uni.redirectTo({
  58. url: `/pages/index/index`
  59. })
  60. }
  61. } catch (err) {
  62. console.log('err', err)
  63. errMsg.value = err.errMsg || err.msg || '加载失败,请重试'
  64. }
  65. }
  66. const handleRefresh = () => {
  67. isShowPopup.value = true
  68. privacyAgreementRef.value.initGetPrivacySetting()
  69. tautology()
  70. }
  71. onLoad(async (option) => {
  72. argument.value = option || {}
  73. console.log('option', argument.value)
  74. uni.getSystemInfo({
  75. success: (info) => {
  76. user.setSystemInfo(info)
  77. },
  78. fail: (err) => {
  79. user.setSystemInfo({})
  80. }
  81. })
  82. tautology()
  83. })
  84. </script>
  85. <style lang="scss" scoped>
  86. .welcome {
  87. .wrap {
  88. width: 200px;
  89. height: 60px;
  90. position: absolute;
  91. left: 50%;
  92. top: 50%;
  93. transform: translate(-50%, -50%);
  94. .circle {
  95. width: 20px;
  96. height: 20px;
  97. position: absolute;
  98. border-radius: 50%;
  99. background-color: var(--primary);
  100. left: 15%;
  101. transform-origin: 50%;
  102. animation: circle 0.5s alternate infinite ease;
  103. }
  104. @keyframes circle {
  105. 0% {
  106. top: 60px;
  107. height: 5px;
  108. border-radius: 50px 50px 25px 25px;
  109. transform: scaleX(1.7);
  110. }
  111. 40% {
  112. height: 20px;
  113. border-radius: 50%;
  114. transform: scaleX(1);
  115. }
  116. 100% {
  117. top: 0%;
  118. }
  119. }
  120. .circle:nth-child(2) {
  121. left: 45%;
  122. animation-delay: 0.2s;
  123. }
  124. .circle:nth-child(3) {
  125. left: auto;
  126. right: 15%;
  127. animation-delay: 0.3s;
  128. }
  129. .shadow {
  130. width: 20px;
  131. height: 4px;
  132. border-radius: 50%;
  133. background-color: rgba(0, 0, 0, 0.5);
  134. position: absolute;
  135. top: 62px;
  136. transform-origin: 50%;
  137. z-index: -1;
  138. left: 15%;
  139. filter: blur(1px);
  140. animation: shadow 0.5s alternate infinite ease;
  141. }
  142. @keyframes shadow {
  143. 0% {
  144. transform: scaleX(1.5);
  145. }
  146. 40% {
  147. transform: scaleX(1);
  148. opacity: 0.7;
  149. }
  150. 100% {
  151. transform: scaleX(0.2);
  152. opacity: 0.4;
  153. }
  154. }
  155. .shadow:nth-child(4) {
  156. left: 45%;
  157. animation-delay: 0.2s;
  158. }
  159. .shadow:nth-child(5) {
  160. left: auto;
  161. right: 15%;
  162. animation-delay: 0.3s;
  163. }
  164. text {
  165. position: absolute;
  166. top: 75px;
  167. font-family: 'Lato';
  168. font-size: 18px;
  169. letter-spacing: 12px;
  170. color: var(--primary);
  171. left: 15%;
  172. }
  173. }
  174. }
  175. </style>