new.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <template>
  2. <view class="center">
  3. <view class="top">
  4. <image class="top-bg" src="../../static/img/top-bg.png" mode=""></image>
  5. <!-- <swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  6. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  7. @click="bannerNavToUrl(item)">
  8. <image class="top-bg" :src="item.pic" />
  9. </swiper-item>
  10. </swiper> -->
  11. <view class="title">新品专区</view>
  12. </view>
  13. <swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  14. <swiper-item class="carousel-item" v-for="(item,index) in carouselList " @click="bannerNavToUrl(item)"><image :src="item.pic" mode=""></image> </swiper-item>
  15. </swiper>
  16. <view class="">
  17. <view class="goldenBean" v-for="(item,index) in leibieList" v-if="item.loaded && item.list.length != 0">
  18. <view class="title">
  19. <image src="@/static/img/list1.png"></image>
  20. <view class="title-t"> {{item.cate_name}} </view>
  21. <text class="about">超值体验</text>
  22. </view>
  23. <view class="box">
  24. <view class="header" :style="index%2!=1?bgColor[0]:bgColor[1]">
  25. <view class="left">
  26. <view class="title">
  27. 热门好物推荐
  28. </view>
  29. <view class="about">
  30. 买到就是赚到
  31. </view>
  32. </view>
  33. <view class="right">
  34. <image src="@/static/img/right.png" @click="navToDetailPage('/pages/product/fenlei?id=' + item.id)"></image>
  35. </view>
  36. </view>
  37. <view class="footer">
  38. <view class="list">
  39. <view class="item" v-for="d in item.list"
  40. @click="navToDetailPage('/pages/product/product?id='+d.id)">
  41. <view class="img">
  42. <image :src="d.image" mode=""></image>
  43. </view>
  44. <view class="name nowarp" :title='d.store_name'>
  45. {{d.store_name}}
  46. </view>
  47. <view class="price">
  48. ¥{{d.price}}
  49. </view>
  50. <view class="name" style="font-size: 22rpx;color: #999;">
  51. 已售 {{ d.sales || '0'}}
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <u-tabbar activeColor="#f42b4e" v-model="current" :list="tabbar"></u-tabbar>
  60. </view>
  61. </template>
  62. <script>
  63. import {
  64. loadIndexs,
  65. store_list
  66. } from '@/api/index.js';
  67. // import {
  68. // getProducts
  69. // } from '@/api/product.js';
  70. import { tabbar1 } from '@/utils/tabbar.js';
  71. // import goldenBean from '@/pages/index/goldenBean.vue'
  72. import goldenBean from '@/pages/index/goldenBean.vue'
  73. import { groomList,getProducts,getCategorylist,goodsDetail } from '@/api/product.js';
  74. export default {
  75. components: {
  76. goldenBean
  77. // wholesale,
  78. // recommend,
  79. // topTitle
  80. },
  81. data() {
  82. return {
  83. carouselList: [], //轮播图列表
  84. bgColor: [{background: "linear-gradient(43deg, #FFBD70, #FF8F44)"},
  85. {background: "linear-gradient(90deg, #F75022, #FF8B6C)"},
  86. ],
  87. indexLoad: '',
  88. current: 3,
  89. tabbar: tabbar1,
  90. firstList: [],
  91. type: 2,
  92. page: 1,
  93. limit: 20,
  94. loaded: false,
  95. loadingType: 'more',
  96. jdList: [], //金豆商品
  97. leibieList:[],//'类别'
  98. id:0,
  99. swiperCurrent: 0,
  100. swiperLength: 0,
  101. };
  102. },
  103. onLoad() {
  104. this.get()
  105. // this.getProducts()
  106. this.loadData();
  107. this.getBargainList();
  108. },
  109. onShow() {
  110. this.getGoodList()
  111. // this.getProducts()
  112. // this.loadData();
  113. // this.getBargainList();
  114. },
  115. onReachBottom() {
  116. // this.loadData();
  117. },
  118. methods: {
  119. nav(url){
  120. uni.navigateTo({
  121. url
  122. })
  123. },
  124. get(){
  125. loadIndexs({})
  126. .then(({
  127. data
  128. }) => {
  129. let goods = data.info;
  130. // this.dataList = goods.bastList; //精品推荐
  131. this.carouselList = data.banner;
  132. console.log(this.carouselList,'banner');
  133. })
  134. .catch(e => {});
  135. },
  136. //轮播图切换修改背景色
  137. swiperChange(e) {
  138. const index = e.detail.current;
  139. this.swiperCurrent = index;
  140. this.titleNViewBackground = this.carouselList[index].background;
  141. },
  142. getProducts() {
  143. let obj = this;
  144. console.log(obj.id,'id');
  145. getProducts({sid:obj.id} ).then(function({ data }) {
  146. console.log(data,'data');
  147. obj.jdList = data
  148. });
  149. },
  150. getProductss(item) {
  151. let obj = this;
  152. getProducts({sid:item.id}).then(function({ data }) {
  153. obj.$set(item,'list',data)
  154. obj.$set(item,'loaded',true)
  155. // item.loaded = true
  156. console.log(item.list,'data+++++++');
  157. });
  158. },
  159. getBargainList() {
  160. let that = this;
  161. getProducts({
  162. page: that.page,
  163. limit: that.limit,
  164. })
  165. .then(function(res) {
  166. that.jdList = res.data
  167. // console.log(that.jdList,'jdlist');
  168. })
  169. .catch(res => {});
  170. },
  171. loadData() {
  172. let obj = this;
  173. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  174. return;
  175. }
  176. obj.loadingType = 'loading';
  177. groomList(
  178. {
  179. page: obj.page,
  180. limit: obj.limit
  181. },
  182. obj.id
  183. )
  184. .then(({ data }) => {
  185. // 保存轮播图
  186. obj.bannerImg = data.banner;
  187. // 保存商品信息
  188. obj.firstList = this.firstList.concat(data.list);
  189. obj.loaded = true;
  190. obj.page++;
  191. if (obj.limit == data.list.length) {
  192. obj.loadingType = 'more';
  193. } else {
  194. obj.loadingType = 'noMore';
  195. }
  196. })
  197. .catch(e => {
  198. console.log(e);
  199. });
  200. },
  201. getGoodList() {
  202. let obj = this
  203. getCategorylist().then(res=>{
  204. this.leibieList = res.data[1].children
  205. console.log(this.leibieList,'徐浩岚')
  206. this.leibieList.forEach(item => {
  207. obj.getProductss(item)
  208. })
  209. })
  210. },
  211. navToDetailPage(e) {
  212. uni.navigateTo({
  213. url:e
  214. });
  215. }
  216. }
  217. };
  218. </script>
  219. <style lang="scss">
  220. $grey: #95A0B1;
  221. $text: #333333;
  222. $red: #FF4C4C;
  223. page,
  224. .center {
  225. min-height: 100%;
  226. height: auto;
  227. background: #ffffff;
  228. }
  229. .top {
  230. position: relative;
  231. width: 100%;
  232. height: 400rpx;
  233. .top-bg {
  234. position: absolute;
  235. top: 0;
  236. left: 0;
  237. right: 0;
  238. width: 100%;
  239. height: 100%;
  240. }
  241. .title {
  242. position: relative;
  243. z-index: 2;
  244. padding: 30rpx 0;
  245. font-size: 34rpx;
  246. font-family: PingFang SC;
  247. font-weight: bold;
  248. color: #ffffff;
  249. text-align: center;
  250. }
  251. }
  252. .carousel {
  253. width: 700rpx;
  254. height: 300rpx;
  255. margin: -280rpx auto 0;
  256. image {
  257. width: 700rpx;
  258. height: 300rpx;
  259. }
  260. }
  261. .hotgoods {
  262. margin-top: 38rpx;
  263. width: 100%;
  264. display: flex;
  265. flex-wrap: wrap;
  266. padding: 0 32rpx;
  267. .hotgoods-item {
  268. width: 48%;
  269. background-color: #ffffff;
  270. border-radius: 12rpx;
  271. margin-bottom: 24rpx;
  272. &:nth-child(2n + 1) {
  273. margin-right: 24rpx;
  274. }
  275. .image-wrapper {
  276. width: 100%;
  277. height: 330rpx;
  278. // background: red;
  279. border-radius: 3px;
  280. overflow: hidden;
  281. image {
  282. width: 100%;
  283. height: 100%;
  284. opacity: 1;
  285. border-radius: 12rpx 12rpx 0 0;
  286. }
  287. }
  288. .title {
  289. font-size: $font-base;
  290. color: $font-color-dark;
  291. font-weight: bold;
  292. line-height: 80rpx;
  293. }
  294. .hot-price {
  295. display: flex;
  296. justify-content: space-between;
  297. padding: 0 16rpx 12rpx;
  298. .price {
  299. font-size: 36rpx;
  300. font-weight: bold;
  301. color: #fd3b39;
  302. }
  303. .cart-icon {
  304. image {
  305. width: 44rpx;
  306. height: 44rpx;
  307. }
  308. }
  309. }
  310. }
  311. }
  312. .goldenBean {
  313. font-family: PingFang-SC-Bold;
  314. margin-top: 20rpx;
  315. padding: 20rpx;
  316. background-color: #fff;
  317. .title {
  318. display: flex;
  319. line-height: 40rpx;
  320. .title-t {
  321. color: $text;
  322. font-weight: bold;
  323. margin: 0 20rpx;
  324. font-size: 34rpx;
  325. }
  326. .about {
  327. font-size: 24rpx;
  328. color: $grey;
  329. }
  330. image {
  331. width: 40rpx;
  332. height: 40rpx;
  333. }
  334. }
  335. .box {
  336. margin: 20rpx 0;
  337. border-radius: 10rpx;
  338. overflow: hidden;
  339. .header {
  340. padding: 20rpx;
  341. padding-bottom: 80rpx;
  342. width: 100%;
  343. display: flex;
  344. justify-content: space-between;
  345. color: #fff;
  346. .left {
  347. line-height: 40rpx;
  348. .title {
  349. font-size: 32rpx;
  350. }
  351. .about {
  352. opacity: 0.9;
  353. font-size: 24rpx;
  354. }
  355. }
  356. .right {
  357. margin: auto 0;
  358. image {
  359. width: 30rpx;
  360. height: 30rpx;
  361. }
  362. }
  363. }
  364. .footer {
  365. height: 300rpx;
  366. background-color: $page-color-base;
  367. padding: 20rpx;
  368. margin-bottom: -50rpx;
  369. .list {
  370. display: flex;
  371. // justify-content: space-between;
  372. overflow: auto;
  373. border-radius: 10rpx;
  374. position: relative;
  375. top: -90rpx;
  376. background-color: #fff;
  377. .item {
  378. padding: 35rpx;
  379. border-right: solid 1rpx $page-color-base;
  380. .name {
  381. font-size: 24rpx;
  382. color: #3F3F3F;
  383. width: 150rpx;
  384. overflow: hidden;
  385. display: -webkit-box;
  386. -webkit-box-orient: vertical;
  387. -webkit-line-clamp: 1;
  388. border-radius: 10rpx;
  389. text-overflow: ellipsis;
  390. }
  391. .price {
  392. font-size: 28rpx;
  393. color: $red;
  394. font-weight: bold;
  395. }
  396. .img {
  397. overflow: hidden;
  398. border-radius: 20rpx;
  399. image {
  400. width: 150rpx;
  401. height: 150rpx;
  402. }
  403. }
  404. }
  405. }
  406. }
  407. }
  408. }
  409. </style>