微信小程序购物车新增删除功能
parent
31a895fa1a
commit
75ddce71d9
|
|
@ -12,6 +12,7 @@ namespace app\service;
|
|||
|
||||
use think\Db;
|
||||
use app\service\MessageService;
|
||||
use app\service\UserService;
|
||||
|
||||
/**
|
||||
* 积分服务层
|
||||
|
|
@ -53,6 +54,13 @@ class IntegralService
|
|||
$integral = ($data['type'] == 0) ? $data['original_integral']-$data['new_integral'] : $data['new_integral']-$data['original_integral'];
|
||||
$detail = $msg.'积分'.$type_msg.$integral;
|
||||
MessageService::MessageAdd($user_id, '积分变动', $detail);
|
||||
|
||||
// 用户登录数据更新防止数据存储session不同步展示
|
||||
if(in_array(APPLICATION_CLIENT_TYPE, ['pc', 'h5']))
|
||||
{
|
||||
UserService::UserLoginRecord($user_id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
<!-- 扩展数据展示 -->
|
||||
<view wx:if="{{extension_data.length > 0}}" class="extension-list spacing-mb">
|
||||
<view wx:for="{{extension_data}}" wx:key="key" class="item oh">
|
||||
<text class="cr-666">{{item.name}}
|
||||
<text class="cr-666 fl">{{item.name}}
|
||||
</text>
|
||||
<text class="text-tips fr">{{item.tips}}
|
||||
</text>
|
||||
|
|
|
|||
|
|
@ -175,38 +175,6 @@ Page({
|
|||
});
|
||||
},
|
||||
|
||||
// 滑动操作
|
||||
right_item_event(e) {
|
||||
var type = e.detail.type;
|
||||
var index = e.extra;
|
||||
var id = this.data.data_list[index]['id'];
|
||||
var goods_id = this.data.data_list[index]['goods_id'];
|
||||
|
||||
// 收藏
|
||||
if (type == 'edit') {
|
||||
this.goods_favor_event(id, goods_id, type);
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: '温馨提示',
|
||||
content: '删除后不可恢复,确定继续吗?',
|
||||
confirmText: '确定',
|
||||
cancelText: '取消',
|
||||
success: (result) => {
|
||||
if (result.confirm) {
|
||||
this.cart_delete(id, type);
|
||||
} else {
|
||||
this.setData({ swipe_index: null });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 滑动操作
|
||||
swipe_start_event(e) {
|
||||
this.setData({ swipe_index: e.index });
|
||||
},
|
||||
|
||||
// 收藏事件
|
||||
goods_favor_event(id, goods_id, type) {
|
||||
wx.request({
|
||||
|
|
@ -227,6 +195,26 @@ Page({
|
|||
});
|
||||
},
|
||||
|
||||
// 删除操作事件
|
||||
cart_delete_event(e) {
|
||||
var id = e.currentTarget.dataset.id || null;
|
||||
if (id !== null) {
|
||||
wx.showModal({
|
||||
title: '温馨提示',
|
||||
content: '删除后不可恢复,确定继续吗?',
|
||||
confirmText: '确认',
|
||||
cancelText: '暂不',
|
||||
success: (result) => {
|
||||
if (result.confirm) {
|
||||
this.cart_delete(id, 'delete');
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
app.showToast("参数有误");
|
||||
}
|
||||
},
|
||||
|
||||
// 购物车删除
|
||||
cart_delete(id, type) {
|
||||
wx.request({
|
||||
|
|
|
|||
|
|
@ -32,7 +32,12 @@
|
|||
<text class="sales-price">¥{{item.price}}</text>
|
||||
<text wx:if="{{item.original_price > 0}}" class="original-price">¥{{item.original_price}}</text>
|
||||
<text class="buy-number cr-888">x{{item.stock}}</text>
|
||||
|
||||
<!-- 删除操作 -->
|
||||
<view class="fr delete" data-id="{{item.id}}" bindtap="cart_delete_event">删除</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@
|
|||
.goods-item .selected {
|
||||
margin-top: 60rpx;
|
||||
}
|
||||
.goods-item .delete {
|
||||
color: #e00303;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数量操作
|
||||
|
|
|
|||
|
|
@ -806,7 +806,7 @@ function DataDelete(e)
|
|||
url:url,
|
||||
type:'POST',
|
||||
dataType:"json",
|
||||
timeout:e.attr('timeout') || 30000,
|
||||
timeout:e.attr('data-timeout') || 30000,
|
||||
data:{"id":id},
|
||||
success:function(result)
|
||||
{
|
||||
|
|
@ -926,7 +926,7 @@ function AjaxRequest(e)
|
|||
url:url,
|
||||
type:'POST',
|
||||
dataType:"json",
|
||||
timeout:e.attr('timeout') || 30000,
|
||||
timeout:e.attr('data-timeout') || 30000,
|
||||
data:{"id":id, "value": value, "field": field},
|
||||
success:function(result)
|
||||
{
|
||||
|
|
@ -1340,7 +1340,7 @@ $(function()
|
|||
var id = $tag.attr('data-id');
|
||||
var state = ($tag.attr('data-state') == 1) ? 0 : 1;
|
||||
var url = $tag.attr('data-url');
|
||||
var field = $tag.attr('field') || '';
|
||||
var field = $tag.attr('data-field') || '';
|
||||
var is_update_status = $tag.attr('data-is-update-status') || 0;
|
||||
if(id == undefined || url == undefined)
|
||||
{
|
||||
|
|
@ -1353,7 +1353,7 @@ $(function()
|
|||
url:url,
|
||||
type:'POST',
|
||||
dataType:"json",
|
||||
timeout:$tag.attr('timeout') || 30000,
|
||||
timeout:$tag.attr('data-timeout') || 30000,
|
||||
data:{"id":id, "state":state, "field":field},
|
||||
success:function(result)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue