mall.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <view class="center">
  3. <!-- 顶部logo and 搜索 start-->
  4. <view class="top-search flex">
  5. <view class="top-logo">
  6. <image src="../../static/icon/logo.png" mode="widthFix"></image>
  7. </view>
  8. <view class="search-box flex" @click="clickSearch()">
  9. <image class="search" src="../../static/icon/search-h.png" mode=""></image>
  10. <view class="search-font">输入关键词搜索</view>
  11. </view>
  12. </view>
  13. <!-- 顶部logo and 搜索 end-->
  14. <view class="jg"></view>
  15. <!-- 轮播图 start -->
  16. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  17. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  18. @click="bannerNavToUrl(item)">
  19. <image src="../../static/img/bargainBg.jpg" />
  20. </swiper-item>
  21. </swiper>
  22. <!-- 轮播图 end -->
  23. <view class="swiper-btm flex">
  24. <view class="btm-item flex">
  25. <image src="../../static/icon/index-gou.png" mode=""></image>
  26. <view class="">自用购物返利</view>
  27. </view>
  28. <view class="btm-item flex">
  29. <image src="../../static/icon/index-gou.png" mode=""></image>
  30. <view class="">分享好友赚钱</view>
  31. </view>
  32. <view class="btm-item flex">
  33. <image src="../../static/icon/index-gou.png" mode=""></image>
  34. <view class="">超值正品优惠</view>
  35. </view>
  36. </view>
  37. <!-- 商品列表 -->
  38. <view class="good-list">
  39. <view class="good flex" v-for="item in goodList" @click="navto('/pages/product/product?id=' + item.id)">
  40. <view class="good-img">
  41. <image :src="item.image" mode=""></image>
  42. </view>
  43. <view class="good-info flex">
  44. <view class="good-name clamp2">
  45. {{item.store_name}}
  46. </view>
  47. <view class="good-price">
  48. <view class="old-price" v-if="item.ot_price*1 > item.price*1">
  49. <text class="old-left">¥{{item.ot_price}}</text> <image src="../../static/icon/down.png" mode="widthFix"></image><text class="old-right">直降{{item.ot_price*1 - item.price*1}}元</text>
  50. </view>
  51. <view class="new-price flex">
  52. <view class="">
  53. ¥{{item.price}}
  54. </view>
  55. <!-- <view class="good-tip">
  56. 1960提货券
  57. </view> -->
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <uni-load-more :status="loadingType"></uni-load-more>
  64. </view>
  65. </template>
  66. <script>
  67. import {
  68. tabbar1
  69. } from '@/utils/tabbar.js';
  70. import {
  71. loadIndexs
  72. } from '@/api/index.js';
  73. import { getProducts } from '@/api/product.js'
  74. import uniCountdowns from '@/components/uni-countdown/uni-countdowns.vue';
  75. export default {
  76. components: {
  77. uniCountdowns
  78. },
  79. data() {
  80. return {
  81. current: 0,
  82. tabbar: tabbar1,
  83. titleNViewBackground: '',
  84. swiperCurrent: 0,
  85. swiperLength: 0,
  86. dataList: '',
  87. carouselList: [], //轮播图列表
  88. text: ['恭喜黑白灰用户拼团成功¥353元!', '恭喜黑白灰用户拼团成功¥353元!'],
  89. stopTime: {
  90. stopTimeH: 0,
  91. stopTimeM: 24,
  92. stopTimeS: 59
  93. },
  94. bzb: 30,
  95. goodList: [],
  96. page: 1,
  97. limit: 10,
  98. loadingType: 'more'
  99. };
  100. },
  101. onLoad() {
  102. this.loadData();
  103. this.getProList()
  104. },
  105. onReachBottom() {
  106. this.getProList()
  107. },
  108. methods: {
  109. navto(url) {
  110. uni.navigateTo({
  111. url
  112. })
  113. },
  114. loadData() {
  115. loadIndexs({})
  116. .then(({
  117. data
  118. }) => {
  119. let goods = data.info;
  120. this.dataList = goods.bastList; //精品推荐
  121. this.carouselList = data.banner;
  122. })
  123. .catch(e => {});
  124. },
  125. goDetails(e) {
  126. console.log(e, '123456');
  127. uni.navigateTo({
  128. url: '/pages/index/messageInfo'
  129. });
  130. },
  131. nav(url) {
  132. uni.navigateTo({
  133. url,
  134. fail() {
  135. uni.switchTab({
  136. url
  137. });
  138. }
  139. });
  140. },
  141. //轮播图切换修改背景色
  142. swiperChange(e) {
  143. const index = e.detail.current;
  144. this.swiperCurrent = index;
  145. this.titleNViewBackground = this.carouselList[index].background;
  146. },
  147. // 點擊搜索框
  148. clickSearch() {
  149. uni.navigateTo({
  150. url: '/pages/product/search'
  151. });
  152. },
  153. //详情页
  154. navToDetailPage(item) {
  155. let id = item.id;
  156. uni.navigateTo({
  157. url: '/pages/product/product?id=' + id
  158. });
  159. },
  160. getProList() {
  161. let obj =this
  162. if(obj.loadingType == 'loading' || obj.loadingType == 'noMore' ) {
  163. return
  164. }
  165. obj.loadingType = 'loading'
  166. getProducts({
  167. page: obj.page,
  168. limit: obj.limit
  169. }).then(res => {
  170. obj.goodList = obj.goodList.concat(res.data)
  171. obj.page++
  172. if(obj.limit == res.data.length ) {
  173. obj.loadingType = 'more'
  174. }else {
  175. obj.loadingType = 'noMore'
  176. }
  177. })
  178. }
  179. }
  180. };
  181. </script>
  182. <style lang="scss">
  183. page,
  184. .center {
  185. min-height: 100%;
  186. height: auto;
  187. background: #ededed;
  188. }
  189. // 顶部搜索
  190. .top-search {
  191. height: 80rpx;
  192. padding: 0 20rpx;
  193. background-color: #fff;
  194. .top-logo {
  195. width: 50rpx;
  196. // height: 50rpx;
  197. margin-right: 10rpx;
  198. image {
  199. width: 50rpx;
  200. // height: 50rpx;
  201. }
  202. }
  203. .search-box {
  204. justify-content: center;
  205. width: 698rpx;
  206. height: 60rpx;
  207. background: #EEEEEE;
  208. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  209. border-radius: 30rpx;
  210. .search {
  211. width: 34rpx;
  212. height: 34rpx;
  213. }
  214. .search-font {
  215. margin-left: 14rpx;
  216. font-size: 28rpx;
  217. font-family: PingFang SC;
  218. font-weight: 500;
  219. color: #CBCBCB;
  220. }
  221. }
  222. }
  223. // 顶部轮播图
  224. .top-swiper {
  225. width: 750rpx;
  226. height: 360rpx;
  227. // margin: 20rpx 0 0;
  228. image {
  229. width: 750rpx;
  230. height: 360rpx;
  231. }
  232. }
  233. .swiper-btm {
  234. height: 60rpx;
  235. width: 750rpx;
  236. background-color: #fff;
  237. margin-bottom: 20rpx;
  238. font-size: 21rpx;
  239. font-weight: 500;
  240. color: #333333;
  241. .btm-item {
  242. flex-grow: 1;
  243. justify-content: center;
  244. image {
  245. width: 25rpx;
  246. height: 25rpx;
  247. margin-right: 14rpx;
  248. }
  249. }
  250. }
  251. .jg {
  252. height: 20rpx;
  253. background-color: #fff;
  254. }
  255. .good-list {
  256. width: 750rpx;
  257. background: linear-gradient(0deg, #FFFFFF, #F8F8F8);
  258. padding: 30rpx 0;
  259. .good {
  260. width: 690rpx;
  261. height: 276rpx;
  262. background: #FFFFFF;
  263. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  264. border-radius: 10rpx;
  265. margin: auto;
  266. padding: 20rpx 15rpx;
  267. margin-bottom: 20rpx;
  268. &:last-of-type {
  269. margin-bottom: 0rpx;
  270. }
  271. .good-img {
  272. flex-shrink: 0;
  273. width: 236rpx;
  274. height: 236rpx;
  275. border-radius: 10rpx;
  276. margin-right: 22rpx;
  277. image {
  278. width: 236rpx;
  279. height: 236rpx;
  280. border-radius: 10rpx;
  281. }
  282. }
  283. .good-info {
  284. flex-grow: 1;
  285. height: 100%;
  286. flex-direction: column;
  287. justify-content: space-between;
  288. align-items: flex-start;
  289. .good-name {
  290. font-size: 32rpx;
  291. font-weight: bold;
  292. padding-top: 10rpx;
  293. color: #333333;
  294. }
  295. .good-price {
  296. width: 100%;
  297. image {
  298. width: 14rpx;
  299. margin: 0 6rpx 0 10rpx;
  300. }
  301. .old-price {
  302. .old-left {
  303. font-size: 26rpx;
  304. font-weight: 500;
  305. text-decoration: line-through;
  306. color: #999999;
  307. }
  308. .old-right {
  309. font-size: 24rpx;
  310. font-weight: bold;
  311. color: #B59467;
  312. }
  313. }
  314. .new-price {
  315. width: 100%;
  316. font-size: 36rpx;
  317. font-weight: bold;
  318. color: #FF4C4C;
  319. justify-content: space-between;
  320. .good-tip {
  321. display: inline-block;
  322. padding: 0 20rpx 0 17rpx;
  323. min-width: 160rpx;
  324. text-align: center;
  325. line-height: 40rpx;
  326. background: #303030;
  327. font-size: 24rpx;
  328. font-weight: 500;
  329. color: #F8DABA;
  330. border-radius: 10rpx;
  331. position: relative;
  332. &::before {
  333. content: '';
  334. display: inline-block;
  335. height: 17rpx;
  336. width: 17rpx;
  337. background-color: #fff;
  338. border-radius: 50%;
  339. position: absolute;
  340. top: 0;
  341. bottom: 0;
  342. left: -9rpx;
  343. margin: auto;
  344. }
  345. &::after {
  346. content: '';
  347. display: inline-block;
  348. height: 17rpx;
  349. width: 17rpx;
  350. background-color: #fff;
  351. border-radius: 50%;
  352. position: absolute;
  353. top: 0;
  354. bottom: 0;
  355. right: -9rpx;
  356. margin: auto;
  357. }
  358. }
  359. }
  360. }
  361. }
  362. }
  363. }
  364. </style>