index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <view class="container">
  3. <view class="top flex">
  4. <view class="icon1 flex">
  5. <image class="img margin-r-10" src="../../static/shouye/shouye1.png" mode="scaleToFill"></image>
  6. <text class="tet">{{$t('login.a0')}}</text>
  7. </view>
  8. <view class="flex">
  9. <view class="icon2 text margin-r-10" v-if="userInfo.nickname">
  10. {{userInfo.nickname}}
  11. </view>
  12. <view class="icon1 margin-r-10">
  13. <image class="langTip" src="../../static/shouye/shouye2.png" mode="scaleToFill"></image>
  14. </view>
  15. <view class="text1 margin-r-10">
  16. <picker :range="langList" range-key='label' @change="selectLang">
  17. <view>{{label}}</view>
  18. </picker>
  19. </view>
  20. <view class="icon1">
  21. <image class="langTipDom" src="../../static/shouye/shouye3.png" mode="scaleToFill"></image>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 轮播图 -->
  26. <view class="uni-margin-wrap margin-b-10">
  27. <swiper indicator-color='rgba(255,255,255,0.69)' indicator-active-color='#FFF' class="swiper" circular
  28. :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
  29. <swiper-item class="swiper-box">
  30. <image class="swiper-item" src="../../static/shouye/shouye4.png" mode="scaleToFill"></image>
  31. </swiper-item>
  32. <swiper-item class="swiper-box">
  33. <image class="swiper-item" src="../../static/shouye/shouye4.png" mode="scaleToFill"></image>
  34. </swiper-item>
  35. </swiper>
  36. </view>
  37. <!-- 底部 -->
  38. <view class="tra flex margin-b-10">
  39. <view class="tra-item">
  40. {{$t('home.b8')}}
  41. </view>
  42. <view class="tra-item">
  43. {{$t('home.k1')}}
  44. </view>
  45. <view class="tra-item">
  46. {{$t('home.b0')}}
  47. </view>
  48. </view>
  49. <!-- 每一项 -->
  50. <view class="list flex" v-for="(item,ind) in navList">
  51. <view class="list-item flex-start">
  52. <!-- <image class="img margin-r-10" :src="item.img" mode="scaleToFill"> </image> -->
  53. <text class="tli">{{item.name}}</text>
  54. </view>
  55. <view class="list-item">
  56. {{item.newVlaue}}
  57. </view>
  58. <view class="list-item flex items-right">
  59. <view class="box" :class="{green:item.new24Value>0,red:item.new24Value<=0}">
  60. {{item.new24Value}}
  61. </view>
  62. </view>
  63. </view>
  64. <taber tab='index'></taber>
  65. </view>
  66. </template>
  67. <script>
  68. import {
  69. prices
  70. } from "@/api/index.js"
  71. import {
  72. mapState,
  73. mapActions
  74. } from "vuex";
  75. import taber from "@/components/footer/footer.vue";
  76. export default {
  77. components: {
  78. taber
  79. },
  80. data() {
  81. return {
  82. indicatorDots: true,
  83. autoplay: true,
  84. interval: 5000,
  85. duration: 500,
  86. navList: [],
  87. timeout:'',
  88. }
  89. },
  90. computed: {
  91. ...mapState({
  92. langList: "langList",
  93. lang: "lang",
  94. }),
  95. ...mapState('user', ['userInfo']),
  96. label() {
  97. const label = this.langList.find((item) => {
  98. console.log(this.lang, item.value);
  99. return item.value == this.lang
  100. }).label;
  101. return label
  102. }
  103. },
  104. filters: {
  105. decimalPlaces(value) {
  106. if (typeof value !== 'number') {
  107. return value;
  108. }
  109. return value.toFixed(5);
  110. }
  111. },
  112. onLoad(option) {
  113. // #ifndef MP
  114. if (option.spread) {
  115. // 存储其他邀请人
  116. uni.setStorageSync('spread', option.spread);
  117. }
  118. // #endif
  119. // #ifdef MP
  120. if (option.scene) {
  121. // 存储小程序邀请人
  122. uni.setStorage({
  123. key: 'spread_code',
  124. data: option.scene
  125. });
  126. }
  127. // #endif
  128. this.loadData()
  129. },
  130. onShow() {
  131. this.timeout = setInterval(this.loadData,60000)
  132. },
  133. onHide() {
  134. clearInterval(this.timeout);
  135. },
  136. methods: {
  137. ...mapActions({
  138. setLang: "setLang",
  139. }),
  140. getCurrent() {
  141. let pages = getCurrentPages();
  142. let curPage = pages[pages.length - 1];
  143. return curPage
  144. },
  145. selectLang(value) {
  146. this.setLang(this.langList[value.detail.value].value);
  147. let path = '/' + this.getCurrent().route
  148. },
  149. loadData(source) {
  150. //这里是将订单挂载到tab列表下
  151. const that = this;
  152. prices({})
  153. .then(({
  154. data
  155. }) => {
  156. let arr = [];
  157. for (let key in data.prices) {
  158. let item = data.prices[key];
  159. let ar = item.data[0];
  160. arr.push({
  161. name: key,
  162. newVlaue: ar.idxPx,
  163. new24Value: Number(((ar.idxPx - ar.open24h) / ar.open24h).toFixed(5))
  164. })
  165. }
  166. that.navList = arr
  167. })
  168. .catch(e => {
  169. console.log(e);
  170. });
  171. },
  172. },
  173. }
  174. </script>
  175. <style lang="scss">
  176. .container {
  177. width: 100%;
  178. background-color: #000000;
  179. padding-top: var(--status-bar-height);
  180. }
  181. .top {
  182. font-weight: 500;
  183. padding: 40rpx 30rpx 24rpx 30rpx;
  184. line-height: 1;
  185. .icon1 {
  186. line-height: 0;
  187. .img {
  188. width: 47rpx;
  189. height: 47rpx;
  190. }
  191. .tet {
  192. font-size: 28rpx;
  193. color: #C3A76C;
  194. }
  195. }
  196. .icon2 {
  197. background: #292C3D;
  198. border: 2px solid #414243;
  199. border-radius: 21rpx;
  200. }
  201. .langTip {
  202. width: 34rpx;
  203. height: 34rpx;
  204. }
  205. .langTipDom {
  206. width: 23rpx;
  207. height: 15rpx;
  208. }
  209. .text {
  210. font-size: 24rpx;
  211. color: #FFFFFF;
  212. padding: 10rpx 20rpx;
  213. }
  214. .text1 {
  215. font-size: 24rpx;
  216. color: #FFFFFF;
  217. }
  218. }
  219. .uni-margin-wrap {
  220. height: 394rpx;
  221. .swiper {
  222. height: 100%;
  223. .swiper-box {
  224. height: 100%;
  225. text-align: center;
  226. .swiper-item {
  227. width: 100%;
  228. height: 100%;
  229. }
  230. }
  231. }
  232. }
  233. .tra {
  234. height: 93rpx;
  235. background: #2B2A26;
  236. padding: 0 30rpx;
  237. font-size: 24rpx;
  238. color: #999999;
  239. .tra-item {
  240. width: 33.3%;
  241. }
  242. .tra-item:nth-child(2) {
  243. text-align: center;
  244. }
  245. .tra-item:nth-child(3) {
  246. text-align: right;
  247. }
  248. }
  249. .list {
  250. font-weight: bold;
  251. font-size: 30rpx;
  252. color: #FFFFFF;
  253. padding: 20rpx 30rpx 20rpx 30rpx;
  254. line-height: 1;
  255. border-bottom: 1px solid #2B2A26;
  256. .list-item:nth-child(2) {
  257. text-align: center;
  258. }
  259. .list-item:nth-child(3) {
  260. text-align: right;
  261. }
  262. .list-item {
  263. width: 33.3%;
  264. .box {
  265. padding: 20rpx 0;
  266. min-width: 150rpx;
  267. text-align: center;
  268. border-radius: 10rpx;
  269. &.red {
  270. background-color: $uni-color-error;
  271. }
  272. &.green {
  273. background-color: $color-green;
  274. }
  275. }
  276. .img {
  277. width: 60rpx;
  278. height: 60rpx;
  279. }
  280. .button {
  281. padding: 10rpx 20rpx;
  282. border-radius: 10rpx;
  283. min-width: 150rpx;
  284. text-align: center;
  285. display: inline-block;
  286. &.up {
  287. background: #FB5E57;
  288. }
  289. &.dom {
  290. background: #77DA90;
  291. }
  292. }
  293. }
  294. }
  295. </style>