Showing
5 changed files
with
81 additions
and
3 deletions
app/models/cart/cart.js
0 → 100644
1 | +import cartModel from '../../models/cart/cart'; | ||
2 | + | ||
3 | +const app = getApp(); | ||
4 | +const router = global.router; | ||
5 | + | ||
1 | Page({ | 6 | Page({ |
2 | data: { | 7 | data: { |
3 | }, | 8 | }, |
4 | onLoad() { | 9 | onLoad() { |
5 | 10 | ||
11 | + }, | ||
12 | + onShow() { | ||
13 | + this.getCartData(); | ||
14 | + | ||
15 | + }, | ||
16 | + goShopping() { | ||
17 | + router.go('home'); | ||
18 | + }, | ||
19 | + getCartData() { | ||
20 | + cartModel.getCartData({uid: app.getUid()}) | ||
21 | + .then(res => { | ||
22 | + if (res.code === 200 && res.data) { | ||
23 | + this._resolveCartData(res.data); | ||
24 | + } else { | ||
25 | + return Promise.reject(); | ||
26 | + } | ||
27 | + }) | ||
28 | + .catch(() => {}); | ||
29 | + }, | ||
30 | + _resolveCartData() { | ||
31 | + | ||
6 | } | 32 | } |
7 | }); | 33 | }); |
1 | -<view class="container"> | ||
2 | - <view>hello from the shopping cart!</view> | ||
3 | -</view> | 1 | +<block wx:if="{{curShoppingCartData.has_product_in_shop_cart}}"> |
2 | + 我是购物车内容 | ||
3 | +</block> | ||
4 | +<block wx:else> | ||
5 | + <view class='empty-cart'> | ||
6 | + <image src='../../static/images/empty_cart.png' class='empty-img'></image> | ||
7 | + <text class='empty-desc'>购物车空空如也\n去挑选中意的商品</text> | ||
8 | + <view class='shopping-btn' bindtap='goShopping'>去逛逛</view> | ||
9 | + </view> | ||
10 | +</block> |
1 | + | ||
2 | +.empty-cart .empty-img { | ||
3 | + display: block; | ||
4 | + width: 204rpx; | ||
5 | + height: 200rpx; | ||
6 | + margin: 300rpx auto 0 auto; | ||
7 | +} | ||
8 | + | ||
9 | +.empty-cart .empty-desc { | ||
10 | + display: block; | ||
11 | + width: 400rpx; | ||
12 | + margin: 60rpx auto 0 auto; | ||
13 | + color: #444; | ||
14 | + font-size: 26rpx; | ||
15 | + line-height: 1.4; | ||
16 | + text-align: center; | ||
17 | +} | ||
18 | + | ||
19 | +.empty-cart .shopping-btn { | ||
20 | + width: 360rpx; | ||
21 | + padding: 30rpx; | ||
22 | + margin: 60rpx auto 0 auto; | ||
23 | + color: #fff; | ||
24 | + font-size: 28rpx; | ||
25 | + text-align: center; | ||
26 | + border-radius: 4rpx; | ||
27 | + background-color: #444; | ||
28 | +} |
app/static/images/empty_cart.png
0 → 100755
2.71 KB
-
Please register or login to post a comment