index.vue 3.5 KB

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