Commit 33964552ae9ed38b2a820f59bbe7319394fcaa51

Authored by yvan.ni
1 parent af9b551e

预售的限购问题优化问题完成

packageC/pages/presell/cart/cart.js
@@ -423,10 +423,11 @@ Page({ @@ -423,10 +423,11 @@ Page({
423 //------获取预售主表---------- 423 //------获取预售主表----------
424 await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell.prom_id, {}).then(res => { 424 await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell.prom_id, {}).then(res => {
425 if (res.data.code == 0 && res.data.data) { 425 if (res.data.code == 0 && res.data.data) {
  426 + act=res.data.data;
  427 +
426 th.setData({ 428 th.setData({
427 act: res.data.data, 429 act: res.data.data,
428 }); 430 });
429 -  
430 } 431 }
431 }) 432 })
432 433
@@ -487,6 +488,17 @@ Page({ @@ -487,6 +488,17 @@ Page({
487 } 488 }
488 } 489 }
489 490
  491 +
  492 + var g_url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+order_goods.goods_id+"&pre_id="+pre_arr.id;
  493 + if(act.is_end || th.data.act.end_time<ut.gettimestamp()) {
  494 + g_url="/pages/goods/goodsInfo/goodsInfo?goods_id="+order_goods.goods_id;
  495 + getApp().request.put("/api/weshop/goods/update",
  496 + { data:{goods_id:order_goods.goods_id,store_id:os.stoid,prom_id:0,prom_type:0},
  497 + success: function(e) {}
  498 + });
  499 + }
  500 +
  501 +
490 //---获取商品--- 502 //---获取商品---
491 await getApp().request.promiseGet("/api/weshop/goods/get/" + oo.stoid + "/" + order_goods.goods_id, {}).then(res => { 503 await getApp().request.promiseGet("/api/weshop/goods/get/" + oo.stoid + "/" + order_goods.goods_id, {}).then(res => {
492 goods = res.data.data; 504 goods = res.data.data;
@@ -584,7 +596,8 @@ Page({ @@ -584,7 +596,8 @@ Page({
584 order_goods:order_goods, 596 order_goods:order_goods,
585 all_price:pre_arr.presell_price*order_goods.goods_num, 597 all_price:pre_arr.presell_price*order_goods.goods_num,
586 pickup_id:pickup.pickup_id, 598 pickup_id:pickup.pickup_id,
587 - send_time:send_time 599 + send_time:send_time,
  600 + g_url:g_url
588 }); 601 });
589 th.get_diff(); 602 th.get_diff();
590 //统一进行计算金额 603 //统一进行计算金额
packageC/pages/presell/cart/cart.wxml
@@ -177,12 +177,11 @@ @@ -177,12 +177,11 @@
177 <view>{{pickup.pickup_name}}</view> 177 <view>{{pickup.pickup_name}}</view>
178 </view> 178 </view>
179 <view class="order-detail"> 179 <view class="order-detail">
180 - <view class="goods-img" bindtap="go_goods" data-url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{goods.goods_id}}&pre_id={{pre_arr.id}}"> 180 + <view class="goods-img" bindtap="go_goods" data-url="{{g_url}}">
181 <image class="wh100 bdr14" src="{{imgUrl}}{{goods.original_img}}" binderror='cart_set_err' 181 <image class="wh100 bdr14" src="{{imgUrl}}{{goods.original_img}}" binderror='cart_set_err'
182 data-err="goods.original_img"></image> 182 data-err="goods.original_img"></image>
183 </view> 183 </view>
184 - <navigator class="order-cont"  
185 - url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{goods.goods_id}}&pre_id={{pre_arr.id}}"> 184 + <navigator class="order-cont" url="{{g_url}}">
186 <view class="goods-name ellipsis-2">{{goods.goods_name}}</view> 185 <view class="goods-name ellipsis-2">{{goods.goods_name}}</view>
187 <!-- 商品属性 --> 186 <!-- 商品属性 -->
188 <view class="flex-vertical fs28 xc-ash color-gray n_guige"> 187 <view class="flex-vertical fs28 xc-ash color-gray n_guige">
packageC/pages/presell/goodsInfo/goodsInfo.js
@@ -2372,47 +2372,56 @@ Page({ @@ -2372,47 +2372,56 @@ Page({
2372 2372
2373 2373
2374 //-------------获取购买数量的总函数---------------- 2374 //-------------获取购买数量的总函数----------------
2375 - get_buy_num: function (gd, func) {  
2376 - var map = this.data.g_buy_num,  
2377 - th = this,  
2378 - user_id = getApp().globalData.user_id;  
2379 - if (user_id == null) {  
2380 - map.set(gd.goods_id, 0);  
2381 - th.setData({  
2382 - g_buy_num: map,  
2383 - prom_buy_num: 0,  
2384 - });  
2385 - "function" == typeof func && func();  
2386 - return false;  
2387 - } 2375 + get_buy_num: function (gd, func) {
  2376 + var map = this.data.g_buy_num,
  2377 + th = this,
  2378 + user_id = getApp().globalData.user_id;
  2379 + if (user_id == null) {
  2380 + map.set(gd.goods_id, 0);
  2381 + th.setData({
  2382 + g_buy_num: map,
  2383 + prom_buy_num: 0,
  2384 + });
  2385 + "function" == typeof func && func();
  2386 + return false;
  2387 + }
2388 2388
2389 - if (map.has(gd.goods_id)) {  
2390 - "function" == typeof func && func();  
2391 - } else {  
2392 - //----获取商品购买数----  
2393 - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", {  
2394 - data: {  
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 - },  
2401 - success: function (t) {  
2402 - if (t.data.code == 0) {  
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 - });  
2409 - "function" == typeof func && func(); 2389 + if (map.has(gd.goods_id)) {
  2390 + "function" == typeof func && func();
  2391 + } else {
  2392 + //----获取商品购买数----
  2393 + getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  2394 + data: {
  2395 + store_id: os.stoid,
  2396 + user_id: user_id,
  2397 + goods_id: gd.goods_id,
  2398 + },
  2399 + success: function (t) {
  2400 + if (t.data.code == 0) {
  2401 + var g_buy_num = t.data.data.goodsbuynum;
  2402 + map.set(gd.goods_id, g_buy_num);
  2403 + th.setData({
  2404 + g_buy_num: map,
  2405 + });
  2406 + getApp().request.get("/api/weshop/order/orderPresell/countBuyGoodsSum",{
  2407 + data: {store_id: os.stoid, user_id: user_id, goods_id: gd.goods_id, prom_id: gd.prom_id},
  2408 + success: function (e) {
  2409 + if (e.data.code == 0) {
  2410 + th.setData({prom_buy_num: e.data.data.sumgoodsnum})
  2411 + "function" == typeof func && func();
  2412 + } else {
  2413 + th.setData({prom_buy_num: 0,})
  2414 + "function" == typeof func && func();
  2415 + }
  2416 +
  2417 + }
  2418 + });
2410 2419
2411 - } 2420 + }
  2421 + }
  2422 + });
2412 } 2423 }
2413 - });  
2414 - }  
2415 - }, 2424 + },
2416 2425
2417 //--拼单推荐的显示--- 2426 //--拼单推荐的显示---
2418 tj_Click: function (e) { 2427 tj_Click: function (e) {
@@ -3887,7 +3896,6 @@ Page({ @@ -3887,7 +3896,6 @@ Page({
3887 } 3896 }
3888 }) 3897 })
3889 3898
3890 -  
3891 } else { 3899 } else {
3892 //------获取预售从表---------- 3900 //------获取预售从表----------
3893 await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + th.data.pre_id, {}).then(res => { 3901 await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + th.data.pre_id, {}).then(res => {