Commit 3c042e234dcb9f154d04b7f9c8335d252e271127

Authored by yvan.ni
1 parent 5e5cdb22

购物车失效的优化

pages/cart/cart/cart.js
@@ -49,9 +49,9 @@ Page({ @@ -49,9 +49,9 @@ Page({
49 49
50 }, 50 },
51 onLoad: function () { 51 onLoad: function () {
  52 +
52 var a = this, 53 var a = this,
53 ee = a; 54 ee = a;
54 -  
55 55
56 wx.setNavigationBarTitle({ 56 wx.setNavigationBarTitle({
57 title: "购物车", 57 title: "购物车",
@@ -268,53 +268,67 @@ Page({ @@ -268,53 +268,67 @@ Page({
268 }, 268 },
269 //清空失效宝贝 269 //清空失效宝贝
270 delInva(obj=null){ 270 delInva(obj=null){
271 - let ainvalid='';  
272 - let binvalid='';  
273 - var user_id = getApp().globalData.user_id;  
274 - var th = this;  
275 - let ab = 0; //选中  
276 - let abc = 0; //  
277 - let arr = obj.id ? [obj] : this.data.invalidList  
278 - console.log('失效-----')  
279 - console.log(arr);  
280 - arr.map(item=>{  
281 - if (item.classType ==0 ) {  
282 - ainvalid+=item.id + ',';  
283 - ab = 1;  
284 - }  
285 - if (item.classType ==1 ) {  
286 - binvalid+=item.id + ',';  
287 - abc = 1;  
288 - }  
289 - }); 271 +
  272 + var th = this;
  273 + wx.showModal({
  274 + title: '提示',
  275 + content: '确认要清空全部失效商品吗?',
  276 + success(res) {
  277 + if (res.confirm) {
  278 + let ainvalid='';
  279 + let binvalid='';
  280 + var user_id = getApp().globalData.user_id;
  281 +
  282 + let ab = 0; //选中
  283 + let abc = 0; //
  284 + let arr = obj.id ? [obj] : th.data.invalidList
  285 + console.log('失效-----')
  286 + console.log(arr);
  287 + arr.map(item=>{
  288 + if (item.classType ==0 ) {
  289 + ainvalid+=item.id + ',';
  290 + ab = 1;
  291 + }
  292 + if (item.classType ==1 ) {
  293 + binvalid+=item.id + ',';
  294 + abc = 1;
  295 + }
  296 + });
  297 +
  298 +
  299 + if (ab == 0 && abc == 0 ) {
  300 + t.my_warnning('没有需要清空的失效宝贝', 0, th);
  301 + return false;
  302 + }
  303 + if (ab) {
  304 + ainvalid = ainvalid.substring(0, ainvalid.length - 1);
  305 + //要删除购物车中的商品
  306 + var url = '/api/weshop/cart/delIds/' + oo.stoid + '/' + user_id + '/' + ainvalid;
  307 + getApp().request.delete(url, {
  308 + success: function (t) {
  309 + th.getCardList();
  310 + getApp().requestCardNum(th);
  311 + }
  312 + });
  313 + }
  314 + if (abc) {
  315 + binvalid = binvalid.substring(0, binvalid.length - 1);
  316 + //要删除购物车中的商品
  317 + var url = '/api/weshop/cartService/delIds/' + oo.stoid + '/' + user_id + '/' + binvalid;
  318 + getApp().request.delete(url, {
  319 + success: function (t) {
  320 + th.getCardList();
  321 + getApp().requestCardNum(th);
  322 + }
  323 + });
  324 + }
  325 +
  326 + }
  327 + }
  328 + })
  329 +
290 330
291 331
292 - if (ab == 0 && abc == 0 ) {  
293 - t.my_warnning('没有需要清空的失效宝贝', 0, th);  
294 - return false;  
295 - }  
296 - if (ab) {  
297 - ainvalid = ainvalid.substring(0, ainvalid.length - 1);  
298 - //要删除购物车中的商品  
299 - var url = '/api/weshop/cart/delIds/' + oo.stoid + '/' + user_id + '/' + ainvalid;  
300 - getApp().request.delete(url, {  
301 - success: function (t) {  
302 - th.getCardList();  
303 - getApp().requestCardNum(th);  
304 - }  
305 - });  
306 - }  
307 - if (abc) {  
308 - binvalid = binvalid.substring(0, binvalid.length - 1);  
309 - //要删除购物车中的商品  
310 - var url = '/api/weshop/cartService/delIds/' + oo.stoid + '/' + user_id + '/' + binvalid;  
311 - getApp().request.delete(url, {  
312 - success: function (t) {  
313 - th.getCardList();  
314 - getApp().requestCardNum(th);  
315 - }  
316 - });  
317 - }  
318 }, 332 },
319 333
320 //---------点击收藏------------ 334 //---------点击收藏------------
@@ -3242,6 +3256,21 @@ Page({ @@ -3242,6 +3256,21 @@ Page({
3242 }); 3256 });
3243 } 3257 }
3244 3258
  3259 + setTimeout(()=>{
  3260 + if ((!th.data.requestData|| th.data.requestData.length==0) && (!th.data.service_data|| th.data.service_data.length==0)){
  3261 +
  3262 + console.log('---1111---bb');
  3263 + var goods_list = th.selectComponent("#goods_list"); //组件的id
  3264 + if (goods_list) {
  3265 + goods_list.init();
  3266 + goods_list.get_list();
  3267 + }
  3268 +
  3269 + }
  3270 +
  3271 + },1200)
  3272 +
  3273 +
3245 }, 3274 },
3246 //跳到首页 3275 //跳到首页
3247 goto: function (e) { 3276 goto: function (e) {
pages/cart/cart/cart.wxml
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 </block> 23 </block>
24 24
25 25
26 -<view class="container" wx:if="{{(requestData && requestData.length>0) || (service_data && service_data.length>0) }}"> 26 +<view class="container {{(requestData && requestData.length>0) || (service_data && service_data.length>0)?'margin_b':''}} " wx:if="{{(requestData && requestData.length>0) || (service_data && service_data.length>0) || invalidList && invalidList.length }}">
27 <!-- 购物车商品框架 --> 27 <!-- 购物车商品框架 -->
28 <view class="login-in"> 28 <view class="login-in">
29 <!-- 编辑 --> 29 <!-- 编辑 -->
@@ -276,7 +276,7 @@ @@ -276,7 +276,7 @@
276 </block> 276 </block>
277 277
278 </view> 278 </view>
279 - <view class="pay-for flex-vertical-between"> 279 + <view class="pay-for flex-vertical-between" wx:if="{{(requestData && requestData.length>0) || (service_data && service_data.length>0)}}" >
280 <view class="allradio flex-vertical-between"> 280 <view class="allradio flex-vertical-between">
281 <view class="flex-vertical mlr" bindtap="checkAll"> 281 <view class="flex-vertical mlr" bindtap="checkAll">
282 <!--<radio class="order-raido" color="red" checked="{{checkAllToggle}}"></radio>--> 282 <!--<radio class="order-raido" color="red" checked="{{checkAllToggle}}"></radio>-->
@@ -306,7 +306,7 @@ @@ -306,7 +306,7 @@
306 </view> 306 </view>
307 307
308 <!-- 购物车为空 --> 308 <!-- 购物车为空 -->
309 -<view class="empty_order" wx:if="{{(!requestData|| requestData.length==0) && (!service_data|| service_data.length==0) && is_load}}"> 309 +<view class="empty_order" wx:if="{{(!requestData|| requestData.length==0) && (!service_data|| service_data.length==0) && (!invalidList || invalidList.length==0) && is_load}}">
310 <view class="flex-level"> 310 <view class="flex-level">
311 <image src="{{iurl}}miniapp/images/stores/nocart.png"></image> 311 <image src="{{iurl}}miniapp/images/stores/nocart.png"></image>
312 </view> 312 </view>
pages/cart/cart/cart.wxss
@@ -30,6 +30,9 @@ page { @@ -30,6 +30,9 @@ page {
30 align-items: center; 30 align-items: center;
31 justify-content: center; 31 justify-content: center;
32 background-color: rgb(255, 255, 255); 32 background-color: rgb(255, 255, 255);
  33 + /*margin-bottom: 160rpx;*/
  34 +}
  35 +.container.margin_b{
33 margin-bottom: 160rpx; 36 margin-bottom: 160rpx;
34 } 37 }
35 38