index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view class="container">
  3. <view class="tiele-index">首页</view>
  4. <view class="swiper">
  5. <view class="swiper-box">
  6. <swiper circular="true" autoplay="true" @change="swiperChange">
  7. <swiper-item v-for="swiper in banner" :key="swiper.id" @click="ToBanner(swiper)"><image :src="swiper.pic"></image></swiper-item>
  8. </swiper>
  9. <view class="indicator"><view class="dots" v-for="(swiper, index) in banner" :class="[swiperCurrent >= index ? 'on' : '']" :key="index"></view></view>
  10. </view>
  11. </view>
  12. <view class="notice-box">
  13. <view class="notice-title flex_item">
  14. <image src="../../static/img/img31.png"></image>
  15. <view class="title">通知</view>
  16. </view>
  17. <view class="notice-list flex">
  18. <view class="notice-tpl" @click="navTo('/pages/index/information')">
  19. <image src="../../static/img/img02.png"></image>
  20. <view class="name">行业资讯</view>
  21. </view>
  22. <view class="notice-tpl" @click="navTo('/pages/index/pingtai')"> <!-- @click="navTo('/pages/index/introduce')" -->
  23. <image src="../../static/img/img03.png"></image>
  24. <view class="name">平台介绍</view>
  25. </view>
  26. <view class="notice-tpl" @click="navTo('/pages/index/notice')">
  27. <image src="../../static/img/img04.png"></image>
  28. <view class="name">通知公告</view>
  29. </view>
  30. <view class="notice-tpl" @click="navTo('/pages/index/share')">
  31. <image src="../../static/img/img05.png"></image>
  32. <view class="name">分享好友</view>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- <image class="logo-img" @click="navTo('/pages/index/information')" src="../../static/img/img44.png"></image> -->
  37. <view class="notice-box">
  38. <view class="notice-title flex_item">
  39. <image src="../../static/img/img32.png"></image>
  40. <view class="title">行情</view>
  41. </view>
  42. <view class="quotation-list">
  43. <view class="quotation-tpl" v-for="(ls,index) in list" :key='index' v-if="ls.name!='USDT'">
  44. <view class="tpl title">{{ls.name}}/USDT</view>
  45. <view class="tpl num">{{ls.usdt}}</view>
  46. <view class="tpl money">¥{{ls.price}}</view>
  47. <view class="tip-box">
  48. <image src="../../static/img/img30.png"></image>
  49. <view class="tip" v-if="ls.up > 0">{{ls.up }}%</view>
  50. <view class="tip grenn" v-if="ls.up == 0 || ls.up < 0">{{ls.up }}%</view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="list-box flex">
  56. <image src="../../static/img/img45.png"></image>
  57. <image src="../../static/img/img46.png"></image>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import { interceptor } from '@/utils/loginUtils';
  63. import { loadIndexs,moneyType } from '@/api/index.js';
  64. import { mapState } from 'vuex';
  65. export default {
  66. data() {
  67. return {
  68. swiperCurrent: 0,
  69. banner: [],
  70. list:''
  71. };
  72. },
  73. computed: {
  74. ...mapState(['loginInterceptor','hasLogin']),
  75. },
  76. onLoad: function(option) {
  77. if (option.spread) {
  78. // 存储其他邀请人
  79. uni.setStorageSync('spread', option.spread);
  80. }
  81. },
  82. onShow: function() {
  83. // 判断是否强制登录
  84. if (this.loginInterceptor && !this.hasLogin) {
  85. // 登录拦截
  86. interceptor();
  87. }else{
  88. this.loadData();
  89. this.moneyType();
  90. }
  91. },
  92. //下拉刷新
  93. onPullDownRefresh() {
  94. this.loadData();
  95. this.moneyType();
  96. setTimeout(function () {
  97. uni.stopPullDownRefresh();
  98. }, 1000);
  99. },
  100. methods: {
  101. // 请求载入数据
  102. async loadData() {
  103. let obj = this;
  104. loadIndexs({}).then(({ data }) => {
  105. obj.banner = data.banner;
  106. });
  107. },
  108. moneyType(){
  109. let obj = this;
  110. moneyType({index:1}).then(({ data }) => {
  111. console.log(data)
  112. obj.list = data;
  113. obj.list.forEach((e,index) => {
  114. e.up = parseFloat(e.up*100).toFixed(2);
  115. });
  116. });
  117. },
  118. /**
  119. * 统一跳转接口,拦截未登录路由
  120. * navigator标签现在默认没有转场动画,所以用view
  121. */
  122. navTo(url) {
  123. uni.navigateTo({
  124. url
  125. });
  126. },
  127. //轮播图
  128. swiperChange(e) {
  129. let index = e.detail.current;
  130. this.swiperCurrent = index;
  131. },
  132. }
  133. };
  134. </script>
  135. <style lang="scss">
  136. page {
  137. min-height: 100%;
  138. background-color: #ffffff;
  139. .container {
  140. width: 100%;
  141. padding: 25rpx 40rpx;
  142. }
  143. }
  144. .tiele-index{
  145. font-weight: 500;
  146. font-size: 50rpx;
  147. padding: 15% 0rpx 30rpx 0rpx;
  148. }
  149. .top-head {
  150. position: fixed;
  151. top: 0;
  152. z-index: 99;
  153. width: 100%;
  154. background-color: #272f41;
  155. padding: 15rpx 35rpx;
  156. color: #edc959;
  157. image {
  158. width: 80rpx;
  159. height: 80rpx;
  160. }
  161. .top-name {
  162. padding-left: 15rpx;
  163. }
  164. }
  165. //轮播图
  166. .swiper {
  167. width: 100%;
  168. display: flex;
  169. justify-content: center;
  170. border-radius: 15rpx;
  171. .swiper-box {
  172. width: 100%;
  173. height: 335rpx;
  174. overflow: hidden;
  175. // box-shadow: 0upx 8upx 25upx rgba(0, 0, 0, 0.2);
  176. //兼容ios,微信小程序
  177. border-radius: 15rpx;
  178. position: relative;
  179. z-index: 1;
  180. swiper {
  181. width: 100%;
  182. height: 100%;
  183. swiper-item {
  184. image {
  185. width: 100%;
  186. height: 100%;
  187. border-radius: 15rpx;
  188. }
  189. }
  190. }
  191. .indicator {
  192. position: absolute;
  193. bottom: 20upx;
  194. left: 20upx;
  195. background-color: rgba(255, 255, 255, 0.4);
  196. width: 150upx;
  197. height: 5upx;
  198. border-radius: 3upx;
  199. overflow: hidden;
  200. display: flex;
  201. .dots {
  202. width: 0upx;
  203. background-color: rgba(255, 255, 255, 1);
  204. transition: all 0.3s ease-out;
  205. &.on {
  206. width: (100%/3);
  207. }
  208. }
  209. }
  210. }
  211. }
  212. .notice-box{
  213. padding: 40rpx 0rpx;
  214. .notice-title{
  215. padding-bottom: 30rpx;
  216. image{
  217. width:35rpx;
  218. height: 32rpx;
  219. }
  220. .title{
  221. font-size: 34rpx;
  222. font-weight: bold;
  223. font-style: italic;
  224. color: #333333;
  225. margin-left: 15rpx;
  226. }
  227. }
  228. .notice-list{
  229. .notice-tpl{
  230. image{
  231. width: 99rpx;
  232. height: 113rpx;
  233. }
  234. .name{
  235. font-size: 26rpx;
  236. color: #5D616D;
  237. }
  238. }
  239. }
  240. }
  241. .logo-img{
  242. width: 100%;
  243. height: 210rpx;
  244. }
  245. .quotation-list{
  246. display: flex;
  247. flex-wrap: wrap;
  248. .quotation-tpl{
  249. position: relative;
  250. padding: 22rpx 24rpx;
  251. height: 220rpx;
  252. overflow: hidden;
  253. display: flex;
  254. flex-direction: column;
  255. width:31%;
  256. margin-bottom: 4%;
  257. margin-right: 2%;
  258. // &:nth-child(2n + 1) {
  259. // margin-right: 2%;
  260. // }
  261. .tpl{
  262. z-index: 99;
  263. position: relative;
  264. font-size: 24rpx;
  265. padding-bottom: 10rpx;
  266. }
  267. .title{
  268. color: #333333;
  269. font-weight: bold;
  270. padding-bottom: 21rpx !important;
  271. }
  272. .num{
  273. color: #FB3A2F;
  274. }
  275. .money{
  276. color: #666666;
  277. }
  278. .tip-box{
  279. image{
  280. width: 100%;
  281. height: 118rpx;
  282. position: absolute;
  283. bottom: 0;
  284. left: 0;
  285. }
  286. .tip{
  287. position: relative;
  288. color: #FB3A2F;
  289. font-size: 26rpx;
  290. text-align: center;
  291. font-weight: 600;
  292. padding-top: 25rpx;
  293. }
  294. .grenn{
  295. color: #606266;
  296. }
  297. }
  298. }
  299. }
  300. .list-box{
  301. image{
  302. width: 326rpx;
  303. height: 210rpx;
  304. }
  305. }
  306. </style>