Commit bcc735c24aa84ef4b0b4b6411773839f9c787745
1 parent
34e11ce8
OA单预存款使用
Showing
6 changed files
with
430 additions
and
41 deletions
packageE/pages/cart/cart2/cart2.js
1 | 1 | var t = getApp(), app = t, a = t.request, e = require("../../../../utils/common.js"), |
2 | - s = require("../../../../utils/util.js"), ut = s, o = require("../../../../utils/md5.js"), to = getApp(); | |
2 | + s = require("../../../../utils/util.js"), rq = require("../../../../utils/request.js"), ut = s, o = require("../../../../utils/md5.js"), to = getApp(); | |
3 | 3 | var oo = t.globalData.setting, os = oo; |
4 | 4 | var regeneratorRuntime = require('../../../../utils/runtime.js'); |
5 | 5 | var util_pay = require("../../../../utils/pay.js"); |
... | ... | @@ -138,7 +138,7 @@ Page({ |
138 | 138 | bn_use_commission: 0, //是不是使用佣金 |
139 | 139 | cart_use_commission: 0, |
140 | 140 | cart_commission: 0, |
141 | - | |
141 | + udata:null,//用户预存值,数据 | |
142 | 142 | //订单所有搭配购的 |
143 | 143 | all_collocation_list: [], |
144 | 144 | appoint_pick_keyid:'' |
... | ... | @@ -313,9 +313,146 @@ Page({ |
313 | 313 | //值在这里换 |
314 | 314 | getApp().globalData.plus_buy_back = 0; |
315 | 315 | }, |
316 | + //获取预存款余额 | |
317 | + async getAdvancesum(){ | |
318 | + /*-----获取线下会员的预存款和优惠券的数量-----*/ | |
319 | + let url= "/api/weshop/users/getinfo/" + os.stoid + "/" + getApp().globalData.userInfo.user_id | |
320 | + await getApp().request.promiseGet(url, { | |
321 | + data: { | |
322 | + isShowLoading: 0, | |
323 | + }, | |
324 | + }).then(su => { | |
325 | + if (su.data.code == 0 && su.data.data) { | |
326 | + var data = su.data.data; | |
327 | + if (!data) data = {}; | |
328 | + data.cashcount = parseInt(data.cashcount); | |
329 | + this.setData({ | |
330 | + udata: data, | |
331 | + }); | |
332 | + } | |
333 | + }) | |
316 | 334 | |
335 | + }, | |
336 | + //购物车预存开启关闭 | |
337 | + prestore(e){ | |
338 | + let ind=e.currentTarget.dataset.ind; | |
339 | + let item = e.currentTarget.dataset.item | |
340 | + let txt = 'cartlist[' + ind + '].yck_off'; | |
341 | + let txt1 = 'old_cartlist[' + ind + '].yck_off'; | |
342 | + if(item.yck_off==2){ | |
343 | + this.setData({ [txt]: 1,[txt1]:1}) | |
344 | + }else if(item.yck_off==1){ | |
345 | + this.setData({ [txt]: 2,[txt1]:2}) | |
346 | + } | |
347 | + this.calculatePrice()//计算金额 | |
348 | + }, | |
349 | + //直接购买预存开启关闭 | |
350 | + prestore2(){ | |
351 | + let txt = 'bn_goods.yck_off'; | |
352 | + if(this.data.bn_goods.yck_off==2){ | |
353 | + this.setData({ [txt]: 1}) | |
354 | + }else if(this.data.bn_goods.yck_off==1){ | |
355 | + this.setData({ [txt]: 2}) | |
356 | + } | |
357 | + this.calculatePrice2()//计算金额 | |
358 | + }, | |
359 | + //计算商品预存款前置方法------------------------------------ | |
360 | + async beforAdvancesum(cartList){ | |
361 | + // let cartList= this.data.cartlist | |
362 | + // let cartList= arr | |
363 | + // let length = cartList.length | |
364 | + wx.showLoading({ | |
365 | + title: '加载中', | |
366 | + mask:true | |
367 | + }) | |
368 | + // for (let i = 0; i < length; i++) { | |
369 | + let item = cartList; | |
370 | + let goods = item.goods | |
371 | + let keyid=item.sto.keyid | |
372 | + let listform = [] | |
373 | + goods.map(ite=>{ | |
374 | + let obj={ | |
375 | + wareno: ite.goods_sn, | |
376 | + price: ite.goods_price, | |
377 | + qty: ite.goods_num | |
378 | + } | |
379 | + listform.push(obj) | |
380 | + }) | |
381 | + let arr = await this.getGoodsAdvancesum(keyid,listform,cartList) | |
382 | + // } | |
383 | + return arr | |
384 | + // wx.hideLoading() | |
385 | + }, | |
386 | + //计算商品预存款请求方法------------------------------------ | |
387 | + async getGoodsAdvancesum(storageid,listform,cartList){ | |
388 | + let res = await getApp().request.promisePost(`/api/weshop/delphiapi/saveErpApi`,{ | |
389 | + data:{ | |
390 | + accdb:getApp().globalData.config.erpid, | |
391 | + ApiName:'api.pos.shop.advancesum.seek', | |
392 | + usercode: "admin", | |
393 | + vipid: this.data.userinfo.erpvipid, | |
394 | + oddsum: "0", | |
395 | + advancesum: cartList.order_amount, | |
396 | + storageid: storageid, | |
397 | + listform | |
398 | + }, | |
399 | + is_json:1 | |
400 | + }) | |
401 | + console.log('计算商品的预存款'); | |
402 | + console.log(res); | |
403 | + let yck=0 | |
404 | + let yckid="" | |
405 | + let yckIdArr=[] | |
406 | + let pre_json=null | |
407 | + if (res.data.code==0 && res.data.data && res.data.data.length>0) { | |
408 | + let resData=res.data.data | |
409 | + resData.map(ite=>{ | |
410 | + yck+=ite.advancesum | |
411 | + yckIdArr.push(ite.advanceitemid) | |
412 | + }) | |
413 | + pre_json=resData | |
414 | + } | |
415 | + yckid=yckIdArr.join() | |
416 | + let obj={} | |
417 | + if(yck*1>0){ | |
418 | + obj.yck_off=1 | |
419 | + }else{ | |
420 | + obj.yck_off=0 | |
421 | + } | |
422 | + obj.yck=yck | |
423 | + obj.yckid=yckid | |
424 | + obj.pre_json=pre_json | |
425 | + return obj | |
426 | + }, | |
317 | 427 | |
318 | - | |
428 | + //支付成功后预存处理请求 | |
429 | + async setAdvancesum(item,number){ | |
430 | + let pre_json = item.pre_json ? JSON.parse(item.pre_json) : [] | |
431 | + if(!pre_json.length){return} | |
432 | + let listform=[] | |
433 | + pre_json.map(ite=>{ | |
434 | + let ob={ | |
435 | + advanceitemid: ite.advanceitemid, | |
436 | + insum: "", | |
437 | + outsum: ite.advancesum, | |
438 | + remark: "" | |
439 | + } | |
440 | + listform.push(ob) | |
441 | + }) | |
442 | + let obj={ | |
443 | + accdb:getApp().globalData.config.erpid, | |
444 | + ApiName:'api.pos.shop.vipinfolist.save', | |
445 | + vipid: this.data.userinfo.erpvipid, | |
446 | + storageid: item.keyid, | |
447 | + operator: "admin", | |
448 | + number, | |
449 | + listform, | |
450 | + } | |
451 | + let res = await getApp().request.promisePost(`/api/weshop/delphiapi/saveErpApi`,{ | |
452 | + data:obj, | |
453 | + is_json:1 | |
454 | + }) | |
455 | + }, | |
319 | 456 | |
320 | 457 | //-------------------获取物流--------------- |
321 | 458 | get_wuliu(func) { |
... | ... | @@ -371,9 +508,10 @@ Page({ |
371 | 508 | }, |
372 | 509 | |
373 | 510 | //----------------展示页面,是再获取用户信息之后-------------- |
374 | - show_page: function () { | |
511 | + async show_page() { | |
375 | 512 | var th = this, ta = this.data.param; |
376 | - | |
513 | + //获取用户预存款 | |
514 | + await th.getAdvancesum() | |
377 | 515 | //会员的信息,要获取最新 |
378 | 516 | var user = getApp().globalData.userInfo; |
379 | 517 | getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, { |
... | ... | @@ -962,6 +1100,8 @@ Page({ |
962 | 1100 | } |
963 | 1101 | } |
964 | 1102 | |
1103 | + | |
1104 | + | |
965 | 1105 | //深拷贝 |
966 | 1106 | th.data.old_cartlist = JSON.parse(JSON.stringify(arr)); |
967 | 1107 | th.setData({ |
... | ... | @@ -979,10 +1119,7 @@ Page({ |
979 | 1119 | } |
980 | 1120 | th.calculatePrice(); |
981 | 1121 | th.get_cart_quan(); |
982 | - }) | |
983 | - | |
984 | - }, 500) | |
985 | - | |
1122 | + })}, 500) | |
986 | 1123 | } |
987 | 1124 | }); |
988 | 1125 | }, |
... | ... | @@ -1755,6 +1892,9 @@ Page({ |
1755 | 1892 | var all_zh_cutprice = 0; //所有的组合优惠减 |
1756 | 1893 | var all_ladder_cutprice = 0; //所有的阶梯促销优惠减 |
1757 | 1894 | var all_order_prom = 0; //所有的订单优惠 |
1895 | + var all_prestore=0; //所有预存优化金额 | |
1896 | + var all_pre_json=[]; //所有预存优化json | |
1897 | + var all_yck_arr=[]; //所有预存真实抵扣数组 | |
1758 | 1898 | |
1759 | 1899 | var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0); |
1760 | 1900 | var out_of_weight = 0; //超出多少重量 |
... | ... | @@ -1780,6 +1920,7 @@ Page({ |
1780 | 1920 | await th.get_cart_quan(c_arr); |
1781 | 1921 | |
1782 | 1922 | |
1923 | + | |
1783 | 1924 | //-- 经纬度不循环调用接口 -- |
1784 | 1925 | var lon = 0; var lat = 0; |
1785 | 1926 | //---循环购物车--- |
... | ... | @@ -2240,8 +2381,69 @@ Page({ |
2240 | 2381 | }) |
2241 | 2382 | if (!is_next) return false |
2242 | 2383 | } |
2384 | + | |
2385 | + //预存金额使用参与计算 | |
2386 | + if(th.data.udata && th.data.udata.Balance>0 && cart_item.order_amount*1>0){ | |
2387 | + let cart_yc = await th.beforAdvancesum(cart_item) | |
2388 | + if(!cart_item.yck_off){ | |
2389 | + cart_item.yck_off=cart_yc.yck_off | |
2390 | + } | |
2391 | + cart_item.yck=cart_yc.yck | |
2392 | + cart_item.yckid=cart_yc.yckid | |
2393 | + cart_item.pre_json=cart_yc.pre_json | |
2394 | + let yct1 = 'cartlist[' + i + '].yck_off'; | |
2395 | + let yct11 = 'old_cartlist[' + i + '].yck_off'; | |
2396 | + let yct2 = 'cartlist[' + i + '].yck'; | |
2397 | + let yct22 = 'old_cartlist[' + i + '].yck'; | |
2398 | + let yct3 = 'cartlist[' + i + '].yckid'; | |
2399 | + let yct33 = 'old_cartlist[' + i + '].yckid'; | |
2400 | + let yct4 = 'cartlist[' + i + '].pre_json'; | |
2401 | + let yct44 = 'old_cartlist[' + i + '].pre_json'; | |
2402 | + th.setData({ | |
2403 | + [yct1]:cart_item.yck_off, | |
2404 | + [yct11]:cart_item.yck_off, | |
2405 | + [yct2]:cart_item.yck, | |
2406 | + [yct22]:cart_item.yck, | |
2407 | + [yct3]:cart_item.yckid, | |
2408 | + [yct33]:cart_item.yckid, | |
2409 | + [yct4]:cart_item.pre_json, | |
2410 | + [yct44]:cart_item.pre_json, | |
2411 | + }) | |
2243 | 2412 | |
2244 | - | |
2413 | + if(cart_item.yck_off && cart_item.yck_off==2 ){ | |
2414 | + let order_amount = (cart_item.order_amount - cart_item.yck).toFixed(2); | |
2415 | + let yck=0 | |
2416 | + if(order_amount*1>0){ | |
2417 | + cart_item.order_amount = order_amount; | |
2418 | + all_prestore+=parseFloat(cart_item.yck); | |
2419 | + yck=parseFloat(cart_item.yck) | |
2420 | + }else{ | |
2421 | + all_prestore+=cart_item.order_amount*1 | |
2422 | + yck=parseFloat(cart_item.order_amount) | |
2423 | + cart_item.order_amount=0 | |
2424 | + } | |
2425 | + all_yck_arr.push(yck) //真实预存款抵扣金额 | |
2426 | + all_pre_json.push(cart_item.pre_json) | |
2427 | + all_prestore = parseFloat(all_prestore); //真实预存款抵扣金额总和 | |
2428 | + } | |
2429 | + }else{ | |
2430 | + let yct1 = 'cartlist[' + i + '].yck_off'; | |
2431 | + let yct11 = 'old_cartlist[' + i + '].yck_off'; | |
2432 | + let yct2 = 'cartlist[' + i + '].yck'; | |
2433 | + let yct22 = 'old_cartlist[' + i + '].yck'; | |
2434 | + let yct3 = 'cartlist[' + i + '].yckid'; | |
2435 | + let yct33 = 'old_cartlist[' + i + '].yckid'; | |
2436 | + let yct4 = 'cartlist[' + i + '].pre_json'; | |
2437 | + let yct44 = 'old_cartlist[' + i + '].pre_json'; | |
2438 | + th.setData({ | |
2439 | + [yct2]:0, | |
2440 | + [yct22]:0, | |
2441 | + [yct3]:'', | |
2442 | + [yct33]:'', | |
2443 | + [yct4]:'', | |
2444 | + [yct44]:'', | |
2445 | + }) | |
2446 | + } | |
2245 | 2447 | |
2246 | 2448 | |
2247 | 2449 | |
... | ... | @@ -2322,6 +2524,7 @@ Page({ |
2322 | 2524 | all_order_prom += parseFloat(cart_item.order_prom_amount); |
2323 | 2525 | } |
2324 | 2526 | |
2527 | + all_prestore = parseFloat(all_prestore).toFixed(2); | |
2325 | 2528 | all_shipping_m = parseFloat(all_shipping_m).toFixed(2); |
2326 | 2529 | all_total_m = parseFloat(all_total_m).toFixed(2); |
2327 | 2530 | all_order_m = parseFloat(all_order_m).toFixed(2); |
... | ... | @@ -2344,12 +2547,18 @@ Page({ |
2344 | 2547 | var atxt7 = "formData.order_prom_amount"; |
2345 | 2548 | var atxt8 = "formData.zh_cut_price"; |
2346 | 2549 | var atxt9 = "formData.ladder_cut_price"; |
2550 | + var atxt10 = "formData.prestore"; //预存金额 | |
2551 | + var atxt11 = "formData.pre_json"; //预存json | |
2552 | + var atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | |
2347 | 2553 | |
2348 | 2554 | th.setData({ |
2349 | 2555 | [atxt]: all_total_m, [atxt1]: all_order_m, |
2350 | 2556 | [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m, |
2351 | 2557 | [atxt5]: all_coupon_price_m, [atxt6]: all_cutprice, |
2352 | - [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice, [atxt9]: all_ladder_cutprice, submit: 0 | |
2558 | + [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice, [atxt9]: all_ladder_cutprice, submit: 0, | |
2559 | + [atxt10]:all_prestore, | |
2560 | + [atxt11]:all_pre_json, | |
2561 | + [atxt12]:all_yck_arr, | |
2353 | 2562 | }) |
2354 | 2563 | th.data.order_prom_list_cart = c_arr; |
2355 | 2564 | th.set_can_num(); |
... | ... | @@ -2410,7 +2619,7 @@ Page({ |
2410 | 2619 | var allpice = good.shop_price * good.buynum; |
2411 | 2620 | var cut_price = 0; |
2412 | 2621 | var allpice1 = allpice; |
2413 | - | |
2622 | + | |
2414 | 2623 | |
2415 | 2624 | if (good.prom_type == 3 && good.prom_price !== null) { |
2416 | 2625 | cut_price = allpice - good.prom_price; |
... | ... | @@ -2676,6 +2885,107 @@ Page({ |
2676 | 2885 | if (th.data.bn_goods.whsle_id > 0) { |
2677 | 2886 | o_condition = 0; |
2678 | 2887 | } |
2888 | + | |
2889 | + | |
2890 | + //预存金额使用参与计算 | |
2891 | + if(th.data.udata && th.data.udata.Balance>0 && order_m*1>0){ | |
2892 | + if(!th.data.bn_goods.keyid){ | |
2893 | + //获取门店信息 | |
2894 | + await getApp().request.promiseGet("/api/weshop/pickup/list", { data: { | |
2895 | + store_id: os.stoid, | |
2896 | + ids: th.data.bn_pick | |
2897 | + } }).then(res => { | |
2898 | + if (ut.ajax_ok(res)) { | |
2899 | + console.log(res); | |
2900 | + if(res.data.code==0){ | |
2901 | + let resData = res.data.data.pageData | |
2902 | + if(resData && resData[0]){ | |
2903 | + let keyid= resData[0].keyid | |
2904 | + let txt='bn_goods.keyid' | |
2905 | + th.setData({ | |
2906 | + [txt]:keyid | |
2907 | + }) | |
2908 | + } | |
2909 | + } | |
2910 | + } | |
2911 | + }) | |
2912 | + } | |
2913 | + if(th.data.bn_goods.keyid){ | |
2914 | + let cart_yc = await th.beforAdvancesum({ | |
2915 | + order_amount:order_m, | |
2916 | + goods:[{ | |
2917 | + goods_sn:th.data.bn_goods.goods_sn, | |
2918 | + goods_price:th.data.bn_goods.goods_price, | |
2919 | + goods_num:th.data.bn_goods.goods_num, | |
2920 | + }], | |
2921 | + sto:{ | |
2922 | + keyid:th.data.bn_goods.keyid | |
2923 | + } | |
2924 | + }) | |
2925 | + | |
2926 | + if(!good.yck_off){ | |
2927 | + good.yck_off=cart_yc.yck_off | |
2928 | + } | |
2929 | + good.yck=cart_yc.yck | |
2930 | + good.yckid=cart_yc.yckid | |
2931 | + good.pre_json=cart_yc.pre_json | |
2932 | + let yct1 = 'bn_goods.yck_off'; | |
2933 | + let yct2 = 'bn_goods.yck'; | |
2934 | + let yct3 = 'bn_goods.yckid'; | |
2935 | + let yct4 = 'bn_goods.pre_json'; | |
2936 | + th.setData({ | |
2937 | + [yct1]:good.yck_off, | |
2938 | + [yct2]:good.yck, | |
2939 | + [yct3]:good.yckid, | |
2940 | + [yct4]:good.pre_json, | |
2941 | + }) | |
2942 | + | |
2943 | + if(good.yck_off && good.yck_off==2 ){ | |
2944 | + let order_amount = (order_m - good.yck).toFixed(2); | |
2945 | + let yck=0 | |
2946 | + if(order_amount*1>0){ | |
2947 | + order_m = order_amount; | |
2948 | + // all_prestore+=parseFloat(good.yck); | |
2949 | + yck=parseFloat(good.yck) | |
2950 | + }else{ | |
2951 | + // all_prestore+=order_m*1 | |
2952 | + yck=parseFloat(order_m) | |
2953 | + order_m=0 | |
2954 | + } | |
2955 | + let atxt10 = "formData.prestore"; //预存金额 | |
2956 | + let atxt11 = "formData.pre_json"; //预存json | |
2957 | + let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | |
2958 | + th.setData({ | |
2959 | + [atxt10]:yck, | |
2960 | + [atxt11]:[good.pre_json], | |
2961 | + [atxt12]:[yck], | |
2962 | + }) | |
2963 | + // formData.prestore | |
2964 | + // all_yck_arr.push(yck) //真实预存款抵扣金额 | |
2965 | + // all_pre_json.push(good.pre_json) | |
2966 | + // all_prestore = parseFloat(all_prestore); //真实预存款抵扣金额总和 | |
2967 | + } | |
2968 | + } | |
2969 | + }else{ | |
2970 | + let yct1 = 'bn_goods.yck_off'; | |
2971 | + let yct2 = 'bn_goods.yck'; | |
2972 | + let yct3 = 'bn_goods.yckid'; | |
2973 | + let yct4 = 'bn_goods.pre_json'; | |
2974 | + let atxt10 = "formData.prestore"; //预存金额 | |
2975 | + let atxt11 = "formData.pre_json"; //预存json | |
2976 | + let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | |
2977 | + th.setData({ | |
2978 | + [yct2]:0, | |
2979 | + [yct3]:'', | |
2980 | + [yct4]:'', | |
2981 | + [atxt10]:0, | |
2982 | + [atxt11]:'', | |
2983 | + [atxt12]:[], | |
2984 | + }) | |
2985 | + } | |
2986 | + | |
2987 | + | |
2988 | + | |
2679 | 2989 | if (o_condition > 0) { |
2680 | 2990 | th.check_is_order_prom(o_condition, async function () { |
2681 | 2991 | var order_prom_amount = 0; |
... | ... | @@ -2914,6 +3224,7 @@ Page({ |
2914 | 3224 | } |
2915 | 3225 | |
2916 | 3226 | |
3227 | + | |
2917 | 3228 | total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); |
2918 | 3229 | order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); |
2919 | 3230 | var atxt = "formData.total_amount"; |
... | ... | @@ -3073,16 +3384,17 @@ Page({ |
3073 | 3384 | let strarr=[] |
3074 | 3385 | let cbarr=[] |
3075 | 3386 | let cbarr_id=[] |
3076 | - | |
3077 | - for (let index = 0,length=cartlist.length; index < length; index++) { | |
3078 | - let item=cartlist[index].goods | |
3079 | - for (let i = 0,leng=item.length; i < leng; i++) { | |
3080 | - if (item[i].prom_type==7) { | |
3081 | - strarr.push(item[i]) | |
3082 | - } | |
3083 | - if (item[i].prom_type !=7 && item[i].goods_prom_type==7) { | |
3084 | - allarr.push(item[i]) | |
3085 | - } | |
3387 | + if(cartlist && cartlist.length>0){ | |
3388 | + for (let index = 0,length=cartlist.length; index < length; index++) { | |
3389 | + let item=cartlist[index].goods | |
3390 | + for (let i = 0,leng=item.length; i < leng; i++) { | |
3391 | + if (item[i].prom_type==7) { | |
3392 | + strarr.push(item[i]) | |
3393 | + } | |
3394 | + if (item[i].prom_type !=7 && item[i].goods_prom_type==7) { | |
3395 | + allarr.push(item[i]) | |
3396 | + } | |
3397 | + } | |
3086 | 3398 | } |
3087 | 3399 | } |
3088 | 3400 | if(strarr.length>0){ |
... | ... | @@ -3103,7 +3415,6 @@ Page({ |
3103 | 3415 | cbarr_id.push(strarr[j].id) |
3104 | 3416 | } |
3105 | 3417 | } |
3106 | - | |
3107 | 3418 | if(cbarr.length>0){ |
3108 | 3419 | let str = cbarr.join() |
3109 | 3420 | wx.showModal({ |
... | ... | @@ -3462,6 +3773,7 @@ Page({ |
3462 | 3773 | for (var i = 0; i < order_prom_list_cart.length; i++) { |
3463 | 3774 | var t_item = order_prom_list_cart[i]; |
3464 | 3775 | var item = { |
3776 | + "keyid":t_item.sto ? t_item.sto.keyid : '', | |
3465 | 3777 | 'user_id': to.globalData.user_id, |
3466 | 3778 | 'consignee': addr == null ? th.data.userinfo.mobile : addr.consignee, |
3467 | 3779 | 'province': addr == null ? 0 : addr.province, |
... | ... | @@ -3808,8 +4120,27 @@ Page({ |
3808 | 4120 | } |
3809 | 4121 | |
3810 | 4122 | if (pdata.length == 0) return; |
4123 | + //如果有使用预存,要处理 | |
4124 | + if (th.data.formData && th.data.formData.prestore*1 > 0) { | |
4125 | + let formData = th.data.formData | |
4126 | + let pre_json = formData.pre_json | |
4127 | + let all_yck_arr=formData.all_yck_arr | |
4128 | + pdata.map((item,i)=>{ | |
4129 | + item.pre_cut=all_yck_arr[i] ? all_yck_arr[i] : 0 | |
4130 | + item.pre_preferential=0 | |
4131 | + item.pre_json=pre_json[i] ? JSON.stringify(pre_json[i]) : '' | |
4132 | + }) | |
4133 | + } | |
4134 | + | |
4135 | + | |
4136 | + if(!pdata.keyid && th.data.bn_goods){ | |
4137 | + pdata.map(ite=>{ | |
4138 | + ite.keyid=th.data.bn_goods.keyid | |
4139 | + }) | |
4140 | + // pdata.keyid = th.data.bn_goods.keyid | |
4141 | + } | |
3811 | 4142 | var str = JSON.stringify(pdata); |
3812 | - | |
4143 | + | |
3813 | 4144 | wx.showLoading({ title: "加载中" }); |
3814 | 4145 | th.setData({ submit: 1, }) |
3815 | 4146 | wx.request({ |
... | ... | @@ -3821,6 +4152,7 @@ Page({ |
3821 | 4152 | },// 设置请求的 header |
3822 | 4153 | success: function (res) { |
3823 | 4154 | wx.hideLoading(); |
4155 | + | |
3824 | 4156 | if (res.statusCode == 200) { |
3825 | 4157 | var data = res.data; |
3826 | 4158 | if (data.code == 0) { |
... | ... | @@ -3838,18 +4170,32 @@ Page({ |
3838 | 4170 | pdata.forEach(function (em, ind) { |
3839 | 4171 | order_amount += parseFloat(em.order_amount); |
3840 | 4172 | }) |
4173 | + | |
3841 | 4174 | //要进行判断,如果是用微信支付,就要跳转到支付界面 |
3842 | 4175 | if (order_amount > 0) { |
3843 | 4176 | th.setData({ isclose: 0 }); |
3844 | 4177 | //void e.jumpToCart4({ |
3845 | 4178 | // order_sn: data.data, |
3846 | 4179 | //}, 1); |
3847 | - util_pay.pay(data.data, function () { | |
4180 | + | |
4181 | + util_pay.pay(data.data, async function () { | |
3848 | 4182 | //app.my_warnning("支付成功",1,th); |
3849 | 4183 | //setTimeout(function () { |
3850 | - wx.redirectTo({ | |
3851 | - url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data | |
3852 | - }) | |
4184 | + if (th.data.formData && th.data.formData.prestore*1 > 0) { //有使用预存的处理 | |
4185 | + let length=pdata.length | |
4186 | + wx.showLoading({ title: "加载中",mask:true }); | |
4187 | + for (let yi = 0; yi < length; yi++) { | |
4188 | + await th.setAdvancesum(pdata[yi],data.data) | |
4189 | + } | |
4190 | + wx.hideLoading() | |
4191 | + wx.redirectTo({ | |
4192 | + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data | |
4193 | + }) | |
4194 | + }else{ | |
4195 | + wx.redirectTo({ | |
4196 | + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data | |
4197 | + }) | |
4198 | + } | |
3853 | 4199 | //},1000) |
3854 | 4200 | |
3855 | 4201 | }, function () { |
... | ... | @@ -3876,15 +4222,29 @@ Page({ |
3876 | 4222 | }; |
3877 | 4223 | a.post("/api/weshop/order/pay/createOrder", { |
3878 | 4224 | data: dd, |
3879 | - success: function (t) { | |
3880 | - //console.log(t); | |
4225 | + success: async function (t) { | |
4226 | + console.log(t); | |
3881 | 4227 | if (t.data.code == 0) { |
3882 | 4228 | //app.my_warnning("支付成功",1,th); |
3883 | 4229 | //setTimeout(function () { |
3884 | - th.setData({ isclose: 0 }); | |
3885 | - wx.redirectTo({ | |
3886 | - url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, | |
3887 | - }) | |
4230 | + if (th.data.formData && th.data.formData.prestore*1 > 0) { //有使用预存的处理 | |
4231 | + let length=pdata.length | |
4232 | + wx.showLoading({ title: "加载中",mask:true }); | |
4233 | + for (let yi = 0; yi < length; yi++) { | |
4234 | + await th.setAdvancesum(pdata[yi],data.data) | |
4235 | + } | |
4236 | + wx.hideLoading() | |
4237 | + th.setData({ isclose: 0 }); | |
4238 | + wx.redirectTo({ | |
4239 | + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, | |
4240 | + }) | |
4241 | + }else{ | |
4242 | + th.setData({ isclose: 0 }); | |
4243 | + wx.redirectTo({ | |
4244 | + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, | |
4245 | + }) | |
4246 | + } | |
4247 | + | |
3888 | 4248 | //}, 1000) |
3889 | 4249 | } |
3890 | 4250 | }, |
... | ... | @@ -4698,7 +5058,7 @@ Page({ |
4698 | 5058 | if (!arr) arr = []; |
4699 | 5059 | //如果系统有限制使用优惠券 |
4700 | 5060 | if (th.data.is_close_quan) return false; |
4701 | - | |
5061 | + | |
4702 | 5062 | //------------开始计算使用优惠券相关------------ |
4703 | 5063 | for (var ind in arr) { |
4704 | 5064 | var ep = arr[ind]; |
... | ... | @@ -4846,7 +5206,7 @@ Page({ |
4846 | 5206 | }) |
4847 | 5207 | } |
4848 | 5208 | } |
4849 | - | |
5209 | + | |
4850 | 5210 | //如果是搭配购的立即购买的时候 |
4851 | 5211 | if (th.data.is_b_now) { |
4852 | 5212 | if (arr && arr.length > 0) { | ... | ... |
packageE/pages/cart/cart2/cart2.wxml
... | ... | @@ -251,7 +251,16 @@ |
251 | 251 | </view> |
252 | 252 | </view> |
253 | 253 | |
254 | - | |
254 | + <!-- 预存款 --> | |
255 | + <view class="set-mes" wx:if="{{item.yck_off}}" data-ind="{{pidx}}" data-item="{{item}}" catchtap="prestore"> | |
256 | + <view class="use-item" style="justify-content: space-between;"> | |
257 | + <view> | |
258 | + <icon color="{{item.yck_off==2 ? 'red' : '#808080'}}" size="16" type="success"></icon> | |
259 | + <view class="yu_er">使用预存</view> | |
260 | + </view> | |
261 | + <view wx:if="{{item.yck_off==2}}">¥{{filters.toFix(item.yck,2)}}</view> | |
262 | + </view> | |
263 | + </view> | |
255 | 264 | |
256 | 265 | <!-- 留言 --> |
257 | 266 | <view class="coupon-mes flex-vertical"> |
... | ... | @@ -516,6 +525,7 @@ |
516 | 525 | </view> |
517 | 526 | </view> |
518 | 527 | |
528 | + | |
519 | 529 | <!-----使用余额------> |
520 | 530 | <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}"> |
521 | 531 | <view class="use-item" bindtap='set_bn_useyuer'> |
... | ... | @@ -523,7 +533,16 @@ |
523 | 533 | <view class="yu_er">使用余额 :¥{{yuer}} </view> |
524 | 534 | </view> |
525 | 535 | </view> |
526 | - | |
536 | + <!-- 预存款 --> | |
537 | + <view class="set-mes" catchtap="prestore2" wx:if="{{bn_goods.yck_off}}"> | |
538 | + <view class="use-item" style="justify-content: space-between;"> | |
539 | + <view> | |
540 | + <icon color="{{bn_goods.yck_off==2 ? 'red' : '#808080'}}" size="16" type="success"></icon> | |
541 | + <view class="yu_er">使用预存</view> | |
542 | + </view> | |
543 | + <view wx:if="{{bn_goods.yck_off==2 }}">¥{{filters.toFix(bn_goods.yck,2)}}</view> | |
544 | + </view> | |
545 | + </view> | |
527 | 546 | </block> |
528 | 547 | |
529 | 548 | <view class="information bdr14"> |
... | ... | @@ -560,6 +579,11 @@ |
560 | 579 | <view>订单优惠</view> |
561 | 580 | <view class="co-red">- ¥ {{filters.toFix(formData.order_prom_amount,2)}}元</view> |
562 | 581 | </view> |
582 | + <!-- 使用预存优惠金额 --> | |
583 | + <view class="item" wx:if="{{formData.prestore>0}}"> | |
584 | + <view>使用预存</view> | |
585 | + <view class="co-red">- ¥ {{filters.toFix(formData.prestore,2)}}元</view> | |
586 | + </view> | |
563 | 587 | <view class="item" wx:if="{{formData.user_money>0}}"> |
564 | 588 | <view>使用余额</view> |
565 | 589 | <view class="co-red">- ¥ {{formData.user_money}}元</view> | ... | ... |
pages/user/order_detail/order_detail.js
pages/user/order_detail/order_detail.wxml
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | <view class="goods-num">×{{item.goods_num}}</view> |
37 | 37 | |
38 | 38 | <!-- 不是整单退的时候 --> |
39 | - <block wx:if="{{order.is_all_return!=1 && order.discount<=0 && order.coupon_price<=0 && order.order_prom_amount<=0 && order.discount_amount<=0 && item.prom_type!=5 && !order.is_prom && item.is_whsle_goods!=1}}"> | |
39 | + <block wx:if="{{!order.pre_cut && order.is_all_return!=1 && order.discount<=0 && order.coupon_price<=0 && order.order_prom_amount<=0 && order.discount_amount<=0 && item.prom_type!=5 && !order.is_prom && item.is_whsle_goods!=1}}"> | |
40 | 40 | <view bindtap="checkReturnGoodsStatus" class="goods-num" data-oid="{{item.order_id}}" |
41 | 41 | data-recid="{{item.goods_id}}" wx:if="{{item.return_btn==1 && !order.is_bedistri}}">申请退款</view> |
42 | 42 | <view bindtap="gotoreturn" class="return-btn" data-oid="{{item.order_id}}" |
... | ... | @@ -116,7 +116,10 @@ |
116 | 116 | <view>优惠券</view> |
117 | 117 | <view> ¥ {{order.coupon_price}}元</view> |
118 | 118 | </view> |
119 | - | |
119 | + <view class="item pnew" wx:if="{{order.pre_cut>0}}"> | |
120 | + <view>使用预存</view> | |
121 | + <view> ¥ {{order.pre_cut}}元</view> | |
122 | + </view> | |
120 | 123 | <view class="item pnew" wx:if="{{order.integral>0}}"> |
121 | 124 | <view>积分</view> |
122 | 125 | <view>{{order.integral}}积分</view> | ... | ... |
pages/user/order_list/order_list.js
pages/user/order_list/order_list.wxml
... | ... | @@ -162,7 +162,7 @@ |
162 | 162 | </view> |
163 | 163 | <view class="flex-level-right fs26 refund"> |
164 | 164 | <!-- 不是整单退的时候 --> |
165 | - <block wx:if="{{item.is_all_return!=1 && item.discount<=0 && item.coupon_price<=0 && item.order_prom_amount<=0 && item.discount_amount<=0 && goods.prom_type!=5 && !item.is_prom && goods.is_whsle_goods!=1}}"> | |
165 | + <block wx:if="{{!item.pre_cut && item.is_all_return!=1 && item.discount<=0 && item.coupon_price<=0 && item.order_prom_amount<=0 && item.discount_amount<=0 && goods.prom_type!=5 && !item.is_prom && goods.is_whsle_goods!=1}}"> | |
166 | 166 | <view catchtap="checkReturnGoodsStatus" class="return-btn" data-oid="{{goods.order_id}}" data-recid="{{goods.goods_id}}" wx:if="{{goods.return_btn==1 && !item.is_bedistri }}">申请退款</view> |
167 | 167 | <view catchtap="gotoreturn" class="return-btn" data-oid="{{goods.order_id}}" data-recid="{{goods.goods_id}}" wx:if="{{goods.return_btn==2}}">退款中</view> |
168 | 168 | <view catchtap="checkReturnGoodsStatus" class="return-btn" data-oid="{{goods.order_id}}" data-recid="{{goods.goods_id}}" wx:if="{{goods.return_btn==3}}">重新退款</view> | ... | ... |