123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- <template>
- <view class="container">
- <view class="jg"></view>
- <view v-if="list.length != 0" class="good-wrapper flex" :key="ind" v-for="(good, ind) in list"
- @click="navTo(good)">
- <image :src="good.image" mode="" class="good-img"></image>
- <view class="good-info flex">
- <view class="tit clamp2">
- {{good.store_name }}
- </view>
- <view class="price-wrap">
- <view class="old-price">
- <text class="old">¥{{good.ot_price}}</text>
- <image src="../../static/icon/down.png" mode=""></image>
- <text class="zj">直降{{good.ot_price - good.price}}元</text>
- </view>
- <view class="integral-wrap">
- <text class="price">¥{{good.price}}</text>
- </view>
- </view>
- <view class="btn">
- 立即购买
- </view>
- </view>
- </view>
- <empty v-if="list.length === 0"></empty>
- <view class="jg"></view>
- <navigator url="/pages/cart/cart2">
- <view class="cart">
- <view class="text" v-if="total>0">
- {{total}}
- </view>
- <image class="cart-icon" src="/static/img/cartIcon.png" mode="scaleToFill"></image>
- </view>
- </navigator>
- </view>
- </template>
- <script>
- import empty from '@/components/empty';
- import {
- groomList
- } from '@/api/product.js';
- import {
- getCartList,
- } from '@/api/cart.js';
- export default {
- data() {
- return {
- list: [],
- bannerImg: [],
- total: 0
- };
- },
- components: {
- empty
- },
- onShow() {
- this.loadCart();
- },
- onLoad(option) {
- // 获取查询对象
- this.type = option.type;
- if (this.type == 7) {
- uni.setNavigationBarTitle({
- title: '商家礼包'
- });
- }
- // 加载基础数据
- this.loadData();
- this.loadCart();
- },
- methods: {
- async loadCart() {
- let obj = this;
- getCartList({
- type: 2
- })
- .then(function(e) {
- obj.total = e.data.valid.length;
- })
- .catch(function(e) {
- console.log(e);
- });
- },
- navTo: function(ls) {
- if (this.type == 7) {
- uni.navigateTo({
- url: '/pages/product/product?isRz=1&id=' + ls.id
- });
- } else {
- uni.navigateTo({
- url: '/pages/product/product?id=' + ls.id
- });
- }
- },
- // 请求载入数据
- async loadData() {
- groomList({}, this.type)
- .then(({
- data
- }) => {
- // 保存轮播图
- this.bannerImg = data.banner;
- // 保存商品信息
- this.list = data.list;
- })
- .catch(e => {
- console.log(e);
- });
- },
- // 轮播图跳转
- bannerNavToUrl(item) {
- // #ifdef H5
- if (item.wap_link.indexOf('http') > 0) {
- window.location.href = item.wap_link;
- }
- // #endif
- if (item.wap_link) {
- uni.navigateTo({
- url: item.wap_link
- });
- }
- }
- }
- };
- </script>
- <style lang="scss">
- .cart {
- position: fixed;
- right: 30rpx;
- bottom: 60rpx;
- .cart-icon {
- width: 150rpx;
- height: 150rpx;
- }
- .text {
- background-color: $color-red;
- color: #FFF;
- position: absolute;
- top: 0;
- right: 0;
- width: 40rpx;
- height: 40rpx;
- z-index: 999;
- text-align: center;
- border-radius: 99rpx;
- }
- }
- page {
- background: $page-color-base;
- }
- .good-wrapper {
- width: 690rpx;
- height: 276rpx;
- justify-content: flex-start;
- align-items: flex-start;
- margin: 0 auto 20rpx;
- // &:last-of-type {
- // margin-bottom: 0;
- // }
- background: #FFFFFF;
- box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
- border-radius: 10rpx;
- padding: 20rpx 25rpx 20rpx 15rpx;
- .good-img {
- flex-shrink: 0;
- background-color: #eee;
- width: 236rpx;
- height: 236rpx;
- border-radius: 10rpx;
- margin-right: 20rpx;
- }
- .good-info {
- flex-direction: column;
- align-items: flex-start;
- width: 100%;
- height: 100%;
- position: relative;
- .tit {
- padding-top: 10rpx;
- padding-right: 15rpx;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- }
- .btn {
- width: 137rpx;
- line-height: 52rpx;
- background: linear-gradient(0deg, #52C696 0%, #52C696 100%);
- border-radius: 26rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- text-align: center;
- color: #FFFFFF;
- position: absolute;
- bottom: 0;
- right: 0;
- }
- .price-wrap {
- .old-price {
- .old {
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- text-decoration: line-through;
- color: #999999;
- }
- image {
- display: inline-block;
- width: 14rpx;
- height: 20rpx;
- margin: 0 6rpx 0 10rpx;
- }
- .zj {
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #B59467;
- }
- }
- .integral-wrap {
- display: flex;
- justify-content: flex-start;
- padding-top: 14rpx;
- image {
- width: 40rpx;
- height: 40rpx;
- margin-right: 8rpx;
- }
- .price {
- font-size: 36rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FF6F0F;
- line-height: 40rpx;
- }
- }
- }
- }
- }
- </style>
|