Commit 9b43128bf530fa08bdba8bfb773340525e7daae5

Authored by yvan.ni
1 parent 05748a8a

预售的

packageC/pages/presell/cart/cart.js
... ... @@ -369,6 +369,7 @@ Page({
369 369 exp_type = 0,
370 370 presell=null, //订单从表
371 371 pre_arr=null, //订单内容
  372 + act=null, //订单内容
372 373 th = this;
373 374  
374 375  
... ... @@ -402,27 +403,6 @@ Page({
402 403 presell = res.data.data;
403 404 });
404 405  
405   - var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: order_goods.goods_id };
406   - if(presell.deposit_pay_time>0){
407   - pre_data.timetype=12;
408   - }
409   -
410   - pre_data.user_id = order.user_id;
411   - var isok=1;
412   - await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
413   - data: pre_data,
414   - }).then(e => {
415   - if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
416   - pre_arr = e.data.data.pageData[0];
417   - }else{
418   - isok=0;
419   - }
420   - })
421   - if(!isok){
422   - getApp().confirmBox("活动已经结束,或者会员身份不符合");
423   - return false;
424   - }
425   -
426 406 //等待定金
427 407 if(order.order_status<2 && presell.deposit_pay_time<=0 ){
428 408 th.setData({wait_dj:1})
... ... @@ -440,8 +420,6 @@ Page({
440 420 if(order.pay_status==1 && order.shipping_status==1 && order.order_status<2){
441 421 th.setData({wait_sh:1})
442 422 }
443   -
444   -
445 423 //------获取预售主表----------
446 424 await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell.prom_id, {}).then(res => {
447 425 if (res.data.code == 0 && res.data.data) {
... ... @@ -452,6 +430,62 @@ Page({
452 430 }
453 431 })
454 432  
  433 + //-- 判断一下会员的身份 --
  434 + if(order.pay_status==0){
  435 + var pre_data = { store_id: os.stoid, presell_id: presell.prom_id,timetype: 12, goods_id: order_goods.goods_id };
  436 + pre_data.user_id = order.user_id;
  437 + var isok=1;
  438 + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
  439 + data: pre_data,
  440 + }).then(e => {
  441 + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
  442 + pre_arr = e.data.data.pageData[0];
  443 + }else{
  444 + isok=0;
  445 + }
  446 + })
  447 +
  448 + if(!isok){
  449 + getApp().confirmBox("会员身份不符合");
  450 + return false;
  451 + }
  452 +
  453 + if(th.data.wait_dj){
  454 + if(act.is_end) {
  455 + getApp().confirmBox("活动已经结束");
  456 + return false;
  457 + }
  458 + if(!act.isuse) {
  459 + getApp().confirmBox("活动未启用");
  460 + return false;
  461 + }
  462 + if(th.data.act.end_time<ut.gettimestamp()) {
  463 + getApp().confirmBox("活动的定金时间已经结束");
  464 + return false;
  465 + }
  466 +
  467 + }
  468 + if(th.data.wait_wk){
  469 + if(th.data.act.pay_enddate<ut.gettimestamp()) {
  470 + getApp().confirmBox("活动的尾款时间已经结束");
  471 + return false;
  472 + }
  473 + }
  474 + }
  475 + else{
  476 + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/list",{
  477 + data:{store_id:os.stoid,goods_id:order_goods.goods_id,presell_id:order_goods.prom_id}
  478 + }).then(re=>{
  479 + if (re.data.code == 0 && re.data.data && re.data.data.length > 0) {
  480 + pre_arr = re.data.data[0];
  481 + }
  482 + })
  483 +
  484 + if(!pre_arr){
  485 + getApp().confirmBox("未找到商品");
  486 + return false;
  487 + }
  488 + }
455 489  
456 490 //---获取商品---
457 491 await getApp().request.promiseGet("/api/weshop/goods/get/" + oo.stoid + "/" + order_goods.goods_id, {}).then(res => {
... ... @@ -527,14 +561,13 @@ Page({
527 561  
528 562 //等待发货的时候
529 563 if(th.data.wait_fh){
530   - var send_time=pre_arr.delivery_date;
531   - if(pre_arr.delivery_type==2){
532   - send_time=pre_arr.delivery_daynum*3600;
  564 + var send_time=th.data.act.delivery_date;
  565 + if(th.data.act.delivery_type==2){
  566 + send_time=th.data.act.delivery_daynum*3600;
533 567 }
534 568  
535 569 }
536 570  
537   -
538 571 order.order_goods = order_goods;
539 572 var tail_pay=pre_arr.presell_price*order_goods.goods_num-presell.presell_deposit;
540 573 this.setData({
... ... @@ -557,7 +590,7 @@ Page({
557 590 //统一进行计算金额
558 591 th.calculatePrice2();
559 592 //如果可以
560   - if(pre_arr.is_usecoupon){
  593 + if(th.data.act.is_usecoupon){
561 594 th.get_buy_now_quan();
562 595 }
563 596 },
... ...
packageC/pages/presell/goodsInfo/goodsInfo.js
... ... @@ -1067,16 +1067,12 @@ Page({
1067 1067 if (re.data.data.total > 0) {
1068 1068  
1069 1069 var item = re.data.data.pageData[0];
  1070 + if (item.goods_num + th.data.goodsInputNum > o.store_count) {
  1071 + return s.my_warnning("库存不足!", 0, th);
  1072 + }
1070 1073  
1071   - //判断数量,要看下购物车中有没有该商品
1072   - if (CanOutQty) {
1073   - if (item.goods_num + th.data.goodsInputNum > CanOutQty) {
1074   - return s.my_warnning("库存不足!", 0, th);
1075   - }
1076   - } else {
1077   - if (item.goods_num + th.data.goodsInputNum > o.store_count) {
1078   - return s.my_warnning("库存不足!", 0, th);
1079   - }
  1074 + if (item.goods_num + th.data.goodsInputNum >th.data.pre_arr.presell_sumqty-th.data.pre_arr.buy_goodnum) {
  1075 + return s.my_warnning("库存不足!", 0, th);
1080 1076 }
1081 1077  
1082 1078 var updata = {
... ... @@ -1200,6 +1196,9 @@ Page({
1200 1196 }
1201 1197  
1202 1198 var e = th.data.sele_g.store_count;
  1199 + var e2=th.data.pre_arr.presell_sumqty-th.data.pre_arr.buy_goodnum;
  1200 + if(e2<e) e=e2;
  1201 +
1203 1202 if (!e) e = 0;
1204 1203 //库存不足,不增加
1205 1204 if (e < t) {
... ... @@ -1766,7 +1765,6 @@ Page({
1766 1765 })
1767 1766 }
1768 1767  
1769   -
1770 1768 var idx=all_pre_goods.findIndex(function (ele) {
1771 1769 return ele.goods_id==goodsinfo.goods_id;
1772 1770 })
... ... @@ -2394,42 +2392,22 @@ Page({
2394 2392 //----获取商品购买数----
2395 2393 getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", {
2396 2394 data: {
2397   - store_id: os.stoid,
2398   - user_id: user_id,
2399   - goods_id: gd.goods_id
  2395 + store_id: os.stoid,
  2396 + user_id: user_id,
  2397 + goods_id: gd.goods_id,
  2398 + prom_type: gd.prom_type,
  2399 + prom_id: gd.prom_id
2400 2400 },
2401 2401 success: function (t) {
2402 2402 if (t.data.code == 0) {
2403   - var g_buy_num = t.data.data.goodsbuynum;
2404   - if (gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6) {
2405   - //----获取活动购买数----
2406   - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", {
2407   - data: {
2408   - store_id: os.stoid,
2409   - user_id: user_id,
2410   - goods_id: gd.goods_id,
2411   - prom_type: gd.prom_type,
2412   - prom_id: gd.prom_id
2413   - },
2414   - //-----获取-----
2415   - success: function (tt) {
2416   - if (tt.data.code == 0) {
2417   - map.set(gd.goods_id, g_buy_num);
2418   - th.setData({
2419   - g_buy_num: map,
2420   - prom_buy_num: tt.data.data.goodsbuynum,
2421   - });
2422   - "function" == typeof func && func();
2423   - }
2424   - }
2425   - });
2426   - } else {
2427   - map.set(gd.goods_id, g_buy_num);
2428   - th.setData({
2429   - g_buy_num: map
2430   - });
  2403 + var g_buy_num = t.data.data.goodsbuynum;
  2404 + map.set(gd.goods_id, g_buy_num);
  2405 + th.setData({
  2406 + g_buy_num: map,
  2407 + prom_buy_num: t.data.data.goodsbuynum,
  2408 + });
2431 2409 "function" == typeof func && func();
2432   - }
  2410 +
2433 2411 }
2434 2412 }
2435 2413 });
... ... @@ -3923,7 +3901,6 @@ Page({
3923 3901 })
3924 3902 }
3925 3903  
3926   -
3927 3904 if (!presell_id) {
3928 3905 wx.showToast({title: "未找到活动商品", icon: 'none', duration: 3000});
3929 3906 ut.wx_back();
... ... @@ -3948,12 +3925,14 @@ Page({
3948 3925 return false;
3949 3926 }
3950 3927  
3951   - var end_time = act_data.pay_enddate;
  3928 + var err_txt="活动定金时间已经结束";
  3929 + var end_time = act_data.end_time;
3952 3930 if (act_data.presell_type == 1) {
3953   - end_time = act_data.end_time;
  3931 + end_time = act_data.pay_enddate;
  3932 + err_txt="活动尾款时间已经结束";
3954 3933 }
3955 3934 if (end_time < ut.gettimestamp()) {
3956   - wx.showToast({title: "活动已经结束", icon: 'none', duration: 3000});
  3935 + wx.showToast({title:err_txt, icon: 'none', duration: 3000});
3957 3936 setTimeout(function () {
3958 3937 ut.wx_back();
3959 3938 }, 1100)
... ... @@ -3977,10 +3956,10 @@ Page({
3977 3956 if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
3978 3957  
3979 3958 th.data.all_pre_goods = e.data.data.pageData;
3980   -
3981 3959 var idx = e.data.data.pageData.findIndex(function (ele) {
3982 3960 return ele.id == th.data.presellList.id;
3983 3961 })
  3962 +
3984 3963 pre_arr = e.data.data.pageData[idx];
3985 3964 th.setData({pre_arr: pre_arr})
3986 3965 th.data.prom_buy_limit = pre_arr.vip_butyqty;
... ...
packageC/pages/presell/goodsInfo/goodsInfo.wxml
... ... @@ -64,31 +64,34 @@
64 64 零售价¥{{filters.toFix(data.market_price,2)}}
65 65 </view>
66 66 </view>
67   - <!-- </view> -->
68   - <view class="hy-stop word-color fs26 abs">距活动结束还有</view>
69   - <!-- <view class="hy-stop word-color-lan fs26 abs" wx:if="{{prom_st==0}}">距活动开始还有</view> -->
70   - <view class="secview flex abs fs24 " style="color: black;right: 3px; top:46rpx;">
71   - <block wx:if="djs.day">
72   - <view class='day-val' style="color:#d40022;margin-top:-34rpx;">
73   - {{djs.day}}
  67 +
  68 +
  69 + <block>
  70 + <!-- </view> -->
  71 + <view class="hy-stop word-color fs26 abs">距活动结束还有</view>
  72 + <view class="secview flex abs fs24 " style="color: black;right: 3px; top:46rpx;">
  73 + <block wx:if="djs.day">
  74 + <view class='day-val' style="color:#d40022;margin-top:-34rpx;">
  75 + {{djs.day}}
  76 + </view>
  77 + <view class="day white" style="margin-top:-34rpx;margin-right:10rpx;color:#d40022">
  78 + 天
  79 + </view>
  80 + </block>
  81 + <view class='xc-time-val white t-c' style="background:#d40022">
  82 + {{djs.hou}}
74 83 </view>
75   - <view class="day white" style="margin-top:-34rpx;margin-right:10rpx;color:#d40022">
76   - 天
  84 + <view class="xc-time" style="color:#d40022">时</view>
  85 + <view class='xc-time-val white t-c' style="background:#d40022">
  86 + {{djs.min}}
77 87 </view>
78   - </block>
79   - <view class='xc-time-val white t-c' style="background:#d40022">
80   - {{djs.hou}}
81   - </view>
82   - <view class="xc-time" style="color:#d40022">时</view>
83   - <view class='xc-time-val white t-c' style="background:#d40022">
84   - {{djs.min}}
85   - </view>
86   - <view class="xc-time" style="color:#d40022">分</view>
87   - <view class='xc-time-val white t-c' style=";background:#d40022">
88   - {{djs.sec}}
  88 + <view class="xc-time" style="color:#d40022">分</view>
  89 + <view class='xc-time-val white t-c' style=";background:#d40022">
  90 + {{djs.sec}}
  91 + </view>
  92 + <view class="xc-time" style="color:#d40022">秒</view>
89 93 </view>
90   - <view class="xc-time" style="color:#d40022">秒</view>
91   - </view>
  94 + </block>
92 95 </view>
93 96 <view class="pt_fir pd20">
94 97 <!-- --显示团类型和团价格-- -->
... ... @@ -545,9 +548,9 @@
545 548  
546 549 <view class="flex">
547 550 <view class="spec-goods-stock">
548   - 已售:{{pre_arr.buy_goodnum+pre_arr.virtual_qty}}
  551 + 已售:{{presellList.buy_goodnum+presellList.virtual_qty}}
549 552 </view>
550   - <view class="spec-goods-stock">可售:{{pre_arr.presell_sumqty-pre_arr.buy_goodnum}}</view>
  553 + <view class="spec-goods-stock">可售:{{presellList.presell_sumqty-presellList.buy_goodnum}}</view>
551 554 </view>
552 555  
553 556  
... ... @@ -647,8 +650,8 @@
647 650 <block wx:else>
648 651 <view wx:if="{{openSpecModal_ind==2}}" bindtap="addCart"
649 652 data-openSpecModal_ind="{{openSpecModal_ind}}" class="spec-cart-btn spec-buy" data-action="buy">
650   - <text wx:if="{{presellForm.presell_type==0}}">支付定金(¥{{pre_arr.presell_money}})</text>
651   - <text wx:else>支付金额(¥{{pre_arr.presell_price}})</text>
  653 + <text wx:if="{{presellForm.presell_type==0}}">支付定金(¥{{presellList.presell_money}})</text>
  654 + <text wx:else>支付金额(¥{{presellList.presell_price}})</text>
652 655 </view>
653 656 </block>
654 657  
... ...