index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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 * 100}}%</view>
  50. <view class="tip grenn" v-if="ls.up == 0 || ls.up < 0">{{ls.up * 100}}%</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. obj.list = data;
  112. });
  113. },
  114. /**
  115. * 统一跳转接口,拦截未登录路由
  116. * navigator标签现在默认没有转场动画,所以用view
  117. */
  118. navTo(url) {
  119. uni.navigateTo({
  120. url
  121. });
  122. },
  123. //轮播图
  124. swiperChange(e) {
  125. let index = e.detail.current;
  126. this.swiperCurrent = index;
  127. },
  128. }
  129. };
  130. </script>
  131. <style lang="scss">
  132. page {
  133. min-height: 100%;
  134. background-color: #ffffff;
  135. .container {
  136. width: 100%;
  137. padding: 25rpx 40rpx;
  138. }
  139. }
  140. .tiele-index{
  141. font-weight: 500;
  142. font-size: 50rpx;
  143. padding: 15% 0rpx 30rpx 0rpx;
  144. }
  145. .top-head {
  146. position: fixed;
  147. top: 0;
  148. z-index: 99;
  149. width: 100%;
  150. background-color: #272f41;
  151. padding: 15rpx 35rpx;
  152. color: #edc959;
  153. image {
  154. width: 80rpx;
  155. height: 80rpx;
  156. }
  157. .top-name {
  158. padding-left: 15rpx;
  159. }
  160. }
  161. //轮播图
  162. .swiper {
  163. width: 100%;
  164. display: flex;
  165. justify-content: center;
  166. border-radius: 15rpx;
  167. .swiper-box {
  168. width: 100%;
  169. height: 335rpx;
  170. overflow: hidden;
  171. // box-shadow: 0upx 8upx 25upx rgba(0, 0, 0, 0.2);
  172. //兼容ios,微信小程序
  173. border-radius: 15rpx;
  174. position: relative;
  175. z-index: 1;
  176. swiper {
  177. width: 100%;
  178. height: 100%;
  179. swiper-item {
  180. image {
  181. width: 100%;
  182. height: 100%;
  183. border-radius: 15rpx;
  184. }
  185. }
  186. }
  187. .indicator {
  188. position: absolute;
  189. bottom: 20upx;
  190. left: 20upx;
  191. background-color: rgba(255, 255, 255, 0.4);
  192. width: 150upx;
  193. height: 5upx;
  194. border-radius: 3upx;
  195. overflow: hidden;
  196. display: flex;
  197. .dots {
  198. width: 0upx;
  199. background-color: rgba(255, 255, 255, 1);
  200. transition: all 0.3s ease-out;
  201. &.on {
  202. width: (100%/3);
  203. }
  204. }
  205. }
  206. }
  207. }
  208. .notice-box{
  209. padding: 40rpx 0rpx;
  210. .notice-title{
  211. padding-bottom: 30rpx;
  212. image{
  213. width:35rpx;
  214. height: 32rpx;
  215. }
  216. .title{
  217. font-size: 34rpx;
  218. font-weight: bold;
  219. font-style: italic;
  220. color: #333333;
  221. margin-left: 15rpx;
  222. }
  223. }
  224. .notice-list{
  225. .notice-tpl{
  226. image{
  227. width: 99rpx;
  228. height: 113rpx;
  229. }
  230. .name{
  231. font-size: 26rpx;
  232. color: #5D616D;
  233. }
  234. }
  235. }
  236. }
  237. .logo-img{
  238. width: 100%;
  239. height: 210rpx;
  240. }
  241. .quotation-list{
  242. display: flex;
  243. flex-wrap: wrap;
  244. .quotation-tpl{
  245. position: relative;
  246. padding: 22rpx 24rpx;
  247. height: 220rpx;
  248. overflow: hidden;
  249. display: flex;
  250. flex-direction: column;
  251. width:31%;
  252. margin-bottom: 4%;
  253. margin-right: 2%;
  254. // &:nth-child(2n + 1) {
  255. // margin-right: 2%;
  256. // }
  257. .tpl{
  258. z-index: 99;
  259. position: relative;
  260. font-size: 24rpx;
  261. padding-bottom: 10rpx;
  262. }
  263. .title{
  264. color: #333333;
  265. font-weight: bold;
  266. padding-bottom: 21rpx !important;
  267. }
  268. .num{
  269. color: #FB3A2F;
  270. }
  271. .money{
  272. color: #666666;
  273. }
  274. .tip-box{
  275. image{
  276. width: 100%;
  277. height: 118rpx;
  278. position: absolute;
  279. bottom: 0;
  280. left: 0;
  281. }
  282. .tip{
  283. position: relative;
  284. color: #FB3A2F;
  285. font-size: 26rpx;
  286. text-align: center;
  287. font-weight: 600;
  288. padding-top: 25rpx;
  289. }
  290. .grenn{
  291. color: #606266;
  292. }
  293. }
  294. }
  295. }
  296. .list-box{
  297. image{
  298. width: 326rpx;
  299. height: 210rpx;
  300. }
  301. }
  302. </style>