mall.vue 8.9 KB

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