diff --git a/components/diy_pingd_buy/diy_pingd_buy.js b/components/diy_pingd_buy/diy_pingd_buy.js
index be709c4..26d126f 100644
--- a/components/diy_pingd_buy/diy_pingd_buy.js
+++ b/components/diy_pingd_buy/diy_pingd_buy.js
@@ -104,7 +104,11 @@ Component({
var url= "/api/weshop/teamlist/pageteam/2?page=1&pageSize=9";
getApp().request.promiseGet(url, {
data: {
- store_id: os.stoid,is_end: 0,is_show: 1,
+ store_id:
+ os.stoid,
+ is_end: 0,
+ is_show: 1,
+ user_id: getApp().globalData.user_id,
}
}).then(res => {
if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){
@@ -139,7 +143,7 @@ Component({
//--三个三个一组---
for(var i=0;i< all_array.length;i+=3){
arr.push(all_array.slice(i,i+3));
- }
+ }
/*--熏染到前台--*/
th.setData({goods_array:arr});
var newTime = ut.gettimestamp();
diff --git a/packageA/pages/distribution/myteam/myteam.wxml b/packageA/pages/distribution/myteam/myteam.wxml
index 23f27bb..0ca7b99 100644
--- a/packageA/pages/distribution/myteam/myteam.wxml
+++ b/packageA/pages/distribution/myteam/myteam.wxml
@@ -12,7 +12,7 @@
{{item.nickname}}
分销会员
- 普通会员
+ 普通会员
{{filter.format_time(item.reg_time)}}
diff --git a/packageB/pages/zuhegou/index/index.js b/packageB/pages/zuhegou/index/index.js
index af5ec6c..29d9dcf 100644
--- a/packageB/pages/zuhegou/index/index.js
+++ b/packageB/pages/zuhegou/index/index.js
@@ -1972,15 +1972,8 @@ Page({
if (this.data.act.is_bzyh && zhqty_bz.length > 0) {
if (zhqty_bz.length > 1) {
let zhqty_bz_arr = [];
- let zhqty_bz_flag = zhqty_bz.every((item1, i) => {
- var bz_num = be * item1['zhqty']; //超量倍增
- var num = item1['num'] - item1['zhqty']; //购买数量减去超量
- if (bz_num > num) {
- zhqty_bz_arr.push(item1);
- zhqty_bz.splice(i, 1)
- }
- return bz_num <= num;
- })
+ let zhqty_bz_flag=this.zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr);
+
if (zhqty_bz_flag) {
for (let i = 0; i < zhqty_bz.length; i++) {
var vv = zhqty_bz[i];
@@ -1995,11 +1988,12 @@ Page({
}
}
} else {
+ zhqty_len=1;
let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) {
- return o['num']
+ return o['num'];
}));
let new_arr = zhqty_bz_arr.filter(ii => {
- return ii['num'] == min_bz_num
+ return ii['num'] == min_bz_num;
})
var vv = new_arr[0];
var bz_num = be * new_arr[0].zhqty; //超量倍增
@@ -2018,16 +2012,20 @@ Page({
}
bz_num_ok = be * vv.zhqty;
}
-
- for (let j = 0; j < bz_num_ok; j++) {
- let index = no_in_arr.findIndex(i => {
- return vv.goods_id === i.goods_id
- })
- if (index > -1) {
- delete_num++
- no_in_arr.splice(index, 1)
+
+ for(let i = 0; i < zhqty_bz.length; i++){
+ let item1=zhqty_bz[i];
+ for (let j = 0; j < be * item1['zhqty']; j++) {
+ let index = no_in_arr.findIndex(i => {
+ return item1.goods_id === i.goods_id
+ })
+ if (index > -1) {
+ // delete_num++
+ no_in_arr.splice(index, 1)
+ }
}
}
+ aprice += be * aprice;
}
} else {
var vv = zhqty_bz[0];
@@ -2258,6 +2256,20 @@ Page({
}
if (func) func(list)
- }
+ },
+ zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr){
+ let zhqty_bz_flag =true;
+ for(let i=0;i num) {
+ zhqty_bz_flag=false;
+ zhqty_bz_arr.push(item);
+ // zhqty_bz.splice(i,1)
+ }
+ }
+ return zhqty_bz_flag;
+ }
})
\ No newline at end of file
diff --git a/packageB/pages/zuhegou/list/list.wxml b/packageB/pages/zuhegou/list/list.wxml
index f58b305..da472f6 100644
--- a/packageB/pages/zuhegou/list/list.wxml
+++ b/packageB/pages/zuhegou/list/list.wxml
@@ -63,7 +63,7 @@
没有相关内容
-
+
diff --git a/packageC/pages/group_list/group_list.wxml b/packageC/pages/group_list/group_list.wxml
index 7d63580..1e04a00 100644
--- a/packageC/pages/group_list/group_list.wxml
+++ b/packageC/pages/group_list/group_list.wxml
@@ -44,7 +44,7 @@
-
+
\ No newline at end of file
diff --git a/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js b/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js
index efeb85c..ccc853c 100644
--- a/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js
+++ b/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js
@@ -1374,11 +1374,11 @@ Page({
o_price += item[j].goods_price * item[j].goods_num;
//判断是否有设置限制重量包邮
- if(weight_free){
- if( item[j]['exp_sum_type']==2 ){
- if (goods_weight < 0) goods_weight = 0;
- //累积商品重量 每种商品的重量 * 数量
- goods_weight += item[j]['weight'] * item[j]['goods_num'];
+ if(item[j]['is_past']!==1 && item[j]['exp_sum_type']==2){
+ if (goods_weight < 0) goods_weight = 0;
+ //累积商品重量 每种商品的重量 * 数量
+ goods_weight += item[j]['weight'] * item[j]['goods_num'];
+ if(weight_free > 0){
out_of_weight = (weight_free*1000) - goods_weight;
}
}
@@ -1560,9 +1560,11 @@ Page({
}
}else{
- if(goods_weight && out_of_weight !== 0){
- goods_weight=-1;
- out_of_weight=0;
+ if(item[j]['exp_sum_type']==2){
+ if(out_of_weight !==0){
+ goods_weight=-1;
+ out_of_weight=0;
+ }
}
}
}
@@ -1866,7 +1868,9 @@ Page({
if (goods_weight < 0) goods_weight = 0;
//累积商品重量 每种商品的重量 * 数量
goods_weight += good['weight'] * good['buynum'];
- out_of_weight = (weight_free * 1000 ) - goods_weight;
+ if(weight_free > 0){
+ out_of_weight = (weight_free * 1000 ) - goods_weight;
+ }
break;
case 3:
if (goods_piece < 0) goods_piece = 0;
@@ -1896,6 +1900,7 @@ Page({
if (res.data.data[0].region_list) {
if (th.check_by_area(res.data.data[0].region_list)) {
freight_free = 0;
+ out_of_weight=0;
th.data.is_no_by[th.data.bn_pick] = 1;
}
}
@@ -1903,6 +1908,7 @@ Page({
if (res.data.data[0].goods_list && freight_free) {
if (th.check_by_goods(res.data.data[0].goods_list)) {
freight_free = 0;
+ out_of_weight=0;
th.data.is_no_by[th.data.bn_pick] = 1;
}
}
@@ -2863,7 +2869,7 @@ Page({
var price = 0, th = this;
price += parseFloat(o_shipping_price);
//如果是包邮
- if (freight_free > 0 && o_price >= freight_free && out_of_weight > 0) {
+ if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) {
return 0;
}
if (user_addr == null) {
@@ -2881,7 +2887,7 @@ Page({
item = item.config;
if (item == null) return o_shipping_price;
//------按重量----------
- if (goods_weight >= 0 && item['money'] && out_of_weight > 0) {
+ if (goods_weight >= 0 && item['money']) {
fw_price = parseFloat(item['money']);
if (goods_weight > item['first_weight']) {
var fw = goods_weight - item['first_weight'];
@@ -2890,11 +2896,14 @@ Page({
}
}
//------超出重量----------
- if(out_of_weight < 0){
+ if(out_of_weight < 0 && o_price >= freight_free){
fw_price = parseFloat(item['money']);
var out_of_weight = Math.abs(out_of_weight);
- var n = Math.ceil(out_of_weight / item['second_weight'])
- fw_price = fw_price + n * parseFloat(item['add_money']);
+ if (out_of_weight > item['first_weight']) {
+ var fw = out_of_weight - item['first_weight'];
+ var n = Math.ceil(fw / item['second_weight'])
+ fw_price = fw_price + n * parseFloat(item['add_money']);
+ }
}
//------按件数----------
if (goods_piece > 0 && item['piecemoney']) {
@@ -3786,6 +3795,7 @@ Page({
if (no_by_data && no_by_data.region_list) {
if (th.check_by_area(no_by_data.region_list)) {
gift_freight_free = 0;
+ out_of_weight=0;
th.data.is_no_by[th.data.bn_pick] = 1;
}
}
@@ -3793,12 +3803,13 @@ Page({
if (no_by_data && no_by_data.goods_list && gift_freight_free) {
if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) {
gift_freight_free = 0;
+ out_of_weight=0;
//th.data.is_no_by[th.data.bn_pick]=1;
}
}
var t_shipping_price =
- this.calculatewuliu(code, gift_shipping_price, goods_weight,
+ this.calculatewuliu(code, gift_shipping_price, goods_weight,out_of_weight,
goods_piece, user_addr, gift_freight_free, allpice, rs);
return t_shipping_price;
diff --git a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
index 79d7362..e4222b5 100644
--- a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
+++ b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
@@ -513,6 +513,10 @@ Page({
var o_shipping_price = 0,
goods_weight = -1,
goods_piece = -1;
+ var out_of_weight=null; //超出多少重量
+ var freight_free = ee.freight_free; //全场满多少包邮
+ var weight_free = ee.weight_free; //多少kg内包邮
+ var no_ex_id = ee.no_ex_id;
//-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格----------
if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type !=
3 || th.data.bn_goods.is_normal == 1)) {
@@ -525,6 +529,9 @@ Page({
if (goods_weight < 0) goods_weight = 0;
//累积商品重量 每种商品的重量 * 数量
goods_weight += good['weight'] * good['buynum'];
+ if(weight_free > 0){
+ out_of_weight = (weight_free * 1000 ) - goods_weight;
+ }
break;
case 3:
if (goods_piece < 0) goods_piece = 0;
@@ -1042,7 +1049,7 @@ Page({
th = this;
price += parseFloat(o_shipping_price);
//如果是包邮
- if (freight_free > 0 && o_price >= freight_free) {
+ if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) {
return 0;
}
if (user_addr == null) {
@@ -1061,7 +1068,7 @@ Page({
item = item.config;
if (item == null) return o_shipping_price;
//------按重量----------
- if (goods_weight > 0) {
+ if (goods_weight > 0 && item['money']) {
fw_price = parseFloat(item['money']);
if (goods_weight > item['first_weight']) {
var fw = goods_weight - item['first_weight'];
@@ -1069,6 +1076,16 @@ Page({
fw_price = fw_price + n * parseFloat(item['add_money']);
}
}
+ //------超出重量----------
+ if(out_of_weight < 0 && o_price >= freight_free){
+ fw_price = parseFloat(item['money']);
+ var out_of_weight = Math.abs(out_of_weight);
+ if (out_of_weight > item['first_weight']) {
+ var fw = out_of_weight - item['first_weight'];
+ var n = Math.ceil(fw / item['second_weight'])
+ fw_price = fw_price + n * parseFloat(item['add_money']);
+ }
+ }
//------按件数----------
if (goods_piece > 0) {
fp_price = parseFloat(item['piecemoney']);
diff --git a/packageC/pages/presell/cart/cart.js b/packageC/pages/presell/cart/cart.js
index 9374ed6..3496e3a 100644
--- a/packageC/pages/presell/cart/cart.js
+++ b/packageC/pages/presell/cart/cart.js
@@ -112,34 +112,34 @@ Page({
tabs: ['门店自提', '快递邮寄'],
currentTabIndex: 1,
- order_sn:'',
- order_id:'',
+ order_sn: '',
+ order_id: '',
},
onLoad: function (t) {
-
- if(t.order_id) this.data.order_id=t.order_id;
- if(t.order_sn) this.data.order_sn=t.order_sn;
- wx.setNavigationBarTitle({title: "订单详情",})
+ if (t.order_id) this.data.order_id = t.order_id;
+ if (t.order_sn) this.data.order_sn = t.order_sn;
+
+ wx.setNavigationBarTitle({ title: "订单详情", })
var th = this;
- this.setData({is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,});
+ this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, });
th.data.param = t;
//清理一下,确保最新的系统配置
getApp().globalData.config2 = null;
//清空is_pick_up
getApp().request.put("/api/weshop/useraddress/updatePickUp", {
- data: {user_id: getApp().globalData.user_id, is_pickup: 0},
+ data: { user_id: getApp().globalData.user_id, is_pickup: 0 },
success: function (s) {
}
});
- if(!getApp().globalData.userInfo){
+ if (!getApp().globalData.userInfo) {
getApp().goto("/pages/togoin/togoin");
}
},
onUnload: function () {
- this.setData({isclose: 1})
+ this.setData({ isclose: 1 })
},
onHide: function () {
this.setData({
@@ -152,13 +152,13 @@ Page({
//----------子页返回父页触发----------
onShow: function () {
var th = this;
- th.setData({show_submit: 0}); //让提交先掩藏
+ th.setData({ show_submit: 0 }); //让提交先掩藏
th.data.g_cart_q_time = null;
if (th.data.isclose == 0) {
wx.navigateTo({
- url:"/pages/index/index/index"
+ url: "/pages/index/index/index"
})
- }else{
+ } else {
this.getuser_addr(function (ie) {
//地址切换要把包邮券清空
if (!th.data.user_addr || !ie || th.data.user_addr.address_id != ie.address_id) {
@@ -178,16 +178,16 @@ Page({
th.data.prom_goods_map = {};
th.data.is_summit_ing = 0;
//更换地址回来要重新调用计算价钱的接口
- if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id){
- th.setData({user_addr: ie});
- th.setData({add_back: 1});
- th.calculatePrice2();
+ if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
+ th.setData({ user_addr: ie });
+ th.setData({ add_back: 1 });
+ th.calculatePrice2();
} else {
- th.setData({user_addr: ie});
+ th.setData({ user_addr: ie });
}
var going = 0;
});
-
+
var is_card_back = getApp().globalData.is_card_back;
//--更新默认地址--,看一下是不是跳到地址页面,同时也不是购买等级卡返回的,这里很重要,否则会重新更新收货物流公司
if (!getApp().globalData.is_cart_old && !is_card_back && !getApp().globalData.plus_buy_back) {
@@ -210,7 +210,7 @@ Page({
sales_rules: ee.sales_rules,
rank_switch: json_d.rank_switch,
is_default_logistics: is_default_logistics,
- sys_switch:json_d,
+ sys_switch: json_d,
});
var rank_switch = json_d.rank_switch;
@@ -223,34 +223,34 @@ Page({
//-- 获取所有的等级卡, --
getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid,
{}).then(res => {
- if (res.data.code == 0) {
- var plusCard = res.data.data;
- //-- 循环判断,拿到最贵的那张卡 --
- for (var ih in plusCard) {
- if (plusCard[ih].IsStopBuy == true) {
- continue;
- }
- if (max_price < 0) {
- max_price = plusCard[ih].CardFee;
- name = 'card' + plusCard[ih]['CorrPrice'];
- show_card = plusCard[ih];
- } else {
- if (max_price < plusCard[ih].CardFee) {
+ if (res.data.code == 0) {
+ var plusCard = res.data.data;
+ //-- 循环判断,拿到最贵的那张卡 --
+ for (var ih in plusCard) {
+ if (plusCard[ih].IsStopBuy == true) {
+ continue;
+ }
+ if (max_price < 0) {
max_price = plusCard[ih].CardFee;
name = 'card' + plusCard[ih]['CorrPrice'];
show_card = plusCard[ih];
+ } else {
+ if (max_price < plusCard[ih].CardFee) {
+ max_price = plusCard[ih].CardFee;
+ name = 'card' + plusCard[ih]['CorrPrice'];
+ show_card = plusCard[ih];
+ }
}
}
- }
- if (show_card) {
- name = name.toLowerCase();
- th.setData({card_name: name, show_card: show_card})
+ if (show_card) {
+ name = name.toLowerCase();
+ th.setData({ card_name: name, show_card: show_card })
+ }
}
- }
- //-----先获取物流,再获取用户信息,再展示页面-----
- th.get_wuliu(th.get_info(th.show_page));
- })
+ //-----先获取物流,再获取用户信息,再展示页面-----
+ th.get_wuliu(th.get_info(th.show_page));
+ })
} else {
//-----先获取物流,再获取用户信息,再展示页面-----
th.get_wuliu(th.get_info(th.show_page));
@@ -270,10 +270,10 @@ Page({
if (th.data.is_default_logistics) {
//如果第一个不是开启默认,说明要让用户自己选
if (!e[0].is_default) {
- th.setData({is_default_logistics: 0});
+ th.setData({ is_default_logistics: 0 });
}
}
- th.setData({wu_arr: e})
+ th.setData({ wu_arr: e })
typeof func == "function" && func();
})
},
@@ -287,9 +287,9 @@ Page({
getuser_addr: function (func) {
var th = this;
a.get("/api/weshop/useraddress/page", {
- data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()},
+ data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random() },
success: function (su) {
-
+
var item = null;
if (su.data.code == 0 && su.data.data && su.data.data.pageData) {
var user_addr = su.data.data.pageData;
@@ -308,7 +308,7 @@ Page({
}
if (item == undefined) item = null;
- if (!item) th.setData({user_addr: null}); //地址为空的时候,要清空,因为返回的时候,有缓存
+ if (!item) th.setData({ user_addr: null }); //地址为空的时候,要清空,因为返回的时候,有缓存
func(item);
}
@@ -336,7 +336,7 @@ Page({
});
}
//获取立即购买的商品信息
- th.get_buy_goods(th.data.order_id,th.data.order_sn);
+ th.get_buy_goods(th.data.order_id, th.data.order_sn);
});
//获取提现金额
getApp().request.get("/api/weshop/withdrawals/summoney", {
@@ -360,30 +360,30 @@ Page({
},
//-----获取商品------
- async get_buy_goods(ord,o_sn) {
+ async get_buy_goods(ord, o_sn) {
var order = null,
order_goods = null,
goods = null,
pickup = null,
distr_type = 0,
exp_type = 0,
- presell=null, //订单从表
- pre_arr=null, //订单内容
- act=null, //订单内容
+ presell = null, //订单从表
+ pre_arr = null, //订单内容
+ act = null, //订单内容
th = this;
- if(o_sn){
+ if (o_sn) {
//获取order信息根据订单编号order_sn
await getApp().request.promiseGet("/api/weshop/order/page", {
- data: { store_id: os.stoid, order_sn: o_sn,}
+ data: { store_id: os.stoid, order_sn: o_sn, }
}).then(res => {
order = res.data.data.pageData[0];
})
- ord=order.order_id;
- }else{
+ ord = order.order_id;
+ } else {
//---获取订单---
await getApp().request.promiseGet("/api/weshop/order/get/" + oo.stoid + "/" + ord, {}).then(res => {
order = res.data.data;
@@ -399,94 +399,94 @@ Page({
order_goods = res.data.data.pageData[0];
});
- await getApp().request.promiseGet("/api/weshop/order/orderPresell/get/"+oo.stoid+"/"+order.order_id, {}).then(res => {
+ await getApp().request.promiseGet("/api/weshop/order/orderPresell/get/" + oo.stoid + "/" + order.order_id, {}).then(res => {
presell = res.data.data;
});
//等待定金
- if(order.order_status<2 && presell.deposit_pay_time<=0 ){
- th.setData({wait_dj:1})
+ if (order.order_status < 2 && presell.deposit_pay_time <= 0) {
+ th.setData({ wait_dj: 1 })
}
//等待尾款
- if(order.order_status<2 && presell.deposit_pay_time>0 && presell.tail_pay_state==0 && presell.presell_type!=1){
- th.setData({wait_wk:1})
- wx.setNavigationBarTitle({title: "支付尾款",})
+ if (order.order_status < 2 && presell.deposit_pay_time > 0 && presell.tail_pay_state == 0 && presell.presell_type != 1) {
+ th.setData({ wait_wk: 1 })
+ wx.setNavigationBarTitle({ title: "支付尾款", })
}
//等待发货
- if(order.pay_status==1 && order.shipping_status==0){
- th.setData({wait_fh:1})
+ if (order.pay_status == 1 && order.shipping_status == 0) {
+ th.setData({ wait_fh: 1 })
}
- if(order.pay_status==1 && order.shipping_status==1 && order.order_status<2){
- th.setData({wait_sh:1})
+ if (order.pay_status == 1 && order.shipping_status == 1 && order.order_status < 2) {
+ th.setData({ wait_sh: 1 })
}
//------获取预售主表----------
- await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell.prom_id, {}).then(res => {
+ await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + presell.prom_id, {}).then(res => {
if (res.data.code == 0 && res.data.data) {
- act=res.data.data;
+ act = res.data.data;
th.setData({
- act: res.data.data,
+ act: res.data.data,
});
}
})
//-- 判断一下会员的身份 --
- if(order.pay_status==0){
- var pre_data = { store_id: os.stoid, presell_id: presell.prom_id,timetype: 12, goods_id: order_goods.goods_id };
+ if (order.pay_status == 0) {
+ var pre_data = { store_id: os.stoid, presell_id: presell.prom_id, timetype: 12, goods_id: order_goods.goods_id };
pre_data.user_id = order.user_id;
- var isok=1;
+ var isok = 1;
await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
data: pre_data,
}).then(e => {
if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
pre_arr = e.data.data.pageData[0];
- }else{
- isok=0;
+ } else {
+ isok = 0;
}
})
- if(!isok){
+ if (!isok) {
getApp().confirmBox("会员身份不符合");
return false;
}
- if(th.data.wait_dj){
- if(act.is_end) {
+ if (th.data.wait_dj) {
+ if (act.is_end) {
getApp().confirmBox("活动已经结束");
return false;
}
- if(!act.isuse) {
+ if (!act.isuse) {
getApp().confirmBox("活动未启用");
return false;
}
- if(th.data.act.end_time{
+ else {
+ await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/list", {
+ data: { store_id: os.stoid, goods_id: order_goods.goods_id, presell_id: order_goods.prom_id }
+ }).then(re => {
if (re.data.code == 0 && re.data.data && re.data.data.length > 0) {
pre_arr = re.data.data[0];
}
})
- if(!pre_arr){
+ if (!pre_arr) {
getApp().confirmBox("未找到商品");
return false;
}
@@ -498,28 +498,29 @@ Page({
order.market_price = goods.market_price;
order.show_img = oo.imghost + goods.original_img;
});
-
-
- var g_url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+order_goods.goods_id+"&pre_id="+pre_arr.id;
- if(act.is_end || th.data.act.end_time{
- var ttd=rss;
+ await getApp().request.promiseGet("/api/weshop/order/returngoods/page", {
+ data: {
+ order_id: order.order_id, store_id: oo.stoid,
+ user_id: order.user_id, pageSize: 200
+ }
+ }).then(rss => {
+ var ttd = rss;
//----没有相关的退款记录----
- if (ttd.data.data.total==0){
+ if (ttd.data.data.total == 0) {
order['is_all_return'] = 0;
- }else{
+ } else {
var eea = ttd.data.data.pageData[0];
//1.退款正在进行中,
//2.退款被拒绝就要显示可以退款
//3.退款已经完成
- order['is_all_return']=1;
+ order['is_all_return'] = 1;
order['is_all_return_status'] = ttd.data.data.pageData[0].status;
if (order['order_status'] == 1 && order['pay_status'] == 1) {
switch (eea.status) {
case 0:
case 1:
- order.order_status_detail="退款中";
+ order.order_status_detail = "退款中";
order['return_btn'] = 2; break;
case 2:
- order.order_status_detail="退款完成";
+ order.order_status_detail = "退款完成";
order['return_btn'] = 4; break;
case 3:
order['return_btn'] = 3; break;
@@ -563,8 +566,8 @@ Page({
}
})
- var price=presell.presell_price;
- if(!goods) return false;
+ var price = presell.presell_price;
+ if (!goods) return false;
//--判断物流--
if (goods.distr_type)
distr_type = goods.distr_type;
@@ -587,50 +590,50 @@ Page({
}
//等待发货的时候
- if(th.data.wait_fh){
- var send_time=th.data.act.delivery_date;
- if(th.data.act.delivery_type==2){
- send_time=ut.gettimestamp()+th.data.act.delivery_daynum*3600*24;
- }
+ if (th.data.wait_fh) {
+ var send_time = th.data.act.delivery_date;
+ if (th.data.act.delivery_type == 2) {
+ send_time = ut.gettimestamp() + th.data.act.delivery_daynum * 3600 * 24;
+ }
}
order.order_goods = order_goods;
- var tail_pay=pre_arr.presell_price*order_goods.goods_num-presell.presell_deposit;
+ var tail_pay = pre_arr.presell_price * order_goods.goods_num - presell.presell_deposit;
this.setData({
order: order,
distr_type: distr_type,
pickup: pickup,
exp_type: exp_type,
goods: goods,
- presell:presell,
- pre_arr:pre_arr,
- show_submit:1,
- userInfo:getApp().globalData.userInfo,
- tail_pay:tail_pay,
- order_goods:order_goods,
- all_price:pre_arr.presell_price*order_goods.goods_num,
- pickup_id:pickup.pickup_id,
- send_time:send_time,
- g_url:g_url
+ presell: presell,
+ pre_arr: pre_arr,
+ show_submit: 1,
+ userInfo: getApp().globalData.userInfo,
+ tail_pay: tail_pay,
+ order_goods: order_goods,
+ all_price: pre_arr.presell_price * order_goods.goods_num,
+ pickup_id: pickup.pickup_id,
+ send_time: send_time,
+ g_url: g_url
});
th.get_diff();
//统一进行计算金额
th.calculatePrice2();
//如果可以
- if(th.data.act.is_usecoupon){
+ if (th.data.act.is_usecoupon) {
th.get_buy_now_quan();
}
},
- async calculatePrice2(){
- var th=this;
- if(!this.data.pre_arr) return false;
+ async calculatePrice2() {
+ var th = this;
+ if (!this.data.pre_arr) return false;
//--计算物流--
if (this.data.exp_type == 0) {
this.calculate_wuliu();
} else {
- var allpice =this.data.pre_arr.presell_price*this.data.order_goods.goods_num;
+ var allpice = this.data.pre_arr.presell_price * this.data.order_goods.goods_num;
allpice = allpice.toFixed(2);
//--看一下有没有订单优惠--
var o_condition = parseFloat(allpice);
@@ -654,37 +657,37 @@ Page({
quan_price = res.data.data[0].WareCashSum;
}
})
- }else{
- th.setData({quan_price:0});
- if(th.data.using_quan && th.data.using_quan[bn_pick] && th.data.using_quan[bn_pick].isby==1){
- var txt="using_quan["+bn_pick+"]";
- th.setData({[txt]:{}});
+ } else {
+ th.setData({ quan_price: 0 });
+ if (th.data.using_quan && th.data.using_quan[bn_pick] && th.data.using_quan[bn_pick].isby == 1) {
+ var txt = "using_quan[" + bn_pick + "]";
+ th.setData({ [txt]: {} });
}
}
- if(quan_price>0){
- if (quan_price < th.data.tail_pay) th.setData({quan_price: quan_price})
- else {
- th.setData({quan_price: th.data.tail_pay})
- }
- o_condition=o_condition-quan_price;
+ if (quan_price > 0) {
+ if (quan_price < th.data.tail_pay) th.setData({ quan_price: quan_price })
+ else {
+ th.setData({ quan_price: th.data.tail_pay })
+ }
+ o_condition = o_condition - quan_price;
- }else{
- th.setData({quan_price: 0})
+ } else {
+ th.setData({ quan_price: 0 })
}
- if(o_condition<0) o_condition=0;
+ if (o_condition < 0) o_condition = 0;
//如果同意参与订单优惠
if (o_condition > 0 && this.data.pre_arr.is_useorderyh) {
th.check_is_order_prom(o_condition, function (ord_price) {
- var bn_pick=th.data.pickup.pickup_id
+ var bn_pick = th.data.pickup.pickup_id
var order_prom_amount = 0;
var order_prom_id = 0;
- var o_condition1=0;
+ var o_condition1 = 0;
if (th.data.order_prom[bn_pick]) {
var ord_prom = th.data.order_prom[bn_pick];
- if(!ord_prom.is_xz_yh || quan_price<=0) {
+ if (!ord_prom.is_xz_yh || quan_price <= 0) {
order_prom_id = ord_prom['id'];
switch (ord_prom['type']) {
case 0:
@@ -703,19 +706,19 @@ Page({
var order_prom_txt1 = "order_prom_id";
var order_prom_txt2 = "order_prom_amount";
if (order_prom_id > 0) {
- th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount})
- }else{
- o_condition1=ord_price;
- th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0})
+ th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount })
+ } else {
+ o_condition1 = ord_price;
+ th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 })
}
-
- o_condition1=parseFloat(o_condition1)-parseFloat(th.data.presell.presell_deposit);
- if(o_condition1<0) o_condition1=0;
- th.setData({ exp_price: 0, order_m: o_condition1 })
+
+ o_condition1 = parseFloat(o_condition1) - parseFloat(th.data.presell.presell_deposit);
+ if (o_condition1 < 0) o_condition1 = 0;
+ th.setData({ exp_price: 0, order_m: o_condition1 })
})
- }else{
- o_condition=parseFloat(o_condition)-parseFloat(th.data.presell.presell_deposit);
- if(o_condition<0) o_condition=0;
+ } else {
+ o_condition = parseFloat(o_condition) - parseFloat(th.data.presell.presell_deposit);
+ if (o_condition < 0) o_condition = 0;
th.setData({ exp_price: 0, order_m: o_condition })
}
}
@@ -725,14 +728,14 @@ Page({
checkAddressList: function () {
var t = this;
return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({
- title: "请先填写或选择收货地址~",
- success: function (a) {
- a.confirm ? t.enterAddressPage() : wx.navigateBack();
- },
- fail: function () {
- wx.navigateBack();
- }
- }), !1);
+ title: "请先填写或选择收货地址~",
+ success: function (a) {
+ a.confirm ? t.enterAddressPage() : wx.navigateBack();
+ },
+ fail: function () {
+ wx.navigateBack();
+ }
+ }), !1);
},
showInvoice: function () {
this.setData({
@@ -752,7 +755,7 @@ Page({
keyUpChangeNum: function (t) {
this.setData({
maxWord: t.detail.value.length,
- user_note:t.detail.value
+ user_note: t.detail.value
});
},
@@ -781,7 +784,7 @@ Page({
}
}
var set_txt = "cartlist[" + iter + "].can_num";
- th.setData({[set_txt]: num});
+ th.setData({ [set_txt]: num });
}
},
useCoupon: function () {
@@ -798,7 +801,7 @@ Page({
});
},
enterAddressPage: function () {
- if(!this.data.wait_wk) return false;
+ if (!this.data.wait_wk) return false;
getApp().globalData.is_cart_old = 1;
this.data.isget_by_quan = {};
@@ -811,9 +814,9 @@ Page({
setexptype: function (t) {
var th = this;
var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code;
- th.setData({bn_exp_type: ty});
+ th.setData({ bn_exp_type: ty });
if (ty == 0) {
- th.setData({is_all_zt: 0});
+ th.setData({ is_all_zt: 0 });
}
//当物流为空的时候。
@@ -826,7 +829,7 @@ Page({
if (ty == 1) {
th.data.isget_by_quan = {};
if (th.data.using_quan[bn_pick] && th.data.using_quan[bn_pick].isby == 1) {
- th.setData({using_quan: {}});
+ th.setData({ using_quan: {} });
}
}
@@ -836,7 +839,7 @@ Page({
if (wu_arr != null && wu_arr != "") {
for (var i = 0; i < wu_arr.length; i++) {
if (wu_arr[i].shipping_code == def_exp_code) {
- th.setData({index: i});
+ th.setData({ index: i });
}
}
}
@@ -848,16 +851,16 @@ Page({
//--------立即购买时,使用余额--------
set_bn_useyuer: function () {
var th = this;
- th.setData({bn_use_money: !th.data.bn_use_money});
+ th.setData({ bn_use_money: !th.data.bn_use_money });
th.calculatePrice2();
},
- //-------------------计算物流---------------
- calculatewuliu: function (code, o_shipping_price, goods_weight,
- goods_piece, user_addr, freight_free, o_price, rs) {
+ //-----------------计算物流-------------
+ calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight,
+ goods_piece, user_addr, freight_free, o_price, rs, pickid) {
var price = 0, th = this;
price += parseFloat(o_shipping_price);
//如果是包邮
- if (freight_free > 0 && o_price >= freight_free) {
+ if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) {
return 0;
}
if (user_addr == null) {
@@ -883,6 +886,16 @@ Page({
fw_price = fw_price + n * parseFloat(item['add_money']);
}
}
+ //------超出重量----------
+ if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) {
+ fw_price = parseFloat(item['money']);
+ var out_of_weight = Math.abs(out_of_weight);
+ if (out_of_weight > item['first_weight']) {
+ var fw = out_of_weight - item['first_weight'];
+ var n = Math.ceil(fw / item['second_weight'])
+ fw_price = fw_price + n * parseFloat(item['add_money']);
+ }
+ }
//------按件数----------
if (goods_piece > 0 && item['piecemoney']) {
fp_price = parseFloat(item['piecemoney']);
@@ -920,7 +933,7 @@ Page({
//----------立即购买,选择物流-------------
bindPickerChange: function (e) {
var ind = e.detail.value
- this.setData({index: ind});
+ this.setData({ index: ind });
this.calculatePrice2();
},
/*----券的所有操作----*/
@@ -933,7 +946,7 @@ Page({
if (bn == 1) {
- th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1});
+ th.setData({ open_quan: 1, selected_quan_pick: pickid, disabled: 1 });
} else {
//---多单打开券的时候,就要判断券在其他门店是否有使用---
var quanlist = th.data.cartlist[cindx].quan_list;
@@ -959,9 +972,9 @@ Page({
else
get_by_quan_list_cart[i].show_red = 0;
}
- th.setData({by_quan_list_cart: get_by_quan_list_cart});
+ th.setData({ by_quan_list_cart: get_by_quan_list_cart });
} else {
- th.setData({by_quan_list_cart: null});
+ th.setData({ by_quan_list_cart: null });
}
th.setData({
@@ -976,7 +989,7 @@ Page({
},
close_coupon: function (e) {
var th = this;
- th.setData({open_quan: 0, disabled: 0});
+ th.setData({ open_quan: 0, disabled: 0 });
},
//---判断券时候在已经选择的列表中---
@@ -1006,14 +1019,14 @@ Page({
for (var i in quanlist) {
quanlist[i].show_red = 0;
}
- this.setData({selected_quan_list: quanlist});
+ this.setData({ selected_quan_list: quanlist });
var by_quanlist = this.data.get_by_quan_list;
if (by_quanlist) {
//---所有的券的显示红色选择都清理一遍---
for (var inb in by_quanlist) {
by_quanlist[inb].show_red = 0;
}
- this.setData({get_by_quan_list: by_quanlist});
+ this.setData({ get_by_quan_list: by_quanlist });
}
var by_cart_list = this.data.by_quan_list_cart;
@@ -1022,7 +1035,7 @@ Page({
for (var inc in by_cart_list) {
by_cart_list[inc].show_red = 0;
}
- this.setData({by_quan_list_cart: by_cart_list});
+ this.setData({ by_quan_list_cart: by_cart_list });
}
var using_quan = this.data.using_quan;
@@ -1033,9 +1046,9 @@ Page({
using_quan[pickid].is_nouse_red = 1;
}
else {
- using_quan[pickid] = {is_nouse_red: 1};
+ using_quan[pickid] = { is_nouse_red: 1 };
}
- this.setData({using_quan: using_quan, is_coupon: 2222});
+ this.setData({ using_quan: using_quan, is_coupon: 2222 });
return;
}
@@ -1052,9 +1065,9 @@ Page({
using_quan[pickid].is_nouse_red = 0;
}
else {
- using_quan[pickid] = {is_nouse_red: 0};
+ using_quan[pickid] = { is_nouse_red: 0 };
}
- this.setData({using_quan: using_quan});
+ this.setData({ using_quan: using_quan });
},
/*----- 点击选择包邮券 -----*/
@@ -1067,7 +1080,7 @@ Page({
for (var ind in by_quanlist) {
by_quanlist[ind].show_red = 0;
}
- this.setData({get_by_quan_list: by_quanlist});
+ this.setData({ get_by_quan_list: by_quanlist });
}
//--购物车过来的包邮券--
@@ -1077,7 +1090,7 @@ Page({
for (var ind in by_cart_list) {
by_cart_list[ind].show_red = 0;
}
- this.setData({by_quan_list_cart: by_cart_list});
+ this.setData({ by_quan_list_cart: by_cart_list });
}
//普通券
var quanlist = this.data.selected_quan_list;
@@ -1086,7 +1099,7 @@ Page({
for (var ind in quanlist) {
quanlist[ind].show_red = 0;
}
- this.setData({selected_quan_list: quanlist});
+ this.setData({ selected_quan_list: quanlist });
}
var th = this;
@@ -1097,9 +1110,9 @@ Page({
using_quan[th.data.selected_quan_pick].is_nouse_red = 1;
}
else {
- using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1};
+ using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 };
}
- this.setData({using_quan: using_quan, is_coupon: 2222});
+ this.setData({ using_quan: using_quan, is_coupon: 2222 });
return;
}
@@ -1110,20 +1123,20 @@ Page({
var txt1 = "";
var quan_item = null;
- quan_item = this.data.get_by_quan_list[ind];
- txt = "get_by_quan_list[" + ind + "].show_red";
- var obj = {};
- obj[txt] = 1;
- this.setData(obj);
+ quan_item = this.data.get_by_quan_list[ind];
+ txt = "get_by_quan_list[" + ind + "].show_red";
+ var obj = {};
+ obj[txt] = 1;
+ this.setData(obj);
if (using_quan[th.data.selected_quan_pick]) {
using_quan[th.data.selected_quan_pick].is_nouse_red = 0;
}
else {
- using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0};
+ using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 };
}
- this.setData({using_quan: using_quan});
+ this.setData({ using_quan: using_quan });
},
//--确认使用券---
confirm_quan: function () {
@@ -1180,10 +1193,10 @@ Page({
//选择了的券,看是不是点击了不使用券,点击了不使用优惠券
if (using_quan[pickid]) {
if (using_quan[pickid].is_nouse_red == 1) {
- using_quan[pickid] = {is_nouse_red: 1};
+ using_quan[pickid] = { is_nouse_red: 1 };
th.calculatePrice2();
- th.setData({open_quan: 0});
- th.setData({using_quan: using_quan});
+ th.setData({ open_quan: 0 });
+ th.setData({ using_quan: using_quan });
}
}
@@ -1204,12 +1217,12 @@ Page({
};
using_quan[pickid].isby = 1;
} else {
- using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0};
+ using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 };
using_quan[pickid].isby = 0;
}
- this.setData({using_quan: using_quan});
+ this.setData({ using_quan: using_quan });
th.calculatePrice2();
- th.setData({open_quan: 0});
+ th.setData({ open_quan: 0 });
},
cart_set_err: function (e) {
@@ -1246,7 +1259,7 @@ Page({
var wu_arr_txt = e.currentTarget.dataset.txt;
var w_sele_index = e.currentTarget.dataset.w_sele_index;
var is_express = null;
- var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1};
+ var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 };
//--如果是多个门店的时候--
if (w_sele_index != undefined) {
@@ -1257,21 +1270,21 @@ Page({
},
// 关闭物流的弹窗
close_express: function () {
- this.setData({open_express: 0, disabled: 0});
+ this.setData({ open_express: 0, disabled: 0 });
},
// 选择物流
click_express_name: function (e) {
var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
var index = e.currentTarget.dataset.idxe;
- var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0};
+ var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 };
ob[this.data.wu_arr_txt] = index;
this.setData(ob);
},
//点击确定物流
determine_expres: function (e) {
- this.setData({open_express: 0});
- this.calculatePrice2();
+ this.setData({ open_express: 0 });
+ this.calculatePrice2();
},
//点击打开优惠券使用说明
@@ -1287,7 +1300,7 @@ Page({
obj[txt] = is_open;
this.setData(obj);
- this.setData({disabled: 1})
+ this.setData({ disabled: 1 })
},
clik_coupons2: function (e) {
@@ -1302,7 +1315,7 @@ Page({
obj[txt] = is_open;
this.setData(obj);
- this.setData({disabled: 1})
+ this.setData({ disabled: 1 })
},
@@ -1311,11 +1324,11 @@ Page({
var th = this;
var is_shipping_code = this.data.is_shipping_code
getApp().request.put("/api/weshop/users/update", {
- data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code},
+ data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code },
success: function (rse) {
if (rse.data.code == 0) {
getApp().globalData.userInfo.def_exp_code = is_shipping_code;
- th.setData({open_express: 0});
+ th.setData({ open_express: 0 });
//----计算此时购物车的价格----
th.calculatePrice2();
@@ -1325,7 +1338,7 @@ Page({
},
//更新下默认,在onshow里面
- update_code(){
+ update_code() {
var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
//--定时器,判断wu_arr不未空--
var uii = setInterval(function () {
@@ -1339,7 +1352,7 @@ Page({
}
//--如果是立即购买--
if (th.data.is_b_now == 1) {
- th.setData({index: m_wind, is_express: m_wind});
+ th.setData({ index: m_wind, is_express: m_wind });
} else {
var ui = setInterval(function () {
if (th.data.cartlist) {
@@ -1347,7 +1360,7 @@ Page({
for (var i in c_arr) {
c_arr[i].wind = m_wind;
}
- th.setData({cartlist: c_arr, is_express: m_wind})
+ th.setData({ cartlist: c_arr, is_express: m_wind })
clearInterval(ui);
}
}, 500)
@@ -1448,10 +1461,10 @@ Page({
if (th.data.is_b_now) {
if (arr && arr.length > 0) {
var quanlist = arr[0].quan_list;
- th.setData({selected_quan_list: quanlist, cartlist: arr})
+ th.setData({ selected_quan_list: quanlist, cartlist: arr })
}
} else {
- th.setData({cartlist: arr})
+ th.setData({ cartlist: arr })
th.set_can_num();
}
},
@@ -1459,14 +1472,14 @@ Page({
//------ 获取立即购买的购物车的劵 --------
get_buy_now_quan: function () {
var quanlist = null, th = this, frozenQuan = null;
- var allprice =this.data.pre_arr.presell_price*this.data.order_goods.goods_num;
+ var allprice = this.data.pre_arr.presell_price * this.data.order_goods.goods_num;
th.data.ckeck_quan_price = allprice;
//--如果商家后台没有限制使用优惠券,同时商品的优惠活动没有限制使用优惠券--
if (th.data.is_close_quan != 1) {
var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
var url = "/api/weshop/couponList/getUseCouponList";
- app.request.promiseGet(url0, {1: 1}).then(res => {
+ app.request.promiseGet(url0, { 1: 1 }).then(res => {
if (res.data.code == 0) {
frozenQuan = res.data.data;
th.data.frozenQuan = frozenQuan;
@@ -1484,7 +1497,7 @@ Page({
quanlist = res.data.data.pageData;
if (quanlist) {
quanlist = th.check_is_frozenQuan(quanlist, frozenQuan);
- th.setData({selected_quan_list: quanlist})
+ th.setData({ selected_quan_list: quanlist })
}
}
}
@@ -1512,7 +1525,7 @@ Page({
if (!goods_id) goods_id = this.data.bn_goods.goods_id;
for (var i in arr) {
var item = arr[i];
- if (goods_id == item) return 0;
+ if (goods_id == item) return 0;
}
return 1;
},
@@ -1534,14 +1547,14 @@ Page({
pick = this.data.pickup.pickup_id;
//---获取订单优惠---
getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
- data: {store_id: os.stoid, orderAmount: condition}
+ data: { store_id: os.stoid, orderAmount: condition }
}).then(res => {
if (res.data.code == 0) {
var data = res.data.data;
th.data.order_prom[pick] = data;
- }else{
- th.data.order_prom[pick] = null;
- }
+ } else {
+ th.data.order_prom[pick] = null;
+ }
func(condition);
})
},
@@ -1558,7 +1571,7 @@ Page({
var ob = map[pickid][item.prom_id];
ob.price += item.goods_price * item.goods_num;
ob.goods_num += item.goods_num;
- ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
+ ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num });
} else {
var prom = null;
@@ -1574,7 +1587,7 @@ Page({
ob.is_bz = prom.is_bz;
ob.is_xz_yh = prom.is_xz_yh;
ob.goods = new Array();
- ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
+ ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num });
map[pickid][item.prom_id] = ob;
}
} else {
@@ -1591,7 +1604,7 @@ Page({
ob.is_bz = prom.is_bz;
ob.is_xz_yh = prom.is_xz_yh;
ob.goods = new Array();
- ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
+ ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num });
var obj = {};
obj[item.prom_id] = ob;
@@ -1635,6 +1648,7 @@ Page({
if (no_by_data && no_by_data.region_list) {
if (th.check_by_area(no_by_data.region_list)) {
gift_freight_free = 0;
+ out_of_weight = 0;
th.data.is_no_by[bn_pick] = 1;
}
}
@@ -1642,12 +1656,14 @@ Page({
if (no_by_data && no_by_data.goods_list && gift_freight_free) {
if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) {
gift_freight_free = 0;
+ out_of_weight = 0;
+ th.data.is_no_by[bn_pick] = 1;
}
}
var t_shipping_price =
- this.calculatewuliu(code, gift_shipping_price, goods_weight,
- goods_piece, user_addr, gift_freight_free, allpice, rs);
+ this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight,
+ goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick);
return t_shipping_price;
},
@@ -1707,12 +1723,15 @@ Page({
goods_weight = -1,
goods_piece = -1,
good = th.data.goods,
- quan_price=0,
- exp_price=0;
+ quan_price = 0,
+ exp_price = 0;
var quan_no = null;
- var bn_pick=th.data.pickup.pickup_id;
- var allpice =th.data.all_price;
+ var bn_pick = th.data.pickup.pickup_id;
+ var allpice = th.data.all_price;
+ var out_of_weight = null; //超出多少重量
+ var freight_free = ee.freight_free; //全场满多少包邮
+ var weight_free = ee.weight_free; //多少kg内包邮
if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
quan_no = th.data.using_quan[bn_pick].coupon_no;
@@ -1734,19 +1753,19 @@ Page({
})
if (quan_price > 0) {
- if (quan_price < th.data.tail_pay) th.setData({quan_price: quan_price})
+ if (quan_price < th.data.tail_pay) th.setData({ quan_price: quan_price })
else {
- th.setData({quan_price: th.data.tail_pay})
+ th.setData({ quan_price: th.data.tail_pay })
quan_price = th.data.tail_pay;
}
} else {
- th.setData({quan_price: 0})
+ th.setData({ quan_price: 0 })
}
- }else{
- th.setData({quan_price: 0})
+ } else {
+ th.setData({ quan_price: 0 })
}
- }else{
- th.setData({quan_price: 0})
+ } else {
+ th.setData({ quan_price: 0 })
}
//-----------当地址不为空,且是物流时,计算物流费用----------
@@ -1775,15 +1794,15 @@ Page({
arr.push(item);
}
if (arr) {
- th.setData({get_by_quan_list: arr});
+ th.setData({ get_by_quan_list: arr });
}
th.data.isget_by_quan[bn_pick] = 1;
}
})
}
if (quan_no && th.data.using_quan[bn_pick].isby == 1) {
- exp_price=0;
- }else{
+ exp_price = 0;
+ } else {
switch (good['exp_sum_type']) {
case 1:
//统一运费
@@ -1793,6 +1812,9 @@ Page({
if (goods_weight < 0) goods_weight = 0;
//累积商品重量 每种商品的重量 * 数量
goods_weight += good['weight'] * th.data.order.order_goods['goods_num'];
+ if (weight_free > 0) {
+ out_of_weight = (weight_free * 1000) - goods_weight;
+ }
break;
case 3:
if (goods_piece < 0) goods_piece = 0;
@@ -1802,35 +1824,34 @@ Page({
}
var code = th.data.wu_arr[th.data.index].code;
- var freight_free = ee.freight_free; //全场满多少包邮
var shipping_price =
- th.calculatewuliu(code, o_shipping_price, goods_weight,
+ th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
goods_piece, th.data.user_addr, freight_free, allpice, rs);
exp_price = parseFloat(shipping_price).toFixed(2);
}
- th.wuliu_next(allpice,quan_price,exp_price);
+ th.wuliu_next(allpice, quan_price, exp_price);
} else {
- th.wuliu_next(allpice,quan_price,exp_price);
+ th.wuliu_next(allpice, quan_price, exp_price);
}
});
});
},
//相同的东西统一在一起
- wuliu_next( allpice,quan_price,exp_price){
- var th=this;
- var o_condition =parseFloat(allpice)-parseFloat(quan_price);
- if(o_condition<0) o_condition=0;
+ wuliu_next(allpice, quan_price, exp_price) {
+ var th = this;
+ var o_condition = parseFloat(allpice) - parseFloat(quan_price);
+ if (o_condition < 0) o_condition = 0;
//如果同意参与订单优惠
if (o_condition > 0 && this.data.pre_arr.is_useorderyh) {
th.check_is_order_prom(o_condition, function (ord_price) {
- var bn_pick=th.data.pickup.pickup_id
+ var bn_pick = th.data.pickup.pickup_id
var order_prom_amount = 0;
var order_prom_id = 0;
- var order_m=0;
+ var order_m = 0;
if (th.data.order_prom[bn_pick]) {
var ord_prom = th.data.order_prom[bn_pick];
//么有使用券,或者活动没有限制使用优惠券
- if(quan_price<=0 || !ord_prom.is_xz_yh) {
+ if (quan_price <= 0 || !ord_prom.is_xz_yh) {
order_prom_id = ord_prom['id'];
switch (ord_prom['type']) {
case 0:
@@ -1850,37 +1871,37 @@ Page({
if (order_prom_id > 0) {
var order_prom_txt1 = "order_prom_id";
var order_prom_txt2 = "order_prom_amount";
- th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount})
- }else{
- var order_prom_txt1 = "order_prom_id";
- var order_prom_txt2 = "order_prom_amount";
- th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0})
- }
-
-
- ord_price=parseFloat(ord_price)-parseFloat(th.data.presell.presell_deposit);
- if(ord_price<0) ord_price=0;
- th.setData({ exp_price: exp_price, order_m: ord_price +parseFloat(exp_price) })
+ th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount })
+ } else {
+ var order_prom_txt1 = "order_prom_id";
+ var order_prom_txt2 = "order_prom_amount";
+ th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 })
+ }
+
+
+ ord_price = parseFloat(ord_price) - parseFloat(th.data.presell.presell_deposit);
+ if (ord_price < 0) ord_price = 0;
+ th.setData({ exp_price: exp_price, order_m: ord_price + parseFloat(exp_price) })
})
- }else{
-
- var o_condition1=parseFloat(o_condition)-parseFloat(th.data.presell.presell_deposit);
- if(o_condition1<0) o_condition1=0;
- th.setData({ exp_price: exp_price, order_m: parseFloat(o_condition1)+parseFloat(exp_price) })
+ } else {
+
+ var o_condition1 = parseFloat(o_condition) - parseFloat(th.data.presell.presell_deposit);
+ if (o_condition1 < 0) o_condition1 = 0;
+ th.setData({ exp_price: exp_price, order_m: parseFloat(o_condition1) + parseFloat(exp_price) })
}
},
//-- 获取时间差 --
- get_diff(){
+ get_diff() {
switch (this.data.act.presell_type) {
//部分定金
case 0:
if (this.data.act.pay_begindate > ut.gettimestamp()) {
- this.setData({no_start: 1})
+ this.setData({ no_start: 1 })
} else if (this.data.act.pay_enddate < ut.gettimestamp()) {
- this.setData({is_end: 1})
+ this.setData({ is_end: 1 })
} else {
var end_time = this.data.act.pay_enddate;
var e_str = ut.formatTime(end_time);
@@ -1891,15 +1912,15 @@ Page({
var hours = parseInt(difftime / 3600) - 24 * days; // 小时 60*60 总小时数-过去的小时数=现在的小时数
var minutes = parseInt(difftime % 3600 / 60); // 分钟 -(day*24) 以60秒为一整份 取余 剩下秒数 秒数/60 就是分钟数
var seconds = parseInt(difftime % 60); // 以60秒为一整份 取余 剩下秒数
- this.setData({days: days, hours: hours, minutes: minutes, seconds: seconds})
+ this.setData({ days: days, hours: hours, minutes: minutes, seconds: seconds })
}
break;
//全额付款
case 1:
if (this.data.act.start_time > ut.gettimestamp()) {
- this.setData({no_start: 1})
+ this.setData({ no_start: 1 })
} else if (this.data.act.end_time < ut.gettimestamp()) {
- this.setData({is_end: 1})
+ this.setData({ is_end: 1 })
} else {
var end_time = this.data.act.end_time;
var e_str = ut.formatTime(end_time);
@@ -1910,7 +1931,7 @@ Page({
var hours = parseInt(difftime / 3600) - 24 * days; // 小时 60*60 总小时数-过去的小时数=现在的小时数
var minutes = parseInt(difftime % 3600 / 60); // 分钟 -(day*24) 以60秒为一整份 取余 剩下秒数 秒数/60 就是分钟数
var seconds = parseInt(difftime % 60); // 以60秒为一整份 取余 剩下秒数
- this.setData({days: days, hours: hours, minutes: minutes, seconds: seconds})
+ this.setData({ days: days, hours: hours, minutes: minutes, seconds: seconds })
}
break;
@@ -1921,16 +1942,16 @@ Page({
//显示支付选择
show_pay: function () {
//不用钱直接支付
- if(this.data.order_m<=0){
+ if (this.data.order_m <= 0) {
this.to_pay_type(1);
- }else{
- this.setData({show_pay_type: 1});
+ } else {
+ this.setData({ show_pay_type: 1 });
}
},
//关闭支付
close_show_pay: function () {
- this.setData({show_pay_type: 0});
+ this.setData({ show_pay_type: 0 });
},
//--弹起支付框--
to_pay() {
@@ -1939,7 +1960,7 @@ Page({
return getApp().my_warnning("请选择收货地址", 0, this);
}
- this.setData({show_pay_type: 1});
+ this.setData({ show_pay_type: 1 });
},
//选择支付方式
@@ -1975,26 +1996,26 @@ Page({
dd.addressid = th.data.user_addr.address_id;
}
- if(th.data.order_prom_amount>0){
- var e={
- order_prom_id:th.data.order_prom_id,
- order_prom_amount:th.data.order_prom_amount,
+ if (th.data.order_prom_amount > 0) {
+ var e = {
+ order_prom_id: th.data.order_prom_id,
+ order_prom_amount: th.data.order_prom_amount,
}
- dd.order_prom_list=e;
+ dd.order_prom_list = e;
}
- var bn_pick=th.data.pickup_id;
- var quan_no='';
+ var bn_pick = th.data.pickup_id;
+ var quan_no = '';
if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
quan_no = th.data.using_quan[bn_pick].coupon_no;
- if(quan_no){
- dd.coupon_no=quan_no;
- if(th.data.quan_price) dd.coupon_price=th.data.quan_price;
+ if (quan_no) {
+ dd.coupon_no = quan_no;
+ if (th.data.quan_price) dd.coupon_price = th.data.quan_price;
}
- if(th.data.user_note){
- dd.user_note=th.data.user_note;
+ if (th.data.user_note) {
+ dd.user_note = th.data.user_note;
}
- dd.order_amount= parseFloat(th.data.order_m).toFixed(2);
+ dd.order_amount = parseFloat(th.data.order_m).toFixed(2);
console.log(JSON.stringify(dd));
wx.request({
@@ -2014,25 +2035,25 @@ Page({
function () {
//---用余额支付---
getApp().my_warnning("支付成功", 1, th);
- var send_time=th.data.pre_arr.delivery_date;
- if(th.data.pre_arr.delivery_type==2){
- send_time=th.data.pre_arr.delivery_daynum*3600;
- }
- th.setData({isclose: 0,'order.order_status':1,'order.pay_status':1,'wait_wk':0,'presell.tail_pay_state':1,'wait_fh':1,send_time:send_time});
-
+ var send_time = th.data.pre_arr.delivery_date;
+ if (th.data.pre_arr.delivery_type == 2) {
+ send_time = th.data.pre_arr.delivery_daynum * 3600;
+ }
+ th.setData({ isclose: 0, 'order.order_status': 1, 'order.pay_status': 1, 'wait_wk': 0, 'presell.tail_pay_state': 1, 'wait_fh': 1, send_time: send_time });
+
}, function () {
getApp().my_warnning("支付失败", 0, th);
})
} else {
if (t.data.code == 0) {
- var send_time=th.data.pre_arr.delivery_date;
- if(th.data.pre_arr.delivery_type==2){
- send_time=th.data.pre_arr.delivery_daynum*3600;
+ var send_time = th.data.pre_arr.delivery_date;
+ if (th.data.pre_arr.delivery_type == 2) {
+ send_time = th.data.pre_arr.delivery_daynum * 3600;
}
//---用余额支付---
- getApp().my_warnning("支付成功", 1, th);
- th.setData({isclose: 0,'order.order_status':1,'order.pay_status':1,'wait_wk':0,'presell.tail_pay_state':1,'wait_fh':1,send_time:send_time});
-
+ getApp().my_warnning("支付成功", 1, th);
+ th.setData({ isclose: 0, 'order.order_status': 1, 'order.pay_status': 1, 'wait_wk': 0, 'presell.tail_pay_state': 1, 'wait_fh': 1, send_time: send_time });
+
} else {
getApp().my_warnning(t.data.msg, 1, th);
}
@@ -2057,17 +2078,17 @@ Page({
},
fail: function (n) {
console.log(n), "requestPayment:fail" == n.errMsg ? getApp().my_warnning("支付失败", 0, th) : "requestPayment:fail cancel" == n.errMsg ? getApp().my_warnning("您已取消支付", 0, th) : getApp().my_warnning("支付失败:" + n.errMsg.substr("requestPayment:fail ".length), 0, th),
- "function" == typeof fail && fail();
+ "function" == typeof fail && fail();
}
});
},
- show_liuyan:function () {
- this.setData({sh_liuyan:true})
+ show_liuyan: function () {
+ this.setData({ sh_liuyan: true })
},
- close_liuyan(){
- this.setData({sh_liuyan:false})
+ close_liuyan() {
+ this.setData({ sh_liuyan: false })
},
//--------点击选择----------
@@ -2081,83 +2102,83 @@ Page({
//--------立即支付----------
async jumpToCart4(e) {
- var th=this;
- if(this.data.optionIsGoup)
+ var th = this;
+ if (this.data.optionIsGoup)
wx.navigateTo({
url: "/pages/team/team_confirm/team_confirm?orderSn=" + this.data.order.order_sn + "&orderPay=true"
})
- var order=this.data.order;
- var order_goods=this.data.order_goods;
- var user_id=getApp().globalData.userInfo.user_id;
-
- var wlist="";
-
- var good=order_goods;
- //线下取价功能已经关闭或者过期
- if(!th.data.is_open_offline && good.offline_cut>0){
- wx.showModal({
- title: '提示',
- content: '线下取价功能已经关闭或者过期!'
- });
- return false;
- }
- //如果不是小程序有的功能,直接提示要去3.0处理
- if(good.prom_type==2 ){
- wx.showModal({
- title: '提示',
- content: '小程序还未有该活动,请到3.0公众号支付'
- });
- return false;
- }
+ var order = this.data.order;
+ var order_goods = this.data.order_goods;
+ var user_id = getApp().globalData.userInfo.user_id;
+
+ var wlist = "";
+
+ var good = order_goods;
+ //线下取价功能已经关闭或者过期
+ if (!th.data.is_open_offline && good.offline_cut > 0) {
+ wx.showModal({
+ title: '提示',
+ content: '线下取价功能已经关闭或者过期!'
+ });
+ return false;
+ }
+ //如果不是小程序有的功能,直接提示要去3.0处理
+ if (good.prom_type == 2) {
+ wx.showModal({
+ title: '提示',
+ content: '小程序还未有该活动,请到3.0公众号支付'
+ });
+ return false;
+ }
- //要每件每件的商品进行检查,看有么有超出库存,超出限购
- var goodsbuynum=0,promgoodsbuynum=0,gg=null;
- //获取单品的现在的活动状态
- await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, {
- }).then(res=>{
- gg=res.data.data;
- })
- var limit = gg.viplimited;
- var store_count = gg.store_count;
- good.erpwareid=gg.erpwareid;
+ //要每件每件的商品进行检查,看有么有超出库存,超出限购
+ var goodsbuynum = 0, promgoodsbuynum = 0, gg = null;
+ //获取单品的现在的活动状态
+ await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, {
+ }).then(res => {
+ gg = res.data.data;
+ })
+ var limit = gg.viplimited;
+ var store_count = gg.store_count;
+ good.erpwareid = gg.erpwareid;
- //---要获得商品,该用户买了多少件,同步应用---
- await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
- data: {
- store_id: os.stoid,
- user_id: getApp().globalData.user_id,
- goods_id: good.goods_id,
- prom_type: good.prom_type,
- prom_id: good.prom_id
- },
- }).then(res => {
- var buy_num_data = res.data.data;
- if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
- goodsbuynum = buy_num_data.goodsbuynum;
- })
+ //---要获得商品,该用户买了多少件,同步应用---
+ await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
+ data: {
+ store_id: os.stoid,
+ user_id: getApp().globalData.user_id,
+ goods_id: good.goods_id,
+ prom_type: good.prom_type,
+ prom_id: good.prom_id
+ },
+ }).then(res => {
+ var buy_num_data = res.data.data;
+ if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
+ goodsbuynum = buy_num_data.goodsbuynum;
+ })
- var buyed_mum2=goodsbuynum+good.goods_num;
- if (buyed_mum2 > limit && limit > 0) {
+ var buyed_mum2 = goodsbuynum + good.goods_num;
+ if (buyed_mum2 > limit && limit > 0) {
- var content=gg.goods_name+'购买数量超出商品限购,请取消订单';
- th.toast(content);
- return false;
- }
+ var content = gg.goods_name + '购买数量超出商品限购,请取消订单';
+ th.toast(content);
+ return false;
+ }
//如果是预售的时候,
- if(good.prom_type==8){
- await getApp().request.promiseGet("/api/weshop/order/orderPresell/countBuyGoodsSum",{
- data: {store_id: os.stoid, user_id: user_id, goods_id: good.goods_id, prom_id: good.prom_id},
- }).then(e=>{
+ if (good.prom_type == 8) {
+ await getApp().request.promiseGet("/api/weshop/order/orderPresell/countBuyGoodsSum", {
+ data: { store_id: os.stoid, user_id: user_id, goods_id: good.goods_id, prom_id: good.prom_id },
+ }).then(e => {
if (e.data.code == 0) {
- promgoodsbuynum=e.data.data.sumgoodsnum;
+ promgoodsbuynum = e.data.data.sumgoodsnum;
}
})
- var presell_id =good.prom_id;
- var presellList=null;
+ var presell_id = good.prom_id;
+ var presellList = null;
var url = "/api/weshop/marketing/marketingPresellList/list"
var rd = {
store_id: os.stoid,
@@ -2170,13 +2191,13 @@ Page({
}).then(res => {
if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
var arr = res.data.data[0];
- presellList=arr
+ presellList = arr
}
})
- if(presellList){
+ if (presellList) {
- if(good.goods_num>presellList.presell_sumqty-presellList.buy_goodnum){
+ if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) {
var content = gg.goods_name + '购买数量超出商品库存,请取消订单';
th.toast(content);
return false;
@@ -2192,247 +2213,248 @@ Page({
}
- //如果优惠促销和搭配购的时候
- if((good.prom_type==3 || good.prom_type==5) && good.is_collocation!=1 && good.is_gift!=1){
- var p_ok=1;
- await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
- if(res.data.code==0){
- var r_data=res.data.data;
- if(!r_data.collocationPromList && good.prom_type==5){
-
- var content=good.goods_name+'未找到活动,请取消订单重新购买';
- th.toast(content);
- p_ok=0;
- }
- if(!r_data.promGoodsLists && good.prom_type==3){
-
- var content=good.goods_name+'未找到活动,请取消订单重新购买';
- th.toast(content);
- p_ok=0;
- }
- }else{
+ //如果优惠促销和搭配购的时候
+ if ((good.prom_type == 3 || good.prom_type == 5) && good.is_collocation != 1 && good.is_gift != 1) {
+ var p_ok = 1;
+ await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => {
+ if (res.data.code == 0) {
+ var r_data = res.data.data;
+ if (!r_data.collocationPromList && good.prom_type == 5) {
- var content=good.goods_name+'未找到活动,请取消订单重新购买';
+ var content = good.goods_name + '未找到活动,请取消订单重新购买';
th.toast(content);
- p_ok=0;
+ p_ok = 0;
}
- })
- if(!p_ok) return false;
- }
+ if (!r_data.promGoodsLists && good.prom_type == 3) {
- //商品的普通购买 ,不要进行判断
- if((good.prom_type==1 || good.prom_type==6 || good.prom_type==4) && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal){
- if(gg.prom_type!=good.prom_type) {
+ var content = good.goods_name + '未找到活动,请取消订单重新购买';
+ th.toast(content);
+ p_ok = 0;
+ }
+ } else {
- var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
+ var content = good.goods_name + '未找到活动,请取消订单重新购买';
th.toast(content);
- return false;
+ p_ok = 0;
}
- }else{
- if((gg.prom_type==1 || gg.prom_type==3 || gg.prom_type==5 || gg.prom_type==6 || gg.prom_type==4)
- && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
- var prom=null;
- //---如果是活动的时候---
- var prom=null,th=this;
- if(gg.prom_type==1){
- await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+gg.prom_id,{
- }).then(res=>{
- if(res.data.code==0){
- prom=res.data.data;
- }
- })
- }
- if(gg.prom_type==6){
- await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+gg.prom_id,{
- }).then(res=>{
- if(res.data.code==0){
- prom=res.data.data;
- }
- })
- }
-
- if(gg.prom_type==4){
- await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
- data:{store_id:os.stoid,goods_id:gg.goods_id}
- }).then(res=>{
- if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){
- prom=res.data.data.pageData[0];
- }
- })
- }
+ })
+ if (!p_ok) return false;
+ }
- if(prom){
- var t_now=ut.gettimestamp();
- if(prom.is_end==0 && prom.start_timet_now){
+ //商品的普通购买 ,不要进行判断
+ if ((good.prom_type == 1 || good.prom_type == 6 || good.prom_type == 4) && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal) {
+ if (gg.prom_type != good.prom_type) {
- var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
- th.toast(content);
- return false;
+ var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
+ th.toast(content);
+ return false;
+ }
+ } else {
+ if ((gg.prom_type == 1 || gg.prom_type == 3 || gg.prom_type == 5 || gg.prom_type == 6 || gg.prom_type == 4)
+ && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
+ var prom = null;
+ //---如果是活动的时候---
+ var prom = null, th = this;
+ if (gg.prom_type == 1) {
+ await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + gg.prom_id, {
+ }).then(res => {
+ if (res.data.code == 0) {
+ prom = res.data.data;
}
- }
+ })
+ }
+ if (gg.prom_type == 6) {
+ await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + gg.prom_id, {
+ }).then(res => {
+ if (res.data.code == 0) {
+ prom = res.data.data;
+ }
+ })
}
- else{
- //不是赠品的时候
- if(!good.is_gift && good.prom_type!=3){
- var t_ok=1;
- await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
- if(res.data.code==0){
- var r_data=res.data.data;
- //-- 参加了全局的优惠活动 --
- if(r_data.promGoodsLists){
-
- var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
- th.toast(content);
- t_ok=0;
- }
- }
- })
- if(!t_ok) return false;
- }
- //-- 如果有参加线下取价 --
- if(good.offline_cut>0) wlist+=encodeURIComponent(gg.erpwareid)+",";
+ if (gg.prom_type == 4) {
+ await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", {
+ data: { store_id: os.stoid, goods_id: gg.goods_id }
+ }).then(res => {
+ if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) {
+ prom = res.data.data.pageData[0];
+ }
+ })
}
- //赠品和搭配购不判断商品金额
- var isok=1;
- var card_field=th.data.card_field;
- //如果会员是等级会员,商品有等级价,且不是活动商品
- if(!good.is_gift && !good.is_collocation && good.prom_type!=8) {
- if (card_field && gg[card_field] > 0) {
- if (good.goods_price != gg[card_field] && good.offline_cut<=0) isok = 0;
- if (good.goods_price >gg[card_field] && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过
- } else {
- if (good.goods_price != gg.shop_price && good.offline_cut<=0) isok = 0;
- if (good.goods_price> gg.shop_price && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过
- }
- var is_h=0;
- if (!isok) {
+ if (prom) {
+ var t_now = ut.gettimestamp();
+ if (prom.is_end == 0 && prom.start_time < t_now && prom.end_time > t_now) {
- var content=gg.goods_name + '商品的价格发生了变化,请取消订单重新购买';
+ var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
th.toast(content);
return false;
}
}
+ }
+ else {
+ //不是赠品的时候
+ if (!good.is_gift && good.prom_type != 3) {
+ var t_ok = 1;
+ await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => {
+ if (res.data.code == 0) {
+ var r_data = res.data.data;
+ //-- 参加了全局的优惠活动 --
+ if (r_data.promGoodsLists) {
+ var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
+ th.toast(content);
+ t_ok = 0;
+ }
+ }
+ })
+ if (!t_ok) return false;
+ }
- if(good.goods_num>store_count){
-
- var content=gg.goods_name+'商品的库存不足,请取消订单';
- th.toast(content);
- return false;
- }
+ //-- 如果有参加线下取价 --
+ if (good.offline_cut > 0) wlist += encodeURIComponent(gg.erpwareid) + ",";
+ }
+ //赠品和搭配购不判断商品金额
+ var isok = 1;
+ var card_field = th.data.card_field;
+ //如果会员是等级会员,商品有等级价,且不是活动商品
+ if (!good.is_gift && !good.is_collocation && good.prom_type != 8) {
+ if (card_field && gg[card_field] > 0) {
+ if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0;
+ if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
+ } else {
+ if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0;
+ if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
+ }
+ var is_h = 0;
+ if (!isok) {
+ var content = gg.goods_name + '商品的价格发生了变化,请取消订单重新购买';
+ th.toast(content);
+ return false;
+ }
}
- console.log("------------------------------------");
- //---如果是活动的时候---
- var prom=null,goodsinfo=good,th=this;
- if(goodsinfo.prom_type==1){
- await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+goodsinfo.prom_id,{
- }).then(res=>{
- if(res.data.code==0){
- prom=res.data.data;
- }
- })
+
+ if (good.goods_num > store_count) {
+
+ var content = gg.goods_name + '商品的库存不足,请取消订单';
+ th.toast(content);
+ return false;
}
- if(goodsinfo.prom_type==6 && !good.is_pd_normal){
- await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{
- }).then(res=>{
- if(res.data.code==0){
- prom=res.data.data;
- }
- })
+
+
+ }
+
+ console.log("------------------------------------");
+ //---如果是活动的时候---
+ var prom = null, goodsinfo = good, th = this;
+ if (goodsinfo.prom_type == 1) {
+ await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {
+ }).then(res => {
+ if (res.data.code == 0) {
+ prom = res.data.data;
+ }
+ })
+ }
+ if (goodsinfo.prom_type == 6 && !good.is_pd_normal) {
+ await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {
+ }).then(res => {
+ if (res.data.code == 0) {
+ prom = res.data.data;
+ }
+ })
+ }
+
+ if (goodsinfo.prom_type == 4 && !good.is_integral_normal) {
+ await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", {
+ data: { store_id: os.stoid, goods_id: goodsinfo.goods_id }
+ }).then(res => {
+ if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) {
+ prom = res.data.data.pageData[0];
+ }
+ })
+ }
+
+ //----------如果有活动,并且在进行中,就不计算线下库存---------------
+ if (prom) {
+ var now = ut.gettimestamp();
+ if (prom.is_end == 1 && prom.end_time < now) {
+
+ var content = goodsinfo.goods_name + '商品的活动已经结束,请取消订单重新购买';
+ th.toast(content);
+ return false;
}
- if(goodsinfo.prom_type==4 && !good.is_integral_normal){
- await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
- data:{store_id:os.stoid,goods_id:goodsinfo.goods_id}
- }).then(res=>{
- if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){
- prom=res.data.data.pageData[0];
- }
- })
+ buyed_mum2 = promgoodsbuynum + good.goods_num;
+ if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) {
+
+ var content = goodsinfo.goods_name + '购买数量超出商品活动限购,请取消订单重新购买';
+ th.toast(content);
+ return false;
}
- //----------如果有活动,并且在进行中,就不计算线下库存---------------
- if(prom){
- var now=ut.gettimestamp();
- if(prom.is_end==1 && prom.end_time prom.limitqty - prom.buy_num) {
- var content=goodsinfo.goods_name+'商品的活动已经结束,请取消订单重新购买';
+ var content = goodsinfo.goods_name + '购买数量超出商品活动库存,请取消订单';
th.toast(content);
return false;
}
+ } else {
+ var redis_num = 0;
+ //------判断活动是否抢光-----
+ await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
+ os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, {
+ }).then(res => {
+ redis_num = res.data.data;
+ });
- buyed_mum2=promgoodsbuynum+good.goods_num;
- if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) {
+ if (good.goods_num > redis_num) {
- var content=goodsinfo.goods_name+'购买数量超出商品活动限购,请取消订单重新购买';
+ var content = gg.goods_name + '超出商品活动库存,请取消订单';
th.toast(content);
return false;
}
-
- if(goodsinfo.prom_type==4){
- if (good.goods_num > prom.limitqty-prom.buy_num) {
-
- var content=goodsinfo.goods_name+'购买数量超出商品活动库存,请取消订单';
- th.toast(content);
- return false;
- }
- }else{
- var redis_num = 0;
- //------判断活动是否抢光-----
- await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
- os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, {
- }).then(res => {
- redis_num = res.data.data;
- });
-
- if (good.goods_num > redis_num) {
-
- var content=gg.goods_name+'超出商品活动库存,请取消订单';
- th.toast(content);
- return false;
- }
- }
-
}
+ }
+
//-- 要判断一下线下取价价格是不是发生改变 --
- if(wlist!="" && th.data.is_open_offline && th.data.is_open_offline>0){
- wlist=ut.sub_last(wlist);
- var keyid=order.pickup_id;
- var user_info=getApp().globalData.userInfo;
- if(!keyid) return false;
- var offarr=null;
+ if (wlist != "" && th.data.is_open_offline && th.data.is_open_offline > 0) {
+ wlist = ut.sub_last(wlist);
+ var keyid = order.pickup_id;
+ var user_info = getApp().globalData.userInfo;
+ if (!keyid) return false;
+ var offarr = null;
await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", {
- data:{
- VIPId:encodeURIComponent(user_info.erpvipid),
- store_id:os.stoid,
- PickupId:keyid,
- WareIds:wlist},
+ data: {
+ VIPId: encodeURIComponent(user_info.erpvipid),
+ store_id: os.stoid,
+ PickupId: keyid,
+ WareIds: wlist
},
- ).then(res=>{
- if(res.data.code==0 && res.data.data && res.data.data.length>0){
- offarr=res.data.data;
+ },
+ ).then(res => {
+ if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
+ offarr = res.data.data;
}
})
- if(!offarr && offarr.length<=0 ){
- wx.showModal({ title: '获取线下取价失败',});
+ if (!offarr && offarr.length <= 0) {
+ wx.showModal({ title: '获取线下取价失败', });
}
- var newarr=ut.convert_arr_key(offarr,'WareId');
+ var newarr = ut.convert_arr_key(offarr, 'WareId');
//-- 循环判断线下的价格 --
- for(var k in order_goods){
- var good=order_goods[k];
+ for (var k in order_goods) {
+ var good = order_goods[k];
//判断线下取价是不是一样
- if(newarr[good.erpwareid] &&
- parseFloat(newarr[good.erpwareid].WarePrice)!=parseFloat(good.goods_price)){
+ if (newarr[good.erpwareid] &&
+ parseFloat(newarr[good.erpwareid].WarePrice) != parseFloat(good.goods_price)) {
- var content=good.goods_name + '商品的价格发生了变化,请取消订单重新购买';
+ var content = good.goods_name + '商品的价格发生了变化,请取消订单重新购买';
th.toast(content);
return false;
}
@@ -2447,30 +2469,30 @@ Page({
type: 1 //正常单
}, 1);--*/
- util_pay.pay(this.data.order.order_sn, function() {
- wx.showToast({title: '支付成功'})
+ util_pay.pay(this.data.order.order_sn, function () {
+ wx.showToast({ title: '支付成功' })
wx.navigateBack();
- },null,os.stoid,1);
+ }, null, os.stoid, 1);
},
//--------取消订单---------
- cancelOrder: function(e) {
- var t = this,th=t, ord_id = this.data.order.order_id,order=this.data.order;
+ cancelOrder: function (e) {
+ var t = this, th = t, ord_id = this.data.order.order_id, order = this.data.order;
wx.showModal({
title: "是否取消订单?",
- success: function(e) {
- if(!e.confirm) return false;
+ success: function (e) {
+ if (!e.confirm) return false;
//如果是秒杀和拼单的商品,取消订单要返回redis,并取消订单
//if(is_skill==1 || is_zsorder>=2){
- getApp().request.post("/api/weshop/order/cancelOrder/"+os.stoid+"/"+ord_id+"/"+getApp().globalData.user_id,{
- data:{},
- success: function(t) {
- if(t.data.code==0){
- th.setData({'order.order_status':3});
- wx.setStorageSync("order:order_list:update", !0);
+ getApp().request.post("/api/weshop/order/cancelOrder/" + os.stoid + "/" + ord_id + "/" + getApp().globalData.user_id, {
+ data: {},
+ success: function (t) {
+ if (t.data.code == 0) {
+ th.setData({ 'order.order_status': 3 });
+ wx.setStorageSync("order:order_list:update", !0);
}
},
@@ -2482,36 +2504,36 @@ Page({
//-----删除订单-----
- deleteOrderData: function(t) {
- var th=this;
- var order_id=this.data.order.order_id;
- var up_data={
- order_id: order_id,isdel:1
+ deleteOrderData: function (t) {
+ var th = this;
+ var order_id = this.data.order.order_id;
+ var up_data = {
+ order_id: order_id, isdel: 1
};
- if(th.data.order.order_status!=6){
- up_data.order_status=5;
+ if (th.data.order.order_status != 6) {
+ up_data.order_status = 5;
}
wx.showModal({
title: "是否删除订单?",
- success: function(tt) {
+ success: function (tt) {
tt.confirm && getApp().request.put("/api/weshop/order/updatebyId", {
data: up_data,
success: function (t) {
- getApp().my_warnning("删除成功",1,th);
+ getApp().my_warnning("删除成功", 1, th);
setTimeout(function () {
getApp().goto("/pages/user/order_list/order_list");
- },1000);
+ }, 1000);
}
})
}
});
},
- go_goods:function (e) {
- var url=e.currentTarget.dataset.url;
+ go_goods: function (e) {
+ var url = e.currentTarget.dataset.url;
getApp().goto(url);
},
- toast(msg){
+ toast(msg) {
wx.showToast({
title: msg,
icon: 'none',
@@ -2519,15 +2541,15 @@ Page({
})
},
//--------确认收货---------
- confirmOrder: function(e) {
- var th=this;
- var o = this.data.order.order_id,order=this.data.order;
+ confirmOrder: function (e) {
+ var th = this;
+ var o = this.data.order.order_id, order = this.data.order;
wx.showModal({
title: "是否确认收货?",
- success: function(t) {
- t.confirm && getApp().request.post("/api/weshop/order/confirmOrder/"+os.stoid+"/"+o+"/"+getApp().globalData.user_id,{
- success:function (e) {
- if(e.data.code==0){
+ success: function (t) {
+ t.confirm && getApp().request.post("/api/weshop/order/confirmOrder/" + os.stoid + "/" + o + "/" + getApp().globalData.user_id, {
+ success: function (e) {
+ if (e.data.code == 0) {
th.setData({})
}
}
@@ -2538,13 +2560,13 @@ Page({
//---------联系客服------------
- contactService: function() {
- getApp().getConfig(function(t) {
+ contactService: function () {
+ getApp().getConfig(function (t) {
if (t.store_tel == undefined) {
getApp().request.get("/api/weshop/store/get/" + os.stoid, {
isShowLoading: 1,
data: {},
- success: function(rs) {
+ success: function (rs) {
getApp().globalData.config = rs.data.data;
if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) {
getApp().my_warnning("商家未设置电话", 0, th);
@@ -2560,13 +2582,13 @@ Page({
},
//---------联系微信客服------------
- con_weixin:function () {
- var url=this.data.sys_switch.weapp_customertype_url;
- var id=this.data.sys_switch.weapp_customertype_appid;
+ con_weixin: function () {
+ var url = this.data.sys_switch.weapp_customertype_url;
+ var id = this.data.sys_switch.weapp_customertype_appid;
wx.openCustomerServiceChat({
- extInfo: {url: url},
+ extInfo: { url: url },
corpId: id,
- success(res) {}
+ success(res) { }
})
}
diff --git a/packageC/pages/presell/cart/cart2.js b/packageC/pages/presell/cart/cart2.js
index 075c2c2..8b25596 100644
--- a/packageC/pages/presell/cart/cart2.js
+++ b/packageC/pages/presell/cart/cart2.js
@@ -121,25 +121,25 @@ Page({
tabs: ['门店自提', '快递邮寄'],
currentTabIndex: 1,
- in_zhact_gdmap:{}, //不同门店参与同一活动的限购
- hid_inp:1,
- user_note:{},
+ in_zhact_gdmap: {}, //不同门店参与同一活动的限购
+ hid_inp: 1,
+ user_note: {},
},
onLoad: function (t) {
- wx.setNavigationBarTitle({title: "填写订单",})
+ wx.setNavigationBarTitle({ title: "填写订单", })
var th = this;
//清理一下,确保最新的系统配置
getApp().globalData.config2 = null;
//清空is_pick_up
getApp().request.put("/api/weshop/useraddress/updatePickUp", {
- data: {user_id: getApp().globalData.user_id, is_pickup: 0},
+ data: { user_id: getApp().globalData.user_id, is_pickup: 0 },
success: function (s) {
}
});
},
onUnload: function () {
- this.setData({isclose: 1})
+ this.setData({ isclose: 1 })
},
onHide: function () {
this.setData({
@@ -152,7 +152,7 @@ Page({
//----------子页返回父页触发----------
onShow: function () {
var th = this;
- th.setData({show_submit: 0}); //让提交先掩藏
+ th.setData({ show_submit: 0 }); //让提交先掩藏
th.data.g_cart_q_time = null;
if (th.data.isclose == 0) {
@@ -182,20 +182,20 @@ Page({
th.data.is_summit_ing = 0;
//更换地址回来要重新调用计算价钱的接口
if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
- th.setData({user_addr: ie});
+ th.setData({ user_addr: ie });
if (th.data.is_b_now == 1) {
if (th.data.bn_goods) {
- th.setData({add_back: 1});
+ th.setData({ add_back: 1 });
//th.calculatePrice2();
}
} else {
if (th.data.cartlist) {
- th.setData({add_back: 1});
+ th.setData({ add_back: 1 });
//th.calculatePrice();
}
}
} else {
- th.setData({user_addr: ie});
+ th.setData({ user_addr: ie });
}
var going = 0;
@@ -234,34 +234,34 @@ Page({
//-- 获取所有的等级卡, --
getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid,
{}).then(res => {
- if (res.data.code == 0) {
- var plusCard = res.data.data;
- //-- 循环判断,拿到最贵的那张卡 --
- for (var ih in plusCard) {
- if (plusCard[ih].IsStopBuy == true) {
- continue;
- }
- if (max_price < 0) {
- max_price = plusCard[ih].CardFee;
- name = 'card' + plusCard[ih]['CorrPrice'];
- show_card = plusCard[ih];
- } else {
- if (max_price < plusCard[ih].CardFee) {
+ if (res.data.code == 0) {
+ var plusCard = res.data.data;
+ //-- 循环判断,拿到最贵的那张卡 --
+ for (var ih in plusCard) {
+ if (plusCard[ih].IsStopBuy == true) {
+ continue;
+ }
+ if (max_price < 0) {
max_price = plusCard[ih].CardFee;
name = 'card' + plusCard[ih]['CorrPrice'];
show_card = plusCard[ih];
+ } else {
+ if (max_price < plusCard[ih].CardFee) {
+ max_price = plusCard[ih].CardFee;
+ name = 'card' + plusCard[ih]['CorrPrice'];
+ show_card = plusCard[ih];
+ }
}
}
- }
- if (show_card) {
- name = name.toLowerCase();
- th.setData({card_name: name, show_card: show_card})
+ if (show_card) {
+ name = name.toLowerCase();
+ th.setData({ card_name: name, show_card: show_card })
+ }
}
- }
- //-----先获取物流,再获取用户信息,再展示页面-----
- th.get_wuliu(th.get_info(th.show_page));
- })
+ //-----先获取物流,再获取用户信息,再展示页面-----
+ th.get_wuliu(th.get_info(th.show_page));
+ })
} else {
//-----先获取物流,再获取用户信息,再展示页面-----
th.get_wuliu(th.get_info(th.show_page));
@@ -281,10 +281,10 @@ Page({
if (th.data.is_default_logistics) {
//如果第一个不是开启默认,说明要让用户自己选
if (!e[0].is_default) {
- th.setData({is_default_logistics: 0});
+ th.setData({ is_default_logistics: 0 });
}
}
- th.setData({wu_arr: e})
+ th.setData({ wu_arr: e })
typeof func == "function" && func();
})
},
@@ -298,7 +298,7 @@ Page({
getuser_addr: function (func) {
var th = this;
a.get("/api/weshop/useraddress/page", {
- data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()},
+ data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random() },
success: function (su) {
/*---
var user_addr=[
@@ -323,7 +323,7 @@ Page({
}
if (item == undefined) item = null;
- if (!item) th.setData({user_addr: null}); //地址为空的时候,要清空,因为返回的时候,有缓存
+ if (!item) th.setData({ user_addr: null }); //地址为空的时候,要清空,因为返回的时候,有缓存
func(item);
}
@@ -338,32 +338,32 @@ Page({
//会员的信息,要获取最新
var user = getApp().globalData.userInfo;
getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, {
- data: {r: Math.random()},
+ data: { r: Math.random() },
success: function (e) {
getApp().globalData.userInfo = e.data.data;
- th.setData({userinfo: e.data.data});
+ th.setData({ userinfo: e.data.data });
//选获取地址
th.getuser_addr(function (addr) {
- th.setData({user_addr: addr});
- //--------------------------立即购买------------------
- //读取门店
- to.get_allsto(function (e) {
- th.setData({allsto: e});
- //获取立即购买的商品信息
- th.get_buy_goods();
- });
+ th.setData({ user_addr: addr });
+ //--------------------------立即购买------------------
+ //读取门店
+ to.get_allsto(function (e) {
+ th.setData({ allsto: e });
+ //获取立即购买的商品信息
+ th.get_buy_goods();
+ });
});
//获取提现金额
getApp().request.get("/api/weshop/withdrawals/summoney", {
- data: {user_id: to.globalData.user_id, store_id: oo.stoid, status: 0},
+ data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 },
success: function (su) {
if (su.data.code == 0) {
var yuer = parseFloat(th.data.userinfo.user_money -
(th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2);
- th.setData({txmon: su.data.data.summoney, yuer: yuer});
+ th.setData({ txmon: su.data.data.summoney, yuer: yuer });
}
}
});
@@ -379,127 +379,127 @@ Page({
th.data.gg = to.get_b_now();
//--------如果goods_id一样,就是要立即购买-----
getApp().request.get("/api/weshop/goods/get/" + oo.stoid + "/" + th.data.gg.goods_id, {
- success: async function (t) {
- var gd = t.data.data;
- if (!gd) return false;
-
- t.data.data.original_img = oo.imghost + t.data.data.original_img;
- t.data.data['buynum'] = th.data.gg.goods_num;
- var distr_t = 0, et = 0
- if (t.data.data.distr_type == 0) {
- distr_t = th.data.gg.pick_dis;
- } else {
- distr_t = t.data.data.distr_type;
- }
+ success: async function (t) {
+ var gd = t.data.data;
+ if (!gd) return false;
+
+ t.data.data.original_img = oo.imghost + t.data.data.original_img;
+ t.data.data['buynum'] = th.data.gg.goods_num;
+ var distr_t = 0, et = 0
+ if (t.data.data.distr_type == 0) {
+ distr_t = th.data.gg.pick_dis;
+ } else {
+ distr_t = t.data.data.distr_type;
+ }
- switch (distr_t) {
- case 0:
- et = 1;
- //-- 系统后台有设置要默认的 --
- if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0;
- break;
- case 1:
- et = 1;
- break;
- case 2:
- et = 0;
- break;
- }
+ switch (distr_t) {
+ case 0:
+ et = 1;
+ //-- 系统后台有设置要默认的 --
+ if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0;
+ break;
+ case 1:
+ et = 1;
+ break;
+ case 2:
+ et = 0;
+ break;
+ }
- var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
- if (et == 0 && def_exp_code) {
- for (var k = 0; k < th.data.wu_arr.length; k++) {
- var item = th.data.wu_arr[k];
- if (def_exp_code == item.code) {
- m_wind = k;
- }
+ var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
+ if (et == 0 && def_exp_code) {
+ for (var k = 0; k < th.data.wu_arr.length; k++) {
+ var item = th.data.wu_arr[k];
+ if (def_exp_code == item.code) {
+ m_wind = k;
}
}
+ }
- if (th.data.bn_goods) {
- et = th.data.bn_exp_type;
- m_wind = th.data.index;
- }
+ if (th.data.bn_goods) {
+ et = th.data.bn_exp_type;
+ m_wind = th.data.index;
+ }
- //---是不是购买等级卡成功的返回---等级卡显示的判断---
- var is_card_back = getApp().globalData.is_card_back;
- if (is_card_back) {
- th.data.card_name = th.data.userinfo.card_field;
- th.data.gg.goods_price = gd[th.data.card_name];
- getApp().globalData.is_card_back = 0;
- th.setData({card_cut_price: 0});
- //如果是秒杀的返回
- if (gd.prom_type == 1) gd.prom_type = 0;
- } else {
- //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格
- //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 --
- if (!th.data.gg.collocation_goods && gd['prom_type'] != 6 && th.data.card_name && gd[th.data.card_name] > 0 && th.data.gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) {
- var cut_p = (th.data.gg.goods_price - gd[th.data.card_name]) * th.data.gg.goods_num;
- th.setData({card_cut_price: cut_p});
- }
+ //---是不是购买等级卡成功的返回---等级卡显示的判断---
+ var is_card_back = getApp().globalData.is_card_back;
+ if (is_card_back) {
+ th.data.card_name = th.data.userinfo.card_field;
+ th.data.gg.goods_price = gd[th.data.card_name];
+ getApp().globalData.is_card_back = 0;
+ th.setData({ card_cut_price: 0 });
+ //如果是秒杀的返回
+ if (gd.prom_type == 1) gd.prom_type = 0;
+ } else {
+ //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格
+ //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 --
+ if (!th.data.gg.collocation_goods && gd['prom_type'] != 6 && th.data.card_name && gd[th.data.card_name] > 0 && th.data.gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) {
+ var cut_p = (th.data.gg.goods_price - gd[th.data.card_name]) * th.data.gg.goods_num;
+ th.setData({ card_cut_price: cut_p });
}
+ }
- //定义变量
- var gg = th.data.gg,act = null,prelist = null;
- var url = "/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + gg.prom_id;
- await getApp().request.promiseGet(url, {}).then(res => {
- if (res.data.code == 0) {
- act = res.data.data;
- }
- })
- if (!act) {
- wx.showToast({title: "未找到活动", icon: 'none', duration: 3000});
- return false;
- }
- if (act.is_end==1 ) {
- wx.showToast({title:'活动已经结束' , icon: 'none', duration: 3000});
- return false;
- }
- if( ut.gettimestamp()>act.end_time){
- wx.showToast({title:"活动定金支付时间已过期" , icon: 'none', duration: 3000});
- return false;
+ //定义变量
+ var gg = th.data.gg, act = null, prelist = null;
+ var url = "/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + gg.prom_id;
+ await getApp().request.promiseGet(url, {}).then(res => {
+ if (res.data.code == 0) {
+ act = res.data.data;
}
+ })
+ if (!act) {
+ wx.showToast({ title: "未找到活动", icon: 'none', duration: 3000 });
+ return false;
+ }
+ if (act.is_end == 1) {
+ wx.showToast({ title: '活动已经结束', icon: 'none', duration: 3000 });
+ return false;
+ }
+ if (ut.gettimestamp() > act.end_time) {
+ wx.showToast({ title: "活动定金支付时间已过期", icon: 'none', duration: 3000 });
+ return false;
+ }
- var url = "/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + gg.presell_list_id;
- await getApp().request.promiseGet(url, {}).then(res => {
- if (res.data.code == 0) {
- prelist = res.data.data;
- }
- })
- if (!prelist) {
- wx.showToast({title: "未找到商品", icon: 'none', duration: 3000});
- return false;
+ var url = "/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + gg.presell_list_id;
+ await getApp().request.promiseGet(url, {}).then(res => {
+ if (res.data.code == 0) {
+ prelist = res.data.data;
}
+ })
+ if (!prelist) {
+ wx.showToast({ title: "未找到商品", icon: 'none', duration: 3000 });
+ return false;
+ }
- //这个位置要拿活动的预售价
- t.data.data.shop_price = prelist.presell_money;
- th.setData({
- bn_goods: t.data.data,
- bn_pickname: gg.pick_name,
- bn_exp_type: et,
- index: m_wind,
- bn_pick: gg.pick_id,
- bn_t_exp_t: distr_t,
- bn_exp_type: et,
- act:act
- });
+ //这个位置要拿活动的预售价
+ t.data.data.shop_price = prelist.presell_money;
+ th.setData({
+ bn_goods: t.data.data,
+ bn_pickname: gg.pick_name,
+ bn_exp_type: et,
+ index: m_wind,
+ bn_pick: gg.pick_id,
+ bn_t_exp_t: distr_t,
+ bn_exp_type: et,
+ act: act
+ });
- if(act.is_usecoupon==1){
- th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num;
- th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + "";
- th.data.check_quan_ware_list = t.data.data.erpwareid + "";
- }
+ if (act.is_usecoupon == 1) {
+ th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num;
+ th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + "";
+ th.data.check_quan_ware_list = t.data.data.erpwareid + "";
+ }
- //计算价格
- th.calculatePrice2();
- //获取优惠券,如果有券的钱,就调用
- if(th.data.ckeck_quan_price>0) th.get_buy_now_quan();
+ //计算价格
+ th.calculatePrice2();
+ //获取优惠券,如果有券的钱,就调用
+ if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan();
- },
- });
+ },
+ });
},
@@ -507,14 +507,14 @@ Page({
checkAddressList: function () {
var t = this;
return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({
- title: "请先填写或选择收货地址~",
- success: function (a) {
- a.confirm ? t.enterAddressPage() : wx.navigateBack();
- },
- fail: function () {
- wx.navigateBack();
- }
- }), !1);
+ title: "请先填写或选择收货地址~",
+ success: function (a) {
+ a.confirm ? t.enterAddressPage() : wx.navigateBack();
+ },
+ fail: function () {
+ wx.navigateBack();
+ }
+ }), !1);
},
showInvoice: function () {
this.setData({
@@ -533,7 +533,7 @@ Page({
},
keyUpChangeNum: function (t) {
var index = t.currentTarget.dataset.index;
- var txt="user_note."+index;
+ var txt = "user_note." + index;
this.setData({
maxWord: t.detail.value.length,
[txt]: t.detail.value
@@ -564,7 +564,7 @@ Page({
}
}
var set_txt = "cartlist[" + iter + "].can_num";
- th.setData({[set_txt]: num});
+ th.setData({ [set_txt]: num });
}
},
@@ -595,10 +595,10 @@ Page({
allpice = parseFloat(allpice).toFixed(2);
var txt = "formData.all_price";
- th.setData({[txt]: allpice,});
+ th.setData({ [txt]: allpice, });
if (cut_price) {
var c_txt = "formData.cut_price";
- th.setData({[c_txt]: cut_price,});
+ th.setData({ [c_txt]: cut_price, });
}
@@ -612,7 +612,7 @@ Page({
to.getwuliuprice(async function (rs) {
var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
- var out_of_weight=null; //超出多少重量
+ var out_of_weight = null; //超出多少重量
var freight_free = ee.freight_free; //全场满多少包邮
var weight_free = ee.weight_free; //多少kg内包邮
var no_ex_id = ee.no_ex_id;
@@ -666,7 +666,7 @@ Page({
arr.push(item);
}
if (arr) {
- th.setData({get_by_quan_list: arr});
+ th.setData({ get_by_quan_list: arr });
}
th.data.isget_by_quan[th.data.bn_pick] = 1;
}
@@ -682,7 +682,9 @@ Page({
if (goods_weight < 0) goods_weight = 0;
//累积商品重量 每种商品的重量 * 数量
goods_weight += good['weight'] * good['buynum'];
- out_of_weight = (weight_free * 1000 ) - goods_weight;
+ if (weight_free > 0) {
+ out_of_weight = (weight_free * 1000) - goods_weight;
+ }
break;
case 3:
if (goods_piece < 0) goods_piece = 0;
@@ -693,18 +695,17 @@ Page({
var code = "";
if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
-
+
th.data.is_no_by[th.data.bn_pick] = 0;
var no_by_data = null;
var gift_freight_free = freight_free;
-
//有不包邮区域,且不免运费
if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) {
//-----------获取不包邮区域,不包邮商品-------
await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
- data: {store_id: os.stoid, id: no_ex_id}
+ data: { store_id: os.stoid, id: no_ex_id }
}).then(res => {
if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
no_by_data = res.data.data[0];
@@ -712,6 +713,8 @@ Page({
if (res.data.data[0].region_list) {
if (th.check_by_area(res.data.data[0].region_list)) {
freight_free = 0;
+ out_of_weight = 0;
+ weight_free=-1;
th.data.is_no_by[th.data.bn_pick] = 1;
}
}
@@ -719,6 +722,8 @@ Page({
if (res.data.data[0].goods_list && freight_free) {
if (th.check_by_goods(res.data.data[0].goods_list)) {
freight_free = 0;
+ out_of_weight = 0;
+ weight_free=-1;
th.data.is_no_by[th.data.bn_pick] = 1;
}
}
@@ -729,13 +734,13 @@ Page({
th.data.is_by[th.data.bn_pick] = 0;
//--------------开始计算物流------------------
var shipping_price =
- th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight,
- goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs);
+ th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
+ goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs,th.data.bn_pick);
//如果有赠品的时候,也要计算赠品的物流费用
if (th.data.buy_now_gift_goods) {
- shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,gift_weight_free,
- parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece);
+ shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, out_of_weight, gift_weight_free,
+ parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece,th.data.bn_pick);
}
if (shipping_price <= 0) {
@@ -744,18 +749,18 @@ Page({
shipping_price = parseFloat(shipping_price).toFixed(2);
var wl_txt = "formData.shipping_price";
- th.setData({[wl_txt]: shipping_price,})
+ th.setData({ [wl_txt]: shipping_price, })
} else {
var wl_txt = "formData.shipping_price";
- th.setData({[wl_txt]: 0,})
+ th.setData({ [wl_txt]: 0, })
}
if (quan_no) {
if (th.data.using_quan[bn_pick].isby == 1) {
shipping_price = 0;
var wl_txt = "formData.shipping_price";
- th.setData({[wl_txt]: 0,})
+ th.setData({ [wl_txt]: 0, })
}
}
//-----------------支付价,优惠券不减物流-----------------
@@ -774,7 +779,7 @@ Page({
var order_prom_id = 0;
if (th.data.order_prom[th.data.bn_pick]) {
var ord_prom = th.data.order_prom[th.data.bn_pick];
- if(!ord_prom.is_xz_yh || quan_price<=0) {
+ if (!ord_prom.is_xz_yh || quan_price <= 0) {
order_prom_id = ord_prom['id'];
switch (ord_prom['type']) {
case 0:
@@ -792,7 +797,7 @@ Page({
if (order_prom_id > 0) {
var order_prom_txt1 = "formData.order_prom_id";
var order_prom_txt2 = "formData.order_prom_amount";
- th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount})
+ th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount })
}
total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price);
@@ -802,7 +807,7 @@ Page({
order_m = order_m.toFixed(2);
var atxt = "formData.total_amount";
- th.setData({[atxt]: total_m,})
+ th.setData({ [atxt]: total_m, })
var txt = "formData.user_money";
var txt2 = "formData.order_amount";
@@ -812,43 +817,43 @@ Page({
if (th.data.bn_use_money == 1) {
if (amoney > order_m) {
order_m = parseFloat(order_m).toFixed(2);
- th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 })
} else {
order_m = parseFloat(order_m) - parseFloat(amoney);
order_m = order_m.toFixed(2);
- th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 })
}
} else {
- th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 })
}
//优惠活动送积分
if (good.s_intValue) {
txt = "formData.give_integral";
- th.setData({[txt]: good.s_intValue});
+ th.setData({ [txt]: good.s_intValue });
}
//优惠送券
if (good.s_coupon_id) {
var i_txt = "formData.give_coupon_id";
//这个是json格式的
var i_txt1 = "formData.g_coupon_num";
- var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}];
+ var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }];
ob = JSON.stringify(ob);
- th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob});
+ th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob });
}
//优惠礼包
if (good.s_libao) {
var l_txt = "formData.give_lb_id";
//这个是json格式的
var l_txt1 = "formData.g_lb_num";
- var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}];
+ var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }];
ob = JSON.stringify(ob);
- th.setData({[l_txt]: good.s_libao, [l_txt1]: ob});
+ th.setData({ [l_txt]: good.s_libao, [l_txt1]: ob });
}
})
} else {
var order_prom_txt1 = "formData.order_prom_id";
var order_prom_txt2 = "formData.order_prom_amount";
- th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0})
+ th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 })
total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price);
order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price);
@@ -857,7 +862,7 @@ Page({
total_m = total_m.toFixed(2);
order_m = order_m.toFixed(2);
- th.setData({[atxt]: total_m,})
+ th.setData({ [atxt]: total_m, })
var txt = "formData.user_money";
var txt2 = "formData.order_amount";
@@ -867,37 +872,37 @@ Page({
if (th.data.bn_use_money == 1) {
if (amoney > order_m) {
order_m = parseFloat(order_m).toFixed(2);
- th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 })
} else {
order_m = parseFloat(order_m) - parseFloat(amoney);
order_m = order_m.toFixed(2);
- th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 })
}
} else {
- th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 })
}
//优惠活动送积分
if (good.s_intValue) {
txt = "formData.give_integral";
- th.setData({[txt]: good.s_intValue});
+ th.setData({ [txt]: good.s_intValue });
}
//优惠送券
if (good.s_coupon_id) {
var i_txt = "formData.give_coupon_id";
//这个是json格式的
var i_txt1 = "formData.g_coupon_num";
- var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}];
+ var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }];
ob = JSON.stringify(ob);
- th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob});
+ th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob });
}
//优惠礼包
if (good.s_libao) {
var l_txt = "formData.give_lb_id";
//这个是json格式的
var l_txt1 = "formData.g_lb_num";
- var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}];
+ var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }];
ob = JSON.stringify(ob);
- th.setData({[l_txt]: good.s_coupon_id, [l_txt1]: ob});
+ th.setData({ [l_txt]: good.s_coupon_id, [l_txt1]: ob });
}
}
@@ -908,7 +913,7 @@ Page({
},
//--------------------提交订单-----------------------
- async submitForm(t){
+ async submitForm(t) {
var sub_value = t;
if (this.data.is_summit_ing == 1) return false; //--提交中退出--
@@ -981,7 +986,7 @@ Page({
}
//--判断优惠活动的提交--
- if (th.data.formData.cut_price > 0 ) {
+ if (th.data.formData.cut_price > 0) {
order_prom_list.discount_amount = th.data.formData.cut_price.toFixed(2);
var ob = [{
"prom_id": th.data.bn_goods.prom_id,
@@ -1044,7 +1049,7 @@ Page({
goods.guide_id = gg.guide_id;
goods.guide_type = gg.guide_type;
//调用接口判断是不是会员
- await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => {
+ await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => {
if (res.data.code == 0) {
goods.guide_name = res.data.data.salesman;
goods.guide_sn = res.data.data.salesman_no;
@@ -1096,7 +1101,7 @@ Page({
}
var pt_res = null;
- await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
+ await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
is_json: 1,
data: pt_data
}).then(res => {
@@ -1216,14 +1221,14 @@ Page({
order_prom_list.order_prom_amount = t_item.order_prom_amount;
}
- order_prom_list.discount_amount =0;
+ order_prom_list.discount_amount = 0;
//--判断优惠活动的提交--
if (t_item.cut_price > 0) {
order_prom_list.discount_amount += t_item.cut_price;
order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json);
}
//--判断组合优惠活动的提交--
- if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) {
+ if (t_item.zh_cut_price > 0 || t_item.zh_cut_price < 0) {
order_prom_list.discount_amount += t_item.zh_cut_price;
order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json);
}
@@ -1238,11 +1243,11 @@ Page({
order_prom_list.give_lb_id = t_item.s_libao;
order_prom_list.g_lb_num = JSON.stringify(t_item.g_lb_num);
}
- if (Object.keys(order_prom_list).length > 0){
- if(order_prom_list.discount_amount)
- order_prom_list.discount_amount= parseFloat(order_prom_list.discount_amount).toFixed(2);
- if(order_prom_list.order_prom_amount)
- order_prom_list.order_prom_amount= parseFloat(order_prom_list.order_prom_amount).toFixed(2);
+ if (Object.keys(order_prom_list).length > 0) {
+ if (order_prom_list.discount_amount)
+ order_prom_list.discount_amount = parseFloat(order_prom_list.discount_amount).toFixed(2);
+ if (order_prom_list.order_prom_amount)
+ order_prom_list.order_prom_amount = parseFloat(order_prom_list.order_prom_amount).toFixed(2);
item.order_prom_list = order_prom_list;
}
@@ -1266,7 +1271,7 @@ Page({
//-------------让商品添加到商品列表--------------------
for (var k = 0; k < t_item.goods.length; k++) {
var g_item = t_item.goods[k];
- if(g_item.goods_num<=0) continue;
+ if (g_item.goods_num <= 0) continue;
var goods = {
'goods_id': g_item.goods_id,
'goods_name': g_item.goods_name,
@@ -1279,7 +1284,7 @@ Page({
};
//-- 线下取价也要写入,组合购的商品不能去线下价格 --
- if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type!=7) {
+ if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type != 7) {
goods.goods_price = g_item.offline_price;
goods.member_goods_price = g_item.offline_price;
goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2);
@@ -1290,7 +1295,7 @@ Page({
if (t_item.quan_youhui_list && t_item.coupon_price) {
for (var kk in t_item.quan_youhui_list) {
var you_item = t_item.quan_youhui_list[kk];
- if (g_item.prom_type!=7 && g_item.erpwareid == you_item.WareId) {
+ if (g_item.prom_type != 7 && g_item.erpwareid == you_item.WareId) {
goods.quan_num = you_item.WareCashSum;
goods.quan_no = you_item.CashRepNo;
}
@@ -1341,7 +1346,7 @@ Page({
}
//把优惠的平摊结果写进去
- if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account!=undefined)) {
+ if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account != undefined)) {
if (g_item.account >= 0) goods.account = g_item.account;
if (g_item.account_yu != 0) goods.account_yu = g_item.account_yu;
item.is_discount_amount = 1;
@@ -1352,7 +1357,7 @@ Page({
goods.guide_id = g_item.guide_id;
goods.guide_type = g_item.guide_type;
//调用接口判断是不是会员
- await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => {
+ await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => {
if (res.data.code == 0) {
goods.guide_name = res.data.data.salesman;
goods.guide_sn = res.data.data.salesman_no;
@@ -1378,7 +1383,7 @@ Page({
if (pdata.length == 0) return;
var str = JSON.stringify(pdata);
- wx.showLoading({title: "加载中"});
+ wx.showLoading({ title: "加载中" });
wx.request({
url: oo.url + '/api/weshop/order/createWxdOrder',
data: str,
@@ -1409,7 +1414,7 @@ Page({
})
//要进行判断,如果是用微信支付,就要跳转到支付界面
if (order_amount > 0) {
- th.setData({isclose: 0});
+ th.setData({ isclose: 0 });
//void e.jumpToCart4({
// order_sn: data.data,
//}, 1);
@@ -1424,12 +1429,12 @@ Page({
}, function () {
//支付失败
setTimeout(function () {
- var cps=getCurrentPages();
- if(cps.length>1){
- wx.navigateBack({delta: 1})
- }else{
- getApp().goto("/pages/index/index/index");
- }
+ var cps = getCurrentPages();
+ if (cps.length > 1) {
+ wx.navigateBack({ delta: 1 })
+ } else {
+ getApp().goto("/pages/index/index/index");
+ }
}, 1000)
}, oo.stoid);
@@ -1447,7 +1452,7 @@ Page({
if (t.data.code == 0) {
//app.my_warnning("支付成功",1,th);
//setTimeout(function () {
- th.setData({isclose: 0});
+ th.setData({ isclose: 0 });
wx.redirectTo({
url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data,
})
@@ -1472,7 +1477,7 @@ Page({
cancelText: '取消',
confirmText: '确定',
showCancel: true,
- success(res){
+ success(res) {
if (res.cancel) {
return;
} else if (res.confirm) {
@@ -1506,11 +1511,11 @@ Page({
},
//---确认线下门店的数量足不足---
- async check_store_num(goods_id, pick, goods_num, func){
+ async check_store_num(goods_id, pick, goods_num, func) {
var lock = 0, pick_no, plist, erpwareid;
//先读取门店的lock
await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
- data: {store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000}
+ data: { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 }
}).then(res => {
if (res.data.code == 0 && res.data.data.total > 0) {
for (var i in res.data.data.pageData)
@@ -1519,7 +1524,7 @@ Page({
})
//先获取门店的编号
await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, {
- data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick}
+ data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick }
}).then(res => {
if (res.data.code == 0) {
pick_no = res.data.data.pickup_no;
@@ -1527,7 +1532,7 @@ Page({
})
//先获取商品的线下库存
await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, {
- data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick}
+ data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick }
}).then(res => {
if (res.data.code == 0) {
erpwareid = res.data.data.erpwareid;
@@ -1535,7 +1540,7 @@ Page({
})
//读取线下的门店库存
await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
- data: {storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000}
+ data: { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000 }
}).then(res => {
if (res.data.code == 0) {
plist = res.data.data.pageData[0];
@@ -1577,11 +1582,11 @@ Page({
wl_txt = t.currentTarget.dataset.wl_txt,
ont = t.currentTarget.dataset.ont;
- th.setData({[txt]: ty});
+ th.setData({ [txt]: ty });
var iszt = 1;
if (ty == 0) {
- th.setData({is_all_zt: 0});
+ th.setData({ is_all_zt: 0 });
} else {
for (var i = 0; i < th.data.cartlist.length; i++) {
var item = th.data.cartlist[i];
@@ -1591,7 +1596,7 @@ Page({
}
}
- th.setData({is_all_zt: iszt});
+ th.setData({ is_all_zt: iszt });
var ind = t.currentTarget.dataset.ind;
var c_item = th.data.cartlist[ind];
@@ -1599,7 +1604,7 @@ Page({
if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1) {
th.data.using_quan[pickid] = {};
- th.setData({using_quan: th.data.using_quan});
+ th.setData({ using_quan: th.data.using_quan });
}
@@ -1611,7 +1616,7 @@ Page({
for (var i = 0; i < wu_arr.length; i++) {
if (wu_arr[i].shipping_code == def_exp_code) {
var set_txt = "cartlist"
- th.setData({wl_txt: i});
+ th.setData({ wl_txt: i });
}
}
}
@@ -1624,9 +1629,9 @@ Page({
setexptype: function (t) {
var th = this;
var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code;
- th.setData({bn_exp_type: ty});
+ th.setData({ bn_exp_type: ty });
if (ty == 0) {
- th.setData({is_all_zt: 0});
+ th.setData({ is_all_zt: 0 });
}
//当物流为空的时候。
@@ -1639,7 +1644,7 @@ Page({
if (ty == 1) {
th.data.isget_by_quan = {};
if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby == 1) {
- th.setData({using_quan: {}});
+ th.setData({ using_quan: {} });
}
}
@@ -1649,7 +1654,7 @@ Page({
if (wu_arr != null && wu_arr != "") {
for (var i = 0; i < wu_arr.length; i++) {
if (wu_arr[i].shipping_code == def_exp_code) {
- th.setData({index: i});
+ th.setData({ index: i });
}
}
}
@@ -1661,21 +1666,21 @@ Page({
//--------立即购买时,使用余额--------
set_bn_useyuer: function () {
var th = this;
- th.setData({bn_use_money: !th.data.bn_use_money});
+ th.setData({ bn_use_money: !th.data.bn_use_money });
th.calculatePrice2();
},
set_js_useyuer: function () {
var th = this;
- th.setData({js_use_money: !th.data.js_use_money});
+ th.setData({ js_use_money: !th.data.js_use_money });
th.calculatePrice();
},
//-------------------计算物流---------------
- calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight,
- goods_piece, user_addr, freight_free, o_price, rs) {
+ calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight,
+ goods_piece, user_addr, freight_free, o_price, rs,pickid) {
var price = 0, th = this;
price += parseFloat(o_shipping_price);
//如果是包邮
- if (freight_free > 0 && o_price >= freight_free && out_of_weight > 0) {
+ if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) {
return 0;
}
if (user_addr == null) {
@@ -1693,7 +1698,7 @@ Page({
item = item.config;
if (item == null) return o_shipping_price;
//------按重量----------
- if (goods_weight >= 0 && item['money'] && out_of_weight > 0) {
+ if (goods_weight >= 0 && item['money']) {
fw_price = parseFloat(item['money']);
if (goods_weight > item['first_weight']) {
var fw = goods_weight - item['first_weight'];
@@ -1702,8 +1707,8 @@ Page({
}
}
- //------超出重量----------
- if(out_of_weight < 0){
+ //------超出重量----------
+ if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) {
fw_price = parseFloat(item['money']);
var out_of_weight = Math.abs(out_of_weight);
var n = Math.ceil(out_of_weight / item['second_weight'])
@@ -1746,13 +1751,13 @@ Page({
//----------立即购买,选择物流-------------
bindPickerChange: function (e) {
var ind = e.detail.value
- this.setData({index: ind});
+ this.setData({ index: ind });
this.calculatePrice2();
},
//----------购物车结算,选择物流-------------
bindPickerChange_w: function (e) {
var ind = e.detail.value, txt = e.currentTarget.dataset.txt;
- this.setData({[txt]: ind});
+ this.setData({ [txt]: ind });
this.calculatePrice();
},
@@ -1766,7 +1771,7 @@ Page({
if (bn == 1) {
- th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1});
+ th.setData({ open_quan: 1, selected_quan_pick: pickid, disabled: 1 });
} else {
//---多单打开券的时候,就要判断券在其他门店是否有使用---
var quanlist = th.data.cartlist[cindx].quan_list;
@@ -1792,9 +1797,9 @@ Page({
else
get_by_quan_list_cart[i].show_red = 0;
}
- th.setData({by_quan_list_cart: get_by_quan_list_cart});
+ th.setData({ by_quan_list_cart: get_by_quan_list_cart });
} else {
- th.setData({by_quan_list_cart: null});
+ th.setData({ by_quan_list_cart: null });
}
console.log("2222222券的列表", quanlist);
@@ -1810,7 +1815,7 @@ Page({
},
close_coupon: function (e) {
var th = this;
- th.setData({open_quan: 0, disabled: 0});
+ th.setData({ open_quan: 0, disabled: 0 });
},
//---判断券时候在已经选择的列表中---
@@ -1881,14 +1886,14 @@ Page({
for (var i in quanlist) {
quanlist[i].show_red = 0;
}
- this.setData({selected_quan_list: quanlist});
+ this.setData({ selected_quan_list: quanlist });
var by_quanlist = this.data.get_by_quan_list;
if (by_quanlist) {
//---所有的券的显示红色选择都清理一遍---
for (var inb in by_quanlist) {
by_quanlist[inb].show_red = 0;
}
- this.setData({get_by_quan_list: by_quanlist});
+ this.setData({ get_by_quan_list: by_quanlist });
}
var by_cart_list = this.data.by_quan_list_cart;
@@ -1897,7 +1902,7 @@ Page({
for (var inc in by_cart_list) {
by_cart_list[inc].show_red = 0;
}
- this.setData({by_quan_list_cart: by_cart_list});
+ this.setData({ by_quan_list_cart: by_cart_list });
}
var using_quan = this.data.using_quan;
@@ -1909,9 +1914,9 @@ Page({
using_quan[th.data.selected_quan_pick].is_nouse_red = 1;
}
else {
- using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1};
+ using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 };
}
- this.setData({using_quan: using_quan, is_coupon: 2222});
+ this.setData({ using_quan: using_quan, is_coupon: 2222 });
return;
}
@@ -1928,9 +1933,9 @@ Page({
using_quan[th.data.selected_quan_pick].is_nouse_red = 0;
}
else {
- using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0};
+ using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 };
}
- this.setData({using_quan: using_quan});
+ this.setData({ using_quan: using_quan });
},
@@ -1945,7 +1950,7 @@ Page({
for (var ind in by_quanlist) {
by_quanlist[ind].show_red = 0;
}
- this.setData({get_by_quan_list: by_quanlist});
+ this.setData({ get_by_quan_list: by_quanlist });
}
//--购物车过来的包邮券--
@@ -1955,7 +1960,7 @@ Page({
for (var ind in by_cart_list) {
by_cart_list[ind].show_red = 0;
}
- this.setData({by_quan_list_cart: by_cart_list});
+ this.setData({ by_quan_list_cart: by_cart_list });
}
//普通券
var quanlist = this.data.selected_quan_list;
@@ -1964,7 +1969,7 @@ Page({
for (var ind in quanlist) {
quanlist[ind].show_red = 0;
}
- this.setData({selected_quan_list: quanlist});
+ this.setData({ selected_quan_list: quanlist });
}
var th = this;
@@ -1975,9 +1980,9 @@ Page({
using_quan[th.data.selected_quan_pick].is_nouse_red = 1;
}
else {
- using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1};
+ using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 };
}
- this.setData({using_quan: using_quan, is_coupon: 2222});
+ this.setData({ using_quan: using_quan, is_coupon: 2222 });
return;
}
@@ -1988,20 +1993,20 @@ Page({
var txt1 = "";
var quan_item = null;
- quan_item = this.data.get_by_quan_list[ind];
- txt = "get_by_quan_list[" + ind + "].show_red";
- var obj = {};
- obj[txt] = 1;
- this.setData(obj);
+ quan_item = this.data.get_by_quan_list[ind];
+ txt = "get_by_quan_list[" + ind + "].show_red";
+ var obj = {};
+ obj[txt] = 1;
+ this.setData(obj);
if (using_quan[th.data.selected_quan_pick]) {
using_quan[th.data.selected_quan_pick].is_nouse_red = 0;
}
else {
- using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0};
+ using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 };
}
- this.setData({using_quan: using_quan});
+ this.setData({ using_quan: using_quan });
},
//--确认使用券---
@@ -2061,14 +2066,14 @@ Page({
//选择了的券,看是不是点击了不使用券,点击了不使用优惠券
if (using_quan[pickid]) {
if (using_quan[pickid].is_nouse_red == 1) {
- using_quan[pickid] = {is_nouse_red: 1};
- th.setData({using_quan: using_quan});
+ using_quan[pickid] = { is_nouse_red: 1 };
+ th.setData({ using_quan: using_quan });
if (th.data.is_b_now == 1) {
th.calculatePrice2();
} else {
th.calculatePrice();
}
- th.setData({open_quan: 0});
+ th.setData({ open_quan: 0 });
return;
}
}
@@ -2087,13 +2092,13 @@ Page({
};
using_quan[pickid].isby = 1;
} else {
- using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0};
+ using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 };
using_quan[pickid].isby = 0;
}
- this.setData({using_quan: using_quan});
+ this.setData({ using_quan: using_quan });
th.calculatePrice2();
- th.setData({open_quan: 0});
+ th.setData({ open_quan: 0 });
},
cart_set_err: function (e) {
@@ -2130,7 +2135,7 @@ Page({
var wu_arr_txt = e.currentTarget.dataset.txt;
var w_sele_index = e.currentTarget.dataset.w_sele_index;
var is_express = null;
- var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1};
+ var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 };
//--如果是多个门店的时候--
if (w_sele_index != undefined) {
@@ -2141,20 +2146,20 @@ Page({
},
// 关闭物流的弹窗
close_express: function () {
- this.setData({open_express: 0, disabled: 0});
+ this.setData({ open_express: 0, disabled: 0 });
},
// 选择物流
click_express_name: function (e) {
var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
var index = e.currentTarget.dataset.idxe;
- var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0};
+ var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 };
ob[this.data.wu_arr_txt] = index;
this.setData(ob);
},
//点击确定物流
determine_expres: function (e) {
- this.setData({open_express: 0});
+ this.setData({ open_express: 0 });
if (this.data.is_b_now == 1)
this.calculatePrice2();
else
@@ -2174,7 +2179,7 @@ Page({
obj[txt] = is_open;
this.setData(obj);
- this.setData({disabled: 1})
+ this.setData({ disabled: 1 })
},
clik_coupons2: function (e) {
@@ -2189,7 +2194,7 @@ Page({
obj[txt] = is_open;
this.setData(obj);
- this.setData({disabled: 1})
+ this.setData({ disabled: 1 })
},
@@ -2198,11 +2203,11 @@ Page({
var th = this;
var is_shipping_code = this.data.is_shipping_code
getApp().request.put("/api/weshop/users/update", {
- data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code},
+ data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code },
success: function (rse) {
if (rse.data.code == 0) {
getApp().globalData.userInfo.def_exp_code = is_shipping_code;
- th.setData({open_express: 0});
+ th.setData({ open_express: 0 });
//----计算此时购物车的价格----
if (th.data.is_b_now == 1) th.calculatePrice2();
else th.calculatePrice();
@@ -2212,7 +2217,7 @@ Page({
},
//更新下默认,在onshow里面
- update_code(){
+ update_code() {
var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
//--定时器,判断wu_arr不未空--
var uii = setInterval(function () {
@@ -2226,7 +2231,7 @@ Page({
}
//--如果是立即购买--
if (th.data.is_b_now == 1) {
- th.setData({index: m_wind, is_express: m_wind});
+ th.setData({ index: m_wind, is_express: m_wind });
} else {
var ui = setInterval(function () {
if (th.data.cartlist) {
@@ -2234,7 +2239,7 @@ Page({
for (var i in c_arr) {
c_arr[i].wind = m_wind;
}
- th.setData({cartlist: c_arr, is_express: m_wind})
+ th.setData({ cartlist: c_arr, is_express: m_wind })
clearInterval(ui);
}
}, 500)
@@ -2335,10 +2340,10 @@ Page({
if (th.data.is_b_now) {
if (arr && arr.length > 0) {
var quanlist = arr[0].quan_list;
- th.setData({selected_quan_list: quanlist, cartlist: arr})
+ th.setData({ selected_quan_list: quanlist, cartlist: arr })
}
} else {
- th.setData({cartlist: arr})
+ th.setData({ cartlist: arr })
th.set_can_num();
}
@@ -2358,7 +2363,7 @@ Page({
if (th.data.is_close_quan != 1 && th.data.bn_goods.is_xz_yh != 1) {
var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
var url = "/api/weshop/couponList/getUseCouponList";
- app.request.promiseGet(url0, {1: 1}).then(res => {
+ app.request.promiseGet(url0, { 1: 1 }).then(res => {
if (res.data.code == 0) {
frozenQuan = res.data.data;
th.data.frozenQuan = frozenQuan;
@@ -2376,7 +2381,7 @@ Page({
quanlist = res.data.data.pageData;
if (quanlist) {
quanlist = th.check_is_frozenQuan(quanlist, frozenQuan);
- th.setData({selected_quan_list: quanlist})
+ th.setData({ selected_quan_list: quanlist })
}
}
}
@@ -2404,7 +2409,7 @@ Page({
if (!goods_id) goods_id = this.data.bn_goods.goods_id;
for (var i in arr) {
var item = arr[i];
- if (goods_id == item) return 0;
+ if (goods_id == item) return 0;
}
return 1;
},
@@ -2475,7 +2480,7 @@ Page({
pick = this.data.bn_pick;
//---获取订单优惠---
getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
- data: {store_id: os.stoid, orderAmount: condition}
+ data: { store_id: os.stoid, orderAmount: condition }
}).then(res => {
if (res.data.code == 0) {
var data = res.data.data;
@@ -2497,7 +2502,7 @@ Page({
var ob = map[pickid][item.prom_id];
ob.price += item.goods_price * item.goods_num;
ob.goods_num += item.goods_num;
- ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
+ ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num });
} else {
var prom = null;
@@ -2513,7 +2518,7 @@ Page({
ob.is_bz = prom.is_bz;
ob.is_xz_yh = prom.is_xz_yh;
ob.goods = new Array();
- ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
+ ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num });
map[pickid][item.prom_id] = ob;
}
} else {
@@ -2530,7 +2535,7 @@ Page({
ob.is_bz = prom.is_bz;
ob.is_xz_yh = prom.is_xz_yh;
ob.goods = new Array();
- ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
+ ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num });
var obj = {};
obj[item.prom_id] = ob;
@@ -2540,7 +2545,7 @@ Page({
},
//计算立即购买赠品的物流费用
- get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,gift_weight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
+ get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, gift_weight_free, out_of_weight, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1,pickid) {
var good = this.data.buy_now_gift_goods;
var goods_weight = -1, goods_piece = -1;
var gift_shipping_price = 0;
@@ -2556,8 +2561,9 @@ Page({
//累积商品重量 每种商品的重量 * 数量
goods_weight += good['weight'] * good['buynum'];
if (goods_weight1 > 0) {
+ out_of_weight = gift_weight_free - goods_weight;
+ //不能调换位置 下面goods_weight会变大
goods_weight += goods_weight1;
- out_of_weight = (gift_weight_free*1000) - goods_weight;
}
break;
case 3:
@@ -2575,6 +2581,7 @@ Page({
if (no_by_data && no_by_data.region_list) {
if (th.check_by_area(no_by_data.region_list)) {
gift_freight_free = 0;
+ out_of_weight = 0;
th.data.is_no_by[th.data.bn_pick] = 1;
}
}
@@ -2582,13 +2589,14 @@ Page({
if (no_by_data && no_by_data.goods_list && gift_freight_free) {
if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) {
gift_freight_free = 0;
- //th.data.is_no_by[th.data.bn_pick]=1;
+ out_of_weight = 0;
+ th.data.is_no_by[th.data.bn_pick]=1;
}
}
var t_shipping_price =
- this.calculatewuliu(code, gift_shipping_price, goods_weight,
- goods_piece, user_addr, gift_freight_free, allpice, rs);
+ this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight,
+ goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick);
return t_shipping_price;
},
@@ -2645,7 +2653,7 @@ Page({
//跳转关闭弹出框的显示
close_offline: function () {
- this.setData({is_offline_show: 0});
+ this.setData({ is_offline_show: 0 });
},
//立即购买显示弹出框
@@ -2653,7 +2661,7 @@ Page({
var off_price = this.data.bn_goods.shop_price - this.data.bn_goods.offline_price;
//是不是线下
var is_get_offline = this.data.bn_goods.is_offline;
- this.setData({is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline});
+ this.setData({ is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline });
},
//确定使用线下取价
@@ -2661,14 +2669,14 @@ Page({
var bn_goods = this.data.bn_goods;
if (bn_goods && bn_goods.prom_type == 0) {
bn_goods.is_offline = 1;
- this.setData({is_offline_show: 0, bn_goods: bn_goods});
+ this.setData({ is_offline_show: 0, bn_goods: bn_goods });
this.calculatePrice2();
}
//就是购物车结算时的
else {
var index = this.data.pop_offline_index;
var txt = "cartlist[" + index + "].is_offline";
- this.setData({[txt]: 1, is_offline_show: 0,});
+ this.setData({ [txt]: 1, is_offline_show: 0, });
this.data.old_cartlist[index].is_offline = 1;
this.calculatePrice();
}
@@ -2681,14 +2689,14 @@ Page({
var bn_goods = this.data.bn_goods;
if (bn_goods && bn_goods.prom_type == 0) {
bn_goods.is_offline = 0;
- this.setData({is_offline_show: 0, bn_goods: bn_goods});
+ this.setData({ is_offline_show: 0, bn_goods: bn_goods });
this.calculatePrice2();
}
//就是购物车结算时的
else {
var index = this.data.pop_offline_index;
var txt = "cartlist[" + index + "].is_offline";
- this.setData({[txt]: 0, is_offline_show: 0,})
+ this.setData({ [txt]: 0, is_offline_show: 0, })
this.data.old_cartlist[index].is_offline = 0;
this.calculatePrice();
}
@@ -2709,16 +2717,16 @@ Page({
});
},
- set_hid_inp:function (e) {
+ set_hid_inp: function (e) {
var index = e.currentTarget.dataset.index;
var txt = "cartlist[" + index + "].focus";
- this.setData({[txt]:1})
+ this.setData({ [txt]: 1 })
},
- clear_hid_inp:function (e) {
+ clear_hid_inp: function (e) {
var index = e.currentTarget.dataset.index;
var txt = "cartlist[" + index + "].focus";
- this.setData({[txt]:0})
+ this.setData({ [txt]: 0 })
},
diff --git a/packageC/pages/presell/cart/cart2_pre.js b/packageC/pages/presell/cart/cart2_pre.js
index 39a3410..71625c1 100644
--- a/packageC/pages/presell/cart/cart2_pre.js
+++ b/packageC/pages/presell/cart/cart2_pre.js
@@ -1,5 +1,5 @@
-var t = getApp(),app=t, a = t.request, ut = require("../../../../utils/util.js");
-var os=t.globalData.setting;
+var t = getApp(), app = t, a = t.request, ut = require("../../../../utils/util.js");
+var os = t.globalData.setting;
var regeneratorRuntime = require('../../../../utils/runtime.js');
var util_pay = require("../../../../utils/pay.js");
@@ -20,132 +20,132 @@ Page({
enterAddressPage: !1,
firstEnter: !0,
//页面获取的参数
- param:null,
- postdata:null,
+ param: null,
+ postdata: null,
//提交订单的格式
formData: {
- order_amount:0,//支付金额
- total_amount:0,//总价
- all_price:0,//商品卖的总价
+ order_amount: 0,//支付金额
+ total_amount: 0,//总价
+ all_price: 0,//商品卖的总价
pay_points: 0,//使用积分
user_money: 0,//使用余额
couponCode: "",//使用优惠券(多单就用逗号隔开)
- shipping_price:0,//物流费用
+ shipping_price: 0,//物流费用
},
/*----------------立即购买---------------------*/
- is_b_now:0, //0是购物车结算 1立即购买
- bn_goods:null, //立即购买时候的调用商品
- bn_use_money:0,//是否使用余额
- bn_exp_type:1, //0是物流 1自提
- bn_pick:0, //选择的门店
+ is_b_now: 0, //0是购物车结算 1立即购买
+ bn_goods: null, //立即购买时候的调用商品
+ bn_use_money: 0,//是否使用余额
+ bn_exp_type: 1, //0是物流 1自提
+ bn_pick: 0, //选择的门店
bn_pickname: "", //选择的门店名称
- bn_t_exp_t:0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流
+ bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流
/*------------------------*/
- user_addr:null,//物流
- userinfo:null, //获取会员
+ user_addr: null,//物流
+ userinfo: null, //获取会员
/*----------物流选择--------*/
- wu_arr:null,
- index:0,
+ wu_arr: null,
+ index: 0,
//判断页面是返回回来的还是 首次进入的
- isclose:1,
- is_express:0,//选择物流的控制器
- yuer:0,
- agree_no_ref:0
+ isclose: 1,
+ is_express: 0,//选择物流的控制器
+ yuer: 0,
+ agree_no_ref: 0
},
- onLoad: function(t) {
+ onLoad: function (t) {
wx.setNavigationBarTitle({
title: "填写订单",
});
- var th = this; this.setData({ is_b_now: 1});
- th.data.postdata=getApp().get_b_now();
- th.data.param=t;
-
+ var th = this; this.setData({ is_b_now: 1 });
+ th.data.postdata = getApp().get_b_now();
+ th.data.param = t;
+
},
- onUnload: function () { this.setData({ isclose: 1 })},
+ onUnload: function () { this.setData({ isclose: 1 }) },
//------获取会员信息-----先获取用户信息,在进行下一步---
- get_info:function(func){
- var user_id = t.globalData.user_id;
- app.auth.get_u(func);
+ get_info: function (func) {
+ var user_id = t.globalData.user_id;
+ app.auth.get_u(func);
},
//-------------------获取物流---------------
get_wuliu(func) {
- var th = this;
- app.getwuliu(function (e) {
- if (th.data.is_default_logistics) {
- //如果第一个不是开启默认,说明要让用户自己选
- if (!e[0].is_default) {
- th.setData({ is_default_logistics: 0 });
- }
- }
- th.setData({ wu_arr: e })
- typeof func == "function" && func();
- })
+ var th = this;
+ app.getwuliu(function (e) {
+ if (th.data.is_default_logistics) {
+ //如果第一个不是开启默认,说明要让用户自己选
+ if (!e[0].is_default) {
+ th.setData({ is_default_logistics: 0 });
+ }
+ }
+ th.setData({ wu_arr: e })
+ typeof func == "function" && func();
+ })
},
//------获取会员收货地址-----
- getuser_addr:function(func){
- if (app.globalData.baddr!=null){
- var user_addr =app.globalData.baddr;
- app.globalData.baddr=null;
- func(user_addr);
- }else{
- a.get("/api/weshop/useraddress/page", {
- data: { user_id:app.globalData.user_id, store_id: os.stoid, pageSize: 600 },
- success: function (su) {
-
- var user_addr = su.data.data.pageData;
- var item = null;
- var def_item=null;
- for (var i = 0; i < user_addr.length; i++) {
- if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; }
- if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; }
- }
- if (item == null) item = def_item;
- if (item == null) item = user_addr[0];
- if (item == undefined) item = null;
- func(item);
- }
- });
- }
+ getuser_addr: function (func) {
+ if (app.globalData.baddr != null) {
+ var user_addr = app.globalData.baddr;
+ app.globalData.baddr = null;
+ func(user_addr);
+ } else {
+ a.get("/api/weshop/useraddress/page", {
+ data: { user_id: app.globalData.user_id, store_id: os.stoid, pageSize: 600 },
+ success: function (su) {
+
+ var user_addr = su.data.data.pageData;
+ var item = null;
+ var def_item = null;
+ for (var i = 0; i < user_addr.length; i++) {
+ if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; }
+ if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; }
+ }
+ if (item == null) item = def_item;
+ if (item == null) item = user_addr[0];
+ if (item == undefined) item = null;
+ func(item);
+ }
+ });
+ }
},
//----------------展示页面,是再获取用户信息之后--------------
- show_page:function(){
- var th=this;
- var user=getApp().globalData.userInfo;
- getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + user.user_id, {
- data:{r:Math.random()},
- success: function (e) {
-
- getApp().globalData.userInfo = e.data.data;
- th.setData({userinfo:e.data.data});
- //获取立即购买的商品信息
- th.get_buy_goods();
-
- //获取提现金额
- getApp().request.get("/api/weshop/withdrawals/summoney", {
- data: { user_id:app.globalData.user_id, store_id: os.stoid, status: 0 },
- success: function (su) {
- if (su.data.code == 0) {
- var yuer = parseFloat(th.data.userinfo.user_money -
- (th.data.userinfo.frozen_money>0?th.data.userinfo.frozen_money:0) - su.data.data.summoney).toFixed(2);
- if(yuer<0) yuer=0;
- th.setData({ txmon: su.data.data.summoney, yuer: yuer });
- }
- }
- });
- }
- });
+ show_page: function () {
+ var th = this;
+ var user = getApp().globalData.userInfo;
+ getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + user.user_id, {
+ data: { r: Math.random() },
+ success: function (e) {
+
+ getApp().globalData.userInfo = e.data.data;
+ th.setData({ userinfo: e.data.data });
+ //获取立即购买的商品信息
+ th.get_buy_goods();
+
+ //获取提现金额
+ getApp().request.get("/api/weshop/withdrawals/summoney", {
+ data: { user_id: app.globalData.user_id, store_id: os.stoid, status: 0 },
+ success: function (su) {
+ if (su.data.code == 0) {
+ var yuer = parseFloat(th.data.userinfo.user_money -
+ (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2);
+ if (yuer < 0) yuer = 0;
+ th.setData({ txmon: su.data.data.summoney, yuer: yuer });
+ }
+ }
+ });
+ }
+ });
},
//-----获取立即购买的商品信息----
get_buy_goods: async function () {
var th = this, a = getApp().request;
//定义变量
- var gg = th.data.postdata,act = null,prelist = null;
+ var gg = th.data.postdata, act = null, prelist = null;
var url = "/api/weshop/marketing/marketingPresellForm/get/" + os.stoid + "/" + gg.prom_id;
await getApp().request.promiseGet(url, {}).then(res => {
if (res.data.code == 0) {
@@ -153,15 +153,15 @@ Page({
}
})
if (!act) {
- wx.showToast({title: "未找到活动", icon: 'none', duration: 3000});
+ wx.showToast({ title: "未找到活动", icon: 'none', duration: 3000 });
return false;
}
- if (act.is_end==1 ) {
- wx.showToast({title:'活动已经结束' , icon: 'none', duration: 3000});
+ if (act.is_end == 1) {
+ wx.showToast({ title: '活动已经结束', icon: 'none', duration: 3000 });
return false;
}
- if( ut.gettimestamp()>act.end_time){
- wx.showToast({title:"活动定金支付时间已过期" , icon: 'none', duration: 3000});
+ if (ut.gettimestamp() > act.end_time) {
+ wx.showToast({ title: "活动定金支付时间已过期", icon: 'none', duration: 3000 });
return false;
}
@@ -172,7 +172,7 @@ Page({
}
})
if (!prelist) {
- wx.showToast({title: "未找到商品", icon: 'none', duration: 3000});
+ wx.showToast({ title: "未找到商品", icon: 'none', duration: 3000 });
return false;
}
//-- 调用商品 --
@@ -191,7 +191,7 @@ Page({
distr_t = t.data.data.distr_type;
}
- if(act.presell_type==1){
+ if (act.presell_type == 1) {
switch (distr_t) {
case 0:
et = 1;
@@ -205,13 +205,13 @@ Page({
et = 0;
break;
}
- }else{
- et=1; //要付定金的时候
+ } else {
+ et = 1; //要付定金的时候
}
t.data.data.shop_price = prelist.presell_money;
th.setData({
- bn_goods: t.data.data, bn_pickname: gg.pick_name,prelist:prelist,act:act,
+ bn_goods: t.data.data, bn_pickname: gg.pick_name, prelist: prelist, act: act,
bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et
});
//计算价格
@@ -222,263 +222,269 @@ Page({
//----------子页返回父页触发----------
onShow: function () {
- var th = this;
- if (th.data.isclose == 0) {
- wx.navigateTo({
- url: "/pages/index/index/index"
- })
- } else {
- this.getuser_addr(function (ie) {
- //更换地址回来要重新调用计算价钱的接口
- th.setData({ user_addr: ie });
- if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
- th.setData({ add_back: 1 });
- if (this.data.bn_goods) th.calculatePrice2();
- }
- })
- //--更新默认地址--,看一下是不是跳到地址页面
- if (!getApp().globalData.is_cart_old) {
- this.update_code();
+ var th = this;
+ if (th.data.isclose == 0) {
+ wx.navigateTo({
+ url: "/pages/index/index/index"
+ })
} else {
- getApp().globalData.is_cart_old = 0;
- }
- }
-
- //先获取是否有关闭使用优惠券
- getApp().getConfig2(function (ee) {
- var json_d = JSON.parse(ee.switch_list);
- th.data.json_d = json_d;
- th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值
- var is_default_logistics = json_d.is_default_logistics;
-
- th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics });
-
- var rank_switch = json_d.rank_switch;
- var max_price = -1;
- var show_card = null;
- var name = "";
- //如果有开等级卡的时候,
- //因为都是调接口,要返回在计算
- if (rank_switch == 2) {
- //-- 获取所有的等级卡, --
- getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid,
- {}).then(res => {
- if (res.data.code == 0) {
- var plusCard = res.data.data;
- //-- 循环判断,拿到最贵的那张卡 --
- for (var ih in plusCard) {
- if (plusCard[ih].IsStopBuy == true) { continue; }
- if (max_price < 0) {
- max_price = plusCard[ih].CardFee;
- name = 'card' + plusCard[ih]['CorrPrice'];
- show_card = plusCard[ih];
- } else {
- if (max_price < plusCard[ih].CardFee) {
- max_price = plusCard[ih].CardFee;
- name = 'card' + plusCard[ih]['CorrPrice'];
- show_card = plusCard[ih];
- }
- }
- }
-
- if (show_card) {
- name = name.toLowerCase();
- th.setData({ card_name: name, show_card: show_card })
+ this.getuser_addr(function (ie) {
+ //更换地址回来要重新调用计算价钱的接口
+ th.setData({ user_addr: ie });
+ if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
+ th.setData({ add_back: 1 });
+ if (this.data.bn_goods) th.calculatePrice2();
}
- }
- //-----先获取物流,再获取用户信息,再展示页面-----
- th.get_wuliu(th.get_info(th.show_page));
})
- } else {
- //-----先获取物流,再获取用户信息,再展示页面-----
- th.get_wuliu(th.get_info(th.show_page));
+ //--更新默认地址--,看一下是不是跳到地址页面
+ if (!getApp().globalData.is_cart_old) {
+ this.update_code();
+ } else {
+ getApp().globalData.is_cart_old = 0;
+ }
}
- }, 1)
+
+ //先获取是否有关闭使用优惠券
+ getApp().getConfig2(function (ee) {
+ var json_d = JSON.parse(ee.switch_list);
+ th.data.json_d = json_d;
+ th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值
+ var is_default_logistics = json_d.is_default_logistics;
+
+ th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics });
+
+ var rank_switch = json_d.rank_switch;
+ var max_price = -1;
+ var show_card = null;
+ var name = "";
+ //如果有开等级卡的时候,
+ //因为都是调接口,要返回在计算
+ if (rank_switch == 2) {
+ //-- 获取所有的等级卡, --
+ getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid,
+ {}).then(res => {
+ if (res.data.code == 0) {
+ var plusCard = res.data.data;
+ //-- 循环判断,拿到最贵的那张卡 --
+ for (var ih in plusCard) {
+ if (plusCard[ih].IsStopBuy == true) { continue; }
+ if (max_price < 0) {
+ max_price = plusCard[ih].CardFee;
+ name = 'card' + plusCard[ih]['CorrPrice'];
+ show_card = plusCard[ih];
+ } else {
+ if (max_price < plusCard[ih].CardFee) {
+ max_price = plusCard[ih].CardFee;
+ name = 'card' + plusCard[ih]['CorrPrice'];
+ show_card = plusCard[ih];
+ }
+ }
+ }
+
+ if (show_card) {
+ name = name.toLowerCase();
+ th.setData({ card_name: name, show_card: show_card })
+ }
+ }
+ //-----先获取物流,再获取用户信息,再展示页面-----
+ th.get_wuliu(th.get_info(th.show_page));
+ })
+ } else {
+ //-----先获取物流,再获取用户信息,再展示页面-----
+ th.get_wuliu(th.get_info(th.show_page));
+ }
+ }, 1)
},
//---------------检查是否有收货地址-------------------
- checkAddressList: function() {
+ checkAddressList: function () {
var t = this;
return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({
title: "请先填写或选择收货地址~",
- success: function(a) {
+ success: function (a) {
a.confirm ? t.enterAddressPage() : wx.navigateBack();
},
- fail: function() {
+ fail: function () {
wx.navigateBack();
}
}), !1);
},
- showInvoice: function() {
+ showInvoice: function () {
this.setData({
invoiceToggle: !this.data.invoiceToggle
});
},
- keyUpChangePay1: function(t) {
+ keyUpChangePay1: function (t) {
this.setData({
payWithUserMoney: !(t.detail.value.length > 0)
});
},
- keyUpChangePay2: function(t) {
+ keyUpChangePay2: function (t) {
this.setData({
payWithPoints: !(t.detail.value.length > 0)
});
},
- keyUpChangeNum: function(t) {
+ keyUpChangeNum: function (t) {
this.setData({
maxWord: t.detail.value.length
});
},
//---------计算立即购买----------
calculatePrice2: function () {
- console.log('calculatePrice2');
- var th = this, good = this.data.bn_goods;
- //-----------计算商品总价--------------
- var allpice = good.shop_price * good.buynum;
- allpice=parseFloat(allpice).toFixed(2);
- var txt = "formData.all_price";
- th.setData({ [txt]: allpice, });
- console.log(th.data.formData);
-
- app.getConfig2(function (ee) {
- app.getwuliuprice(function (rs) {
- var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
- //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格----------
- if (th.data.user_addr != null && th.data.bn_exp_type == 0
- && good.is_free_shipping == 0 && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){
- switch (good['exp_sum_type']) {
- case 1:
- //统一运费
- o_shipping_price += good['uniform_exp_sum']; break;
- case 2:
- if (goods_weight < 0) goods_weight = 0;
- //累积商品重量 每种商品的重量 * 数量
- goods_weight += good['weight'] * good['buynum'];break;
- case 3:
- if (goods_piece < 0) goods_piece = 0;
- //累积商品数量
- goods_piece += good['buynum']; break;
- }
-
- var code = th.data.wu_arr[th.data.index].code;
- var freight_free = ee.freight_free; //全场满多少包邮
- var shipping_price=
- th.calculatewuliu(code, o_shipping_price, goods_weight,
+ console.log('calculatePrice2');
+ var th = this, good = this.data.bn_goods;
+ //-----------计算商品总价--------------
+ var allpice = good.shop_price * good.buynum;
+ allpice = parseFloat(allpice).toFixed(2);
+ var txt = "formData.all_price";
+ th.setData({ [txt]: allpice, });
+ console.log(th.data.formData);
+
+ app.getConfig2(function (ee) {
+ app.getwuliuprice(function (rs) {
+ var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
+ var out_of_weight = null; //超出多少重量
+ var freight_free = ee.freight_free; //全场满多少包邮
+ var weight_free = ee.weight_free; //多少kg内包邮
+ var no_ex_id = ee.no_ex_id;
+ //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格----------
+ if (th.data.user_addr != null && th.data.bn_exp_type == 0
+ && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
+ switch (good['exp_sum_type']) {
+ case 1:
+ //统一运费
+ o_shipping_price += good['uniform_exp_sum']; break;
+ case 2:
+ if (goods_weight < 0) goods_weight = 0;
+ //累积商品重量 每种商品的重量 * 数量
+ goods_weight += good['weight'] * good['buynum'];
+ if (weight_free > 0) {
+ out_of_weight = (weight_free * 1000) - goods_weight;
+ }
+ break;
+ case 3:
+ if (goods_piece < 0) goods_piece = 0;
+ //累积商品数量
+ goods_piece += good['buynum']; break;
+ }
+
+ var code = th.data.wu_arr[th.data.index].code;
+ var shipping_price =
+ th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
goods_piece, th.data.user_addr, freight_free, allpice, rs);
- shipping_price = parseFloat(shipping_price).toFixed(2);
- var wl_txt = "formData.shipping_price";
- th.setData({ [wl_txt]: shipping_price, })
-
- }else{
- var wl_txt = "formData.shipping_price";
- th.setData({ [wl_txt]: 0, })
- }
- //-----------------总价-----------------
- var total_m = parseFloat(allpice) + parseFloat( th.data.formData.shipping_price);
- total_m = parseFloat(total_m).toFixed(2);
-
- var atxt= "formData.total_amount";
- th.setData({ [atxt]: total_m, })
- var order_m = total_m;
-
- var txt = "formData.user_money";
- var txt2 = "formData.order_amount";
- //--------------如果使用余额---------------------
- if (th.data.bn_use_money == 1 && th.data.yuer>0) {
- if ( parseFloat(th.data.yuer) > total_m) {
- th.setData({ [txt]: total_m, [txt2]:0 })
- }else{
- order_m = parseFloat(order_m) - parseFloat(th.data.yuer);
- order_m = order_m.toFixed(2);
- th.setData({ [txt]: th.data.yuer, [txt2]: order_m })
- }
- }else{
+ shipping_price = parseFloat(shipping_price).toFixed(2);
+ var wl_txt = "formData.shipping_price";
+ th.setData({ [wl_txt]: shipping_price, })
+
+ } else {
+ var wl_txt = "formData.shipping_price";
+ th.setData({ [wl_txt]: 0, })
+ }
+ //-----------------总价-----------------
+ var total_m = parseFloat(allpice) + parseFloat(th.data.formData.shipping_price);
+ total_m = parseFloat(total_m).toFixed(2);
+
+ var atxt = "formData.total_amount";
+ th.setData({ [atxt]: total_m, })
+ var order_m = total_m;
+
+ var txt = "formData.user_money";
+ var txt2 = "formData.order_amount";
+ //--------------如果使用余额---------------------
+ if (th.data.bn_use_money == 1 && th.data.yuer > 0) {
+ if (parseFloat(th.data.yuer) > total_m) {
+ th.setData({ [txt]: total_m, [txt2]: 0 })
+ } else {
+ order_m = parseFloat(order_m) - parseFloat(th.data.yuer);
+ order_m = order_m.toFixed(2);
+ th.setData({ [txt]: th.data.yuer, [txt2]: order_m })
+ }
+ } else {
th.setData({ [txt]: 0, [txt2]: order_m })
- }
+ }
- });
- });
+ });
+ });
},
// -- 支付的下一步 --
- submitForm_next:async function(t){
- if(this.data.is_summit_ing==1) return false; //--提交中退出--
- this.data.is_summit_ing=1;
+ submitForm_next: async function (t) {
+ if (this.data.is_summit_ing == 1) return false; //--提交中退出--
+ this.data.is_summit_ing = 1;
- var th=this,pdata=new Array();
- var ff=true;
+ var th = this, pdata = new Array();
+ var ff = true;
//------------立即购买-------------
//如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候
- if(th.data.bn_exp_type == 0 && th.data.user_addr==null && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){
+ if (th.data.bn_exp_type == 0 && th.data.user_addr == null && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
ff = false;
- getApp().my_warnning("请选择收货地址",0,this);
+ getApp().my_warnning("请选择收货地址", 0, this);
this.data.is_summit_ing = 0;
}
if (!ff) return false;
var addr = th.data.user_addr;
- if (th.data.bn_exp_type == 1) addr=null;
+ if (th.data.bn_exp_type == 1) addr = null;
- if(th.data.bn_exp_type==0 && (th.data.kt_type!=3)) {
+ if (th.data.bn_exp_type == 0 && (th.data.kt_type != 3)) {
if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
- getApp().my_warnning("读取物流失败",0,this);
+ getApp().my_warnning("读取物流失败", 0, this);
this.data.is_summit_ing = 0;
return false;
}
}
//阶梯团强制带1,自提~~~
- if(th.data.kt_type==3 ){
- th.data.bn_exp_type=1;
+ if (th.data.kt_type == 3) {
+ th.data.bn_exp_type = 1;
}
- var item={
- 'user_id':app.globalData.user_id,
+ var item = {
+ 'user_id': app.globalData.user_id,
'consignee': addr == null ? "" : addr.consignee,
'province': addr == null ? 0 : addr.province,
'city': addr == null ? 0 : addr.city,
'district': addr == null ? 0 : addr.district,
'twon': addr == null ? 0 : addr.twon,
- 'address': addr == null ? "": addr.address,
+ 'address': addr == null ? "" : addr.address,
'more_address': addr == null ? "" : addr.more_address,
- 'mobile': addr == null ? th.data.userinfo.mobile:addr.mobile,
- 'email':'',
- 'invoice_title':'',
+ 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile,
+ 'email': '',
+ 'invoice_title': '',
'goods_price': th.data.formData.all_price, //商品总价
'shipping_price': th.data.formData.shipping_price, //物流金额
'user_money': th.data.formData.user_money, //使用余额
'total_amount': th.data.formData.total_amount, //订单总价
'order_amount': th.data.formData.order_amount, //应付
'user_note': t.detail.value.user_note, //用户备注
- 'store_id':os.stoid, //商家
+ 'store_id': os.stoid, //商家
'pickup_id': th.data.bn_pick, //门店
- 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
+ 'prom_type': th.data.bn_goods.prom_type, //促销活动类型
'prom_id': th.data.bn_goods.prom_id, //促销活动id
- 'order_goods':new Array(),
+ 'order_goods': new Array(),
};
//老会员成为分销下线需要的参数
- if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){
+ if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) {
//判断一下分享人是不是分享商
- await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{
- if(res.data.code==0){
- var user= res.data.data;
- if(user.is_distribut==1){
- item.first_leader=parseInt(getApp().globalData.first_leader);
+ await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => {
+ if (res.data.code == 0) {
+ var user = res.data.data;
+ if (user.is_distribut == 1) {
+ item.first_leader = parseInt(getApp().globalData.first_leader);
}
}
})
}
- if(th.data.qh!='')
- {
- item.team_qh=th.data.qh;
- item.pt_listno=th.data.qh;
+ if (th.data.qh != '') {
+ item.team_qh = th.data.qh;
+ item.pt_listno = th.data.qh;
}
- var gg =app.get_b_now();
- var goods={
+ var gg = app.get_b_now();
+ var goods = {
'goods_id': gg.goods_id,
'goods_name': gg.goods_name,
'goods_sn': gg.goods_sn,
@@ -487,37 +493,37 @@ Page({
'goods_price': th.data.bn_goods.shop_price,
'member_goods_price': th.data.bn_goods.shop_price,
'store_id': os.stoid,
- 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
+ 'prom_type': th.data.bn_goods.prom_type, //促销活动类型
'prom_id': th.data.bn_goods.prom_id, //促销活动id
};
//--导购分享过来的id--
- if(gg.guide_id){
- goods.guide_id=gg.guide_id;
- goods.guide_type=gg.guide_type;
+ if (gg.guide_id) {
+ goods.guide_id = gg.guide_id;
+ goods.guide_type = gg.guide_type;
//调用接口判断是不是会员
- await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/"+os.stoid+"/"+gg.guide_id,{}).then(res=>{
- if(res.data.code==0){
- goods.guide_name=res.data.data.salesman;
- goods.guide_sn=res.data.data.salesman_no;
+ await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + os.stoid + "/" + gg.guide_id, {}).then(res => {
+ if (res.data.code == 0) {
+ goods.guide_name = res.data.data.salesman;
+ goods.guide_sn = res.data.data.salesman_no;
}
})
}
//--商品的房间号--
- if(gg.room_id && gg.room_id>0){
- item.room_ids=gg.room_id;
- goods.room_id=gg.room_id;
+ if (gg.room_id && gg.room_id > 0) {
+ item.room_ids = gg.room_id;
+ goods.room_id = gg.room_id;
}
- if(th.data.bn_goods.is_normal){goods.is_pd_normal=1;}
+ if (th.data.bn_goods.is_normal) { goods.is_pd_normal = 1; }
item.order_goods.push(goods);
pdata.push(item);
- if (pdata.length==0) return;
+ if (pdata.length == 0) return;
var str = JSON.stringify(pdata);
- wx.showLoading({title: "加载中"});
+ wx.showLoading({ title: "加载中" });
wx.request({
url: os.url + '/api/weshop/order/createWxdOrder',
data: str,
@@ -529,8 +535,8 @@ Page({
wx.hideLoading();
if (res.statusCode == 200) {
- var data=res.data;
- if(data.code==0){
+ var data = res.data;
+ if (data.code == 0) {
console.log(th.data.is_b_now);
//如果是购物车结算,还要删除购物车
if (th.data.is_b_now == 0) {
@@ -548,11 +554,11 @@ Page({
//要进行判断,如果是用微信支付,就要跳转到支付界面
if (order_amount > 0) {
th.setData({ isclose: 0 });
- util_pay.pay(data.data, function() {
- var url="/packageC/pages/presell/cart/cart?order_sn="+data.data;
+ util_pay.pay(data.data, function () {
+ var url = "/packageC/pages/presell/cart/cart?order_sn=" + data.data;
setTimeout(function () {
- wx.reLaunch({ url: url,})
- },1000)
+ wx.reLaunch({ url: url, })
+ }, 1000)
}, function () {
//支付失败
setTimeout(function () {
@@ -560,9 +566,9 @@ Page({
wx.reLaunch({
url: "/pages/user/order_list/order_list",
})
- },1000)
+ }, 1000)
- },os.stoid,1);
+ }, os.stoid, 1);
} else {
var dd = {
@@ -575,15 +581,15 @@ Page({
data: dd,
success: function (t) {
console.log(t);
- app.my_warnning("支付成功",1,th);
+ app.my_warnning("支付成功", 1, th);
setTimeout(function () {
th.setData({ isclose: 0 });
- var url="/packageC/pages/presell/cart/cart?order_sn="+data.data;
- wx.reLaunch({
- url: url
- })
+ var url = "/packageC/pages/presell/cart/cart?order_sn=" + data.data;
+ wx.reLaunch({
+ url: url
+ })
@@ -592,54 +598,54 @@ Page({
});
}
}
- else{
- th.data.is_summit_ing=0; //是否提交中
+ else {
+ th.data.is_summit_ing = 0; //是否提交中
getApp().confirmBox(data.msg);
}
} else {
- th.data.is_summit_ing=0; //是否提交中
+ th.data.is_summit_ing = 0; //是否提交中
console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
}
},
fail: function () {
- th.data.is_summit_ing=0; //是否提交中
+ th.data.is_summit_ing = 0; //是否提交中
wx.hideLoading();
console.log("index.js wx.request CheckCallUser fail");
},
- complete: function () {}
+ complete: function () { }
})
},
//--------------------提交订单-----------------------
- submitForm: function(t){
- var th=this;
+ submitForm: function (t) {
+ var th = this;
//如果是部分定金,商家不同意退定金,
- if(this.data.act.presell_type!=1 && !this.data.act.is_refundmoney && !th.agree_no_ref){
+ if (this.data.act.presell_type != 1 && !this.data.act.is_refundmoney && !th.agree_no_ref) {
wx.showModal({
content: ' 预售商品不允许退定金!是否继续下单?',
showCancel: true,//是否显示取消按钮
- cancelText:"我在想想",//默认是“取消”
- confirmText:"继续下单",//默认是“确定”
+ cancelText: "我在想想",//默认是“取消”
+ confirmText: "继续下单",//默认是“确定”
success: function (res) {
if (res.cancel) {
//点击取消,默认隐藏弹框
} else {
- th.setData({agree_no_ref:1})
- th.submitForm_next(t)
+ th.setData({ agree_no_ref: 1 })
+ th.submitForm_next(t)
}
},
})
- }else{
- this.submitForm_next(t);
+ } else {
+ this.submitForm_next(t);
}
},
- useCoupon: function() {
+ useCoupon: function () {
if (this.data.order.couponNum <= 0) {
//return t.showWarning("无可用优惠券");
- getApp().my_warnning("无可用优惠券",0,this);
+ getApp().my_warnning("无可用优惠券", 0, this);
return;
}
var a = {
@@ -649,148 +655,158 @@ Page({
url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a)
});
},
- enterAddressPage: function() {
- getApp().globalData.is_cart_old=1;
+ enterAddressPage: function () {
+ getApp().globalData.is_cart_old = 1;
this.data.enterAddressPage = !0, wx.navigateTo({
url: "/pages/user/address_list/address_list"
});
},
- //--------立即购买时,选择自提和物流-----------
- setexptype_w:function(t){
- var th=this;
- var ty = t.currentTarget.dataset.t,txt = t.currentTarget.dataset.txt;
- th.setData({ [txt]: ty });
- var iszt=1;
- if(ty==0){
- th.setData({ is_all_zt: 0 });
- }else{
- for(var i=0;i 0 && o_price >= freight_free){ return 0;}
- if (user_addr==null) { return 0; }
- //计算物流的config item;
- var item=null;
- //先根据 镇 县 区找计算的config
- item = th.get_wuliu_config(user_addr.district,code,rs);
- if (item==null) item = th.get_wuliu_config(user_addr.city, code, rs);
- if (item==null) item = th.get_wuliu_config(user_addr.province, code, rs);
- if (item == null) item = th.get_wuliu_default(code,rs);
- if (item == null) return o_shipping_price;
- var fw_price = 0, fp_price=0;
- item=item.config;
- if (item == null) return o_shipping_price;
- //------按重量----------
- if (goods_weight>0) {
- fw_price =parseFloat(item['money']);
- if (goods_weight > item['first_weight']){
- var fw = goods_weight - item['first_weight'];
- var n = Math.ceil(fw/item['second_weight'])
- fw_price = fw_price + n * parseFloat(item['add_money']);
- }
- }
- //------按件数----------
- if (goods_piece > 0) {
- fp_price = parseFloat(item['piecemoney']);
- if (goods_piece > item['first_piece']) {
- var fp = goods_piece - item['first_piece'];
- var m = Math.ceil(fp / item['second_piece'])
- fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
- }
- }
- var rspice =parseFloat(price + fw_price + fp_price);
- return rspice;
- },
-
- //------------循环获取config-----------
- get_wuliu_config:function(region_id,code,rs){
- var item=null,rslist = rs.pageData;
- for (var i = 0; i < rslist.length;i++){
- if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i];}
- }
- return item;
- },
- //-------循环获取config,code default-------
- get_wuliu_default: function (code, rs) {
- var item = null, rslist=rs.pageData;
- for (var i = 0; i < rslist.length; i++) {
- if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; }
- }
- return item;
- },
-
- //----------立即购买,选择物流-------------
- bindPickerChange:function(e){
- var ind = e.detail.value
- this.setData({ index: ind });
- this.calculatePrice2();
- },
-
- //----------购物车结算,选择物流-------------
- bindPickerChange_w: function (e) {
- var ind=e.detail.value, txt = e.currentTarget.dataset.txt;
+ setexptype: function (t) {
+ var th = this;
+ var ty = t.currentTarget.dataset.t;
+ th.setData({ bn_exp_type: ty });
+ //当物流为空的时候。
+ if (ty == 0 && th.data.wu_arr == null) {
+ return th.get_wuliu(th.calculatePrice2());
+ }
+ th.calculatePrice2()
+ console.log('setexptype');
+ },
+
+ //--------立即购买时,使用余额--------
+ set_bn_useyuer: function () {
+ var th = this;
+ th.setData({ bn_use_money: !th.data.bn_use_money });
+ th.calculatePrice2();
+ },
+ set_js_useyuer: function () {
+ var th = this;
+ th.setData({ js_use_money: !th.data.js_use_money });
+ th.calculatePrice();
+ },
+
+ //-------------------计算物流---------------
+ calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight,
+ goods_piece, user_addr, freight_free, o_price, rs) {
+ var price = 0, th = this;
+ price += parseFloat(o_shipping_price);
+ //如果是包邮
+ if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; }
+ if (user_addr == null) { return 0; }
+ //计算物流的config item;
+ var item = null;
+ //先根据 镇 县 区找计算的config
+ item = th.get_wuliu_config(user_addr.district, code, rs);
+ if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
+ if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
+ if (item == null) item = th.get_wuliu_default(code, rs);
+ if (item == null) return o_shipping_price;
+ var fw_price = 0, fp_price = 0;
+ item = item.config;
+ if (item == null) return o_shipping_price;
+ //------按重量----------
+ if (goods_weight >= 0 && item['money']) {
+ fw_price = parseFloat(item['money']);
+ if (goods_weight > item['first_weight']) {
+ var fw = goods_weight - item['first_weight'];
+ var n = Math.ceil(fw / item['second_weight'])
+ fw_price = fw_price + n * parseFloat(item['add_money']);
+ }
+ }
+ //------超出重量----------
+ if (out_of_weight < 0 && o_price >= freight_free) {
+ fw_price = parseFloat(item['money']);
+ var out_of_weight = Math.abs(out_of_weight);
+ if (out_of_weight > item['first_weight']) {
+ var fw = out_of_weight - item['first_weight'];
+ var n = Math.ceil(fw / item['second_weight'])
+ fw_price = fw_price + n * parseFloat(item['add_money']);
+ }
+ }
+ //------按件数----------
+ if (goods_piece > 0) {
+ fp_price = parseFloat(item['piecemoney']);
+ if (goods_piece > item['first_piece']) {
+ var fp = goods_piece - item['first_piece'];
+ var m = Math.ceil(fp / item['second_piece'])
+ fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
+ }
+ }
+ var rspice = parseFloat(price + fw_price + fp_price);
+ return rspice;
+ },
+
+ //------------循环获取config-----------
+ get_wuliu_config: function (region_id, code, rs) {
+ var item = null, rslist = rs.pageData;
+ for (var i = 0; i < rslist.length; i++) {
+ if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; }
+ }
+ return item;
+ },
+ //-------循环获取config,code default-------
+ get_wuliu_default: function (code, rs) {
+ var item = null, rslist = rs.pageData;
+ for (var i = 0; i < rslist.length; i++) {
+ if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; }
+ }
+ return item;
+ },
+
+ //----------立即购买,选择物流-------------
+ bindPickerChange: function (e) {
+ var ind = e.detail.value
+ this.setData({ index: ind });
+ this.calculatePrice2();
+ },
+
+ //----------购物车结算,选择物流-------------
+ bindPickerChange_w: function (e) {
+ var ind = e.detail.value, txt = e.currentTarget.dataset.txt;
this.setData({ [txt]: ind });
this.calculatePrice();
- },
-
- cart_set_err: function (e) {
- var txt = e.currentTarget.dataset.err;
- var ob = {};
- ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif";
- this.setData(ob);
- },
+ },
+
+ cart_set_err: function (e) {
+ var txt = e.currentTarget.dataset.err;
+ var ob = {};
+ ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif";
+ this.setData(ob);
+ },
//// 开启物流的弹窗
- show_wu_arr:function(e){
- this.setData({ open_express: 1});
+ show_wu_arr: function (e) {
+ this.setData({ open_express: 1 });
},
//更新下默认,在onshow里面
- update_code(){
- var th=this,m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code;
+ update_code() {
+ var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
- var uii=setInterval(function () {
- if(th.data.wu_arr){
- clearInterval(uii);
+ var uii = setInterval(function () {
+ if (th.data.wu_arr) {
+ clearInterval(uii);
for (var k = 0; k < th.data.wu_arr.length; k++) {
var item = th.data.wu_arr[k];
if (def_exp_code == item.code) {
@@ -798,37 +814,37 @@ Page({
}
}
//--如果是立即购买--
- th.setData({ index: m_wind, is_express: m_wind});
+ th.setData({ index: m_wind, is_express: m_wind });
}
- },500)
+ }, 500)
},
// 关闭物流的弹窗
- close_express:function(){
- this.setData({ open_express:0 });
+ close_express: function () {
+ this.setData({ open_express: 0 });
},
// 选择物流
- click_express_name:function(e){
+ click_express_name: function (e) {
var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
- var index=e.currentTarget.dataset.idxe;
- var ob={ is_express: index, is_shipping_code: shippingcode,index:index};
+ var index = e.currentTarget.dataset.idxe;
+ var ob = { is_express: index, is_shipping_code: shippingcode, index: index };
this.setData(ob);
},
//点击确定物流
- determine_expres:function(e){
- this.setData({ open_express: 0});
+ determine_expres: function (e) {
+ this.setData({ open_express: 0 });
this.calculatePrice2();
},
//设置默认物流
select_default_logistics: function () {
- var th=this;
- var is_shipping_code=this.data.is_shipping_code
- getApp().request.put("/api/weshop/users/update",{
- data: { user_id: getApp().globalData.user_id, store_id: os.stoid, def_exp_code: is_shipping_code},
- success:function(rse){
- if (rse.data.code==0){
- getApp().globalData.userInfo.def_exp_code=is_shipping_code;
+ var th = this;
+ var is_shipping_code = this.data.is_shipping_code
+ getApp().request.put("/api/weshop/users/update", {
+ data: { user_id: getApp().globalData.user_id, store_id: os.stoid, def_exp_code: is_shipping_code },
+ success: function (rse) {
+ if (rse.data.code == 0) {
+ getApp().globalData.userInfo.def_exp_code = is_shipping_code;
th.setData({ open_express: 0 });
//----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19----
//if(th.data.is_b_now==1) th.calculatePrice2();
@@ -841,14 +857,14 @@ Page({
//跳转到购买卡
- buycard:function(){
- getApp().goto("/pages/user/plus/plus");
- getApp().globalData.plus_buy_back=1;
- },
-
- switchChange:function (e) {
- console.log(e,111);
- this.setData({agree_no_ref:e.detail.value});
+ buycard: function () {
+ getApp().goto("/pages/user/plus/plus");
+ getApp().globalData.plus_buy_back = 1;
+ },
+
+ switchChange: function (e) {
+ console.log(e, 111);
+ this.setData({ agree_no_ref: e.detail.value });
}
-
+
});
diff --git a/pages/cart/cart/cart.wxml b/pages/cart/cart/cart.wxml
index ab2e874..309db35 100644
--- a/pages/cart/cart/cart.wxml
+++ b/pages/cart/cart/cart.wxml
@@ -41,7 +41,8 @@
- 全场满{{freight_free}}元可享包邮({{weight_free}}kg内)
+ 全场满{{freight_free}}元可享包邮
+ 全场满{{freight_free}}元可享包邮({{weight_free}}kg内)
编辑
完成
diff --git a/pages/cart/cart/zh_calculate.js b/pages/cart/cart/zh_calculate.js
index 04fae18..e68c1b0 100644
--- a/pages/cart/cart/zh_calculate.js
+++ b/pages/cart/cart/zh_calculate.js
@@ -239,15 +239,8 @@ module.exports = {
if (act.is_bzyh && zhqty_bz.length > 0) {
if (zhqty_bz.length > 1) {
let zhqty_bz_arr = [];
- let zhqty_bz_flag = zhqty_bz.every((item1, i) => {
- var bz_num = be * item1['zhqty']; //超量倍增
- var num = item1['num'] - item1['zhqty']; //购买数量减去超量
- if (bz_num > num) {
- zhqty_bz_arr.push(item1);
- zhqty_bz.splice(i, 1)
- }
- return bz_num <= num;
- })
+ let zhqty_bz_flag=this.zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr);
+
if (zhqty_bz_flag) {
for (let i = 0; i < zhqty_bz.length; i++) {
var vv = zhqty_bz[i];
@@ -262,11 +255,12 @@ module.exports = {
}
}
} else {
+ zhqty_len=1;
let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) {
- return o['num']
+ return o['num'];
}));
let new_arr = zhqty_bz_arr.filter(ii => {
- return ii['num'] == min_bz_num
+ return ii['num'] == min_bz_num;
})
var vv = new_arr[0];
var bz_num = be * new_arr[0].zhqty; //超量倍增
@@ -285,18 +279,22 @@ module.exports = {
}
bz_num_ok = be * vv.zhqty;
}
-
- for (let j = 0; j < bz_num_ok; j++) {
- let index = no_in_arr.findIndex(i => {
- return vv.goods_id === i.goods_id
- })
- if (index > -1) {
- delete_num++
- no_in_arr.splice(index, 1)
+
+ for(let i = 0; i < zhqty_bz.length; i++){
+ let item1=zhqty_bz[i];
+ for (let j = 0; j < be * item1['zhqty']; j++) {
+ let index = no_in_arr.findIndex(i => {
+ return item1.goods_id === i.goods_id
+ })
+ if (index > -1) {
+ // delete_num++
+ no_in_arr.splice(index, 1)
+ }
}
}
+ aprice += be * aprice;
}
- } else {
+ } else {
var vv = zhqty_bz[0];
var bz_num = be * vv.zhqty; //超量倍增
var num = vv['num'] - vv.zhqty; //购买数量减去超量
@@ -310,14 +308,11 @@ module.exports = {
// be=be-bz_num_ok;
if (num % vv.zhqty == 0) {
be = num / vv.zhqty;
- // bz_num_ok = num;
} else {
be = Math.floor(num / vv.zhqty)
- // bz_num_ok = num - (be * vv.zhqty);
}
bz_num_ok = be * vv.zhqty;
}
- // be=vv.num;
for (let j = 0; j < bz_num_ok; j++) {
let index = no_in_arr.findIndex(i => {
return vv.goods_id === i.goods_id
@@ -496,7 +491,22 @@ module.exports = {
}
}
return dest;
- }
+ },
+
+ zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr){
+ let zhqty_bz_flag =true;
+ for(let i=0;i num) {
+ zhqty_bz_flag=false;
+ zhqty_bz_arr.push(item);
+ // zhqty_bz.splice(i,1)
+ }
+ }
+ return zhqty_bz_flag;
+ }
}
\ No newline at end of file
diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js
index f414b42..66080e8 100644
--- a/pages/cart/cart2/cart2.js
+++ b/pages/cart/cart2/cart2.js
@@ -123,46 +123,47 @@ Page({
tabs: ['门店自提', '快递邮寄'],
currentTabIndex: 1,
- in_zhact_gdmap:{}, //不同门店参与同一活动的限购
- hid_inp:1,
- user_note:"",
- zhhe_act_map:{}, //组合活动的map表
- zuhe_map_good:{}, //组合购的map表
- ladder_map:{}, //阶梯促销的map表
-
- state:0, //阶梯促销的的立即购买也走购物车流程state=1
+ in_zhact_gdmap: {}, //不同门店参与同一活动的限购
+ hid_inp: 1,
+ user_note: "",
+ zhhe_act_map: {}, //组合活动的map表
+ zuhe_map_good: {}, //组合购的map表
+ ladder_map: {}, //阶梯促销的map表
+ is_no_past: 1,
+ state: 0, //阶梯促销的的立即购买也走购物车流程state=1
},
onLoad: function (t) {
- wx.setNavigationBarTitle({title: "填写订单",})
+ wx.setNavigationBarTitle({ title: "填写订单", })
var th = this;
- this.setData({is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,});
+ this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, });
th.data.param = t;
//清理一下,确保最新的系统配置
getApp().globalData.config2 = null;
//清空is_pick_up
getApp().request.put("/api/weshop/useraddress/updatePickUp", {
- data: {user_id: getApp().globalData.user_id, is_pickup: 0},
+ data: { user_id: getApp().globalData.user_id, is_pickup: 0 },
success: function (s) {
}
});
//阶梯购 或者 组合购的立即购买
- if(t.state){
- th.data.state=1;
+ if (t.state) {
+ th.data.state = 1;
}
getApp().promiseGet("/api/wx/weappSendlist/page", {
data: {
store_id: os.stoid,
typeid: "1001"
- }}).then(res=>{
+ }
+ }).then(res => {
if (res.data.code == 0 && res.data.data.pageData.length > 0) {
var template_id = res.data.data.pageData[0].template_id;
- th.setData({template_id:template_id});
+ th.setData({ template_id: template_id });
}
})
},
onUnload: function () {
- this.setData({isclose: 1})
+ this.setData({ isclose: 1 })
},
onHide: function () {
this.setData({
@@ -175,7 +176,7 @@ Page({
//----------子页返回父页触发----------
onShow: function () {
var th = this;
- th.setData({show_submit: 0}); //让提交先掩藏
+ th.setData({ show_submit: 0 }); //让提交先掩藏
th.data.g_cart_q_time = null;
if (th.data.isclose == 0) {
@@ -208,20 +209,20 @@ Page({
th.data.is_summit_ing = 0;
//更换地址回来要重新调用计算价钱的接口
if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
- th.setData({user_addr: ie});
+ th.setData({ user_addr: ie });
if (th.data.is_b_now == 1) {
if (th.data.bn_goods) {
- th.setData({add_back: 1});
+ th.setData({ add_back: 1 });
//th.calculatePrice2();
}
} else {
if (th.data.cartlist) {
- th.setData({add_back: 1});
+ th.setData({ add_back: 1 });
//th.calculatePrice();
}
}
} else {
- th.setData({user_addr: ie});
+ th.setData({ user_addr: ie });
}
var going = 0;
@@ -275,34 +276,34 @@ Page({
//-- 获取所有的等级卡, --
getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid,
{}).then(res => {
- if (res.data.code == 0) {
- var plusCard = res.data.data;
- //-- 循环判断,拿到最贵的那张卡 --
- for (var ih in plusCard) {
- if (plusCard[ih].IsStopBuy == true) {
- continue;
- }
- if (max_price < 0) {
- max_price = plusCard[ih].CardFee;
- name = 'card' + plusCard[ih]['CorrPrice'];
- show_card = plusCard[ih];
- } else {
- if (max_price < plusCard[ih].CardFee) {
+ if (res.data.code == 0) {
+ var plusCard = res.data.data;
+ //-- 循环判断,拿到最贵的那张卡 --
+ for (var ih in plusCard) {
+ if (plusCard[ih].IsStopBuy == true) {
+ continue;
+ }
+ if (max_price < 0) {
max_price = plusCard[ih].CardFee;
name = 'card' + plusCard[ih]['CorrPrice'];
show_card = plusCard[ih];
+ } else {
+ if (max_price < plusCard[ih].CardFee) {
+ max_price = plusCard[ih].CardFee;
+ name = 'card' + plusCard[ih]['CorrPrice'];
+ show_card = plusCard[ih];
+ }
}
}
- }
- if (show_card) {
- name = name.toLowerCase();
- th.setData({card_name: name, show_card: show_card})
+ if (show_card) {
+ name = name.toLowerCase();
+ th.setData({ card_name: name, show_card: show_card })
+ }
}
- }
- //-----先获取物流,再获取用户信息,再展示页面-----
- th.get_wuliu(th.get_info(th.show_page));
- })
+ //-----先获取物流,再获取用户信息,再展示页面-----
+ th.get_wuliu(th.get_info(th.show_page));
+ })
} else {
//-----先获取物流,再获取用户信息,再展示页面-----
th.get_wuliu(th.get_info(th.show_page));
@@ -321,10 +322,10 @@ Page({
if (th.data.is_default_logistics) {
//如果第一个不是开启默认,说明要让用户自己选
if (!e[0].is_default) {
- th.setData({is_default_logistics: 0});
+ th.setData({ is_default_logistics: 0 });
}
}
- th.setData({wu_arr: e})
+ th.setData({ wu_arr: e })
typeof func == "function" && func();
})
},
@@ -338,7 +339,7 @@ Page({
getuser_addr: function (func) {
var th = this;
a.get("/api/weshop/useraddress/page", {
- data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()},
+ data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random() },
success: function (su) {
/*---
var user_addr=[
@@ -363,7 +364,7 @@ Page({
}
if (item == undefined) item = null;
- if (!item) th.setData({user_addr: null}); //地址为空的时候,要清空,因为返回的时候,有缓存
+ if (!item) th.setData({ user_addr: null }); //地址为空的时候,要清空,因为返回的时候,有缓存
func(item);
}
@@ -378,19 +379,19 @@ Page({
//会员的信息,要获取最新
var user = getApp().globalData.userInfo;
getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, {
- data: {r: Math.random()},
+ data: { r: Math.random() },
success: function (e) {
getApp().globalData.userInfo = e.data.data;
- th.setData({userinfo: e.data.data});
+ th.setData({ userinfo: e.data.data });
//选获取地址
th.getuser_addr(function (addr) {
- th.setData({user_addr: addr});
+ th.setData({ user_addr: addr });
//--------------------------立即购买------------------
if (ta.is_bnow == 1) {
//读取门店
to.get_allsto(function (e) {
- th.setData({allsto: e});
+ th.setData({ allsto: e });
//获取立即购买的商品信息
th.get_buy_goods(ta.goods_id);
});
@@ -398,7 +399,7 @@ Page({
//------------------------购物车结算----------------------
//读取门店
to.get_allsto(function (e) {
- th.setData({allsto: e});
+ th.setData({ allsto: e });
//-------获取购物车已经选择的商品--------
th.get_cart();
})
@@ -407,12 +408,12 @@ Page({
//获取提现金额
getApp().request.get("/api/weshop/withdrawals/summoney", {
- data: {user_id: to.globalData.user_id, store_id: oo.stoid, status: 0},
+ data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 },
success: function (su) {
if (su.data.code == 0) {
var yuer = parseFloat(th.data.userinfo.user_money -
(th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2);
- th.setData({txmon: su.data.data.summoney, yuer: yuer});
+ th.setData({ txmon: su.data.data.summoney, yuer: yuer });
}
}
});
@@ -426,8 +427,8 @@ Page({
//-----真的获取购物车,入口--------
get_cart: function () {
var th = this, app = getApp();
- var state=0;
- if(th.data.state) state=1;
+ var state = 0;
+ if (th.data.state) state = 1;
a.get("/api/weshop/cart/list", {
data: {
user_id: to.globalData.user_id, selected: 1, state: state,
@@ -438,7 +439,7 @@ Page({
var arr = new Array();
var carr = su.data.data.pageData;
th.data.cartlist_y = carr; //存储原始购物车列表
- th.data.in_zhact_gdmap={};
+ th.data.in_zhact_gdmap = {};
//---是不是购买等级卡成功的返回---等级卡显示的判断---
var is_card_back = getApp().globalData.is_card_back;
@@ -447,7 +448,7 @@ Page({
var item1 = carr[i];
//把已经购买了多少见的内容填入
- var goodsbuynum=0,promgoodsbuynum=0;
+ var goodsbuynum = 0, promgoodsbuynum = 0;
//--要获得商品,该用户买了多少件,同步应用--
await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
data: {
@@ -465,7 +466,7 @@ Page({
goodsbuynum = buy_num_data.goodsbuynum;
})
//如果有购买活动
- item1.promgoodsbuynum=promgoodsbuynum;
+ item1.promgoodsbuynum = promgoodsbuynum;
//要把优惠活动加入,prom_goods_map中,赠品不要运算
if (item1.prom_type == 3 && item1.is_gift != 1) {
@@ -473,8 +474,8 @@ Page({
}
//要把组合购的东西拿出来算一下
- if(item1.prom_type == 7) {
- if(!th.data.zuhe_map_good[item1.prom_id]) {
+ if (item1.prom_type == 7) {
+ if (!th.data.zuhe_map_good[item1.prom_id]) {
var isok = 1;
var is_flag = 1;
//如果有组合购
@@ -523,50 +524,49 @@ Page({
}
})
}
- else
- {
- item1.act = th.data.zhhe_act_map[item1.prom_id];
+ else {
+ item1.act = th.data.zhhe_act_map[item1.prom_id];
}
}
- if(item1.prom_type==10){
- if(!th.data.ladder_map[item1.prom_id]){
+ if (item1.prom_type == 10) {
+ if (!th.data.ladder_map[item1.prom_id]) {
//如果有组合购
var isok = 1;
- var is_flag=1;
- var act=null;
- var url="/api/weshop/prom/ladderForm/get/"+os.stoid+"/"+item1.prom_id;
+ var is_flag = 1;
+ var act = null;
+ var url = "/api/weshop/prom/ladderForm/get/" + os.stoid + "/" + item1.prom_id;
await getApp().request.promiseGet(url, {}).then(res => {
- console.log(res,1000);
- if(res.data.code==0 && res.data.data){
- if(res.data.data.isuse!=1){
- isok=0;
+ console.log(res, 1000);
+ if (res.data.code == 0 && res.data.data) {
+ if (res.data.data.isuse != 1) {
+ isok = 0;
}
//如果活动已经结束
- if(res.data.data.is_end==1){
- isok=0;
+ if (res.data.data.is_end == 1) {
+ isok = 0;
}
//已经结束
- if(ut.gettimestamp()>res.data.data.end_time){
- isok=0;
+ if (ut.gettimestamp() > res.data.data.end_time) {
+ isok = 0;
}
//还未开始
- if(ut.gettimestamp() {
- if (rs1.data.code==0 && rs1.data.data) {
+ if (rs1.data.code == 0 && rs1.data.data) {
var gdlist = rs1.data.data;
- th.data.ladder_map[item1.prom_id].ladder_list=gdlist;
+ th.data.ladder_map[item1.prom_id].ladder_list = gdlist;
}
})
}
@@ -616,7 +616,7 @@ Page({
item.original_img = oo.imghost + item.original_img;
- var car_item=item;
+ var car_item = item;
/*----接口要弄出来的,先顶着-----*/
var pcid = car_item.pick_id;
var find = 0;
@@ -625,7 +625,7 @@ Page({
if (arr.length > 0) {
for (var j = 0; j < arr.length; j++) {
if (arr[j].pickup_id == pcid) {
- if(item.is_gift!=1){
+ if (item.is_gift != 1) {
//确定配送方式
if (arr[j].distr_t == 0) {
arr[j].distr_t = car_item.distr_type;
@@ -644,8 +644,8 @@ Page({
break;
}
arr[j].exp_type = e_t;
- if (e_t == 0) th.setData({is_all_zt: 0});
- else if(e_t==1) th.setData({is_all_zt: 1});
+ if (e_t == 0) th.setData({ is_all_zt: 0 });
+ else if (e_t == 1) th.setData({ is_all_zt: 1 });
}
//-- 把等级卡会优惠多少钱装进去 --
@@ -688,8 +688,8 @@ Page({
break;
}
//如果是物流的话,全部自提的控制要弄成0
- if (e_t == 0) th.setData({is_all_zt: 0});
- else th.setData({is_all_zt: 1});
+ if (e_t == 0) th.setData({ is_all_zt: 0 });
+ else th.setData({ is_all_zt: 1 });
var narr = new Array();
narr.push(car_item);
@@ -748,11 +748,11 @@ Page({
var offline_price = 0;
var offline_num = 0;
for (var c = 0; c < item.length; c++) {
- if(th.data.sales_rules!=2){
- item[c].offline_price=0;
+ if (th.data.sales_rules != 2) {
+ item[c].offline_price = 0;
}
//-- 如果这个商品是线下取价的时候 --
- if (item[c].offline_price > 0 && item[c].prom_type != 7 ) {
+ if (item[c].offline_price > 0 && item[c].prom_type != 7) {
offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num;
offline_num += item[c].goods_num;
}
@@ -778,7 +778,7 @@ Page({
var h_item = obj[var1];
var gdlist = th.data.zuhe_map_good[h_item.prom_id];
//获取活动需要的商品列表
- u_item.zh_prom_goods[h_item.prom_id] = {gdlist: gdlist, act: h_item.act};
+ u_item.zh_prom_goods[h_item.prom_id] = { gdlist: gdlist, act: h_item.act };
}
zh_calc.fir_set_arr(u_item, th);
}
@@ -792,10 +792,10 @@ Page({
//存储不同阶梯促销活动的商品列表
u_item.ladder_map = {};
for (let var1 in obj) {
- var h_item=obj[var1];
- var act= th.data.ladder_map[h_item.prom_id];
+ var h_item = obj[var1];
+ var act = th.data.ladder_map[h_item.prom_id];
//获取活动需要的商品列表
- u_item.ladder_map[h_item.prom_id] =act;
+ u_item.ladder_map[h_item.prom_id] = act;
}
ladder_calc.fir_set_arr(u_item, th);
}
@@ -809,7 +809,7 @@ Page({
setTimeout(function () {
var frozenQuan = null;
var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
- app.request.promiseGet(url0, {1: 1}).then(res => {
+ app.request.promiseGet(url0, { 1: 1 }).then(res => {
if (res.data.code == 0) {
frozenQuan = res.data.data;
th.data.frozenQuan = frozenQuan;
@@ -880,7 +880,7 @@ Page({
th.data.card_name = th.data.userinfo.card_field;
gg.goods_price = gd[th.data.card_name];
getApp().globalData.is_card_back = 0;
- th.setData({card_cut_price: 0});
+ th.setData({ card_cut_price: 0 });
//如果是秒杀的返回
if (gd.prom_type == 1) gd.prom_type = 0;
} else {
@@ -888,12 +888,12 @@ Page({
//-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 --
if (!gg.collocation_goods && gd['prom_type'] != 6 && th.data.card_name && gd[th.data.card_name] > 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) {
var cut_p = (gg.goods_price - gd[th.data.card_name]) * gg.goods_num;
- th.setData({card_cut_price: cut_p});
+ th.setData({ card_cut_price: cut_p });
}
}
- gd.prom_type=gg.prom_type?gg.prom_type:0;
- gd.prom_id=gg.prom_id?gg.prom_id:0;
+ gd.prom_type = gg.prom_type ? gg.prom_type : 0;
+ gd.prom_id = gg.prom_id ? gg.prom_id : 0;
switch (gd.prom_type) {
case 0:
@@ -956,7 +956,7 @@ Page({
ob.exp_sum_type = data.gift_exp_sum_type; //商品的物流计算方式
ob.uniform_exp_sum = data.gift_uniform_exp_sum //统一运费的金额
- th.setData({buy_now_gift_goods: ob});
+ th.setData({ buy_now_gift_goods: ob });
}
}
@@ -990,7 +990,7 @@ Page({
t.data.data.guide_id = gg.guide_id;
t.data.data.guide_type = gg.guide_type;
}
- th.setData({collocation_goods: gg.collocation_goods});
+ th.setData({ collocation_goods: gg.collocation_goods });
var cart_arr = new Array();
//var narr=gg.collocation_goods;
@@ -1001,21 +1001,20 @@ Page({
//-- 搭配促销的门店配送方式的修复 --
et = 1;
- distr_t = 0;
+ distr_t = 0; // 配送方式 0=用户自选 1=自提 2=物流
for (var hi in narr) {
var dis_t = narr[hi].distr_type;
if (dis_t == 2) {
- th.setData({is_all_zt: 0});
+ th.setData({ is_all_zt: 0 });
et = 0;
}
if (dis_t > 0) {
distr_t = dis_t;
}
}
-
//自选的时候,系统配置了默认的配送方式是物流的时候
if (distr_t == 0 && th.data.json_d.pickupway && th.data.json_d.pickupway == 1) {
- et = 0;
+ et = 2;
}
@@ -1047,7 +1046,7 @@ Page({
if (gg.prom_type == 5) {
var frozenQuan = null;
var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
- app.request.promiseGet(url0, {1: 1}).then(res => {
+ app.request.promiseGet(url0, { 1: 1 }).then(res => {
if (res.data.code == 0) {
frozenQuan = res.data.data;
th.data.frozenQuan = frozenQuan;
@@ -1057,7 +1056,7 @@ Page({
th.get_cart_quan();
});
-
+
} else {
//计算价格
@@ -1071,13 +1070,13 @@ Page({
case 1: //---秒杀-----
var quanlist = null;
getApp().request.get("/api/weshop/activitylist/getSJGoodsPriceNew/" + gd.store_id
- + "/" + gd.goods_id + "/1/" + gd.prom_id+"/"+app.globalData.user_id, {
+ + "/" + gd.goods_id + "/1/" + gd.prom_id + "/" + app.globalData.user_id, {
success: async function (tt) {
if (tt.data.code == 0) {
//t.data.data.shop_price = tt.data.data.prom_price;
t.data.data.shop_price = tt.data.data.prom_user_price;
- th.data.ckeck_quan_price=0;
- gd.is_xz_yh=1;
+ th.data.ckeck_quan_price = 0;
+ gd.is_xz_yh = 1;
} else {
t.data.data.prom_id = 0;
t.data.data.prom_type = 0;
@@ -1099,7 +1098,7 @@ Page({
//计算价格
th.calculatePrice2();
//获取优惠券,如果有券的钱,就调用
- if(th.data.ckeck_quan_price>0) th.get_buy_now_quan();
+ if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan();
}
});
@@ -1107,7 +1106,7 @@ Page({
case 2: //--- 团购 ---
var quanlist = null;
- getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" +os.stoid + "/" +gd.goods_id+"/"+ gd.prom_id, {
+ getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gd.goods_id + "/" + gd.prom_id, {
success: async function (tt) {
if (tt.data.code == 0) {
//t.data.data.shop_price = tt.data.data.prom_price;
@@ -1117,12 +1116,12 @@ Page({
t.data.data.prom_type = 0;
}
- if(tt.data.data.isQuan){
+ if (tt.data.data.isQuan) {
th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num;
th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + "";
th.data.check_quan_ware_list = t.data.data.erpwareid + "";
- }else{
- gd.is_xz_yh=1;
+ } else {
+ gd.is_xz_yh = 1;
}
th.setData({
@@ -1138,7 +1137,7 @@ Page({
//-- 计算价格 --
th.calculatePrice2();
//获取优惠券,如果有券的钱,就调用
- if(th.data.ckeck_quan_price>0) th.get_buy_now_quan();
+ if (th.data.ckeck_quan_price > 0) th.get_buy_now_quan();
}
});
@@ -1153,14 +1152,14 @@ Page({
checkAddressList: function () {
var t = this;
return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({
- title: "请先填写或选择收货地址~",
- success: function (a) {
- a.confirm ? t.enterAddressPage() : wx.navigateBack();
- },
- fail: function () {
- wx.navigateBack();
- }
- }), !1);
+ title: "请先填写或选择收货地址~",
+ success: function (a) {
+ a.confirm ? t.enterAddressPage() : wx.navigateBack();
+ },
+ fail: function () {
+ wx.navigateBack();
+ }
+ }), !1);
},
showInvoice: function () {
this.setData({
@@ -1179,7 +1178,7 @@ Page({
},
keyUpChangeNum: function (t) {
var index = t.currentTarget.dataset.index;
- var txt="user_note."+index;
+ var txt = "user_note." + index;
this.setData({
maxWord: t.detail.value.length,
[txt]: t.detail.value
@@ -1269,7 +1268,7 @@ Page({
}
var pt_res = null;
- await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
+ await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
is_json: 1,
data: pt_data
}).then(res => {
@@ -1324,11 +1323,11 @@ Page({
if (item_map.s_coupon_id) {
if (!cart_item.s_coupon_id) {
cart_item.s_coupon_id = item_map.s_coupon_id + "";
- cart_item.g_coupon_num = [{'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num}];
+ cart_item.g_coupon_num = [{ 'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num }];
}
else {
cart_item.s_coupon_id += "," + item_map.s_coupon_id;
- cart_item.g_coupon_num.push({'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num})
+ cart_item.g_coupon_num.push({ 'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num })
}
}
@@ -1336,11 +1335,11 @@ Page({
if (item_map.s_libao) {
if (!cart_item.s_libao) {
cart_item.s_libao = item_map.s_libao + "";
- cart_item.g_lb_num = [{'l_id': item_map.s_libao, "num": item_map.s_lb_num}];
+ cart_item.g_lb_num = [{ 'l_id': item_map.s_libao, "num": item_map.s_lb_num }];
}
else {
cart_item.s_libao += "," + item_map.s_libao;
- cart_item.g_lb_num.push({'l_id': item_map.s_libao, "num": item_map.s_lb_num})
+ cart_item.g_lb_num.push({ 'l_id': item_map.s_libao, "num": item_map.s_lb_num })
}
}
}
@@ -1349,7 +1348,7 @@ Page({
},
//-------------------计算订单价格-------------------
- calculatePrice : function (t, s) {
+ calculatePrice: function (t, s) {
var th = this;
to.getConfig2(function (ee) {
to.getwuliuprice(async function (rs) {
@@ -1373,11 +1372,11 @@ Page({
var no_ex_id = ee.no_ex_id;
var no_ex_good = null;
var by_qc = {};
- var out_of_weight=0; //超出多少重量
+ var out_of_weight = 0; //超出多少重量
if (no_ex_id && freight_free > 0) {
//-----------获取不包邮区域,不包邮商品-------
await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
- data: {store_id: os.stoid, id: no_ex_id}
+ data: { store_id: os.stoid, id: no_ex_id }
}).then(res => {
if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
by_qc = res.data.data[0];
@@ -1396,9 +1395,9 @@ Page({
//调用函数计算每件商品的单价
await th.calc_per(c_arr);
//调用函数计算每件组合购商品的单价,
- await zh_calc.calc_zh_split_price(c_arr,th);
+ await zh_calc.calc_zh_split_price(c_arr, th);
//调用函数计算每件阶梯促销商品的单价,
- await ladder_calc.calc_split_price(c_arr,th);
+ await ladder_calc.calc_split_price(c_arr, th);
//调用函数计算,优惠券优惠什么商品价格,优惠券优惠什么商品
await th.get_cart_quan(c_arr);
//---循环购物车---
@@ -1421,7 +1420,7 @@ Page({
var cart_item = c_arr[i]; //就是每一单的意思
var pickid = cart_item.pickup_id;
var o_price = 0;
- var o_price_no_zh=0; //参与订单优惠叠加--组合购的金额汇总
+ var o_price_no_zh = 0; //参与订单优惠叠加--组合购的金额汇总
var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
var item = c_arr[i].goods; //就是每一单的从表的意思
@@ -1429,11 +1428,11 @@ Page({
var quan_price = 0;
var coupon_price = 0;
var quan_no = null;
- var is_has_zh=c_arr[i].is_has_zh;
- var is_has_ladder=c_arr[i].is_has_ladder;
+ var is_has_zh = c_arr[i].is_has_zh;
+ var is_has_ladder = c_arr[i].is_has_ladder;
- var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间
- var ladder_prom_goods=c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间
+ var zh_prom_goods = c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间
+ var ladder_prom_goods = c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间
if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined)
quan_no = th.data.using_quan[pickid].coupon_no;
@@ -1462,66 +1461,65 @@ Page({
//--------循环计算总价-----------
for (var j = 0; j < item.length; j++) {
- var is_no_zh=0;
- if(item[j].prom_type!=7 && item[j].prom_type!=10 ) is_no_zh=1;
+ var is_no_zh = 0;
+ if (item[j].prom_type != 7 && item[j].prom_type != 10) is_no_zh = 1;
//组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
- if(item[j].prom_type==7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[j].prom_id]
- && th.data.zhhe_act_map[item[j].prom_id].is_orderyh )
- {
- is_no_zh=1;
+ if (item[j].prom_type == 7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[j].prom_id]
+ && th.data.zhhe_act_map[item[j].prom_id].is_orderyh) {
+ is_no_zh = 1;
}
//阶梯购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
- if(item[j].prom_type==10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id]
- && th.data.ladder_map[item[j].prom_id].is_useorderyh )
- {
- is_no_zh=1;
+ if (item[j].prom_type == 10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id]
+ && th.data.ladder_map[item[j].prom_id].is_useorderyh) {
+ is_no_zh = 1;
}
- if(is_no_zh){
+ if (is_no_zh) {
o_price_no_zh += item[j].goods_price * item[j].goods_num;
}
o_price += item[j].goods_price * item[j].goods_num;
//判断是否有设置限制重量包邮,先看商品有没有包邮
- if(item[j]['is_past']!==1 && weight_free){
- if( item[j]['exp_sum_type']==2 ){
- if (goods_weight < 0) goods_weight = 0;
- //累积商品重量 每种商品的重量 * 数量
- goods_weight += item[j]['weight'] * item[j]['goods_num'];
- out_of_weight = (weight_free*1000) - goods_weight;
+ if (item[j]['is_past'] !== 1 && item[j]['exp_sum_type'] == 2) {
+ if (goods_weight < 0) goods_weight = 0;
+ //累积商品重量 每种商品的重量 * 数量
+ goods_weight += item[j]['weight'] * item[j]['goods_num'];
+ if (weight_free > 0) {
+ out_of_weight = (weight_free * 1000) - goods_weight;
}
}
+
}
//判断是不是有组合购的金额
var f_o_price = o_price;
//如果又优惠的钱,就要减价
- if (c_arr[i].cut_price > 0){
+ if (c_arr[i].cut_price > 0) {
o_price -= c_arr[i].cut_price;
- o_price_no_zh-=c_arr[i].cut_price;
+ o_price_no_zh -= c_arr[i].cut_price;
}
//如果有组合购优惠的钱,就要减价
- if (c_arr[i].zh_cut_price>0 || c_arr[i].zh_cut_price<0){
+ if (c_arr[i].zh_cut_price > 0 || c_arr[i].zh_cut_price < 0) {
o_price -= c_arr[i].zh_cut_price;
- if(o_price_no_zh>0){
+ if (o_price_no_zh > 0) {
//找到那些可以订单优惠叠加的
- for(let ij in zh_prom_goods){
- let kitem=zh_prom_goods[ij];
- if(kitem.act.is_orderyh)
- o_price_no_zh-=kitem.cut_price;
+ for (let ij in zh_prom_goods) {
+ let kitem = zh_prom_goods[ij];
+ if (kitem.act.is_orderyh)
+ o_price_no_zh -= kitem.cut_price;
}
}
}
//如果有组合购优惠的钱,就要减价
- if (c_arr[i].ladder_cut_price>0 || c_arr[i].ladder_cut_price<0){
+ if (c_arr[i].ladder_cut_price > 0 || c_arr[i].ladder_cut_price < 0) {
o_price -= c_arr[i].ladder_cut_price;
- if(o_price_no_zh>0){
+ if (o_price_no_zh > 0) {
//找到那些可以订单优惠叠加的
- for(let ij in ladder_prom_goods){
- let kitem=ladder_prom_goods[ij];
- if(th.data.ladder_map[ij].is_useorderyh )
- o_price_no_zh-=kitem.cut_price;
+ for (let ij in ladder_prom_goods) {
+ let kitem = ladder_prom_goods[ij];
+ if (th.data.ladder_map[ij].is_useorderyh)
+ o_price_no_zh -= kitem.cut_price;
}
}
}
@@ -1529,30 +1527,37 @@ Page({
//-- 计算线下取价的功能 --
if (cart_item.is_offline == 1) {
o_price = o_price - cart_item.offline_price;
- o_price_no_zh-=c_arr[i].offline_price;
+ o_price_no_zh -= c_arr[i].offline_price;
}
//判断包邮券的钱,组合购的商品不使用优惠券
var q_conditin = 0;
q_conditin = o_price - quan_price;
- if(is_has_zh){
+ if (is_has_zh) {
q_conditin = o_price_no_zh - quan_price;
}
cart_item.goods_price = f_o_price.toFixed(2); //商品总费用,用f_o_price来计算
//计算物流费用
cart_item.shipping_price = 0;
+ th.data.is_no_past = 1; //不包邮标识符
+
//--有不包邮区域,且不免运费,全场的计算,要减到优惠金额 和券的金额--
- if (no_ex_id && freight_free > 0 && (o_price - quan_price) >= freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list) && out_of_weight >= 0) {
+ if (no_ex_id && freight_free > 0 && (o_price - quan_price) >= freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list)) {
//如果有设置不包邮区域的时候
if (by_qc.region_list != "" && by_qc.region_list != null && by_qc.region_list != undefined) {
if (th.check_by_area(by_qc.region_list)) {
freight_free = 0;
+ goods_weight = -1;
+ out_of_weight = 0;
th.data.is_no_by[pickid] = 1;
}
}
//如果有设置不包邮区商品
if (by_qc.goods_list != "" && by_qc.goods_list != undefined && by_qc != null && freight_free > 0) {
freight_free = 0;
+ goods_weight = -1;
+ out_of_weight = 0;
+ th.data.is_no_by[pickid] = 1;
no_ex_good = by_qc.goods_list;
}
}
@@ -1567,7 +1572,7 @@ Page({
store_id: os.stoid,
isuse: 0,
//condition: q_conditin,
- condition:cart_item.ckeck_quan_price,
+ condition: cart_item.ckeck_quan_price,
user_id: getApp().globalData.user_id,
pageSize: 2000
}
@@ -1592,7 +1597,7 @@ Page({
}
if (arr) {
th.data.get_by_quan_list_cart[pickid] = arr;
- th.setData({get_by_quan_list_cart:th.data.get_by_quan_list_cart});
+ th.setData({ get_by_quan_list_cart: th.data.get_by_quan_list_cart });
//if (th.data.is_b_now) {
// th.setData({get_by_quan_list: arr});
//}
@@ -1617,7 +1622,7 @@ Page({
if (ut.isContained(arr, arr2)) {
getApp().my_warnning("全场不包邮商品和包邮券的重复", 0, th);
th.data.using_quan[pickid] = {};
- th.setData({using_quan: th.data.using_quan})
+ th.setData({ using_quan: th.data.using_quan })
return false;
}
var n_arr = ut.mergeArray(arr, arr2);
@@ -1656,7 +1661,7 @@ Page({
if (no_ex_good) no_ex_good_arr = no_ex_good.split(',');
//----------------如果是选择了物流---------------------
- if (cart_item.exp_type == 0 && item[j].is_free_shipping == 0 && (!no_ex_good_arr || no_ex_good_arr.indexOf(item[j].goods_id + '') > -1 )) {
+ if (cart_item.exp_type == 0 && item[j].is_free_shipping == 0 && (!no_ex_good_arr || no_ex_good_arr.indexOf(item[j].goods_id + '') > -1)) {
//如果地址不为空
if (th.data.user_addr != null) {
@@ -1665,13 +1670,15 @@ Page({
//统一运费
o_shipping_price += item[j]['uniform_exp_sum'];
break;
- // case 2: //1464行已计算 不必重复计算 注释为:判断是否有设置限制重量包邮
- // +''
- // if (goods_weight < 0) goods_weight = 0;
- // //累积商品重量 每种商品的重量 * 数量
- // goods_weight += item[j]['weight'] * item[j]['goods_num'];
- // out_of_weight = (weight_free*1000) - goods_weight;
- // break;
+ case 2:
+ +''
+ if (goods_weight < 0) goods_weight = 0;
+ //累积商品重量 每种商品的重量 * 数量
+ goods_weight += item[j]['weight'] * item[j]['goods_num'];
+ if (weight_free > 0) {
+ out_of_weight = (weight_free * 1000) - goods_weight;
+ }
+ break;
case 3:
if (goods_piece < 0) goods_piece = 0;
//累积商品数量
@@ -1679,12 +1686,6 @@ Page({
break;
}
}
-
- }else{
- if(goods_weight && out_of_weight !==0){
- goods_weight=-1;
- out_of_weight=0;
- }
}
}
@@ -1695,8 +1696,8 @@ Page({
if (th.data.wu_arr && th.data.wu_arr[cart_item.wind])
code = th.data.wu_arr[cart_item.wind].code;
cart_item.shipping_price =
- th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight,
- goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs);
+ th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
+ goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs, pickid);
if (!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby != 1) {
if (cart_item.shipping_price == 0) th.data.is_by[pickid] = 1; //已经全场包邮,就不要选择券了
@@ -1715,26 +1716,26 @@ Page({
var order_prom_id = 0;
var o_condition = cart_item.order_amount;
//看一下是不是不用组合购的订单优惠的叠加
- if(is_has_zh){
- o_condition=o_price_no_zh-quan_price;
+ if (is_has_zh) {
+ o_condition = o_price_no_zh - quan_price;
}
//看一下是不是不用组合购的订单优惠的叠加
- if(is_has_ladder){
- o_condition=o_price_no_zh-quan_price;
+ if (is_has_ladder) {
+ o_condition = o_price_no_zh - quan_price;
}
var order_m = 0;
//---判断是不是有订单优惠---
- await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
- data: {store_id: os.stoid, orderAmount: o_condition}
+ await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
+ data: { store_id: os.stoid, orderAmount: o_condition }
}).then(res => {
if (res.data.code == 0) {
var ord_prom = res.data.data;
//么有使用券,或者活动没有限制使用优惠券
- if(quan_price<=0 || !ord_prom.is_xz_yh) {
+ if (quan_price <= 0 || !ord_prom.is_xz_yh) {
order_prom_id = ord_prom['id'];
switch (ord_prom['type']) {
case 0:
@@ -1878,13 +1879,13 @@ Page({
}
}
var set_txt = "cartlist[" + iter + "].can_num";
- th.setData({[set_txt]: num});
+ th.setData({ [set_txt]: num });
}
},
//---------计算立即购买----------
- calculatePrice2 : function () {
+ calculatePrice2: function () {
var th = this, good = this.data.bn_goods;
if (!good) return false;
@@ -1910,10 +1911,10 @@ Page({
allpice = parseFloat(allpice).toFixed(2);
var txt = "formData.all_price";
- th.setData({[txt]: allpice,});
+ th.setData({ [txt]: allpice, });
if (cut_price) {
var c_txt = "formData.cut_price";
- th.setData({[c_txt]: cut_price,});
+ th.setData({ [c_txt]: cut_price, });
}
@@ -1926,8 +1927,8 @@ Page({
to.getConfig2(function (ee) {
to.getwuliuprice(async function (rs) {
- var o_shipping_price = 0,goods_weight = -1,goods_piece = -1;
- var out_of_weight=null; //超出多少重量
+ var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
+ var out_of_weight = null; //超出多少重量
var freight_free = ee.freight_free; //全场满多少包邮
var weight_free = ee.weight_free; //多少kg内包邮
var no_ex_id = ee.no_ex_id;
@@ -1982,7 +1983,7 @@ Page({
arr.push(item);
}
if (arr) {
- th.setData({get_by_quan_list: arr});
+ th.setData({ get_by_quan_list: arr });
}
th.data.isget_by_quan[th.data.bn_pick] = 1;
}
@@ -1999,7 +2000,9 @@ Page({
//dw
//累积商品重量 每种商品的重量 * 数量
goods_weight += good['weight'] * good['buynum'];
- out_of_weight = (weight_free * 1000 ) - goods_weight;
+ if (weight_free > 0) {
+ out_of_weight = (weight_free * 1000) - goods_weight;
+ }
break;
case 3:
if (goods_piece < 0) goods_piece = 0;
@@ -2021,7 +2024,7 @@ Page({
if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) {
//-----------获取不包邮区域,不包邮商品-------
await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
- data: {store_id: os.stoid, id: no_ex_id}
+ data: { store_id: os.stoid, id: no_ex_id }
}).then(res => {
if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
no_by_data = res.data.data[0];
@@ -2029,6 +2032,7 @@ Page({
if (res.data.data[0].region_list) {
if (th.check_by_area(res.data.data[0].region_list)) {
freight_free = 0;
+ out_of_weight = 0;
th.data.is_no_by[th.data.bn_pick] = 1;
}
}
@@ -2036,6 +2040,7 @@ Page({
if (res.data.data[0].goods_list && freight_free) {
if (th.check_by_goods(res.data.data[0].goods_list)) {
freight_free = 0;
+ out_of_weight = 0;
th.data.is_no_by[th.data.bn_pick] = 1;
}
}
@@ -2046,12 +2051,12 @@ Page({
th.data.is_by[th.data.bn_pick] = 0;
//--------------开始计算物流------------------
var shipping_price =
- th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight,
- goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs);
+ th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
+ goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs, th.data.bn_pick);
//如果有赠品的时候,也要计算赠品的物流费用
if (th.data.buy_now_gift_goods) {
- shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,out_of_weight,
+ shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, out_of_weight,
parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece);
}
@@ -2061,18 +2066,18 @@ Page({
shipping_price = parseFloat(shipping_price).toFixed(2);
var wl_txt = "formData.shipping_price";
- th.setData({[wl_txt]: shipping_price,})
+ th.setData({ [wl_txt]: shipping_price, })
} else {
var wl_txt = "formData.shipping_price";
- th.setData({[wl_txt]: 0,})
+ th.setData({ [wl_txt]: 0, })
}
if (quan_no) {
if (th.data.using_quan[bn_pick].isby == 1) {
shipping_price = 0;
var wl_txt = "formData.shipping_price";
- th.setData({[wl_txt]: 0,})
+ th.setData({ [wl_txt]: 0, })
}
}
//-----------------支付价,优惠券不减物流-----------------
@@ -2092,7 +2097,7 @@ Page({
if (th.data.order_prom[th.data.bn_pick]) {
var ord_prom = th.data.order_prom[th.data.bn_pick];
//么有使用券,或者活动没有限制使用优惠券
- if(coupon_price<=0 || !ord_prom.is_xz_yh) {
+ if (coupon_price <= 0 || !ord_prom.is_xz_yh) {
order_prom_id = ord_prom['id'];
switch (ord_prom['type']) {
case 0:
@@ -2110,9 +2115,9 @@ Page({
var order_prom_txt1 = "formData.order_prom_id";
var order_prom_txt2 = "formData.order_prom_amount";
if (order_prom_id > 0) {
- th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount})
- }else{
- th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0})
+ th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount })
+ } else {
+ th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 })
}
total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price);
@@ -2122,7 +2127,7 @@ Page({
order_m = order_m.toFixed(2);
var atxt = "formData.total_amount";
- th.setData({[atxt]: total_m,})
+ th.setData({ [atxt]: total_m, })
var txt = "formData.user_money";
var txt2 = "formData.order_amount";
@@ -2132,44 +2137,44 @@ Page({
if (th.data.bn_use_money == 1) {
if (amoney > order_m) {
order_m = parseFloat(order_m).toFixed(2);
- th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 })
} else {
order_m = parseFloat(order_m) - parseFloat(amoney);
order_m = order_m.toFixed(2);
- th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 })
}
} else {
- th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 })
}
//优惠活动送积分
if (good.s_intValue) {
txt = "formData.give_integral";
- th.setData({[txt]: good.s_intValue});
+ th.setData({ [txt]: good.s_intValue });
}
//优惠送券
if (good.s_coupon_id) {
var i_txt = "formData.give_coupon_id";
//这个是json格式的
var i_txt1 = "formData.g_coupon_num";
- var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}];
+ var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }];
ob = JSON.stringify(ob);
- th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob});
+ th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob });
}
//优惠礼包
if (good.s_libao) {
var l_txt = "formData.give_lb_id";
//这个是json格式的
var l_txt1 = "formData.g_lb_num";
- var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}];
+ var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }];
ob = JSON.stringify(ob);
- th.setData({[l_txt]: good.s_libao, [l_txt1]: ob});
+ th.setData({ [l_txt]: good.s_libao, [l_txt1]: ob });
}
})
} else {
var order_prom_txt1 = "formData.order_prom_id";
var order_prom_txt2 = "formData.order_prom_amount";
- th.setData({[order_prom_txt1]: 0, [order_prom_txt2]: 0})
+ th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 })
total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price);
@@ -2179,7 +2184,7 @@ Page({
total_m = total_m.toFixed(2);
order_m = order_m.toFixed(2);
- th.setData({[atxt]: total_m,})
+ th.setData({ [atxt]: total_m, })
var txt = "formData.user_money";
var txt2 = "formData.order_amount";
@@ -2189,37 +2194,37 @@ Page({
if (th.data.bn_use_money == 1) {
if (amoney > order_m) {
order_m = parseFloat(order_m).toFixed(2);
- th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 })
} else {
order_m = parseFloat(order_m) - parseFloat(amoney);
order_m = order_m.toFixed(2);
- th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 })
}
} else {
- th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
+ th.setData({ [txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1 })
}
//优惠活动送积分
if (good.s_intValue) {
txt = "formData.give_integral";
- th.setData({[txt]: good.s_intValue});
+ th.setData({ [txt]: good.s_intValue });
}
//优惠送券
if (good.s_coupon_id) {
var i_txt = "formData.give_coupon_id";
//这个是json格式的
var i_txt1 = "formData.g_coupon_num";
- var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}];
+ var ob = [{ "num": good.s_coupon_num, "c_id": good.s_coupon_id }];
ob = JSON.stringify(ob);
- th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob});
+ th.setData({ [i_txt]: good.s_coupon_id, [i_txt1]: ob });
}
//优惠礼包
if (good.s_libao) {
var l_txt = "formData.give_lb_id";
//这个是json格式的
var l_txt1 = "formData.g_lb_num";
- var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}];
+ var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }];
ob = JSON.stringify(ob);
- th.setData({[l_txt]: good.s_coupon_id, [l_txt1]: ob});
+ th.setData({ [l_txt]: good.s_coupon_id, [l_txt1]: ob });
}
}
@@ -2229,17 +2234,17 @@ Page({
});
},
- requestSubscribe(){
- const th=this;
+ requestSubscribe() {
+ const th = this;
const template_id = this.data.template_id;
wx.getSetting({
- withSubscriptions:true,
- success(res){
- let itemSettings=res.subscriptionsSetting.itemSettings;
- if(itemSettings && itemSettings[template_id]=="accept"){
+ withSubscriptions: true,
+ success(res) {
+ let itemSettings = res.subscriptionsSetting.itemSettings;
+ if (itemSettings && itemSettings[template_id] == "accept") {
th.submit_func();
- }else{
- th.sendsm(function(){
+ } else {
+ th.sendsm(function () {
th.submit_func();
})
}
@@ -2248,11 +2253,12 @@ Page({
},
//--------------------提交订单-----------------------
- async submit_func(){
+ async submit_func() {
if (this.data.is_summit_ing == 1) return false; //--提交中退出--
this.data.is_summit_ing = 1;
var th = this, pdata = new Array();
var ff = true;
+
//------------立即购买-------------
if (th.data.is_b_now == 1 && th.data.bn_goods.prom_type != 5) {
if (th.data.bn_exp_type == 0 && th.data.user_addr == null) {
@@ -2263,7 +2269,6 @@ Page({
if (!ff) return false;
var addr = th.data.user_addr;
if (th.data.bn_exp_type == 1) addr = null;
-
if (th.data.bn_exp_type == 0)
if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
getApp().my_warnning("读取物流失败", 0, th);
@@ -2291,7 +2296,7 @@ Page({
'user_money': th.data.formData.user_money, //使用余额
'total_amount': th.data.formData.total_amount, //订单总价
'order_amount': th.data.formData.order_amount, //应付
- 'user_note': th.data.user_note['0']?th.data.user_note['0']:0, //用户备注
+ 'user_note': th.data.user_note['0'] ? th.data.user_note['0'] : 0, //用户备注
'store_id': oo.stoid, //商家
'pickup_id': th.data.bn_pick, //门店
'exp_type': th.data.bn_exp_type, //配送方式
@@ -2317,7 +2322,7 @@ Page({
}
//--判断优惠活动的提交--
- if (th.data.formData.cut_price > 0 ) {
+ if (th.data.formData.cut_price > 0) {
order_prom_list.discount_amount = th.data.formData.cut_price.toFixed(2);
var ob = [{
"prom_id": th.data.bn_goods.prom_id,
@@ -2380,7 +2385,7 @@ Page({
goods.guide_id = gg.guide_id;
goods.guide_type = gg.guide_type;
//调用接口判断是不是会员
- await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => {
+ await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => {
if (res.data.code == 0) {
goods.guide_name = res.data.data.salesman;
goods.guide_sn = res.data.data.salesman_no;
@@ -2432,7 +2437,7 @@ Page({
}
var pt_res = null;
- await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
+ await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
is_json: 1,
data: pt_data
}).then(res => {
@@ -2481,8 +2486,8 @@ Page({
//调用接口判断是不是会员
await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => {
if (res.data.code == 0) {
- g_goods.guide_name = res.data.salesman;
- g_goods.guide_sn = res.data.salesman_no;
+ g_goods.guide_name = res.data.data.salesman;
+ g_goods.guide_sn = res.data.data.salesman_no;
}
})
}
@@ -2490,6 +2495,7 @@ Page({
}
pdata.push(item);
} else {
+
//---------购物车的结算---------
if (th.data.is_all_zt == 0 && th.data.user_addr == null) {
th.data.is_summit_ing = 0;
@@ -2499,6 +2505,7 @@ Page({
if (!ff) return false;
var addr = th.data.user_addr;
+ // 自提,地址数据清空 exp_type设置为1
if (th.data.is_all_zt == 1) addr = null;
var val_arr = th.data.user_note;
@@ -2509,8 +2516,8 @@ Page({
return false;
}
- var order_prom_list_cart = th.data.order_prom_list_cart;
-
+ var order_prom_list_cart = th.data.order_prom_list_cart;;
+ console.log('xxxxxxxxxxxxxxxx', order_prom_list_cart)
//--组装推送数据--
for (var i = 0; i < order_prom_list_cart.length; i++) {
var t_item = order_prom_list_cart[i];
@@ -2562,23 +2569,23 @@ Page({
order_prom_list.order_prom_amount = t_item.order_prom_amount;
}
- order_prom_list.discount_amount =0;
+ order_prom_list.discount_amount = 0;
//--判断优惠活动的提交--
if (t_item.cut_price > 0) {
order_prom_list.discount_amount += t_item.cut_price;
}
//--判断组合优惠活动的提交--
- if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) {
+ if (t_item.zh_cut_price > 0 || t_item.zh_cut_price < 0) {
order_prom_list.discount_amount += t_item.zh_cut_price;
order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json);
}
//--判断阶梯优惠活动的提交--
- if (t_item.ladder_cut_price > 0 || t_item.ladder_cut_price<0) {
+ if (t_item.ladder_cut_price > 0 || t_item.ladder_cut_price < 0) {
order_prom_list.discount_amount += t_item.ladder_cut_price;
}
- if(t_item.prom_pt_json){
+ if (t_item.prom_pt_json) {
order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json);
}
@@ -2593,11 +2600,11 @@ Page({
order_prom_list.give_lb_id = t_item.s_libao;
order_prom_list.g_lb_num = JSON.stringify(t_item.g_lb_num);
}
- if (Object.keys(order_prom_list).length > 0){
- if(order_prom_list.discount_amount)
- order_prom_list.discount_amount= parseFloat(order_prom_list.discount_amount).toFixed(2);
- if(order_prom_list.order_prom_amount)
- order_prom_list.order_prom_amount= parseFloat(order_prom_list.order_prom_amount).toFixed(2);
+ if (Object.keys(order_prom_list).length > 0) {
+ if (order_prom_list.discount_amount)
+ order_prom_list.discount_amount = parseFloat(order_prom_list.discount_amount).toFixed(2);
+ if (order_prom_list.order_prom_amount)
+ order_prom_list.order_prom_amount = parseFloat(order_prom_list.order_prom_amount).toFixed(2);
item.order_prom_list = order_prom_list;
}
@@ -2619,18 +2626,18 @@ Page({
//房间号的ids
var room_ids = "";
- //-- 把券的钱,写入从表 ---
- if (t_item.quan_youhui_list && t_item.coupon_price) {
+ //-- 把券的钱,写入从表 ---
+ if (t_item.quan_youhui_list && t_item.coupon_price) {
for (var kk in t_item.quan_youhui_list) {
var you_item = t_item.quan_youhui_list[kk];
//-- 对券的价格进行平摊 --
- await th.split_set_goods_quanprice(you_item,t_item);
+ await th.split_set_goods_quanprice(you_item, t_item);
}
}
//-------------让商品添加到商品列表--------------------
for (var k = 0; k < t_item.goods.length; k++) {
var g_item = t_item.goods[k];
- if(g_item.goods_num<=0) continue;
+ if (g_item.goods_num <= 0) continue;
var goods = {
'goods_id': g_item.goods_id,
'goods_name': g_item.goods_name,
@@ -2643,20 +2650,20 @@ Page({
};
//-- 线下取价也要写入,组合购的商品不能去线下价格 --
- if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type!=7) {
+ if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type != 7) {
goods.goods_price = g_item.offline_price;
goods.member_goods_price = g_item.offline_price;
goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2);
goods.pricing_type = g_item.pricing_type;
}
- if(g_item.quan_num){
- goods.quan_num=g_item.quan_num;
- goods.quan_no=g_item.quan_no;
+ if (g_item.quan_num) {
+ goods.quan_num = g_item.quan_num;
+ goods.quan_no = g_item.quan_no;
}
//--判断活动的类型--
switch (g_item.prom_type) {
case 1:
- case 2:
+ case 2:
case 10:
goods.prom_type = g_item.prom_type;
goods.prom_id = g_item.prom_id;
@@ -2699,7 +2706,7 @@ Page({
}
//把优惠的平摊结果写进去
- if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account!=undefined)) {
+ if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account != undefined)) {
if (g_item.account >= 0) goods.account = g_item.account;
if (g_item.account_yu != 0) goods.account_yu = g_item.account_yu;
item.is_discount_amount = 1;
@@ -2710,7 +2717,7 @@ Page({
goods.guide_id = g_item.guide_id;
goods.guide_type = g_item.guide_type;
//调用接口判断是不是会员
- await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => {
+ await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => {
if (res.data.code == 0) {
goods.guide_name = res.data.data.salesman;
goods.guide_sn = res.data.data.salesman_no;
@@ -2724,8 +2731,8 @@ Page({
}
//如果有阶梯促销
- if(g_item.ladder_list_id){
- goods.ladder_list_id=g_item.ladder_list_id;
+ if (g_item.ladder_list_id) {
+ goods.ladder_list_id = g_item.ladder_list_id;
}
item.order_goods.push(goods);
@@ -2742,7 +2749,7 @@ Page({
if (pdata.length == 0) return;
var str = JSON.stringify(pdata);
- wx.showLoading({title: "加载中"});
+ wx.showLoading({ title: "加载中" });
wx.request({
url: oo.url + '/api/weshop/order/createWxdOrder',
data: str,
@@ -2771,7 +2778,7 @@ Page({
})
//要进行判断,如果是用微信支付,就要跳转到支付界面
if (order_amount > 0) {
- th.setData({isclose: 0});
+ th.setData({ isclose: 0 });
//void e.jumpToCart4({
// order_sn: data.data,
//}, 1);
@@ -2786,12 +2793,12 @@ Page({
}, function () {
//支付失败
setTimeout(function () {
- var cps=getCurrentPages();
- if(cps.length>1){
- wx.navigateBack({delta: 1})
- }else{
- getApp().goto("/pages/index/index/index");
- }
+ var cps = getCurrentPages();
+ if (cps.length > 1) {
+ wx.navigateBack({ delta: 1 })
+ } else {
+ getApp().goto("/pages/index/index/index");
+ }
}, 1000)
}, oo.stoid);
@@ -2809,7 +2816,7 @@ Page({
if (t.data.code == 0) {
//app.my_warnning("支付成功",1,th);
//setTimeout(function () {
- th.setData({isclose: 0});
+ th.setData({ isclose: 0 });
wx.redirectTo({
url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data,
})
@@ -2834,7 +2841,7 @@ Page({
cancelText: '取消',
confirmText: '确定',
showCancel: true,
- success(res){
+ success(res) {
if (res.cancel) {
return;
} else if (res.confirm) {
@@ -2868,11 +2875,11 @@ Page({
},
//---确认线下门店的数量足不足---
- async check_store_num(goods_id, pick, goods_num, func){
+ async check_store_num(goods_id, pick, goods_num, func) {
var lock = 0, pick_no, plist, erpwareid;
//先读取门店的lock
await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
- data: {store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000}
+ data: { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 }
}).then(res => {
if (res.data.code == 0 && res.data.data.total > 0) {
for (var i in res.data.data.pageData)
@@ -2881,7 +2888,7 @@ Page({
})
//先获取门店的编号
await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, {
- data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick}
+ data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick }
}).then(res => {
if (res.data.code == 0) {
pick_no = res.data.data.pickup_no;
@@ -2889,7 +2896,7 @@ Page({
})
//先获取商品的线下库存
await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, {
- data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick}
+ data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick }
}).then(res => {
if (res.data.code == 0) {
erpwareid = res.data.data.erpwareid;
@@ -2897,7 +2904,7 @@ Page({
})
//读取线下的门店库存
await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
- data: {storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000}
+ data: { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000 }
}).then(res => {
if (res.data.code == 0) {
plist = res.data.data.pageData[0];
@@ -2939,11 +2946,11 @@ Page({
wl_txt = t.currentTarget.dataset.wl_txt,
ont = t.currentTarget.dataset.ont;
- th.setData({[txt]: ty});
+ th.setData({ [txt]: ty });
var iszt = 1;
if (ty == 0) {
- th.setData({is_all_zt: 0});
+ th.setData({ is_all_zt: 0 });
} else {
for (var i = 0; i < th.data.cartlist.length; i++) {
var item = th.data.cartlist[i];
@@ -2953,7 +2960,7 @@ Page({
}
}
- th.setData({is_all_zt: iszt});
+ th.setData({ is_all_zt: iszt });
var ind = t.currentTarget.dataset.ind;
var c_item = th.data.cartlist[ind];
@@ -2961,7 +2968,7 @@ Page({
if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1) {
th.data.using_quan[pickid] = {};
- th.setData({using_quan: th.data.using_quan});
+ th.setData({ using_quan: th.data.using_quan });
}
@@ -2973,7 +2980,7 @@ Page({
for (var i = 0; i < wu_arr.length; i++) {
if (wu_arr[i].shipping_code == def_exp_code) {
var set_txt = "cartlist"
- th.setData({wl_txt: i});
+ th.setData({ wl_txt: i });
}
}
}
@@ -2986,9 +2993,9 @@ Page({
setexptype: function (t) {
var th = this;
var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code;
- th.setData({bn_exp_type: ty});
+ th.setData({ bn_exp_type: ty });
if (ty == 0) {
- th.setData({is_all_zt: 0});
+ th.setData({ is_all_zt: 0 });
}
//当物流为空的时候。
@@ -3001,7 +3008,7 @@ Page({
if (ty == 1) {
th.data.isget_by_quan = {};
if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby == 1) {
- th.setData({using_quan: {}});
+ th.setData({ using_quan: {} });
}
}
@@ -3011,7 +3018,7 @@ Page({
if (wu_arr != null && wu_arr != "") {
for (var i = 0; i < wu_arr.length; i++) {
if (wu_arr[i].shipping_code == def_exp_code) {
- th.setData({index: i});
+ th.setData({ index: i });
}
}
}
@@ -3023,21 +3030,21 @@ Page({
//--------立即购买时,使用余额--------
set_bn_useyuer: function () {
var th = this;
- th.setData({bn_use_money: !th.data.bn_use_money});
+ th.setData({ bn_use_money: !th.data.bn_use_money });
th.calculatePrice2();
},
set_js_useyuer: function () {
var th = this;
- th.setData({js_use_money: !th.data.js_use_money});
+ th.setData({ js_use_money: !th.data.js_use_money });
th.calculatePrice();
},
//-------------------计算物流---------------
- calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight,
- goods_piece, user_addr, freight_free, o_price, rs) {
+ calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight,
+ goods_piece, user_addr, freight_free, o_price, rs, pickid) {
var price = 0, th = this;
price += parseFloat(o_shipping_price);
//如果是包邮
- if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0) {
+ if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) {
return 0;
}
if (user_addr == null) {
@@ -3055,7 +3062,7 @@ Page({
item = item.config;
if (item == null) return o_shipping_price;
//------按重量----------
- if (goods_weight >= 0 && item['money'] && out_of_weight > 0) {
+ if (goods_weight >= 0 && item['money']) {
fw_price = parseFloat(item['money']);
if (goods_weight > item['first_weight']) {
var fw = goods_weight - item['first_weight'];
@@ -3064,11 +3071,9 @@ Page({
}
}
//------超出重量----------
- if(out_of_weight < 0){
+ if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) {
fw_price = parseFloat(item['money']);
var out_of_weight = Math.abs(out_of_weight);
- // var n = Math.ceil(out_of_weight / item['second_weight'])
- // fw_price = fw_price + n * parseFloat(item['add_money']);
if (out_of_weight > item['first_weight']) {
var fw = out_of_weight - item['first_weight'];
var n = Math.ceil(fw / item['second_weight'])
@@ -3112,13 +3117,13 @@ Page({
//----------立即购买,选择物流-------------
bindPickerChange: function (e) {
var ind = e.detail.value
- this.setData({index: ind});
+ this.setData({ index: ind });
this.calculatePrice2();
},
//----------购物车结算,选择物流-------------
bindPickerChange_w: function (e) {
var ind = e.detail.value, txt = e.currentTarget.dataset.txt;
- this.setData({[txt]: ind});
+ this.setData({ [txt]: ind });
this.calculatePrice();
},
@@ -3132,7 +3137,7 @@ Page({
if (bn == 1) {
- th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1});
+ th.setData({ open_quan: 1, selected_quan_pick: pickid, disabled: 1 });
} else {
//---多单打开券的时候,就要判断券在其他门店是否有使用---
var quanlist = th.data.cartlist[cindx].quan_list;
@@ -3158,9 +3163,9 @@ Page({
else
get_by_quan_list_cart[i].show_red = 0;
}
- th.setData({by_quan_list_cart: get_by_quan_list_cart});
+ th.setData({ by_quan_list_cart: get_by_quan_list_cart });
} else {
- th.setData({by_quan_list_cart: null});
+ th.setData({ by_quan_list_cart: null });
}
console.log("2222222券的列表", quanlist);
@@ -3176,7 +3181,7 @@ Page({
},
close_coupon: function (e) {
var th = this;
- th.setData({open_quan: 0, disabled: 0});
+ th.setData({ open_quan: 0, disabled: 0 });
},
//---判断券时候在已经选择的列表中---
@@ -3247,14 +3252,14 @@ Page({
for (var i in quanlist) {
quanlist[i].show_red = 0;
}
- this.setData({selected_quan_list: quanlist});
+ this.setData({ selected_quan_list: quanlist });
var by_quanlist = this.data.get_by_quan_list;
if (by_quanlist) {
//---所有的券的显示红色选择都清理一遍---
for (var inb in by_quanlist) {
by_quanlist[inb].show_red = 0;
}
- this.setData({get_by_quan_list: by_quanlist});
+ this.setData({ get_by_quan_list: by_quanlist });
}
var by_cart_list = this.data.by_quan_list_cart;
@@ -3263,7 +3268,7 @@ Page({
for (var inc in by_cart_list) {
by_cart_list[inc].show_red = 0;
}
- this.setData({by_quan_list_cart: by_cart_list});
+ this.setData({ by_quan_list_cart: by_cart_list });
}
var using_quan = this.data.using_quan;
@@ -3275,9 +3280,9 @@ Page({
using_quan[th.data.selected_quan_pick].is_nouse_red = 1;
}
else {
- using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1};
+ using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 };
}
- this.setData({using_quan: using_quan, is_coupon: th.is_coupon});
+ this.setData({ using_quan: using_quan, is_coupon: th.is_coupon });
return;
}
@@ -3294,9 +3299,9 @@ Page({
using_quan[th.data.selected_quan_pick].is_nouse_red = 0;
}
else {
- using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0};
+ using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 };
}
- this.setData({using_quan: using_quan});
+ this.setData({ using_quan: using_quan });
},
@@ -3311,7 +3316,7 @@ Page({
for (var ind in by_quanlist) {
by_quanlist[ind].show_red = 0;
}
- this.setData({get_by_quan_list: by_quanlist});
+ this.setData({ get_by_quan_list: by_quanlist });
}
//--购物车过来的包邮券--
@@ -3321,7 +3326,7 @@ Page({
for (var ind in by_cart_list) {
by_cart_list[ind].show_red = 0;
}
- this.setData({by_quan_list_cart: by_cart_list});
+ this.setData({ by_quan_list_cart: by_cart_list });
}
//普通券
var quanlist = this.data.selected_quan_list;
@@ -3330,7 +3335,7 @@ Page({
for (var ind in quanlist) {
quanlist[ind].show_red = 0;
}
- this.setData({selected_quan_list: quanlist});
+ this.setData({ selected_quan_list: quanlist });
}
var th = this;
@@ -3341,9 +3346,9 @@ Page({
using_quan[th.data.selected_quan_pick].is_nouse_red = 1;
}
else {
- using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1};
+ using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 };
}
- this.setData({using_quan: using_quan, is_coupon: th.is_coupon});
+ this.setData({ using_quan: using_quan, is_coupon: th.is_coupon });
return;
}
@@ -3372,9 +3377,9 @@ Page({
using_quan[th.data.selected_quan_pick].is_nouse_red = 0;
}
else {
- using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0};
+ using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 };
}
- this.setData({using_quan: using_quan});
+ this.setData({ using_quan: using_quan });
},
//--确认使用券---
@@ -3434,14 +3439,14 @@ Page({
//选择了的券,看是不是点击了不使用券,点击了不使用优惠券
if (using_quan[pickid]) {
if (using_quan[pickid].is_nouse_red == 1) {
- using_quan[pickid] = {is_nouse_red: 1};
- th.setData({using_quan: using_quan});
+ using_quan[pickid] = { is_nouse_red: 1 };
+ th.setData({ using_quan: using_quan });
if (th.data.is_b_now == 1) {
th.calculatePrice2();
} else {
th.calculatePrice();
}
- th.setData({open_quan: 0});
+ th.setData({ open_quan: 0 });
return;
}
}
@@ -3460,16 +3465,16 @@ Page({
};
using_quan[pickid].isby = 1;
} else {
- using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0};
+ using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 };
using_quan[pickid].isby = 0;
}
- this.setData({using_quan: using_quan});
+ this.setData({ using_quan: using_quan });
if (th.data.is_b_now == 1) {
th.calculatePrice2();
} else {
th.calculatePrice();
}
- th.setData({open_quan: 0});
+ th.setData({ open_quan: 0 });
},
cart_set_err: function (e) {
@@ -3506,7 +3511,7 @@ Page({
var wu_arr_txt = e.currentTarget.dataset.txt;
var w_sele_index = e.currentTarget.dataset.w_sele_index;
var is_express = null;
- var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1};
+ var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 };
//--如果是多个门店的时候--
if (w_sele_index != undefined) {
@@ -3517,20 +3522,20 @@ Page({
},
// 关闭物流的弹窗
close_express: function () {
- this.setData({open_express: 0, disabled: 0});
+ this.setData({ open_express: 0, disabled: 0 });
},
// 选择物流
click_express_name: function (e) {
var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
var index = e.currentTarget.dataset.idxe;
- var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0};
+ var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 };
ob[this.data.wu_arr_txt] = index;
this.setData(ob);
},
//点击确定物流
determine_expres: function (e) {
- this.setData({open_express: 0});
+ this.setData({ open_express: 0 });
if (this.data.is_b_now == 1)
this.calculatePrice2();
else
@@ -3550,7 +3555,7 @@ Page({
obj[txt] = is_open;
this.setData(obj);
- this.setData({disabled: 1})
+ this.setData({ disabled: 1 })
},
clik_coupons2: function (e) {
@@ -3565,7 +3570,7 @@ Page({
obj[txt] = is_open;
this.setData(obj);
- this.setData({disabled: 1})
+ this.setData({ disabled: 1 })
},
@@ -3574,11 +3579,11 @@ Page({
var th = this;
var is_shipping_code = this.data.is_shipping_code
getApp().request.put("/api/weshop/users/update", {
- data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code},
+ data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code },
success: function (rse) {
if (rse.data.code == 0) {
getApp().globalData.userInfo.def_exp_code = is_shipping_code;
- th.setData({open_express: 0});
+ th.setData({ open_express: 0 });
//----计算此时购物车的价格----
if (th.data.is_b_now == 1) th.calculatePrice2();
else th.calculatePrice();
@@ -3588,7 +3593,7 @@ Page({
},
//更新下默认,在onshow里面
- update_code(){
+ update_code() {
var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
//--定时器,判断wu_arr不未空--
var uii = setInterval(function () {
@@ -3602,7 +3607,7 @@ Page({
}
//--如果是立即购买--
if (th.data.is_b_now == 1) {
- th.setData({index: m_wind, is_express: m_wind});
+ th.setData({ index: m_wind, is_express: m_wind });
} else {
var ui = setInterval(function () {
if (th.data.cartlist) {
@@ -3610,7 +3615,7 @@ Page({
for (var i in c_arr) {
c_arr[i].wind = m_wind;
}
- th.setData({cartlist: c_arr, is_express: m_wind})
+ th.setData({ cartlist: c_arr, is_express: m_wind })
clearInterval(ui);
}
}, 500)
@@ -3622,7 +3627,7 @@ Page({
get_cart_quan: async function (order_prom_list_cart) {
var th = this;
var is_xz_yh = 1;
- var user_id=getApp().globalData.user_id;
+ var user_id = getApp().globalData.user_id;
//等待值的出现
//getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () {
//var arr=th.data.order_prom_list_cart;
@@ -3641,8 +3646,8 @@ Page({
var ckeck_quan_price = 0,
check_quan_price_list = '',
check_quan_ware_list = '',
- check_quan_price_list_arr=[],
- check_quan_ware_list_arr=[];
+ check_quan_price_list_arr = [],
+ check_quan_ware_list_arr = [];
for (var i in goodlist) {
var gd = goodlist[i];
@@ -3652,25 +3657,25 @@ Page({
}
//--如果是团购,要判断有没有限制使用优惠券
- if(gd.prom_type == 2){
- var prom1=null;
+ if (gd.prom_type == 2) {
+ var prom1 = null;
await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gd.goods_id + "/" + gd.prom_id, {
}).then(res => {
if (res.data.code == 0) prom1 = res.data.data;
})
- if(prom1 && !prom1.isQuan){
+ if (prom1 && !prom1.isQuan) {
continue;
}
}
//--如果是团购,要判断有没有限制使用优惠券
- if(gd.prom_type == 10){
- var prom1=null;
- await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/"+ os.stoid +"/"+user_id+"/"+ gd.prom_id, {
+ if (gd.prom_type == 10) {
+ var prom1 = null;
+ await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + gd.prom_id, {
}).then(res => {
if (res.data.code == 0) prom1 = res.data.data;
})
- if(prom1 && prom1.isuse && prom1. is_usecoupon){
+ if (prom1 && prom1.isuse && prom1.is_usecoupon) {
continue;
}
}
@@ -3682,43 +3687,43 @@ Page({
}
is_xz_yh = 0;
- var item_price = gd.goods_price * gd.goods_num;
- var item_price2=item_price;
+ var item_price = gd.goods_price * gd.goods_num;
+ var item_price2 = item_price;
//-- 如果有平摊下去,有实收价格的时候,就要用account来计算价格 --
if (gd.account_fir != null && gd.account_fir != undefined) {
item_price2 = gd.account_fir * gd.goods_num;
}
- if(gd.ld_account){
+ if (gd.ld_account) {
item_price2 = gd.ld_account * gd.goods_num;
}
ckeck_quan_price += item_price;
//如果商品有重复的过滤,一般是组合购和阶梯购的情况下
- var idx=check_quan_ware_list_arr.findIndex(function(ele){
- return ele== encodeURIComponent(gd['erpwareid']);
+ var idx = check_quan_ware_list_arr.findIndex(function (ele) {
+ return ele == encodeURIComponent(gd['erpwareid']);
})
- if(idx>-1){
- check_quan_price_list_arr[idx]+=item_price2;
- }else{
+ if (idx > -1) {
+ check_quan_price_list_arr[idx] += item_price2;
+ } else {
check_quan_ware_list_arr.push(encodeURIComponent(gd['erpwareid']));
check_quan_price_list_arr.push(item_price2);
}
- //--组装价格list--
- /*--
- if (check_quan_price_list) {
- check_quan_price_list += "," + item_price;
- } else {
- check_quan_price_list = item_price;
- }
- //--组装商品的线下erpwareid--
- if (check_quan_ware_list) {
- check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']);
- } else {
- check_quan_ware_list = encodeURIComponent(gd['erpwareid']);
- }---*/
+ //--组装价格list--
+ /*--
+ if (check_quan_price_list) {
+ check_quan_price_list += "," + item_price;
+ } else {
+ check_quan_price_list = item_price;
+ }
+ //--组装商品的线下erpwareid--
+ if (check_quan_ware_list) {
+ check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']);
+ } else {
+ check_quan_ware_list = encodeURIComponent(gd['erpwareid']);
+ }---*/
}
//优惠券优惠的金额要控制到优惠券的选择条件
var cut_price = 0;
@@ -3729,16 +3734,16 @@ Page({
}
}
- var prom_pt_json= ep.prom_pt_json;
- if(prom_pt_json){
- for(let oj in prom_pt_json){
- let item_j=prom_pt_json[oj];
+ var prom_pt_json = ep.prom_pt_json;
+ if (prom_pt_json) {
+ for (let oj in prom_pt_json) {
+ let item_j = prom_pt_json[oj];
//要对一下阶梯优惠促销的功能
- if(item_j.ladder_prom_id){
+ if (item_j.ladder_prom_id) {
//看一下要不要限制使用优惠券
- if (th.data.ladder_map[item_j.ladder_prom_id] && th.data.ladder_map[item_j.ladder_prom_id].is_usecoupon){
+ if (th.data.ladder_map[item_j.ladder_prom_id] && th.data.ladder_map[item_j.ladder_prom_id].is_usecoupon) {
continue;
}
@@ -3747,10 +3752,10 @@ Page({
}
}
- if(check_quan_price_list_arr.length) check_quan_price_list=check_quan_price_list_arr.join(',');
- if(check_quan_ware_list_arr.length) check_quan_ware_list=check_quan_ware_list_arr.join(',')
+ if (check_quan_price_list_arr.length) check_quan_price_list = check_quan_price_list_arr.join(',');
+ if (check_quan_ware_list_arr.length) check_quan_ware_list = check_quan_ware_list_arr.join(',')
- arr[ind].ckeck_quan_price = ckeck_quan_price - (cut_price?cut_price:0);
+ arr[ind].ckeck_quan_price = ckeck_quan_price - (cut_price ? cut_price : 0);
arr[ind].check_quan_ware_list = check_quan_ware_list;
arr[ind].check_quan_price_list = check_quan_price_list;
arr[ind].is_xz_yh = is_xz_yh;
@@ -3780,10 +3785,10 @@ Page({
if (th.data.is_b_now) {
if (arr && arr.length > 0) {
var quanlist = arr[0].quan_list;
- th.setData({selected_quan_list: quanlist, cartlist: arr})
+ th.setData({ selected_quan_list: quanlist, cartlist: arr })
}
} else {
- th.setData({cartlist: arr})
+ th.setData({ cartlist: arr })
th.set_can_num();
}
@@ -3803,7 +3808,7 @@ Page({
if (th.data.is_close_quan != 1 && th.data.bn_goods.is_xz_yh != 1) {
var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
var url = "/api/weshop/couponList/getUseCouponList";
- app.request.promiseGet(url0, {1: 1}).then(res => {
+ app.request.promiseGet(url0, { 1: 1 }).then(res => {
if (res.data.code == 0) {
frozenQuan = res.data.data;
th.data.frozenQuan = frozenQuan;
@@ -3821,7 +3826,7 @@ Page({
quanlist = res.data.data.pageData;
if (quanlist) {
quanlist = th.check_is_frozenQuan(quanlist, frozenQuan);
- th.setData({selected_quan_list: quanlist})
+ th.setData({ selected_quan_list: quanlist })
}
}
}
@@ -3849,7 +3854,7 @@ Page({
if (!goods_id) goods_id = this.data.bn_goods.goods_id;
for (var i in arr) {
var item = arr[i];
- if (goods_id == item) return 0;
+ if (goods_id == item) return 0;
}
return 1;
},
@@ -3920,7 +3925,7 @@ Page({
if (this.data.is_b_now == 1) pick = this.data.bn_pick;
//---获取订单优惠---
getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
- data: {store_id: os.stoid, orderAmount: condition}
+ data: { store_id: os.stoid, orderAmount: condition }
}).then(res => {
if (res.data.code == 0) {
var data = res.data.data;
@@ -3942,7 +3947,7 @@ Page({
var ob = map[pickid][item.prom_id];
ob.price += item.goods_price * item.goods_num;
ob.goods_num += item.goods_num;
- ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
+ ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num });
} else {
var prom = null;
@@ -3958,7 +3963,7 @@ Page({
ob.is_bz = prom.is_bz;
ob.is_xz_yh = prom.is_xz_yh;
ob.goods = new Array();
- ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
+ ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num });
map[pickid][item.prom_id] = ob;
}
} else {
@@ -3975,7 +3980,7 @@ Page({
ob.is_bz = prom.is_bz;
ob.is_xz_yh = prom.is_xz_yh;
ob.goods = new Array();
- ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
+ ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num });
var obj = {};
obj[item.prom_id] = ob;
@@ -3985,12 +3990,12 @@ Page({
},
//计算立即购买赠品的物流费用
- get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,gift_weight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
+ get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, out_of_weight, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
var good = this.data.buy_now_gift_goods;
var goods_weight = -1, goods_piece = -1;
var gift_shipping_price = 0;
var th = this;
- var out_of_weight=null;
+ var out_of_weight = null;
switch (good['exp_sum_type']) {
case 1:
//统一运费
@@ -4002,7 +4007,7 @@ Page({
//累积商品重量 每种商品的重量 * 数量
goods_weight += good['weight'] * good['buynum'];
if (goods_weight1 > 0) {
- out_of_weight = gift_weight_free - goods_weight;
+ out_of_weight = gift_weight_free - goods_weight;
//不能调换位置 下面goods_weight会变大
goods_weight += goods_weight1;
}
@@ -4022,6 +4027,7 @@ Page({
if (no_by_data && no_by_data.region_list) {
if (th.check_by_area(no_by_data.region_list)) {
gift_freight_free = 0;
+ out_of_weight = 0
th.data.is_no_by[th.data.bn_pick] = 1;
}
}
@@ -4029,13 +4035,14 @@ Page({
if (no_by_data && no_by_data.goods_list && gift_freight_free) {
if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) {
gift_freight_free = 0;
- //th.data.is_no_by[th.data.bn_pick]=1;
+ out_of_weight = 0
+ th.data.is_no_by[th.data.bn_pick]=1;
}
}
var t_shipping_price =
- this.calculatewuliu(code, gift_shipping_price, goods_weight,out_of_weight,
- goods_piece, user_addr, gift_freight_free, allpice, rs);
+ this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight,
+ goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick);
return t_shipping_price;
},
@@ -4092,7 +4099,7 @@ Page({
//跳转关闭弹出框的显示
close_offline: function () {
- this.setData({is_offline_show: 0});
+ this.setData({ is_offline_show: 0 });
},
//立即购买显示弹出框
@@ -4100,7 +4107,7 @@ Page({
var off_price = this.data.bn_goods.shop_price - this.data.bn_goods.offline_price;
//是不是线下
var is_get_offline = this.data.bn_goods.is_offline;
- this.setData({is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline});
+ this.setData({ is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline });
},
//确定使用线下取价
@@ -4108,14 +4115,14 @@ Page({
var bn_goods = this.data.bn_goods;
if (bn_goods && bn_goods.prom_type == 0) {
bn_goods.is_offline = 1;
- this.setData({is_offline_show: 0, bn_goods: bn_goods});
+ this.setData({ is_offline_show: 0, bn_goods: bn_goods });
this.calculatePrice2();
}
//就是购物车结算时的
else {
var index = this.data.pop_offline_index;
var txt = "cartlist[" + index + "].is_offline";
- this.setData({[txt]: 1, is_offline_show: 0,});
+ this.setData({ [txt]: 1, is_offline_show: 0, });
this.data.old_cartlist[index].is_offline = 1;
this.calculatePrice();
}
@@ -4127,14 +4134,14 @@ Page({
var bn_goods = this.data.bn_goods;
if (bn_goods && bn_goods.prom_type == 0) {
bn_goods.is_offline = 0;
- this.setData({is_offline_show: 0, bn_goods: bn_goods});
+ this.setData({ is_offline_show: 0, bn_goods: bn_goods });
this.calculatePrice2();
}
//就是购物车结算时的
else {
var index = this.data.pop_offline_index;
var txt = "cartlist[" + index + "].is_offline";
- this.setData({[txt]: 0, is_offline_show: 0,})
+ this.setData({ [txt]: 0, is_offline_show: 0, })
this.data.old_cartlist[index].is_offline = 0;
this.calculatePrice();
}
@@ -4167,34 +4174,34 @@ Page({
// this.setData({[txt]:0})
// },
- go_url:function (e) {
+ go_url: function (e) {
var url = e.currentTarget.dataset.url;
getApp().goto(url);
},
- //进行对商品的平摊g_item是单个商品,you_item是这个商品分多少优惠券的钱,goods是商品列表
- split_set_goods_quanprice:async function (you_item,t_item) {
- var coupon_price=you_item.WareCashSum;
- var goods=t_item.goods;
- var arr=[];
+ //进行对商品的平摊g_item是单个商品,you_item是这个商品分多少优惠券的钱,goods是商品列表
+ split_set_goods_quanprice: async function (you_item, t_item) {
+ var coupon_price = you_item.WareCashSum;
+ var goods = t_item.goods;
+ var arr = [];
//判断是不是有goods_id重复
- for(var i=0;i {
@@ -4217,21 +4224,21 @@ Page({
for (var i in pt_res) {
var idx = pt_res[i].idx;
//有account的实收价,就要用account实收价
- var price=(t_item.goods[idx].account?t_item.goods[idx].account:t_item.goods[idx].goods_price);
- price=(price - pt_res[i].fisrt_account)* t_item.goods[idx].goods_num;
- t_item.goods[idx].quan_num =price;
+ var price = (t_item.goods[idx].account ? t_item.goods[idx].account : t_item.goods[idx].goods_price);
+ price = (price - pt_res[i].fisrt_account) * t_item.goods[idx].goods_num;
+ t_item.goods[idx].quan_num = price;
- t_item.goods[idx].quan_num =Math.floor(t_item.goods[idx].quan_num * 100) / 100;
- t_item.goods[idx].quan_no=t_item.quan_no;
+ t_item.goods[idx].quan_num = Math.floor(t_item.goods[idx].quan_num * 100) / 100;
+ t_item.goods[idx].quan_no = t_item.quan_no;
q_s_num += t_item.goods[idx].quan_num;
}
- if (q_s_num > parseFloat(coupon_price) || q_s_num < parseFloat(coupon_price)){
+ if (q_s_num > parseFloat(coupon_price) || q_s_num < parseFloat(coupon_price)) {
for (var ik in arr) {
if (arr[ik].goods_num == 1) {
var id = arr[ik].idx;
- var pri=Math.floor(coupon_price*100)/100-Math.floor(q_s_num*100)/100
- t_item.goods[id].quan_num+=pri;
+ var pri = Math.floor(coupon_price * 100) / 100 - Math.floor(q_s_num * 100) / 100
+ t_item.goods[id].quan_num += pri;
break;
}
}
@@ -4239,8 +4246,7 @@ Page({
}
},
//订阅消息提醒
- sendsm:function(func)
- {
+ sendsm: function (func) {
var template_id = this.data.template_id;
// //授权订阅
wx.requestSubscribeMessage({
diff --git a/pages/cart/cart2/zh_calculate.js b/pages/cart/cart2/zh_calculate.js
index 0475ca1..a1c204e 100644
--- a/pages/cart/cart2/zh_calculate.js
+++ b/pages/cart/cart2/zh_calculate.js
@@ -152,15 +152,7 @@ module.exports = {
if (act.is_bzyh && zhqty_bz.length > 0) {
if (zhqty_bz.length > 1) {
let zhqty_bz_arr = [];
- let zhqty_bz_flag = zhqty_bz.every((item1, i) => {
- var bz_num = be * item1['zhqty']; //超量倍增
- var num = item1['num'] - item1['zhqty']; //购买数量减去超量
- if (bz_num > num) {
- zhqty_bz_arr.push(item1);
- zhqty_bz.splice(i, 1)
- }
- return bz_num <= num;
- })
+ let zhqty_bz_flag=this.zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr);
if (zhqty_bz_flag) {
for (let i = 0; i < zhqty_bz.length; i++) {
var vv = zhqty_bz[i];
@@ -175,11 +167,12 @@ module.exports = {
}
}
} else {
+ zhqty_len=1;
let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) {
- return o['num']
+ return o['num'];
}));
let new_arr = zhqty_bz_arr.filter(ii => {
- return ii['num'] == min_bz_num
+ return ii['num'] == min_bz_num;
})
var vv = new_arr[0];
var bz_num = be * new_arr[0].zhqty; //超量倍增
@@ -198,18 +191,22 @@ module.exports = {
}
bz_num_ok = be * vv.zhqty;
}
-
- for (let j = 0; j < bz_num_ok; j++) {
- let index = no_in_arr.findIndex(i => {
- return vv.goods_id === i.goods_id
- })
- if (index > -1) {
- delete_num++
- no_in_arr.splice(index, 1)
+
+ for(let i = 0; i < zhqty_bz.length; i++){
+ let item1=zhqty_bz[i];
+ for (let j = 0; j < be * item1['zhqty']; j++) {
+ let index = no_in_arr.findIndex(i => {
+ return item1.goods_id === i.goods_id
+ })
+ if (index > -1) {
+ // delete_num++
+ no_in_arr.splice(index, 1)
+ }
}
}
+ aprice += be * aprice;
}
- } else {
+ } else {
var vv = zhqty_bz[0];
var bz_num = be * vv.zhqty; //超量倍增
var num = vv['num'] - vv.zhqty; //购买数量减去超量
@@ -223,19 +220,16 @@ module.exports = {
// be=be-bz_num_ok;
if (num % vv.zhqty == 0) {
be = num / vv.zhqty;
- // bz_num_ok = num;
} else {
be = Math.floor(num / vv.zhqty)
- // bz_num_ok = num - (be * vv.zhqty);
}
bz_num_ok = be * vv.zhqty;
}
- // be=vv.num;
for (let j = 0; j < bz_num_ok; j++) {
let index = no_in_arr.findIndex(i => {
return vv.goods_id === i.goods_id
})
- if(index > -1){
+ if (index > -1) {
delete_num++
no_in_arr.splice(index, 1)
}
@@ -515,6 +509,20 @@ module.exports = {
}
+ },
+ zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr){
+ let zhqty_bz_flag =true;
+ for(let i=0;i num) {
+ zhqty_bz_flag=false;
+ zhqty_bz_arr.push(item);
+ // zhqty_bz.splice(i,1)
+ }
+ }
+ return zhqty_bz_flag;
}
diff --git a/pages/cart/cart2_inte/cart2_inte.js b/pages/cart/cart2_inte/cart2_inte.js
index 0f2a7f6..bd33015 100644
--- a/pages/cart/cart2_inte/cart2_inte.js
+++ b/pages/cart/cart2_inte/cart2_inte.js
@@ -1,12 +1,12 @@
-var t = getApp(),app=t, a = t.request, e = require("../../../utils/common.js"),
- s = require("../../../utils/util.js"),ut=s, o = require("../../../utils/md5.js"), to = getApp();
-var oo=t.globalData.setting,os=oo;
+var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"),
+ s = require("../../../utils/util.js"), ut = s, o = require("../../../utils/md5.js"), to = getApp();
+var oo = t.globalData.setting, os = oo;
var regeneratorRuntime = require('../../../utils/runtime.js');
var util_pay = require("../../../utils/pay.js");
-Page({
+Page({
data: {
- url: t.globalData.setting.url,
+ url: t.globalData.setting.url,
imgUrl: t.globalData.setting.imghost,
goods: null,
order: null,
@@ -20,361 +20,361 @@ Page({
enterAddressPage: !1,
firstEnter: !0,
//页面获取的参数
- param:null,
+ param: null,
//提交订单的格式
formData: {
- order_amount:0,//支付金额
- total_amount:0,//总价
- all_price:0,//商品卖的总价
+ order_amount: 0,//支付金额
+ total_amount: 0,//总价
+ all_price: 0,//商品卖的总价
pay_points: 0,//使用积分
user_money: 0,//使用余额
couponCode: "",//使用优惠券(多单就用逗号隔开)
- shipping_price:0,//物流费用
+ shipping_price: 0,//物流费用
},
/*----------------立即购买---------------------*/
- is_b_now:1, //0是购物车结算 1立即购买
- bn_goods:null, //立即购买时候的调用商品
- bn_use_money:0,//是否使用余额
- bn_exp_type:1, //0是物流 1自提
- bn_pick:0, //选择的门店
+ is_b_now: 1, //0是购物车结算 1立即购买
+ bn_goods: null, //立即购买时候的调用商品
+ bn_use_money: 0,//是否使用余额
+ bn_exp_type: 1, //0是物流 1自提
+ bn_pick: 0, //选择的门店
bn_pickname: "", //选择的门店名称
- bn_t_exp_t:0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流
-
- bn_plus_cut_price:0, //显示等级卡会优惠多少钱
+ bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流
+
+ bn_plus_cut_price: 0, //显示等级卡会优惠多少钱
/*------------------------*/
- user_addr:null,//物流
- userinfo:null, //获取会员
+ user_addr: null,//物流
+ userinfo: null, //获取会员
/*----------物流选择--------*/
- wu_arr:null,
- index:0,
- w_sele_index:0,
+ wu_arr: null,
+ index: 0,
+ w_sele_index: 0,
//判断页面是返回回来的还是 首次进入的
- isclose:1,
+ isclose: 1,
//申请提现的金额
- txmon:0,
- yuer:0,
+ txmon: 0,
+ yuer: 0,
//提交中,不重复提交
- is_summit_ing:0,
-
- disabled:0,
- open_express:0,//控制选择物流名列表 的属性
-
- is_express:0, //选中物流的属性
- expres_name:"", //点击选定
- is_shipping_code:"",//插入用户默认地址
- wu_arr_txt:"", //要更新的物流的字段
-
- //如果是全场包邮了,或者是全场不包邮了,就不要选包邮券
- is_no_by:{},
- is_by:{},
- is_quan_by:{},
+ is_summit_ing: 0,
+
+ disabled: 0,
+ open_express: 0,//控制选择物流名列表 的属性
+
+ is_express: 0, //选中物流的属性
+ expres_name: "", //点击选定
+ is_shipping_code: "",//插入用户默认地址
+ wu_arr_txt: "", //要更新的物流的字段
+
+ //如果是全场包邮了,或者是全场不包邮了,就不要选包邮券
+ is_no_by: {},
+ is_by: {},
+ is_quan_by: {},
//--购买赠送的商品--
- buy_now_gift_goods:null,
+ buy_now_gift_goods: null,
//--订单优惠--
- order_prom:{},
- show_submit:0, //提交按钮变正常显示
+ order_prom: {},
+ show_submit: 0, //提交按钮变正常显示
},
- onLoad: function(t) {
- wx.setNavigationBarTitle({ title: "填写订单",})
- var th = this;
- th.data.param=t;
+ onLoad: function (t) {
+ wx.setNavigationBarTitle({ title: "填写订单", })
+ var th = this;
+ th.data.param = t;
//清空is_pick_up
getApp().request.put("/api/weshop/useraddress/updatePickUp", {
- data: {user_id: getApp().globalData.user_id, is_pickup: 0},
- success: function (s) {
- }
+ data: { user_id: getApp().globalData.user_id, is_pickup: 0 },
+ success: function (s) {
+ }
});
-
- //先获取是否有关闭使用优惠券
- getApp().getConfig2(function (ee) {
- var json_d = JSON.parse(ee.switch_list);
- th.data.json_d=json_d;
- th.data.ispt_goods=json_d.ispt_goods; //是不是平摊到单品的控制参数赋值
- var is_default_logistics=json_d.is_default_logistics;
- th.setData({ is_close_quan: json_d.is_close_quan,sales_rules:ee.sales_rules,rank_switch:json_d.rank_switch,is_default_logistics:is_default_logistics});
-
- var rank_switch=json_d.rank_switch;
- var max_price=-1;
- var show_card=null;
- var name="";
- //如果有开等级卡的时候,
- //因为都是调接口,要返回在计算
- if(rank_switch==2){
- //-- 获取所有的等级卡, --
- getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid,
- {}).then(res => {
- if(res.data.code==0){
- var plusCard = res.data.data;
- //-- 循环判断,拿到最贵的那张卡 --
- for(var ih in plusCard){
- if(plusCard[ih].IsStopBuy == true){ continue; }
- if(max_price<0){
- max_price=plusCard[ih].CardFee;
- name='card'+plusCard[ih]['CorrPrice'];
- show_card=plusCard[ih];
- }else{
- if(max_price {
+ if (res.data.code == 0) {
+ var plusCard = res.data.data;
+ //-- 循环判断,拿到最贵的那张卡 --
+ for (var ih in plusCard) {
+ if (plusCard[ih].IsStopBuy == true) { continue; }
+ if (max_price < 0) {
+ max_price = plusCard[ih].CardFee;
+ name = 'card' + plusCard[ih]['CorrPrice'];
+ show_card = plusCard[ih];
+ } else {
+ if (max_price < plusCard[ih].CardFee) {
+ max_price = plusCard[ih].CardFee;
+ name = 'card' + plusCard[ih]['CorrPrice'];
+ show_card = plusCard[ih];
+ }
+ }
+ }
+
+ if (show_card) {
+ name = name.toLowerCase();
+ th.setData({ card_name: name, show_card: show_card })
+ }
+ }
+ //-----先获取物流,再获取用户信息,再展示页面-----
+ th.get_wuliu(th.get_info(th.show_page));
+ })
+ } else {
+ //-----先获取物流,再获取用户信息,再展示页面-----
+ th.get_wuliu(th.get_info(th.show_page));
+ }
+ }, 1);
+
+
},
- onUnload: function () { this.setData({ isclose: 1 })},
+ onUnload: function () { this.setData({ isclose: 1 }) },
onHide: function () {
- this.setData({
- is_no_by:{},
- is_by:{}
- })
+ this.setData({
+ is_no_by: {},
+ is_by: {}
+ })
},
//----------子页返回父页触发----------
- onShow: function() {
- var th=this;
- th.data.g_cart_q_time=null;
-
- if (th.data.isclose==0){
+ onShow: function () {
+ var th = this;
+ th.data.g_cart_q_time = null;
+
+ if (th.data.isclose == 0) {
wx.navigateTo({
url: "/pages/index/index/index"
})
- }else{
- this.getuser_addr(function(ie){
- /*--
- //地址切换要把包邮券清空
- if( !th.data.user_addr || !ie || th.data.user_addr.address_id!=ie.address_id){
- var using_quan=th.data.using_quan;
- for(var i in using_quan){
- var item=using_quan[i];
- if(item.isby==1){
- var ob={},txt="using_quan["+i+"]";ob[txt]={};
- th.setData(ob);
- }
+ } else {
+ this.getuser_addr(function (ie) {
+ /*--
+ //地址切换要把包邮券清空
+ if( !th.data.user_addr || !ie || th.data.user_addr.address_id!=ie.address_id){
+ var using_quan=th.data.using_quan;
+ for(var i in using_quan){
+ var item=using_quan[i];
+ if(item.isby==1){
+ var ob={},txt="using_quan["+i+"]";ob[txt]={};
+ th.setData(ob);
+ }
+ }
+
+ }--*/
+
+ //th.data.prom_goods_map={};
+ //更换地址回来要重新调用计算价钱的接口
+ if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
+ th.setData({ user_addr: ie, show_submit: 0 });
+ if (th.data.is_b_now == 1) {
+ if (th.data.bn_goods) {
+ th.setData({ add_back: 1 });
+ th.calculatePrice2();
}
-
- }--*/
-
- //th.data.prom_goods_map={};
- //更换地址回来要重新调用计算价钱的接口
- if(!th.data.user_addr || th.data.user_addr.address_id!=ie.address_id){
- th.setData({user_addr: ie,show_submit:0 });
- if (th.data.is_b_now == 1) {
- if(th.data.bn_goods) {
- th.setData({add_back:1});
- th.calculatePrice2();
- }
- }
- }else{
- th.setData({user_addr: ie });
- }
- var going=0;
-
- });
- //--更新默认地址--,看一下是不是跳到地址页面
- if(!getApp().globalData.is_cart_old){
- this.update_code();
- }else{
- getApp().globalData.is_cart_old=0;
+ }
+ } else {
+ th.setData({ user_addr: ie });
}
+ var going = 0;
+
+ });
+ //--更新默认地址--,看一下是不是跳到地址页面
+ if (!getApp().globalData.is_cart_old) {
+ this.update_code();
+ } else {
+ getApp().globalData.is_cart_old = 0;
+ }
}
-
+
},
//-------------------获取物流---------------
get_wuliu(func) {
var th = this;
to.getwuliu(function (e) {
- if(th.data.is_default_logistics){
- //如果第一个不是开启默认,说明要让用户自己选
- if(!e[0].is_default){
- th.setData({is_default_logistics:0});
- }
- }
- th.setData({ wu_arr: e })
- typeof func == "function" && func();
+ if (th.data.is_default_logistics) {
+ //如果第一个不是开启默认,说明要让用户自己选
+ if (!e[0].is_default) {
+ th.setData({ is_default_logistics: 0 });
+ }
+ }
+ th.setData({ wu_arr: e })
+ typeof func == "function" && func();
})
},
//------获取会员信息-----先获取用户信息,在进行下一步---
- get_info:function(func){
+ get_info: function (func) {
var user_id = t.globalData.user_id;
to.auth.get_u(func);
},
//------获取会员收货地址-----
- getuser_addr:function(func){
- var th=this;
- a.get("/api/weshop/useraddress/page", {
- data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600,t:Math.random()},
- success: function (su) {
-
- var item = null;
- if(su.data.code==0 && su.data.data && su.data.data.pageData){
- var user_addr = su.data.data.pageData;
- var def_item=null;
- for (var i = 0; i < user_addr.length; i++) {
- if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i];}
- if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; }
- }
-
- if (item == null) item = def_item;
- if (item == null) item = user_addr[0];
- }
-
- if(item==undefined) item=null;
- if(!item) th.setData({user_addr:null}); //地址为空的时候,要清空,因为返回的时候,有缓存
- func(item);
+ getuser_addr: function (func) {
+ var th = this;
+ a.get("/api/weshop/useraddress/page", {
+ data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random() },
+ success: function (su) {
+
+ var item = null;
+ if (su.data.code == 0 && su.data.data && su.data.data.pageData) {
+ var user_addr = su.data.data.pageData;
+ var def_item = null;
+ for (var i = 0; i < user_addr.length; i++) {
+ if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; }
+ if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; }
+ }
+
+ if (item == null) item = def_item;
+ if (item == null) item = user_addr[0];
}
- });
+
+ if (item == undefined) item = null;
+ if (!item) th.setData({ user_addr: null }); //地址为空的时候,要清空,因为返回的时候,有缓存
+ func(item);
+ }
+ });
},
-
+
//----------------展示页面,是再获取用户信息之后--------------
- show_page:function(){
- var th=this,ta = this.data.param;
+ show_page: function () {
+ var th = this, ta = this.data.param;
//th.setData({ userinfo: getApp().globalData.userInfo,});
-
- var user=getApp().globalData.userInfo;
- getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, {
- data:{r:Math.random()},
- success: function (e) {
-
- getApp().globalData.userInfo = e.data.data;
- th.setData({userinfo:e.data.data});
-
- //选获取地址
- th.getuser_addr(function(addr){
- th.setData({user_addr: addr});
- //--------------------------立即购买------------------
- if(ta.is_bnow== 1){
- //读取门店
- to.get_allsto(function (e) {
- th.setData({ allsto: e });
- //获取立即购买的商品信息
- th.get_buy_goods(ta.goods_id);
- });
- }
- });
- //获取提现金额
- getApp().request.get("/api/weshop/withdrawals/summoney", {
- data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 },
- success: function (su) {
- if (su.data.code == 0) {
- var yuer = parseFloat(th.data.userinfo.user_money -
- (th.data.userinfo.frozen_money>0?th.data.userinfo.frozen_money:0) - su.data.data.summoney).toFixed(2);
- th.setData({ txmon: su.data.data.summoney, yuer: yuer });
- }
- }
- });
-
- },
- })
-
-
+
+ var user = getApp().globalData.userInfo;
+ getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, {
+ data: { r: Math.random() },
+ success: function (e) {
+
+ getApp().globalData.userInfo = e.data.data;
+ th.setData({ userinfo: e.data.data });
+
+ //选获取地址
+ th.getuser_addr(function (addr) {
+ th.setData({ user_addr: addr });
+ //--------------------------立即购买------------------
+ if (ta.is_bnow == 1) {
+ //读取门店
+ to.get_allsto(function (e) {
+ th.setData({ allsto: e });
+ //获取立即购买的商品信息
+ th.get_buy_goods(ta.goods_id);
+ });
+ }
+ });
+ //获取提现金额
+ getApp().request.get("/api/weshop/withdrawals/summoney", {
+ data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 },
+ success: function (su) {
+ if (su.data.code == 0) {
+ var yuer = parseFloat(th.data.userinfo.user_money -
+ (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2);
+ th.setData({ txmon: su.data.data.summoney, yuer: yuer });
+ }
+ }
+ });
+
+ },
+ })
+
+
},
-
+
//-----获取立即购买的商品信息,入口----
- get_buy_goods: function (e){
- var th=this;
+ get_buy_goods: function (e) {
+ var th = this;
var gg = to.get_b_now();
//--------如果goods_id一样,就是要立即购买-----
- if(e==gg.goods_id){
- a.get("/api/weshop/goods/get/" + oo.stoid+"/"+e, {
- success:async function (t) {
+ if (e == gg.goods_id) {
+ a.get("/api/weshop/goods/get/" + oo.stoid + "/" + e, {
+ success: async function (t) {
var gd = t.data.data;
- if(!gd) return false;
+ if (!gd) return false;
t.data.data.original_img = oo.imghost + t.data.data.original_img;
t.data.data['buynum'] = gg.goods_num;
- var distr_t=0,et=0
- if (t.data.data.distr_type==0){
+ var distr_t = 0, et = 0
+ if (t.data.data.distr_type == 0) {
distr_t = gg.pick_dis;
- }else{
+ } else {
distr_t = t.data.data.distr_type;
}
- switch (distr_t){
+ switch (distr_t) {
case 0:
- et=1;
- //-- 系统后台有设置要默认的 --
- if(th.data.json_d.pickupway && th.data.json_d.pickupway==1) et=0;
- break;
+ et = 1;
+ //-- 系统后台有设置要默认的 --
+ if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0;
+ break;
case 1: et = 1; break;
case 2: et = 0; break;
}
-
- if(th.data.bn_goods) et=th.data.bn_exp_type
-
- var m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code;
- if(et==0 && def_exp_code){
- for(var k=0;k0 && gg.goods_price>gd[th.data.card_name] && !th.data.userinfo.card_field){
- var cut_p= (gg.goods_price-gd[th.data.card_name])*gg.goods_num;
- th.setData({card_cut_price:cut_p});
- }
- }
-
- switch (gd.prom_type){
+
+ //---是不是购买等级卡成功的返回---等级卡显示的判断---
+ var is_card_back = getApp().globalData.is_card_back;
+ if (is_card_back) {
+ th.data.card_name = th.data.userinfo.card_field;
+ gg.goods_price = gd[th.data.card_name];
+ getApp().globalData.is_card_back = 0;
+ th.setData({ card_cut_price: 0 });
+ //如果是秒杀的返回
+ if (gd.prom_type == 4) gd.prom_type = 0;
+ } else {
+ //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格
+ //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 --
+ if (!gg.collocation_goods && gd['prom_type'] != 6 && th.data.card_name && gd[th.data.card_name] > 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) {
+ var cut_p = (gg.goods_price - gd[th.data.card_name]) * gg.goods_num;
+ th.setData({ card_cut_price: cut_p });
+ }
+ }
+
+ switch (gd.prom_type) {
case 0:
case 2:
case 3:
case 5:
case 6:
- getApp().my_warnning("商品不是积分活动",0,th);
- wx.navigateBack();
- break;
+ getApp().my_warnning("商品不是积分活动", 0, th);
+ wx.navigateBack();
+ break;
case 4: //-- 积分购 --
- getApp().request.get("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
- data:{store_id:os.stoid,goods_id:gg.goods_id},
+ getApp().request.get("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", {
+ data: { store_id: os.stoid, goods_id: gg.goods_id },
success: async function (tt) {
- if(tt.data.code==0 && tt.data.data && tt.data.data.pageData){
- var inte_data=tt.data.data.pageData[0];
- t.data.data.shop_price=inte_data.addmoney;
- t.data.data.integral=inte_data.integral;
- th.setData({
- bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind,
- bn_pick: gg.pick_id, bn_t_exp_t: distr_t,bn_exp_type: et
- });
- //计算价格
- th.calculatePrice2();
- }else{
- getApp().my_warnning("商品不是积分活动",0,th);
- wx.navigateBack();
- }
+ if (tt.data.code == 0 && tt.data.data && tt.data.data.pageData) {
+ var inte_data = tt.data.data.pageData[0];
+ t.data.data.shop_price = inte_data.addmoney;
+ t.data.data.integral = inte_data.integral;
+ th.setData({
+ bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, index: m_wind,
+ bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et
+ });
+ //计算价格
+ th.calculatePrice2();
+ } else {
+ getApp().my_warnning("商品不是积分活动", 0, th);
+ wx.navigateBack();
+ }
}
});
break;
@@ -385,34 +385,34 @@ Page({
},
//---------------检查是否有收货地址-------------------
- checkAddressList: function() {
+ checkAddressList: function () {
var t = this;
return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({
title: "请先填写或选择收货地址~",
- success: function(a) {
+ success: function (a) {
a.confirm ? t.enterAddressPage() : wx.navigateBack();
},
- fail: function() {
+ fail: function () {
wx.navigateBack();
}
}), !1);
},
- showInvoice: function() {
+ showInvoice: function () {
this.setData({
invoiceToggle: !this.data.invoiceToggle
});
},
- keyUpChangePay1: function(t) {
+ keyUpChangePay1: function (t) {
this.setData({
payWithUserMoney: !(t.detail.value.length > 0)
});
},
- keyUpChangePay2: function(t) {
+ keyUpChangePay2: function (t) {
this.setData({
payWithPoints: !(t.detail.value.length > 0)
});
},
- keyUpChangeNum: function(t) {
+ keyUpChangeNum: function (t) {
this.setData({
maxWord: t.detail.value.length
});
@@ -421,30 +421,33 @@ Page({
//---------计算立即购买----------
calculatePrice2: function () {
- var th = this, good = this.data.bn_goods;
- wx.showLoading({ title:"处理中.",})
+ var th = this, good = this.data.bn_goods;
+ wx.showLoading({ title: "处理中.", })
//-----------计算商品总价--------------
var allpice = good.shop_price * good.buynum;
- var all_integral=good.integral * good.buynum;
-
- var cut_price=0;
- if(good.prom_type==3 && good.prom_price!==null){
- cut_price=allpice-good.prom_price;
+ var all_integral = good.integral * good.buynum;
+
+ var cut_price = 0;
+ if (good.prom_type == 3 && good.prom_price !== null) {
+ cut_price = allpice - good.prom_price;
}
- allpice=parseFloat(allpice).toFixed(2);
+ allpice = parseFloat(allpice).toFixed(2);
var txt = "formData.all_price";
th.setData({ [txt]: allpice, });
- if(cut_price){
- var c_txt="formData.cut_price";
+ if (cut_price) {
+ var c_txt = "formData.cut_price";
th.setData({ [c_txt]: cut_price, });
}
to.getConfig2(function (ee) {
to.getwuliuprice(async function (rs) {
var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
+ var out_of_weight = null; //超出多少重量
+ var freight_free = ee.freight_free; //全场满多少包邮
+ var weight_free = ee.weight_free; //多少kg内包邮
//-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮----------
- if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past!=1 ){
-
+ if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1) {
+
switch (good['exp_sum_type']) {
case 1:
//统一运费
@@ -452,100 +455,105 @@ Page({
case 2:
if (goods_weight < 0) goods_weight = 0;
//累积商品重量 每种商品的重量 * 数量
- goods_weight += good['weight'] * good['buynum'];break;
+ goods_weight += good['weight'] * good['buynum'];
+ if (weight_free > 0) {
+ out_of_weight = (weight_free * 1000) - goods_weight;
+ }
+ break;
case 3:
if (goods_piece < 0) goods_piece = 0;
//累积商品数量
goods_piece += good['buynum']; break;
}
- var code ="";
- if(th.data.wu_arr && th.data.wu_arr[th.data.index]) code=th.data.wu_arr[th.data.index].code;
- var freight_free = ee.freight_free; //全场满多少包邮
- var no_ex_id=ee.no_ex_id;
- th.data.is_no_by[th.data.bn_pick]=0;
-
- var no_by_data=null;
- var gift_freight_free=freight_free;
- //有不包邮区域,且不免运费
- if(no_ex_id && freight_free>0 && freight_free<=allpice-cut_price){
- //-----------获取不包邮区域,不包邮商品-------
- await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods",{
- data:{store_id:os.stoid,id:no_ex_id}
- }).then(res=>{
- if(res.data.code==0){
- no_by_data=res.data.data[0];
- //如果有设置不包邮区域的时候
- if(res.data.data[0].region_list){
- if(th.check_by_area(res.data.data[0].region_list)){
- freight_free=0;
- th.data.is_no_by[th.data.bn_pick]=1;
- }
- }
- //如果有设置不包邮商品
- if(res.data.data[0].goods_list && freight_free){
- if(th.check_by_goods(res.data.data[0].goods_list)){
- freight_free=0;
- th.data.is_no_by[th.data.bn_pick]=1;
- }
- }
- }
- })
- }
-
- th.data.is_by[th.data.bn_pick]=0;
- //--------------开始计算物流------------------
- var shipping_price=
- th.calculatewuliu(code, o_shipping_price, goods_weight,
- goods_piece, th.data.user_addr, freight_free, allpice-cut_price, rs);
- if(shipping_price<=0){
- th.data.is_by[th.data.bn_pick]=1; //已经是包邮了,就不要选择包邮券
+ var code = "";
+ if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
+ var no_ex_id = ee.no_ex_id;
+ th.data.is_no_by[th.data.bn_pick] = 0;
+ var no_by_data = null;
+ var gift_freight_free = freight_free;
+ //有不包邮区域,且不免运费
+ if (no_ex_id && freight_free > 0 && freight_free <= allpice - cut_price) {
+ //-----------获取不包邮区域,不包邮商品-------
+ await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
+ data: { store_id: os.stoid, id: no_ex_id }
+ }).then(res => {
+ if (res.data.code == 0) {
+ no_by_data = res.data.data[0];
+ //如果有设置不包邮区域的时候
+ if (res.data.data[0].region_list) {
+ if (th.check_by_area(res.data.data[0].region_list)) {
+ freight_free = 0;
+ out_of_weight = 0;
+ weight_free = -1;
+ th.data.is_no_by[th.data.bn_pick] = 1;
+ }
+ }
+ //如果有设置不包邮商品
+ if (res.data.data[0].goods_list && freight_free) {
+ if (th.check_by_goods(res.data.data[0].goods_list)) {
+ freight_free = 0;
+ out_of_weight = 0;
+ weight_free = -1;
+ th.data.is_no_by[th.data.bn_pick] = 1;
+ }
+ }
+ }
+ })
+ }
+
+ //--------------开始计算物流------------------
+ var shipping_price =
+ th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
+ goods_piece, th.data.user_addr, freight_free, allpice - cut_price, rs, th.data.bn_pick);
+ if (shipping_price <= 0) {
+ th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
}
shipping_price = parseFloat(shipping_price).toFixed(2);
var wl_txt = "formData.shipping_price";
th.setData({ [wl_txt]: shipping_price, })
-
- }else{
+
+ } else {
var wl_txt = "formData.shipping_price";
th.setData({ [wl_txt]: 0, })
}
//---如果有选择优惠券的情况下---
- var quan_price=0,bn_pick=th.data.bn_pick;
-
- //-----------------支付价,优惠券不减物流-----------------
+ var quan_price = 0, bn_pick = th.data.bn_pick;
+
+ //-----------------支付价,优惠券不减物流-----------------
var total_m = (parseFloat(allpice)).toFixed(2);
- var order_m = (parseFloat(allpice-cut_price)-quan_price).toFixed(2);
- var coupon_price=quan_price; //优惠券优惠了多少钱
- if(order_m<0) {
- order_m=0;coupon_price=parseFloat(order_m).toFixed(2);
+ var order_m = (parseFloat(allpice - cut_price) - quan_price).toFixed(2);
+ var coupon_price = quan_price; //优惠券优惠了多少钱
+ if (order_m < 0) {
+ order_m = 0; coupon_price = parseFloat(order_m).toFixed(2);
}
-
- //--看一下有没有订单优惠--
- total_m= parseFloat( total_m)+ parseFloat( th.data.formData.shipping_price);
- order_m = parseFloat(order_m)+ parseFloat( th.data.formData.shipping_price);
- var atxt= "formData.total_amount";
- th.setData({ [atxt]: total_m, })
-
- var txt = "formData.user_money";
- var txt2 = "formData.order_amount";
- var txt4="formData.integral";
-
- var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
- //--------------如果使用余额---------------------
- if (th.data.bn_use_money == 1) {
- if (amoney> order_m) {
- order_m = order_m.toFixed(2);
- th.setData({ [txt]: order_m, [txt2]:0,[txt4]:all_integral,show_submit:1 })
- }else{
- order_m =parseFloat(order_m - amoney);
- order_m = order_m.toFixed(2);
- th.setData({ [txt]: amoney, [txt2]: order_m,[txt4]:all_integral,show_submit:1 })
- }
- }else{
- th.setData({ [txt]: 0, [txt2]: order_m,[txt4]:all_integral, show_submit:1 })
- }
-
+
+ //--看一下有没有订单优惠--0
+ total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price);
+ order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price);
+ var atxt = "formData.total_amount";
+ th.setData({ [atxt]: total_m, })
+
+ var txt = "formData.user_money";
+ var txt2 = "formData.order_amount";
+ var txt4 = "formData.integral";
+
+ var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
+ //--------------如果使用余额---------------------
+ if (th.data.bn_use_money == 1) {
+ if (amoney > order_m) {
+ order_m = order_m.toFixed(2);
+ th.setData({ [txt]: order_m, [txt2]: 0, [txt4]: all_integral, show_submit: 1 })
+ } else {
+ order_m = parseFloat(order_m - amoney);
+ order_m = order_m.toFixed(2);
+ th.setData({ [txt]: amoney, [txt2]: order_m, [txt4]: all_integral, show_submit: 1 })
+ }
+ } else {
+ th.setData({ [txt]: 0, [txt2]: order_m, [txt4]: all_integral, show_submit: 1 })
+ }
+
wx.hideLoading();
});
@@ -553,104 +561,104 @@ Page({
},
//--------------------提交订单-----------------------
- async submitForm(t){
- var sub_value=t;
+ async submitForm(t) {
+ var sub_value = t;
- if(this.data.is_summit_ing==1) return false; //--提交中退出--
- this.data.is_summit_ing=1;
- var th=this,pdata=new Array();
- var ff=true;
+ if (this.data.is_summit_ing == 1) return false; //--提交中退出--
+ this.data.is_summit_ing = 1;
+ var th = this, pdata = new Array();
+ var ff = true;
//------------立即购买-------------
- if (th.data.is_b_now==1 && th.data.bn_goods.prom_type!=5){
+ if (th.data.is_b_now == 1 && th.data.bn_goods.prom_type != 5) {
- if(th.data.bn_exp_type == 0 && th.data.user_addr==null ){
- ff = false; getApp().my_warnning("请选择收货地址",0,th);
- th.data.is_summit_ing = 0;
+ if (th.data.bn_exp_type == 0 && th.data.user_addr == null) {
+ ff = false; getApp().my_warnning("请选择收货地址", 0, th);
+ th.data.is_summit_ing = 0;
}
if (!ff) return false;
var addr = th.data.user_addr;
- if (th.data.bn_exp_type == 1) addr=null;
+ if (th.data.bn_exp_type == 1) addr = null;
- if(th.data.bn_exp_type==0)
- if(th.data.wu_arr==null || th.data.wu_arr.length<=0){
- getApp().my_warnning("读取物流失败",0,th);
- th.data.is_summit_ing = 0;
+ if (th.data.bn_exp_type == 0)
+ if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
+ getApp().my_warnning("读取物流失败", 0, th);
+ th.data.is_summit_ing = 0;
return false;
}
-
-
- var integrals=0;
- var get_datas= {
- user_id:getApp().globalData.user_id, store_id:o.stoid,
- };
- await getApp().request.promiseGet("/api/weshop/users/getAllPoints", {
- data: get_datas
- }).then(res => {
- if(res.data.code==0){
- integrals=res.data.data.Integral;
- }
- })
-
- //判断积分的情况
- if(th.data.formData.integral && parseFloat(th.data.formData.integral)< parseFloat(integrals) ){
- getApp().my_warnning("积分不足",0,th);
- th.data.is_summit_ing = 0;
- return false;
- }
-
-
- var item={
+
+
+ var integrals = 0;
+ var get_datas = {
+ user_id: getApp().globalData.user_id, store_id: o.stoid,
+ };
+ await getApp().request.promiseGet("/api/weshop/users/getAllPoints", {
+ data: get_datas
+ }).then(res => {
+ if (res.data.code == 0) {
+ integrals = res.data.data.Integral;
+ }
+ })
+
+ //判断积分的情况
+ if (th.data.formData.integral && parseFloat(th.data.formData.integral) < parseFloat(integrals)) {
+ getApp().my_warnning("积分不足", 0, th);
+ th.data.is_summit_ing = 0;
+ return false;
+ }
+
+
+ var item = {
'user_id': to.globalData.user_id,
'consignee': addr == null ? "" : addr.consignee,
'province': addr == null ? 0 : addr.province,
'city': addr == null ? 0 : addr.city,
'district': addr == null ? 0 : addr.district,
'twon': addr == null ? 0 : addr.twon,
- 'address': addr == null ? "": addr.address,
+ 'address': addr == null ? "" : addr.address,
'more_address': addr == null ? "" : addr.more_address,
//'mobile': th.data.userinfo.mobile,
'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile,
- 'email':'',
+ 'email': '',
'shipping_code': th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code,
'shipping_name': th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name,
- 'invoice_title':'',
+ 'invoice_title': '',
'goods_price': th.data.formData.all_price, //商品总价
'shipping_price': th.data.formData.shipping_price, //物流金额
'user_money': th.data.formData.user_money, //使用余额
'total_amount': th.data.formData.total_amount, //订单总价
'order_amount': th.data.formData.order_amount, //应付
'user_note': t.detail.value.user_note, //用户备注
- 'store_id':oo.stoid, //商家
+ 'store_id': oo.stoid, //商家
'pickup_id': th.data.bn_pick, //门店
'exp_type': th.data.bn_exp_type, //配送方式
- 'order_goods':new Array(),
- 'integral': th.data.formData.integral,
+ 'order_goods': new Array(),
+ 'integral': th.data.formData.integral,
};
//是不是重新提交
- if(th.data.is_continue==1) item.is_continue=1;
+ if (th.data.is_continue == 1) item.is_continue = 1;
//获取立即购买的商品的信息
var gg = to.get_b_now();
//--商品的房间号--
- if(gg.room_id && gg.room_id>0){
- item.room_ids=gg.room_id;
+ if (gg.room_id && gg.room_id > 0) {
+ item.room_ids = gg.room_id;
+ }
+
+ //老会员成为分销下线需要的参数
+ if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) {
+ //判断一下分享人是不是分享商
+ await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => {
+ if (res.data.code == 0) {
+ var user = res.data.data;
+ if (user.is_distribut == 1) {
+ item.first_leader = parseInt(getApp().globalData.first_leader);
+ }
+ }
+ })
}
-
- //老会员成为分销下线需要的参数
- if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){
- //判断一下分享人是不是分享商
- await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{
- if(res.data.code==0){
- var user= res.data.data;
- if(user.is_distribut==1){
- item.first_leader=parseInt(getApp().globalData.first_leader);
- }
- }
- })
- }
-
-
- var goods={
+
+
+ var goods = {
'goods_id': gg.goods_id,
'goods_name': gg.goods_name,
'goods_sn': gg.goods_sn,
@@ -659,37 +667,37 @@ Page({
'goods_price': th.data.bn_goods.shop_price,
'member_goods_price': th.data.bn_goods.shop_price,
'store_id': oo.stoid,
- 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
+ 'prom_type': th.data.bn_goods.prom_type, //促销活动类型
'prom_id': th.data.bn_goods.prom_id, //促销活动id
};
//-- 把导购的信息填入--
- if(gg.guide_id){
- goods.guide_id=gg.guide_id;
- goods.guide_type=gg.guide_type;
- //调用接口判断是不是会员
- await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/"+oo.stoid+"/"+gg.guide_id,{}).then(res=>{
- if(res.data.code==0){
- goods.guide_name=res.data.data.salesman;
- goods.guide_sn=res.data.data.salesman_no;
- }
- })
+ if (gg.guide_id) {
+ goods.guide_id = gg.guide_id;
+ goods.guide_type = gg.guide_type;
+ //调用接口判断是不是会员
+ await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => {
+ if (res.data.code == 0) {
+ goods.guide_name = res.data.data.salesman;
+ goods.guide_sn = res.data.data.salesman_no;
+ }
+ })
}
//--商品的房间号--
- if(gg.room_id && gg.room_id>0){
- goods.room_id=gg.room_id;
+ if (gg.room_id && gg.room_id > 0) {
+ goods.room_id = gg.room_id;
}
-
+
item.order_goods.push(goods);
- pdata.push(item);
+ pdata.push(item);
}
-
- if (pdata.length==0) return;
+
+ if (pdata.length == 0) return;
var str = JSON.stringify(pdata);
-
- wx.showLoading({title: "加载中"});
+
+ wx.showLoading({ title: "加载中" });
wx.request({
url: oo.url + '/api/weshop/order/createWxdOrder',
data: str,
@@ -699,11 +707,11 @@ Page({
},// 设置请求的 header
success: function (res) {
- th.data.is_summit_ing=0; //是否提交中
+ th.data.is_summit_ing = 0; //是否提交中
wx.hideLoading();
if (res.statusCode == 200) {
- var data=res.data;
- if(data.code==0){
+ var data = res.data;
+ if (data.code == 0) {
console.log(th.data.is_b_now);
//如果是购物车结算,还要删除购物车
if (th.data.is_b_now == 0) {
@@ -724,20 +732,20 @@ Page({
//void e.jumpToCart4({
// order_sn: data.data,
//}, 1);
- util_pay.pay(data.data, function() {
- //app.my_warnning("支付成功",1,th);
- //setTimeout(function () {
- wx.redirectTo({
- url: "/pages/payment/pay_success/pay_success?type=2&order_sn="+data.data
- })
- //},1000)
-
- }, function () {
- //支付失败
- setTimeout(function () {
- wx.navigateBack({ delta: 1 })
- },1000)
- },oo.stoid);
+ util_pay.pay(data.data, function () {
+ //app.my_warnning("支付成功",1,th);
+ //setTimeout(function () {
+ wx.redirectTo({
+ url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data
+ })
+ //},1000)
+
+ }, function () {
+ //支付失败
+ setTimeout(function () {
+ wx.navigateBack({ delta: 1 })
+ }, 1000)
+ }, oo.stoid);
} else {
var dd = {
@@ -749,110 +757,110 @@ Page({
data: dd,
success: function (t) {
//console.log(t);
- if(t.data.code==0){
- //app.my_warnning("支付成功",1,th);
- //setTimeout(function () {
- th.setData({ isclose: 0 });
- wx.redirectTo({
- url: "/pages/payment/pay_success/pay_success?type=2&order_sn="+data.data,
- })
- //}, 1000)
+ if (t.data.code == 0) {
+ //app.my_warnning("支付成功",1,th);
+ //setTimeout(function () {
+ th.setData({ isclose: 0 });
+ wx.redirectTo({
+ url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data,
+ })
+ //}, 1000)
}
},
- fail:function () {
+ fail: function () {
}
});
}
}
- else{
- //--内容换行--
- var msg=data.msg;
- //赠品活动已经取消,无法赠送,是否继续买单?
- if(msg.indexOf("是否继续买单")>0){
- wx.showModal({
- title:"提示",
- content: data.msg,
- cancelText:'取消',
- confirmText:'确定',
- showCancel: true,
- success(res){
- if(res.cancel){
- return;
- }else if(res.confirm){
- th.data.is_continue=1;
- th.submitForm(sub_value);
- }
- }
- })
- return;
- }
- if(msg.length>13){
- msg=msg.slice(0, 13) + "\r\n"+ msg.slice(13);
- }
- getApp().confirmBox(msg);
- }
- }else{
- console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
+ else {
+ //--内容换行--
+ var msg = data.msg;
+ //赠品活动已经取消,无法赠送,是否继续买单?
+ if (msg.indexOf("是否继续买单") > 0) {
+ wx.showModal({
+ title: "提示",
+ content: data.msg,
+ cancelText: '取消',
+ confirmText: '确定',
+ showCancel: true,
+ success(res) {
+ if (res.cancel) {
+ return;
+ } else if (res.confirm) {
+ th.data.is_continue = 1;
+ th.submitForm(sub_value);
+ }
+ }
+ })
+ return;
+ }
+ if (msg.length > 13) {
+ msg = msg.slice(0, 13) + "\r\n" + msg.slice(13);
+ }
+ getApp().confirmBox(msg);
+ }
+ } else {
+ console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
}
},
fail: function () {
- th.data.is_summit_ing=0;
+ th.data.is_summit_ing = 0;
wx.hideLoading();
console.log("index.js wx.request CheckCallUser fail");
},
- complete: function () {}
+ complete: function () { }
})
},
-
+
//---确认线下门店的数量足不足---
- async check_store_num(goods_id,pick,goods_num,func){
- var lock=0,pick_no,plist,erpwareid;
- //先读取门店的lock
- await getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
- data:{store_id:os.stoid,wareId:goods_id,storageId:pick,pageSize:1000}
- }).then(res=>{
- if(res.data.code==0 && res.data.data.total>0){
- for(var i in res.data.data.pageData)
- lock+=res.data.data.pageData[i].outQty;
- }
- })
- //先获取门店的编号
- await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+pick,{
- data:{storeId:os.stoid,goodsId:t.goods_id,pickupId:pick}
- }).then(res=>{
- if(res.data.code==0){
- pick_no=res.data.data.pickup_no;
- }
- })
- //先获取商品的线下库存
- await getApp().request.promiseGet("/api/weshop/goods/get/"+os.stoid+"/"+goods_id,{
- data:{storeId:os.stoid,goodsId:t.goods_id,pickupId:pick}
- }).then(res=>{
- if(res.data.code==0){
- erpwareid=res.data.data.erpwareid;
- }
- })
- //读取线下的门店库存
- await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
- data:{storageNos:pick_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid}
- }).then(res=>{
- if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){
- plist=res.data.data.pageData[0];
- }
- })
- var isok=1;
- if(goods_num>plist.CanOutQty-lock){
- isok=0;
- }
- func(isok);
+ async check_store_num(goods_id, pick, goods_num, func) {
+ var lock = 0, pick_no, plist, erpwareid;
+ //先读取门店的lock
+ await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
+ data: { store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000 }
+ }).then(res => {
+ if (res.data.code == 0 && res.data.data.total > 0) {
+ for (var i in res.data.data.pageData)
+ lock += res.data.data.pageData[i].outQty;
+ }
+ })
+ //先获取门店的编号
+ await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, {
+ data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick }
+ }).then(res => {
+ if (res.data.code == 0) {
+ pick_no = res.data.data.pickup_no;
+ }
+ })
+ //先获取商品的线下库存
+ await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, {
+ data: { storeId: os.stoid, goodsId: t.goods_id, pickupId: pick }
+ }).then(res => {
+ if (res.data.code == 0) {
+ erpwareid = res.data.data.erpwareid;
+ }
+ })
+ //读取线下的门店库存
+ await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
+ data: { storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid }
+ }).then(res => {
+ if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) {
+ plist = res.data.data.pageData[0];
+ }
+ })
+ var isok = 1;
+ if (goods_num > plist.CanOutQty - lock) {
+ isok = 0;
+ }
+ func(isok);
},
- useCoupon: function() {
+ useCoupon: function () {
if (this.data.order.couponNum <= 0) {
- getApp().my_warnning("无可用优惠券",0,this);
+ getApp().my_warnning("无可用优惠券", 0, this);
return;
}
@@ -863,86 +871,96 @@ Page({
url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a)
});
},
- enterAddressPage: function() {
- getApp().globalData.is_cart_old=1;
- this.data.isget_by_quan={};
+ enterAddressPage: function () {
+ getApp().globalData.is_cart_old = 1;
+ this.data.isget_by_quan = {};
this.data.enterAddressPage = !0, wx.navigateTo({
url: "/pages/user/address_list/address_list"
});
},
-
+
//--------立即购买时,选择自提和物流----------
- setexptype:function(t){
- var th=this;
- var ty = t.currentTarget.dataset.t,def_exp_code= getApp().globalData.userInfo.def_exp_code;
- th.setData({ bn_exp_type:ty});
+ setexptype: function (t) {
+ var th = this;
+ var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code;
+ th.setData({ bn_exp_type: ty });
//当物流为空的时候。
- if (ty == 0 && th.data.wu_arr==null){
- th.data.isget_by_quan={};
+ if (ty == 0 && th.data.wu_arr == null) {
+ th.data.isget_by_quan = {};
return th.get_wuliu(th.calculatePrice2());
}
//--自提就要把包邮券清理掉--
- if(ty==1){
- th.data.isget_by_quan={};
- if(th.data.using_quan && th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby==1){
- th.setData({using_quan:{}});
+ if (ty == 1) {
+ th.data.isget_by_quan = {};
+ if (th.data.using_quan && th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby == 1) {
+ th.setData({ using_quan: {} });
}
}
- //判断有没有默认的物流地址值
- if (def_exp_code != "" && def_exp_code != null && def_exp_code !=undefined) {
- var wu_arr=this.data.wu_arr;
- if (wu_arr!= null && wu_arr!=""){
- for(var i=0;i 0 && o_price >= freight_free){ return 0;}
- if (user_addr==null) { return 0; }
+ if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; }
+ if (user_addr == null) { return 0; }
//计算物流的config item;
- var item=null;
+ var item = null;
//先根据 镇 县 区找计算的config
- item = th.get_wuliu_config(user_addr.district,code,rs);
- if (item==null) item = th.get_wuliu_config(user_addr.city, code, rs);
- if (item==null) item = th.get_wuliu_config(user_addr.province, code, rs);
- if (item == null) item = th.get_wuliu_default(code,rs);
+ item = th.get_wuliu_config(user_addr.district, code, rs);
+ if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
+ if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
+ if (item == null) item = th.get_wuliu_default(code, rs);
+ if (item == null) return o_shipping_price;
+ var fw_price = 0, fp_price = 0;
+ item = item.config;
if (item == null) return o_shipping_price;
- var fw_price = 0, fp_price=0;
- item=item.config;
- if (item == null) return o_shipping_price;
//------按重量----------
- if (goods_weight>=0 && item['money']) {
- fw_price =parseFloat(item['money']);
- if (goods_weight > item['first_weight']){
+ if (goods_weight >= 0 && item['money']) {
+ fw_price = parseFloat(item['money']);
+ if (goods_weight > item['first_weight']) {
var fw = goods_weight - item['first_weight'];
- var n = Math.ceil(fw/item['second_weight'])
+ var n = Math.ceil(fw / item['second_weight'])
+ fw_price = fw_price + n * parseFloat(item['add_money']);
+ }
+ }
+ //------超出重量----------
+ if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) {
+ fw_price = parseFloat(item['money']);
+ var out_of_weight = Math.abs(out_of_weight);
+ if (out_of_weight > item['first_weight']) {
+ var fw = out_of_weight - item['first_weight'];
+ var n = Math.ceil(fw / item['second_weight'])
fw_price = fw_price + n * parseFloat(item['add_money']);
}
}
@@ -955,21 +973,21 @@ Page({
fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
}
}
- var rspice =parseFloat(price + fw_price + fp_price);
+ var rspice = parseFloat(price + fw_price + fp_price);
return rspice;
},
//------------循环获取config-----------
- get_wuliu_config:function(region_id,code,rs){
- var item=null,rslist = rs.pageData;
- for (var i = 0; i < rslist.length;i++){
- if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i];}
+ get_wuliu_config: function (region_id, code, rs) {
+ var item = null, rslist = rs.pageData;
+ for (var i = 0; i < rslist.length; i++) {
+ if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; }
}
return item;
},
//-------循环获取config,code default-------
get_wuliu_default: function (code, rs) {
- var item = null, rslist=rs.pageData;
+ var item = null, rslist = rs.pageData;
for (var i = 0; i < rslist.length; i++) {
if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; }
}
@@ -977,141 +995,140 @@ Page({
},
//----------立即购买,选择物流-------------
- bindPickerChange:function(e){
+ bindPickerChange: function (e) {
var ind = e.detail.value
this.setData({ index: ind });
this.calculatePrice2();
},
//----------购物车结算,选择物流-------------
bindPickerChange_w: function (e) {
- var ind=e.detail.value, txt = e.currentTarget.dataset.txt;
+ var ind = e.detail.value, txt = e.currentTarget.dataset.txt;
this.setData({ [txt]: ind });
this.calculatePrice();
},
- cart_set_err:function(e){
- var txt = e.currentTarget.dataset.err;
- var ob={};
- ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif";
- this.setData(ob);
+ cart_set_err: function (e) {
+ var txt = e.currentTarget.dataset.err;
+ var ob = {};
+ ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif";
+ this.setData(ob);
},
-
+
//// 开启物流的弹窗
- show_wu_arr:function(e){
- var wu_arr_txt=e.currentTarget.dataset.txt;
- var w_sele_index=e.currentTarget.dataset.w_sele_index;
- var is_express=null;
- var ob={open_express: 1,wu_arr_txt:wu_arr_txt,disabled:1};
+ show_wu_arr: function (e) {
+ var wu_arr_txt = e.currentTarget.dataset.txt;
+ var w_sele_index = e.currentTarget.dataset.w_sele_index;
+ var is_express = null;
+ var ob = { open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1 };
//--如果是多个门店的时候--
- if(w_sele_index!=undefined){
- is_express=this.data.cartlist[w_sele_index].wind;
- ob['is_express']=is_express;
+ if (w_sele_index != undefined) {
+ is_express = this.data.cartlist[w_sele_index].wind;
+ ob['is_express'] = is_express;
}
this.setData(ob);
},
- // 关闭物流的弹窗
- close_express:function(){
- this.setData({ open_express:0,disabled:0 });
+ // 关闭物流的弹窗
+ close_express: function () {
+ this.setData({ open_express: 0, disabled: 0 });
+ },
+ // 选择物流
+ click_express_name: function (e) {
+ var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
+ var index = e.currentTarget.dataset.idxe;
+ var ob = { is_express: index, is_shipping_code: shippingcode, disabled: 0 };
+ ob[this.data.wu_arr_txt] = index;
+ this.setData(ob);
},
- // 选择物流
- click_express_name:function(e){
- var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
- var index=e.currentTarget.dataset.idxe;
- var ob={ is_express: index, is_shipping_code: shippingcode,disabled:0};
- ob[this.data.wu_arr_txt]=index;
- this.setData(ob);
- },
- //点击确定物流
- determine_expres:function(e){
- this.setData({ open_express: 0});
- this.calculatePrice2();
+ //点击确定物流
+ determine_expres: function (e) {
+ this.setData({ open_express: 0 });
+ this.calculatePrice2();
},
-
+
//设置默认物流
select_default_logistics: function () {
- var th=this;
- var is_shipping_code=this.data.is_shipping_code
- getApp().request.put("/api/weshop/users/update",{
- data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code},
- success:function(rse){
- if (rse.data.code==0){
- getApp().globalData.userInfo.def_exp_code=is_shipping_code;
+ var th = this;
+ var is_shipping_code = this.data.is_shipping_code
+ getApp().request.put("/api/weshop/users/update", {
+ data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code },
+ success: function (rse) {
+ if (rse.data.code == 0) {
+ getApp().globalData.userInfo.def_exp_code = is_shipping_code;
th.setData({ open_express: 0 });
//----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19--------
//if(th.data.is_b_now==1) th.calculatePrice2();
//else th.calculatePrice();
th.calculatePrice2();
- }
+ }
}
})
},
//更新下默认,在onshow里面
- update_code(){
- var th=this,m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code;
- //--定时器,判断wu_arr不未空--
- var uii=setInterval(function () {
- if(th.data.wu_arr)
- {
- clearInterval(uii);
- for (var k = 0; k < th.data.wu_arr.length; k++) {
- var item = th.data.wu_arr[k];
- if (def_exp_code == item.code) { m_wind = k; }
- }
- //--如果是立即购买--
- th.setData({index: m_wind,is_express:m_wind});
-
- }
- },500);
+ update_code() {
+ var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
+ //--定时器,判断wu_arr不未空--
+ var uii = setInterval(function () {
+ if (th.data.wu_arr) {
+ clearInterval(uii);
+ for (var k = 0; k < th.data.wu_arr.length; k++) {
+ var item = th.data.wu_arr[k];
+ if (def_exp_code == item.code) { m_wind = k; }
+ }
+ //--如果是立即购买--
+ th.setData({ index: m_wind, is_express: m_wind });
+
+ }
+ }, 500);
},
-
+
//检查区域是不是包邮
- check_area:function(arr){
- var user_addr=this.data.user_addr;
- for(var i in arr){
- var item=arr[i];
- if(user_addr.twon==item || user_addr.district==item
- || user_addr.city==item|| user_addr.province==item ){
- return 0;
- }
- }
- return 1;
+ check_area: function (arr) {
+ var user_addr = this.data.user_addr;
+ for (var i in arr) {
+ var item = arr[i];
+ if (user_addr.twon == item || user_addr.district == item
+ || user_addr.city == item || user_addr.province == item) {
+ return 0;
+ }
+ }
+ return 1;
},
-
+
//检查立即购买的商品是不是不包邮
- check_good:function(arr,goods_id){
- if(!goods_id) goods_id=this.data.bn_goods.goods_id;
- for(var i in arr){
- var item=arr[i];
- if(goods_id==item) return 0;
- }
- return 1;
+ check_good: function (arr, goods_id) {
+ if (!goods_id) goods_id = this.data.bn_goods.goods_id;
+ for (var i in arr) {
+ var item = arr[i];
+ if (goods_id == item) return 0;
+ }
+ return 1;
},
- check_by_area:function(region_list){
- var arr=region_list.split(",");
- var check=this.check_area(arr);
- return !check;
+ check_by_area: function (region_list) {
+ var arr = region_list.split(",");
+ var check = this.check_area(arr);
+ return !check;
},
- check_by_goods:function(goods_list,goods_id){
- var arr=goods_list.split(",");
- var check=this.check_good(arr,goods_id);
- return !check;
+ check_by_goods: function (goods_list, goods_id) {
+ var arr = goods_list.split(",");
+ var check = this.check_good(arr, goods_id);
+ return !check;
},
-
- //从优惠的映射中拿出商品从表的item
- arr_get_goods:function(goods_id,arr){
- for(var i in arr){
- if(arr[i].goods_id==goods_id) return arr[i];
- }
- },
-
- //跳转到购买卡
- buycard:function(){
- getApp().goto("/pages/user/plus/plus");
- getApp().globalData.plus_buy_back=1;
- }
+
+ //从优惠的映射中拿出商品从表的item
+ arr_get_goods: function (goods_id, arr) {
+ for (var i in arr) {
+ if (arr[i].goods_id == goods_id) return arr[i];
+ }
+ },
+
+ //跳转到购买卡
+ buycard: function () {
+ getApp().goto("/pages/user/plus/plus");
+ getApp().globalData.plus_buy_back = 1;
+ }
});
diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js
index 377b76f..fd3f517 100644
--- a/pages/cart/cart2_pt/cart2_pt.js
+++ b/pages/cart/cart2_pt/cart2_pt.js
@@ -1,850 +1,866 @@
-var t = getApp(),app=t, a = t.request, e = require("../../../utils/common.js"),
+var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"),
s = require("../../../utils/util.js"), o = require("../../../utils/md5.js"), to = getApp();
-var oo=t.globalData.setting,os=oo;
+var oo = t.globalData.setting, os = oo;
var regeneratorRuntime = require('../../../utils/runtime.js');
var util_pay = require("../../../utils/pay.js");
Page({
- data: {
- url: t.globalData.setting.url,
- resourceUrl: t.globalData.setting.resourceUrl,
- imgUrl: t.globalData.setting.imghost,
- goods: null,
- order: null,
- orderPrices: null,
- coupons: null,
- coupon: null,
- invoiceToggle: !0,
- payWithUserMoney: !0,
- payWithPoints: !0,
- maxWord: 0,
- enterAddressPage: !1,
- firstEnter: !0,
- //页面获取的参数
- param:null,
- postdata:null,
- //提交订单的格式
- formData: {
- order_amount:0,//支付金额
- total_amount:0,//总价
- all_price:0,//商品卖的总价
- pay_points: 0,//使用积分
- user_money: 0,//使用余额
- couponCode: "",//使用优惠券(多单就用逗号隔开)
- shipping_price:0,//物流费用
- },
-
- /*----------------立即购买---------------------*/
- is_b_now:0, //0是购物车结算 1立即购买
- bn_goods:null, //立即购买时候的调用商品
- bn_use_money:0,//是否使用余额
- bn_exp_type:1, //0是物流 1自提
- bn_pick:0, //选择的门店
- bn_pickname: "", //选择的门店名称
- bn_t_exp_t:0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流
- /*------------------------*/
- user_addr:null,//物流
- userinfo:null, //获取会员
- /*----------物流选择--------*/
- wu_arr:null,
- index:0,
-
- //判断页面是返回回来的还是 首次进入的
- isclose:1,
- kt_type:0, //开团类型
- is_pt_tz:0,//是否开团团长
- qh:'', //期号
- pt_listno:'',//期号
- is_normal:0,
- is_express:0,//选择物流的控制器
- yuer:0,
-
- rank_switch:0, //是不是开同等级卡
- show_card:null, //显示的等级卡
- card_name:'', //显示的卡的名称
- card_cut_price:null,//减价多少钱
+ data: {
+ url: t.globalData.setting.url,
+ resourceUrl: t.globalData.setting.resourceUrl,
+ imgUrl: t.globalData.setting.imghost,
+ goods: null,
+ order: null,
+ orderPrices: null,
+ coupons: null,
+ coupon: null,
+ invoiceToggle: !0,
+ payWithUserMoney: !0,
+ payWithPoints: !0,
+ maxWord: 0,
+ enterAddressPage: !1,
+ firstEnter: !0,
+ //页面获取的参数
+ param: null,
+ postdata: null,
+ //提交订单的格式
+ formData: {
+ order_amount: 0,//支付金额
+ total_amount: 0,//总价
+ all_price: 0,//商品卖的总价
+ pay_points: 0,//使用积分
+ user_money: 0,//使用余额
+ couponCode: "",//使用优惠券(多单就用逗号隔开)
+ shipping_price: 0,//物流费用
},
- onLoad: function(t) {
- console.log("onLoad_pt_cart");
- var th = this; this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,});
- var appD=getApp().get_b_now();
-
- th.data.postdata=appD;
- //如果期号有值
- if(appD.qh){
- th.data.qh=appD.qh;
- th.data.pt_listno=appD.qh;
- }
- //th.data.kt_type=appD.kt_type;
- th.setData({kt_type:appD.kt_type});
- if(appD.is_pt_tz) th.data.is_pt_tz=appD.is_pt_tz;
- th.data.param=t;
- //先获取物流,再获取用户信息,再展示页面
- //th.get_wuliu(th.get_info(th.show_page));
- },
- onUnload: function () { this.setData({ isclose: 1 })},
- //------获取会员信息-----先获取用户信息,在进行下一步---
- get_info:function(func){
- var user_id = t.globalData.user_id;
- to.auth.get_u(func);
- },
+ /*----------------立即购买---------------------*/
+ is_b_now: 0, //0是购物车结算 1立即购买
+ bn_goods: null, //立即购买时候的调用商品
+ bn_use_money: 0,//是否使用余额
+ bn_exp_type: 1, //0是物流 1自提
+ bn_pick: 0, //选择的门店
+ bn_pickname: "", //选择的门店名称
+ bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流
+ /*------------------------*/
+ user_addr: null,//物流
+ userinfo: null, //获取会员
+ /*----------物流选择--------*/
+ wu_arr: null,
+ index: 0,
+
+ //判断页面是返回回来的还是 首次进入的
+ isclose: 1,
+ kt_type: 0, //开团类型
+ is_pt_tz: 0,//是否开团团长
+ qh: '', //期号
+ pt_listno: '',//期号
+ is_normal: 0,
+ is_express: 0,//选择物流的控制器
+ yuer: 0,
+
+ rank_switch: 0, //是不是开同等级卡
+ show_card: null, //显示的等级卡
+ card_name: '', //显示的卡的名称
+ card_cut_price: null,//减价多少钱
+ },
+ onLoad: function (t) {
+ console.log("onLoad_pt_cart");
+ var th = this; this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, });
+ var appD = getApp().get_b_now();
+
+ th.data.postdata = appD;
+ //如果期号有值
+ if (appD.qh) {
+ th.data.qh = appD.qh;
+ th.data.pt_listno = appD.qh;
+ }
+ //th.data.kt_type=appD.kt_type;
+ th.setData({ kt_type: appD.kt_type });
+ if (appD.is_pt_tz) th.data.is_pt_tz = appD.is_pt_tz;
+ th.data.param = t;
+ //先获取物流,再获取用户信息,再展示页面
+ //th.get_wuliu(th.get_info(th.show_page));
+ },
+ onUnload: function () { this.setData({ isclose: 1 }) },
- //-------------------获取物流---------------
- get_wuliu(func) {
- var th = this;
- console.log("getwuliu4545");
- to.getwuliu(function (e) {
- if (th.data.is_default_logistics) {
- //如果第一个不是开启默认,说明要让用户自己选
- if (!e[0].is_default) {
- th.setData({ is_default_logistics: 0 });
- }
+ //------获取会员信息-----先获取用户信息,在进行下一步---
+ get_info: function (func) {
+ var user_id = t.globalData.user_id;
+ to.auth.get_u(func);
+ },
+
+ //-------------------获取物流---------------
+ get_wuliu(func) {
+ var th = this;
+ console.log("getwuliu4545");
+ to.getwuliu(function (e) {
+ if (th.data.is_default_logistics) {
+ //如果第一个不是开启默认,说明要让用户自己选
+ if (!e[0].is_default) {
+ th.setData({ is_default_logistics: 0 });
}
- th.setData({ wu_arr: e })
- typeof func == "function" && func();
- })
- },
+ }
+ th.setData({ wu_arr: e })
+ typeof func == "function" && func();
+ })
+ },
- //------获取会员收货地址-----
- getuser_addr:function(func){
- if (to.globalData.baddr!=null){
- var user_addr = to.globalData.baddr;
- to.globalData.baddr=null;
- func(user_addr);
- }else{
- a.get("/api/weshop/useraddress/page", {
- data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600 },
+ //------获取会员收货地址-----
+ getuser_addr: function (func) {
+ if (to.globalData.baddr != null) {
+ var user_addr = to.globalData.baddr;
+ to.globalData.baddr = null;
+ func(user_addr);
+ } else {
+ a.get("/api/weshop/useraddress/page", {
+ data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600 },
+ success: function (su) {
+
+ var user_addr = su.data.data.pageData;
+ var item = null;
+ var def_item = null;
+ for (var i = 0; i < user_addr.length; i++) {
+ if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; }
+ if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; }
+ }
+ if (item == null) item = def_item;
+ if (item == null) item = user_addr[0];
+ if (item == undefined) item = null;
+ func(item);
+ }
+ });
+ }
+ },
+ //----------------展示页面,是再获取用户信息之后--------------
+ show_page: function () {
+ var th = this;
+ //th.setData({ userinfo: to.globalData.userInfo}); 会员信息要时时获取
+ var user = getApp().globalData.userInfo;
+ getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, {
+ data: { r: Math.random() },
+ success: function (e) {
+
+ getApp().globalData.userInfo = e.data.data;
+ th.setData({ userinfo: e.data.data });
+ //获取立即购买的商品信息
+ th.get_buy_goods();
+
+ //获取提现金额
+ getApp().request.get("/api/weshop/withdrawals/summoney", {
+ data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 },
success: function (su) {
-
- var user_addr = su.data.data.pageData;
- var item = null;
- var def_item=null;
- for (var i = 0; i < user_addr.length; i++) {
- if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; }
- if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; }
+ if (su.data.code == 0) {
+ var yuer = parseFloat(th.data.userinfo.user_money -
+ (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2);
+ if (yuer < 0) yuer = 0;
+ th.setData({ txmon: su.data.data.summoney, yuer: yuer });
}
- if (item == null) item = def_item;
- if (item == null) item = user_addr[0];
- if (item == undefined) item = null;
- func(item);
}
});
}
- },
- //----------------展示页面,是再获取用户信息之后--------------
- show_page:function(){
- var th=this;
- //th.setData({ userinfo: to.globalData.userInfo}); 会员信息要时时获取
- var user=getApp().globalData.userInfo;
- getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, {
- data:{r:Math.random()},
- success: function (e) {
-
- getApp().globalData.userInfo = e.data.data;
- th.setData({userinfo:e.data.data});
- //获取立即购买的商品信息
- th.get_buy_goods();
-
- //获取提现金额
- getApp().request.get("/api/weshop/withdrawals/summoney", {
- data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 },
- success: function (su) {
- if (su.data.code == 0) {
- var yuer = parseFloat(th.data.userinfo.user_money -
- (th.data.userinfo.frozen_money>0?th.data.userinfo.frozen_money:0) - su.data.data.summoney).toFixed(2);
- if(yuer<0) yuer=0;
- th.setData({ txmon: su.data.data.summoney, yuer: yuer });
- }
- }
- });
- }
- });
- },
+ });
+ },
- //-----获取立即购买的商品信息----
- get_buy_goods: function (){
- var th=this,a=getApp().request;
- var gg = th.data.postdata;
- //调用商品
- a.get("/api/weshop/goods/get/" + oo.stoid+"/"+gg.goods_id, {
- success: function (t) {
- var gd = t.data.data;
- if(!gd) return false;
-
- t.data.data.original_img = oo.imghost + t.data.data.original_img;
- t.data.data['buynum'] = gg.goods_num;
- console.log(t.data.data);
- var distr_t = 0, et = 0
- if (t.data.data.distr_type == 0) {
- distr_t = gg.pick_dis;
- } else {
- distr_t = t.data.data.distr_type;
- }
- switch (distr_t) {
- case 0:
- et = 1;
- //-- 系统后台有设置要默认的 --
- if(th.data.json_d.pickupway && th.data.json_d.pickupway==1) et=0;
- break;
- case 1:
- et = 1;
- break;
- case 2:
- et = 0;
- break;
- }
-
- t.data.data.shop_price=gg.goods_price;
- //--如果是普通购买的时候--
- if(gg.is_normal==1){
- t.data.data.prom_id = 0;
- t.data.data.prom_type = 0;
- t.data.data.is_normal=1;
-
- var gd=t.data.data;
- //-- 用商品的手店价来显示 --
- gg.goods_price=gd.shop_price;
- //---是不是购买等级卡成功的返回---等级卡显示的判断---
- var is_card_back=getApp().globalData.is_card_back;
- if(is_card_back){
- gg.goods_price=gd[th.data.card_name];
- t.data.data.shop_price=gg.goods_price;
- getApp().globalData.is_card_back=0;
- th.setData({card_cut_price:0});
- }else{
- //--- 商品不能是搭配购,商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格
- if(th.data.card_name && gd[th.data.card_name]>0 && gg.goods_price>gd[th.data.card_name] && !th.data.userinfo.card_field){
- var cut_p= gg.goods_price-gd[th.data.card_name];
- th.setData({card_cut_price:cut_p});
- }
- }
-
- if(th.data.bn_goods){
- et=th.data.bn_exp_type;
- }
-
-
- th.setData({
- bn_goods: t.data.data, bn_pickname: gg.pick_name,
- bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal:1,bn_exp_type:et
- });
-
-
-
- th.calculatePrice2();
- }else{
-
- //--阶梯团很特殊,不能用总表来拿价格--
- getApp().request.get("/api/weshop/teamlist/get/"+oo.stoid+"/"+gd.prom_id, {
- success: function (tt) {
-
- if (tt.data.code == 0) {
- var pt_data=tt.data.data;
- var now=s.gettimestamp();
-
- if(pt_data.is_end==1){
- t.data.data.prom_id = 0;
- t.data.data.prom_type = 0;
- t.data.data.is_normal=1;
- }else if(now>pt_data.end_time){
- t.data.data.prom_id = 0;
- t.data.data.prom_type = 0;
- t.data.data.is_normal=1;
- }else{
- t.data.data.shop_price = tt.data.data.price; //活动价格
- t.data.data.is_normal=0;
- if(pt_data.kttype==3){
- t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买
- }
- }
- } else {
- t.data.data.prom_id = 0;
- t.data.data.prom_type = 0;
- t.data.data.is_normal=1;
- }
-
- if(th.data.bn_goods){
- et=th.data.bn_exp_type;
- }
-
- th.setData({
- bn_goods: t.data.data, bn_pickname: gg.pick_name,
- bn_pick: gg.pick_id, bn_t_exp_t: distr_t,bn_exp_type:et
- });
-
-
- //计算价格
- th.calculatePrice2();
- }
- });
- }
- }
- });
- },
+ //-----获取立即购买的商品信息----
+ get_buy_goods: function () {
+ var th = this, a = getApp().request;
+ var gg = th.data.postdata;
+ //调用商品
+ a.get("/api/weshop/goods/get/" + oo.stoid + "/" + gg.goods_id, {
+ success: function (t) {
+ var gd = t.data.data;
+ if (!gd) return false;
+
+ t.data.data.original_img = oo.imghost + t.data.data.original_img;
+ t.data.data['buynum'] = gg.goods_num;
+ console.log(t.data.data);
+ var distr_t = 0, et = 0
+ if (t.data.data.distr_type == 0) {
+ distr_t = gg.pick_dis;
+ } else {
+ distr_t = t.data.data.distr_type;
+ }
+ switch (distr_t) {
+ case 0:
+ et = 1;
+ //-- 系统后台有设置要默认的 --
+ if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0;
+ break;
+ case 1:
+ et = 1;
+ break;
+ case 2:
+ et = 0;
+ break;
+ }
- //----------子页返回父页触发----------
- onShow: function () {
- var th = this;
- if (th.data.isclose == 0) {
- wx.navigateTo({
- url: "/pages/index/index/index"
- })
- } else {
- this.getuser_addr(function (ie) {
- //更换地址回来要重新调用计算价钱的接口
- th.setData({ user_addr: ie });
- if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
- th.setData({ add_back: 1 });
- if (th.data.bn_goods) th.calculatePrice2();
+ t.data.data.shop_price = gg.goods_price;
+ //--如果是普通购买的时候--
+ if (gg.is_normal == 1) {
+ t.data.data.prom_id = 0;
+ t.data.data.prom_type = 0;
+ t.data.data.is_normal = 1;
+
+ var gd = t.data.data;
+ //-- 用商品的手店价来显示 --
+ gg.goods_price = gd.shop_price;
+ //---是不是购买等级卡成功的返回---等级卡显示的判断---
+ var is_card_back = getApp().globalData.is_card_back;
+ if (is_card_back) {
+ gg.goods_price = gd[th.data.card_name];
+ t.data.data.shop_price = gg.goods_price;
+ getApp().globalData.is_card_back = 0;
+ th.setData({ card_cut_price: 0 });
+ } else {
+ //--- 商品不能是搭配购,商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格
+ if (th.data.card_name && gd[th.data.card_name] > 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) {
+ var cut_p = gg.goods_price - gd[th.data.card_name];
+ th.setData({ card_cut_price: cut_p });
+ }
+ }
+
+ if (th.data.bn_goods) {
+ et = th.data.bn_exp_type;
}
- })
- //--更新默认地址--,看一下是不是跳到地址页面
- if (!getApp().globalData.is_cart_old) {
- this.update_code();
+
+
+ th.setData({
+ bn_goods: t.data.data, bn_pickname: gg.pick_name,
+ bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal: 1, bn_exp_type: et
+ });
+
+
+
+ th.calculatePrice2();
} else {
- getApp().globalData.is_cart_old = 0;
+
+ //--阶梯团很特殊,不能用总表来拿价格--
+ getApp().request.get("/api/weshop/teamlist/get/" + oo.stoid + "/" + gd.prom_id, {
+ success: function (tt) {
+
+ if (tt.data.code == 0) {
+ var pt_data = tt.data.data;
+ var now = s.gettimestamp();
+
+ if (pt_data.is_end == 1) {
+ t.data.data.prom_id = 0;
+ t.data.data.prom_type = 0;
+ t.data.data.is_normal = 1;
+ } else if (now > pt_data.end_time) {
+ t.data.data.prom_id = 0;
+ t.data.data.prom_type = 0;
+ t.data.data.is_normal = 1;
+ } else {
+ t.data.data.shop_price = tt.data.data.price; //活动价格
+ t.data.data.is_normal = 0;
+ if (pt_data.kttype == 3) {
+ t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买
+ }
+ }
+ } else {
+ t.data.data.prom_id = 0;
+ t.data.data.prom_type = 0;
+ t.data.data.is_normal = 1;
+ }
+
+ if (th.data.bn_goods) {
+ et = th.data.bn_exp_type;
+ }
+
+ th.setData({
+ bn_goods: t.data.data, bn_pickname: gg.pick_name,
+ bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et
+ });
+
+
+ //计算价格
+ th.calculatePrice2();
+ }
+ });
}
}
+ });
+ },
+
+ //----------子页返回父页触发----------
+ onShow: function () {
+ var th = this;
+ if (th.data.isclose == 0) {
+ wx.navigateTo({
+ url: "/pages/index/index/index"
+ })
+ } else {
+ this.getuser_addr(function (ie) {
+ //更换地址回来要重新调用计算价钱的接口
+ th.setData({ user_addr: ie });
+ if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
+ th.setData({ add_back: 1 });
+ if (th.data.bn_goods) th.calculatePrice2();
+ }
+ })
+ //--更新默认地址--,看一下是不是跳到地址页面
+ if (!getApp().globalData.is_cart_old) {
+ this.update_code();
+ } else {
+ getApp().globalData.is_cart_old = 0;
+ }
+ }
- //先获取是否有关闭使用优惠券
- getApp().getConfig2(function (ee) {
- var json_d = JSON.parse(ee.switch_list);
- th.data.json_d = json_d;
- th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值
- var is_default_logistics = json_d.is_default_logistics;
-
- th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics });
-
- var rank_switch = json_d.rank_switch;
- var max_price = -1;
- var show_card = null;
- var name = "";
- //如果有开等级卡的时候,
- //因为都是调接口,要返回在计算
- if (rank_switch == 2) {
- //-- 获取所有的等级卡, --
- getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid,
- {}).then(res => {
- if (res.data.code == 0) {
- var plusCard = res.data.data;
- //-- 循环判断,拿到最贵的那张卡 --
- for (var ih in plusCard) {
- if (plusCard[ih].IsStopBuy == true) { continue; }
- if (max_price < 0) {
+ //先获取是否有关闭使用优惠券
+ getApp().getConfig2(function (ee) {
+ var json_d = JSON.parse(ee.switch_list);
+ th.data.json_d = json_d;
+ th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值
+ var is_default_logistics = json_d.is_default_logistics;
+
+ th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics });
+
+ var rank_switch = json_d.rank_switch;
+ var max_price = -1;
+ var show_card = null;
+ var name = "";
+ //如果有开等级卡的时候,
+ //因为都是调接口,要返回在计算
+ if (rank_switch == 2) {
+ //-- 获取所有的等级卡, --
+ getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid,
+ {}).then(res => {
+ if (res.data.code == 0) {
+ var plusCard = res.data.data;
+ //-- 循环判断,拿到最贵的那张卡 --
+ for (var ih in plusCard) {
+ if (plusCard[ih].IsStopBuy == true) { continue; }
+ if (max_price < 0) {
+ max_price = plusCard[ih].CardFee;
+ name = 'card' + plusCard[ih]['CorrPrice'];
+ show_card = plusCard[ih];
+ } else {
+ if (max_price < plusCard[ih].CardFee) {
max_price = plusCard[ih].CardFee;
name = 'card' + plusCard[ih]['CorrPrice'];
show_card = plusCard[ih];
- } else {
- if (max_price < plusCard[ih].CardFee) {
- max_price = plusCard[ih].CardFee;
- name = 'card' + plusCard[ih]['CorrPrice'];
- show_card = plusCard[ih];
- }
}
}
+ }
- if (show_card) {
- name = name.toLowerCase();
- th.setData({ card_name: name, show_card: show_card })
- }
+ if (show_card) {
+ name = name.toLowerCase();
+ th.setData({ card_name: name, show_card: show_card })
}
- //-----先获取物流,再获取用户信息,再展示页面-----
- th.get_wuliu(th.get_info(th.show_page));
- })
+ }
+ //-----先获取物流,再获取用户信息,再展示页面-----
+ th.get_wuliu(th.get_info(th.show_page));
+ })
+ } else {
+ //-----先获取物流,再获取用户信息,再展示页面-----
+ th.get_wuliu(th.get_info(th.show_page));
+ }
+ }, 1)
+
+ },
+ //---------------检查是否有收货地址-------------------
+ checkAddressList: function () {
+ var t = this;
+ return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({
+ title: "请先填写或选择收货地址~",
+ success: function (a) {
+ a.confirm ? t.enterAddressPage() : wx.navigateBack();
+ },
+ fail: function () {
+ wx.navigateBack();
+ }
+ }), !1);
+ },
+ showInvoice: function () {
+ this.setData({
+ invoiceToggle: !this.data.invoiceToggle
+ });
+ },
+ keyUpChangePay1: function (t) {
+ this.setData({
+ payWithUserMoney: !(t.detail.value.length > 0)
+ });
+ },
+ keyUpChangePay2: function (t) {
+ this.setData({
+ payWithPoints: !(t.detail.value.length > 0)
+ });
+ },
+ keyUpChangeNum: function (t) {
+ this.setData({
+ maxWord: t.detail.value.length
+ });
+ },
+ //---------计算立即购买----------
+ calculatePrice2: function () {
+ var th = this, good = this.data.bn_goods;
+ //-----------计算商品总价--------------
+ var allpice = good.shop_price * good.buynum;
+ allpice = parseFloat(allpice).toFixed(2);
+ var txt = "formData.all_price";
+ th.setData({ [txt]: allpice, });
+ console.log(th.data.formData);
+
+ to.getConfig2(function (ee) {
+ to.getwuliuprice(function (rs) {
+ console.log('calculatePrice2222');
+ console.log(rs);
+ var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
+ var out_of_weight = null; //超出多少重量
+ var freight_free = ee.freight_free; //全场满多少包邮
+ var weight_free = ee.weight_free; //多少kg内包邮
+ //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格----------
+ if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
+ switch (good['exp_sum_type']) {
+ case 1:
+ //统一运费
+ o_shipping_price += good['uniform_exp_sum']; break;
+ case 2:
+ if (goods_weight < 0) goods_weight = 0;
+ //累积商品重量 每种商品的重量 * 数量
+ goods_weight += good['weight'] * good['buynum'];
+ if (weight_free > 0) {
+ out_of_weight = (weight_free * 1000) - goods_weight;
+ }
+ break;
+ case 3:
+ if (goods_piece < 0) goods_piece = 0;
+ //累积商品数量
+ goods_piece += good['buynum']; break;
+ }
+
+ console.log(o_shipping_price + ":" + goods_weight + ":" + goods_piece);
+ console.log(th.data.wu_arr);
+ var code = th.data.wu_arr[th.data.index].code;
+ var freight_free = ee.freight_free; //全场满多少包邮
+ var shipping_price =
+ th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
+ goods_piece, th.data.user_addr, freight_free, allpice, rs);
+
+ shipping_price = parseFloat(shipping_price).toFixed(2);
+ var wl_txt = "formData.shipping_price";
+ th.setData({ [wl_txt]: shipping_price, })
+
} else {
- //-----先获取物流,再获取用户信息,再展示页面-----
- th.get_wuliu(th.get_info(th.show_page));
+ var wl_txt = "formData.shipping_price";
+ th.setData({ [wl_txt]: 0, })
+ }
+ //-----------------总价-----------------
+ var total_m = parseFloat(allpice) + parseFloat(th.data.formData.shipping_price);
+ total_m = parseFloat(total_m).toFixed(2);
+
+ var atxt = "formData.total_amount";
+ th.setData({ [atxt]: total_m, })
+ var order_m = total_m;
+
+ var txt = "formData.user_money";
+ var txt2 = "formData.order_amount";
+ //--------------如果使用余额---------------------
+ if (th.data.bn_use_money == 1 && th.data.yuer > 0) {
+ if (parseFloat(th.data.yuer) > total_m) {
+ th.setData({ [txt]: total_m, [txt2]: 0 })
+ } else {
+ order_m = parseFloat(order_m) - parseFloat(th.data.yuer);
+ order_m = order_m.toFixed(2);
+ th.setData({ [txt]: th.data.yuer, [txt2]: order_m })
+ }
+ } else {
+ th.setData({ [txt]: 0, [txt2]: order_m })
}
- }, 1)
-
- },
- //---------------检查是否有收货地址-------------------
- checkAddressList: function() {
- var t = this;
- return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({
- title: "请先填写或选择收货地址~",
- success: function(a) {
- a.confirm ? t.enterAddressPage() : wx.navigateBack();
- },
- fail: function() {
- wx.navigateBack();
- }
- }), !1);
- },
- showInvoice: function() {
- this.setData({
- invoiceToggle: !this.data.invoiceToggle
- });
- },
- keyUpChangePay1: function(t) {
- this.setData({
- payWithUserMoney: !(t.detail.value.length > 0)
- });
- },
- keyUpChangePay2: function(t) {
- this.setData({
- payWithPoints: !(t.detail.value.length > 0)
- });
- },
- keyUpChangeNum: function(t) {
- this.setData({
- maxWord: t.detail.value.length
- });
- },
- //---------计算立即购买----------
- calculatePrice2: function () {
- console.log('calculatePrice2');
- var th = this, good = this.data.bn_goods;
- //-----------计算商品总价--------------
- var allpice = good.shop_price * good.buynum;
- allpice=parseFloat(allpice).toFixed(2);
- var txt = "formData.all_price";
- th.setData({ [txt]: allpice, });
- console.log(th.data.formData);
-
- to.getConfig2(function (ee) {
- to.getwuliuprice(function (rs) {
- console.log('calculatePrice2222');
- console.log(rs);
- var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
- //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格----------
- if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){
- switch (good['exp_sum_type']) {
- case 1:
- //统一运费
- o_shipping_price += good['uniform_exp_sum']; break;
- case 2:
- if (goods_weight < 0) goods_weight = 0;
- //累积商品重量 每种商品的重量 * 数量
- goods_weight += good['weight'] * good['buynum'];break;
- case 3:
- if (goods_piece < 0) goods_piece = 0;
- //累积商品数量
- goods_piece += good['buynum']; break;
- }
-
- console.log(o_shipping_price + ":" + goods_weight + ":" + goods_piece);
- console.log(th.data.wu_arr);
- var code = th.data.wu_arr[th.data.index].code;
- var freight_free = ee.freight_free; //全场满多少包邮
- var shipping_price=
- th.calculatewuliu(code, o_shipping_price, goods_weight,
- goods_piece, th.data.user_addr, freight_free, allpice, rs);
-
- shipping_price = parseFloat(shipping_price).toFixed(2);
- var wl_txt = "formData.shipping_price";
- th.setData({ [wl_txt]: shipping_price, })
-
- }else{
- var wl_txt = "formData.shipping_price";
- th.setData({ [wl_txt]: 0, })
- }
- //-----------------总价-----------------
- var total_m = parseFloat(allpice) + parseFloat( th.data.formData.shipping_price);
- total_m = parseFloat(total_m).toFixed(2);
-
- var atxt= "formData.total_amount";
- th.setData({ [atxt]: total_m, })
- var order_m = total_m;
-
- var txt = "formData.user_money";
- var txt2 = "formData.order_amount";
- //--------------如果使用余额---------------------
- if (th.data.bn_use_money == 1 && th.data.yuer>0) {
- if ( parseFloat(th.data.yuer) > total_m) {
- th.setData({ [txt]: total_m, [txt2]:0 })
- }else{
- order_m = parseFloat(order_m) - parseFloat(th.data.yuer);
- order_m = order_m.toFixed(2);
- th.setData({ [txt]: th.data.yuer, [txt2]: order_m })
- }
- }else{
- th.setData({ [txt]: 0, [txt2]: order_m })
- }
- });
});
- },
- //--------------------提交订单-----------------------
- submitForm: async function(t){
- if(this.data.is_summit_ing==1) return false; //--提交中退出--
- this.data.is_summit_ing=1;
-
- var th=this,pdata=new Array();
- var ff=true;
- //------------立即购买-------------
- console.log("buy_new");
-
- //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候
- if(th.data.bn_exp_type == 0 && th.data.user_addr==null && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){
- ff = false;
- getApp().my_warnning("请选择收货地址",0,this);
- this.data.is_summit_ing = 0;
- }
- if (!ff) return false;
- var addr = th.data.user_addr;
- if (th.data.bn_exp_type == 1) addr=null;
-
- console.log(th.data.formData);
- console.log(th.data.wu_arr);
- console.log(th.data.bn_exp_type);
-
- if(th.data.bn_exp_type==0 && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1)) {
- if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
- getApp().my_warnning("读取物流失败",0,this);
- this.data.is_summit_ing = 0;
- return false;
+ });
+ },
+ //--------------------提交订单-----------------------
+ submitForm: async function (t) {
+ if (this.data.is_summit_ing == 1) return false; //--提交中退出--
+ this.data.is_summit_ing = 1;
+
+ var th = this, pdata = new Array();
+ var ff = true;
+ //------------立即购买-------------
+ console.log("buy_new");
+
+ //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候
+ if (th.data.bn_exp_type == 0 && th.data.user_addr == null && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
+ ff = false;
+ getApp().my_warnning("请选择收货地址", 0, this);
+ this.data.is_summit_ing = 0;
+ }
+ if (!ff) return false;
+ var addr = th.data.user_addr;
+ if (th.data.bn_exp_type == 1) addr = null;
+
+ console.log(th.data.formData);
+ console.log(th.data.wu_arr);
+ console.log(th.data.bn_exp_type);
+
+ if (th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
+ if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
+ getApp().my_warnning("读取物流失败", 0, this);
+ this.data.is_summit_ing = 0;
+ return false;
+ }
+ }
+
+ //阶梯团强制带1,自提~~~
+ if (th.data.kt_type == 3) {
+ th.data.bn_exp_type = 1;
+ }
+
+ var item = {
+ 'user_id': to.globalData.user_id,
+ 'consignee': addr == null ? "" : addr.consignee,
+ 'province': addr == null ? 0 : addr.province,
+ 'city': addr == null ? 0 : addr.city,
+ 'district': addr == null ? 0 : addr.district,
+ 'twon': addr == null ? 0 : addr.twon,
+ 'address': addr == null ? "" : addr.address,
+ 'more_address': addr == null ? "" : addr.more_address,
+ 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile,
+ 'email': '',
+ 'invoice_title': '',
+ 'goods_price': th.data.formData.all_price, //商品总价
+ 'shipping_price': th.data.formData.shipping_price, //物流金额
+ 'user_money': th.data.formData.user_money, //使用余额
+ 'total_amount': th.data.formData.total_amount, //订单总价
+ 'order_amount': th.data.formData.order_amount, //应付
+ 'user_note': t.detail.value.user_note, //用户备注
+ 'store_id': oo.stoid, //商家
+ 'pickup_id': th.data.bn_pick, //门店
+ 'exp_type': th.data.bn_exp_type, //配送方式
+ 'is_normal': th.data.bn_goods.is_normal, //是否是普通购买
+ 'pt_prom_id': th.data.bn_goods.prom_id, //拼单ID
+ 'is_pt_tz': th.data.is_pt_tz, //开团类型
+ 'order_goods': new Array(),
+ };
+
+ //如果不是阶梯团,或者是普通购买,
+ if ((th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
+ item['shipping_code'] = th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code;
+ item['shipping_name'] = th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name;
+ }
+
+ if (!th.data.bn_goods.is_normal) {
+ item.is_zsorder = th.data.kt_type + 1; //开团类型
+ }
+ //老会员成为分销下线需要的参数
+ if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) {
+ //判断一下分享人是不是分享商
+ await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => {
+ if (res.data.code == 0) {
+ var user = res.data.data;
+ if (user.is_distribut == 1) {
+ item.first_leader = parseInt(getApp().globalData.first_leader);
}
}
-
- //阶梯团强制带1,自提~~~
- if(th.data.kt_type==3 ){
- th.data.bn_exp_type=1;
- }
-
- var item={
- 'user_id': to.globalData.user_id,
- 'consignee': addr == null ? "" : addr.consignee,
- 'province': addr == null ? 0 : addr.province,
- 'city': addr == null ? 0 : addr.city,
- 'district': addr == null ? 0 : addr.district,
- 'twon': addr == null ? 0 : addr.twon,
- 'address': addr == null ? "": addr.address,
- 'more_address': addr == null ? "" : addr.more_address,
- 'mobile': addr == null ? th.data.userinfo.mobile:addr.mobile,
- 'email':'',
- 'invoice_title':'',
- 'goods_price': th.data.formData.all_price, //商品总价
- 'shipping_price': th.data.formData.shipping_price, //物流金额
- 'user_money': th.data.formData.user_money, //使用余额
- 'total_amount': th.data.formData.total_amount, //订单总价
- 'order_amount': th.data.formData.order_amount, //应付
- 'user_note': t.detail.value.user_note, //用户备注
- 'store_id':oo.stoid, //商家
- 'pickup_id': th.data.bn_pick, //门店
- 'exp_type': th.data.bn_exp_type, //配送方式
- 'is_normal':th.data.bn_goods.is_normal, //是否是普通购买
- 'pt_prom_id':th.data.bn_goods.prom_id, //拼单ID
- 'is_pt_tz':th.data.is_pt_tz, //开团类型
- 'order_goods':new Array(),
- };
-
- //如果不是阶梯团,或者是普通购买,
- if((th.data.kt_type!=3 || th.data.bn_goods.is_normal==1)){
- item['shipping_code']= th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code;
- item['shipping_name']= th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name;
- }
-
- if(!th.data.bn_goods.is_normal){
- item.is_zsorder=th.data.kt_type+1; //开团类型
- }
- //老会员成为分销下线需要的参数
- if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){
- //判断一下分享人是不是分享商
- await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{
- if(res.data.code==0){
- var user= res.data.data;
- if(user.is_distribut==1){
- item.first_leader=parseInt(getApp().globalData.first_leader);
- }
- }
- })
- }
-
- if(th.data.qh!='')
- {
- item.team_qh=th.data.qh;
- item.pt_listno=th.data.qh;
- }
-
- var gg = to.get_b_now();
- var goods={
- 'goods_id': gg.goods_id,
- 'goods_name': gg.goods_name,
- 'goods_sn': gg.goods_sn,
- 'goods_num': gg.goods_num,
- 'market_price': th.data.bn_goods.market_price,
- 'goods_price': th.data.bn_goods.shop_price,
- 'member_goods_price': th.data.bn_goods.shop_price,
- 'store_id': oo.stoid,
- 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
- 'prom_id': th.data.bn_goods.prom_id, //促销活动id
- };
-
- //--导购分享过来的id--
- if(gg.guide_id){
- goods.guide_id=gg.guide_id;
- goods.guide_type=gg.guide_type;
- //调用接口判断是不是会员
- await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/"+oo.stoid+"/"+gg.guide_id,{}).then(res=>{
- if(res.data.code==0){
- goods.guide_name=res.data.data.salesman;
- goods.guide_sn=res.data.data.salesman_no;
- }
- })
- }
-
- //--商品的房间号--
- if(gg.room_id && gg.room_id>0){
- item.room_ids=gg.room_id;
- goods.room_id=gg.room_id;
+ })
+ }
+
+ if (th.data.qh != '') {
+ item.team_qh = th.data.qh;
+ item.pt_listno = th.data.qh;
+ }
+
+ var gg = to.get_b_now();
+ var goods = {
+ 'goods_id': gg.goods_id,
+ 'goods_name': gg.goods_name,
+ 'goods_sn': gg.goods_sn,
+ 'goods_num': gg.goods_num,
+ 'market_price': th.data.bn_goods.market_price,
+ 'goods_price': th.data.bn_goods.shop_price,
+ 'member_goods_price': th.data.bn_goods.shop_price,
+ 'store_id': oo.stoid,
+ 'prom_type': th.data.bn_goods.prom_type, //促销活动类型
+ 'prom_id': th.data.bn_goods.prom_id, //促销活动id
+ };
+
+ //--导购分享过来的id--
+ if (gg.guide_id) {
+ goods.guide_id = gg.guide_id;
+ goods.guide_type = gg.guide_type;
+ //调用接口判断是不是会员
+ await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => {
+ if (res.data.code == 0) {
+ goods.guide_name = res.data.data.salesman;
+ goods.guide_sn = res.data.data.salesman_no;
}
-
- if(th.data.bn_goods.is_normal){goods.is_pd_normal=1;}
-
- item.order_goods.push(goods);
- pdata.push(item);
-
- if (pdata.length==0) return;
- var str = JSON.stringify(pdata);
- console.log("支付数据");
- console.log(str);
- //return false;
- wx.showLoading({title: "加载中"});
- wx.request({
- url: oo.url + '/api/weshop/order/createWxdOrder',
- data: str,
- method: 'POST',
- header: {
- 'content-type': 'application/json'
- },// 设置请求的 header
- success: function (res) {
-
- wx.hideLoading();
- if (res.statusCode == 200) {
- var data=res.data;
- if(data.code==0){
- console.log(th.data.is_b_now);
- //如果是购物车结算,还要删除购物车
- if (th.data.is_b_now == 0) {
- console.log(th.data.cartlist_y);
- var list = th.data.cartlist_y;
- for (var i = 0; i < list.length; i++) {
- //删除购物车
- getApp().request.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {});
- }
- }
- var order_amount = 0;
- pdata.forEach(function (em, ind) {
- order_amount += em.order_amount;
- })
- //要进行判断,如果是用微信支付,就要跳转到支付界面
- if (order_amount > 0) {
+ })
+ }
+
+
+ //--商品的房间号--
+ if (gg.room_id && gg.room_id > 0) {
+ item.room_ids = gg.room_id;
+ goods.room_id = gg.room_id;
+ }
+
+ if (th.data.bn_goods.is_normal) { goods.is_pd_normal = 1; }
+
+ item.order_goods.push(goods);
+ pdata.push(item);
+
+ if (pdata.length == 0) return;
+ var str = JSON.stringify(pdata);
+ console.log("支付数据");
+ console.log(str);
+ //return false;
+ wx.showLoading({ title: "加载中" });
+ wx.request({
+ url: oo.url + '/api/weshop/order/createWxdOrder',
+ data: str,
+ method: 'POST',
+ header: {
+ 'content-type': 'application/json'
+ },// 设置请求的 header
+ success: function (res) {
+
+ wx.hideLoading();
+ if (res.statusCode == 200) {
+ var data = res.data;
+ if (data.code == 0) {
+ console.log(th.data.is_b_now);
+ //如果是购物车结算,还要删除购物车
+ if (th.data.is_b_now == 0) {
+ console.log(th.data.cartlist_y);
+ var list = th.data.cartlist_y;
+ for (var i = 0; i < list.length; i++) {
+ //删除购物车
+ getApp().request.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {});
+ }
+ }
+ var order_amount = 0;
+ pdata.forEach(function (em, ind) {
+ order_amount += em.order_amount;
+ })
+ //要进行判断,如果是用微信支付,就要跳转到支付界面
+ if (order_amount > 0) {
+ th.setData({ isclose: 0 });
+ //void e.jumpToCart4({
+ // order_sn: data.data,
+ // type:1,
+ // }, 1);
+ util_pay.pay(data.data, function () {
+ setTimeout(function () {
+ wx.reLaunch({
+ //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data,
+ url: "/pages/team/team_success/team_success?ordersn=" + data.data,
+ })
+ }, 1000)
+ }, function () {
+ //支付失败
+ setTimeout(function () {
+ //wx.navigateBack({ delta: 1 })
+ wx.reLaunch({
+ url: "/pages/user/order_list/order_list",
+ })
+ }, 1000)
+
+ }, oo.stoid, 1);
+
+ } else {
+ var dd = {
+ parent_sn: data.data,
+ store_id: oo.stoid,
+ type: 1,
+ };
+ //return false;
+ getApp().request.post("/api/weshop/order/pay/createOrder", {
+ data: dd,
+ success: function (t) {
+ console.log(t);
+ app.my_warnning("支付成功", 1, th);
+ setTimeout(function () {
th.setData({ isclose: 0 });
- //void e.jumpToCart4({
- // order_sn: data.data,
- // type:1,
- // }, 1);
- util_pay.pay(data.data, function() {
- setTimeout(function () {
- wx.reLaunch({
- //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data,
- url: "/pages/team/team_success/team_success?ordersn=" + data.data,
- })
- },1000)
- }, function () {
- //支付失败
- setTimeout(function () {
- //wx.navigateBack({ delta: 1 })
- wx.reLaunch({
- url: "/pages/user/order_list/order_list",
- })
- },1000)
-
- },oo.stoid,1);
- } else {
- var dd = {
- parent_sn: data.data,
- store_id: oo.stoid,
- type: 1,
- };
- //return false;
- getApp().request.post("/api/weshop/order/pay/createOrder", {
- data: dd,
- success: function (t) {
- console.log(t);
- app.my_warnning("支付成功",1,th);
- setTimeout(function () {
- th.setData({ isclose: 0 });
-
- if(th.data.is_normal==1){
- /*--
- wx.navigateTo({
- url: "/pages/user/order_list/order_list",
- })--*/
- var url="/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data;
- wx.reLaunch({
- url: url
- })
-
- }else{
- wx.reLaunch({
- url: "/pages/team/team_success/team_success?ordersn=" + data.data,
- })
- }
-
-
- }, 1000)
+ if (th.data.is_normal == 1) {
+ /*--
+ wx.navigateTo({
+ url: "/pages/user/order_list/order_list",
+ })--*/
+ var url = "/pages/payment/pay_success/pay_success?type=1&order_sn=" + data.data;
+ wx.reLaunch({
+ url: url
+ })
+
+ } else {
+ wx.reLaunch({
+ url: "/pages/team/team_success/team_success?ordersn=" + data.data,
+ })
}
- });
+
+
+ }, 1000)
}
- }
- else{
- th.data.is_summit_ing=0; //是否提交中
- getApp().confirmBox(data.msg);
- }
- } else {
- th.data.is_summit_ing=0; //是否提交中
- console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
+ });
+ }
}
- },
- fail: function () {
- th.data.is_summit_ing=0; //是否提交中
- wx.hideLoading();
- console.log("index.js wx.request CheckCallUser fail");
- },
- complete: function () {}
- })
- },
- useCoupon: function() {
- if (this.data.order.couponNum <= 0) {
- //return t.showWarning("无可用优惠券");
- getApp().my_warnning("无可用优惠券",0,this);
- return;
+ else {
+ th.data.is_summit_ing = 0; //是否提交中
+ getApp().confirmBox(data.msg);
+ }
+ } else {
+ th.data.is_summit_ing = 0; //是否提交中
+ console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
}
- var a = {
- lid: this.data.coupon ? this.data.coupon.id : "0"
- };
- wx.navigateTo({
- url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a)
- });
- },
- enterAddressPage: function() {
- getApp().globalData.is_cart_old=1;
- this.data.enterAddressPage = !0, wx.navigateTo({
- url: "/pages/user/address_list/address_list"
- });
- },
+ },
+ fail: function () {
+ th.data.is_summit_ing = 0; //是否提交中
+ wx.hideLoading();
+ console.log("index.js wx.request CheckCallUser fail");
+ },
+ complete: function () { }
+ })
+ },
+ useCoupon: function () {
+ if (this.data.order.couponNum <= 0) {
+ //return t.showWarning("无可用优惠券");
+ getApp().my_warnning("无可用优惠券", 0, this);
+ return;
+ }
+ var a = {
+ lid: this.data.coupon ? this.data.coupon.id : "0"
+ };
+ wx.navigateTo({
+ url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a)
+ });
+ },
+ enterAddressPage: function () {
+ getApp().globalData.is_cart_old = 1;
+ this.data.enterAddressPage = !0, wx.navigateTo({
+ url: "/pages/user/address_list/address_list"
+ });
+ },
- //--------立即购买时,选择自提和物流-----------
- setexptype_w:function(t){
- var th=this;
- var ty = t.currentTarget.dataset.t,txt = t.currentTarget.dataset.txt;
- th.setData({ [txt]: ty });
- var iszt=1;
- if(ty==0){
- th.setData({ is_all_zt: 0 });
- }else{
- for(var i=0;i 0 && o_price >= freight_free){ return 0;}
- if (user_addr==null) { return 0; }
- //计算物流的config item;
- var item=null;
- //先根据 镇 县 区找计算的config
- item = th.get_wuliu_config(user_addr.district,code,rs);
- if (item==null) item = th.get_wuliu_config(user_addr.city, code, rs);
- if (item==null) item = th.get_wuliu_config(user_addr.province, code, rs);
- if (item == null) item = th.get_wuliu_default(code,rs);
+ calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight,
+ goods_piece, user_addr, freight_free, o_price, rs, pickid) {
+ var price = 0, th = this;
+ price += parseFloat(o_shipping_price);
+ //如果是包邮
+ if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; }
+ if (user_addr == null) { return 0; }
+ //计算物流的config item;
+ var item = null;
+ //先根据 镇 县 区找计算的config
+ item = th.get_wuliu_config(user_addr.district, code, rs);
+ if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
+ if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
+ if (item == null) item = th.get_wuliu_default(code, rs);
+ if (item == null) return o_shipping_price;
+ var fw_price = 0, fp_price = 0;
+ item = item.config;
if (item == null) return o_shipping_price;
- var fw_price = 0, fp_price=0;
- item=item.config;
- if (item == null) return o_shipping_price;
//------按重量----------
- if (goods_weight>=0) {
- fw_price =parseFloat(item['money']);
- if (goods_weight > item['first_weight']){
- var fw = goods_weight - item['first_weight'];
- var n = Math.ceil(fw/item['second_weight'])
- fw_price = fw_price + n * parseFloat(item['add_money']);
- }
+ if (goods_weight >= 0 && item['money']) {
+ fw_price = parseFloat(item['money']);
+ if (goods_weight > item['first_weight']) {
+ var fw = goods_weight - item['first_weight'];
+ var n = Math.ceil(fw / item['second_weight'])
+ fw_price = fw_price + n * parseFloat(item['add_money']);
+ }
+ }
+ //------超出重量----------
+ if (out_of_weight < 0 && o_price >= freight_free) {
+ fw_price = parseFloat(item['money']);
+ var out_of_weight = Math.abs(out_of_weight);
+ if (out_of_weight > item['first_weight']) {
+ var fw = out_of_weight - item['first_weight'];
+ var n = Math.ceil(fw / item['second_weight'])
+ fw_price = fw_price + n * parseFloat(item['add_money']);
+ }
}
//------按件数----------
if (goods_piece > 0) {
fp_price = parseFloat(item['piecemoney']);
if (goods_piece > item['first_piece']) {
- var fp = goods_piece - item['first_piece'];
- var m = Math.ceil(fp / item['second_piece'])
+ var fp = goods_piece - item['first_piece'];
+ var m = Math.ceil(fp / item['second_piece'])
fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
}
}
- var rspice =parseFloat(price + fw_price + fp_price);
+ var rspice = parseFloat(price + fw_price + fp_price);
return rspice;
},
//------------循环获取config-----------
- get_wuliu_config:function(region_id,code,rs){
- var item=null,rslist = rs.pageData;
- for (var i = 0; i < rslist.length;i++){
- if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i];}
- }
- return item;
+ get_wuliu_config: function (region_id, code, rs) {
+ var item = null, rslist = rs.pageData;
+ for (var i = 0; i < rslist.length; i++) {
+ if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; }
+ }
+ return item;
},
//-------循环获取config,code default-------
get_wuliu_default: function (code, rs) {
- var item = null, rslist=rs.pageData;
+ var item = null, rslist = rs.pageData;
for (var i = 0; i < rslist.length; i++) {
if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; }
}
return item;
},
- //----------立即购买,选择物流-------------
- bindPickerChange:function(e){
- var ind = e.detail.value
- this.setData({ index: ind });
- this.calculatePrice2();
- },
-
- //----------购物车结算,选择物流-------------
- bindPickerChange_w: function (e) {
- var ind=e.detail.value, txt = e.currentTarget.dataset.txt;
- this.setData({ [txt]: ind });
- this.calculatePrice();
- },
-
+ //----------立即购买,选择物流-------------
+ bindPickerChange: function (e) {
+ var ind = e.detail.value
+ this.setData({ index: ind });
+ this.calculatePrice2();
+ },
+
+ //----------购物车结算,选择物流-------------
+ bindPickerChange_w: function (e) {
+ var ind = e.detail.value, txt = e.currentTarget.dataset.txt;
+ this.setData({ [txt]: ind });
+ this.calculatePrice();
+ },
+
cart_set_err: function (e) {
var txt = e.currentTarget.dataset.err;
var ob = {};
@@ -852,70 +868,70 @@ Page({
this.setData(ob);
},
- //// 开启物流的弹窗
- show_wu_arr:function(e){
- this.setData({ open_express: 1});
- },
+ //// 开启物流的弹窗
+ show_wu_arr: function (e) {
+ this.setData({ open_express: 1 });
+ },
- //更新下默认,在onshow里面
- update_code(){
- var th=this,m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code;
-
- var uii=setInterval(function () {
- if(th.data.wu_arr){
- clearInterval(uii);
- for (var k = 0; k < th.data.wu_arr.length; k++) {
- var item = th.data.wu_arr[k];
- if (def_exp_code == item.code) {
- m_wind = k;
- }
- }
- //--如果是立即购买--
- th.setData({ index: m_wind, is_express: m_wind});
- }
- },500)
- },
+ //更新下默认,在onshow里面
+ update_code() {
+ var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
+
+ var uii = setInterval(function () {
+ if (th.data.wu_arr) {
+ clearInterval(uii);
+ for (var k = 0; k < th.data.wu_arr.length; k++) {
+ var item = th.data.wu_arr[k];
+ if (def_exp_code == item.code) {
+ m_wind = k;
+ }
+ }
+ //--如果是立即购买--
+ th.setData({ index: m_wind, is_express: m_wind });
+ }
+ }, 500)
+ },
- // 关闭物流的弹窗
- close_express:function(){
- this.setData({ open_express:0 });
- },
- // 选择物流
- click_express_name:function(e){
- var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
- var index=e.currentTarget.dataset.idxe;
- var ob={ is_express: index, is_shipping_code: shippingcode,index:index};
- this.setData(ob);
- },
+ // 关闭物流的弹窗
+ close_express: function () {
+ this.setData({ open_express: 0 });
+ },
+ // 选择物流
+ click_express_name: function (e) {
+ var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
+ var index = e.currentTarget.dataset.idxe;
+ var ob = { is_express: index, is_shipping_code: shippingcode, index: index };
+ this.setData(ob);
+ },
- //点击确定物流
- determine_expres:function(e){
- this.setData({ open_express: 0});
- this.calculatePrice2();
- },
- //设置默认物流
- select_default_logistics: function () {
- var th=this;
- var is_shipping_code=this.data.is_shipping_code
- getApp().request.put("/api/weshop/users/update",{
- data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code},
- success:function(rse){
- if (rse.data.code==0){
- getApp().globalData.userInfo.def_exp_code=is_shipping_code;
- th.setData({ open_express: 0 });
- //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19----
- //if(th.data.is_b_now==1) th.calculatePrice2();
- //else th.calculatePrice();
- th.calculatePrice2();
- }
- }
- })
- },
+ //点击确定物流
+ determine_expres: function (e) {
+ this.setData({ open_express: 0 });
+ this.calculatePrice2();
+ },
+ //设置默认物流
+ select_default_logistics: function () {
+ var th = this;
+ var is_shipping_code = this.data.is_shipping_code
+ getApp().request.put("/api/weshop/users/update", {
+ data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code },
+ success: function (rse) {
+ if (rse.data.code == 0) {
+ getApp().globalData.userInfo.def_exp_code = is_shipping_code;
+ th.setData({ open_express: 0 });
+ //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19----
+ //if(th.data.is_b_now==1) th.calculatePrice2();
+ //else th.calculatePrice();
+ th.calculatePrice2();
+ }
+ }
+ })
+ },
- //跳转到购买卡
- buycard:function(){
- getApp().goto("/pages/user/plus/plus");
- getApp().globalData.plus_buy_back=1;
- }
+ //跳转到购买卡
+ buycard: function () {
+ getApp().goto("/pages/user/plus/plus");
+ getApp().globalData.plus_buy_back = 1;
+ }
});
diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js
index f55f477..ae5f3ee 100644
--- a/pages/cart/cart_wk/cart_wk.js
+++ b/pages/cart/cart_wk/cart_wk.js
@@ -420,10 +420,10 @@ Page({
var to = getApp(), th = this;
to.getConfig2(function (ee) {
to.getwuliuprice(function (rs) {
- var o_shipping_price = 0,
- goods_weight = -1,
- goods_piece = -1,
- good = th.data.goods;
+ var o_shipping_price = 0,goods_weight = -1,goods_piece = -1,good=th.data.goods;
+ var out_of_weight=null; //超出多少重量
+ var freight_free = ee.freight_free; //全场满多少包邮
+ var weight_free = ee.weight_free; //多少kg内包邮
//-----------当地址不为空,且是物流时,计算物流费用----------
if (th.data.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) {
switch (good['exp_sum_type']) {
@@ -435,6 +435,9 @@ Page({
if (goods_weight < 0) goods_weight = 0;
//累积商品重量 每种商品的重量 * 数量
goods_weight += good['weight'] * th.data.order.order_goods['goods_num'];
+ if(weight_free > 0){
+ out_of_weight = (weight_free * 1000 ) - goods_weight;
+ }
break;
case 3:
if (goods_piece < 0) goods_piece = 0;
@@ -443,11 +446,10 @@ Page({
break;
}
var code = th.data.wu_arr[th.data.index].code;
- var freight_free = ee.freight_free; //全场满多少包邮
//--全部金额--
var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money;
var shipping_price =
- th.calculatewuliu(code, o_shipping_price, goods_weight,
+ th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight,
goods_piece, th.data.user_addr, freight_free, allpice, rs);
var exp_price = parseFloat(shipping_price).toFixed(2);
allpice = parseFloat(exp_price) + parseFloat(allpice);
@@ -465,12 +467,12 @@ Page({
},
//----------------计算物流---------------
- calculatewuliu: function (code, o_shipping_price, goods_weight,
+ calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight,
goods_piece, user_addr, freight_free, o_price, rs) {
var price = 0, th = this;
price += parseFloat(o_shipping_price);
//如果是包邮
- if (freight_free > 0 && o_price >= freight_free) { return 0; }
+ if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0) { return 0; }
if (user_addr == null) { return 0; }
//计算物流的config item;
var item = null;
@@ -484,7 +486,7 @@ Page({
item = item.config;
if (item == null) return o_shipping_price;
//------按重量----------
- if (goods_weight > 0) {
+ if (goods_weight >= 0 && item['money']) {
fw_price = parseFloat(item['money']);
if (goods_weight > item['first_weight']) {
var fw = goods_weight - item['first_weight'];
@@ -492,6 +494,16 @@ Page({
fw_price = fw_price + n * parseFloat(item['add_money']);
}
}
+ //------超出重量----------
+ if(out_of_weight < 0 && o_price >= freight_free){
+ fw_price = parseFloat(item['money']);
+ var out_of_weight = Math.abs(out_of_weight);
+ if (out_of_weight > item['first_weight']) {
+ var fw = out_of_weight - item['first_weight'];
+ var n = Math.ceil(fw / item['second_weight'])
+ fw_price = fw_price + n * parseFloat(item['add_money']);
+ }
+ }
//------按件数----------
if (goods_piece > 0) {
fp_price = parseFloat(item['piecemoney']);
diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js
index ed3a012..5e476db 100644
--- a/pages/goods/goodsInfo/goodsInfo.js
+++ b/pages/goods/goodsInfo/goodsInfo.js
@@ -33,6 +33,8 @@ Page({
iurl: o.imghost,
defaultAvatar: o.resourceUrl + "/static/images/user68.jpg",
+ viplimited_timetype: 0,
+
data: null,
content: "", //商品详情
comments: null, //商品评论
@@ -740,7 +742,8 @@ Page({
i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, {
failRollback: !0,
success: function (t) {
- console.log(t);
+
+ ee.data.viplimited_timetype = t.data.data.viplimited_timetype;
if (t.data.code == 0) {
if (t.data.data.is_on_sale != 1) {
wx.showModal({
@@ -2243,7 +2246,7 @@ Page({
) {
url += "&room_id=" + getApp().globalData.room_id + "&room_user_share=1";
}
-
+ console.log(url,500);
var ob = {
title: price + "元 " + title,
path: url,
@@ -2268,7 +2271,6 @@ Page({
ob.title = text + " " + name;
}
-
//-- 页面不能刷新 --
this.data.show_prew_img=1;
return ob;
@@ -3720,7 +3722,8 @@ Page({
data: {
store_id: os.stoid,
user_id: user_id,
- goods_id: gd.goods_id
+ goods_id: gd.goods_id,
+ timetype: th.data.viplimited_timetype
},
success: function (t) {
if (t.data.code == 0) {
@@ -4164,7 +4167,7 @@ Page({
var item = this.data.teamgroup[ind];
var id = item.id;
var th = this;
-
+ var goods_id=this.data.data.goods_id;
getApp().request.get("/api/weshop/order/page", {
data: {
pt_prom_id: item.team_id,
@@ -4207,14 +4210,14 @@ Page({
} else {
wx.navigateTo({
- url: "/pages/team/team_show/team_show?tg_id=" + id,
+ url: `/pages/team/team_show/team_show?tg_id=${id}&goods_id=${goods_id}`,
});
}
}
//--跳转到参团--
else {
wx.navigateTo({
- url: "/pages/team/team_show/team_show?tg_id=" + id,
+ url: `/pages/team/team_show/team_show?tg_id=${id}&goods_id=${goods_id}`,
});
}
}
diff --git a/pages/team/team_show/team_show.js b/pages/team/team_show/team_show.js
index 110ef29..0f00042 100644
--- a/pages/team/team_show/team_show.js
+++ b/pages/team/team_show/team_show.js
@@ -94,18 +94,29 @@ Page({
},
onLoad: function(options) {
-
wx.setNavigationBarTitle({ title: "拼团订单",})
//var postdata=getApp().globalData.to_group;
var postdata=options;
- var tg_id = postdata.tg_id, first_leader=options.first_leader;
+ var tg_id = postdata.tg_id, first_leader=options.first_leader,goods_id=options.goods_id;
//如果tg_id是空的话
- if(tg_id==undefined || tg_id==null || tg_id==""){
+ if(tg_id==null ||goods_id==null){
var tg_id_str=decodeURIComponent(postdata.scene);
tg_id_str=tg_id_str.split("_");
- tg_id=tg_id_str[0];
- if(tg_id_str.length>1){
- first_leader=tg_id_str[1];
+ console.log(tg_id_str.length);
+ //tg_id_str[0] teamgroup.id tg_id_str[1] user_id tg_id_str[2] goods_id
+ switch(tg_id_str.length){
+ case 1:
+ tg_id=tg_id_str[0];
+ break;
+ case 2:
+ tg_id=tg_id_str[0];
+ first_leader=tg_id_str[1];
+ break;
+ case 3:
+ tg_id=tg_id_str[0];
+ first_leader=tg_id_str[1];
+ goods_id=tg_id_str[2];
+ break;
}
}
//--判断一下是不是导购--
@@ -118,14 +129,13 @@ Page({
}
})
}
-
- this.setData({tg_id: tg_id });
+ this.setData({tg_id: tg_id,goods_id});
getApp().globalData.to_group=null;
- var th=this;
- getApp().getConfig2(function(e) {
- th.setData({ bconfig: e,});
- th.wait_for_store_config(); //获取默认的门店
+ var th=this;
+ getApp().getConfig2(function(e) {
+ th.setData({ bconfig: e,});
+ th.wait_for_store_config(); //获取默认的门店
})
},
@@ -358,17 +368,47 @@ Page({
max_num = 0,
min_price = 0,
th=this,
- that=th;
+ that=th,
+ flag=null;
+ await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2",{
+ data:{
+ store_id: os.stoid,
+ is_end: 0,
+ is_show: 1,
+ user_id: getApp().globalData.user_id,
+ pageSize:1000
+ }
+ }).then(res=>{
+ let pd_list=res.data.data.pageData;
+ if(res.data.code==0 && pd_list.length>0){
+ flag =pd_list.some(pd=>{
+ // if(th.data.goods_id){
+ return pd.goods_id==th.data.goods_id;
+ // }
+ })
+ }
+ })
+ if(!flag){
+ wx.showToast({title: "当前会员身份不符,无法参与", icon: 'none', duration: 3000});
+ setTimeout(function () {
+ ut.wx_back();
+ }, 1000)
+ return false;
+ }
//获取活动从表信息team_id,listno团编号(券号)
await getApp().request.promiseGet("/api/weshop/teamgroup/get/"+os.stoid+"/"+tg_id, {
}).then(res => {
+
+ if(res.data.code !=0 ){
+ getApp().showWarning(res.data.msg);
+ th.go_back();
+ return false;
+ }
-
- if(res.data.code==0 && res.data && res.data.data ) {
+ if(res.data && res.data.data ) {
teamgroup = res.data.data;
-
//获取当前时间,并且判断剩余时间
var nt = ut.gettimestamp();
var buy_start_date = ut.formatTime(teamgroup.buy_start_date, "yyyy-MM-dd hh:mm:ss");
@@ -388,7 +428,6 @@ Page({
}
}
-
})
//判断是不是要继续的开关
@@ -433,36 +472,10 @@ Page({
//获取活动表的信息根据活动team_id
await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + teamgroup.team_id, {
data: {}
- }).then(async res => {
- var flag=null;
+ }).then(res => {
if (res.data.code == 0) {
teamlist = res.data.data;
goods_id = res.data.data.goods_id;
-
- await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/1",{
- data:{
- store_id: os.stoid,
- is_end: 0,
- is_show: 1,
- user_id: getApp().globalData.user_id,
- pageSize:1000
- }
- }).then(res=>{
- let pd_list=res.data.data.pageData;
- if(res.data.code==0 && pd_list.length>0){
- flag =pd_list.some(pd=>{
- return pd.goods_id==teamlist['goods_id']
- })
- }
- })
- if(!flag){
- wx.showToast({title: "当前会员身份不符,无法参与", icon: 'none', duration: 3000});
- // setTimeout(function () {
- ut.wx_back();
- // }, 2000)
- return false;
- }
-
//----------查看阶梯团------------
if (teamlist.ct_rylist != "" && teamlist.ct_rylist != null && teamlist.ct_rylist != undefined) {
var ct_rylist = JSON.parse(teamlist.ct_rylist);
diff --git a/pages/team/team_success/team_success.js b/pages/team/team_success/team_success.js
index 0bb3b38..0d85179 100644
--- a/pages/team/team_success/team_success.js
+++ b/pages/team/team_success/team_success.js
@@ -398,19 +398,26 @@ Page({
var app = getApp();
var unit = that.data.screenWidth / 750 * 1.35;
var scene=th.data.teamgroup.id;
+ var goods_id=th.data.teamlist.goods_id;
var user_id=getApp().globalData.user_id?getApp().globalData.user_id:0;
if(user_id>0){
scene+="_"+user_id;
}
+ if(goods_id !==""){
+ scene+="_"+goods_id;
+ }
//二微码
var path3 = os.url+ "/api/wx/open/app/user/getWeAppEwm/"+
os.stoid+"?sceneValue="+scene+"&pageValue=pages/team/team_show/team_show";
+ console.log(path3,6000);
+
//读取文件成功则OK--
wx.getImageInfo({
src: path3,
success:function (res) {
+ console.log(res,5000);
//回调写法
th.get_head_temp(th.get_goods_temp,function () {
var vpath = res.path;
@@ -812,7 +819,8 @@ Page({
onShareAppMessage: function (e) {
var th=this;
var scene=this.data.teamgroup.id;
- var url="/pages/team/team_show/team_show?tg_id="+scene;
+ var goods_id=this.data.teamlist.goods_id;
+ var url="/pages/team/team_show/team_show?tg_id="+scene+"&goods_id="+goods_id;
//--分享图片--
var img=th.data.iurl+th.data.teamlist.share_imgurl;
//--把会员分享出去--
@@ -828,7 +836,6 @@ Page({
if(th.data.teamlist.share_title){
share_title=th.data.teamlist.share_title;
}
- console.log(url,3000);
return {
path:url,
title: share_title,