welcome.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. if (sharePath.split('/').filter(item => item)[0] == 'pages') uni.switchTab(data)
  56. else uni.redirectTo(data)
  57. } else {
  58. uni.switchTab({
  59. url: `/pages/index/index`
  60. })
  61. }
  62. } catch (err) {
  63. console.log('err', err)
  64. errMsg.value = err.errMsg || err.msg || '加载失败,请重试'
  65. }
  66. }
  67. const handleRefresh = () => {
  68. isShowPopup.value = true
  69. privacyAgreementRef.value.initGetPrivacySetting()
  70. tautology()
  71. }
  72. onLoad(async (option) => {
  73. argument.value = option || {}
  74. console.log('option', argument.value)
  75. uni.getSystemInfo({
  76. success: (info) => {
  77. user.setSystemInfo(info)
  78. },
  79. fail: (err) => {
  80. user.setSystemInfo({})
  81. }
  82. })
  83. tautology()
  84. })
  85. </script>
  86. <style lang="scss" scoped>
  87. .welcome {
  88. .wrap {
  89. width: 200px;
  90. height: 60px;
  91. position: absolute;
  92. left: 50%;
  93. top: 50%;
  94. transform: translate(-50%, -50%);
  95. .circle {
  96. width: 20px;
  97. height: 20px;
  98. position: absolute;
  99. border-radius: 50%;
  100. background-color: var(--primary);
  101. left: 15%;
  102. transform-origin: 50%;
  103. animation: circle 0.5s alternate infinite ease;
  104. }
  105. @keyframes circle {
  106. 0% {
  107. top: 60px;
  108. height: 5px;
  109. border-radius: 50px 50px 25px 25px;
  110. transform: scaleX(1.7);
  111. }
  112. 40% {
  113. height: 20px;
  114. border-radius: 50%;
  115. transform: scaleX(1);
  116. }
  117. 100% {
  118. top: 0%;
  119. }
  120. }
  121. .circle:nth-child(2) {
  122. left: 45%;
  123. animation-delay: 0.2s;
  124. }
  125. .circle:nth-child(3) {
  126. left: auto;
  127. right: 15%;
  128. animation-delay: 0.3s;
  129. }
  130. .shadow {
  131. width: 20px;
  132. height: 4px;
  133. border-radius: 50%;
  134. background-color: rgba(0, 0, 0, 0.5);
  135. position: absolute;
  136. top: 62px;
  137. transform-origin: 50%;
  138. z-index: -1;
  139. left: 15%;
  140. filter: blur(1px);
  141. animation: shadow 0.5s alternate infinite ease;
  142. }
  143. @keyframes shadow {
  144. 0% {
  145. transform: scaleX(1.5);
  146. }
  147. 40% {
  148. transform: scaleX(1);
  149. opacity: 0.7;
  150. }
  151. 100% {
  152. transform: scaleX(0.2);
  153. opacity: 0.4;
  154. }
  155. }
  156. .shadow:nth-child(4) {
  157. left: 45%;
  158. animation-delay: 0.2s;
  159. }
  160. .shadow:nth-child(5) {
  161. left: auto;
  162. right: 15%;
  163. animation-delay: 0.3s;
  164. }
  165. text {
  166. position: absolute;
  167. top: 75px;
  168. font-family: 'Lato';
  169. font-size: 18px;
  170. letter-spacing: 12px;
  171. color: var(--primary);
  172. left: 15%;
  173. }
  174. }
  175. }
  176. </style>