index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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" mode="scaleToFill" @error="imgerror($event,item)" />
  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="isShowIllegality" 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" v-if="isShowIllegality">
  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. },
  109. onLoad() {
  110. this.loadData();
  111. // this.getTicket();
  112. },
  113. computed: {
  114. ...mapState(["isShowIllegality"])
  115. },
  116. methods: {
  117. ...mapMutations(['setLat', 'setLon', 'setChoose','changeState']),
  118. imgerror(data,item){
  119. setTimeout(()=>{
  120. item.pic = item.pic+`?time=${(new Date).getTime()}`
  121. },1000)
  122. },
  123. goDetails(e) {
  124. uni.navigateTo({
  125. url: '/pages/index/messageInfo?id=' + this.article[e].id
  126. });
  127. },
  128. getTicket() {
  129. getTicket()
  130. .then(
  131. (res) => {
  132. console.log(res);
  133. this.ticketBase = res.data.v||{};
  134. this.ticketBase.CurrentGains = +this.ticketBase.CurrentGains
  135. }
  136. ).catch(
  137. (err) => {
  138. console.log(err);
  139. }
  140. )
  141. },
  142. loadData() {
  143. article({}, 6).then(({
  144. data
  145. }) => {
  146. this.text = data.map((re) => {
  147. return re.synopsis
  148. })
  149. this.article = data;
  150. });
  151. loadIndexs({})
  152. .then(({
  153. data
  154. }) => {
  155. let goods = data.info;
  156. this.dataList = goods.bastList; //精品推荐
  157. this.carouselList = data.banner;
  158. })
  159. .catch(e => {});
  160. },
  161. nav(url) {
  162. uni.navigateTo({
  163. url,
  164. fail() {
  165. uni.switchTab({
  166. url
  167. });
  168. }
  169. });
  170. },
  171. //轮播图切换修改背景色
  172. swiperChange(e) {
  173. const index = e.detail.current;
  174. this.swiperCurrent = index;
  175. this.titleNViewBackground = this.carouselList[index].background;
  176. },
  177. // 點擊搜索框
  178. clickSearch() {
  179. uni.navigateTo({
  180. url: '/pages/product/search'
  181. });
  182. },
  183. }
  184. };
  185. </script>
  186. <style lang="scss">
  187. .box {
  188. border-radius: 10rpx;
  189. line-height: 1;
  190. margin: 0 30rpx;
  191. background-image: url("../../static/img/indwxWp.png");
  192. background-size: 100% auto;
  193. background-repeat: no-repeat;
  194. position: relative;
  195. height: 230rpx;
  196. align-items: stretch;
  197. .leftbox {
  198. flex-grow: 1;
  199. padding: 20rpx 0;
  200. flex-direction: column;
  201. .title {
  202. padding: 6rpx 20rpx;
  203. border-radius: 50rpx;
  204. font-size: $font-sm;
  205. color: #FFF;
  206. border: 1px solid #FFF;
  207. }
  208. .num {
  209. font-size: $font-lg;
  210. text-align: center;
  211. color: $color-red;
  212. height: 80rpx;
  213. .onStrong {
  214. font-size: 36rpx;
  215. }
  216. .chines {
  217. color: #FFF;
  218. }
  219. .tip {
  220. width: 80rpx;
  221. height: 6rpx;
  222. &.tipr {
  223. transform: rotate(180deg);
  224. }
  225. }
  226. }
  227. }
  228. .right {
  229. flex-shrink: 0;
  230. width: 200rpx;
  231. flex-direction: column;
  232. color: #FFF;
  233. .righttext {
  234. width: 130rpx;
  235. height: 130rpx;
  236. border-radius: 1000rpx;
  237. border: 1px solid #FFF;
  238. .rightNumBox {
  239. font-size: 40rpx;
  240. }
  241. }
  242. .text {
  243. margin-top: 20rpx;
  244. font-size: $font-sm;
  245. text-shadow: 2px 2px 1px red;
  246. }
  247. }
  248. }
  249. page,
  250. .center {
  251. min-height: 100%;
  252. height: auto;
  253. background: #ffffff;
  254. }
  255. .vheigh {
  256. height: var(--status-bar-height);
  257. background-color: $base-color;
  258. }
  259. .top {
  260. position: relative;
  261. width: 100%;
  262. height: 360rpx;
  263. .top-bg {
  264. position: absolute;
  265. top: 0;
  266. left: 0;
  267. right: 0;
  268. width: 100%;
  269. height: 100%;
  270. }
  271. .top-main {
  272. position: relative;
  273. z-index: 2;
  274. padding: 30rpx;
  275. .search-box {
  276. justify-content: center;
  277. width: 698rpx;
  278. height: 60rpx;
  279. background: rgba(255, 240, 245, 0.4);
  280. box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  281. border-radius: 30rpx;
  282. .search {
  283. width: 34rpx;
  284. height: 34rpx;
  285. }
  286. .search-font {
  287. margin-left: 14rpx;
  288. font-size: 28rpx;
  289. font-family: PingFang SC;
  290. font-weight: 500;
  291. color: #ffffff;
  292. }
  293. }
  294. }
  295. }
  296. .carousel {
  297. width: 700rpx;
  298. height: 276rpx;
  299. /* #ifndef APP-PLUS */
  300. margin: -240rpx auto 0;
  301. /* #endif */
  302. /* #ifdef APP-PLUS */
  303. margin: -180rpx auto 0;
  304. /* #endif */
  305. border-radius: 40rpx;
  306. image {
  307. border-radius: 40rpx;
  308. width: 700rpx;
  309. height: 276rpx;
  310. }
  311. }
  312. .tongz {
  313. width: 690rpx;
  314. height: 70rpx;
  315. margin: 32rpx auto 0;
  316. padding: 18rpx 30rpx 18rpx 24rpx;
  317. align-items: center;
  318. position: relative;
  319. .tongz-bg {
  320. position: absolute;
  321. top: 0;
  322. right: 0;
  323. left: 0;
  324. width: 690rpx;
  325. height: 70rpx;
  326. image {
  327. width: 100%;
  328. height: 100%;
  329. }
  330. }
  331. .tongz-left {
  332. width: 640rpx;
  333. .image-left {
  334. width: 28rpx;
  335. height: 34rpx;
  336. }
  337. .tongz-font {
  338. margin-left: 22rpx;
  339. font-size: 28rpx;
  340. font-family: Source Han Sans CN;
  341. font-weight: 400;
  342. color: #0f253a;
  343. }
  344. }
  345. .tongz-right {
  346. position: relative;
  347. z-index: 11;
  348. width: 12rpx;
  349. height: 26rpx;
  350. image {
  351. width: 100%;
  352. height: 100%;
  353. }
  354. }
  355. }
  356. .nav-item {
  357. width: 698rpx;
  358. height: 219rpx;
  359. background: linear-gradient(150deg, #F5BE41 0%, #DF4226 100%);
  360. border-radius: 14rpx;
  361. margin: 40rpx auto 0;
  362. .nav-img {
  363. width: 100%;
  364. height: 100%;
  365. border-radius: 14rpx;
  366. }
  367. }
  368. .btm {
  369. position: fixed;
  370. bottom: 0;
  371. width: 100%;
  372. height: 50rpx;
  373. line-height: 50rpx;
  374. text-align: center;
  375. .a-pm {
  376. text-decoration: none;
  377. width: 100%;
  378. height: 50rpx;
  379. line-height: 50rpx;
  380. color: navigator;
  381. }
  382. }
  383. </style>