index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view class="center">
  3. <view class="top">
  4. <view class="vheigh"></view>
  5. <image class="top-bg" src="../../static/img/top-bg.png" mode=""></image>
  6. <view class="top-main flex">
  7. <view class="search-box flex" @click="clickSearch()">
  8. <image class="search" src="../../static/img/search.png" mode=""></image>
  9. <view class="search-font">输入关键词搜索</view>
  10. </view>
  11. </view>
  12. </view>
  13. <swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  14. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  15. @click="bannerNavToUrl(item)">
  16. <image :src="item.pic" />
  17. </swiper-item>
  18. </swiper>
  19. <view class="tongz flex">
  20. <view>
  21. <view class="tongz-bg">
  22. <image src="../../static/img/tongz-bg.png" mode=""></image>
  23. </view>
  24. <view class="tongz-left flex">
  25. <image class="image-left" src="../../static/img/ling.png" mode=""></image>
  26. <u-notice-bar style="width: 100%;" mode="vertical" type="none" :volume-icon="false"
  27. :more-icon="true" :list="text" @click="goDetails"
  28. @getMore="nav('/pages/index/message?type=6')"></u-notice-bar>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="navbar">
  33. <view class="nav-item" @click="nav('/pages/index/index')">
  34. <image class="nav-img" src="../../static/img/newbanner.png" mode=""></image>
  35. </view>
  36. <!-- <view v-if="changeState" class="nav-item" @click="nav('/pages/navigation/main')">
  37. <image class="nav-img" src="../../static/img/oldbanner.png" mode=""></image>
  38. </view> -->
  39. </view>
  40. <!-- <view class="box margin-t-30 flex">
  41. <view class="leftbox flex">
  42. <view class="flex-center">
  43. <view class="title">
  44. {{ticketBase.fullname}}
  45. </view>
  46. </view>
  47. <view class="num flex">
  48. <image class="tip" src="../../static/img/wpicon.png" mode="scaleToFill"></image>
  49. <text class="chines margin-l-10">
  50. 价格(CNY):
  51. </text>
  52. <text class="onStrong margin-r-10">
  53. {{ticketBase.CurPrice}}
  54. </text>
  55. <image class="tip tipr" src="../../static/img/wpicon.png" mode="scaleToFill"></image>
  56. </view>
  57. </view>
  58. <view class="right flex-center">
  59. <view class="righttext flex-center">
  60. <view class="rightNumBox">
  61. <text class="font-size-sm" v-if="ticketBase.CurrentGains>0">+</text>
  62. <text class="font-size-sm" v-if="ticketBase.CurrentGains<0">-</text>
  63. {{ticketBase.CurrentGains}}
  64. <text class="font-size-sm">%</text>
  65. </view>
  66. </view>
  67. <view class="text">
  68. 24小时涨跌幅
  69. </view>
  70. </view>
  71. </view> -->
  72. <!-- #ifdef H5 -->
  73. <view class="btm">
  74. <a href="https://beian.miit.gov.cn" class="a-pm">备案编号:浙ICP备2022017146号 </a>
  75. </view>
  76. <!-- #endif -->
  77. </view>
  78. </template>
  79. <script>
  80. import {
  81. loadIndexs,
  82. store_list
  83. } from '@/api/index.js';
  84. import {
  85. getTicket
  86. } from '@/api/quick.js';
  87. import {
  88. mapState,
  89. mapMutations
  90. } from 'vuex';
  91. import {
  92. article
  93. } from '@/api/user.js';
  94. export default {
  95. data() {
  96. return {
  97. current: 0,
  98. titleNViewBackground: '',
  99. swiperCurrent: 0,
  100. swiperLength: 0,
  101. carouselList: [], //轮播图列表
  102. text: [],
  103. ticketBase: {},
  104. article: [],
  105. };
  106. },
  107. onShow() {
  108. this.loadData();
  109. this.getTicket()
  110. },
  111. onLoad() {},
  112. methods: {
  113. ...mapMutations(['setLat', 'setLon', 'setChoose','changeState']),
  114. goDetails(e) {
  115. uni.navigateTo({
  116. url: '/pages/index/messageInfo?id=' + this.article[e].id
  117. });
  118. },
  119. getTicket() {
  120. getTicket()
  121. .then(
  122. (res) => {
  123. console.log(res);
  124. this.ticketBase = res.data.v;
  125. this.ticketBase.CurrentGains = +this.ticketBase.CurrentGains
  126. }
  127. ).catch(
  128. (err) => {
  129. console.log(err);
  130. }
  131. )
  132. },
  133. loadData() {
  134. article({}, 6).then(({
  135. data
  136. }) => {
  137. this.text = data.map((re) => {
  138. return re.synopsis
  139. })
  140. this.article = data;
  141. });
  142. loadIndexs({})
  143. .then(({
  144. data
  145. }) => {
  146. let goods = data.info;
  147. this.dataList = goods.bastList; //精品推荐
  148. this.carouselList = data.banner;
  149. })
  150. .catch(e => {});
  151. },
  152. nav(url) {
  153. uni.navigateTo({
  154. url,
  155. fail() {
  156. uni.switchTab({
  157. url
  158. });
  159. }
  160. });
  161. },
  162. //轮播图切换修改背景色
  163. swiperChange(e) {
  164. const index = e.detail.current;
  165. this.swiperCurrent = index;
  166. this.titleNViewBackground = this.carouselList[index].background;
  167. },
  168. // 點擊搜索框
  169. clickSearch() {
  170. uni.navigateTo({
  171. url: '/pages/product/search'
  172. });
  173. },
  174. }
  175. };
  176. </script>
  177. <style lang="scss">
  178. .box {
  179. border-radius: 10rpx;
  180. line-height: 1;
  181. margin: 0 30rpx;
  182. background-image: url("../../static/img/indwxWp.png");
  183. background-size: 100% auto;
  184. background-repeat: no-repeat;
  185. position: relative;
  186. height: 230rpx;
  187. align-items: stretch;
  188. .leftbox {
  189. flex-grow: 1;
  190. padding: 20rpx 0;
  191. flex-direction: column;
  192. .title {
  193. padding: 6rpx 20rpx;
  194. border-radius: 50rpx;
  195. font-size: $font-sm;
  196. color: #FFF;
  197. border: 1px solid #FFF;
  198. }
  199. .num {
  200. font-size: $font-lg;
  201. text-align: center;
  202. color: $color-red;
  203. height: 80rpx;
  204. .onStrong {
  205. font-size: 36rpx;
  206. }
  207. .chines {
  208. color: #FFF;
  209. }
  210. .tip {
  211. width: 80rpx;
  212. height: 6rpx;
  213. &.tipr {
  214. transform: rotate(180deg);
  215. }
  216. }
  217. }
  218. }
  219. .right {
  220. flex-shrink: 0;
  221. width: 200rpx;
  222. flex-direction: column;
  223. color: #FFF;
  224. .righttext {
  225. width: 130rpx;
  226. height: 130rpx;
  227. border-radius: 1000rpx;
  228. border: 1px solid #FFF;
  229. .rightNumBox {
  230. font-size: 40rpx;
  231. }
  232. }
  233. .text {
  234. margin-top: 20rpx;
  235. font-size: $font-sm;
  236. text-shadow: 2px 2px 1px red;
  237. }
  238. }
  239. }
  240. page,
  241. .center {
  242. min-height: 100%;
  243. height: auto;
  244. background: #ffffff;
  245. }
  246. .vheigh {
  247. height: var(--status-bar-height);
  248. background-color: $base-color;
  249. }
  250. .top {
  251. position: relative;
  252. width: 100%;
  253. height: 360rpx;
  254. .top-bg {
  255. position: absolute;
  256. top: 0;
  257. left: 0;
  258. right: 0;
  259. width: 100%;
  260. height: 100%;
  261. }
  262. .top-main {
  263. position: relative;
  264. z-index: 2;
  265. padding: 30rpx;
  266. .search-box {
  267. justify-content: center;
  268. width: 698rpx;
  269. height: 60rpx;
  270. background: rgba(255, 240, 245, 0.4);
  271. box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  272. border-radius: 30rpx;
  273. .search {
  274. width: 34rpx;
  275. height: 34rpx;
  276. }
  277. .search-font {
  278. margin-left: 14rpx;
  279. font-size: 28rpx;
  280. font-family: PingFang SC;
  281. font-weight: 500;
  282. color: #ffffff;
  283. }
  284. }
  285. }
  286. }
  287. .carousel {
  288. width: 700rpx;
  289. height: 276rpx;
  290. /* #ifndef APP-PLUS */
  291. margin: -240rpx auto 0;
  292. /* #endif */
  293. /* #ifdef APP-PLUS */
  294. margin: -180rpx auto 0;
  295. /* #endif */
  296. border-radius: 40rpx;
  297. image {
  298. border-radius: 40rpx;
  299. width: 700rpx;
  300. height: 276rpx;
  301. }
  302. }
  303. .tongz {
  304. width: 690rpx;
  305. height: 70rpx;
  306. margin: 32rpx auto 0;
  307. padding: 18rpx 30rpx 18rpx 24rpx;
  308. align-items: center;
  309. position: relative;
  310. .tongz-bg {
  311. position: absolute;
  312. top: 0;
  313. right: 0;
  314. left: 0;
  315. width: 690rpx;
  316. height: 70rpx;
  317. image {
  318. width: 100%;
  319. height: 100%;
  320. }
  321. }
  322. .tongz-left {
  323. width: 640rpx;
  324. .image-left {
  325. width: 28rpx;
  326. height: 34rpx;
  327. }
  328. .tongz-font {
  329. margin-left: 22rpx;
  330. font-size: 28rpx;
  331. font-family: Source Han Sans CN;
  332. font-weight: 400;
  333. color: #0f253a;
  334. }
  335. }
  336. .tongz-right {
  337. position: relative;
  338. z-index: 11;
  339. width: 12rpx;
  340. height: 26rpx;
  341. image {
  342. width: 100%;
  343. height: 100%;
  344. }
  345. }
  346. }
  347. .nav-item {
  348. width: 698rpx;
  349. height: 219rpx;
  350. background: linear-gradient(150deg, #F5BE41 0%, #DF4226 100%);
  351. border-radius: 14rpx;
  352. margin: 40rpx auto 0;
  353. .nav-img {
  354. width: 100%;
  355. height: 100%;
  356. border-radius: 14rpx;
  357. }
  358. }
  359. .btm {
  360. position: fixed;
  361. bottom: 0;
  362. width: 100%;
  363. height: 50rpx;
  364. line-height: 50rpx;
  365. text-align: center;
  366. .a-pm {
  367. text-decoration: none;
  368. width: 100%;
  369. height: 50rpx;
  370. line-height: 50rpx;
  371. color: navigator;
  372. }
  373. }
  374. </style>