cart.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <template>
  2. <view class="container">
  3. <!-- <view class="vheigh"></view> -->
  4. <!-- 小程序头部兼容 -->
  5. <!-- 顶部logo and 搜索 start-->
  6. <view class="top-search flex">
  7. <view class="search-box flex" @click="clickSearch()">
  8. <image class="search" src="../../static/icon/search-h.png" mode=""></image>
  9. <view class="search-font"><input type="text" placeholder="输入关键词搜索" v-model="productname" /></view>
  10. </view>
  11. </view>
  12. <!-- 精品 商品 -->
  13. <view class="guess-section-box">
  14. <view class="guess-section">
  15. <view v-for="(item, index) in bastList" :key="index" class="guess-item" @click="navToDetailPage(item)">
  16. <view class="image-wrapper"><image :src="item.image" mode="scaleToFill"></image></view>
  17. <text class="title clamp margin-c-20">{{ item.store_name }}</text>
  18. <view class="cmy-hr margin-c-20">{{ item.price }}元</view>
  19. <view class="price margin-c-20 flex">
  20. <view>
  21. {{ item.price * 1 - item.max_use_integral * 1 }}元
  22. <!-- <text class="font-size-sm ">积分</text> -->
  23. </view>
  24. <view class="font-size-sm">
  25. <text>{{ item.max_use_integral }}积分</text>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import { loadIndexs } from '@/api/index.js';
  35. import { getUserInfo } from '@/api/user.js';
  36. import { getProducts } from '@/api/product.js';
  37. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  38. import { mapState } from 'vuex';
  39. export default {
  40. data() {
  41. return {
  42. pageProportion: 0, //保存页面基于750宽度的比例
  43. swiperHeight: 0,
  44. checkid: 0,
  45. titleNViewBackground: '',
  46. bastList: [], //精品推荐列表
  47. page: 1,
  48. limit: 10,
  49. productname: '',
  50. loadingType: 'more' //加载更多状态
  51. };
  52. },
  53. computed: {
  54. ...mapState(['loginInterceptor']),
  55. ...mapState('user', ['hasLogin', 'userInfo'])
  56. },
  57. onLoad: function(option) {},
  58. onShow: function() {
  59. this.productname = '';
  60. this.loadingType = 'more';
  61. this.page = 1;
  62. this.bastList = []; //精品推荐列表
  63. this.loadData();
  64. },
  65. onReachBottom() {
  66. this.loadData();
  67. },
  68. methods: {
  69. // 监听切换事件
  70. listChange(e) {
  71. this.checkid = e.detail.current;
  72. },
  73. // 點擊搜索框
  74. clickSearch() {
  75. this.bastList = [];
  76. this.page = 1;
  77. this.limit = 10;
  78. this.loadingType = 'more';
  79. this.loadData();
  80. },
  81. // 请求载入数据
  82. async loadData() {
  83. let obj = this;
  84. if (obj.loadingType == 'nomore' || obj.loadingType == 'loading') {
  85. return;
  86. }
  87. obj.loadingType = 'loading';
  88. let data = {
  89. page: obj.page,
  90. limit: obj.limit,
  91. keyword: obj.productname,
  92. sid: 2
  93. };
  94. getProducts(data).then(function(e) {
  95. console.log(e.data);
  96. obj.bastList = obj.bastList.concat(e.data);
  97. //判断是否还有下一页,有是more 没有是nomore
  98. if (obj.limit == e.data.length) {
  99. obj.page++;
  100. obj.loadingType = 'more';
  101. } else {
  102. obj.loadingType = 'nomore';
  103. }
  104. });
  105. },
  106. //轮播图切换修改背景色
  107. swiperChange(e) {
  108. const index = e.detail.current;
  109. this.swiperCurrent = index;
  110. this.titleNViewBackground = this.carouselList[index].background;
  111. },
  112. //详情页
  113. navToDetailPage(item) {
  114. let id = item.id;
  115. uni.navigateTo({
  116. url: '/pages/product/product?id=' + id
  117. });
  118. }
  119. }
  120. };
  121. </script>
  122. <style lang="scss">
  123. page {
  124. .cate-section {
  125. position: relative;
  126. z-index: 5;
  127. border-radius: 16rpx 16rpx 0 0;
  128. margin-top: -20rpx;
  129. }
  130. }
  131. page {
  132. background: #f7f8f7;
  133. }
  134. .top-search {
  135. height: 80rpx;
  136. padding: 0 20rpx;
  137. background-color: #fff;
  138. .search-box {
  139. justify-content: center;
  140. width: 698rpx;
  141. height: 60rpx;
  142. background: #eeeeee;
  143. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  144. border-radius: 30rpx;
  145. .search {
  146. width: 34rpx;
  147. height: 34rpx;
  148. }
  149. .search-font {
  150. width: 500rpx;
  151. margin-left: 14rpx;
  152. font-size: 28rpx;
  153. font-family: PingFang SC;
  154. font-weight: 500;
  155. color: #cbcbcb;
  156. }
  157. }
  158. }
  159. // 顶部轮播图
  160. .top-swiper {
  161. width: 750rpx;
  162. height: 360rpx;
  163. // margin: 20rpx 0 0;
  164. image {
  165. width: 750rpx;
  166. height: 360rpx;
  167. }
  168. }
  169. .swiper-btm {
  170. height: 60rpx;
  171. width: 750rpx;
  172. background-color: #fff;
  173. margin-bottom: 20rpx;
  174. font-size: 21rpx;
  175. font-weight: 500;
  176. color: #333333;
  177. .btm-item {
  178. flex-grow: 1;
  179. justify-content: center;
  180. image {
  181. width: 25rpx;
  182. height: 25rpx;
  183. margin-right: 14rpx;
  184. }
  185. }
  186. }
  187. /* 分类 */
  188. .cate-section {
  189. display: flex;
  190. justify-content: space-around;
  191. align-items: center;
  192. flex-wrap: wrap;
  193. padding: 30rpx 22rpx;
  194. .cate-item {
  195. display: flex;
  196. flex-direction: column;
  197. align-items: center;
  198. font-size: $font-sm + 2rpx;
  199. color: $font-color-dark;
  200. }
  201. /* 原图标颜色太深,不想改图了,所以加了透明度 */
  202. image {
  203. width: 88rpx;
  204. height: 88rpx;
  205. margin-bottom: 14rpx;
  206. border-radius: 50%;
  207. opacity: 0.7;
  208. }
  209. }
  210. /*公用边框样式*/
  211. %icon {
  212. margin-right: 10rpx;
  213. display: inline-block;
  214. padding: 2rpx 10rpx;
  215. border: 1rpx solid $color-yellow;
  216. color: $color-yellow;
  217. line-height: 1;
  218. font-size: $font-base;
  219. border-radius: 10rpx;
  220. }
  221. .vheigh {
  222. height: var(--status-bar-height);
  223. }
  224. /* 猜你喜欢 */
  225. .guess-section {
  226. display: flex;
  227. flex-wrap: wrap;
  228. padding: 0 30rpx;
  229. .guess-item {
  230. overflow: hidden;
  231. display: flex;
  232. flex-direction: column;
  233. width: 48%;
  234. margin-bottom: 4%;
  235. border-radius: $border-radius-sm;
  236. background-color: white;
  237. box-shadow: $box-shadow;
  238. &:nth-child(2n + 1) {
  239. margin-right: 4%;
  240. }
  241. }
  242. .image-wrapper {
  243. width: 100%;
  244. height: 330rpx;
  245. border-radius: 3px;
  246. overflow: hidden;
  247. image {
  248. width: 100%;
  249. height: 100%;
  250. opacity: 1;
  251. }
  252. }
  253. .title {
  254. font-size: $font-base;
  255. color: $font-color-dark;
  256. font-weight: bold;
  257. line-height: 80rpx;
  258. }
  259. .price {
  260. font-size: $font-lg;
  261. color: $font-color-base;
  262. font-weight: bold;
  263. line-height: 1;
  264. line-height: 80rpx;
  265. }
  266. .icon {
  267. @extend %icon;
  268. }
  269. .detail {
  270. line-height: 1;
  271. }
  272. .tip {
  273. color: white;
  274. background-color: $color-yellow;
  275. line-height: 1.5;
  276. font-size: $font-sm;
  277. padding-left: 20rpx;
  278. }
  279. .cmy-hr {
  280. color: #ff0000;
  281. text-decoration: line-through;
  282. }
  283. }
  284. // 推荐
  285. .recommend {
  286. width: 95%;
  287. height: 155rpx;
  288. margin: 0rpx auto;
  289. padding-top: 30rpx;
  290. font-size: 26rpx;
  291. text-align: center;
  292. color: #333333;
  293. align-items: flex-start;
  294. .recommend_list {
  295. width: 33%;
  296. }
  297. .re_title {
  298. font-size: 32rpx;
  299. font-weight: bold;
  300. }
  301. .re_name {
  302. color: #999999;
  303. padding-top: 10rpx;
  304. }
  305. .selected_icon {
  306. width: 25rpx;
  307. height: 10rpx;
  308. margin: 0px auto;
  309. display: none;
  310. image {
  311. width: 100%;
  312. height: 100%;
  313. }
  314. }
  315. .active {
  316. display: block;
  317. }
  318. .active_color {
  319. color: #dc4d46 !important;
  320. }
  321. }
  322. // 列表
  323. .list-box-h {
  324. height: 1550rpx;
  325. }
  326. // 优惠券
  327. .coupon-list {
  328. display: inline-block;
  329. }
  330. .row {
  331. border-radius: 15rpx;
  332. margin: 25rpx;
  333. height: 155rpx;
  334. // width: 552rpx;
  335. overflow: hidden;
  336. background-color: #ffffff;
  337. padding-right: 25rpx;
  338. .list-interval {
  339. border: 1px dashed $border-color-light;
  340. height: 100%;
  341. .top,
  342. .bottom {
  343. border-radius: 100rpx;
  344. width: 30rpx;
  345. height: 30rpx;
  346. position: absolute;
  347. background-color: $page-color-base;
  348. right: -15rpx;
  349. }
  350. .top {
  351. top: -18rpx;
  352. }
  353. .bottom {
  354. bottom: -18rpx;
  355. }
  356. }
  357. .list-money {
  358. height: 100%;
  359. min-width: 155rpx;
  360. text-align: center;
  361. image {
  362. height: 100%;
  363. width: 20rpx;
  364. }
  365. .list-money-text {
  366. flex-grow: 1;
  367. padding: 0 25rpx;
  368. .tit {
  369. text-align: center;
  370. padding: 15rpx 0rpx;
  371. font-size: 55rpx;
  372. color: $color-red;
  373. font-weight: bold;
  374. &.noAction {
  375. color: $font-color-light;
  376. }
  377. }
  378. .price {
  379. padding-bottom: 25rpx;
  380. color: $font-color-light;
  381. }
  382. }
  383. }
  384. .row_list_right {
  385. // flex-grow: 1;
  386. min-width: 200rpx;
  387. padding-left: 25rpx;
  388. line-height: 1;
  389. .right_time {
  390. padding: 10rpx 0rpx;
  391. color: $font-color-light;
  392. font-size: $font-sm;
  393. }
  394. .right_top {
  395. margin: 15rpx 0;
  396. .right_name {
  397. font-size: $font-base;
  398. color: #bc253a;
  399. font-weight: bold;
  400. }
  401. .right_title {
  402. font-size: $font-base;
  403. color: $font-base;
  404. font-weight: bold;
  405. &.noAction {
  406. color: $font-color-light;
  407. }
  408. }
  409. }
  410. }
  411. .right_use {
  412. margin: 15rpx 0;
  413. padding: 10rpx;
  414. width: 160rpx;
  415. text-align: center;
  416. color: #fff;
  417. background-color: #bc253a;
  418. border-radius: 50rpx;
  419. font-size: $font-sm;
  420. &.noAction {
  421. background-color: $font-color-light;
  422. }
  423. }
  424. .iconlocation {
  425. font-size: 36rpx;
  426. color: $font-color-light;
  427. }
  428. }
  429. .guess-section-box {
  430. margin-top: 20rpx;
  431. }
  432. </style>