Authored by yyq

change animation

... ... @@ -21,11 +21,6 @@ Component({
value: '',
observer: '_selectChange'
},
touchKey: {
type: String,
value: '',
observer: '_touchChange'
},
isInvalid: {
type: Boolean,
value: false
... ... @@ -113,8 +108,10 @@ Component({
}
},
toggleAnimation(isShow) {
this._isShowMore = isShow;
this.setData({scrollLeft: isShow ? this.data.slideWidth : 0});
if (this._isShowMore !== isShow || (!isShow && this._scollLeft > 0)) {
this._isShowMore = isShow;
this.setData({scrollLeft: isShow ? this.data.slideWidth : 0});
}
},
touchStartAction(e) {
this._touchStart = false;
... ... @@ -138,11 +135,14 @@ Component({
return;
}
let slideWidth = this.data.slideWidth;
let touchEnd = e.changedTouches[0];
let offsetX = this._touchStart.clientX - touchEnd.clientX;
if (offsetX > 0) {
if (offsetX >= slideWidth) {
this._isShowMore = true;
} else if (offsetX > 0) {
let show = false;
if (offsetX > this.data.slideWidth * 0.3) {
... ... @@ -152,6 +152,9 @@ Component({
this.toggleAnimation(show);
}
},
onScoll(e) {
this._scollLeft = e.detail.scrollLeft;
},
chooseItemAction() {
let item = {...this.data.item};
... ... @@ -187,5 +190,15 @@ Component({
editGoodsColorSize(e) {
this.triggerEvent('editGoodsColorSize', e.detail);
}
},
created() {
let pages = getCurrentPages();
let currentPage = pages[pages.length - 1];
if (currentPage && currentPage.event && currentPage.event.on) {
currentPage.event.on('cart-touch-start', key => {
this._touchChange(key);
});
}
}
});
... ...
<wxs src="../../../wxs/helper.wxs" module="helper" />
<view class="goods-item" bindtouchstart="touchStartAction" bindtouchend="touchEndAction">
<scroll-view scroll-x="true" scroll-left="{{scrollLeft}}" scroll-with-animation="true">
<scroll-view scroll-x="true" scroll-left="{{scrollLeft}}" scroll-with-animation="true" bindscroll="onScoll">
<view class="scoll-wrap" style="padding-right: {{slideWidth}}px;">
<view class="goods-item-wrap">
<view class="choose-btn" bindtap="chooseItemAction">
... ...
import wx from '../../utils/wx';
import event from '../../common/event';
import formatImage from '../../utils/formatImage';
import detailModel from '../../models/product/detail';
import cartModel from '../../models/cart/cart';
... ... @@ -49,6 +50,9 @@ Page({
}
},
onLoad() {
this.event = {...event};
this.event.removeAllListeners();
Picker.init(this);
},
onShow() {
... ... @@ -163,7 +167,7 @@ Page({
touchKey = e.detail.indexKey;
}
this.setData({touchKey});
this.event.emit('cart-touch-start', touchKey);
},
showMorePromotion(e) {
let pid = e.currentTarget.dataset.pid;
... ... @@ -421,7 +425,9 @@ Page({
return this.showToast('您还没有选择宝贝哦');
}
if (this.data.matchGiftIds && this.data.matchGiftIds.length > 0) {
let matchGiftIds = this.data.matchGiftIds;
if (matchGiftIds && matchGiftIds.length > 0) {
return this.showModal('您还未选择赠品,是否去选择赠品?', {
cancelText: '不要赠品',
confirmText: '去选择',
... ... @@ -429,11 +435,18 @@ Page({
cancelColor: '#444444',
}).then(res => {
if (res.confirm) {
// TODO 去选择赠品
// that.navToChooseGiftPage();
} else if (res.cancel) {
// 直接跳转 结算页面
router.go('cartEnsure');
// 去选择赠品
let ids = [];
matchGiftIds.map(item => {
ids.push(item);
});
router.go('cartGift', {
promotion_id: ids.join(','),
is_gift: 1,
status: 10
});
}
});
}
... ...
... ... @@ -25,7 +25,7 @@
</view>
</view>
<scroll-view scroll-y class="cart-scoll-wrap" bindtouchstart="touchStartAction">
<view class="tips-wrap" wx:if="{{priceDownTips || shippingCostTips}}">
<view class="tips-wrap hide-wrap" wx:if="{{priceDownTips || shippingCostTips}}">
<view class="hold-text">
<text>{{priceDownTips || shippingCostTips}}</text>
</view>
... ...
... ... @@ -47,6 +47,10 @@ page {
font-size: 24rpx;
}
.hide-wrap {
visibility: hidden;
}
.tips-wrap .hold-text,
.tips-wrap .fixed-top-tips {
padding: 16rpx 30rpx;
... ...
<template name="cartGoodsList">
<block wx:if="{{goodsList.length}}">
<block wx:for="{{goodsList}}" wx:key="unique">
<cart-item goods="{{item}}" index="{{index}}" isEditing="{{isEditing}}" isEditSelectAll="{{isEditSelectAll}}" isInvalid="{{isInvalid}}" touchKey="{{touchKey}}" bind:chooseGoodsItem="chooseGoodsItem" bind:removeGoodsListInEdit="removeGoodsListInEdit" bind:editGoodsNum="editGoodsNum" bind:editGoodsColorSize="editGoodsColorSize" bind:removeGoods="removeGoods" bind:goodsItemTouched="touchStartAction" bind:navToDetailPage="navToDetailPage"></cart-item>
<cart-item goods="{{item}}" index="{{index}}" isEditing="{{isEditing}}" isEditSelectAll="{{isEditSelectAll}}" isInvalid="{{isInvalid}}" bind:chooseGoodsItem="chooseGoodsItem" bind:removeGoodsListInEdit="removeGoodsListInEdit" bind:editGoodsNum="editGoodsNum" bind:editGoodsColorSize="editGoodsColorSize" bind:removeGoods="removeGoods" bind:goodsItemTouched="touchStartAction" bind:navToDetailPage="navToDetailPage"></cart-item>
</block>
</block>
</template>
... ...
... ... @@ -12,14 +12,14 @@
<template is="cartPromotionList" data="{{promotionList: sItem.promotion_list, promotionMapId: sItem.promotionMapId, isSub: true}}"/>
<view class="list-warp">
<template is="cartGoodsList" data="{{goodsList: sItem.goods_list, isEditing, isEditSelectAll, touchKey}}"/>
<template is="cartGoodsList" data="{{goodsList: sItem.goods_list, isEditing, isEditSelectAll}}"/>
</view>
</block>
</block>
<cart-bundle-head bundle="{{item}}" index="{{index}}" isEditing="{{isEditing}}" bind:chooseGoodsBundle="chooseGoodsBundle" bind:removeGoodsListInEdit="removeGoodsListInEdit" bind:editBundleNum="editBundleNum"></cart-bundle-head>
<template is="cartGoodsList" data="{{goodsList: item.goods_list, isEditing, isEditSelectAll, touchKey}}"/>
<template is="cartGoodsList" data="{{goodsList: item.goods_list, isEditing, isEditSelectAll}}"/>
<view class="split-line"></view>
</block>
... ...