Commit cc3629d60a2615935d3c0da04a1d8f8675981c18
1 parent
f9586563
oa预存优化
Showing
1 changed file
with
444 additions
and
337 deletions
packageE/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"), rq = require("../../../../utils/request.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 | 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"); |
| 6 | var zh_calc = require("zh_calculate.js"); | 6 | var zh_calc = require("zh_calculate.js"); |
| 7 | var ladder_calc = require("ladder_calculate.js"); | 7 | var ladder_calc = require("ladder_calculate.js"); |
| 8 | -// 防抖函数用定时器 | 8 | +// 防抖函数用定时器 |
| 9 | let timer; | 9 | let timer; |
| 10 | Page({ | 10 | Page({ |
| 11 | data: { | 11 | data: { |
| @@ -53,8 +53,8 @@ Page({ | @@ -53,8 +53,8 @@ Page({ | ||
| 53 | bn_pickname: "", //选择的门店名称 | 53 | bn_pickname: "", //选择的门店名称 |
| 54 | bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 | 54 | bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 |
| 55 | 55 | ||
| 56 | - bn_is_order_yh:1, //是不是订单优惠 | ||
| 57 | - bn_is_post_temp:1, //是不是进行计算包邮模板 | 56 | + bn_is_order_yh: 1, //是不是订单优惠 |
| 57 | + bn_is_post_temp: 1, //是不是进行计算包邮模板 | ||
| 58 | 58 | ||
| 59 | bn_plus_cut_price: 0, //显示等级卡会优惠多少钱 | 59 | bn_plus_cut_price: 0, //显示等级卡会优惠多少钱 |
| 60 | /*------------------------*/ | 60 | /*------------------------*/ |
| @@ -141,10 +141,10 @@ Page({ | @@ -141,10 +141,10 @@ Page({ | ||
| 141 | bn_use_commission: 0, //是不是使用佣金 | 141 | bn_use_commission: 0, //是不是使用佣金 |
| 142 | cart_use_commission: 0, | 142 | cart_use_commission: 0, |
| 143 | cart_commission: 0, | 143 | cart_commission: 0, |
| 144 | - udata:null,//用户预存值,数据 | 144 | + udata: null,//用户预存值,数据 |
| 145 | //订单所有搭配购的 | 145 | //订单所有搭配购的 |
| 146 | all_collocation_list: [], | 146 | all_collocation_list: [], |
| 147 | - appoint_pick_keyid:'' | 147 | + appoint_pick_keyid: '' |
| 148 | }, | 148 | }, |
| 149 | onLoad: function (t) { | 149 | onLoad: function (t) { |
| 150 | wx.setNavigationBarTitle({ title: "填写订单", }) | 150 | wx.setNavigationBarTitle({ title: "填写订单", }) |
| @@ -317,81 +317,81 @@ Page({ | @@ -317,81 +317,81 @@ Page({ | ||
| 317 | getApp().globalData.plus_buy_back = 0; | 317 | getApp().globalData.plus_buy_back = 0; |
| 318 | }, | 318 | }, |
| 319 | //获取预存款余额 | 319 | //获取预存款余额 |
| 320 | - async getAdvancesum(){ | ||
| 321 | - /*-----获取线下会员的预存款和优惠券的数量-----*/ | ||
| 322 | - let url= "/api/weshop/users/getinfo/" + os.stoid + "/" + getApp().globalData.userInfo.user_id | ||
| 323 | - await getApp().request.promiseGet(url, { | ||
| 324 | - data: { | ||
| 325 | - isShowLoading: 0, | ||
| 326 | - }, | ||
| 327 | - }).then(su => { | ||
| 328 | - if (su.data.code == 0 && su.data.data) { | ||
| 329 | - var data = su.data.data; | ||
| 330 | - if (!data) data = {}; | ||
| 331 | - data.cashcount = parseInt(data.cashcount); | ||
| 332 | - this.setData({ | ||
| 333 | - udata: data, | ||
| 334 | - }); | ||
| 335 | - } | ||
| 336 | - }) | 320 | + async getAdvancesum() { |
| 321 | + /*-----获取线下会员的预存款和优惠券的数量-----*/ | ||
| 322 | + let url = "/api/weshop/users/getinfo/" + os.stoid + "/" + getApp().globalData.userInfo.user_id | ||
| 323 | + await getApp().request.promiseGet(url, { | ||
| 324 | + data: { | ||
| 325 | + isShowLoading: 0, | ||
| 326 | + }, | ||
| 327 | + }).then(su => { | ||
| 328 | + if (su.data.code == 0 && su.data.data) { | ||
| 329 | + var data = su.data.data; | ||
| 330 | + if (!data) data = {}; | ||
| 331 | + data.cashcount = parseInt(data.cashcount); | ||
| 332 | + this.setData({ | ||
| 333 | + udata: data, | ||
| 334 | + }); | ||
| 335 | + } | ||
| 336 | + }) | ||
| 337 | 337 | ||
| 338 | }, | 338 | }, |
| 339 | //购物车预存开启关闭 | 339 | //购物车预存开启关闭 |
| 340 | - prestore(e){ | ||
| 341 | - let ind=e.currentTarget.dataset.ind; | 340 | + prestore(e) { |
| 341 | + let ind = e.currentTarget.dataset.ind; | ||
| 342 | let item = e.currentTarget.dataset.item | 342 | let item = e.currentTarget.dataset.item |
| 343 | let txt = 'cartlist[' + ind + '].yck_off'; | 343 | let txt = 'cartlist[' + ind + '].yck_off'; |
| 344 | let txt1 = 'old_cartlist[' + ind + '].yck_off'; | 344 | let txt1 = 'old_cartlist[' + ind + '].yck_off'; |
| 345 | - if(item.yck_off==2){ | ||
| 346 | - this.setData({ [txt]: 1,[txt1]:1}) | ||
| 347 | - }else if(item.yck_off==1){ | ||
| 348 | - this.setData({ [txt]: 2,[txt1]:2}) | 345 | + if (item.yck_off == 2) { |
| 346 | + this.setData({ [txt]: 1, [txt1]: 1 }) | ||
| 347 | + } else if (item.yck_off == 1) { | ||
| 348 | + this.setData({ [txt]: 2, [txt1]: 2 }) | ||
| 349 | } | 349 | } |
| 350 | this.calculatePrice()//计算金额 | 350 | this.calculatePrice()//计算金额 |
| 351 | }, | 351 | }, |
| 352 | //直接购买预存开启关闭 | 352 | //直接购买预存开启关闭 |
| 353 | - prestore2(){ | 353 | + prestore2() { |
| 354 | let txt = 'bn_goods.yck_off'; | 354 | let txt = 'bn_goods.yck_off'; |
| 355 | - if(this.data.bn_goods.yck_off==2){ | ||
| 356 | - this.setData({ [txt]: 1}) | ||
| 357 | - }else if(this.data.bn_goods.yck_off==1){ | ||
| 358 | - this.setData({ [txt]: 2}) | 355 | + if (this.data.bn_goods.yck_off == 2) { |
| 356 | + this.setData({ [txt]: 1 }) | ||
| 357 | + } else if (this.data.bn_goods.yck_off == 1) { | ||
| 358 | + this.setData({ [txt]: 2 }) | ||
| 359 | } | 359 | } |
| 360 | this.calculatePrice2()//计算金额 | 360 | this.calculatePrice2()//计算金额 |
| 361 | }, | 361 | }, |
| 362 | //计算商品预存款前置方法------------------------------------ | 362 | //计算商品预存款前置方法------------------------------------ |
| 363 | - async beforAdvancesum(cartList){ | 363 | + async beforAdvancesum(cartList) { |
| 364 | // let cartList= this.data.cartlist | 364 | // let cartList= this.data.cartlist |
| 365 | // let cartList= arr | 365 | // let cartList= arr |
| 366 | // let length = cartList.length | 366 | // let length = cartList.length |
| 367 | wx.showLoading({ | 367 | wx.showLoading({ |
| 368 | title: '加载中', | 368 | title: '加载中', |
| 369 | - mask:true | 369 | + mask: true |
| 370 | }) | 370 | }) |
| 371 | // for (let i = 0; i < length; i++) { | 371 | // for (let i = 0; i < length; i++) { |
| 372 | - let item = cartList; | ||
| 373 | - let goods = item.goods | ||
| 374 | - let keyid=item.sto.keyid | ||
| 375 | - let listform = [] | ||
| 376 | - goods.map(ite=>{ | ||
| 377 | - let obj={ | ||
| 378 | - wareno: ite.goods_sn, | ||
| 379 | - price: ite.goods_price, | ||
| 380 | - qty: ite.goods_num | ||
| 381 | - } | ||
| 382 | - listform.push(obj) | ||
| 383 | - }) | ||
| 384 | - let arr = await this.getGoodsAdvancesum(keyid,listform,cartList) | 372 | + let item = cartList; |
| 373 | + let goods = item.goods | ||
| 374 | + let keyid = item.sto.keyid | ||
| 375 | + let listform = [] | ||
| 376 | + goods.map(ite => { | ||
| 377 | + let obj = { | ||
| 378 | + wareno: ite.goods_sn, | ||
| 379 | + price: ite.goods_price, | ||
| 380 | + qty: ite.goods_num | ||
| 381 | + } | ||
| 382 | + listform.push(obj) | ||
| 383 | + }) | ||
| 384 | + let arr = await this.getGoodsAdvancesum(keyid, listform, cartList) | ||
| 385 | // } | 385 | // } |
| 386 | + wx.hideLoading() | ||
| 386 | return arr | 387 | return arr |
| 387 | - // wx.hideLoading() | ||
| 388 | }, | 388 | }, |
| 389 | //计算商品预存款请求方法------------------------------------ | 389 | //计算商品预存款请求方法------------------------------------ |
| 390 | - async getGoodsAdvancesum(storageid,listform,cartList){ | ||
| 391 | - let res = await getApp().request.promisePost(`/api/weshop/delphiapi/saveErpApi`,{ | ||
| 392 | - data:{ | ||
| 393 | - accdb:getApp().globalData.config.erpid, | ||
| 394 | - ApiName:'api.pos.shop.advancesum.seek', | 390 | + async getGoodsAdvancesum(storageid, listform, cartList) { |
| 391 | + let res = await getApp().request.promisePost(`/api/weshop/delphiapi/saveErpApi`, { | ||
| 392 | + data: { | ||
| 393 | + accdb: getApp().globalData.config.erpid, | ||
| 394 | + ApiName: 'api.pos.shop.advancesum.seek', | ||
| 395 | usercode: "admin", | 395 | usercode: "admin", |
| 396 | vipid: this.data.userinfo.erpvipid, | 396 | vipid: this.data.userinfo.erpvipid, |
| 397 | oddsum: "0", | 397 | oddsum: "0", |
| @@ -399,42 +399,42 @@ Page({ | @@ -399,42 +399,42 @@ Page({ | ||
| 399 | storageid: storageid, | 399 | storageid: storageid, |
| 400 | listform | 400 | listform |
| 401 | }, | 401 | }, |
| 402 | - is_json:1 | 402 | + is_json: 1 |
| 403 | }) | 403 | }) |
| 404 | console.log('计算商品的预存款'); | 404 | console.log('计算商品的预存款'); |
| 405 | console.log(res); | 405 | console.log(res); |
| 406 | - let yck=0 | ||
| 407 | - let yckid="" | ||
| 408 | - let yckIdArr=[] | ||
| 409 | - let pre_json=null | ||
| 410 | - if (res.data.code==0 && res.data.data && res.data.data.length>0) { | ||
| 411 | - let resData=res.data.data | ||
| 412 | - resData.map(ite=>{ | ||
| 413 | - yck+=ite.advancesum | 406 | + let yck = 0 |
| 407 | + let yckid = "" | ||
| 408 | + let yckIdArr = [] | ||
| 409 | + let pre_json = null | ||
| 410 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
| 411 | + let resData = res.data.data | ||
| 412 | + resData.map(ite => { | ||
| 413 | + yck += ite.advancesum | ||
| 414 | yckIdArr.push(ite.advanceitemid) | 414 | yckIdArr.push(ite.advanceitemid) |
| 415 | }) | 415 | }) |
| 416 | - pre_json=resData | 416 | + pre_json = resData |
| 417 | } | 417 | } |
| 418 | - yckid=yckIdArr.join() | ||
| 419 | - let obj={} | ||
| 420 | - if(yck*1>0){ | ||
| 421 | - obj.yck_off=1 | ||
| 422 | - }else{ | ||
| 423 | - obj.yck_off=0 | 418 | + yckid = yckIdArr.join() |
| 419 | + let obj = {} | ||
| 420 | + if (yck * 1 > 0) { | ||
| 421 | + obj.yck_off = 1 | ||
| 422 | + } else { | ||
| 423 | + obj.yck_off = 0 | ||
| 424 | } | 424 | } |
| 425 | - obj.yck=yck | ||
| 426 | - obj.yckid=yckid | ||
| 427 | - obj.pre_json=pre_json | 425 | + obj.yck = yck |
| 426 | + obj.yckid = yckid | ||
| 427 | + obj.pre_json = pre_json | ||
| 428 | return obj | 428 | return obj |
| 429 | }, | 429 | }, |
| 430 | 430 | ||
| 431 | //支付成功后预存处理请求 | 431 | //支付成功后预存处理请求 |
| 432 | - async setAdvancesum(item,number){ | 432 | + async setAdvancesum(item, number) { |
| 433 | let pre_json = item.pre_json ? JSON.parse(item.pre_json) : [] | 433 | let pre_json = item.pre_json ? JSON.parse(item.pre_json) : [] |
| 434 | - if(!pre_json.length){return} | ||
| 435 | - let listform=[] | ||
| 436 | - pre_json.map(ite=>{ | ||
| 437 | - let ob={ | 434 | + if (!pre_json.length) { return } |
| 435 | + let listform = [] | ||
| 436 | + pre_json.map(ite => { | ||
| 437 | + let ob = { | ||
| 438 | advanceitemid: ite.advanceitemid, | 438 | advanceitemid: ite.advanceitemid, |
| 439 | insum: "", | 439 | insum: "", |
| 440 | outsum: ite.advancesum, | 440 | outsum: ite.advancesum, |
| @@ -442,18 +442,18 @@ Page({ | @@ -442,18 +442,18 @@ Page({ | ||
| 442 | } | 442 | } |
| 443 | listform.push(ob) | 443 | listform.push(ob) |
| 444 | }) | 444 | }) |
| 445 | - let obj={ | ||
| 446 | - accdb:getApp().globalData.config.erpid, | ||
| 447 | - ApiName:'api.pos.shop.vipinfolist.save', | 445 | + let obj = { |
| 446 | + accdb: getApp().globalData.config.erpid, | ||
| 447 | + ApiName: 'api.pos.shop.vipinfolist.save', | ||
| 448 | vipid: this.data.userinfo.erpvipid, | 448 | vipid: this.data.userinfo.erpvipid, |
| 449 | storageid: item.keyid, | 449 | storageid: item.keyid, |
| 450 | operator: "admin", | 450 | operator: "admin", |
| 451 | number, | 451 | number, |
| 452 | listform, | 452 | listform, |
| 453 | } | 453 | } |
| 454 | - let res = await getApp().request.promisePost(`/api/weshop/delphiapi/saveErpApi`,{ | ||
| 455 | - data:obj, | ||
| 456 | - is_json:1 | 454 | + let res = await getApp().request.promisePost(`/api/weshop/delphiapi/saveErpApi`, { |
| 455 | + data: obj, | ||
| 456 | + is_json: 1 | ||
| 457 | }) | 457 | }) |
| 458 | }, | 458 | }, |
| 459 | 459 | ||
| @@ -699,14 +699,14 @@ Page({ | @@ -699,14 +699,14 @@ Page({ | ||
| 699 | item1.promgoodsbuynum = promgoodsbuynum; | 699 | item1.promgoodsbuynum = promgoodsbuynum; |
| 700 | 700 | ||
| 701 | //如果是秒杀的时候 | 701 | //如果是秒杀的时候 |
| 702 | - if(item1.prom_type==1){ | ||
| 703 | - var url= "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid | ||
| 704 | - + "/" + item1.goods_id + "/1/" + item1.prom_id + "/" + app.globalData.user_id; | ||
| 705 | - await app.request.promiseGet(url,{}).then(res=>{ | ||
| 706 | - if(res.data.code==0){ | ||
| 707 | - console.log(res.data.data,"111"); | ||
| 708 | - item1.is_order_yh=res.data.data.is_order_yh; | ||
| 709 | - item1.is_post_temp=res.data.data.is_post_temp; | 702 | + if (item1.prom_type == 1) { |
| 703 | + var url = "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid | ||
| 704 | + + "/" + item1.goods_id + "/1/" + item1.prom_id + "/" + app.globalData.user_id; | ||
| 705 | + await app.request.promiseGet(url, {}).then(res => { | ||
| 706 | + if (res.data.code == 0) { | ||
| 707 | + console.log(res.data.data, "111"); | ||
| 708 | + item1.is_order_yh = res.data.data.is_order_yh; | ||
| 709 | + item1.is_post_temp = res.data.data.is_post_temp; | ||
| 710 | } | 710 | } |
| 711 | }) | 711 | }) |
| 712 | } | 712 | } |
| @@ -1116,7 +1116,7 @@ Page({ | @@ -1116,7 +1116,7 @@ Page({ | ||
| 1116 | } | 1116 | } |
| 1117 | } | 1117 | } |
| 1118 | 1118 | ||
| 1119 | - | 1119 | + |
| 1120 | 1120 | ||
| 1121 | //深拷贝 | 1121 | //深拷贝 |
| 1122 | th.data.old_cartlist = JSON.parse(JSON.stringify(arr)); | 1122 | th.data.old_cartlist = JSON.parse(JSON.stringify(arr)); |
| @@ -1135,7 +1135,8 @@ Page({ | @@ -1135,7 +1135,8 @@ Page({ | ||
| 1135 | } | 1135 | } |
| 1136 | th.calculatePrice(); | 1136 | th.calculatePrice(); |
| 1137 | th.get_cart_quan(); | 1137 | th.get_cart_quan(); |
| 1138 | - })}, 500) | 1138 | + }) |
| 1139 | + }, 500) | ||
| 1139 | } | 1140 | } |
| 1140 | }); | 1141 | }); |
| 1141 | }, | 1142 | }, |
| @@ -1455,16 +1456,16 @@ Page({ | @@ -1455,16 +1456,16 @@ Page({ | ||
| 1455 | t.data.data.thi_rate = tt.data.data.thi_rate; | 1456 | t.data.data.thi_rate = tt.data.data.thi_rate; |
| 1456 | t.data.data.commission = tt.data.data.commission; | 1457 | t.data.data.commission = tt.data.data.commission; |
| 1457 | 1458 | ||
| 1458 | - if(tt.data.data.is_order_yh){ | ||
| 1459 | - th.data.bn_is_order_yh=1; | ||
| 1460 | - }else{ | ||
| 1461 | - th.data.bn_is_order_yh=0; | 1459 | + if (tt.data.data.is_order_yh) { |
| 1460 | + th.data.bn_is_order_yh = 1; | ||
| 1461 | + } else { | ||
| 1462 | + th.data.bn_is_order_yh = 0; | ||
| 1462 | } | 1463 | } |
| 1463 | 1464 | ||
| 1464 | - if(tt.data.data.is_post_temp){ | ||
| 1465 | - th.data.bn_is_post_temp=1; | ||
| 1466 | - }else{ | ||
| 1467 | - th.data.bn_is_post_temp=0; | 1465 | + if (tt.data.data.is_post_temp) { |
| 1466 | + th.data.bn_is_post_temp = 1; | ||
| 1467 | + } else { | ||
| 1468 | + th.data.bn_is_post_temp = 0; | ||
| 1468 | } | 1469 | } |
| 1469 | 1470 | ||
| 1470 | } else { | 1471 | } else { |
| @@ -1919,9 +1920,9 @@ Page({ | @@ -1919,9 +1920,9 @@ Page({ | ||
| 1919 | var all_zh_cutprice = 0; //所有的组合优惠减 | 1920 | var all_zh_cutprice = 0; //所有的组合优惠减 |
| 1920 | var all_ladder_cutprice = 0; //所有的阶梯促销优惠减 | 1921 | var all_ladder_cutprice = 0; //所有的阶梯促销优惠减 |
| 1921 | var all_order_prom = 0; //所有的订单优惠 | 1922 | var all_order_prom = 0; //所有的订单优惠 |
| 1922 | - var all_prestore=0; //所有预存优化金额 | ||
| 1923 | - var all_pre_json=[]; //所有预存优化json | ||
| 1924 | - var all_yck_arr=[]; //所有预存真实抵扣数组 | 1923 | + var all_prestore = 0; //所有预存优化金额 |
| 1924 | + var all_pre_json = []; //所有预存优化json | ||
| 1925 | + var all_yck_arr = []; //所有预存真实抵扣数组 | ||
| 1925 | 1926 | ||
| 1926 | var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0); | 1927 | var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0); |
| 1927 | var out_of_weight = 0; //超出多少重量 | 1928 | var out_of_weight = 0; //超出多少重量 |
| @@ -1986,8 +1987,8 @@ Page({ | @@ -1986,8 +1987,8 @@ Page({ | ||
| 1986 | var ladder_prom_goods = c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间 | 1987 | var ladder_prom_goods = c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间 |
| 1987 | 1988 | ||
| 1988 | 1989 | ||
| 1989 | - var no_order_yh=0; //-- 有些活动不能和订单优惠叠加的金额 -- | ||
| 1990 | - var no_post_temp=0; //-- 有些活动不能和包邮模板的金额 -- | 1990 | + var no_order_yh = 0; //-- 有些活动不能和订单优惠叠加的金额 -- |
| 1991 | + var no_post_temp = 0; //-- 有些活动不能和包邮模板的金额 -- | ||
| 1991 | 1992 | ||
| 1992 | 1993 | ||
| 1993 | if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined) | 1994 | if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined) |
| @@ -2043,11 +2044,11 @@ Page({ | @@ -2043,11 +2044,11 @@ Page({ | ||
| 2043 | o_price += item[j].goods_price * item[j].goods_num; | 2044 | o_price += item[j].goods_price * item[j].goods_num; |
| 2044 | 2045 | ||
| 2045 | //-- 秒杀的时候,判断有没有订单优惠和包邮模板的叠加 -- | 2046 | //-- 秒杀的时候,判断有没有订单优惠和包邮模板的叠加 -- |
| 2046 | - if(item[j].prom_type==1 ){ | ||
| 2047 | - if(!item[j].is_order_yh) | ||
| 2048 | - no_order_yh+=item[j].goods_price * item[j].goods_num; | ||
| 2049 | - if(!item[j].is_post_temp) | ||
| 2050 | - no_post_temp+=item[j].goods_price * item[j].goods_num; | 2047 | + if (item[j].prom_type == 1) { |
| 2048 | + if (!item[j].is_order_yh) | ||
| 2049 | + no_order_yh += item[j].goods_price * item[j].goods_num; | ||
| 2050 | + if (!item[j].is_post_temp) | ||
| 2051 | + no_post_temp += item[j].goods_price * item[j].goods_num; | ||
| 2051 | } | 2052 | } |
| 2052 | 2053 | ||
| 2053 | 2054 | ||
| @@ -2149,15 +2150,15 @@ Page({ | @@ -2149,15 +2150,15 @@ Page({ | ||
| 2149 | }) | 2150 | }) |
| 2150 | } | 2151 | } |
| 2151 | 2152 | ||
| 2152 | - var user_addr=th.data.user_addr; | 2153 | + var user_addr = th.data.user_addr; |
| 2153 | var req_d = { | 2154 | var req_d = { |
| 2154 | province: user_addr.province, city: user_addr.city, district: user_addr.district, | 2155 | province: user_addr.province, city: user_addr.city, district: user_addr.district, |
| 2155 | - wuliu:parseFloat(o_price - quan_price-whsle_goods_price-no_post_temp).toFixed(2),store_id: os.stoid | 2156 | + wuliu: parseFloat(o_price - quan_price - whsle_goods_price - no_post_temp).toFixed(2), store_id: os.stoid |
| 2156 | } | 2157 | } |
| 2157 | await getApp().request.promisePost("/api/weshop/order/areaFreight", { | 2158 | await getApp().request.promisePost("/api/weshop/order/areaFreight", { |
| 2158 | is_json: 1, data: req_d | 2159 | is_json: 1, data: req_d |
| 2159 | }).then(rs => { | 2160 | }).then(rs => { |
| 2160 | - if (rs.data.code == 0) back_data =rs.data.data; | 2161 | + if (rs.data.code == 0) back_data = rs.data.data; |
| 2161 | }); | 2162 | }); |
| 2162 | 2163 | ||
| 2163 | } | 2164 | } |
| @@ -2329,9 +2330,9 @@ Page({ | @@ -2329,9 +2330,9 @@ Page({ | ||
| 2329 | } | 2330 | } |
| 2330 | 2331 | ||
| 2331 | 2332 | ||
| 2332 | - if(no_order_yh){ | ||
| 2333 | - o_condition=o_condition-no_order_yh; | ||
| 2334 | - t_o_condition=t_o_condition-no_order_yh; | 2333 | + if (no_order_yh) { |
| 2334 | + o_condition = o_condition - no_order_yh; | ||
| 2335 | + t_o_condition = t_o_condition - no_order_yh; | ||
| 2335 | } | 2336 | } |
| 2336 | 2337 | ||
| 2337 | var order_m = 0; | 2338 | var order_m = 0; |
| @@ -2426,16 +2427,16 @@ Page({ | @@ -2426,16 +2427,16 @@ Page({ | ||
| 2426 | }) | 2427 | }) |
| 2427 | if (!is_next) return false | 2428 | if (!is_next) return false |
| 2428 | } | 2429 | } |
| 2429 | - | 2430 | + |
| 2430 | //预存金额使用参与计算 | 2431 | //预存金额使用参与计算 |
| 2431 | - if(th.data.udata && th.data.udata.Balance>0 && cart_item.order_amount*1>0){ | 2432 | + if (th.data.udata && th.data.udata.Balance > 0 && cart_item.order_amount * 1 > 0) { |
| 2432 | let cart_yc = await th.beforAdvancesum(cart_item) | 2433 | let cart_yc = await th.beforAdvancesum(cart_item) |
| 2433 | - if(!cart_item.yck_off){ | ||
| 2434 | - cart_item.yck_off=cart_yc.yck_off | 2434 | + if (!cart_item.yck_off) { |
| 2435 | + cart_item.yck_off = cart_yc.yck_off | ||
| 2435 | } | 2436 | } |
| 2436 | - cart_item.yck=cart_yc.yck | ||
| 2437 | - cart_item.yckid=cart_yc.yckid | ||
| 2438 | - cart_item.pre_json=cart_yc.pre_json | 2437 | + cart_item.yck = cart_yc.yck |
| 2438 | + cart_item.yckid = cart_yc.yckid | ||
| 2439 | + cart_item.pre_json = cart_yc.pre_json | ||
| 2439 | let yct1 = 'cartlist[' + i + '].yck_off'; | 2440 | let yct1 = 'cartlist[' + i + '].yck_off'; |
| 2440 | let yct11 = 'old_cartlist[' + i + '].yck_off'; | 2441 | let yct11 = 'old_cartlist[' + i + '].yck_off'; |
| 2441 | let yct2 = 'cartlist[' + i + '].yck'; | 2442 | let yct2 = 'cartlist[' + i + '].yck'; |
| @@ -2445,33 +2446,33 @@ Page({ | @@ -2445,33 +2446,33 @@ Page({ | ||
| 2445 | let yct4 = 'cartlist[' + i + '].pre_json'; | 2446 | let yct4 = 'cartlist[' + i + '].pre_json'; |
| 2446 | let yct44 = 'old_cartlist[' + i + '].pre_json'; | 2447 | let yct44 = 'old_cartlist[' + i + '].pre_json'; |
| 2447 | th.setData({ | 2448 | th.setData({ |
| 2448 | - [yct1]:cart_item.yck_off, | ||
| 2449 | - [yct11]:cart_item.yck_off, | ||
| 2450 | - [yct2]:cart_item.yck, | ||
| 2451 | - [yct22]:cart_item.yck, | ||
| 2452 | - [yct3]:cart_item.yckid, | ||
| 2453 | - [yct33]:cart_item.yckid, | ||
| 2454 | - [yct4]:cart_item.pre_json, | ||
| 2455 | - [yct44]:cart_item.pre_json, | 2449 | + [yct1]: cart_item.yck_off, |
| 2450 | + [yct11]: cart_item.yck_off, | ||
| 2451 | + [yct2]: cart_item.yck, | ||
| 2452 | + [yct22]: cart_item.yck, | ||
| 2453 | + [yct3]: cart_item.yckid, | ||
| 2454 | + [yct33]: cart_item.yckid, | ||
| 2455 | + [yct4]: cart_item.pre_json, | ||
| 2456 | + [yct44]: cart_item.pre_json, | ||
| 2456 | }) | 2457 | }) |
| 2457 | 2458 | ||
| 2458 | - if(cart_item.yck_off && cart_item.yck_off==2 ){ | 2459 | + if (cart_item.yck_off && cart_item.yck_off == 2) { |
| 2459 | let order_amount = (cart_item.order_amount - cart_item.yck).toFixed(2); | 2460 | let order_amount = (cart_item.order_amount - cart_item.yck).toFixed(2); |
| 2460 | - let yck=0 | ||
| 2461 | - if(order_amount*1>0){ | 2461 | + let yck = 0 |
| 2462 | + if (order_amount * 1 > 0) { | ||
| 2462 | cart_item.order_amount = order_amount; | 2463 | cart_item.order_amount = order_amount; |
| 2463 | - all_prestore+=parseFloat(cart_item.yck); | ||
| 2464 | - yck=parseFloat(cart_item.yck) | ||
| 2465 | - }else{ | ||
| 2466 | - all_prestore+=cart_item.order_amount*1 | ||
| 2467 | - yck=parseFloat(cart_item.order_amount) | ||
| 2468 | - cart_item.order_amount=0 | 2464 | + all_prestore += parseFloat(cart_item.yck); |
| 2465 | + yck = parseFloat(cart_item.yck) | ||
| 2466 | + } else { | ||
| 2467 | + all_prestore += cart_item.order_amount * 1 | ||
| 2468 | + yck = parseFloat(cart_item.order_amount) | ||
| 2469 | + cart_item.order_amount = 0 | ||
| 2469 | } | 2470 | } |
| 2470 | all_yck_arr.push(yck) //真实预存款抵扣金额 | 2471 | all_yck_arr.push(yck) //真实预存款抵扣金额 |
| 2471 | all_pre_json.push(cart_item.pre_json) | 2472 | all_pre_json.push(cart_item.pre_json) |
| 2472 | all_prestore = parseFloat(all_prestore); //真实预存款抵扣金额总和 | 2473 | all_prestore = parseFloat(all_prestore); //真实预存款抵扣金额总和 |
| 2473 | } | 2474 | } |
| 2474 | - }else{ | 2475 | + } else { |
| 2475 | let yct1 = 'cartlist[' + i + '].yck_off'; | 2476 | let yct1 = 'cartlist[' + i + '].yck_off'; |
| 2476 | let yct11 = 'old_cartlist[' + i + '].yck_off'; | 2477 | let yct11 = 'old_cartlist[' + i + '].yck_off'; |
| 2477 | let yct2 = 'cartlist[' + i + '].yck'; | 2478 | let yct2 = 'cartlist[' + i + '].yck'; |
| @@ -2481,12 +2482,12 @@ Page({ | @@ -2481,12 +2482,12 @@ Page({ | ||
| 2481 | let yct4 = 'cartlist[' + i + '].pre_json'; | 2482 | let yct4 = 'cartlist[' + i + '].pre_json'; |
| 2482 | let yct44 = 'old_cartlist[' + i + '].pre_json'; | 2483 | let yct44 = 'old_cartlist[' + i + '].pre_json'; |
| 2483 | th.setData({ | 2484 | th.setData({ |
| 2484 | - [yct2]:0, | ||
| 2485 | - [yct22]:0, | ||
| 2486 | - [yct3]:'', | ||
| 2487 | - [yct33]:'', | ||
| 2488 | - [yct4]:'', | ||
| 2489 | - [yct44]:'', | 2485 | + [yct2]: 0, |
| 2486 | + [yct22]: 0, | ||
| 2487 | + [yct3]: '', | ||
| 2488 | + [yct33]: '', | ||
| 2489 | + [yct4]: '', | ||
| 2490 | + [yct44]: '', | ||
| 2490 | }) | 2491 | }) |
| 2491 | } | 2492 | } |
| 2492 | 2493 | ||
| @@ -2563,7 +2564,7 @@ Page({ | @@ -2563,7 +2564,7 @@ Page({ | ||
| 2563 | all_user_m += parseFloat(cart_item.user_money); | 2564 | all_user_m += parseFloat(cart_item.user_money); |
| 2564 | all_coupon_price_m += parseFloat(cart_item.coupon_price); | 2565 | all_coupon_price_m += parseFloat(cart_item.coupon_price); |
| 2565 | all_cutprice += parseFloat(cart_item.cut_price); | 2566 | all_cutprice += parseFloat(cart_item.cut_price); |
| 2566 | - | 2567 | + |
| 2567 | all_zh_cutprice += parseFloat((cart_item.zh_cut_price ? cart_item.zh_cut_price : '0')); | 2568 | all_zh_cutprice += parseFloat((cart_item.zh_cut_price ? cart_item.zh_cut_price : '0')); |
| 2568 | all_ladder_cutprice += parseFloat(cart_item.ladder_cut_price); | 2569 | all_ladder_cutprice += parseFloat(cart_item.ladder_cut_price); |
| 2569 | all_order_prom += parseFloat(cart_item.order_prom_amount); | 2570 | all_order_prom += parseFloat(cart_item.order_prom_amount); |
| @@ -2581,7 +2582,7 @@ Page({ | @@ -2581,7 +2582,7 @@ Page({ | ||
| 2581 | all_order_prom = all_order_prom.toFixed(2); | 2582 | all_order_prom = all_order_prom.toFixed(2); |
| 2582 | all_zh_cutprice = parseFloat(all_zh_cutprice).toFixed(2); | 2583 | all_zh_cutprice = parseFloat(all_zh_cutprice).toFixed(2); |
| 2583 | all_ladder_cutprice = parseFloat(all_ladder_cutprice).toFixed(2); | 2584 | all_ladder_cutprice = parseFloat(all_ladder_cutprice).toFixed(2); |
| 2584 | - | 2585 | + |
| 2585 | var atxt = "formData.total_amount"; | 2586 | var atxt = "formData.total_amount"; |
| 2586 | var atxt1 = "formData.order_amount"; | 2587 | var atxt1 = "formData.order_amount"; |
| 2587 | var atxt2 = "formData.all_price"; | 2588 | var atxt2 = "formData.all_price"; |
| @@ -2601,9 +2602,9 @@ Page({ | @@ -2601,9 +2602,9 @@ Page({ | ||
| 2601 | [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m, | 2602 | [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m, |
| 2602 | [atxt5]: all_coupon_price_m, [atxt6]: all_cutprice, | 2603 | [atxt5]: all_coupon_price_m, [atxt6]: all_cutprice, |
| 2603 | [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice, [atxt9]: all_ladder_cutprice, submit: 0, | 2604 | [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice, [atxt9]: all_ladder_cutprice, submit: 0, |
| 2604 | - [atxt10]:all_prestore, | ||
| 2605 | - [atxt11]:all_pre_json, | ||
| 2606 | - [atxt12]:all_yck_arr, | 2605 | + [atxt10]: all_prestore, |
| 2606 | + [atxt11]: all_pre_json, | ||
| 2607 | + [atxt12]: all_yck_arr, | ||
| 2607 | }) | 2608 | }) |
| 2608 | th.data.order_prom_list_cart = c_arr; | 2609 | th.data.order_prom_list_cart = c_arr; |
| 2609 | th.set_can_num(); | 2610 | th.set_can_num(); |
| @@ -2664,7 +2665,7 @@ Page({ | @@ -2664,7 +2665,7 @@ Page({ | ||
| 2664 | var allpice = good.shop_price * good.buynum; | 2665 | var allpice = good.shop_price * good.buynum; |
| 2665 | var cut_price = 0; | 2666 | var cut_price = 0; |
| 2666 | var allpice1 = allpice; | 2667 | var allpice1 = allpice; |
| 2667 | - | 2668 | + |
| 2668 | 2669 | ||
| 2669 | if (good.prom_type == 3 && good.prom_price !== null) { | 2670 | if (good.prom_type == 3 && good.prom_price !== null) { |
| 2670 | cut_price = allpice - good.prom_price; | 2671 | cut_price = allpice - good.prom_price; |
| @@ -2782,7 +2783,7 @@ Page({ | @@ -2782,7 +2783,7 @@ Page({ | ||
| 2782 | var back_data = null; | 2783 | var back_data = null; |
| 2783 | 2784 | ||
| 2784 | //判断是不是包邮模板 | 2785 | //判断是不是包邮模板 |
| 2785 | - if(th.data.bn_is_post_temp){ | 2786 | + if (th.data.bn_is_post_temp) { |
| 2786 | await getApp().request.promisePost("/api/weshop/order/areaFreight", { | 2787 | await getApp().request.promisePost("/api/weshop/order/areaFreight", { |
| 2787 | is_json: 1, data: req_d | 2788 | is_json: 1, data: req_d |
| 2788 | }).then(rs => { | 2789 | }).then(rs => { |
| @@ -2936,78 +2937,120 @@ Page({ | @@ -2936,78 +2937,120 @@ Page({ | ||
| 2936 | } | 2937 | } |
| 2937 | 2938 | ||
| 2938 | 2939 | ||
| 2940 | + | ||
| 2941 | + | ||
| 2942 | + | ||
| 2943 | + if (o_condition > 0 && th.data.bn_is_order_yh) { | ||
| 2944 | + | ||
| 2945 | + th.check_is_order_prom(o_condition, async function () { | ||
| 2946 | + var order_prom_amount = 0; | ||
| 2947 | + var order_prom_id = 0; | ||
| 2948 | + if (th.data.order_prom[th.data.bn_pick] && th.data.order_prom[th.data.bn_pick]['money'] <= o_condition) { | ||
| 2949 | + var ord_prom = th.data.order_prom[th.data.bn_pick]; | ||
| 2950 | + //么有使用券,或者活动没有限制使用优惠券 | ||
| 2951 | + if (coupon_price <= 0 || !ord_prom.is_xz_yh) { | ||
| 2952 | + order_prom_id = ord_prom['id']; | ||
| 2953 | + switch (ord_prom['type']) { | ||
| 2954 | + case 0: | ||
| 2955 | + order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | ||
| 2956 | + order_prom_amount = (o_condition - order_m).toFixed(2); | ||
| 2957 | + break; | ||
| 2958 | + case 1: | ||
| 2959 | + //-- 如果有优惠促销倍减的时候 -- | ||
| 2960 | + var bs = 1; | ||
| 2961 | + if (ord_prom.is_bz) { | ||
| 2962 | + bs = Math.floor(o_condition / ord_prom.money); | ||
| 2963 | + } | ||
| 2964 | + | ||
| 2965 | + order_m = o_condition - bs * ord_prom['expression'];//满额优惠金额 | ||
| 2966 | + order_prom_amount = ord_prom['expression']; | ||
| 2967 | + break; | ||
| 2968 | + } | ||
| 2969 | + } | ||
| 2970 | + } | ||
| 2971 | + //--订单优惠的显示-- | ||
| 2972 | + var order_prom_txt1 = "formData.order_prom_id"; | ||
| 2973 | + var order_prom_txt2 = "formData.order_prom_amount"; | ||
| 2974 | + if (order_prom_id > 0) { | ||
| 2975 | + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) | ||
| 2976 | + } else { | ||
| 2977 | + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | ||
| 2978 | + } | ||
| 2979 | + | ||
| 2939 | //预存金额使用参与计算 | 2980 | //预存金额使用参与计算 |
| 2940 | - if(th.data.udata && th.data.udata.Balance>0 && order_m*1>0){ | ||
| 2941 | - if(!th.data.bn_goods.keyid){ | 2981 | + if (th.data.udata && th.data.udata.Balance > 0 && order_m * 1 > 0) { |
| 2982 | + if (!th.data.bn_goods.keyid) { | ||
| 2942 | //获取门店信息 | 2983 | //获取门店信息 |
| 2943 | - await getApp().request.promiseGet("/api/weshop/pickup/list", { data: { | ||
| 2944 | - store_id: os.stoid, | ||
| 2945 | - ids: th.data.bn_pick | ||
| 2946 | - } }).then(res => { | 2984 | + await getApp().request.promiseGet("/api/weshop/pickup/list", { |
| 2985 | + data: { | ||
| 2986 | + store_id: os.stoid, | ||
| 2987 | + ids: th.data.bn_pick | ||
| 2988 | + } | ||
| 2989 | + }).then(res => { | ||
| 2947 | if (ut.ajax_ok(res)) { | 2990 | if (ut.ajax_ok(res)) { |
| 2948 | console.log(res); | 2991 | console.log(res); |
| 2949 | - if(res.data.code==0){ | 2992 | + if (res.data.code == 0) { |
| 2950 | let resData = res.data.data.pageData | 2993 | let resData = res.data.data.pageData |
| 2951 | - if(resData && resData[0]){ | ||
| 2952 | - let keyid= resData[0].keyid | ||
| 2953 | - let txt='bn_goods.keyid' | 2994 | + if (resData && resData[0]) { |
| 2995 | + let keyid = resData[0].keyid | ||
| 2996 | + let txt = 'bn_goods.keyid' | ||
| 2954 | th.setData({ | 2997 | th.setData({ |
| 2955 | - [txt]:keyid | 2998 | + [txt]: keyid |
| 2956 | }) | 2999 | }) |
| 2957 | } | 3000 | } |
| 2958 | } | 3001 | } |
| 2959 | } | 3002 | } |
| 2960 | }) | 3003 | }) |
| 2961 | } | 3004 | } |
| 2962 | - if(th.data.bn_goods.keyid){ | 3005 | + if (th.data.bn_goods.keyid) { |
| 2963 | let cart_yc = await th.beforAdvancesum({ | 3006 | let cart_yc = await th.beforAdvancesum({ |
| 2964 | - order_amount:order_m, | ||
| 2965 | - goods:[{ | ||
| 2966 | - goods_sn:th.data.bn_goods.goods_sn, | ||
| 2967 | - goods_price:th.data.bn_goods.goods_price, | ||
| 2968 | - goods_num:th.data.bn_goods.goods_num, | 3007 | + order_amount: order_m, |
| 3008 | + goods: [{ | ||
| 3009 | + goods_sn: th.data.bn_goods.goods_sn, | ||
| 3010 | + goods_price: th.data.bn_goods.goods_price, | ||
| 3011 | + goods_num: th.data.bn_goods.goods_num, | ||
| 2969 | }], | 3012 | }], |
| 2970 | - sto:{ | ||
| 2971 | - keyid:th.data.bn_goods.keyid | 3013 | + sto: { |
| 3014 | + keyid: th.data.bn_goods.keyid | ||
| 2972 | } | 3015 | } |
| 2973 | }) | 3016 | }) |
| 2974 | 3017 | ||
| 2975 | - if(!good.yck_off){ | ||
| 2976 | - good.yck_off=cart_yc.yck_off | 3018 | + if (!good.yck_off) { |
| 3019 | + good.yck_off = cart_yc.yck_off | ||
| 2977 | } | 3020 | } |
| 2978 | - good.yck=cart_yc.yck | ||
| 2979 | - good.yckid=cart_yc.yckid | ||
| 2980 | - good.pre_json=cart_yc.pre_json | 3021 | + good.yck = cart_yc.yck |
| 3022 | + good.yckid = cart_yc.yckid | ||
| 3023 | + good.pre_json = cart_yc.pre_json | ||
| 2981 | let yct1 = 'bn_goods.yck_off'; | 3024 | let yct1 = 'bn_goods.yck_off'; |
| 2982 | let yct2 = 'bn_goods.yck'; | 3025 | let yct2 = 'bn_goods.yck'; |
| 2983 | let yct3 = 'bn_goods.yckid'; | 3026 | let yct3 = 'bn_goods.yckid'; |
| 2984 | let yct4 = 'bn_goods.pre_json'; | 3027 | let yct4 = 'bn_goods.pre_json'; |
| 2985 | th.setData({ | 3028 | th.setData({ |
| 2986 | - [yct1]:good.yck_off, | ||
| 2987 | - [yct2]:good.yck, | ||
| 2988 | - [yct3]:good.yckid, | ||
| 2989 | - [yct4]:good.pre_json, | 3029 | + [yct1]: good.yck_off, |
| 3030 | + [yct2]: good.yck, | ||
| 3031 | + [yct3]: good.yckid, | ||
| 3032 | + [yct4]: good.pre_json, | ||
| 2990 | }) | 3033 | }) |
| 2991 | - | ||
| 2992 | - if(good.yck_off && good.yck_off==2 ){ | 3034 | + |
| 3035 | + if (good.yck_off && good.yck_off == 2) { | ||
| 2993 | let order_amount = (order_m - good.yck).toFixed(2); | 3036 | let order_amount = (order_m - good.yck).toFixed(2); |
| 2994 | - let yck=0 | ||
| 2995 | - if(order_amount*1>0){ | 3037 | + let yck = 0 |
| 3038 | + if (order_amount * 1 > 0) { | ||
| 2996 | order_m = order_amount; | 3039 | order_m = order_amount; |
| 2997 | // all_prestore+=parseFloat(good.yck); | 3040 | // all_prestore+=parseFloat(good.yck); |
| 2998 | - yck=parseFloat(good.yck) | ||
| 2999 | - }else{ | 3041 | + yck = parseFloat(good.yck) |
| 3042 | + } else { | ||
| 3000 | // all_prestore+=order_m*1 | 3043 | // all_prestore+=order_m*1 |
| 3001 | - yck=parseFloat(order_m) | ||
| 3002 | - order_m=0 | 3044 | + yck = parseFloat(order_m) |
| 3045 | + order_m = 0 | ||
| 3003 | } | 3046 | } |
| 3004 | let atxt10 = "formData.prestore"; //预存金额 | 3047 | let atxt10 = "formData.prestore"; //预存金额 |
| 3005 | let atxt11 = "formData.pre_json"; //预存json | 3048 | let atxt11 = "formData.pre_json"; //预存json |
| 3006 | let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | 3049 | let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 |
| 3007 | th.setData({ | 3050 | th.setData({ |
| 3008 | - [atxt10]:yck, | ||
| 3009 | - [atxt11]:[good.pre_json], | ||
| 3010 | - [atxt12]:[yck], | 3051 | + [atxt10]: yck, |
| 3052 | + [atxt11]: [good.pre_json], | ||
| 3053 | + [atxt12]: [yck], | ||
| 3011 | }) | 3054 | }) |
| 3012 | // formData.prestore | 3055 | // formData.prestore |
| 3013 | // all_yck_arr.push(yck) //真实预存款抵扣金额 | 3056 | // all_yck_arr.push(yck) //真实预存款抵扣金额 |
| @@ -3015,7 +3058,7 @@ Page({ | @@ -3015,7 +3058,7 @@ Page({ | ||
| 3015 | // all_prestore = parseFloat(all_prestore); //真实预存款抵扣金额总和 | 3058 | // all_prestore = parseFloat(all_prestore); //真实预存款抵扣金额总和 |
| 3016 | } | 3059 | } |
| 3017 | } | 3060 | } |
| 3018 | - }else{ | 3061 | + } else { |
| 3019 | let yct1 = 'bn_goods.yck_off'; | 3062 | let yct1 = 'bn_goods.yck_off'; |
| 3020 | let yct2 = 'bn_goods.yck'; | 3063 | let yct2 = 'bn_goods.yck'; |
| 3021 | let yct3 = 'bn_goods.yckid'; | 3064 | let yct3 = 'bn_goods.yckid'; |
| @@ -3024,51 +3067,15 @@ Page({ | @@ -3024,51 +3067,15 @@ Page({ | ||
| 3024 | let atxt11 = "formData.pre_json"; //预存json | 3067 | let atxt11 = "formData.pre_json"; //预存json |
| 3025 | let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | 3068 | let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 |
| 3026 | th.setData({ | 3069 | th.setData({ |
| 3027 | - [yct2]:0, | ||
| 3028 | - [yct3]:'', | ||
| 3029 | - [yct4]:'', | ||
| 3030 | - [atxt10]:0, | ||
| 3031 | - [atxt11]:'', | ||
| 3032 | - [atxt12]:[], | 3070 | + [yct2]: 0, |
| 3071 | + [yct3]: '', | ||
| 3072 | + [yct4]: '', | ||
| 3073 | + [atxt10]: 0, | ||
| 3074 | + [atxt11]: '', | ||
| 3075 | + [atxt12]: [], | ||
| 3033 | }) | 3076 | }) |
| 3034 | } | 3077 | } |
| 3035 | 3078 | ||
| 3036 | - if (o_condition > 0 && th.data.bn_is_order_yh) { | ||
| 3037 | - | ||
| 3038 | - th.check_is_order_prom(o_condition, async function () { | ||
| 3039 | - var order_prom_amount = 0; | ||
| 3040 | - var order_prom_id = 0; | ||
| 3041 | - if (th.data.order_prom[th.data.bn_pick] && th.data.order_prom[th.data.bn_pick]['money'] <= o_condition) { | ||
| 3042 | - var ord_prom = th.data.order_prom[th.data.bn_pick]; | ||
| 3043 | - //么有使用券,或者活动没有限制使用优惠券 | ||
| 3044 | - if (coupon_price <= 0 || !ord_prom.is_xz_yh) { | ||
| 3045 | - order_prom_id = ord_prom['id']; | ||
| 3046 | - switch (ord_prom['type']) { | ||
| 3047 | - case 0: | ||
| 3048 | - order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | ||
| 3049 | - order_prom_amount = (o_condition - order_m).toFixed(2); | ||
| 3050 | - break; | ||
| 3051 | - case 1: | ||
| 3052 | - //-- 如果有优惠促销倍减的时候 -- | ||
| 3053 | - var bs = 1; | ||
| 3054 | - if (ord_prom.is_bz) { | ||
| 3055 | - bs = Math.floor(o_condition / ord_prom.money); | ||
| 3056 | - } | ||
| 3057 | - | ||
| 3058 | - order_m = o_condition - bs * ord_prom['expression'];//满额优惠金额 | ||
| 3059 | - order_prom_amount = ord_prom['expression']; | ||
| 3060 | - break; | ||
| 3061 | - } | ||
| 3062 | - } | ||
| 3063 | - } | ||
| 3064 | - //--订单优惠的显示-- | ||
| 3065 | - var order_prom_txt1 = "formData.order_prom_id"; | ||
| 3066 | - var order_prom_txt2 = "formData.order_prom_amount"; | ||
| 3067 | - if (order_prom_id > 0) { | ||
| 3068 | - th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) | ||
| 3069 | - } else { | ||
| 3070 | - th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | ||
| 3071 | - } | ||
| 3072 | 3079 | ||
| 3073 | //判断是否同城配送,而且没有调用过 | 3080 | //判断是否同城配送,而且没有调用过 |
| 3074 | if (th.data.bn_exp_type == 2 && th.data.user_addr) { | 3081 | if (th.data.bn_exp_type == 2 && th.data.user_addr) { |
| @@ -3163,7 +3170,6 @@ Page({ | @@ -3163,7 +3170,6 @@ Page({ | ||
| 3163 | } | 3170 | } |
| 3164 | 3171 | ||
| 3165 | 3172 | ||
| 3166 | - | ||
| 3167 | var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); | 3173 | var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); |
| 3168 | //--------------如果使用余额--------------------- | 3174 | //--------------如果使用余额--------------------- |
| 3169 | if (th.data.bn_use_money == 1) { | 3175 | if (th.data.bn_use_money == 1) { |
| @@ -3218,6 +3224,105 @@ Page({ | @@ -3218,6 +3224,105 @@ Page({ | ||
| 3218 | var order_prom_txt2 = "formData.order_prom_amount"; | 3224 | var order_prom_txt2 = "formData.order_prom_amount"; |
| 3219 | th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | 3225 | th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) |
| 3220 | 3226 | ||
| 3227 | + //预存金额使用参与计算 | ||
| 3228 | + if (th.data.udata && th.data.udata.Balance > 0 && order_m * 1 > 0) { | ||
| 3229 | + if (!th.data.bn_goods.keyid) { | ||
| 3230 | + //获取门店信息 | ||
| 3231 | + await getApp().request.promiseGet("/api/weshop/pickup/list", { | ||
| 3232 | + data: { | ||
| 3233 | + store_id: os.stoid, | ||
| 3234 | + ids: th.data.bn_pick | ||
| 3235 | + } | ||
| 3236 | + }).then(res => { | ||
| 3237 | + if (ut.ajax_ok(res)) { | ||
| 3238 | + console.log(res); | ||
| 3239 | + if (res.data.code == 0) { | ||
| 3240 | + let resData = res.data.data.pageData | ||
| 3241 | + if (resData && resData[0]) { | ||
| 3242 | + let keyid = resData[0].keyid | ||
| 3243 | + let txt = 'bn_goods.keyid' | ||
| 3244 | + th.setData({ | ||
| 3245 | + [txt]: keyid | ||
| 3246 | + }) | ||
| 3247 | + } | ||
| 3248 | + } | ||
| 3249 | + } | ||
| 3250 | + }) | ||
| 3251 | + } | ||
| 3252 | + if (th.data.bn_goods.keyid) { | ||
| 3253 | + let cart_yc = await th.beforAdvancesum({ | ||
| 3254 | + order_amount: order_m, | ||
| 3255 | + goods: [{ | ||
| 3256 | + goods_sn: th.data.bn_goods.goods_sn, | ||
| 3257 | + goods_price: th.data.bn_goods.goods_price, | ||
| 3258 | + goods_num: th.data.bn_goods.goods_num, | ||
| 3259 | + }], | ||
| 3260 | + sto: { | ||
| 3261 | + keyid: th.data.bn_goods.keyid | ||
| 3262 | + } | ||
| 3263 | + }) | ||
| 3264 | + | ||
| 3265 | + if (!good.yck_off) { | ||
| 3266 | + good.yck_off = cart_yc.yck_off | ||
| 3267 | + } | ||
| 3268 | + good.yck = cart_yc.yck | ||
| 3269 | + good.yckid = cart_yc.yckid | ||
| 3270 | + good.pre_json = cart_yc.pre_json | ||
| 3271 | + let yct1 = 'bn_goods.yck_off'; | ||
| 3272 | + let yct2 = 'bn_goods.yck'; | ||
| 3273 | + let yct3 = 'bn_goods.yckid'; | ||
| 3274 | + let yct4 = 'bn_goods.pre_json'; | ||
| 3275 | + th.setData({ | ||
| 3276 | + [yct1]: good.yck_off, | ||
| 3277 | + [yct2]: good.yck, | ||
| 3278 | + [yct3]: good.yckid, | ||
| 3279 | + [yct4]: good.pre_json, | ||
| 3280 | + }) | ||
| 3281 | + | ||
| 3282 | + if (good.yck_off && good.yck_off == 2) { | ||
| 3283 | + let order_amount = (order_m - good.yck).toFixed(2); | ||
| 3284 | + let yck = 0 | ||
| 3285 | + if (order_amount * 1 > 0) { | ||
| 3286 | + order_m = order_amount; | ||
| 3287 | + // all_prestore+=parseFloat(good.yck); | ||
| 3288 | + yck = parseFloat(good.yck) | ||
| 3289 | + } else { | ||
| 3290 | + // all_prestore+=order_m*1 | ||
| 3291 | + yck = parseFloat(order_m) | ||
| 3292 | + order_m = 0 | ||
| 3293 | + } | ||
| 3294 | + let atxt10 = "formData.prestore"; //预存金额 | ||
| 3295 | + let atxt11 = "formData.pre_json"; //预存json | ||
| 3296 | + let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | ||
| 3297 | + th.setData({ | ||
| 3298 | + [atxt10]: yck, | ||
| 3299 | + [atxt11]: [good.pre_json], | ||
| 3300 | + [atxt12]: [yck], | ||
| 3301 | + }) | ||
| 3302 | + // formData.prestore | ||
| 3303 | + // all_yck_arr.push(yck) //真实预存款抵扣金额 | ||
| 3304 | + // all_pre_json.push(good.pre_json) | ||
| 3305 | + // all_prestore = parseFloat(all_prestore); //真实预存款抵扣金额总和 | ||
| 3306 | + } | ||
| 3307 | + } | ||
| 3308 | + } else { | ||
| 3309 | + let yct1 = 'bn_goods.yck_off'; | ||
| 3310 | + let yct2 = 'bn_goods.yck'; | ||
| 3311 | + let yct3 = 'bn_goods.yckid'; | ||
| 3312 | + let yct4 = 'bn_goods.pre_json'; | ||
| 3313 | + let atxt10 = "formData.prestore"; //预存金额 | ||
| 3314 | + let atxt11 = "formData.pre_json"; //预存json | ||
| 3315 | + let atxt12 = "formData.all_yck_arr"; //预存真实抵扣列表 | ||
| 3316 | + th.setData({ | ||
| 3317 | + [yct2]: 0, | ||
| 3318 | + [yct3]: '', | ||
| 3319 | + [yct4]: '', | ||
| 3320 | + [atxt10]: 0, | ||
| 3321 | + [atxt11]: '', | ||
| 3322 | + [atxt12]: [], | ||
| 3323 | + }) | ||
| 3324 | + } | ||
| 3325 | + | ||
| 3221 | //判断是否同城配送,而且没有调用过 | 3326 | //判断是否同城配送,而且没有调用过 |
| 3222 | if (th.data.bn_exp_type == 2 && th.data.user_addr) { | 3327 | if (th.data.bn_exp_type == 2 && th.data.user_addr) { |
| 3223 | var gd_w = 0, lon = 0, lat = 0; | 3328 | var gd_w = 0, lon = 0, lat = 0; |
| @@ -3310,7 +3415,9 @@ Page({ | @@ -3310,7 +3415,9 @@ Page({ | ||
| 3310 | th.setData({ [txt4]: th.data.bn_goods.use_commission }) | 3415 | th.setData({ [txt4]: th.data.bn_goods.use_commission }) |
| 3311 | } | 3416 | } |
| 3312 | 3417 | ||
| 3418 | + | ||
| 3313 | var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); | 3419 | var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); |
| 3420 | + | ||
| 3314 | //--------------如果使用余额--------------------- | 3421 | //--------------如果使用余额--------------------- |
| 3315 | if (th.data.bn_use_money == 1) { | 3422 | if (th.data.bn_use_money == 1) { |
| 3316 | if (amoney > parseFloat(order_m)) { | 3423 | if (amoney > parseFloat(order_m)) { |
| @@ -3426,95 +3533,95 @@ Page({ | @@ -3426,95 +3533,95 @@ Page({ | ||
| 3426 | } | 3533 | } |
| 3427 | 3534 | ||
| 3428 | }, | 3535 | }, |
| 3429 | - async submit_func(){ | 3536 | + async submit_func() { |
| 3430 | let cartlist = this.data.cartlist || []; | 3537 | let cartlist = this.data.cartlist || []; |
| 3431 | - let allarr=[] | ||
| 3432 | - let strarr=[] | ||
| 3433 | - let cbarr=[] | ||
| 3434 | - let cbarr_id=[] | ||
| 3435 | - | ||
| 3436 | - if(cartlist && cartlist.length>0){ | ||
| 3437 | - for (let index = 0,length=cartlist.length; index < length; index++) { | ||
| 3438 | - let item=cartlist[index].goods | ||
| 3439 | - for (let i = 0,leng=item.length; i < leng; i++) { | ||
| 3440 | - if (item[i].prom_type==7) { | ||
| 3441 | - strarr.push(item[i]) | ||
| 3442 | - } | ||
| 3443 | - if (item[i].prom_type !=7 && item[i].goods_prom_type==7) { | ||
| 3444 | - allarr.push(item[i]) | ||
| 3445 | - } | 3538 | + let allarr = [] |
| 3539 | + let strarr = [] | ||
| 3540 | + let cbarr = [] | ||
| 3541 | + let cbarr_id = [] | ||
| 3542 | + | ||
| 3543 | + if (cartlist && cartlist.length > 0) { | ||
| 3544 | + for (let index = 0, length = cartlist.length; index < length; index++) { | ||
| 3545 | + let item = cartlist[index].goods | ||
| 3546 | + for (let i = 0, leng = item.length; i < leng; i++) { | ||
| 3547 | + if (item[i].prom_type == 7) { | ||
| 3548 | + strarr.push(item[i]) | ||
| 3549 | + } | ||
| 3550 | + if (item[i].prom_type != 7 && item[i].goods_prom_type == 7) { | ||
| 3551 | + allarr.push(item[i]) | ||
| 3552 | + } | ||
| 3446 | } | 3553 | } |
| 3447 | } | 3554 | } |
| 3448 | } | 3555 | } |
| 3449 | 3556 | ||
| 3450 | - if(strarr.length>0){ | ||
| 3451 | - if(allarr.length>0){ | ||
| 3452 | - allarr.map(item=>{ | ||
| 3453 | - let aitem = strarr.find(ite=>item.goods_prom_id==ite.goods_prom_id) | ||
| 3454 | - if(aitem){ | 3557 | + if (strarr.length > 0) { |
| 3558 | + if (allarr.length > 0) { | ||
| 3559 | + allarr.map(item => { | ||
| 3560 | + let aitem = strarr.find(ite => item.goods_prom_id == ite.goods_prom_id) | ||
| 3561 | + if (aitem) { | ||
| 3455 | strarr.push(item) | 3562 | strarr.push(item) |
| 3456 | } | 3563 | } |
| 3457 | }) | 3564 | }) |
| 3458 | } | 3565 | } |
| 3459 | 3566 | ||
| 3460 | - for (let j = 0,length=strarr.length; j < length; j++) { | 3567 | + for (let j = 0, length = strarr.length; j < length; j++) { |
| 3461 | 3568 | ||
| 3462 | let userbuynum = await this.getUserBuyPromNum(strarr[j].goods_prom_id) | 3569 | let userbuynum = await this.getUserBuyPromNum(strarr[j].goods_prom_id) |
| 3463 | - if (strarr[j].act.buy_limit !=0 && userbuynum >=strarr[j].act.buy_limit) { | 3570 | + if (strarr[j].act.buy_limit != 0 && userbuynum >= strarr[j].act.buy_limit) { |
| 3464 | cbarr.push(strarr[j].goods_name) | 3571 | cbarr.push(strarr[j].goods_name) |
| 3465 | cbarr_id.push(strarr[j].id) | 3572 | cbarr_id.push(strarr[j].id) |
| 3466 | } | 3573 | } |
| 3467 | } | 3574 | } |
| 3468 | - if(cbarr.length>0){ | 3575 | + if (cbarr.length > 0) { |
| 3469 | let str = cbarr.join() | 3576 | let str = cbarr.join() |
| 3470 | wx.showModal({ | 3577 | wx.showModal({ |
| 3471 | title: '提示', | 3578 | title: '提示', |
| 3472 | content: `${str}超出组合购限购次数,将以普通商品购买`, | 3579 | content: `${str}超出组合购限购次数,将以普通商品购买`, |
| 3473 | - success: async (res)=>{ | 3580 | + success: async (res) => { |
| 3474 | if (res.confirm) { | 3581 | if (res.confirm) { |
| 3475 | - //-- 数据的更新 -- | ||
| 3476 | - for (let k = 0,length=cbarr_id.length; k < length; k++) { | ||
| 3477 | - let data = { | ||
| 3478 | - id: cbarr_id[k], | ||
| 3479 | - selected: 1, | ||
| 3480 | - store_id: oo.stoid, | ||
| 3481 | - prom_type:0, | ||
| 3482 | - prom_id:0 | ||
| 3483 | - }; | ||
| 3484 | - await getApp().request.promisePut("/api/weshop/cart/update", { | ||
| 3485 | - data:data | ||
| 3486 | - }); | ||
| 3487 | - } | ||
| 3488 | - | ||
| 3489 | - wx.reLaunch({ | ||
| 3490 | - url: '/packageE/pages/cart/cart2/cart2', | ||
| 3491 | - }) | 3582 | + //-- 数据的更新 -- |
| 3583 | + for (let k = 0, length = cbarr_id.length; k < length; k++) { | ||
| 3584 | + let data = { | ||
| 3585 | + id: cbarr_id[k], | ||
| 3586 | + selected: 1, | ||
| 3587 | + store_id: oo.stoid, | ||
| 3588 | + prom_type: 0, | ||
| 3589 | + prom_id: 0 | ||
| 3590 | + }; | ||
| 3591 | + await getApp().request.promisePut("/api/weshop/cart/update", { | ||
| 3592 | + data: data | ||
| 3593 | + }); | ||
| 3594 | + } | ||
| 3595 | + | ||
| 3596 | + wx.reLaunch({ | ||
| 3597 | + url: '/packageE/pages/cart/cart2/cart2', | ||
| 3598 | + }) | ||
| 3492 | } else if (res.cancel) { | 3599 | } else if (res.cancel) { |
| 3493 | console.log('用户点击取消') | 3600 | console.log('用户点击取消') |
| 3494 | this.setData({ | 3601 | this.setData({ |
| 3495 | - submit:0 | 3602 | + submit: 0 |
| 3496 | }) | 3603 | }) |
| 3497 | } | 3604 | } |
| 3498 | } | 3605 | } |
| 3499 | }) | 3606 | }) |
| 3500 | - }else{ | 3607 | + } else { |
| 3501 | this.submit_func2() | 3608 | this.submit_func2() |
| 3502 | } | 3609 | } |
| 3503 | - }else{ | 3610 | + } else { |
| 3504 | this.submit_func2() | 3611 | this.submit_func2() |
| 3505 | } | 3612 | } |
| 3506 | }, | 3613 | }, |
| 3507 | 3614 | ||
| 3508 | //获取用户活动参与次数 | 3615 | //获取用户活动参与次数 |
| 3509 | - async getUserBuyPromNum(prom_id){ | 3616 | + async getUserBuyPromNum(prom_id) { |
| 3510 | var userInfo = getApp().globalData.userInfo; | 3617 | var userInfo = getApp().globalData.userInfo; |
| 3511 | var url = `/api/weshop/ordergoods/getUserBuyPromNum?store_id=${os.stoid}&user_id=${userInfo.user_id}&prom_type=7&prom_id=${prom_id}`; | 3618 | var url = `/api/weshop/ordergoods/getUserBuyPromNum?store_id=${os.stoid}&user_id=${userInfo.user_id}&prom_type=7&prom_id=${prom_id}`; |
| 3512 | let res = await getApp().request.promiseGet(url, { | 3619 | let res = await getApp().request.promiseGet(url, { |
| 3513 | - data:{} | 3620 | + data: {} |
| 3514 | }); | 3621 | }); |
| 3515 | - let userbuynum=0 | ||
| 3516 | - if(res.data.code==0 && res.data.data){ | ||
| 3517 | - userbuynum=res.data.data.userbuynum | 3622 | + let userbuynum = 0 |
| 3623 | + if (res.data.code == 0 && res.data.data) { | ||
| 3624 | + userbuynum = res.data.data.userbuynum | ||
| 3518 | } | 3625 | } |
| 3519 | return userbuynum | 3626 | return userbuynum |
| 3520 | }, | 3627 | }, |
| @@ -3525,9 +3632,9 @@ Page({ | @@ -3525,9 +3632,9 @@ Page({ | ||
| 3525 | if (this.data.is_summit_ing) return false; | 3632 | if (this.data.is_summit_ing) return false; |
| 3526 | this.data.is_summit_ing = 1; | 3633 | this.data.is_summit_ing = 1; |
| 3527 | 3634 | ||
| 3528 | - function is_ok_wu_arr(index,name){ | ||
| 3529 | - if(!th.data.wu_arr) return ''; | ||
| 3530 | - if(!th.data.wu_arr[index]) return ''; | 3635 | + function is_ok_wu_arr(index, name) { |
| 3636 | + if (!th.data.wu_arr) return ''; | ||
| 3637 | + if (!th.data.wu_arr[index]) return ''; | ||
| 3531 | return th.data.wu_arr[name]; | 3638 | return th.data.wu_arr[name]; |
| 3532 | } | 3639 | } |
| 3533 | 3640 | ||
| @@ -3562,8 +3669,8 @@ Page({ | @@ -3562,8 +3669,8 @@ Page({ | ||
| 3562 | //'mobile': th.data.userinfo.mobile, | 3669 | //'mobile': th.data.userinfo.mobile, |
| 3563 | 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, | 3670 | 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, |
| 3564 | 'email': '', | 3671 | 'email': '', |
| 3565 | - 'shipping_code': th.data.bn_exp_type == 1 ? 0 : is_ok_wu_arr(th.data.index,'code'), | ||
| 3566 | - 'shipping_name': th.data.bn_exp_type == 1 ? '' : is_ok_wu_arr(th.data.index,'name'), | 3672 | + 'shipping_code': th.data.bn_exp_type == 1 ? 0 : is_ok_wu_arr(th.data.index, 'code'), |
| 3673 | + 'shipping_name': th.data.bn_exp_type == 1 ? '' : is_ok_wu_arr(th.data.index, 'name'), | ||
| 3567 | 'invoice_title': '', | 3674 | 'invoice_title': '', |
| 3568 | 'goods_price': parseFloat(th.data.formData.all_price).toFixed(2), //商品总价 | 3675 | 'goods_price': parseFloat(th.data.formData.all_price).toFixed(2), //商品总价 |
| 3569 | 'shipping_price': parseFloat(th.data.formData.shipping_price).toFixed(2), //物流金额 | 3676 | 'shipping_price': parseFloat(th.data.formData.shipping_price).toFixed(2), //物流金额 |
| @@ -3829,7 +3936,7 @@ Page({ | @@ -3829,7 +3936,7 @@ Page({ | ||
| 3829 | for (var i = 0; i < order_prom_list_cart.length; i++) { | 3936 | for (var i = 0; i < order_prom_list_cart.length; i++) { |
| 3830 | var t_item = order_prom_list_cart[i]; | 3937 | var t_item = order_prom_list_cart[i]; |
| 3831 | var item = { | 3938 | var item = { |
| 3832 | - "keyid":t_item.sto ? t_item.sto.keyid : '', | 3939 | + "keyid": t_item.sto ? t_item.sto.keyid : '', |
| 3833 | 'user_id': to.globalData.user_id, | 3940 | 'user_id': to.globalData.user_id, |
| 3834 | 'consignee': addr == null ? th.data.userinfo.mobile : addr.consignee, | 3941 | 'consignee': addr == null ? th.data.userinfo.mobile : addr.consignee, |
| 3835 | 'province': addr == null ? 0 : addr.province, | 3942 | 'province': addr == null ? 0 : addr.province, |
| @@ -3840,8 +3947,8 @@ Page({ | @@ -3840,8 +3947,8 @@ Page({ | ||
| 3840 | 'more_address': addr == null ? "" : addr.more_address, | 3947 | 'more_address': addr == null ? "" : addr.more_address, |
| 3841 | 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, | 3948 | 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile, |
| 3842 | 'email': '', | 3949 | 'email': '', |
| 3843 | - 'shipping_code': th.data.is_all_zt == 1 ? 0 : is_ok_wu_arr(t_item.wind,'code'), | ||
| 3844 | - 'shipping_name': th.data.is_all_zt == 1 ? '' : is_ok_wu_arr(t_item.wind,'name'), | 3950 | + 'shipping_code': th.data.is_all_zt == 1 ? 0 : is_ok_wu_arr(t_item.wind, 'code'), |
| 3951 | + 'shipping_name': th.data.is_all_zt == 1 ? '' : is_ok_wu_arr(t_item.wind, 'name'), | ||
| 3845 | 'invoice_title': '', | 3952 | 'invoice_title': '', |
| 3846 | 'goods_price': parseFloat(t_item.goods_price).toFixed(2), //商品总价 | 3953 | 'goods_price': parseFloat(t_item.goods_price).toFixed(2), //商品总价 |
| 3847 | 'shipping_price': parseFloat(t_item.shipping_price).toFixed(2), //物流金额 | 3954 | 'shipping_price': parseFloat(t_item.shipping_price).toFixed(2), //物流金额 |
| @@ -4177,26 +4284,26 @@ Page({ | @@ -4177,26 +4284,26 @@ Page({ | ||
| 4177 | 4284 | ||
| 4178 | if (pdata.length == 0) return; | 4285 | if (pdata.length == 0) return; |
| 4179 | //如果有使用预存,要处理 | 4286 | //如果有使用预存,要处理 |
| 4180 | - if (th.data.formData && th.data.formData.prestore*1 > 0) { | 4287 | + if (th.data.formData && th.data.formData.prestore * 1 > 0) { |
| 4181 | let formData = th.data.formData | 4288 | let formData = th.data.formData |
| 4182 | let pre_json = formData.pre_json | 4289 | let pre_json = formData.pre_json |
| 4183 | - let all_yck_arr=formData.all_yck_arr | ||
| 4184 | - pdata.map((item,i)=>{ | ||
| 4185 | - item.pre_cut=all_yck_arr[i] ? all_yck_arr[i] : 0 | ||
| 4186 | - item.pre_preferential=0 | ||
| 4187 | - item.pre_json=pre_json[i] ? JSON.stringify(pre_json[i]) : '' | 4290 | + let all_yck_arr = formData.all_yck_arr |
| 4291 | + pdata.map((item, i) => { | ||
| 4292 | + item.pre_cut = all_yck_arr[i] ? all_yck_arr[i] : 0 | ||
| 4293 | + item.pre_preferential = 0 | ||
| 4294 | + item.pre_json = pre_json[i] ? JSON.stringify(pre_json[i]) : '' | ||
| 4188 | }) | 4295 | }) |
| 4189 | } | 4296 | } |
| 4190 | - | ||
| 4191 | - | ||
| 4192 | - if(!pdata.keyid && th.data.bn_goods){ | ||
| 4193 | - pdata.map(ite=>{ | ||
| 4194 | - ite.keyid=th.data.bn_goods.keyid | 4297 | + |
| 4298 | + | ||
| 4299 | + if (!pdata.keyid && th.data.bn_goods) { | ||
| 4300 | + pdata.map(ite => { | ||
| 4301 | + ite.keyid = th.data.bn_goods.keyid | ||
| 4195 | }) | 4302 | }) |
| 4196 | // pdata.keyid = th.data.bn_goods.keyid | 4303 | // pdata.keyid = th.data.bn_goods.keyid |
| 4197 | } | 4304 | } |
| 4198 | var str = JSON.stringify(pdata); | 4305 | var str = JSON.stringify(pdata); |
| 4199 | - | 4306 | + |
| 4200 | wx.showLoading({ title: "加载中" }); | 4307 | wx.showLoading({ title: "加载中" }); |
| 4201 | th.setData({ submit: 1, }) | 4308 | th.setData({ submit: 1, }) |
| 4202 | wx.request({ | 4309 | wx.request({ |
| @@ -4208,7 +4315,7 @@ Page({ | @@ -4208,7 +4315,7 @@ Page({ | ||
| 4208 | },// 设置请求的 header | 4315 | },// 设置请求的 header |
| 4209 | success: function (res) { | 4316 | success: function (res) { |
| 4210 | wx.hideLoading(); | 4317 | wx.hideLoading(); |
| 4211 | - | 4318 | + |
| 4212 | if (res.statusCode == 200) { | 4319 | if (res.statusCode == 200) { |
| 4213 | var data = res.data; | 4320 | var data = res.data; |
| 4214 | if (data.code == 0) { | 4321 | if (data.code == 0) { |
| @@ -4226,28 +4333,28 @@ Page({ | @@ -4226,28 +4333,28 @@ Page({ | ||
| 4226 | pdata.forEach(function (em, ind) { | 4333 | pdata.forEach(function (em, ind) { |
| 4227 | order_amount += parseFloat(em.order_amount); | 4334 | order_amount += parseFloat(em.order_amount); |
| 4228 | }) | 4335 | }) |
| 4229 | - | 4336 | + |
| 4230 | //要进行判断,如果是用微信支付,就要跳转到支付界面 | 4337 | //要进行判断,如果是用微信支付,就要跳转到支付界面 |
| 4231 | if (order_amount > 0) { | 4338 | if (order_amount > 0) { |
| 4232 | th.setData({ isclose: 0 }); | 4339 | th.setData({ isclose: 0 }); |
| 4233 | //void e.jumpToCart4({ | 4340 | //void e.jumpToCart4({ |
| 4234 | // order_sn: data.data, | 4341 | // order_sn: data.data, |
| 4235 | //}, 1); | 4342 | //}, 1); |
| 4236 | - | 4343 | + |
| 4237 | util_pay.pay(data.data, async function () { | 4344 | util_pay.pay(data.data, async function () { |
| 4238 | //app.my_warnning("支付成功",1,th); | 4345 | //app.my_warnning("支付成功",1,th); |
| 4239 | //setTimeout(function () { | 4346 | //setTimeout(function () { |
| 4240 | - if (th.data.formData && th.data.formData.prestore*1 > 0) { //有使用预存的处理 | ||
| 4241 | - let length=pdata.length | ||
| 4242 | - wx.showLoading({ title: "加载中",mask:true }); | 4347 | + if (th.data.formData && th.data.formData.prestore * 1 > 0) { //有使用预存的处理 |
| 4348 | + let length = pdata.length | ||
| 4349 | + wx.showLoading({ title: "加载中", mask: true }); | ||
| 4243 | for (let yi = 0; yi < length; yi++) { | 4350 | for (let yi = 0; yi < length; yi++) { |
| 4244 | - await th.setAdvancesum(pdata[yi],data.data) | 4351 | + await th.setAdvancesum(pdata[yi], data.data) |
| 4245 | } | 4352 | } |
| 4246 | wx.hideLoading() | 4353 | wx.hideLoading() |
| 4247 | wx.redirectTo({ | 4354 | wx.redirectTo({ |
| 4248 | url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data | 4355 | url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data |
| 4249 | }) | 4356 | }) |
| 4250 | - }else{ | 4357 | + } else { |
| 4251 | wx.redirectTo({ | 4358 | wx.redirectTo({ |
| 4252 | url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data | 4359 | url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data |
| 4253 | }) | 4360 | }) |
| @@ -4279,27 +4386,27 @@ Page({ | @@ -4279,27 +4386,27 @@ Page({ | ||
| 4279 | a.post("/api/weshop/order/pay/createOrder", { | 4386 | a.post("/api/weshop/order/pay/createOrder", { |
| 4280 | data: dd, | 4387 | data: dd, |
| 4281 | success: async function (t) { | 4388 | success: async function (t) { |
| 4282 | - console.log(t); | 4389 | + console.log(t); |
| 4283 | if (t.data.code == 0) { | 4390 | if (t.data.code == 0) { |
| 4284 | //app.my_warnning("支付成功",1,th); | 4391 | //app.my_warnning("支付成功",1,th); |
| 4285 | //setTimeout(function () { | 4392 | //setTimeout(function () { |
| 4286 | - if (th.data.formData && th.data.formData.prestore*1 > 0) { //有使用预存的处理 | ||
| 4287 | - let length=pdata.length | ||
| 4288 | - wx.showLoading({ title: "加载中",mask:true }); | ||
| 4289 | - for (let yi = 0; yi < length; yi++) { | ||
| 4290 | - await th.setAdvancesum(pdata[yi],data.data) | ||
| 4291 | - } | ||
| 4292 | - wx.hideLoading() | ||
| 4293 | - th.setData({ isclose: 0 }); | ||
| 4294 | - wx.redirectTo({ | ||
| 4295 | - url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, | ||
| 4296 | - }) | ||
| 4297 | - }else{ | ||
| 4298 | - th.setData({ isclose: 0 }); | ||
| 4299 | - wx.redirectTo({ | ||
| 4300 | - url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, | ||
| 4301 | - }) | 4393 | + if (th.data.formData && th.data.formData.prestore * 1 > 0) { //有使用预存的处理 |
| 4394 | + let length = pdata.length | ||
| 4395 | + wx.showLoading({ title: "加载中", mask: true }); | ||
| 4396 | + for (let yi = 0; yi < length; yi++) { | ||
| 4397 | + await th.setAdvancesum(pdata[yi], data.data) | ||
| 4302 | } | 4398 | } |
| 4399 | + wx.hideLoading() | ||
| 4400 | + th.setData({ isclose: 0 }); | ||
| 4401 | + wx.redirectTo({ | ||
| 4402 | + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, | ||
| 4403 | + }) | ||
| 4404 | + } else { | ||
| 4405 | + th.setData({ isclose: 0 }); | ||
| 4406 | + wx.redirectTo({ | ||
| 4407 | + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data, | ||
| 4408 | + }) | ||
| 4409 | + } | ||
| 4303 | 4410 | ||
| 4304 | //}, 1000) | 4411 | //}, 1000) |
| 4305 | } | 4412 | } |
| @@ -5114,7 +5221,7 @@ Page({ | @@ -5114,7 +5221,7 @@ Page({ | ||
| 5114 | if (!arr) arr = []; | 5221 | if (!arr) arr = []; |
| 5115 | //如果系统有限制使用优惠券 | 5222 | //如果系统有限制使用优惠券 |
| 5116 | if (th.data.is_close_quan) return false; | 5223 | if (th.data.is_close_quan) return false; |
| 5117 | - | 5224 | + |
| 5118 | //------------开始计算使用优惠券相关------------ | 5225 | //------------开始计算使用优惠券相关------------ |
| 5119 | for (var ind in arr) { | 5226 | for (var ind in arr) { |
| 5120 | var ep = arr[ind]; | 5227 | var ep = arr[ind]; |
| @@ -5262,7 +5369,7 @@ Page({ | @@ -5262,7 +5369,7 @@ Page({ | ||
| 5262 | }) | 5369 | }) |
| 5263 | } | 5370 | } |
| 5264 | } | 5371 | } |
| 5265 | - | 5372 | + |
| 5266 | //如果是搭配购的立即购买的时候 | 5373 | //如果是搭配购的立即购买的时候 |
| 5267 | if (th.data.is_b_now) { | 5374 | if (th.data.is_b_now) { |
| 5268 | if (arr && arr.length > 0) { | 5375 | if (arr && arr.length > 0) { |