fix[litemall-wx]: 用户足迹删除不成功。

This commit is contained in:
Junling Bu
2018-05-18 23:30:59 +08:00
parent d97bb18cdc
commit 4aa3f20495
2 changed files with 14 additions and 7 deletions

View File

@@ -41,7 +41,9 @@ Page({
},
deleteItem (event){
let that = this;
let footprint = event.currentTarget.dataset.footprint;
let index = event.currentTarget.dataset.index;
let iindex = event.currentTarget.dataset.iindex;
let goodsId = this.data.footprintList[index][iindex].id;
var touchTime = that.data.touchEnd - that.data.touchStart;
console.log(touchTime);
//如果按下时间大于350为长按
@@ -51,15 +53,20 @@ Page({
content: '要删除所选足迹?',
success: function (res) {
if (res.confirm) {
util.request(api.FootprintDelete, { footprintId: footprint.id }, 'POST').then(function (res) {
util.request(api.FootprintDelete, { footprintId: goodsId }, 'POST').then(function (res) {
if (res.errno === 0) {
wx.showToast({
title: '删除成功',
icon: 'success',
duration: 2000
});
that.data.footprintList = [];
that.getFootprintList();
that.data.footprintList[index].splice(iindex, 1)
if (that.data.footprintList[index].length == 0){
that.data.footprintList.splice(index, 1)
}
that.setData({
footprintList: that.data.footprintList
});
}
});
}
@@ -67,7 +74,7 @@ Page({
});
} else {
wx.navigateTo({
url: '/pages/goods/goods?id=' + footprint.goodsId,
url: '/pages/goods/goods?id=' + goodsId,
});
}

View File

@@ -6,10 +6,10 @@
</view>
</view>
<view class="footprint" wx:if="{{footprintList.length > 0}}">
<view class="day-item" wx:for="{{footprintList}}" wx:key="*this">
<view class="day-item" wx:for="{{footprintList}}" wx:key="*this" wx:for-index="index">
<view class="day-hd" wx:if="{{item.length > 0}}">{{item[0].addTime}}</view>
<view class="day-list" wx:if="{{item.length > 0}}">
<view class="item" data-footprint="{{iitem}}" bindtouchstart="touchStart" bindtouchend="touchEnd" bindtap="deleteItem" wx:for="{{item}}" wx:for-item="iitem" wx:key="id">
<view class="item" data-index="{{index}}" data-iindex="{{iindex}}" bindtouchstart="touchStart" bindtouchend="touchEnd" bindtap="deleteItem" wx:for="{{item}}" wx:for-index="iindex" wx:for-item="iitem" wx:key="id">
<image class="img" src="{{iitem.listPicUrl}}"></image>
<view class="info">
<view class="name">{{iitem.name}}</view>