Commit 89f02c51a5e94811735e3717a8dc595846f3a947

Authored by yvan.ni
1 parent 54ff6ce6

1.全部包邮,不包邮区域,不包邮产品

2. 包邮券,不包邮区域,不包邮产品
pages/cart/cart2/cart2.js
1 var t = getApp(),app=t, a = t.request, e = require("../../../utils/common.js"), 1 var t = getApp(),app=t, a = t.request, e = require("../../../utils/common.js"),
2 - s = require("../../../utils/util.js"), o = require("../../../utils/md5.js"), to = getApp(); 2 + s = require("../../../utils/util.js"),ut=s, o = require("../../../utils/md5.js"), to = getApp();
3 var oo=t.globalData.setting,os=oo; 3 var oo=t.globalData.setting,os=oo;
4 var regeneratorRuntime = require('../../../utils/runtime.js'); 4 var regeneratorRuntime = require('../../../utils/runtime.js');
5 var util_pay = require("../../../utils/pay.js"); 5 var util_pay = require("../../../utils/pay.js");
@@ -85,8 +85,17 @@ Page({ @@ -85,8 +85,17 @@ Page({
85 is_shipping_code:"",//插入用户默认地址 85 is_shipping_code:"",//插入用户默认地址
86 wu_arr_txt:"", //要更新的物流的字段 86 wu_arr_txt:"", //要更新的物流的字段
87 87
88 - sales_rules:1, //默认是显示线上库存  
89 - 88 + sales_rules:1, //默认是显示线上库存
  89 + isget_by_quan:{}, //是否调用了接口获取包邮券
  90 + get_by_quan_list:null, //立即购买的
  91 + get_by_quan_list_cart:{}, //购物车的
  92 + by_quan_list_cart:null, //点击选择的包邮列表
  93 +
  94 + //如果是全场包邮了,或者是全场不包邮了,就不要选包邮券
  95 + is_no_by:{},
  96 + is_by:{},
  97 + is_quan_by:{},
  98 +
90 }, 99 },
91 onLoad: function(t) { 100 onLoad: function(t) {
92 101
@@ -111,6 +120,13 @@ Page({ @@ -111,6 +120,13 @@ Page({
111 120
112 }, 121 },
113 onUnload: function () { this.setData({ isclose: 1 })}, 122 onUnload: function () { this.setData({ isclose: 1 })},
  123 + onHide: function () {
  124 + this.setData({
  125 + isget_by_quan:{},
  126 + is_no_by:{},
  127 + is_by:{}
  128 + })
  129 + },
114 130
115 //----------子页返回父页触发---------- 131 //----------子页返回父页触发----------
116 onShow: function() { 132 onShow: function() {
@@ -454,11 +470,26 @@ Page({ @@ -454,11 +470,26 @@ Page({
454 var umoney = th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money; 470 var umoney = th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money;
455 471
456 var freight_free = ee.freight_free; //全场满多少包邮 472 var freight_free = ee.freight_free; //全场满多少包邮
457 - var c_arr=th.data.cartlist; 473 + var no_ex_id=ee.no_ex_id;
  474 + var no_ex_good=null;
  475 + var by_qc={};
  476 +
  477 + if(no_ex_id && freight_free>0){
  478 + //-----------获取不包邮区域,不包邮商品-------
  479 + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods",{
  480 + data:{store_id:os.stoid,id:no_ex_id}
  481 + }).then(res=>{
  482 + if(res.data.code==0){
  483 + by_qc=res.data.data[0];
  484 + }
  485 + })
  486 + }
458 487
  488 + var c_arr=th.data.cartlist;
459 //---循环购物车--- 489 //---循环购物车---
460 for(var i=0;i<c_arr.length;i++){ 490 for(var i=0;i<c_arr.length;i++){
461 var cart_item=c_arr[i]; 491 var cart_item=c_arr[i];
  492 + var pickid=cart_item.pickup_id;
462 var o_price=0; 493 var o_price=0;
463 var o_shipping_price=0,goods_weight=-1, goods_piece=-1; 494 var o_shipping_price=0,goods_weight=-1, goods_piece=-1;
464 var item=c_arr[i].goods; 495 var item=c_arr[i].goods;
@@ -466,37 +497,138 @@ Page({ @@ -466,37 +497,138 @@ Page({
466 497
467 //--------循环计算总价----------- 498 //--------循环计算总价-----------
468 for(var j=0;j<item.length;j++){ 499 for(var j=0;j<item.length;j++){
469 - o_price += item[j].goods_price * item[j].goods_num;  
470 - th.data.cartlist[i].goods_price = o_price.toFixed(2); //商品总费用  
471 - //计算物流费用  
472 - th.data.cartlist[i].shipping_price = 0;  
473 - //----------------如果是选择了物流---------------------  
474 - if (c_arr[i].exp_type == 0 && item[j].is_free_shipping==0){  
475 - //如果地址不为空  
476 - if (th.data.user_addr!=null){  
477 - switch (item[j]['exp_sum_type']) {  
478 - case 1:  
479 - //统一运费  
480 - o_shipping_price += item[j]['uniform_exp_sum'];break;  
481 - case 2:  
482 - if (goods_weight < 0) goods_weight = 0;  
483 - //累积商品重量 每种商品的重量 * 数量  
484 - goods_weight += item[j]['weight'] * item[j]['goods_num']; break;  
485 - case 3:  
486 - if (goods_piece < 0) goods_piece = 0;  
487 - //累积商品数量  
488 - goods_piece += item[j]['goods_num'];break;  
489 - } 500 + o_price += item[j].goods_price * item[j].goods_num;
  501 + }
  502 +
  503 + th.data.cartlist[i].goods_price = o_price.toFixed(2); //商品总费用
  504 + //计算物流费用
  505 + th.data.cartlist[i].shipping_price = 0;
  506 +
  507 + //--有不包邮区域,且不免运费,全场的计算--
  508 + if(no_ex_id && freight_free>0 && o_price>freight_free && c_arr[i].exp_type == 0 && (by_qc.region_list || by_qc.goods_list) ){
  509 + //如果有设置不包邮区域的时候
  510 + if(by_qc.region_list){
  511 + if(th.check_by_area(by_qc.region_list)){
  512 + freight_free=0;
  513 + th.data.is_no_by[pickid]=1;
490 } 514 }
491 } 515 }
  516 + //如果有设置不包邮区商品
  517 + if(by_qc.goods_list && freight_free){
  518 + no_ex_good=res.data.data.goods_list;
  519 + }
  520 + }
  521 +
  522 + //--如果是物流,且选择了地址,就要开始显示包邮券--
  523 + if (c_arr[i].exp_type == 0 && th.data.user_addr != null) {
  524 + //看是不是有调用过包邮券
  525 + if(!th.data.isget_by_quan[pickid]){
  526 + //--判断要不要显示包邮券,链式调用接口---
  527 + getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea",{
  528 + data:{store_id:os.stoid,isuse:0,condition:o_price,user_id:getApp().globalData.user_id}
  529 + }).then(res=>{
  530 + if(res.data.code==0 && res.data.data.total>0){
  531 + //此时要循环判断包邮的地区,不包邮商品是不是符合
  532 + var arr=[],quanlist=res.data.data.pageData;
  533 + quanlist = th.check_is_frozenQuan(quanlist, th.data.frozenQuan,1);
  534 + for(var i in quanlist){
  535 + var item=quanlist[i];
  536 + var goods=cart_item.goods;
  537 + var g_arr=[];
  538 + for(var ii in goods){
  539 + g_arr.push(goods[ii].goods_id);
  540 + }
  541 +
  542 + if(item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域
  543 + if(item.goods_list){
  544 + var no_goods_arr=item.goods_list.split(",");
  545 + if(ut.isContained(no_goods_arr,g_arr)) continue; //如果是不包邮商品
  546 + }
  547 + arr.push(item);
  548 + }
  549 + if(arr){
  550 + th.data.get_by_quan_list_cart[pickid]=arr;
  551 + th.setData({get_by_quan_list_cart:th.data.get_by_quan_list_cart});
  552 + }
  553 + th.data.isget_by_quan[pickid]=1;
  554 + }
  555 + })
  556 + }
  557 + }
  558 +
  559 + var quan_no=null;
  560 + if(th.data.using_quan[pickid])quan_no=th.data.using_quan[pickid].coupon_no;
  561 + //如果是包邮券的时候,要看看券的情况
  562 + if(quan_no && th.data.using_quan[pickid].isby==1){
  563 + var quan=th.data.using_quan[pickid];
  564 + if(!quan.goods_list){
  565 + th.data.is_quan_by[pickid]=1; //专门给券的判断用的
  566 + }else{
  567 + th.data.is_quan_by[pickid]=0;
  568 + //看有没有模板的包邮
  569 + if(no_ex_good){
  570 + var arr=no_ex_good.split(",");
  571 + var arr2=quan.goods_list.split(",");
  572 + if(ut.isContained(arr,arr2)){
  573 + getApp().my_warnning("全场不包邮商品和包邮券的重复",0,th);
  574 + return false;
  575 + }
  576 + var n_arr=ut.mergeArray(arr,arr2);
  577 + no_ex_good=n_arr.join(",");
  578 + }else{
  579 + no_ex_good=quan.goods_list;
  580 + }
  581 + }
  582 + }else{
  583 + th.data.is_quan_by[pickid]=0; //专门给券的判断用的
492 } 584 }
493 585
  586 + //--------循环计算总价-----------
  587 + for(var j=0;j<item.length;j++){
  588 + //如果都包邮,都没必要等级数量了
  589 + if(th.data.is_quan_by[pickid]) continue;
  590 + //是不是不包邮的商品
  591 + var is_good_no_by=0;
  592 + if(no_ex_good){
  593 + is_good_no_by=th.check_by_goods(no_ex_good,item[j].goods_id);
  594 + }
  595 + //如果达到全场包邮的条件,同时,没有地区不包邮,或者商品不包邮
  596 + if(o_price>freight_free && freight_free>0 && !is_good_no_by && th.data.is_no_by[pickid]!=1) continue;
  597 + //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算--
  598 + if(th.data.using_quan[pickid] && th.data.using_quan[pickid].isby==1 && !is_good_no_by) continue;
  599 +
  600 + //----------------如果是选择了物流---------------------
  601 + if (c_arr[i].exp_type == 0 && item[j].is_free_shipping==0){
  602 + //如果地址不为空
  603 + if (th.data.user_addr!=null){
  604 + switch (item[j]['exp_sum_type']) {
  605 + case 1:
  606 + //统一运费
  607 + o_shipping_price += item[j]['uniform_exp_sum'];break;
  608 + case 2:
  609 + if (goods_weight < 0) goods_weight = 0;
  610 + //累积商品重量 每种商品的重量 * 数量
  611 + goods_weight += item[j]['weight'] * item[j]['goods_num']; break;
  612 + case 3:
  613 + if (goods_piece < 0) goods_piece = 0;
  614 + //累积商品数量
  615 + goods_piece += item[j]['goods_num'];break;
  616 + }
  617 + }
  618 + }
  619 + }
  620 +
  621 +
494 //计算物流价格 622 //计算物流价格
495 if (c_arr[i].exp_type == 0) { 623 if (c_arr[i].exp_type == 0) {
496 var code = th.data.wu_arr[c_arr[i].wind].code; 624 var code = th.data.wu_arr[c_arr[i].wind].code;
497 th.data.cartlist[i].shipping_price = 625 th.data.cartlist[i].shipping_price =
498 th.calculatewuliu(code, o_shipping_price, goods_weight, 626 th.calculatewuliu(code, o_shipping_price, goods_weight,
499 goods_piece,th.data.user_addr, freight_free, o_price, rs); 627 goods_piece,th.data.user_addr, freight_free, o_price, rs);
  628 +
  629 + if(!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby!=1){
  630 + if( th.data.cartlist[i].shipping_price ==0) th.data.is_by[pickid]=0; //已经全场包邮,就不要选择券了
  631 + }
500 }else{ 632 }else{
501 th.data.cartlist[i].shipping_price=0; 633 th.data.cartlist[i].shipping_price=0;
502 } 634 }
@@ -504,26 +636,33 @@ Page({ @@ -504,26 +636,33 @@ Page({
504 th.data.cartlist[i].shipping_price=th.data.cartlist[i].shipping_price.toFixed(2); 636 th.data.cartlist[i].shipping_price=th.data.cartlist[i].shipping_price.toFixed(2);
505 //---如果有选择优惠券的情况下--- 637 //---如果有选择优惠券的情况下---
506 var quan_price=0; 638 var quan_price=0;
507 - var coupon_price=0,bn_pick=th.data.bn_pick,pickid=cart_item.pickup_id;  
508 - console.log("calculatePrice--quan"); 639 + var coupon_price=0;
509 var quan_no= null; 640 var quan_no= null;
510 641
511 if(th.data.using_quan[pickid]!=null && th.data.using_quan[pickid]!=undefined) 642 if(th.data.using_quan[pickid]!=null && th.data.using_quan[pickid]!=undefined)
512 quan_no=th.data.using_quan[pickid].coupon_no; 643 quan_no=th.data.using_quan[pickid].coupon_no;
513 644
514 if(quan_no){ 645 if(quan_no){
515 - //---获取优惠券优惠---  
516 - await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice",{  
517 - data:{storeId:oo.stoid,CashRepNo:quan_no, WaresSum:cart_item.check_quan_price_list, WareIds:cart_item.check_quan_ware_list}  
518 - }).then(res=>{  
519 - if(res.data.code==0 && res.data.data.length>0){  
520 - var q_data=res.data.data; 646 + //如果不是包邮券的时候
  647 + if(th.data.using_quan[pickid] && th.data.using_quan[pickid].isby!=1) {
  648 + //---获取优惠券优惠---
  649 + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", {
  650 + data: {
  651 + storeId: oo.stoid,
  652 + CashRepNo: quan_no,
  653 + WaresSum: cart_item.check_quan_price_list,
  654 + WareIds: cart_item.check_quan_ware_list
  655 + }
  656 + }).then(res => {
  657 + if (res.data.code == 0 && res.data.data.length > 0) {
  658 + var q_data = res.data.data;
521 //--存储商品优惠的内容-- 659 //--存储商品优惠的内容--
522 - th.data.cartlist[i].quan_youhui_list=q_data;  
523 - for(var k in q_data )  
524 - quan_price+=q_data[k].WareCashSum;  
525 - }  
526 - }) 660 + th.data.cartlist[i].quan_youhui_list = q_data;
  661 + for (var k in q_data)
  662 + quan_price += q_data[k].WareCashSum;
  663 + }
  664 + })
  665 + }
527 } 666 }
528 667
529 //总价计算,总价不包含运费 668 //总价计算,总价不包含运费
@@ -559,6 +698,8 @@ Page({ @@ -559,6 +698,8 @@ Page({
559 698
560 if (coupon_price>0) th.data.cartlist[i].coupon_price=coupon_price.toFixed(2); 699 if (coupon_price>0) th.data.cartlist[i].coupon_price=coupon_price.toFixed(2);
561 else th.data.cartlist[i].coupon_price = coupon_price 700 else th.data.cartlist[i].coupon_price = coupon_price
  701 + if(quan_no) th.data.cartlist[i].quan_no = quan_no;
  702 +
562 703
563 th.data.cartlist[i].goods_price = o_price.toFixed(2); 704 th.data.cartlist[i].goods_price = o_price.toFixed(2);
564 th.data.cartlist[i].order_amount= th.data.cartlist[i].order_amount- th.data.cartlist[i].user_money; //会员使用余额 705 th.data.cartlist[i].order_amount= th.data.cartlist[i].order_amount- th.data.cartlist[i].user_money; //会员使用余额
@@ -591,13 +732,10 @@ Page({ @@ -591,13 +732,10 @@ Page({
591 th.setData({ [atxt]: all_total_m, [atxt1]: all_order_m, 732 th.setData({ [atxt]: all_total_m, [atxt1]: all_order_m,
592 [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m, [atxt5]: all_coupon_price_m }) 733 [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m, [atxt5]: all_coupon_price_m })
593 734
594 - console.log('formData',th.data.formData);  
595 - console.log("------------------------");  
596 735
597 }); 736 });
598 }); 737 });
599 }, 738 },
600 -  
601 //---------计算立即购买---------- 739 //---------计算立即购买----------
602 calculatePrice2: function () { 740 calculatePrice2: function () {
603 741
@@ -615,6 +753,31 @@ Page({ @@ -615,6 +753,31 @@ Page({
615 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; 753 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
616 //-----------当地址不为空,且是物流时,计算物流费用---------- 754 //-----------当地址不为空,且是物流时,计算物流费用----------
617 if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 ){ 755 if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 ){
  756 +
  757 + //看是不是有调用过包邮券
  758 + if(!th.data.isget_by_quan[th.data.bn_pick]){
  759 + //--判断要不要显示包邮券,链式调用接口---
  760 + getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea",{
  761 + data:{store_id:os.stoid,isuse:0,condition:allpice,user_id:getApp().globalData.user_id}
  762 + }).then(res=>{
  763 + if(res.data.code==0 && res.data.data.total>0){
  764 + //此时要循环判断包邮的地区,不包邮商品是不是符合
  765 + var arr=[],quanlist=res.data.data.pageData;
  766 + quanlist = th.check_is_frozenQuan(quanlist, th.data.frozenQuan,1);
  767 + for(var i in quanlist){
  768 + var item=quanlist[i];
  769 + if(item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域
  770 + if(item.goods_list && th.check_by_goods(item.goods_list)) continue; //如果是不包邮商品
  771 + arr.push(item);
  772 + }
  773 + if(arr){
  774 + th.setData({get_by_quan_list:arr});
  775 + }
  776 + th.data.isget_by_quan[th.data.bn_pick]=1;
  777 + }
  778 + })
  779 + }
  780 +
618 switch (good['exp_sum_type']) { 781 switch (good['exp_sum_type']) {
619 case 1: 782 case 1:
620 //统一运费 783 //统一运费
@@ -630,36 +793,74 @@ Page({ @@ -630,36 +793,74 @@ Page({
630 } 793 }
631 794
632 var code = th.data.wu_arr[th.data.index].code; 795 var code = th.data.wu_arr[th.data.index].code;
633 - var freight_free = ee.freight_free; //全场满多少包邮 796 + var freight_free = ee.freight_free; //全场满多少包邮
  797 + var no_ex_id=ee.no_ex_id;
  798 + th.data.is_no_by[th.data.bn_pick]=0;
  799 +
  800 + //有不包邮区域,且不免运费
  801 + if(no_ex_id && freight_free>0 && freight_free<=allpice){
  802 + //-----------获取不包邮区域,不包邮商品-------
  803 + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods",{
  804 + data:{store_id:os.stoid,id:no_ex_id}
  805 + }).then(res=>{
  806 + if(res.data.code==0){
  807 + //如果有设置不包邮区域的时候
  808 + if(res.data.data[0].region_list){
  809 + if(th.check_by_area(res.data.data[0].region_list)){
  810 + freight_free=0;
  811 + th.data.is_no_by[th.data.bn_pick]=1;
  812 + }
  813 + }
  814 + //如果有设置不包邮商品
  815 + if(res.data.data[0].goods_list && freight_free){
  816 + if(th.check_by_goods(res.data.data[0].goods_list)){
  817 + freight_free=0;
  818 + th.data.is_no_by[th.data.bn_pick]=1;
  819 + }
  820 + }
  821 + }
  822 + })
  823 + }
  824 +
  825 + th.data.is_by[th.data.bn_pick]=0;
  826 + //--------------开始计算物流------------------
634 var shipping_price= 827 var shipping_price=
635 th.calculatewuliu(code, o_shipping_price, goods_weight, 828 th.calculatewuliu(code, o_shipping_price, goods_weight,
636 goods_piece, th.data.user_addr, freight_free, allpice, rs); 829 goods_piece, th.data.user_addr, freight_free, allpice, rs);
  830 + if(shipping_price<=0){
  831 + th.data.is_by[th.data.bn_pick]=1; //已经是包邮了,就不要选择包邮券
  832 + }
637 833
638 shipping_price = parseFloat(shipping_price).toFixed(2); 834 shipping_price = parseFloat(shipping_price).toFixed(2);
639 var wl_txt = "formData.shipping_price"; 835 var wl_txt = "formData.shipping_price";
640 th.setData({ [wl_txt]: shipping_price, }) 836 th.setData({ [wl_txt]: shipping_price, })
641 - 837 +
642 }else{ 838 }else{
643 var wl_txt = "formData.shipping_price"; 839 var wl_txt = "formData.shipping_price";
644 th.setData({ [wl_txt]: 0, }) 840 th.setData({ [wl_txt]: 0, })
645 } 841 }
646 -  
647 //---如果有选择优惠券的情况下--- 842 //---如果有选择优惠券的情况下---
648 var quan_price=0,bn_pick=th.data.bn_pick; 843 var quan_price=0,bn_pick=th.data.bn_pick;
649 -  
650 var quan_no=null; 844 var quan_no=null;
651 if(th.data.using_quan[bn_pick]!=null && th.data.using_quan[bn_pick]!=undefined) 845 if(th.data.using_quan[bn_pick]!=null && th.data.using_quan[bn_pick]!=undefined)
652 quan_no=th.data.using_quan[bn_pick].coupon_no; 846 quan_no=th.data.using_quan[bn_pick].coupon_no;
653 if(quan_no){ 847 if(quan_no){
654 var aa=1; 848 var aa=1;
655 - //---获取优惠券优惠---  
656 - await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice",{  
657 - data:{storeId:oo.stoid,CashRepNo:quan_no, WaresSum:th.data.ckeck_quan_price, WareIds:th.data.check_quan_ware_list}  
658 - }).then(res=>{  
659 - if(res.data.code==0){  
660 - quan_price=res.data.data[0].WareCashSum;  
661 - }  
662 - }) 849 + if(th.data.using_quan[bn_pick].isby==1){
  850 + shipping_price=0;
  851 + var wl_txt = "formData.shipping_price";
  852 + th.setData({ [wl_txt]: 0, })
  853 + }else{
  854 + //---获取优惠券优惠---
  855 + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice",{
  856 + data:{storeId:oo.stoid,CashRepNo:quan_no, WaresSum:th.data.ckeck_quan_price, WareIds:th.data.check_quan_ware_list}
  857 + }).then(res=>{
  858 + if(res.data.code==0){
  859 + quan_price=res.data.data[0].WareCashSum;
  860 + }
  861 + })
  862 + }
  863 +
663 } 864 }
664 //-----------------支付价,优惠券不减物流----------------- 865 //-----------------支付价,优惠券不减物流-----------------
665 var total_m = (parseFloat(allpice)).toFixed(2); 866 var total_m = (parseFloat(allpice)).toFixed(2);
@@ -676,11 +877,9 @@ Page({ @@ -676,11 +877,9 @@ Page({
676 var atxt= "formData.total_amount"; 877 var atxt= "formData.total_amount";
677 th.setData({ [atxt]: total_m, }) 878 th.setData({ [atxt]: total_m, })
678 879
679 -  
680 var txt = "formData.user_money"; 880 var txt = "formData.user_money";
681 var txt2 = "formData.order_amount"; 881 var txt2 = "formData.order_amount";
682 var txt3="formData.coupon_price"; 882 var txt3="formData.coupon_price";
683 -  
684 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); 883 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
685 //--------------如果使用余额--------------------- 884 //--------------如果使用余额---------------------
686 if (th.data.bn_use_money == 1) { 885 if (th.data.bn_use_money == 1) {
@@ -755,13 +954,15 @@ Page({ @@ -755,13 +954,15 @@ Page({
755 'exp_type': th.data.bn_exp_type, //配送方式 954 'exp_type': th.data.bn_exp_type, //配送方式
756 'order_goods':new Array(), 955 'order_goods':new Array(),
757 }; 956 };
758 -  
759 //组装优惠券的钱 957 //组装优惠券的钱
760 if(th.data.formData.coupon_price){ 958 if(th.data.formData.coupon_price){
761 item.coupon_price=th.data.formData.coupon_price; 959 item.coupon_price=th.data.formData.coupon_price;
762 item.coupon_no=th.data.using_quan[th.data.bn_pick].coupon_no; 960 item.coupon_no=th.data.using_quan[th.data.bn_pick].coupon_no;
763 } 961 }
764 - 962 + if(th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].coupon_no && th.data.using_quan[th.data.bn_pick].isby){
  963 + item.coupon_no=th.data.using_quan[th.data.bn_pick].coupon_no;
  964 + item.coupon_price=0;
  965 + }
765 var gg = to.get_b_now(); 966 var gg = to.get_b_now();
766 var goods={ 967 var goods={
767 'goods_id': gg.goods_id, 968 'goods_id': gg.goods_id,
@@ -847,9 +1048,13 @@ Page({ @@ -847,9 +1048,13 @@ Page({
847 }; 1048 };
848 1049
849 //组装优惠券的钱 1050 //组装优惠券的钱
850 - if(t_item.coupon_price){  
851 - item.coupon_price=t_item.coupon_price;  
852 - item.coupon_no=th.data.using_quan[t_item.pickup_id].coupon_no; 1051 + if(t_item.coupon_price) {
  1052 + item.coupon_price = t_item.coupon_price;
  1053 + item.coupon_no = th.data.using_quan[t_item.pickup_id].coupon_no;
  1054 + }
  1055 + if(t_item.quan_no) {
  1056 + item.coupon_no = t_item.quan_no;
  1057 + item.coupon_price = 0;
853 } 1058 }
854 1059
855 //-------------让商品添加到商品列表-------------------- 1060 //-------------让商品添加到商品列表--------------------
@@ -1005,7 +1210,6 @@ Page({ @@ -1005,7 +1210,6 @@ Page({
1005 }) 1210 })
1006 1211
1007 }, 1212 },
1008 -  
1009 //---确认线下门店的数量足不足--- 1213 //---确认线下门店的数量足不足---
1010 async check_store_num(goods_id,pick,goods_num,func){ 1214 async check_store_num(goods_id,pick,goods_num,func){
1011 var lock=0,pick_no,plist,erpwareid; 1215 var lock=0,pick_no,plist,erpwareid;
@@ -1048,7 +1252,6 @@ Page({ @@ -1048,7 +1252,6 @@ Page({
1048 } 1252 }
1049 func(isok); 1253 func(isok);
1050 }, 1254 },
1051 -  
1052 1255
1053 useCoupon: function() { 1256 useCoupon: function() {
1054 if (this.data.order.couponNum <= 0) { 1257 if (this.data.order.couponNum <= 0) {
@@ -1065,6 +1268,7 @@ Page({ @@ -1065,6 +1268,7 @@ Page({
1065 }, 1268 },
1066 enterAddressPage: function() { 1269 enterAddressPage: function() {
1067 getApp().globalData.is_cart_old=1; 1270 getApp().globalData.is_cart_old=1;
  1271 + this.data.isget_by_quan={};
1068 this.data.enterAddressPage = !0, wx.navigateTo({ 1272 this.data.enterAddressPage = !0, wx.navigateTo({
1069 url: "/pages/user/address_list/address_list" 1273 url: "/pages/user/address_list/address_list"
1070 }); 1274 });
@@ -1089,6 +1293,14 @@ Page({ @@ -1089,6 +1293,14 @@ Page({
1089 } 1293 }
1090 1294
1091 th.setData({ is_all_zt: iszt }); 1295 th.setData({ is_all_zt: iszt });
  1296 +
  1297 +
  1298 +
  1299 + if(th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby==1){
  1300 + th.setData({using_quan:{}});
  1301 + }
  1302 +
  1303 +
1092 } 1304 }
1093 //判断有没有默认的物流地址值 1305 //判断有没有默认的物流地址值
1094 if (def_exp_code != "" && def_exp_code != null && def_exp_code !=undefined) { 1306 if (def_exp_code != "" && def_exp_code != null && def_exp_code !=undefined) {
@@ -1113,9 +1325,18 @@ Page({ @@ -1113,9 +1325,18 @@ Page({
1113 th.setData({ bn_exp_type:ty}); 1325 th.setData({ bn_exp_type:ty});
1114 //当物流为空的时候。 1326 //当物流为空的时候。
1115 if (ty == 0 && th.data.wu_arr==null){ 1327 if (ty == 0 && th.data.wu_arr==null){
  1328 + th.data.isget_by_quan={};
1116 return th.get_wuliu(th.calculatePrice2()); 1329 return th.get_wuliu(th.calculatePrice2());
1117 } 1330 }
1118 1331
  1332 + //--自提就要把包邮券清理掉--
  1333 + if(ty==1){
  1334 + th.data.isget_by_quan={};
  1335 + if(th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby==1){
  1336 + th.setData({using_quan:{}});
  1337 + }
  1338 + }
  1339 +
1119 //判断有没有默认的物流地址值 1340 //判断有没有默认的物流地址值
1120 if (def_exp_code != "" && def_exp_code != null && def_exp_code !=undefined) { 1341 if (def_exp_code != "" && def_exp_code != null && def_exp_code !=undefined) {
1121 var wu_arr=this.data.wu_arr; 1342 var wu_arr=this.data.wu_arr;
@@ -1218,6 +1439,7 @@ Page({ @@ -1218,6 +1439,7 @@ Page({
1218 var pickid=e.currentTarget.dataset.pickid; 1439 var pickid=e.currentTarget.dataset.pickid;
1219 var bn=e.currentTarget.dataset.bn; 1440 var bn=e.currentTarget.dataset.bn;
1220 var cindx=e.currentTarget.dataset.cind; 1441 var cindx=e.currentTarget.dataset.cind;
  1442 + var get_by_quan_list_cart=th.data.get_by_quan_list_cart[pickid];
1221 1443
1222 1444
1223 if(bn==1){ 1445 if(bn==1){
@@ -1225,13 +1447,25 @@ Page({ @@ -1225,13 +1447,25 @@ Page({
1225 }else{ 1447 }else{
1226 //---多单打开券的时候,就要判断券在其他门店是否有使用--- 1448 //---多单打开券的时候,就要判断券在其他门店是否有使用---
1227 var quanlist=th.data.cartlist[cindx].quan_list; 1449 var quanlist=th.data.cartlist[cindx].quan_list;
  1450 + var exp_type=th.data.cartlist[cindx].exp_type;
  1451 +
  1452 +
1228 //对于在其他门店已经选择了的券 要判断是否显示到界面 1453 //对于在其他门店已经选择了的券 要判断是否显示到界面
1229 for(var i in quanlist){ 1454 for(var i in quanlist){
1230 var is_using= th.check_in_sele(quanlist[i].CashRepNo,pickid); 1455 var is_using= th.check_in_sele(quanlist[i].CashRepNo,pickid);
1231 if(is_using) quanlist[i].is_using=1; 1456 if(is_using) quanlist[i].is_using=1;
1232 } 1457 }
  1458 +
  1459 + if(get_by_quan_list_cart){
  1460 + for(var i in get_by_quan_list_cart){
  1461 + var is_using= th.check_in_sele(get_by_quan_list_cart[i].no,pickid);
  1462 + if(is_using) quanlist[i].is_using=1;
  1463 + }
  1464 + th.setData({by_quan_list_cart:get_by_quan_list_cart});
  1465 + }
  1466 +
1233 console.log("2222222券的列表", quanlist); 1467 console.log("2222222券的列表", quanlist);
1234 - th.setData({open_quan:1,selected_quan_pick:pickid,selected_quan_list:quanlist,disabled:1}); 1468 + th.setData({ sele_cart_ind:cindx,sele_exp_type:exp_type,open_quan:1,selected_quan_pick:pickid,selected_quan_list:quanlist,disabled:1});
1235 } 1469 }
1236 }, 1470 },
1237 close_coupon:function (e) { 1471 close_coupon:function (e) {
@@ -1262,18 +1496,36 @@ Page({ @@ -1262,18 +1496,36 @@ Page({
1262 quanlist[ind].show_red=0; 1496 quanlist[ind].show_red=0;
1263 } 1497 }
1264 this.setData({selected_quan_list:quanlist}); 1498 this.setData({selected_quan_list:quanlist});
  1499 + var by_quanlist=this.data.get_by_quan_list;
  1500 + if(by_quanlist){
  1501 + //---所有的券的显示红色选择都清理一遍---
  1502 + for(var ind in by_quanlist){
  1503 + by_quanlist[ind].show_red=0;
  1504 + }
  1505 + this.setData({get_by_quan_list:by_quanlist});
  1506 + }
  1507 +
  1508 + var by_cart_list=this.data.by_quan_list_cart;
  1509 + if(by_cart_list){
  1510 + //---所有的券的显示红色选择都清理一遍---
  1511 + for(var ind in by_cart_list){
  1512 + by_cart_list[ind].show_red=0;
  1513 + }
  1514 + this.setData({by_quan_list_cart:by_cart_list});
  1515 + }
  1516 +
1265 var using_quan=this.data.using_quan; 1517 var using_quan=this.data.using_quan;
1266 var th=this; 1518 var th=this;
1267 //---如果是不使用优惠券--- 1519 //---如果是不使用优惠券---
1268 if(no_use==1){ 1520 if(no_use==1){
1269 - console.log("有进来吗券", no_use); 1521 + console.log("有进来吗券", no_use);
1270 if(using_quan[th.data.selected_quan_pick]){ 1522 if(using_quan[th.data.selected_quan_pick]){
1271 using_quan[th.data.selected_quan_pick].is_nouse_red=1; 1523 using_quan[th.data.selected_quan_pick].is_nouse_red=1;
1272 } 1524 }
1273 else{ 1525 else{
1274 using_quan[th.data.selected_quan_pick] ={is_nouse_red:1}; 1526 using_quan[th.data.selected_quan_pick] ={is_nouse_red:1};
1275 } 1527 }
1276 - this.setData({ using_quan: using_quan, is_coupon:2222}); 1528 + this.setData({ using_quan: using_quan, is_coupon:2222});
1277 return; 1529 return;
1278 } 1530 }
1279 1531
@@ -1299,31 +1551,142 @@ Page({ @@ -1299,31 +1551,142 @@ Page({
1299 1551
1300 }, 1552 },
1301 1553
  1554 +
  1555 + /*----- 点击选择包邮券 -----*/
  1556 + sele_quan_item_by:function(e) {
  1557 + var no_use=e.currentTarget.dataset.no;
  1558 + //立即购买的包邮券
  1559 + var by_quanlist=this.data.get_by_quan_list;
  1560 + if(by_quanlist) {
  1561 + //---所有的券的显示红色选择都清理一遍---
  1562 + for (var ind in by_quanlist) {
  1563 + by_quanlist[ind].show_red = 0;
  1564 + }
  1565 + this.setData({get_by_quan_list: by_quanlist});
  1566 + }
  1567 +
  1568 + //--购物车过来的包邮券--
  1569 + var by_cart_list=this.data.by_quan_list_cart;
  1570 + if(by_cart_list){
  1571 + //---所有的券的显示红色选择都清理一遍---
  1572 + for(var ind in by_cart_list){
  1573 + by_cart_list[ind].show_red=0;
  1574 + }
  1575 + this.setData({by_quan_list_cart:by_cart_list});
  1576 + }
  1577 + //普通券
  1578 + var quanlist=this.data.selected_quan_list;
  1579 + if(quanlist){
  1580 + //---所有的券的显示红色选择都清理一遍---
  1581 + for(var ind in quanlist){
  1582 + quanlist[ind].show_red=0;
  1583 + }
  1584 + this.setData({selected_quan_list:quanlist});
  1585 + }
  1586 +
  1587 + var th=this;
  1588 + var using_quan=this.data.using_quan;
  1589 + //---如果是不使用优惠券---
  1590 + if(no_use==1){
  1591 + if(using_quan[th.data.selected_quan_pick]){
  1592 + using_quan[th.data.selected_quan_pick].is_nouse_red=1;
  1593 + }
  1594 + else{
  1595 + using_quan[th.data.selected_quan_pick] ={is_nouse_red:1};
  1596 + }
  1597 + this.setData({ using_quan: using_quan, is_coupon:2222});
  1598 + return;
  1599 + }
  1600 +
  1601 + var ind = e.currentTarget.dataset.ind;
  1602 + //--如果是立即购买的部分--
  1603 + var txt="";var txt1=""; var quan_item=null;
  1604 + if(th.data.is_b_now){
  1605 + quan_item = this.data.get_by_quan_list[ind];
  1606 + txt = "get_by_quan_list[" + ind + "].show_red";
  1607 + }else{
  1608 + txt = "by_quan_list_cart[" + ind + "].show_red";
  1609 + quan_item = th.data.by_quan_list_cart[ind]
  1610 +
  1611 + }
  1612 + var obj = {}; obj[txt] = 1;
  1613 + if (quan_item.show_red) {
  1614 + obj[txt] = 0;
  1615 + }
  1616 +
  1617 + //购物车购买过来的商品
  1618 + if(txt1){
  1619 + obj[txt1] = 1;
  1620 + if (quan_item.show_red) {
  1621 + obj[txt1] = 0;
  1622 + }
  1623 + }
  1624 +
  1625 + this.setData(obj);
  1626 + if(using_quan[th.data.selected_quan_pick]){
  1627 + using_quan[th.data.selected_quan_pick].is_nouse_red=0;
  1628 + }
  1629 + else{
  1630 + using_quan[th.data.selected_quan_pick] ={is_nouse_red:0};
  1631 + }
  1632 + this.setData({using_quan:using_quan});
  1633 + },
  1634 +
1302 //--确认使用券--- 1635 //--确认使用券---
1303 confirm_quan:function () { 1636 confirm_quan:function () {
1304 -  
1305 - var using_quan=this.data.using_quan,pickid=this.data.selected_quan_pick;  
1306 - var th=this,selected_quan_list=this.data.selected_quan_list; 1637 + var using_quan=this.data.using_quan
  1638 + var pickid=this.data.selected_quan_pick;
  1639 + var th=this;
  1640 + var selected_quan_list=this.data.selected_quan_list;
  1641 + var get_by_quan_list=this.data.get_by_quan_list;
  1642 + var by_quan_list_cart=this.data.by_quan_list_cart;
1307 //选择了的券 1643 //选择了的券
1308 var sele_quan=null; 1644 var sele_quan=null;
1309 - console.log(selected_quan_list, "确认使用券"); 1645 +
  1646 + //循环普通的券
1310 for(var i in selected_quan_list){ 1647 for(var i in selected_quan_list){
1311 -  
1312 var item=selected_quan_list[i]; 1648 var item=selected_quan_list[i];
1313 - console.log(item, "确认使用券",item.show_red);  
1314 if(item.show_red) { 1649 if(item.show_red) {
1315 - console.log(item.show_red, "确定的券7");  
1316 th.insert_into_using_quan(item,using_quan,pickid); 1650 th.insert_into_using_quan(item,using_quan,pickid);
1317 return; 1651 return;
1318 } 1652 }
1319 } 1653 }
  1654 + //循环包邮的券,立即购买的
  1655 + for(var i in get_by_quan_list){
  1656 + var item=get_by_quan_list[i];
  1657 + if(item.show_red) {
  1658 + if(th.data.is_no_by[pickid]==1){
  1659 + getApp().my_warnning("已全场不能包邮,不能选择包邮券",0,th);return false;
  1660 + }
  1661 + if(th.data.is_by[pickid]==1){
  1662 + getApp().my_warnning("已全场包邮,不能选择包邮券",0,th);return false;
  1663 + }
1320 1664
1321 - //选择了的券,看是不是点击了不使用券 1665 + th.insert_into_using_quan(item,using_quan,pickid,1);
  1666 + return;
  1667 + }
  1668 + }
  1669 +
  1670 + //循环包邮的券
  1671 + for(var i in by_quan_list_cart){
  1672 + var item=by_quan_list_cart[i];
  1673 + if(item.show_red) {
  1674 + if(th.data.is_no_by[pickid]==1){
  1675 + getApp().my_warnning("已全场不能包邮,不能选择包邮券",0,th);return false;
  1676 + }
  1677 + if(th.data.is_by[pickid]==1){
  1678 + getApp().my_warnning("已全场包邮,不能选择包邮券",0,th);return false;
  1679 + }
  1680 + th.insert_into_using_quan(item,using_quan,pickid,1);
  1681 + return;
  1682 + }
  1683 + }
  1684 +
  1685 + //选择了的券,看是不是点击了不使用券,点击了不使用优惠券
1322 if(using_quan[pickid]){ 1686 if(using_quan[pickid]){
1323 if(using_quan[pickid].is_nouse_red==1){ 1687 if(using_quan[pickid].is_nouse_red==1){
1324 using_quan[pickid] ={is_nouse_red:1}; 1688 using_quan[pickid] ={is_nouse_red:1};
1325 th.setData({using_quan:using_quan}); 1689 th.setData({using_quan:using_quan});
1326 -  
1327 if(th.data.is_b_now==1){ 1690 if(th.data.is_b_now==1){
1328 th.calculatePrice2(); 1691 th.calculatePrice2();
1329 }else{ 1692 }else{
@@ -1336,11 +1699,16 @@ Page({ @@ -1336,11 +1699,16 @@ Page({
1336 }, 1699 },
1337 1700
1338 //----把券插入之后的操作,同时还要重新计算价格---- 1701 //----把券插入之后的操作,同时还要重新计算价格----
1339 - insert_into_using_quan:function (item,using_quan,pickid) { 1702 + insert_into_using_quan:function (item,using_quan,pickid,isby) {
1340 var th=this; 1703 var th=this;
1341 - using_quan[pickid]={coupon_no:item.CashRepNo,money:item.Sum,is_nouse_red:0}; 1704 + if(isby==1){
  1705 + using_quan[pickid]={coupon_no:item.no,money:0,is_nouse_red:0,region_list:item.region_list,goods_list:item.goods_list};
  1706 + using_quan[pickid].isby=1;
  1707 + }else{
  1708 + using_quan[pickid]={coupon_no:item.CashRepNo,money:item.Sum,is_nouse_red:0};
  1709 + using_quan[pickid].isby=0;
  1710 + }
1342 this.setData({using_quan:using_quan}); 1711 this.setData({using_quan:using_quan});
1343 -  
1344 if(th.data.is_b_now==1){ 1712 if(th.data.is_b_now==1){
1345 th.calculatePrice2(); 1713 th.calculatePrice2();
1346 }else{ 1714 }else{
@@ -1355,9 +1723,8 @@ Page({ @@ -1355,9 +1723,8 @@ Page({
1355 ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; 1723 ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif";
1356 this.setData(ob); 1724 this.setData(ob);
1357 }, 1725 },
1358 -  
1359 //--验证是否已经冻结-- 1726 //--验证是否已经冻结--
1360 - check_is_frozenQuan:function(quanlist,frozenQuan){ 1727 + check_is_frozenQuan:function(quanlist,frozenQuan,isby){
1361 console.log("券列表",quanlist); 1728 console.log("券列表",quanlist);
1362 if(!quanlist) return null; 1729 if(!quanlist) return null;
1363 if(!frozenQuan) return quanlist; 1730 if(!frozenQuan) return quanlist;
@@ -1366,6 +1733,7 @@ Page({ @@ -1366,6 +1733,7 @@ Page({
1366 var item=quanlist[i]; 1733 var item=quanlist[i];
1367 var is_find=0; 1734 var is_find=0;
1368 var Q_no=quanlist[i].CashRepNo; 1735 var Q_no=quanlist[i].CashRepNo;
  1736 + if(isby) Q_no=quanlist[i].no;
1369 for(var j=0;j<frozenQuan.length;j++){ 1737 for(var j=0;j<frozenQuan.length;j++){
1370 var q_no=frozenQuan[j].cashRepNo; 1738 var q_no=frozenQuan[j].cashRepNo;
1371 if(Q_no==q_no){ 1739 if(Q_no==q_no){
@@ -1428,13 +1796,22 @@ Page({ @@ -1428,13 +1796,22 @@ Page({
1428 this.setData(obj); 1796 this.setData(obj);
1429 this.setData({disabled:1}) 1797 this.setData({disabled:1})
1430 }, 1798 },
1431 - //选择券  
1432 - sele_coupon:function(e){  
1433 - var ind = e.currentTarget.dataset.ind;  
1434 - console.log("下标", ind);  
1435 - this.setData({ is_coupon: ind}); 1799 +
  1800 + clik_coupons2:function(e){
  1801 + var ind = e.currentTarget.dataset.idx;
  1802 + var is_open = this.data.get_by_quan_list[ind].is_open;
  1803 +
  1804 + if (is_open == 1) is_open = 0;
  1805 + else is_open = 1;
  1806 +
  1807 + var txt = "get_by_quan_list[" + ind + "].is_open"
  1808 + var obj = {}; obj[txt] = is_open;
  1809 +
  1810 + this.setData(obj);
  1811 + this.setData({disabled:1})
1436 }, 1812 },
1437 - 1813 +
  1814 +
1438 //设置默认物流 1815 //设置默认物流
1439 select_default_logistics: function () { 1816 select_default_logistics: function () {
1440 var th=this; 1817 var th=this;
@@ -1526,7 +1903,7 @@ Page({ @@ -1526,7 +1903,7 @@ Page({
1526 var frozenQuan=null; 1903 var frozenQuan=null;
1527 var url0="/api/weshop/users/frozenQuan/listFrozenQuan/"+app.globalData.user_id; 1904 var url0="/api/weshop/users/frozenQuan/listFrozenQuan/"+app.globalData.user_id;
1528 app.request.promiseGet(url0,{1:1}).then(res=>{ 1905 app.request.promiseGet(url0,{1:1}).then(res=>{
1529 - if(res.data.code==0){ frozenQuan=res.data.data; } 1906 + if(res.data.code==0){ frozenQuan=res.data.data; th.data.frozenQuan=frozenQuan; }
1530 //--调用接口,获取优惠券的列表,3秒钟内控制接口请求-- 1907 //--调用接口,获取优惠券的列表,3秒钟内控制接口请求--
1531 var url="/api/weshop/couponList/getUseCouponList"; 1908 var url="/api/weshop/couponList/getUseCouponList";
1532 app.request.time_limit_get(6,url,{ 1909 app.request.time_limit_get(6,url,{
@@ -1552,7 +1929,7 @@ Page({ @@ -1552,7 +1929,7 @@ Page({
1552 var url="/api/weshop/couponList/getUseCouponList"; 1929 var url="/api/weshop/couponList/getUseCouponList";
1553 app.request.promiseGet(url0, {1: 1}).then(res => { 1930 app.request.promiseGet(url0, {1: 1}).then(res => {
1554 if (res.data.code == 0) { 1931 if (res.data.code == 0) {
1555 - frozenQuan = res.data.data; 1932 + frozenQuan = res.data.data;th.data.frozenQuan=frozenQuan;
1556 } 1933 }
1557 app.request.time_limit_get(6, url, { 1934 app.request.time_limit_get(6, url, {
1558 data: { 1935 data: {
@@ -1571,10 +1948,43 @@ Page({ @@ -1571,10 +1948,43 @@ Page({
1571 } 1948 }
1572 } 1949 }
1573 } 1950 }
1574 -  
1575 }) 1951 })
1576 }) 1952 })
1577 1953
1578 } 1954 }
  1955 + },
  1956 + //检查区域是不是包邮
  1957 + check_area:function(arr){
  1958 + var user_addr=this.data.user_addr;
  1959 + for(var i in arr){
  1960 + var item=arr[i];
  1961 + if(user_addr.twon==item || user_addr.district==item
  1962 + || user_addr.city==item|| user_addr.province==item ){
  1963 + return 0;
  1964 + }
  1965 + }
  1966 + return 1;
  1967 + },
  1968 +
  1969 + //检查立即购买的商品是不是不包邮
  1970 + check_good:function(arr,goods_id){
  1971 + if(!goods_id) goods_id=this.data.bn_goods.goods_id;
  1972 + for(var i in arr){
  1973 + var item=arr[i];
  1974 + if(goods_id==item) return 0;
  1975 + }
  1976 + return 1;
  1977 + },
  1978 + check_by_area:function(region_list){
  1979 + var arr=region_list.split(",");
  1980 + var check=this.check_area(arr);
  1981 + return !check;
  1982 + },
  1983 + check_by_goods:function(goods_list,goods_id){
  1984 + var arr=goods_list.split(",");
  1985 + var check=this.check_good(arr,goods_id);
  1986 + return !check;
1579 } 1987 }
  1988 +
  1989 +
1580 }); 1990 });
pages/cart/cart2/cart2.wxml
@@ -78,6 +78,7 @@ @@ -78,6 +78,7 @@
78 <view class="xc-right-frame"> 78 <view class="xc-right-frame">
79 <text wx:if="{{using_quan[item.pickup_id].is_nouse}}">不使用</text> 79 <text wx:if="{{using_quan[item.pickup_id].is_nouse}}">不使用</text>
80 <text wx:if="{{using_quan[item.pickup_id].money}}">¥{{using_quan[item.pickup_id].money}}元优惠券</text> 80 <text wx:if="{{using_quan[item.pickup_id].money}}">¥{{using_quan[item.pickup_id].money}}元优惠券</text>
  81 + <text wx:if="{{using_quan[item.pickup_id].isby}}">包邮券</text>
81 <view class="xc-right"></view> 82 <view class="xc-right"></view>
82 </view> 83 </view>
83 </view> 84 </view>
@@ -91,7 +92,7 @@ @@ -91,7 +92,7 @@
91 </view> 92 </view>
92 <view class="use-item flex-space-between"> 93 <view class="use-item flex-space-between">
93 <view class="flex-vertical"> 94 <view class="flex-vertical">
94 - <view bindtap='setexptype_w' data-t='1' data-txt='cartlist[{{pidx}}].exp_type'style="display:{{item.distr_t==2?'none':'flex;align-items: center'}};"> 95 + <view bindtap='setexptype_w' data-ind="{{pidx}}" data-t='1' data-txt='cartlist[{{pidx}}].exp_type'style="display:{{item.distr_t==2?'none':'flex;align-items: center'}};">
95 <!-- <icon bindtap='setexptype_w' data-t='1' data-txt='cartlist[{{pidx}}].exp_type' color="{{item.exp_type==1?'red':'gray'}}" size="16" type="success"></icon> --> 96 <!-- <icon bindtap='setexptype_w' data-t='1' data-txt='cartlist[{{pidx}}].exp_type' color="{{item.exp_type==1?'red':'gray'}}" size="16" type="success"></icon> -->
96 97
97 98
@@ -103,10 +104,10 @@ @@ -103,10 +104,10 @@
103 <block wx:else> 104 <block wx:else>
104 <view class="circle xc-hookts on"></view> 105 <view class="circle xc-hookts on"></view>
105 </block> 106 </block>
106 - <view bindtap='setexptype_w' data-t='1' data-txt='cartlist[{{pidx}}].exp_type' class="yu_er">门店自提</view> 107 + <view bindtap='setexptype_w' data-ind="{{pidx}}" data-t='1' data-txt='cartlist[{{pidx}}].exp_type' class="yu_er">门店自提</view>
107 </view> 108 </view>
108 109
109 - <view data-t='0' data-txt='cartlist[{{pidx}}].exp_type' bindtap="setexptype_w" style="display:{{item.distr_t==1?'none':'flex;align-items: center'}};"> 110 + <view data-t='0' data-txt='cartlist[{{pidx}}].exp_type' data-ind="{{pidx}}" bindtap="setexptype_w" style="display:{{item.distr_t==1?'none':'flex;align-items: center'}};">
110 <!-- <icon bindtap='setexptype_w' data-t='0' data-txt='cartlist[{{pidx}}].exp_type' color="{{item.exp_type==0?'red':'gray'}}" size="16" type="success"></icon> --> 111 <!-- <icon bindtap='setexptype_w' data-t='0' data-txt='cartlist[{{pidx}}].exp_type' color="{{item.exp_type==0?'red':'gray'}}" size="16" type="success"></icon> -->
111 <block wx:if="{{item.exp_type==0}}"> 112 <block wx:if="{{item.exp_type==0}}">
112 <!-- <view class="circle white xc-hookt fs20 red-b sn"><text>Γ</text></view> --> 113 <!-- <view class="circle white xc-hookt fs20 red-b sn"><text>Γ</text></view> -->
@@ -116,7 +117,7 @@ @@ -116,7 +117,7 @@
116 <view class="circle xc-hookts on"></view> 117 <view class="circle xc-hookts on"></view>
117 </block> 118 </block>
118 119
119 - <view bindtap='setexptype_w' data-t='0' 120 + <view bindtap='setexptype_w' data-t='0' data-ind="{{pidx}}"
120 data-txt='cartlist[{{pidx}}].exp_type' 121 data-txt='cartlist[{{pidx}}].exp_type'
121 data-wl_txt='cartlist[{{pidx}}].wind' 122 data-wl_txt='cartlist[{{pidx}}].wind'
122 class="yu_er">快递邮寄</view> 123 class="yu_er">快递邮寄</view>
@@ -203,7 +204,10 @@ @@ -203,7 +204,10 @@
203 </view> 204 </view>
204 <view class="xc-right-frame"> 205 <view class="xc-right-frame">
205 <text wx:if="{{using_quan[bn_pick].is_nouse}}">不使用</text> 206 <text wx:if="{{using_quan[bn_pick].is_nouse}}">不使用</text>
206 - <text wx:if="{{using_quan[bn_pick].money}}">¥{{using_quan[bn_pick].money}}元优惠券</text> 207 + <block wx:else>
  208 + <text wx:if="{{using_quan[bn_pick].money}}">¥{{using_quan[bn_pick].money}}元优惠券</text>
  209 + <text wx:if="{{using_quan[bn_pick].isby}}">包邮券</text>
  210 + </block>
207 <view class="xc-right"></view> 211 <view class="xc-right"></view>
208 </view> 212 </view>
209 </view> 213 </view>
@@ -284,153 +288,143 @@ @@ -284,153 +288,143 @@
284 288
285 <!-- 使用券列表的弹窗 --> 289 <!-- 使用券列表的弹窗 -->
286 <view wx:if='{{open_quan==1}}' > 290 <view wx:if='{{open_quan==1}}' >
287 - <view class="cover-layer flex-center " bindtap='close_coupon'>  
288 - </view> 291 + <view class="cover-layer flex-center " bindtap='close_coupon'> </view>
289 <view class="cx-popup {{open_quan==true?'up' : 'down'}}" > 292 <view class="cx-popup {{open_quan==true?'up' : 'down'}}" >
  293 + <!-- 最上面 -->
290 <view class="top flex"> 294 <view class="top flex">
291 - <view class="xc-top-content t-c">  
292 - <view class="xc-title">  
293 - 优惠券使用  
294 - </view>  
295 - </view>  
296 - <view class="xc-close-frame" bindtap='close_coupon' >  
297 - <view class="xc-close">×</view>  
298 - </view> 295 + <view class="xc-top-content t-c"><view class="xc-title">优惠券使用</view></view>
  296 + <view class="xc-close-frame" bindtap='close_coupon' ><view class="xc-close">×</view></view>
299 </view> 297 </view>
300 - <!-- <view class=""> -->  
301 - <view class="may_use_coupon fs28 flex">  
302 - 可使用的优惠券  
303 - <view class=" is_use_coupon flex-vertical" bindtap="sele_quan_item" data-no="1">  
304 - 不使用优惠券  
305 -  
306 - <block wx:if="{{using_quan[selected_quan_pick].is_nouse_red}}">  
307 - <view class="circle white xc-hooka fs20 red-b sn"><text>Γ</text></view>  
308 - </block>  
309 - <block wx:else>  
310 - <view class="circle xc-hookst ons"></view>  
311 - </block>  
312 -  
313 - </view>  
314 - </view>  
315 - <!-- </view> -->  
316 - <view class="xc-frame flex-level">  
317 - <view class="list-frame">  
318 -  
319 - <view wx:for="{{selected_quan_list}}" bindtap="sele_quan_item" wx:if="{{!item.is_using}}" data-ind="{{q_index}}" wx:for-item="item"wx:for-index="q_index">  
320 - <view class="xc-coupon-frame flex-center" bindtap="sele_coupon" data-ind="{{q_index}}">  
321 - <view class="coupon-frame flex rel">  
322 - <!-- 锯齿 -->  
323 - <view class="circle-frame abs">  
324 - <view class='circle circle-sawtooth'></view>  
325 - <view class='circle circle-sawtooth'></view>  
326 - <view class='circle circle-sawtooth'></view>  
327 - <view class='circle circle-sawtooth'></view>  
328 - <view class='circle circle-sawtooth'></view>  
329 - <view class='circle circle-sawtooth'></view>  
330 - <view class='circle circle-sawtooth'></view>  
331 - <view class='circle circle-sawtooth'></view>  
332 - <view class='circle circle-sawtooth'></view>  
333 - <view class='circle circle-sawtooth'></view>  
334 - <view class='circle circle-sawtooth'></view>  
335 - <view class='circle circle-sawtooth'></view>  
336 - <view class='circle circle-sawtooth'></view>  
337 - <view class='circle circle-sawtooth'></view>  
338 - <view class='circle circle-sawtooth'></view>  
339 - <view class='circle circle-sawtooth'></view>  
340 - <view class='circle circle-sawtooth'></view>  
341 - <view class='circle circle-sawtooth'></view>  
342 - <view class='circle circle-sawtooth'></view>  
343 - <view class='circle circle-sawtooth'></view> 298 + <!-- 使用优惠券和不使用优惠券层-->
  299 + <view class="may_use_coupon fs28 flex"> 可使用的优惠券
  300 + <view class=" is_use_coupon flex-vertical" bindtap="sele_quan_item" data-no="1">不使用优惠券
  301 + <block wx:if="{{using_quan[selected_quan_pick].is_nouse_red}}"><view class="circle white xc-hooka fs20 red-b sn"><text>Γ</text></view> </block>
  302 + <block wx:else><view class="circle xc-hookst ons"></view></block>
344 </view> 303 </view>
  304 + </view>
  305 +
  306 + <!-- 中间券内容显示 -->
  307 + <view class="xc-frame flex-level">
  308 + <view class="list-frame">
  309 + <view wx:for="{{selected_quan_list}}" bindtap="sele_quan_item" wx:if="{{!item.is_using}}" data-ind="{{q_index}}" wx:for-item="item" wx:for-index="q_index">
  310 + <view class="xc-coupon-frame flex-center" data-ind="{{q_index}}">
  311 + <view class="coupon-frame flex rel">
  312 + <!-- 锯齿 -->
  313 + <include src="juchi_part.wxml" />
  314 + <!-- 左边 -->
  315 + <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
  316 + <view class="white xc-money-frames">
  317 + <view class="f_text"><text class="xc-rmb-symbol">¥</text><text class="xc-rmb-val">{{item.Sum}}</text></view>
  318 + <view class="coupon-explain t-c" wx:if="{{item.BuySum>0}}">满{{item.BuySum}}元可用</view>
  319 + <view class="coupon-explain t-c" wx:else>满0元可用</view>
  320 + </view>
  321 + </view>
  322 + <!-- 右边 -->
  323 + <view class="coupon-right flex-center rel">
  324 + <view class="coupon-annotation flex">
  325 + <view class="flex top-frame">
  326 + <view class="frame">
  327 + <view class="coupon-wode ib flex ellipsis-2 ">
  328 + <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">{{filter.get_type_card(item.UseObjectType)}}</text>
  329 + <block>{{item.Sum}}元优惠券</block>
  330 + </view>
  331 + <view class="coupon-time">{{filters.replace_time2(item.BeginDate)}}至{{item.ValidDate?filters.replace_time2(item.ValidDate):'不限'}}</view>
  332 + </view>
  333 + </view>
  334 + <block wx:if="{{item.show_red}}"><view class="circle white xc-hook fs20 red-b sn"><text>Γ</text></view></block>
  335 + <block wx:else><view class="circle xc-hooks on"></view></block>
  336 + </view>
  337 + <include src="remark_click_part.wxml" />
  338 + </view>
  339 + </view>
  340 + </view>
  341 + <!-- 打开是说明 -->
  342 + <include src="remark_part.wxml" />
  343 + </view>
  344 + <!-- 包邮券的显示,立即购买 -->
  345 + <block wx:if="{{ is_b_now && bn_exp_type==0}}">
  346 + <view wx:for="{{get_by_quan_list}}" bindtap="sele_quan_item_by" wx:if="{{!item.is_using}}" data-ind="{{byq_index}}" wx:for-item="item" wx:for-index="byq_index">
  347 + <view class="xc-coupon-frame flex-center" data-ind="{{byq_index}}">
  348 + <view class="coupon-frame flex rel">
  349 + <!-- 锯齿 -->
  350 + <include src="juchi_part.wxml" />
  351 + <!-- 左边 -->
  352 + <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
  353 + <view class="white xc-money-frames">
  354 + <view class="f_text"><text class="xc-rmb-val">包邮券</text></view>
  355 + <view class="coupon-explain t-c" wx:if="{{item.condition>0}}">满{{item.condition}}元可用</view>
  356 + <view class="coupon-explain t-c" wx:else>满0元可用</view>
  357 + </view>
  358 + </view>
  359 + <!-- 右边 -->
  360 + <view class="coupon-right flex-center rel">
  361 + <view class="coupon-annotation flex">
  362 + <view class="flex top-frame">
  363 + <view class="frame">
  364 + <view class="coupon-wode ib flex ellipsis-2 ">
  365 + <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">{{filter.get_type_card(0)}}</text>
  366 + <block>包邮券</block>
  367 + </view>
  368 + <view class="coupon-time">{{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}}</view>
  369 + </view>
  370 + </view>
  371 + <block wx:if="{{item.show_red}}"><view class="circle white xc-hook fs20 red-b sn"><text>Γ</text></view></block>
  372 + <block wx:else><view class="circle xc-hooks on"></view></block>
  373 + </view>
  374 + <include src="remark_click_part2.wxml" />
  375 + </view>
  376 + </view>
  377 + </view>
  378 + <!-- 打开是说明 -->
  379 + <include src="remark_part.wxml" />
  380 + </view>
  381 + </block>
345 382
346 - <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">  
347 -  
348 -  
349 - <view class="white xc-money-frames">  
350 - <view class="f_text">  
351 - <text class="xc-rmb-symbol">¥</text>  
352 - <text class="xc-rmb-val">{{item.Sum}}</text>  
353 - </view>  
354 -  
355 -  
356 -  
357 - <view class="coupon-explain t-c" wx:if="{{item.BuySum>0}}">  
358 - 满{{item.BuySum}}元可用  
359 - </view>  
360 - <view class="coupon-explain t-c" wx:else>  
361 - 满0元可用  
362 - </view>  
363 -  
364 - </view>  
365 - </view>  
366 - <view class="coupon-right flex-center rel">  
367 - <view class="coupon-annotation flex">  
368 -  
369 - <view class="flex top-frame">  
370 -  
371 - <view class="frame">  
372 - <!-- <view class="flex"> -->  
373 - <view class="coupon-wode ib flex ellipsis-2 ">  
374 - <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">{{filter.get_type_card(item.UseObjectType)}}  
375 - </text>  
376 - <block>{{item.Sum}}元优惠券</block>  
377 - </view>  
378 - <view class="coupon-time">  
379 - {{filters.replace_time2(item.BeginDate)}}至{{item.ValidDate?filters.replace_time2(item.ValidDate):'不限'}}</view>  
380 - </view>  
381 - </view>  
382 - <!-- <view wx:if="{{item.Obtain>0}}" class="code-img" bindtap="show_quan" data-ind="{{index}}" data-now="{{filter.format_time(now)}}">  
383 - <image class="coupon-code" src='{{iurl}}/miniapp/images/user_r_code.png'></image>  
384 - </view>  
385 - <view wx:else class="code-img">  
386 - <image class="coupon-code" src='{{iurl}}/miniapp/images/hui-ewm.png'></image>  
387 - </view> -->  
388 -  
389 - <block wx:if="{{item.show_red}}">  
390 - <view class="circle white xc-hook fs20 red-b sn"><text>Γ</text></view>  
391 - </block>  
392 - <block wx:else>  
393 - <view class="circle xc-hooks on"></view> 383 + <!-- 包邮券的显示,购物车购买 -->
  384 + <block wx:if="{{!is_b_now && sele_exp_type==0}}">
  385 + <view wx:for="{{by_quan_list_cart}}" bindtap="sele_quan_item_by" wx:if="{{!item.is_using}}" data-ind="{{byq_index}}" wx:for-item="item" wx:for-index="byq_index">
  386 + <view class="xc-coupon-frame flex-center" data-ind="{{byq_index}}">
  387 + <view class="coupon-frame flex rel">
  388 + <!-- 锯齿 -->
  389 + <include src="juchi_part.wxml" />
  390 + <!-- 左边 -->
  391 + <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
  392 + <view class="white xc-money-frames">
  393 + <view class="f_text"><text class="xc-rmb-val">包邮券</text></view>
  394 + <view class="coupon-explain t-c" wx:if="{{item.condition>0}}">满{{item.condition}}元可用</view>
  395 + <view class="coupon-explain t-c" wx:else>满0元可用</view>
  396 + </view>
  397 + </view>
  398 + <!-- 右边 -->
  399 + <view class="coupon-right flex-center rel">
  400 + <view class="coupon-annotation flex">
  401 + <view class="flex top-frame">
  402 + <view class="frame">
  403 + <view class="coupon-wode ib flex ellipsis-2 ">
  404 + <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">{{filter.get_type_card(0)}}</text>
  405 + <block>包邮券</block>
  406 + </view>
  407 + <view class="coupon-time">{{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}}</view>
  408 + </view>
  409 + </view>
  410 + <block wx:if="{{item.show_red}}"><view class="circle white xc-hook fs20 red-b sn"><text>Γ</text></view></block>
  411 + <block wx:else><view class="circle xc-hooks on"></view></block>
  412 + </view>
  413 + <include src="remark_click_part2.wxml" />
  414 + </view>
  415 + </view>
  416 + </view>
  417 + <!-- 打开是说明 -->
  418 + <include src="remark_part.wxml" />
  419 + </view>
394 </block> 420 </block>
395 - </view>  
396 421
397 -  
398 -  
399 - <view class="abs flex-vertical-between bottmo-explain" catchtap='clik_coupons' data-idx="{{q_index}}">  
400 - <view></view>  
401 - <view class="font-word flex">优惠券使用说明  
402 - <view class="circle circle-size flex t-c">  
403 - <view class="xc-jiantou">く</view>  
404 - </view>  
405 - </view>  
406 - </view>  
407 - </view>  
408 - </view>  
409 - </view>  
410 422
411 - <view class="xc-buttom " wx:if="{{item.is_open==1}}">  
412 - <view style="padding:10rpx">  
413 - <text class="five-level-word explain-coupon" wx:if="{{item.Remark}}">{{util.format(item.Remark)}}</text>  
414 - <text class="five-level-word explain-coupon" wx:else>  
415 - <block wx:if="{{item.UseObjectName}}">仅{{item.UseObjectName}}使用</block>  
416 - <block wx:else>全场通用</block>  
417 - </text>  
418 - </view> 423 + </view>
  424 + </view>
  425 + <!-- 最底下确定层-->
  426 + <view class="determine-frame"><view class="xc-confirm flex-center" bindtap="confirm_quan"> 确定 </view></view>
419 </view> 427 </view>
420 -  
421 -</view>  
422 -  
423 -  
424 -  
425 -  
426 - </view>  
427 - </view>  
428 - <view class="determine-frame">  
429 - <view class="xc-confirm flex-center" bindtap="confirm_quan">  
430 - 确定  
431 - </view>  
432 - </view>  
433 - </view >  
434 </view> 428 </view>
435 429
436 <!----弹起选择物流名的列表----> 430 <!----弹起选择物流名的列表---->
pages/cart/cart2/juchi_part.wxml 0 → 100644
  1 +<!-- 锯齿 -->
  2 +<view class="circle-frame abs">
  3 + <view class='circle circle-sawtooth'></view>
  4 + <view class='circle circle-sawtooth'></view>
  5 + <view class='circle circle-sawtooth'></view>
  6 + <view class='circle circle-sawtooth'></view>
  7 + <view class='circle circle-sawtooth'></view>
  8 + <view class='circle circle-sawtooth'></view>
  9 + <view class='circle circle-sawtooth'></view>
  10 + <view class='circle circle-sawtooth'></view>
  11 + <view class='circle circle-sawtooth'></view>
  12 + <view class='circle circle-sawtooth'></view>
  13 + <view class='circle circle-sawtooth'></view>
  14 + <view class='circle circle-sawtooth'></view>
  15 + <view class='circle circle-sawtooth'></view>
  16 + <view class='circle circle-sawtooth'></view>
  17 + <view class='circle circle-sawtooth'></view>
  18 + <view class='circle circle-sawtooth'></view>
  19 + <view class='circle circle-sawtooth'></view>
  20 + <view class='circle circle-sawtooth'></view>
  21 + <view class='circle circle-sawtooth'></view>
  22 + <view class='circle circle-sawtooth'></view>
  23 +</view>
0 \ No newline at end of file 24 \ No newline at end of file
pages/cart/cart2/remark_click_part.wxml 0 → 100644
  1 +<!--点击券说明-->
  2 +<view class="abs flex-vertical-between bottmo-explain" catchtap='clik_coupons' data-idx="{{q_index}}">
  3 + <view></view><view class="font-word flex">优惠券使用说明<view class="circle circle-size flex t-c"> <view class="xc-jiantou">く</view> </view></view>
  4 +</view>
0 \ No newline at end of file 5 \ No newline at end of file
pages/cart/cart2/remark_click_part2.wxml 0 → 100644
  1 +<!--点击券说明-->
  2 +<view class="abs flex-vertical-between bottmo-explain" catchtap='clik_coupons2' data-idx="{{byq_index}}">
  3 + <view></view><view class="font-word flex">优惠券使用说明<view class="circle circle-size flex t-c"> <view class="xc-jiantou">く</view> </view></view>
  4 +</view>
0 \ No newline at end of file 5 \ No newline at end of file
pages/cart/cart2/remark_part.wxml 0 → 100644
  1 +<view class="xc-buttom " wx:if="{{item.is_open==1}}" >
  2 + <view style="padding:10rpx">
  3 + <text class="five-level-word explain-coupon" wx:if="{{item.Remark}}">{{util.format(item.Remark)}}</text>
  4 + <text class="five-level-word explain-coupon" wx:else>
  5 + <block wx:if="{{item.UseObjectName}}">仅{{item.UseObjectName}}使用</block>
  6 + <block wx:else>全场通用</block>
  7 + </text>
  8 + </view>
  9 +</view>
0 \ No newline at end of file 10 \ No newline at end of file
pages/user/order_list/order_list.js
@@ -56,10 +56,10 @@ Page({ @@ -56,10 +56,10 @@ Page({
56 th.setData({conf: e }); 56 th.setData({conf: e });
57 //--- 看后台是不是有开通等级卡 --- 57 //--- 看后台是不是有开通等级卡 ---
58 if(e.switch_list){ 58 if(e.switch_list){
59 - var s_list=JSON.parse(e.switch_list);  
60 - //如果后台有开启等级价的功能  
61 - if(parseInt(s_list.rank_switch)==2){  
62 - var user=getApp().globalData.userInfo; 59 + var s_list=JSON.parse(e.switch_list);
  60 + var user=getApp().globalData.userInfo;
  61 + //如果后台有开启等级价的功能
  62 + if(parseInt(s_list.rank_switch)==2 && user['card_expiredate']){
63 var str = user['card_expiredate'].replace(/-/g, '/'); 63 var str = user['card_expiredate'].replace(/-/g, '/');
64 var end = new Date(str); 64 var end = new Date(str);
65 end = Date.parse(end) / 1000; 65 end = Date.parse(end) / 1000;
utils/util.js
@@ -343,11 +343,36 @@ function draw_circle(ctx,x,y,r,img,color,unit){ @@ -343,11 +343,36 @@ function draw_circle(ctx,x,y,r,img,color,unit){
343 ctx.restore(); 343 ctx.restore();
344 } 344 }
345 345
346 -  
347 function null_promise(){ 346 function null_promise(){
348 var promise=new Promise(function(resolve, reject){ var ob={code:-1,data:null}; resolve(ob); }); return promise; 347 var promise=new Promise(function(resolve, reject){ var ob={code:-1,data:null}; resolve(ob); }); return promise;
349 } 348 }
350 349
  350 +//---合并数组去掉重复项---
  351 +function mergeArray(arr1, arr2){
  352 + for (var i = 0 ; i < arr1.length ; i ++ ){
  353 + for(var j = 0 ; j < arr2.length ; j ++ ){
  354 + if (arr1[i] === arr2[j]){
  355 + arr1.splice(i,1); //利用splice函数删除元素,从第i个位置,截取长度为1的元素
  356 + }
  357 + }
  358 + }
  359 + //alert(arr1.length)
  360 + for(var i = 0; i <arr2.length; i++){
  361 + arr1.push(arr2[i]);
  362 + }
  363 + return arr1;
  364 +}
  365 +
  366 +//一个数组是否包含另一个数组
  367 +function isContained(aa, bb) {
  368 + if (!(aa instanceof Array) || !(bb instanceof Array) || ((aa.length < bb.length))) { return false; }
  369 + var aaStr = aa.toString();
  370 + for (var i = 0; i < bb.length; i++) { if (aaStr.indexOf(bb[i]) < 0) return false; }
  371 + return true;
  372 +}
  373 +
  374 +
  375 +
351 module.exports = { 376 module.exports = {
352 formatTime: function(e, r) { 377 formatTime: function(e, r) {
353 var t = e ? new Date(1e3 * e) : new Date(), n = t.getFullYear(), o = t.getMonth() + 1, a = t.getDate(), u = t.getHours(), i = t.getMinutes(), f = t.getSeconds(), s = function(e) { 378 var t = e ? new Date(1e3 * e) : new Date(), n = t.getFullYear(), o = t.getMonth() + 1, a = t.getDate(), u = t.getHours(), i = t.getMinutes(), f = t.getSeconds(), s = function(e) {
@@ -449,5 +474,7 @@ module.exports = { @@ -449,5 +474,7 @@ module.exports = {
449 draw_randon_rect:draw_randon_rect ,//画图画圆角矩形 474 draw_randon_rect:draw_randon_rect ,//画图画圆角矩形
450 null_promise:null_promise,//返回空的promise 475 null_promise:null_promise,//返回空的promise
451 get_box_arr:get_box_arr,//返回圆的数组 476 get_box_arr:get_box_arr,//返回圆的数组
452 - draw_circle:draw_circle,//绘制圆 477 + draw_circle:draw_circle,//绘制圆,
  478 + mergeArray:mergeArray, //数组合并
  479 + isContained:isContained, //是否包含
453 }; 480 };