123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <template>
- <view class="container">
- <view class="jg"></view>
- <view class="good-wrapper flex" v-for="(good ,index) in list" :key="good.id">
- <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">
- <image src="../../static/icon/jf.png" mode=""></image>
- <text class="price">{{good.price}}</text>
- </view>
- </view>
- <view class="btn" @click="nav(good.id)">
- 立即购买
- </view>
- </view>
- </view>
- <view class="jg"></view>
- <navigator url="/pages/cart/cart4">
- <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 {
- getCartList,
- } from '@/api/cart.js';
- import {
- groomList
- } from '@/api/product.js';
- export default {
- filters: {
- toFixed: function(value) {
- // 判断是否为整数
- if (value % 1 == 0) {
- return value;
- } else {
- return value.toFixed(2);
- }
- }
- },
- data() {
- return {
- list: [],
- bannerImg: [],
- total: 0
- };
- },
- onLoad(option) {
- // 加载基础数据
- this.loadData();
- },
- onShow() {
- this.loadCart();
- },
- methods: {
- async loadCart() {
- let obj = this;
- getCartList({
- type: 4
- })
- .then(function(e) {
- obj.total = e.data.valid.length;
- })
- .catch(function(e) {
- console.log(e);
- });
- },
- //详情页
- navToDetailPage(item) {
- uni.navigateTo({
- url: '/pages/product/product?id=' + item.id
- });
- },
- // 轮播图跳转
- bannerNavToUrl(item) {
- // #ifdef H5
- if (item.wap_link.indexOf('http') > 0) {
- window.location.href = item.wap_link;
- }
- // #endif
- //测试数据没有写id,用title代替
- uni.navigateTo({
- url: item.wap_link
- });
- },
- // 请求载入数据
- async loadData() {
- groomList({}, 6)
- .then(({
- data
- }) => {
- // 保存轮播图
- this.bannerImg = data.banner;
- // 保存商品信息
- this.list = data.list.map(e => {
- e.price = Number(e.price);
- e.ot_price = Number(e.ot_price);
- return e;
- });
- })
- .catch(e => {
- console.log(e);
- });
- },
- nav(id) {
- uni.navigateTo({
- url: '/pages/product/product?id=' + id
- })
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- page {
- background: $page-color-base;
- }
- .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;
- }
- }
- .jg {
- height: 20rpx;
- }
- .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>
|