mall.vue 8.5 KB

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