index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="content" :rise-fall="stocksColor">
  3. <!-- 头部 -->
  4. <headContent>
  5. <template #left>
  6. <loginStatus></loginStatus>
  7. </template>
  8. <template #content>
  9. <view class="haed-title">
  10. <image src="../../static/images/logo.png" mode="aspectFit"></image>
  11. <image src="../../static/images/name.png" mode="aspectFit"></image>
  12. </view>
  13. </template>
  14. <template #right>
  15. <message></message>
  16. <share @openShare="openShare"></share>
  17. </template>
  18. </headContent>
  19. <!-- 轮播图 -->
  20. <carousels :BannerList="BannerList"></carousels>
  21. <!-- 滚动消息 -->
  22. <rollMessage :rollMsg="Announcement"></rollMessage>
  23. <view style="width: 100%;height: 1rpx;"></view>
  24. <!-- usdt -->
  25. <usdt :usdtList="usdtList"></usdt>
  26. <view style="width: 100%;height: 8rpx;"></view>
  27. <gap />
  28. <!-- 快捷买币 -->
  29. <shortcut></shortcut>
  30. <gap />
  31. <!-- 快捷菜单 -->
  32. <navMuen></navMuen>
  33. <!-- 自选 / 市场 -->
  34. <market :market="quotationNew"></market>
  35. <!-- 邀请 -->
  36. <sharePage ref="sharePageRef" :tabBar="false" />
  37. </view>
  38. </template>
  39. <script>
  40. import loginStatus from "@/components/headModules/login.vue"
  41. import message from "@/components/headModules/message.vue"
  42. import share from "@/components/headModules/share.vue"
  43. import usdt from "./modules/usdt.vue"
  44. import shortcut from "./modules/shortcut.vue"
  45. import navMuen from "./modules/nav.vue"
  46. import market from "./modules/market.vue"
  47. import {
  48. Api_getNewsList,
  49. Api_getQuotationNew
  50. } from "@/api/index.js"
  51. import {
  52. mapGetters
  53. } from 'vuex'
  54. export default {
  55. components: {
  56. loginStatus,
  57. message,
  58. share,
  59. usdt,
  60. shortcut,
  61. navMuen,
  62. market
  63. },
  64. data() {
  65. return {
  66. usdtList: [],
  67. title: 'Hello',
  68. BannerList: [],
  69. Announcement: [],
  70. quotationNew: [],
  71. refreshStatus: false,
  72. }
  73. },
  74. computed: {
  75. ...mapGetters([
  76. 'stocksColor'
  77. ]),
  78. },
  79. watch: {
  80. quotationNew: {
  81. handler(newArr) {
  82. this.usdtList = [];
  83. if (newArr && newArr.length > 0) {
  84. const nums = newArr.length > 3 ? 3 : newArr.length;
  85. this.usdtList = newArr.slice(0, nums);
  86. } else {
  87. this.usdtList = []
  88. }
  89. },
  90. deep: true
  91. }
  92. },
  93. onLoad() {
  94. this.getBanner();
  95. this.getAnnouncement();
  96. },
  97. onShow() {
  98. this.refreshStatus = true;
  99. this.getQuotationNew();
  100. },
  101. onHide() {
  102. this.refreshStatus = false;
  103. console.log('00000' , this.refreshStatus)
  104. },
  105. methods: {
  106. openShare() {
  107. console.log('00000')
  108. this.$nextTick(() => {
  109. this.$refs.sharePageRef.openShare()
  110. })
  111. },
  112. // 获取banner
  113. getBanner() {
  114. Api_getNewsList({
  115. cid: 5,
  116. limit: 10
  117. }).then(res => {
  118. this.BannerList = res.list
  119. })
  120. },
  121. // 获取公告
  122. getAnnouncement() {
  123. Api_getNewsList({
  124. cid: 3,
  125. limit: 10
  126. }).then(res => {
  127. this.Announcement = res.list
  128. })
  129. },
  130. // 获取行情 / 首页推荐
  131. getQuotationNew() {
  132. Api_getQuotationNew().then(res => {
  133. if (res && res.length > 0) {
  134. this.quotationNew = res.find((item) => item.name == 'USDT').quotation || [];
  135. } else {
  136. this.quotationNew = []
  137. }
  138. }).catch(err => {
  139. this.quotationNew = [];
  140. }).finally(() => {
  141. setTimeout(() => {
  142. if (this.refreshStatus) {
  143. this.getQuotationNew()
  144. }
  145. }, 3000)
  146. })
  147. },
  148. clearInt() {
  149. try {
  150. clearInterval(this.timeInterval);
  151. } catch (e) {
  152. //TODO handle the exception
  153. }
  154. this.timeInterval = null;
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang="scss" scoped>
  160. .content {
  161. // padding: 0 30rpx;
  162. }
  163. .haed-title {
  164. image {
  165. width: 85rpx;
  166. height: 67rpx;
  167. }
  168. }
  169. </style>