index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <template>
  2. <view class="center">
  3. <!-- 顶部logo and 搜索 start-->
  4. <view class="status_bar"></view>
  5. <view class="top-search flex">
  6. <view class="search-box flex" @click="clickSearch()">
  7. <image class="search" src="../../static/icon/search-h.png" mode=""></image>
  8. <view class="search-font">输入关键词搜索</view>
  9. </view>
  10. </view>
  11. <!-- 顶部logo and 搜索 end-->
  12. <view class="jg"></view>
  13. <!-- 轮播图 start -->
  14. <view class="swiper-wrap">
  15. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  16. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  17. @click="bannerNavToUrl(item)">
  18. <image :src="item.pic" />
  19. </swiper-item>
  20. </swiper>
  21. </view>
  22. <!-- 轮播图 end -->
  23. <view class="jg"></view>
  24. <!-- 分类 start-->
  25. <view class="cate-section flex">
  26. <view class="cate-item flex" @click="nav('/pages/index/rxbd')">
  27. <view class="img-wrapper flex">
  28. <image src="../../static/icon/c1.png" mode=""></image>
  29. </view>
  30. <view class="item-title">热销榜</view>
  31. </view>
  32. <view class="cate-item flex" @click="goCp()">
  33. <view class="img-wrapper flex">
  34. <image src="../../static/icon/c2.png" mode=""></image>
  35. </view>
  36. <view class="item-title">环球国际</view>
  37. </view>
  38. <view class="cate-item flex" @click="openGg()">
  39. <view class="img-wrapper flex">
  40. <image src="../../static/icon/c3.png" mode=""></image>
  41. </view>
  42. <view class="item-title">视频领奖</view>
  43. </view>
  44. <view class="cate-item flex" @click="nav('/pages/coupon/couponList')">
  45. <view class="img-wrapper flex">
  46. <image src="../../static/icon/c4.png" mode=""></image>
  47. </view>
  48. <view class="item-title">领券中心</view>
  49. </view>
  50. <view class="cate-item flex" @click="nav('/pages/user/shareQrCode')">
  51. <view class="img-wrapper flex">
  52. <image src="../../static/icon/c5.png" mode=""></image>
  53. </view>
  54. <view class="item-title">邀请有礼</view>
  55. </view>
  56. </view>
  57. <!-- 分类 end-->
  58. <!-- 专区 start -->
  59. <view class="zq-wrap flex">
  60. <view class="zq-item" @click="nav('/pages/index/xfqzq')">
  61. <view class="zq-tit">
  62. 消费券专区
  63. </view>
  64. <view class="item-info flex">
  65. <image src="../../static/img/xf-bg.png" mode=""></image>
  66. <view class="info-tit">
  67. <image src="../../static/icon/ms.png" mode="widthFix"></image>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="zq-item bd" @click="nav('/pages/index/bdzq')">
  72. <view class="zq-tit">
  73. 爆品专区
  74. </view>
  75. <view class="item-info flex">
  76. <image src="../../static/img/bd-bg.png" mode=""></image>
  77. <view class="info-tit">
  78. <image src="../../static/icon/bd.png" mode="widthFix"></image>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <!-- 专区 end -->
  84. <!-- 商品列表 start -->
  85. <view class="product-box">
  86. <view class="product-tit flex">
  87. <view class="hx">
  88. </view>
  89. <view class="tit">
  90. 猜您喜欢
  91. </view>
  92. <view class="hx">
  93. </view>
  94. </view>
  95. <view class="hotgoods">
  96. <view class="hotgoods-item" v-for="item in list" :key="item.id"
  97. @click="nav('/pages/product/product?id=' + item.id)">
  98. <view class="image-wrapper">
  99. <image class="image" :src="item.image" mode="scaleToFill"></image>
  100. </view>
  101. <view class="title clamp2">{{item.store_name}}</view>
  102. <view class="hot-price">
  103. <view class="price">
  104. <text class="font-size-sm">¥</text>
  105. {{ item.price * 1 }}
  106. </view>
  107. <view class="yuanPrice">{{ item.ot_price*1 }}</view>
  108. </view>
  109. </view>
  110. </view>
  111. <uni-load-more :status="loadingType"></uni-load-more>
  112. </view>
  113. </view>
  114. </template>
  115. <script>
  116. import {
  117. loadIndexs,
  118. groom1,
  119. advertisement
  120. } from '@/api/index.js';
  121. import {
  122. getProducts
  123. } from '@/api/product.js'
  124. import {
  125. mapState,
  126. mapMutations
  127. } from 'vuex';
  128. export default {
  129. data() {
  130. return {
  131. dataList: '',
  132. carouselList: [], //轮播图列表
  133. page: 1,
  134. limit: 10,
  135. list: [],
  136. loadingType: 'more'
  137. };
  138. },
  139. onLoad() {
  140. this.loadData();
  141. this.getProduct()
  142. },
  143. onShow() {
  144. console.log(this.$dsbridge, 'dsbridge+++++++++++++')
  145. },
  146. onHide() {
  147. },
  148. onReachBottom() {
  149. this.getProduct()
  150. },
  151. computed: {
  152. ...mapState('user', ['userInfo'])
  153. },
  154. // 用户下拉刷新
  155. async onPullDownRefresh() {
  156. this.page = 1
  157. this.loadingType = 'more'
  158. this.list = []
  159. await this.getProduct()
  160. uni.stopPullDownRefresh()
  161. },
  162. methods: {
  163. openGg() {
  164. this.$dsbridge.call("fnAds.onShowRewardVideoAD", {}, function(result) {
  165. // alert(result);
  166. // 奖励状态返回
  167. // if(result.event)
  168. let res = JSON.parse(result)
  169. if(res.event == 'onReward') {
  170. advertisement({
  171. task:'1'
  172. }).then(e => {
  173. // alert('奖励已发放')
  174. // uni.showToast({
  175. // title:'奖励已发放',
  176. // duration:2000
  177. // });
  178. }).catch(err => {
  179. })
  180. }
  181. });
  182. },
  183. goCp() {
  184. },
  185. swiperChange() {
  186. },
  187. loadData() {
  188. loadIndexs({})
  189. .then(({
  190. data
  191. }) => {
  192. let goods = data.info;
  193. this.dataList = goods.bastList; //精品推荐
  194. this.carouselList = data.banner;
  195. })
  196. .catch(e => {});
  197. },
  198. nav(url) {
  199. uni.navigateTo({
  200. url,
  201. fail() {
  202. uni.switchTab({
  203. url
  204. });
  205. }
  206. });
  207. },
  208. // 點擊搜索框
  209. clickSearch() {
  210. uni.navigateTo({
  211. url: '/pages/product/search'
  212. });
  213. },
  214. // getProduct
  215. getProduct() {
  216. let obj = this
  217. if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
  218. return
  219. }
  220. obj.loadingType = 'loading'
  221. groom1({
  222. page: obj.page,
  223. limit: obj.limit
  224. }).then(res => {
  225. console.log(res)
  226. obj.list = obj.list.concat(res.data.list)
  227. obj.page++
  228. if (obj.limit == res.data.length) {
  229. obj.loadingType = 'more'
  230. } else {
  231. obj.loadingType = 'noMore'
  232. }
  233. })
  234. }
  235. }
  236. };
  237. </script>
  238. <style lang="scss">
  239. page,
  240. .center {
  241. min-height: 100%;
  242. height: auto;
  243. background: #fff;
  244. }
  245. // 顶部搜索
  246. .top-search {
  247. height: 80rpx;
  248. // padding: 0 20rpx;
  249. background-color: #f32b09;
  250. justify-content: center;
  251. .search-box {
  252. justify-content: center;
  253. width: 700rpx;
  254. height: 60rpx;
  255. background: #fff;
  256. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  257. border-radius: 30rpx;
  258. .search {
  259. width: 34rpx;
  260. height: 34rpx;
  261. }
  262. .search-font {
  263. margin-left: 14rpx;
  264. font-size: 28rpx;
  265. font-family: PingFang SC;
  266. font-weight: 500;
  267. color: #CBCBCB;
  268. }
  269. }
  270. }
  271. // 顶部轮播图
  272. .swiper-wrap {
  273. width: 750rpx;
  274. background-color: #f32b09;
  275. .top-swiper {
  276. width: 700rpx;
  277. height: 350rpx;
  278. margin: auto;
  279. border-radius: 20rpx;
  280. image {
  281. width: 700rpx;
  282. height: 350rpx;
  283. border-radius: 20rpx;
  284. }
  285. }
  286. }
  287. .swiper-btm {
  288. height: 60rpx;
  289. width: 750rpx;
  290. background-color: #fff;
  291. margin-bottom: 20rpx;
  292. font-size: 21rpx;
  293. font-weight: 500;
  294. color: #333333;
  295. .btm-item {
  296. flex-grow: 1;
  297. justify-content: center;
  298. image {
  299. width: 25rpx;
  300. height: 25rpx;
  301. margin-right: 14rpx;
  302. }
  303. }
  304. }
  305. .jg {
  306. height: 20rpx;
  307. background-color: #f32b09;
  308. }
  309. .status_bar {
  310. height: var(--status-bar-height);
  311. width: 100%;
  312. background: #f32b09;
  313. }
  314. // 分类
  315. .cate-section {
  316. justify-content: space-around;
  317. background-color: #fff;
  318. padding: 0rpx 0 30rpx;
  319. background: #f32b09;
  320. .cate-item {
  321. flex-grow: 0;
  322. width: 20%;
  323. flex-direction: column;
  324. text-align: center;
  325. align-items: center;
  326. justify-content: center;
  327. .img-wrapper {
  328. width: 90rpx;
  329. height: 90rpx;
  330. border-radius: 20rpx;
  331. position: relative;
  332. image {
  333. width: 90rpx;
  334. height: 90rpx;
  335. position: absolute;
  336. left: 50%;
  337. top: 50%;
  338. transform: translate(-50%, -50%);
  339. }
  340. }
  341. .item-title {
  342. margin-top: 15rpx;
  343. font-size: 26rpx;
  344. font-weight: 500;
  345. color: #FFFFFF;
  346. }
  347. }
  348. }
  349. // 专区
  350. .zq-wrap {
  351. height: 345rpx;
  352. width: 750rpx;
  353. background: linear-gradient(180deg, #f32b09, #fff);
  354. padding: 0 27rpx;
  355. .zq-item {
  356. width: 342rpx;
  357. height: 300rpx;
  358. background: linear-gradient(180deg, #fc2f40, #fb829e);
  359. border-radius: 20rpx;
  360. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.2);
  361. position: relative;
  362. .zq-tit {
  363. padding: 15rpx 0 0 20rpx;
  364. font-size: 32rpx;
  365. font-weight: bold;
  366. font-style: italic;
  367. color: #FFFFFF;
  368. }
  369. .item-info {
  370. position: absolute;
  371. bottom: 8rpx;
  372. left: 0;
  373. right: 0;
  374. margin: auto;
  375. width: 324rpx;
  376. height: 232rpx;
  377. background: #FFFFFF;
  378. border-radius: 20rpx;
  379. flex-direction: column;
  380. justify-content: center;
  381. align-items: center;
  382. image {
  383. width: 294rpx;
  384. height: 160rpx;
  385. }
  386. .info-tit {
  387. margin-top: 12rpx;
  388. width: 189rpx;
  389. height: 36rpx;
  390. image {
  391. width: 189rpx;
  392. }
  393. }
  394. }
  395. }
  396. .bd {
  397. background: linear-gradient(180deg, #ff601a, #feba9d);
  398. }
  399. }
  400. .product-box {
  401. margin-top: 20rpx;
  402. background: #ffffff;
  403. padding: 26rpx 20rpx 20rpx;
  404. .product-tit {
  405. justify-content: center;
  406. .hx {
  407. width: 120rpx;
  408. height: 1rpx;
  409. background: #989898;
  410. }
  411. .tit {
  412. margin: 0 70rpx;
  413. font-size: 30rpx;
  414. font-weight: 500;
  415. color: #363636;
  416. }
  417. }
  418. }
  419. .hotgoods {
  420. margin-top: 38rpx;
  421. width: 100%;
  422. display: flex;
  423. flex-wrap: wrap;
  424. padding: 0 0 30rpx;
  425. justify-content: space-between;
  426. .hotgoods-item {
  427. width: 345rpx;
  428. background-color: #ffffff;
  429. border-radius: 12rpx;
  430. .image-wrapper {
  431. width: 345rpx;
  432. height: 345rpx;
  433. border-radius: 3px;
  434. overflow: hidden;
  435. position: relative;
  436. .image-bg {
  437. position: absolute;
  438. top: 0;
  439. left: 0;
  440. right: 0;
  441. bottom: 0;
  442. width: 100%;
  443. height: 100%;
  444. opacity: 1;
  445. border-radius: 12rpx 12rpx 0 0;
  446. z-index: 2;
  447. }
  448. .image {
  449. width: 100%;
  450. height: 100%;
  451. opacity: 1;
  452. border-radius: 12rpx 12rpx 0 0;
  453. }
  454. }
  455. .title {
  456. margin-top: 24rpx;
  457. font-size: 28rpx;
  458. font-family: PingFang SC;
  459. font-weight: 500;
  460. color: #333333;
  461. }
  462. .hot-price {
  463. display: flex;
  464. justify-content: flex-start;
  465. align-items: center;
  466. padding: 14rpx 0 30rpx;
  467. .hotPrice-box {
  468. padding: 2rpx 6rpx;
  469. background: linear-gradient(90deg, #c79a4c, #f9df7f);
  470. border-radius: 5rpx;
  471. text-align: center;
  472. line-height: 28rpx;
  473. font-size: 20rpx;
  474. font-family: Source Han Sans CN;
  475. font-weight: 400;
  476. color: #ffffff;
  477. }
  478. .price {
  479. margin-left: 10rpx;
  480. font-size: 40rpx;
  481. color: #ff0000;
  482. font-weight: 500;
  483. }
  484. .yuanPrice {
  485. margin-left: 10rpx;
  486. font-size: 20rpx;
  487. font-family: PingFang SC;
  488. font-weight: 500;
  489. text-decoration: line-through;
  490. color: #999999;
  491. }
  492. .cart-icon {
  493. image {
  494. width: 44rpx;
  495. height: 44rpx;
  496. }
  497. }
  498. }
  499. }
  500. }
  501. </style>