Commit 36ffdc9e441c1786e71cc6ea27c882a8db700331

Authored by taiyuan
1 parent 7e6a94a4

新增代付,修改自定义模板组件

app.wxss
... ... @@ -706,9 +706,9 @@ background: #ffe3e2;
706 706 /* 图标字体(ty) */
707 707 @font-face {
708 708 font-family: 'iconfont'; /* Project id 2054717 */
709   - src: url('//at.alicdn.com/t/font_2054717_lj9v8hh5xa.woff2?t=1630891447571') format('woff2'),
710   - url('//at.alicdn.com/t/font_2054717_lj9v8hh5xa.woff?t=1630891447571') format('woff'),
711   - url('//at.alicdn.com/t/font_2054717_lj9v8hh5xa.ttf?t=1630891447571') format('truetype');
  709 + src: url('//at.alicdn.com/t/font_2054717_x1u9bka6w7.woff2?t=1630899459000') format('woff2'),
  710 + url('//at.alicdn.com/t/font_2054717_x1u9bka6w7.woff?t=1630899459000') format('woff'),
  711 + url('//at.alicdn.com/t/font_2054717_x1u9bka6w7.ttf?t=1630899459000') format('truetype');
712 712 }
713 713  
714 714 .iconfont {
... ... @@ -719,6 +719,10 @@ background: #ffe3e2;
719 719 -moz-osx-font-smoothing: grayscale;
720 720 }
721 721  
  722 +.icon-aixin:before {
  723 + content: "\e8c3";
  724 +}
  725 +
722 726 .icon-daifu:before {
723 727 content: "\e723";
724 728 }
... ...
components/diy_picMax/diy_picMax.wxml
... ... @@ -17,7 +17,7 @@
17 17 </block>
18 18 <block wx:else>
19 19 <view class="picMax" >
20   - <view wx:for="{{object.data}}" class="pic_item width_{{item.x_span}}">
  20 + <view wx:for="{{object.data}}" class="pic_item width_{{item.x_span}} mgt2">
21 21 <block wx:if="{{g_filter.has_char(item.wxapp_url,'plugin')>=0}}" >
22 22 <navigator url="{{item.wxapp_url}}">
23 23 <image src="{{item.src}}" mode="widthFix" style="display: block;" ></image>
... ... @@ -29,4 +29,6 @@
29 29 </view>
30 30 <view class="picMax-clear"></view>
31 31 </view>
  32 +
  33 +
32 34 </block>
... ...
components/diy_picMax/diy_picMax.wxss
... ... @@ -2,13 +2,19 @@
2 2 width: 100%;
3 3 overflow: hidden;
4 4 margin-top: -0.01rpx;
  5 + display: flex;
  6 + flex-wrap: wrap;
5 7 }
6 8 .pic_item{
7   - float: left; margin: 0; padding: 0;
  9 + float: left; margin: 0; padding: 0;font-size: 0;
8 10 }
  11 +/* .pic_item image{width: 100%;} */
9 12 .pic_item image{width: 100.1%;vertical-align: bottom; margin: 0;margin-left: -1rpx;font-size: 0; }
10 13 .picMax-clear{clear: both;}
11 14  
  15 +.mgt2 {
  16 + margin-top: -2rpx;
  17 +}
12 18  
13 19 .picMax2{
14 20 width: 100%;position: relative;
... ... @@ -16,7 +22,7 @@
16 22 .pic_item2{
17 23 position:absolute;top:0; left:0;
18 24 }
19   -.pic_item2 image{ width: 100%; height: 100%;}
  25 +.pic_item2 image{}
20 26 /* .width_1{width: 187.5rpx}.width_2{width: 375rpx;}.width_3{width: 562.5rpx}.width_4{width:750rpx;} */
21 27 .width_1{width: 25%}.width_2{width: 50%}.width_3{width: 75%}.width_4{width:100%}
22 28  
... ...
packageC/pages/payForAnother/payForAnother.js 0 → 100644
  1 +var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"),
  2 + s = require("../../../utils/util.js"), ut = s, o = require("../../../utils/md5.js"), to = getApp();
  3 +var oo = t.globalData.setting, os = oo;
  4 +var regeneratorRuntime = require('../../../utils/runtime.js');
  5 +var util_pay = require("../../../utils/pay.js");
  6 +var zh_calc = require("zh_calculate.js");
  7 +
  8 +Page({
  9 + data: {
  10 + url: t.globalData.setting.url,
  11 + resourceUrl: t.globalData.setting.resourceUrl,
  12 + imgUrl: t.globalData.setting.imghost,
  13 + goods: null,
  14 + order: null,
  15 + orderPrices: null,
  16 + coupons: null,
  17 + coupon: null,
  18 + invoiceToggle: !0,
  19 + payWithUserMoney: !0,
  20 + payWithPoints: !0,
  21 + maxWord: 0,
  22 + enterAddressPage: !1,
  23 + firstEnter: !0,
  24 + //页面获取的参数
  25 + param: null,
  26 + //提交订单的格式
  27 + formData: {
  28 + order_amount: 0,//支付金额
  29 + total_amount: 0,//总价
  30 + all_price: 0,//商品卖的总价
  31 + pay_points: 0,//使用积分
  32 + user_money: 0,//使用余额
  33 + couponCode: "",//使用优惠券(多单就用逗号隔开)
  34 + shipping_price: 0,//物流费用
  35 + },
  36 + /*-----------当是购物车结算的时候-------------*/
  37 + cartlist: null,
  38 + old_cartlist: null,
  39 + cartlist_y: null, //购物车原始列表
  40 + js_use_money: 0, //是否使用余额
  41 + is_all_zt: 1, //是否全部都是自提
  42 +
  43 + /*----------------立即购买---------------------*/
  44 + is_b_now: 0, //0是购物车结算 1立即购买
  45 + bn_goods: null, //立即购买时候的调用商品
  46 + bn_use_money: 0,//是否使用余额
  47 + bn_exp_type: 1, //0是物流 1自提
  48 + bn_pick: 0, //选择的门店
  49 + bn_pickname: "", //选择的门店名称
  50 + bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流
  51 +
  52 + bn_plus_cut_price: 0, //显示等级卡会优惠多少钱
  53 + /*------------------------*/
  54 + user_addr: null,//物流
  55 + userinfo: null, //获取会员
  56 + /*----------物流选择--------*/
  57 + wu_arr: null,
  58 + index: 0,
  59 + w_sele_index: 0,
  60 +
  61 + //判断页面是返回回来的还是 首次进入的
  62 + isclose: 1,
  63 + //申请提现的金额
  64 + txmon: 0,
  65 + yuer: 0,
  66 + //提交中,不重复提交
  67 + is_summit_ing: 0,
  68 + //--更优惠券抵用有关,立即购买的,如果是购物车,就要把相应的值,写入cartlist数组中--
  69 + ckeck_quan_price: 0,
  70 + check_quan_price_list: '',
  71 + check_quan_ware_list: '',
  72 +
  73 + // 设计一个数组来存放已经选择了的券编号,coupon_no是券号,money是面值,coupon_price是真正优惠的价格,数组的下标是pickid
  74 + //using_quan[11]={coupon_no:"1212121",money:"20",coupon_price:"45"}
  75 + using_quan: {},
  76 + open_quan: 0,
  77 + //选择的券列表
  78 + selected_quan_list: null,
  79 + //选择的券的门店
  80 + selected_quan_pick: null,
  81 + is_close_quan: 0,
  82 + disabled: 0,
  83 + open_express: 0,//控制选择物流名列表 的属性
  84 +
  85 + is_express: 0, //选中物流的属性
  86 + expres_name: "", //点击选定
  87 + isopen: 0, //券的说明
  88 + is_coupon: null, //选择券的控制属性
  89 + is_shipping_code: "",//插入用户默认地址
  90 + wu_arr_txt: "", //要更新的物流的字段
  91 +
  92 + sales_rules: 1, //默认是显示线上库存
  93 + isget_by_quan: {}, //是否调用了接口获取包邮券
  94 + get_by_quan_list: null, //立即购买的
  95 + get_by_quan_list_cart: {}, //购物车的
  96 + by_quan_list_cart: null, //点击选择的包邮列表
  97 +
  98 + //如果是全场包邮了,或者是全场不包邮了,就不要选包邮券
  99 + is_no_by: {},
  100 + is_by: {},
  101 + is_quan_by: {},
  102 + //--购买赠送的商品--
  103 + buy_now_gift_goods: null,
  104 + //--订单优惠--
  105 + order_prom: {},
  106 + //-- 购物车优惠活动 --
  107 + prom_goods_map: {},
  108 + //-- order_prom_list --
  109 + order_prom_list_cart: null,
  110 +
  111 + ispt_goods: 0, //是否平摊至单品,0要平摊 1不平摊
  112 +
  113 + rank_switch: 0, //是不是开同等级卡
  114 + show_card: null, //显示的等级卡
  115 + card_name: '', //显示的卡的名称
  116 + card_cut_price: null,//减价多少钱
  117 +
  118 + show_submit: 0, //提交按钮变正常显示
  119 + is_get_offline: 1,
  120 +
  121 + tabs: ['门店自提', '快递邮寄'],
  122 + currentTabIndex: 1,
  123 + },
  124 + onLoad: function (t) {
  125 + // wx.setNavigationBarTitle({title: "填写订单",})
  126 + var th = this;
  127 + this.setData({is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,});
  128 + th.data.param = t;
  129 + //清理一下,确保最新的系统配置
  130 + getApp().globalData.config2 = null;
  131 + //清空is_pick_up
  132 + getApp().request.put("/api/weshop/useraddress/updatePickUp", {
  133 + data: {user_id: getApp().globalData.user_id, is_pickup: 0},
  134 + success: function (s) {
  135 + }
  136 + });
  137 +
  138 +
  139 + },
  140 + onUnload: function () {
  141 + this.setData({isclose: 1})
  142 + },
  143 + onHide: function () {
  144 + this.setData({
  145 + isget_by_quan: {},
  146 + is_no_by: {},
  147 + is_by: {}
  148 + })
  149 + },
  150 +
  151 + //----------子页返回父页触发----------
  152 + onShow: function () {
  153 + var th = this;
  154 + th.setData({show_submit: 0}); //让提交先掩藏
  155 + th.data.g_cart_q_time = null;
  156 +
  157 + if (th.data.isclose == 0) {
  158 + wx.navigateTo({
  159 + url: "/pages/index/index/index"
  160 + })
  161 +
  162 + } else {
  163 + this.getuser_addr(function (ie) {
  164 +
  165 + console.log("getuser_addr")
  166 + console.log(ie)
  167 +
  168 + //地址切换要把包邮券清空
  169 + if (!th.data.user_addr || !ie || th.data.user_addr.address_id != ie.address_id) {
  170 + var using_quan = th.data.using_quan;
  171 + for (var i in using_quan) {
  172 + var item = using_quan[i];
  173 + if (item.isby == 1) {
  174 + var ob = {}, txt = "using_quan[" + i + "]";
  175 + ob[txt] = {};
  176 + th.setData(ob);
  177 + }
  178 + }
  179 + th.data.isget_by_quan = {};
  180 + }
  181 +
  182 +
  183 + th.data.prom_goods_map = {};
  184 + th.data.is_summit_ing = 0;
  185 + //更换地址回来要重新调用计算价钱的接口
  186 + if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
  187 + th.setData({user_addr: ie});
  188 + if (th.data.is_b_now == 1) {
  189 + if (th.data.bn_goods) {
  190 + th.setData({add_back: 1});
  191 + //th.calculatePrice2();
  192 + }
  193 + } else {
  194 + if (th.data.cartlist) {
  195 + th.setData({add_back: 1});
  196 + //th.calculatePrice();
  197 + }
  198 + }
  199 + } else {
  200 + th.setData({user_addr: ie});
  201 + }
  202 + var going = 0;
  203 +
  204 +
  205 + //使用计时器,避免空现象
  206 + /*---
  207 + var jishi= setInterval(function () {
  208 + if (th.data.is_b_now == 1 && going==0) {
  209 + if(th.data.bn_goods) {
  210 + th.calculatePrice2();going=1;clearInterval(jishi);
  211 + }
  212 + }else if(going==0) {
  213 + if (th.data.cartlist){
  214 + th.calculatePrice();going = 1; clearInterval(jishi);
  215 + }
  216 + }
  217 + },500)--*/
  218 +
  219 + });
  220 + var is_card_back = getApp().globalData.is_card_back;
  221 + //--更新默认地址--,看一下是不是跳到地址页面,同时也不是购买等级卡返回的,这里很重要,否则会重新更新收货物流公司
  222 + if (!getApp().globalData.is_cart_old && !is_card_back && !getApp().globalData.plus_buy_back) {
  223 + this.update_code();
  224 + } else {
  225 + getApp().globalData.is_cart_old = 0;
  226 + getApp().globalData.plus_buy_back = 0;
  227 + }
  228 + }
  229 +
  230 + //先获取是否有关闭使用优惠券
  231 + getApp().getConfig2(function (ee) {
  232 + var json_d = JSON.parse(ee.switch_list);
  233 + th.data.json_d = json_d;
  234 + th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值
  235 + var is_default_logistics = json_d.is_default_logistics;
  236 +
  237 + th.setData({
  238 + is_close_quan: json_d.is_close_quan,
  239 + sales_rules: ee.sales_rules,
  240 + rank_switch: json_d.rank_switch,
  241 + is_default_logistics: is_default_logistics
  242 + });
  243 +
  244 + var rank_switch = json_d.rank_switch;
  245 + var max_price = -1;
  246 + var show_card = null;
  247 + var name = "";
  248 + //如果有开等级卡的时候,
  249 + //因为都是调接口,要返回在计算
  250 + if (rank_switch == 2) {
  251 + //-- 获取所有的等级卡, --
  252 + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid,
  253 + {}).then(res => {
  254 + if (res.data.code == 0) {
  255 + var plusCard = res.data.data;
  256 + //-- 循环判断,拿到最贵的那张卡 --
  257 + for (var ih in plusCard) {
  258 + if (plusCard[ih].IsStopBuy == true) {
  259 + continue;
  260 + }
  261 + if (max_price < 0) {
  262 + max_price = plusCard[ih].CardFee;
  263 + name = 'card' + plusCard[ih]['CorrPrice'];
  264 + show_card = plusCard[ih];
  265 + } else {
  266 + if (max_price < plusCard[ih].CardFee) {
  267 + max_price = plusCard[ih].CardFee;
  268 + name = 'card' + plusCard[ih]['CorrPrice'];
  269 + show_card = plusCard[ih];
  270 + }
  271 + }
  272 + }
  273 +
  274 + if (show_card) {
  275 + name = name.toLowerCase();
  276 + th.setData({card_name: name, show_card: show_card})
  277 + }
  278 + }
  279 + //-----先获取物流,再获取用户信息,再展示页面-----
  280 + th.get_wuliu(th.get_info(th.show_page));
  281 + })
  282 + } else {
  283 + //-----先获取物流,再获取用户信息,再展示页面-----
  284 + th.get_wuliu(th.get_info(th.show_page));
  285 + }
  286 +
  287 + }, 1);
  288 +
  289 + //值在这里换
  290 + getApp().globalData.plus_buy_back = 0;
  291 + },
  292 +
  293 + //-------------------获取物流---------------
  294 + get_wuliu(func) {
  295 + var th = this;
  296 + to.getwuliu(function (e) {
  297 + //系统是是否开启了默认的物流
  298 + if (th.data.is_default_logistics) {
  299 + //如果第一个不是开启默认,说明要让用户自己选
  300 + if (!e[0].is_default) {
  301 + th.setData({is_default_logistics: 0});
  302 + }
  303 + }
  304 + th.setData({wu_arr: e})
  305 + typeof func == "function" && func();
  306 + })
  307 + },
  308 + //------获取会员信息-----先获取用户信息,在进行下一步---
  309 + get_info: function (func) {
  310 + var user_id = t.globalData.user_id;
  311 + to.auth.get_u(func);
  312 + },
  313 +
  314 + //------获取会员收货地址-----
  315 + getuser_addr: function (func) {
  316 + var th = this;
  317 + a.get("/api/weshop/useraddress/page", {
  318 + data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()},
  319 + success: function (su) {
  320 + /*---
  321 + var user_addr=[
  322 + { 'address_id': 882, 'user_id': 2661, 'consignee': '测试测试测', 'province': 3102, 'city': 3431, 'district': 3466,
  323 + 'address': 'ed', 'more_address': '山西-长治市-襄垣县-虎(音si)亭镇', 'mobile': 13012345678,'is_default':1},
  324 + ];---*/
  325 + var item = null;
  326 + if (su.data.code == 0 && su.data.data && su.data.data.pageData) {
  327 + var user_addr = su.data.data.pageData;
  328 + var def_item = null;
  329 + for (var i = 0; i < user_addr.length; i++) {
  330 + if (user_addr[i]['is_default'] == 1) {
  331 + def_item = user_addr[i];
  332 + }
  333 + if (user_addr[i]['is_pickup'] == 1) {
  334 + item = user_addr[i];
  335 + }
  336 + }
  337 +
  338 + if (item == null) item = def_item;
  339 + if (item == null) item = user_addr[0];
  340 + }
  341 +
  342 + if (item == undefined) item = null;
  343 + if (!item) th.setData({user_addr: null}); //地址为空的时候,要清空,因为返回的时候,有缓存
  344 +
  345 + func(item);
  346 + }
  347 + });
  348 + },
  349 +
  350 + //----------------展示页面,是再获取用户信息之后--------------
  351 + show_page: function () {
  352 + var th = this, ta = this.data.param;
  353 + //th.setData({ userinfo: getApp().globalData.userInfo,}); //这个余额被缓存了
  354 +
  355 + //会员的信息,要获取最新
  356 + var user = getApp().globalData.userInfo;
  357 + getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, {
  358 + data: {r: Math.random()},
  359 + success: function (e) {
  360 + getApp().globalData.userInfo = e.data.data;
  361 + th.setData({userinfo: e.data.data});
  362 +
  363 + //选获取地址
  364 + th.getuser_addr(function (addr) {
  365 + th.setData({user_addr: addr});
  366 + //--------------------------立即购买------------------
  367 + if (ta.is_bnow == 1) {
  368 + //读取门店
  369 + to.get_allsto(function (e) {
  370 + th.setData({allsto: e});
  371 + //获取立即购买的商品信息
  372 + th.get_buy_goods(ta.goods_id);
  373 + });
  374 + } else {
  375 + //------------------------购物车结算----------------------
  376 + //读取门店
  377 + to.get_allsto(function (e) {
  378 + th.setData({allsto: e});
  379 + //-------获取购物车已经选择的商品--------
  380 + th.get_cart();
  381 + })
  382 + }
  383 + });
  384 +
  385 + //获取提现金额
  386 + getApp().request.get("/api/weshop/withdrawals/summoney", {
  387 + data: {user_id: to.globalData.user_id, store_id: oo.stoid, status: 0},
  388 + success: function (su) {
  389 + if (su.data.code == 0) {
  390 + var yuer = parseFloat(th.data.userinfo.user_money -
  391 + (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2);
  392 + th.setData({txmon: su.data.data.summoney, yuer: yuer});
  393 + }
  394 + }
  395 + });
  396 +
  397 + },
  398 + });
  399 +
  400 + },
  401 +
  402 +
  403 + //-----真的获取购物车,入口--------
  404 + get_cart: function () {
  405 + var th = this, app = getApp();
  406 + a.get("/api/weshop/cart/list", {
  407 + data: {
  408 + user_id: to.globalData.user_id, selected: 1, state: 0,
  409 + store_id: oo.stoid, pageSize: 600
  410 + },
  411 + success: async function (su) {
  412 + //按门店分类的数组
  413 + var arr = new Array();
  414 + var carr = su.data.data.pageData;
  415 + th.data.cartlist_y = carr; //存储原始购物车列表
  416 +
  417 + //---是不是购买等级卡成功的返回---等级卡显示的判断---
  418 + var is_card_back = getApp().globalData.is_card_back;
  419 +
  420 + for (var i = 0; i < carr.length; i++) {
  421 + var item1 = carr[i];
  422 + //把已经购买了多少见的内容填入
  423 +
  424 + var goodsbuynum=0,promgoodsbuynum=0;
  425 + //--要获得商品,该用户买了多少件,同步应用--
  426 + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  427 + data: {
  428 + store_id: os.stoid,
  429 + user_id: getApp().globalData.user_id,
  430 + goods_id: item1.goods_id,
  431 + prom_type: item1.prom_type,
  432 + prom_id: item1.prom_id
  433 + },
  434 + }).then(res => {
  435 + var buy_num_data = res.data.data;
  436 + if (buy_num_data.promgoodsbuynum) {
  437 + promgoodsbuynum = buy_num_data.promgoodsbuynum;
  438 + }
  439 + goodsbuynum = buy_num_data.goodsbuynum;
  440 + })
  441 + //如果有购买活动
  442 + item1.promgoodsbuynum=promgoodsbuynum;
  443 +
  444 + //要把优惠活动加入,prom_goods_map中,赠品不要运算
  445 + if (item1.prom_type == 3 && item1.is_gift != 1) {
  446 + await th.add_prom_goods_map(item1);
  447 + }
  448 +
  449 + //要把组合购的东西拿出来算一下
  450 + if (item1.prom_type == 7) {
  451 + var isok = 1;
  452 + //如果有组合购
  453 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item1.prom_id+'/'+getApp().globalData.userInfo.user_id;
  454 + await getApp().request.promiseGet(url, {}).then(res => {
  455 + if (res.data.code == 0 && res.data.data) {
  456 + //如果活动已经结束
  457 + if (res.data.data.is_end == 1) {
  458 + isok = 0;
  459 + }
  460 + if (ut.gettimestamp() > res.data.data.end_time) {
  461 + isok = 0;
  462 + }
  463 + } else {
  464 + //未找到商品的活动
  465 + isok = 0;
  466 + }
  467 + item1.act = res.data.data;
  468 + })
  469 +
  470 + if (!isok) {
  471 + getApp().my_warnning("组合购的活动已经过期", 0, th);
  472 + return false;
  473 + }
  474 +
  475 + }
  476 + }
  477 +
  478 + //在分组的时候,就不要再调用接口,await
  479 + for (var i = 0; i < carr.length; i++) {
  480 + var item = carr[i];
  481 +
  482 + //-- 如果是等级会员注册返回 --
  483 + if (is_card_back) {
  484 + th.data.card_name = th.data.userinfo.card_field;
  485 + //如果是秒杀的返回,就要把活动弄回0
  486 + if (item['prom_type'] == 1) {
  487 + item['prom_type'] = 0;
  488 + item['prom_id'] = 0;
  489 + }
  490 + // 拼团,搭配购不计算,赠品也不计算
  491 + if (item['prom_type'] != 5 && item['prom_type'] != 6 && !item.is_gift && !item['is_collocation'] && item.goods_price > item[th.data.card_name]) {
  492 + item.goods_price = item[th.data.card_name];
  493 + carr[i].goods_price = item[th.data.card_name];
  494 +
  495 + }
  496 + } else {
  497 + // 拼团,搭配购不计算,赠品也不计算,同时会员还未购买等级会员
  498 + if (item[th.data.card_name] > 0 && item['prom_type'] != 5 && item['prom_type'] != 6 && !th.data.userinfo.card_field
  499 + && !item.is_gift && !item['is_collocation'] && item.goods_price > item[th.data.card_name]) {
  500 + item.cut_price1 = item.goods_price - item[th.data.card_name];
  501 + carr[i].cut_price1 = (item.goods_price - item[th.data.card_name]) * item.goods_num;
  502 + }
  503 +
  504 + }
  505 +
  506 + item.original_img = oo.imghost + item.original_img;
  507 +
  508 + var car_item=item;
  509 + /*----接口要弄出来的,先顶着-----*/
  510 + var pcid = car_item.pick_id;
  511 + var find = 0;
  512 + //----如果有就加进去,没有就新增一个----
  513 + //-----------循环查找门店-------------
  514 + if (arr.length > 0) {
  515 + for (var j = 0; j < arr.length; j++) {
  516 + if (arr[j].pickup_id == pcid) {
  517 + //if(item.is_gift!=1){
  518 + //确定配送方式
  519 + if (arr[j].distr_t == 0) {
  520 + arr[j].distr_t = car_item.distr_type;
  521 + }
  522 + var e_t = 0
  523 + switch (arr[j].distr_t) {
  524 + case 0:
  525 + e_t = 1;
  526 + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) e_t = 0;
  527 + break;
  528 + case 1:
  529 + e_t = 1;
  530 + break;
  531 + case 2:
  532 + e_t = 0;
  533 + break;
  534 + }
  535 + arr[j].exp_type = e_t;
  536 + if (e_t == 0) th.setData({is_all_zt: 0});
  537 + //}
  538 +
  539 + //-- 把等级卡会优惠多少钱装进去 --
  540 + if (car_item.cut_price1) arr[j].card_cut_price += car_item.cut_price1;
  541 +
  542 + arr[j].goods.push(car_item);
  543 + find = 1;
  544 + break;
  545 + }
  546 + }
  547 + }
  548 + //------如果没有找到-----
  549 + if (find == 0) {
  550 + var pikname = '', sto = null;
  551 + //----找到门店名称-----
  552 + for (var k = 0; k < th.data.allsto.length; k++) {
  553 + if (pcid == th.data.allsto[k].pickup_id) {
  554 + pikname = th.data.allsto[k].pickup_name;
  555 + sto = th.data.allsto[k];
  556 + break;
  557 + }
  558 + }
  559 + var e_t = 0, dis_t = 0;//物流方式,配送方式
  560 + if (item.distr_type == 0) {
  561 + dis_t = sto.distr_type;
  562 + } else {
  563 + dis_t = item.distr_type;
  564 + }
  565 + switch (dis_t) {
  566 + case 0:
  567 + e_t = 1;
  568 + //-- 系统后台有设置要默认的 --
  569 + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) e_t = 0;
  570 + break;
  571 + case 1:
  572 + e_t = 1;
  573 + break;
  574 + case 2:
  575 + e_t = 0;
  576 + break;
  577 + }
  578 + //如果是物流的话,全部自提的控制要弄成0
  579 + if (e_t == 0) th.setData({is_all_zt: 0});
  580 +
  581 + var narr = new Array();
  582 + narr.push(car_item);
  583 +
  584 + //-----------拼装购物车结算的数组,如果有默认物流时要用默认物流编号,计算默认的物流,不管是不是自提都算一下-----------------
  585 + var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
  586 + if (def_exp_code) {
  587 + for (var k = 0; k < th.data.wu_arr.length; k++) {
  588 + var item = th.data.wu_arr[k];
  589 + if (def_exp_code == item.code) {
  590 + m_wind = k;
  591 + }
  592 + }
  593 + }
  594 +
  595 + var ie = {
  596 + pickup_id: pcid,
  597 + pname: pikname,
  598 + goods: narr,
  599 + wind: m_wind,
  600 + distr_t: dis_t,
  601 + card_cut_price: 0,
  602 + exp_type: e_t,
  603 + goods_price: 0,
  604 + shipping_price: 0,
  605 + user_money: 0,
  606 + total_amount: 0,
  607 + order_amount: 0,
  608 + user_note: 0
  609 + };
  610 +
  611 + //-- 把等级卡会优惠多少钱装进去 --
  612 + if (car_item.cut_price1) ie.card_cut_price += car_item.cut_price1;
  613 + arr.push(ie);
  614 +
  615 + }
  616 + }
  617 + //-- 如果是回退回来的情况 --
  618 + if (th.data.cartlist && th.data.cartlist.length > 0) {
  619 + for (var kj in th.data.cartlist) {
  620 + for (var ih in arr) {
  621 + var ie = arr[ih];
  622 + if (ie.pickup_id == th.data.cartlist[kj].pickup_id) {
  623 + ie.exp_type = parseInt(th.data.cartlist[kj].exp_type);
  624 + ie.wind = parseInt(th.data.cartlist[kj].wind);
  625 + break;
  626 + }
  627 + }
  628 + }
  629 + }
  630 +
  631 + //-- 循环计算一下线下取价 --
  632 + for (var k = 0; k < arr.length; k++) {
  633 + var c_item = arr[k];
  634 + var item = arr[k].goods;
  635 + var offline_price = 0;
  636 + var offline_num = 0;
  637 + for (var c = 0; c < item.length; c++) {
  638 + if(th.data.sales_rules!=2){
  639 + item[c].offline_price=0;
  640 + }
  641 + //-- 如果这个商品是线下取价的时候 --
  642 + if (item[c].offline_price > 0 && item[c].prom_type != 7 ) {
  643 + offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num;
  644 + offline_num += item[c].goods_num;
  645 + }
  646 + }
  647 + if (offline_price > 0) {
  648 + c_item.offline_price = offline_price;
  649 + c_item.offline_num = offline_num;
  650 + c_item.is_offline = 1;
  651 + }
  652 + }
  653 +
  654 + //每一个门店内的组合购要进行拆分,
  655 + //还得把组合商品的多余商品的线下价格算一算
  656 + for (let var1 in arr) {
  657 + var u_item = arr[var1];
  658 + //把组合购进行分组
  659 + var obj = zh_calc.find_split(u_item);
  660 + if (!obj) continue;
  661 + //存储不同活动的商品列表
  662 + u_item.zh_prom_goods = {};
  663 + for (let var1 in obj) {
  664 + var h_item = obj[var1];
  665 + var gdlist = null;
  666 + var url1 = "/api/weshop/prom/zhbuyGoods/page";
  667 + var req_data = {
  668 + page: 1,
  669 + pageSize: 2000,
  670 + store_id: os.stoid,
  671 + zh_id: h_item.prom_id,
  672 + }
  673 + await getApp().request.promiseGet(url1, {
  674 + data: req_data
  675 + }).then(res => {
  676 + if (ut.ajax_ok(res)) {
  677 + gdlist = res.data.data.pageData;
  678 + }
  679 + })
  680 + //获取活动需要的商品列表
  681 + u_item.zh_prom_goods[h_item.prom_id] = {gdlist: gdlist, act: h_item.act};
  682 + }
  683 + zh_calc.fir_set_arr(u_item, th);
  684 + }
  685 + //深拷贝
  686 + th.data.old_cartlist = JSON.parse(JSON.stringify(arr));
  687 + th.setData({
  688 + cartlist: arr,
  689 + });
  690 + //--- 获取一下看有没有优惠券 ----
  691 + setTimeout(function () {
  692 + var frozenQuan = null;
  693 + var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
  694 + app.request.promiseGet(url0, {1: 1}).then(res => {
  695 + if (res.data.code == 0) {
  696 + frozenQuan = res.data.data;
  697 + th.data.frozenQuan = frozenQuan;
  698 + }
  699 + th.calculatePrice();
  700 + th.get_cart_quan();
  701 + })
  702 +
  703 + }, 500)
  704 +
  705 + }
  706 + });
  707 + },
  708 +
  709 + //-----获取立即购买的商品信息,入口----
  710 + get_buy_goods: function (e) {
  711 + var th = this;
  712 + var gg = to.get_b_now();
  713 + //--------如果goods_id一样,就是要立即购买-----
  714 + if (e == gg.goods_id) {
  715 + a.get("/api/weshop/goods/get/" + oo.stoid + "/" + e, {
  716 + success: async function (t) {
  717 + var gd = t.data.data;
  718 + if (!gd) return false;
  719 +
  720 + t.data.data.original_img = oo.imghost + t.data.data.original_img;
  721 + t.data.data['buynum'] = gg.goods_num;
  722 + var distr_t = 0, et = 0
  723 + if (t.data.data.distr_type == 0) {
  724 + distr_t = gg.pick_dis;
  725 + } else {
  726 + distr_t = t.data.data.distr_type;
  727 + }
  728 +
  729 + switch (distr_t) {
  730 + case 0:
  731 + et = 1;
  732 + //-- 系统后台有设置要默认的 --
  733 + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0;
  734 + break;
  735 + case 1:
  736 + et = 1;
  737 + break;
  738 + case 2:
  739 + et = 0;
  740 + break;
  741 + }
  742 +
  743 +
  744 + var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
  745 + if (et == 0 && def_exp_code) {
  746 + for (var k = 0; k < th.data.wu_arr.length; k++) {
  747 + var item = th.data.wu_arr[k];
  748 + if (def_exp_code == item.code) {
  749 + m_wind = k;
  750 + }
  751 + }
  752 + }
  753 +
  754 + if (th.data.bn_goods) {
  755 + et = th.data.bn_exp_type;
  756 + m_wind = th.data.index;
  757 + }
  758 +
  759 + //---是不是购买等级卡成功的返回---等级卡显示的判断---
  760 + var is_card_back = getApp().globalData.is_card_back;
  761 + if (is_card_back) {
  762 + th.data.card_name = th.data.userinfo.card_field;
  763 + gg.goods_price = gd[th.data.card_name];
  764 + getApp().globalData.is_card_back = 0;
  765 + th.setData({card_cut_price: 0});
  766 + //如果是秒杀的返回
  767 + if (gd.prom_type == 1) gd.prom_type = 0;
  768 + } else {
  769 + //--- 商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格
  770 + //-- 搭配购的商品也可以单独购买,所以此时搭配购的商品要进行计算优惠 --
  771 + 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) {
  772 + var cut_p = (gg.goods_price - gd[th.data.card_name]) * gg.goods_num;
  773 + th.setData({card_cut_price: cut_p});
  774 + }
  775 + }
  776 +
  777 + switch (gd.prom_type) {
  778 + case 0:
  779 + case 2:
  780 + case 3:
  781 + case 4:
  782 + case 5:
  783 + case 6:
  784 + case 7:
  785 + //--此时开始计算商品的使用券相关,如果有等级价还要计算和等级价相关的,
  786 + // 如果有优惠促销,还要把促销的部分计算在内,因为促销还有不能使用优惠券--
  787 + t.data.data.shop_price = gg.goods_price;
  788 + t.data.data.goods_price = gg.goods_price;
  789 + t.data.data.goods_num = gg.goods_num;
  790 + th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num;
  791 + th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + "";
  792 + th.data.check_quan_ware_list = t.data.data.erpwareid + "";
  793 +
  794 + //-- 如果有线下取价的时候 --
  795 + if (gg.offline_price) {
  796 + t.data.data.offline_price = gg.offline_price;
  797 + t.data.data.pricing_type = gg.pricing_type;
  798 + t.data.data.is_offline = 1;
  799 +
  800 + th.data.ckeck_quan_price = t.data.data.offline_price * gg.goods_num;
  801 + th.data.check_quan_price_list = t.data.data.offline_price * gg.goods_num + "";
  802 + th.data.check_quan_ware_list = t.data.data.erpwareid + "";
  803 + }
  804 +
  805 + t.data.data.prom_id = 0;
  806 + t.data.data.prom_type = 0;
  807 +
  808 + //如果立即购买那边过来,就要读取接口,查看活动的优惠内容
  809 + if (gg.prom_type == 3) {
  810 + t.data.data.prom_id = gg.prom_id;
  811 + t.data.data.prom_type = 3;
  812 + //如果是优惠活动,就要调用活动,计算价格
  813 + th.buy_now_prom_goods(gg.prom_id, t.data.data, function (data) {
  814 + //判断一下购买商品的数量是不是超过
  815 + if (data.gift_goods_id) {
  816 + var num = 1;
  817 + if (data.is_bz == 1) {
  818 + num = data.bs;
  819 + if (num > data.gift_limit_num) num = 0;
  820 + }
  821 + //如果赠品数量超出礼品库存,就取消
  822 + if (num > data['gift_storecount']) num = 0;
  823 + if (num > 0) {
  824 + var ob = {};
  825 + ob.is_gift = 1;
  826 + ob.prom_id = data.prom_id;
  827 + ob.goods_id = data.gift_goods_id;
  828 + ob.goods_name = data.gift_goods_name;
  829 + ob.goods_color = data.gift_goods_color;
  830 + ob.goods_spec = data.gift_goods_spec;
  831 + ob.original_img = os.imghost + data.gift_original_img;
  832 + ob.market_price = data.gift_market_price;
  833 + ob.gift_id = data.gift_id;
  834 + ob.shop_price = 0;
  835 + ob.buynum = num;
  836 + ob.weight = data.gift_weight; //商品的重量
  837 + ob.exp_sum_type = data.gift_exp_sum_type; //商品的物流计算方式
  838 + ob.uniform_exp_sum = data.gift_uniform_exp_sum //统一运费的金额
  839 +
  840 + th.setData({buy_now_gift_goods: ob});
  841 + }
  842 + }
  843 +
  844 + th.setData({
  845 + bn_goods: data, bn_pickname: gg.pick_name, index: m_wind,
  846 + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et
  847 + });
  848 +
  849 + //计算价格
  850 + th.calculatePrice2();
  851 + //获取优惠券
  852 + th.get_buy_now_quan();
  853 +
  854 + })
  855 + } else {
  856 + //--看是不是搭配促销--
  857 + if (gg.prom_type == 5) {
  858 + t.data.data.prom_id = gg.prom_id;
  859 + t.data.data.prom_type = 5;
  860 + if (gg.room_id) {
  861 + t.data.data.room_id = gg.room_id;
  862 + }
  863 + //--主商品要有导购id和导购类型--
  864 + if (gg.guide_id) {
  865 + t.data.data.guide_id = gg.guide_id;
  866 + t.data.data.guide_type = gg.guide_type;
  867 + }
  868 + th.setData({collocation_goods: gg.collocation_goods});
  869 +
  870 + var cart_arr = new Array();
  871 + //var narr=gg.collocation_goods;
  872 + //修改成深拷贝,确保返回是数据正确
  873 + var narr = JSON.parse(JSON.stringify(gg.collocation_goods));
  874 +
  875 + narr.push(t.data.data);
  876 +
  877 + //-- 搭配促销的门店配送方式的修复 --
  878 + et = 1;
  879 + distr_t = 0;
  880 + for (var hi in narr) {
  881 + var dis_t = narr[hi].distr_type;
  882 + if (dis_t == 2) {
  883 + th.setData({is_all_zt: 0});
  884 + et = 0;
  885 + }
  886 + if (dis_t > 0) {
  887 + distr_t = dis_t;
  888 + }
  889 + }
  890 +
  891 + //自选的时候,系统配置了默认的配送方式是物流的时候
  892 + if (distr_t == 0 && th.data.json_d.pickupway && th.data.json_d.pickupway == 1) {
  893 + et = 0;
  894 + }
  895 +
  896 +
  897 + var ie = {
  898 + pickup_id: gg.pick_id,
  899 + pname: gg.pick_name,
  900 + goods: narr,
  901 + exp_type: et,
  902 + wind: m_wind,
  903 + distr_t: distr_t,
  904 + bn_t_exp_t: distr_t,
  905 + goods_price: 0,
  906 + shipping_price: 0,
  907 + user_money: 0,
  908 + total_amount: 0,
  909 + order_amount: 0,
  910 + user_note: 0
  911 + };
  912 + cart_arr.push(ie);
  913 + th.data.old_cartlist = cart_arr;
  914 + }
  915 + th.setData({
  916 + bn_goods: t.data.data, bn_pickname: gg.pick_name, index: m_wind,
  917 + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et
  918 + });
  919 +
  920 +
  921 + //--搭配促销也是按照购物车的方式来计算优惠券--
  922 + if (gg.prom_type == 5) {
  923 + var frozenQuan = null;
  924 + var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
  925 + app.request.promiseGet(url0, {1: 1}).then(res => {
  926 + if (res.data.code == 0) {
  927 + frozenQuan = res.data.data;
  928 + th.data.frozenQuan = frozenQuan;
  929 + }
  930 + //计算价格
  931 + th.calculatePrice2();
  932 + th.get_cart_quan();
  933 + });
  934 + } else {
  935 + //计算价格
  936 + th.calculatePrice2();
  937 + //获取优惠券,
  938 + th.get_buy_now_quan();
  939 + }
  940 + }
  941 +
  942 + break;
  943 + case 1: //---秒杀-----
  944 + var quanlist = null;
  945 + getApp().request.get("/api/weshop/activitylist/getSJGoodsPrice/" + gd.store_id
  946 + + "/" + gd.goods_id + "/1/" + gd.prom_id, {
  947 + success: async function (tt) {
  948 + if (tt.data.code == 0) {
  949 + t.data.data.shop_price = tt.data.data.prom_price;
  950 + } else {
  951 + t.data.data.prom_id = 0;
  952 + t.data.data.prom_type = 0;
  953 +
  954 + th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num;
  955 + th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + "";
  956 + th.data.check_quan_ware_list = t.data.data.erpwareid + "";
  957 + }
  958 +
  959 + th.setData({
  960 + bn_goods: t.data.data,
  961 + bn_pickname: gg.pick_name,
  962 + bn_exp_type: et,
  963 + index: m_wind,
  964 + bn_pick: gg.pick_id,
  965 + bn_t_exp_t: distr_t,
  966 + bn_exp_type: et
  967 + });
  968 +
  969 + //计算价格
  970 + th.calculatePrice2();
  971 + //获取优惠券,如果有券的钱,就调用
  972 + if(th.data.ckeck_quan_price>0) th.get_buy_now_quan();
  973 + }
  974 + });
  975 +
  976 + break;
  977 + }
  978 + },
  979 + });
  980 + }
  981 + },
  982 +
  983 + //---------------检查是否有收货地址-------------------
  984 + checkAddressList: function () {
  985 + var t = this;
  986 + return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({
  987 + title: "请先填写或选择收货地址~",
  988 + success: function (a) {
  989 + a.confirm ? t.enterAddressPage() : wx.navigateBack();
  990 + },
  991 + fail: function () {
  992 + wx.navigateBack();
  993 + }
  994 + }), !1);
  995 + },
  996 + showInvoice: function () {
  997 + this.setData({
  998 + invoiceToggle: !this.data.invoiceToggle
  999 + });
  1000 + },
  1001 + keyUpChangePay1: function (t) {
  1002 + this.setData({
  1003 + payWithUserMoney: !(t.detail.value.length > 0)
  1004 + });
  1005 + },
  1006 + keyUpChangePay2: function (t) {
  1007 + this.setData({
  1008 + payWithPoints: !(t.detail.value.length > 0)
  1009 + });
  1010 + },
  1011 + keyUpChangeNum: function (t) {
  1012 + this.setData({
  1013 + maxWord: t.detail.value.length
  1014 + });
  1015 + },
  1016 +
  1017 + calc_per: async function (c_arr) {
  1018 + var th = this;
  1019 + //-- 循环处理 --
  1020 + for (var i in c_arr) {
  1021 + var cart_item = c_arr[i]; //就是每一单的意思
  1022 + var pickid = cart_item.pickup_id;
  1023 + var ord_goods = c_arr[i].goods; //就是每一单的从表的意思
  1024 + var o_price = 0, q_conditin = 0;
  1025 + //--------循环计算总价-----------
  1026 + for (var j = 0; j < ord_goods.length; j++) {
  1027 + o_price += ord_goods[j].goods_price * ord_goods[j].goods_num;
  1028 + }
  1029 +
  1030 + //---如果该门店的相关活动,就要算一下减价--
  1031 + if (th.data.prom_goods_map[pickid]) {
  1032 + var ob = th.data.prom_goods_map[pickid];
  1033 + for (var ii in ob) {
  1034 + var item_map = ob[ii];
  1035 + if (item_map.bs == undefined || item_map.bs == null) {
  1036 + //等待,获取一下优惠活动的信息
  1037 + await getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
  1038 + data: {
  1039 + price: item_map.price, prom_id: item_map.prom_id,
  1040 + goods_num: item_map.goods_num, user_id: getApp().globalData.user_id,
  1041 + is_bz: item_map.is_bz
  1042 + }
  1043 + }).then(res => {
  1044 + if (res.data.code == 0 && res.data.data.condition) {
  1045 + var get_data = res.data.data;
  1046 + item_map.is_bz = get_data.is_bz; //是不是倍增
  1047 + item_map.bs = get_data.bs; //是不是倍数
  1048 + item_map.is_past = get_data.is_past; //是不是包邮
  1049 + item_map.prom_price = get_data.price >= 0 ? get_data.price : item_map.price;
  1050 + item_map.s_intValue = get_data.intValue;
  1051 + item_map.s_coupon_id = get_data.coupon_id;
  1052 + item_map.s_coupon_num = get_data.coupon_num;
  1053 + if (get_data.gift_id && get_data.goodsinfo) {
  1054 + item_map.gift_id = get_data.gift_id;
  1055 + item_map.gift_goods_id = get_data.goods_id;
  1056 + item_map.gift_goods_name = get_data.goods_name;
  1057 + item_map.gift_goods_color = get_data.goodsinfo.goods_color ? get_data.goodsinfo.goods_color : '';
  1058 + item_map.gift_goods_spec = get_data.goodsinfo.goods_spec ? get_data.goodsinfo.goods_spec : '';
  1059 + item_map.gift_original_img = get_data.goodsinfo.original_img;
  1060 + item_map.gift_limit_num = get_data.limit_num;
  1061 + item_map.gift_storecount = get_data.gift_storecount;
  1062 + item_map.gift_weight = get_data.goodsinfo.weight;
  1063 + item_map.gift_exp_sum_type = get_data.goodsinfo.exp_sum_type;
  1064 + item_map.uniform_exp_sum = get_data.goodsinfo.uniform_exp_sum;
  1065 +
  1066 + }
  1067 + item_map.s_libao = get_data.libao;
  1068 + item_map.s_lb_num = get_data.lb_num;
  1069 + }
  1070 + })
  1071 + }
  1072 +
  1073 + //有活动,且优惠活动并没有限制使用优惠券,且有减价
  1074 + //--看有没有减价--
  1075 + //if(item_map.prom_price>=0 && item_map.price-item_map.prom_price){
  1076 + if (item_map.price - item_map.prom_price && item_map.prom_price !== null) {
  1077 + if (cart_item.prom_pt_json) {
  1078 + cart_item.prom_pt_json.push({
  1079 + "prom_id": item_map.prom_id,
  1080 + "dis": (item_map.price - item_map.prom_price).toFixed(2),
  1081 + "ispt": 0
  1082 + })
  1083 + } else {
  1084 + cart_item.prom_pt_json = [{
  1085 + "prom_id": item_map.prom_id,
  1086 + "dis": (item_map.price - item_map.prom_price).toFixed(2),
  1087 + "ispt": 0
  1088 + }];
  1089 + }
  1090 +
  1091 + //-- 如果系统要平摊到单品 --
  1092 +
  1093 + var pt_data = {
  1094 + 'prom_id': item_map.prom_id,
  1095 + 'dis': parseFloat((item_map.price - item_map.prom_price).toFixed(2)),
  1096 + 'goods': item_map.goods
  1097 + }
  1098 +
  1099 + var pt_res = null;
  1100 + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
  1101 + is_json: 1,
  1102 + data: pt_data
  1103 + }).then(res => {
  1104 + if (res.data.code == 0) {
  1105 + pt_res = res.data.data;
  1106 + }
  1107 + })
  1108 + if (pt_res) {
  1109 + for (var io in item_map.goods) {
  1110 + //平摊赋值
  1111 + item_map.goods[io].account_fir = th.arr_get_goods(item_map.goods[io].goods_id, pt_res).fisrt_account;
  1112 + item_map.goods[io].account_yu_fir = th.arr_get_goods(item_map.goods[io].goods_id, pt_res).fisrt_account_yu;
  1113 + if (!th.data.ispt_goods) {
  1114 + item_map.goods[io].account = item_map.goods[io].account_fir;
  1115 + item_map.goods[io].account_yu = item_map.goods[io].account_yu_fir;
  1116 + }
  1117 + }
  1118 + }
  1119 +
  1120 +
  1121 + o_price -= (item_map.price - item_map.prom_price);
  1122 + //如果有限制使用优惠券,就要减掉参与的活动商品的钱
  1123 + if (!item_map.is_xz_yh) q_conditin = o_price;
  1124 + }
  1125 +
  1126 + //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表-----------
  1127 + for (var j = 0; j < ord_goods.length; j++) {
  1128 + if (ord_goods[j].is_gift) continue;
  1129 + if (ord_goods[j].prom_type == 3 && ord_goods[j].prom_id == item_map.prom_id) {
  1130 + ord_goods[j].is_xz_yh = item_map.is_xz_yh;
  1131 + ord_goods[j].is_past = item_map.is_past;
  1132 + ord_goods[j].account_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_fir;
  1133 + ord_goods[j].account_yu_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu_fir;
  1134 + ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account;
  1135 + ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu;
  1136 + }
  1137 + }
  1138 +
  1139 +
  1140 + //--优惠多少钱--
  1141 + if (!cart_item.cut_price) cart_item.cut_price = 0;
  1142 + //-- --
  1143 + if (item_map.price != undefined && item_map.price != null
  1144 + && item_map.prom_price != undefined && item_map.prom_price != null)
  1145 + cart_item.cut_price += (item_map.price - item_map.prom_price);
  1146 + //---如果有送积分---
  1147 + if (item_map.s_intValue) {
  1148 + if (!cart_item.s_intValue) cart_item.s_intValue = 0;
  1149 + cart_item.s_intValue += item_map.s_intValue;
  1150 + }
  1151 + //-- 如果有送优惠券的情况 --
  1152 + if (item_map.s_coupon_id) {
  1153 + if (!cart_item.s_coupon_id) {
  1154 + cart_item.s_coupon_id = item_map.s_coupon_id + "";
  1155 + cart_item.g_coupon_num = [{'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num}];
  1156 + }
  1157 + else {
  1158 + cart_item.s_coupon_id += "," + item_map.s_coupon_id;
  1159 + cart_item.g_coupon_num.push({'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num})
  1160 + }
  1161 + }
  1162 +
  1163 + //-- 如果有送优包邮券的情况 --
  1164 + if (item_map.s_libao) {
  1165 + if (!cart_item.s_libao) {
  1166 + cart_item.s_libao = item_map.s_libao + "";
  1167 + cart_item.g_lb_num = [{'l_id': item_map.s_libao, "num": item_map.s_lb_num}];
  1168 + }
  1169 + else {
  1170 + cart_item.s_libao += "," + item_map.s_libao;
  1171 + cart_item.g_lb_num.push({'l_id': item_map.s_libao, "num": item_map.s_lb_num})
  1172 + }
  1173 + }
  1174 + }
  1175 + }
  1176 + }
  1177 + },
  1178 +
  1179 + //-------------------计算订单价格-------------------
  1180 + calculatePrice: function (t, s) {
  1181 + var th = this;
  1182 + to.getConfig2(function (ee) {
  1183 + to.getwuliuprice(async function (rs) {
  1184 + wx.showLoading({
  1185 + title: "处理中."
  1186 + })
  1187 + var all_price = 0; //所有的商品总价
  1188 + var all_shipping_m = 0; //所有的物流总价
  1189 + var all_total_m = 0; //所有的订单应付总价
  1190 + var all_order_m = 0; //所有的订单应付总价
  1191 + var all_user_m = 0; //所有的订单用户使用金额
  1192 + var all_coupon_price_m = 0; //所有的订单用户使用优惠券价格
  1193 + var all_cutprice = 0; //所有的优惠减
  1194 + var all_zh_cutprice = 0; //所有的组合优惠减
  1195 + var all_order_prom = 0; //所有的订单优惠
  1196 +
  1197 + var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0);
  1198 + var freight_free = ee.freight_free; //全场满多少包邮
  1199 + var no_ex_id = ee.no_ex_id;
  1200 + var no_ex_good = null;
  1201 + var by_qc = {};
  1202 +
  1203 + if (no_ex_id && freight_free > 0) {
  1204 + //-----------获取不包邮区域,不包邮商品-------
  1205 + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
  1206 + data: {store_id: os.stoid, id: no_ex_id}
  1207 + }).then(res => {
  1208 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  1209 + by_qc = res.data.data[0];
  1210 + }
  1211 + })
  1212 + }
  1213 + ;
  1214 + var c_arr = JSON.parse(JSON.stringify(th.data.old_cartlist));
  1215 +
  1216 + if (th.data.cartlist && th.data.cartlist.length > 0) {
  1217 + for (var i = 0; i < c_arr.length; i++) {
  1218 + c_arr[i].exp_type = th.data.cartlist[i].exp_type;
  1219 + c_arr[i].wind = th.data.cartlist[i].wind;
  1220 + }
  1221 + }
  1222 +
  1223 + //调用函数计算每件商品的单价
  1224 + await th.calc_per(c_arr);
  1225 + //调用函数计算每件组合购商品的单价,
  1226 + await zh_calc.calc_zh_split_price(c_arr,th);
  1227 + //调用函数计算,优惠券优惠什么商品价格,优惠券优惠什么商品
  1228 + await th.get_cart_quan(c_arr);
  1229 + //---循环购物车---
  1230 + for (var i in c_arr) {
  1231 + //因为搭配购买也是再这里计算,搭配购的is_b_now==1
  1232 + if (th.data.is_b_now == 0) {
  1233 + //此时物流的选择方式要用th.data.cartlist;
  1234 + c_arr[i].exp_type = th.data.cartlist[i].exp_type;
  1235 + c_arr[i].wind = th.data.cartlist[i].wind;
  1236 + if (th.data.cartlist[i].check_quan_price_list) c_arr[i].check_quan_price_list = th.data.cartlist[i].check_quan_price_list; //优惠券优惠什么商品价格
  1237 + if (th.data.cartlist[i].check_quan_ware_list) c_arr[i].check_quan_ware_list = th.data.cartlist[i].check_quan_ware_list; //优惠券优惠什么商品
  1238 + } else {
  1239 + c_arr[i].exp_type = th.data.bn_exp_type; //配送方式
  1240 + c_arr[i].wind = th.data.index; //立即购买选择的物流
  1241 + //c_arr[i].=th.data. //立即购买的使用余额
  1242 + if (th.data.cartlist) c_arr[i].check_quan_price_list = th.data.cartlist[i].check_quan_price_list; //优惠券优惠什么商品价格
  1243 + if (th.data.cartlist) c_arr[i].check_quan_ware_list = th.data.cartlist[i].check_quan_ware_list; //优惠券优惠什么商品
  1244 + }
  1245 +
  1246 + var cart_item = c_arr[i]; //就是每一单的意思
  1247 + var pickid = cart_item.pickup_id;
  1248 + var o_price = 0;
  1249 + var o_price_no_zh=0; //不包含限制优惠叠加组合购的金额汇总
  1250 + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
  1251 + var item = c_arr[i].goods; //就是每一单的从表的意思
  1252 +
  1253 + //---如果有选择优惠券的情况下---
  1254 + var quan_price = 0;
  1255 + var coupon_price = 0;
  1256 + var quan_no = null;
  1257 + var is_has_zh=c_arr[i].is_has_zh;
  1258 + var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间
  1259 +
  1260 + if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined)
  1261 + quan_no = th.data.using_quan[pickid].coupon_no;
  1262 +
  1263 + //普通券的时候
  1264 + if (quan_no && th.data.using_quan[pickid].isby != 1) {
  1265 + //---获取优惠券优惠---
  1266 + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", {
  1267 + data: {
  1268 + storeId: oo.stoid,
  1269 + CashRepNo: quan_no,
  1270 + WaresSum: cart_item.check_quan_price_list,
  1271 + WareIds: cart_item.check_quan_ware_list
  1272 + }
  1273 + }).then(res => {
  1274 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  1275 + var q_data = res.data.data;
  1276 + //--存储商品优惠的内容--
  1277 + cart_item.quan_youhui_list = q_data;
  1278 + for (var k in q_data)
  1279 + quan_price += q_data[k].WareCashSum;
  1280 + }
  1281 + })
  1282 + }
  1283 +
  1284 + //--------循环计算总价-----------
  1285 + for (var j = 0; j < item.length; j++) {
  1286 + if(item[j].prom_type!=7){
  1287 + o_price_no_zh += item[j].goods_price * item[j].goods_num;
  1288 + }
  1289 + //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
  1290 + else if(zh_prom_goods && zh_prom_goods[item[j].prom_id] && zh_prom_goods[item[j].prom_id].act.is_orderyh )
  1291 + {
  1292 + o_price_no_zh += item[j].goods_price * item[j].goods_num;
  1293 + }
  1294 + o_price += item[j].goods_price * item[j].goods_num;
  1295 + }
  1296 + //判断是不是有组合购的金额
  1297 + var f_o_price = o_price;
  1298 + //如果又优惠的钱,就要减价
  1299 + if (c_arr[i].cut_price > 0){
  1300 + o_price -= c_arr[i].cut_price;
  1301 + o_price_no_zh-=c_arr[i].cut_price;
  1302 + }
  1303 + //如果有组合购优惠的钱,就要减价
  1304 + if (c_arr[i].zh_cut_price>0 || c_arr[i].zh_cut_price<0){
  1305 + o_price -= c_arr[i].zh_cut_price;
  1306 + if(o_price_no_zh>0){
  1307 + //找到那些可以订单优惠叠加的
  1308 + for(let ij in zh_prom_goods){
  1309 + let kitem=zh_prom_goods[ij];
  1310 + if(kitem.act.is_orderyh) continue;
  1311 + o_price_no_zh-=kitem.cut_price;
  1312 + }
  1313 + }
  1314 + }
  1315 +
  1316 + //-- 计算线下取价的功能 --
  1317 + if (cart_item.is_offline == 1) {
  1318 + o_price = o_price - cart_item.offline_price;
  1319 + o_price_no_zh-=c_arr[i].offline_price;
  1320 + }
  1321 + //判断包邮券的钱,组合购的商品不使用优惠券
  1322 + var q_conditin = 0;
  1323 + q_conditin = o_price - quan_price;
  1324 + if(is_has_zh){
  1325 + q_conditin = o_price_no_zh - quan_price;
  1326 + }
  1327 + cart_item.goods_price = f_o_price.toFixed(2); //商品总费用,用f_o_price来计算
  1328 + //计算物流费用
  1329 + cart_item.shipping_price = 0;
  1330 +
  1331 +
  1332 + //--有不包邮区域,且不免运费,全场的计算,要减到优惠金额 和券的金额--
  1333 + 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)) {
  1334 + //如果有设置不包邮区域的时候
  1335 + if (by_qc.region_list != "" && by_qc.region_list != null && by_qc.region_list != undefined) {
  1336 + if (th.check_by_area(by_qc.region_list)) {
  1337 + freight_free = 0;
  1338 + th.data.is_no_by[pickid] = 1;
  1339 + }
  1340 + }
  1341 + //如果有设置不包邮区商品
  1342 + if (by_qc.goods_list != "" && by_qc.goods_list != undefined && by_qc != null && freight_free > 0) {
  1343 + freight_free = 0;
  1344 + no_ex_good = by_qc.goods_list;
  1345 + }
  1346 + }
  1347 +
  1348 + //--如果是物流,且选择了地址,就要开始显示包邮券,且包邮券也已经优惠了优惠活动的金额--
  1349 + if (cart_item.exp_type == 0 && th.data.user_addr != null) {
  1350 + //看是不是有调用过包邮券
  1351 + if (!th.data.isget_by_quan[pickid]) {
  1352 + //--判断要不要显示包邮券,调用接口,因为有for循环---
  1353 + await getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", {
  1354 + data: {
  1355 + store_id: os.stoid,
  1356 + isuse: 0,
  1357 + condition: q_conditin,
  1358 + user_id: getApp().globalData.user_id,
  1359 + pageSize: 2000
  1360 + }
  1361 + }).then(res => {
  1362 + if (res.data.code == 0 && res.data.data.total > 0) {
  1363 + //此时要循环判断包邮的地区,不包邮商品是不是符合
  1364 + var arr = [], quanlist = res.data.data.pageData;
  1365 + quanlist = th.check_is_frozenQuan(quanlist, th.data.frozenQuan, 1);
  1366 + for (var i in quanlist) {
  1367 + var item = quanlist[i];
  1368 + var goods = cart_item.goods;
  1369 + var g_arr = [];
  1370 + for (var ii in goods) {
  1371 + g_arr.push(goods[ii].goods_id);
  1372 + }
  1373 + if (item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域
  1374 + if (item.goods_list) {
  1375 + var no_goods_arr = item.goods_list.split(",");
  1376 + if (ut.isContained(no_goods_arr, g_arr)) continue; //如果是不包邮商品
  1377 + }
  1378 + arr.push(item);
  1379 + }
  1380 + if (arr) {
  1381 + th.data.get_by_quan_list_cart[pickid] = arr;
  1382 + //th.setData({get_by_quan_list_cart:th.data.get_by_quan_list_cart});
  1383 + if (th.data.is_b_now) {
  1384 + th.setData({get_by_quan_list: arr});
  1385 + }
  1386 + }
  1387 + th.data.isget_by_quan[pickid] = 1;
  1388 + }
  1389 + })
  1390 + }
  1391 + }
  1392 +
  1393 + //如果是包邮券的时候,要看看券的情况
  1394 + if (quan_no && th.data.using_quan[pickid].isby == 1) {
  1395 + var quan = th.data.using_quan[pickid];
  1396 + if (!quan.goods_list) {
  1397 + th.data.is_quan_by[pickid] = 1; //专门给券的判断用的
  1398 + } else {
  1399 + th.data.is_quan_by[pickid] = 0;
  1400 + //看有没有模板的包邮
  1401 + if (no_ex_good) {
  1402 + var arr = no_ex_good.split(",");
  1403 + var arr2 = quan.goods_list.split(",");
  1404 + if (ut.isContained(arr, arr2)) {
  1405 + getApp().my_warnning("全场不包邮商品和包邮券的重复", 0, th);
  1406 + th.data.using_quan[pickid] = {};
  1407 + th.setData({using_quan: th.data.using_quan})
  1408 + return false;
  1409 + }
  1410 + var n_arr = ut.mergeArray(arr, arr2);
  1411 + no_ex_good = n_arr.join(",");
  1412 + } else {
  1413 + no_ex_good = quan.goods_list;
  1414 + }
  1415 + }
  1416 + } else {
  1417 + th.data.is_quan_by[pickid] = 0; //专门给券的判断用的
  1418 + }
  1419 +
  1420 + //--------循环计算总价-----------
  1421 + for (var j = 0; j < item.length; j++) {
  1422 + //如果都包邮,都没必要等级数量了
  1423 + if (th.data.is_quan_by[pickid]) continue;
  1424 + //如果是优惠活动是包邮,就不用计算包邮的费用了
  1425 + if (item[j].is_past) continue;
  1426 + //是不是不包邮的商品
  1427 + var is_good_no_by = 0;
  1428 + if (no_ex_good) {
  1429 + is_good_no_by = th.check_by_goods(no_ex_good, item[j].goods_id);
  1430 + }
  1431 +
  1432 + //如果达到全场包邮的条件,同时,没有地区不包邮,或者商品不包邮
  1433 + if (o_price - quan_price >= freight_free && freight_free > 0 && !is_good_no_by && th.data.is_no_by[pickid] != 1) {
  1434 + continue;
  1435 + }
  1436 +
  1437 + //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算--
  1438 + if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1 && !is_good_no_by) {
  1439 + continue;
  1440 + }
  1441 +
  1442 + var no_ex_good_arr = null;
  1443 + if (no_ex_good) no_ex_good_arr = no_ex_good.split(',');
  1444 +
  1445 + //----------------如果是选择了物流---------------------
  1446 + 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 )) {
  1447 +
  1448 + //如果地址不为空
  1449 + if (th.data.user_addr != null) {
  1450 + switch (item[j]['exp_sum_type']) {
  1451 + case 1:
  1452 + //统一运费
  1453 + o_shipping_price += item[j]['uniform_exp_sum'];
  1454 + break;
  1455 + case 2:
  1456 + +''
  1457 + if (goods_weight < 0) goods_weight = 0;
  1458 + //累积商品重量 每种商品的重量 * 数量
  1459 + goods_weight += item[j]['weight'] * item[j]['goods_num'];
  1460 +
  1461 + break;
  1462 + case 3:
  1463 + if (goods_piece < 0) goods_piece = 0;
  1464 + //累积商品数量
  1465 + goods_piece += item[j]['goods_num'];
  1466 + break;
  1467 + }
  1468 + }
  1469 +
  1470 + }
  1471 + }
  1472 +
  1473 + //计算物流价格
  1474 + if (cart_item.exp_type == 0) {
  1475 + //freight_free=0; //后面不在进行判断
  1476 + var code = "";
  1477 + if (th.data.wu_arr && th.data.wu_arr[cart_item.wind])
  1478 + code = th.data.wu_arr[cart_item.wind].code;
  1479 + cart_item.shipping_price =
  1480 + th.calculatewuliu(code, o_shipping_price, goods_weight,
  1481 + goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs);
  1482 +
  1483 + if (!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby != 1) {
  1484 + if (cart_item.shipping_price == 0) th.data.is_by[pickid] = 1; //已经全场包邮,就不要选择券了
  1485 + }
  1486 + } else {
  1487 + cart_item.shipping_price = 0;
  1488 + }
  1489 +
  1490 + cart_item.shipping_price = cart_item.shipping_price.toFixed(2);
  1491 +
  1492 + //总价计算,总价不包含运费
  1493 + cart_item.order_amount = (o_price - quan_price).toFixed(2);
  1494 + cart_item.total_amount = f_o_price.toFixed(2);
  1495 +
  1496 + var order_prom_amount = 0;
  1497 + var order_prom_id = 0;
  1498 + var o_condition = cart_item.order_amount;
  1499 + //看一下是不是不用组合购的订单优惠的叠加
  1500 + if(is_has_zh){
  1501 + o_condition=o_price_no_zh-quan_price;
  1502 + }
  1503 +
  1504 + var order_m = 0;
  1505 + //---判断是不是有订单优惠---
  1506 + await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
  1507 + data: {store_id: os.stoid, orderAmount: o_condition}
  1508 + }).then(res => {
  1509 + if (res.data.code == 0) {
  1510 + var ord_prom = res.data.data;
  1511 + order_prom_id = ord_prom['id'];
  1512 + switch (ord_prom['type']) {
  1513 + case 0:
  1514 + order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折
  1515 + order_prom_amount = (o_condition - order_m).toFixed(2);
  1516 + break;
  1517 + case 1:
  1518 + //order_m = o_condition - ord_prom['expression'];//满额优惠金额
  1519 + order_prom_amount = ord_prom['expression'];
  1520 + break;
  1521 + }
  1522 + }
  1523 + })
  1524 +
  1525 + cart_item.order_prom_amount = 0;
  1526 + //--订单优惠的显示--
  1527 + if (order_prom_id > 0) {
  1528 + cart_item.order_amount = (o_price - quan_price - order_prom_amount).toFixed(2);
  1529 + cart_item.order_prom_id = order_prom_id;
  1530 + cart_item.order_prom_amount = order_prom_amount;
  1531 + }
  1532 + coupon_price = quan_price;
  1533 + if (cart_item.order_amount < 0) {
  1534 + cart_item.order_amount = 0;
  1535 + coupon_price = o_price;
  1536 + }
  1537 +
  1538 + cart_item.total_amount = parseFloat(cart_item.total_amount) + parseFloat(cart_item.shipping_price); //总金额
  1539 + cart_item.order_amount = parseFloat(cart_item.order_amount) + parseFloat(cart_item.shipping_price); //总金额
  1540 + cart_item.total_amount = cart_item.total_amount.toFixed(2);
  1541 + cart_item.order_amount = cart_item.order_amount.toFixed(2);
  1542 +
  1543 + //搭配购在使用余额
  1544 + if (th.data.bn_use_money == 1 && th.data.is_b_now == 1) {
  1545 +
  1546 + if (umoney > cart_item.order_amount) {
  1547 + cart_item.user_money = cart_item.order_amount;
  1548 + umoney = umoney - cart_item.order_amount;
  1549 + } else {
  1550 + cart_item.user_money = umoney;
  1551 + umoney = 0;
  1552 + }
  1553 +
  1554 + } else {
  1555 + //--------------如果使用余额,购物车购买---------------------
  1556 + if (th.data.js_use_money == 1) {
  1557 + if (umoney > cart_item.order_amount) {
  1558 + cart_item.user_money = cart_item.order_amount;
  1559 + umoney = umoney - cart_item.order_amount;
  1560 + } else {
  1561 + cart_item.user_money = umoney;
  1562 + umoney = 0;
  1563 + }
  1564 + } else {
  1565 + cart_item.user_money = 0;
  1566 + }
  1567 + }
  1568 +
  1569 + cart_item.user_money = parseFloat(cart_item.user_money).toFixed(2);
  1570 + if (coupon_price > 0) cart_item.coupon_price = coupon_price.toFixed(2);
  1571 + else cart_item.coupon_price = coupon_price
  1572 + if (quan_no) cart_item.quan_no = quan_no;
  1573 +
  1574 +
  1575 + //cart_item.goods_price = o_price.toFixed(2);
  1576 + cart_item.order_amount = cart_item.order_amount - cart_item.user_money; //会员使用余额
  1577 +
  1578 +
  1579 + all_price += parseFloat(f_o_price);
  1580 + all_total_m += parseFloat(cart_item.total_amount);
  1581 + all_shipping_m += parseFloat(cart_item.shipping_price);
  1582 + all_order_m += parseFloat(cart_item.order_amount);
  1583 + all_user_m += parseFloat(cart_item.user_money);
  1584 + all_coupon_price_m += parseFloat(cart_item.coupon_price);
  1585 + all_cutprice += parseFloat(cart_item.cut_price);
  1586 + all_zh_cutprice += parseFloat(cart_item.zh_cut_price);
  1587 + all_order_prom += parseFloat(cart_item.order_prom_amount);
  1588 + }
  1589 +
  1590 + all_shipping_m = parseFloat(all_shipping_m).toFixed(2);
  1591 + all_total_m = parseFloat(all_total_m).toFixed(2);
  1592 + all_order_m = parseFloat(all_order_m).toFixed(2);
  1593 + all_price = parseFloat(all_price).toFixed(2);
  1594 + all_user_m = parseFloat(all_user_m).toFixed(2);
  1595 + all_total_m = parseFloat(all_total_m).toFixed(2);
  1596 + all_coupon_price_m = parseFloat(all_coupon_price_m).toFixed(2);
  1597 + all_cutprice = all_cutprice.toFixed(2);
  1598 + all_order_prom = all_order_prom.toFixed(2);
  1599 + all_zh_cutprice = parseFloat(all_zh_cutprice).toFixed(2);
  1600 +
  1601 + var atxt = "formData.total_amount";
  1602 + var atxt1 = "formData.order_amount";
  1603 + var atxt2 = "formData.all_price";
  1604 + var atxt3 = "formData.user_money";
  1605 + var atxt4 = "formData.shipping_price";
  1606 + var atxt5 = "formData.coupon_price";
  1607 + var atxt6 = "formData.cut_price";
  1608 + var atxt7 = "formData.order_prom_amount";
  1609 + var atxt8 = "formData.zh_cut_price";
  1610 +
  1611 + th.setData({
  1612 + [atxt]: all_total_m, [atxt1]: all_order_m,
  1613 + [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m,
  1614 + [atxt5]: all_coupon_price_m, [atxt6]: all_cutprice,
  1615 + [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice
  1616 + })
  1617 + th.data.order_prom_list_cart = c_arr;
  1618 + th.set_can_num();
  1619 + wx.hideLoading();
  1620 +
  1621 + });
  1622 + });
  1623 + },
  1624 +
  1625 + set_can_num: function () {
  1626 + var th = this;
  1627 + //-- 这个地方,循环计算几张优惠券可用--
  1628 + for (var iter in th.data.cartlist) {
  1629 + var num = 0;
  1630 + var c_item = th.data.cartlist[iter];
  1631 + var pkid = c_item.pickup_id;
  1632 + //-- 普通券 --
  1633 + if (c_item.quan_list) {
  1634 + for (var iter1 in c_item.quan_list) {
  1635 + //判断是不是其他订单有选用
  1636 + var is_other_is_use = th.check_other_use(c_item.quan_list[iter1], pkid);
  1637 + if (!is_other_is_use) num++;
  1638 + }
  1639 + }
  1640 + //-- 包邮券 --
  1641 + var by_quan = th.data.get_by_quan_list_cart[pkid];
  1642 + if (by_quan) {
  1643 + for (var iter2 in by_quan) {
  1644 + //判断是不是其他订单有选用
  1645 + var is_other_is_use = th.check_other_use_by(by_quan[iter2], pkid);
  1646 + if (!is_other_is_use) num++;
  1647 + }
  1648 + }
  1649 + var set_txt = "cartlist[" + iter + "].can_num";
  1650 + th.setData({[set_txt]: num});
  1651 + }
  1652 + },
  1653 +
  1654 +
  1655 + //---------计算立即购买----------
  1656 + calculatePrice2: function () {
  1657 + var th = this, good = this.data.bn_goods;
  1658 +
  1659 + if (!good) return false;
  1660 +
  1661 + //搭配的计算要用购物的车计算方法
  1662 + if (good.prom_type == 5) {
  1663 + th.calculatePrice();
  1664 + return false;
  1665 + }
  1666 +
  1667 + wx.showLoading({
  1668 + title: "处理中."
  1669 + })
  1670 + //-----------计算商品总价--------------
  1671 + var allpice = good.shop_price * good.buynum;
  1672 + var cut_price = 0;
  1673 + var allpice1 = allpice;
  1674 +
  1675 +
  1676 + if (good.prom_type == 3 && good.prom_price !== null) {
  1677 + cut_price = allpice - good.prom_price;
  1678 + }
  1679 +
  1680 + allpice = parseFloat(allpice).toFixed(2);
  1681 + var txt = "formData.all_price";
  1682 + th.setData({[txt]: allpice,});
  1683 + if (cut_price) {
  1684 + var c_txt = "formData.cut_price";
  1685 + th.setData({[c_txt]: cut_price,});
  1686 +
  1687 + }
  1688 +
  1689 + //如果有线下取价的时候
  1690 + if (good.is_offline) {
  1691 + allpice = good.offline_price * good.buynum;
  1692 + }
  1693 +
  1694 +
  1695 + to.getConfig2(function (ee) {
  1696 + to.getwuliuprice(async function (rs) {
  1697 +
  1698 + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
  1699 +
  1700 + //---如果有选择优惠券的情况下---
  1701 + var quan_price = 0, bn_pick = th.data.bn_pick;
  1702 + var quan_no = null;
  1703 + if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
  1704 + quan_no = th.data.using_quan[bn_pick].coupon_no;
  1705 +
  1706 + if (quan_no) {
  1707 + if (th.data.using_quan[bn_pick].isby != 1) {
  1708 + //---获取优惠券优惠---
  1709 + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", {
  1710 + data: {
  1711 + storeId: oo.stoid,
  1712 + CashRepNo: quan_no,
  1713 + WaresSum: th.data.ckeck_quan_price,
  1714 + WareIds: th.data.check_quan_ware_list
  1715 + }
  1716 + }).then(res => {
  1717 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  1718 + quan_price = res.data.data[0].WareCashSum;
  1719 + }
  1720 + })
  1721 + }
  1722 + }
  1723 +
  1724 + //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮----------
  1725 + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1) {
  1726 + //看是不是有调用过包邮券
  1727 + if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1) {
  1728 + var condition = allpice - cut_price - quan_price;
  1729 + //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额,见到优惠券的钱---
  1730 + getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", {
  1731 + data: {
  1732 + store_id: os.stoid,
  1733 + isuse: 0,
  1734 + condition: condition,
  1735 + user_id: getApp().globalData.user_id,
  1736 + pageSize: 2000
  1737 + }
  1738 + }).then(res => {
  1739 + if (res.data.code == 0 && res.data.data.total > 0) {
  1740 + //此时要循环判断包邮的地区,不包邮商品是不是符合
  1741 + var arr = [], quanlist = res.data.data.pageData;
  1742 + quanlist = th.check_is_frozenQuan(quanlist, th.data.frozenQuan, 1);
  1743 + for (var i in quanlist) {
  1744 + var item = quanlist[i];
  1745 + if (item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域
  1746 + if (item.goods_list && th.check_by_goods(item.goods_list)) continue; //如果是不包邮商品
  1747 + arr.push(item);
  1748 + }
  1749 + if (arr) {
  1750 + th.setData({get_by_quan_list: arr});
  1751 + }
  1752 + th.data.isget_by_quan[th.data.bn_pick] = 1;
  1753 + }
  1754 + })
  1755 + }
  1756 +
  1757 + switch (good['exp_sum_type']) {
  1758 + case 1:
  1759 + //统一运费
  1760 + o_shipping_price += good['uniform_exp_sum'];
  1761 + break;
  1762 + case 2:
  1763 + if (goods_weight < 0) goods_weight = 0;
  1764 + //累积商品重量 每种商品的重量 * 数量
  1765 + goods_weight += good['weight'] * good['buynum'];
  1766 + break;
  1767 + case 3:
  1768 + if (goods_piece < 0) goods_piece = 0;
  1769 + //累积商品数量
  1770 + goods_piece += good['buynum'];
  1771 + break;
  1772 + }
  1773 +
  1774 + var code = "";
  1775 + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
  1776 + var freight_free = ee.freight_free; //全场满多少包邮
  1777 + var no_ex_id = ee.no_ex_id;
  1778 + th.data.is_no_by[th.data.bn_pick] = 0;
  1779 +
  1780 + var no_by_data = null;
  1781 + var gift_freight_free = freight_free;
  1782 +
  1783 +
  1784 + //有不包邮区域,且不免运费
  1785 + if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) {
  1786 + //-----------获取不包邮区域,不包邮商品-------
  1787 + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
  1788 + data: {store_id: os.stoid, id: no_ex_id}
  1789 + }).then(res => {
  1790 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  1791 + no_by_data = res.data.data[0];
  1792 + //如果有设置不包邮区域的时候
  1793 + if (res.data.data[0].region_list) {
  1794 + if (th.check_by_area(res.data.data[0].region_list)) {
  1795 + freight_free = 0;
  1796 + th.data.is_no_by[th.data.bn_pick] = 1;
  1797 + }
  1798 + }
  1799 + //如果有设置不包邮商品
  1800 + if (res.data.data[0].goods_list && freight_free) {
  1801 + if (th.check_by_goods(res.data.data[0].goods_list)) {
  1802 + freight_free = 0;
  1803 + th.data.is_no_by[th.data.bn_pick] = 1;
  1804 + }
  1805 + }
  1806 + }
  1807 + })
  1808 + }
  1809 +
  1810 + th.data.is_by[th.data.bn_pick] = 0;
  1811 + //--------------开始计算物流------------------
  1812 + var shipping_price =
  1813 + th.calculatewuliu(code, o_shipping_price, goods_weight,
  1814 + goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs);
  1815 +
  1816 + //如果有赠品的时候,也要计算赠品的物流费用
  1817 + if (th.data.buy_now_gift_goods) {
  1818 + shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,
  1819 + parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece);
  1820 + }
  1821 +
  1822 + if (shipping_price <= 0) {
  1823 + th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
  1824 + }
  1825 +
  1826 + shipping_price = parseFloat(shipping_price).toFixed(2);
  1827 + var wl_txt = "formData.shipping_price";
  1828 + th.setData({[wl_txt]: shipping_price,})
  1829 +
  1830 + } else {
  1831 + var wl_txt = "formData.shipping_price";
  1832 + th.setData({[wl_txt]: 0,})
  1833 + }
  1834 +
  1835 + if (quan_no) {
  1836 + if (th.data.using_quan[bn_pick].isby == 1) {
  1837 + shipping_price = 0;
  1838 + var wl_txt = "formData.shipping_price";
  1839 + th.setData({[wl_txt]: 0,})
  1840 + }
  1841 + }
  1842 + //-----------------支付价,优惠券不减物流-----------------
  1843 + var total_m = (parseFloat(allpice1)).toFixed(2);
  1844 + var order_m = (parseFloat(allpice - cut_price) - quan_price).toFixed(2);
  1845 + var coupon_price = quan_price; //优惠券优惠了多少钱
  1846 + if (order_m < 0) {
  1847 + order_m = 0;
  1848 + coupon_price = parseFloat(order_m).toFixed(2);
  1849 + }
  1850 + //--看一下有没有订单优惠--
  1851 + var o_condition = parseFloat(order_m);
  1852 + if (o_condition > 0) {
  1853 + th.check_is_order_prom(o_condition, function () {
  1854 + var order_prom_amount = 0;
  1855 + var order_prom_id = 0;
  1856 + if (th.data.order_prom[th.data.bn_pick]) {
  1857 + var ord_prom = th.data.order_prom[th.data.bn_pick];
  1858 + order_prom_id = ord_prom['id'];
  1859 + switch (ord_prom['type']) {
  1860 + case 0:
  1861 + order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折
  1862 + order_prom_amount = (o_condition - order_m).toFixed(2);
  1863 + break;
  1864 + case 1:
  1865 + order_m = o_condition - ord_prom['expression'];//满额优惠金额
  1866 + order_prom_amount = ord_prom['expression'];
  1867 + break;
  1868 + }
  1869 + }
  1870 + //--订单优惠的显示--
  1871 + if (order_prom_id > 0) {
  1872 + var order_prom_txt1 = "formData.order_prom_id";
  1873 + var order_prom_txt2 = "formData.order_prom_amount";
  1874 + th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount})
  1875 + }
  1876 +
  1877 + total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price);
  1878 + order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price);
  1879 +
  1880 + total_m = total_m.toFixed(2);
  1881 + order_m = order_m.toFixed(2);
  1882 +
  1883 + var atxt = "formData.total_amount";
  1884 + th.setData({[atxt]: total_m,})
  1885 +
  1886 + var txt = "formData.user_money";
  1887 + var txt2 = "formData.order_amount";
  1888 + var txt3 = "formData.coupon_price";
  1889 + var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
  1890 + //--------------如果使用余额---------------------
  1891 + if (th.data.bn_use_money == 1) {
  1892 + if (amoney > order_m) {
  1893 + order_m = parseFloat(order_m).toFixed(2);
  1894 + th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1})
  1895 + } else {
  1896 + order_m = parseFloat(order_m) - parseFloat(amoney);
  1897 + order_m = order_m.toFixed(2);
  1898 + th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
  1899 + }
  1900 + } else {
  1901 + th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
  1902 + }
  1903 + //优惠活动送积分
  1904 + if (good.s_intValue) {
  1905 + txt = "formData.give_integral";
  1906 + th.setData({[txt]: good.s_intValue});
  1907 + }
  1908 + //优惠送券
  1909 + if (good.s_coupon_id) {
  1910 + var i_txt = "formData.give_coupon_id";
  1911 + //这个是json格式的
  1912 + var i_txt1 = "formData.g_coupon_num";
  1913 + var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}];
  1914 + ob = JSON.stringify(ob);
  1915 + th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob});
  1916 + }
  1917 + //优惠礼包
  1918 + if (good.s_libao) {
  1919 + var l_txt = "formData.give_lb_id";
  1920 + //这个是json格式的
  1921 + var l_txt1 = "formData.g_lb_num";
  1922 + var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}];
  1923 + ob = JSON.stringify(ob);
  1924 + th.setData({[l_txt]: good.s_libao, [l_txt1]: ob});
  1925 + }
  1926 + })
  1927 + } else {
  1928 + total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price);
  1929 + order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price);
  1930 + var atxt = "formData.total_amount";
  1931 +
  1932 + total_m = total_m.toFixed(2);
  1933 + order_m = order_m.toFixed(2);
  1934 +
  1935 + th.setData({[atxt]: total_m,})
  1936 +
  1937 + var txt = "formData.user_money";
  1938 + var txt2 = "formData.order_amount";
  1939 + var txt3 = "formData.coupon_price";
  1940 + var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
  1941 + //--------------如果使用余额---------------------
  1942 + if (th.data.bn_use_money == 1) {
  1943 + if (amoney > order_m) {
  1944 + order_m = parseFloat(order_m).toFixed(2);
  1945 + th.setData({[txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1})
  1946 + } else {
  1947 + order_m = parseFloat(order_m) - parseFloat(amoney);
  1948 + order_m = order_m.toFixed(2);
  1949 + th.setData({[txt]: amoney, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
  1950 + }
  1951 + } else {
  1952 + th.setData({[txt]: 0, [txt2]: order_m, [txt3]: coupon_price, show_submit: 1})
  1953 + }
  1954 + //优惠活动送积分
  1955 + if (good.s_intValue) {
  1956 + txt = "formData.give_integral";
  1957 + th.setData({[txt]: good.s_intValue});
  1958 + }
  1959 + //优惠送券
  1960 + if (good.s_coupon_id) {
  1961 + var i_txt = "formData.give_coupon_id";
  1962 + //这个是json格式的
  1963 + var i_txt1 = "formData.g_coupon_num";
  1964 + var ob = [{"num": good.s_coupon_num, "c_id": good.s_coupon_id}];
  1965 + ob = JSON.stringify(ob);
  1966 + th.setData({[i_txt]: good.s_coupon_id, [i_txt1]: ob});
  1967 + }
  1968 + //优惠礼包
  1969 + if (good.s_libao) {
  1970 + var l_txt = "formData.give_lb_id";
  1971 + //这个是json格式的
  1972 + var l_txt1 = "formData.g_lb_num";
  1973 + var ob = [{"num": good.s_lb_num, "l_id": good.s_libao}];
  1974 + ob = JSON.stringify(ob);
  1975 + th.setData({[l_txt]: good.s_coupon_id, [l_txt1]: ob});
  1976 + }
  1977 + }
  1978 +
  1979 + wx.hideLoading();
  1980 +
  1981 + });
  1982 + });
  1983 + },
  1984 +
  1985 + //--------------------提交订单-----------------------
  1986 + async submitForm(t){
  1987 + var sub_value = t;
  1988 +
  1989 + if (this.data.is_summit_ing == 1) return false; //--提交中退出--
  1990 + this.data.is_summit_ing = 1;
  1991 + var th = this, pdata = new Array();
  1992 + var ff = true;
  1993 + //------------立即购买-------------
  1994 + if (th.data.is_b_now == 1 && th.data.bn_goods.prom_type != 5) {
  1995 +
  1996 + if (th.data.bn_exp_type == 0 && th.data.user_addr == null) {
  1997 + ff = false;
  1998 + getApp().my_warnning("请选择收货地址", 0, th);
  1999 + th.data.is_summit_ing = 0;
  2000 + }
  2001 + if (!ff) return false;
  2002 + var addr = th.data.user_addr;
  2003 + if (th.data.bn_exp_type == 1) addr = null;
  2004 +
  2005 + if (th.data.bn_exp_type == 0)
  2006 + if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
  2007 + getApp().my_warnning("读取物流失败", 0, th);
  2008 + th.data.is_summit_ing = 0;
  2009 + return false;
  2010 + }
  2011 +
  2012 + var item = {
  2013 + 'user_id': to.globalData.user_id,
  2014 + 'consignee': addr == null ? "" : addr.consignee,
  2015 + 'province': addr == null ? 0 : addr.province,
  2016 + 'city': addr == null ? 0 : addr.city,
  2017 + 'district': addr == null ? 0 : addr.district,
  2018 + 'twon': addr == null ? 0 : addr.twon,
  2019 + 'address': addr == null ? "" : addr.address,
  2020 + 'more_address': addr == null ? "" : addr.more_address,
  2021 + //'mobile': th.data.userinfo.mobile,
  2022 + 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile,
  2023 + 'email': '',
  2024 + 'shipping_code': th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code,
  2025 + 'shipping_name': th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name,
  2026 + 'invoice_title': '',
  2027 + 'goods_price': th.data.formData.all_price, //商品总价
  2028 + 'shipping_price': th.data.formData.shipping_price, //物流金额
  2029 + 'user_money': th.data.formData.user_money, //使用余额
  2030 + 'total_amount': th.data.formData.total_amount, //订单总价
  2031 + 'order_amount': th.data.formData.order_amount, //应付
  2032 + 'user_note': t.detail.value.user_note, //用户备注
  2033 + 'store_id': oo.stoid, //商家
  2034 + 'pickup_id': th.data.bn_pick, //门店
  2035 + 'exp_type': th.data.bn_exp_type, //配送方式
  2036 + 'order_goods': new Array(),
  2037 + };
  2038 + //是不是重新提交
  2039 + if (th.data.is_continue == 1) item.is_continue = 1;
  2040 +
  2041 + //获取立即购买的商品的信息
  2042 + var gg = to.get_b_now();
  2043 + //--商品的房间号--
  2044 + if (gg.room_id && gg.room_id > 0) {
  2045 + item.room_ids = gg.room_id;
  2046 + }
  2047 +
  2048 + var order_prom_list = {};
  2049 + //--判断有没有优惠活动--
  2050 + if (th.data.order_prom[item.pickup_id]) {
  2051 + if (th.data.formData.order_prom_amount > 0) {
  2052 + order_prom_list.order_prom_id = th.data.formData.order_prom_id;
  2053 + order_prom_list.order_prom_amount = th.data.formData.order_prom_amount;
  2054 + }
  2055 + }
  2056 +
  2057 + //--判断优惠活动的提交--
  2058 + if (th.data.formData.cut_price > 0 ) {
  2059 + order_prom_list.discount_amount = th.data.formData.cut_price.toFixed(2);
  2060 + var ob = [{
  2061 + "prom_id": th.data.bn_goods.prom_id,
  2062 + "dis": parseFloat(th.data.formData.cut_price).toFixed(2),
  2063 + "ispt": 0
  2064 + }]
  2065 + order_prom_list.prom_pt_json = JSON.stringify(ob);
  2066 + }
  2067 + if (th.data.formData.give_integral > 0) {
  2068 + order_prom_list.give_integral = th.data.formData.give_integral;
  2069 + }
  2070 + if (th.data.formData.give_coupon_id > 0) {
  2071 + order_prom_list.give_coupon_id = th.data.formData.give_coupon_id;
  2072 + order_prom_list.g_coupon_num = th.data.formData.g_coupon_num;
  2073 + }
  2074 + if (th.data.formData.give_lb_id > 0) {
  2075 + order_prom_list.give_lb_id = th.data.formData.give_lb_id;
  2076 + order_prom_list.g_lb_num = th.data.formData.g_lb_num;
  2077 + }
  2078 + item.order_prom_list = order_prom_list;
  2079 +
  2080 + //组装优惠券的钱
  2081 + if (parseFloat(th.data.formData.coupon_price) > 0) {
  2082 + item.coupon_price = th.data.formData.coupon_price;
  2083 + item.coupon_no = th.data.using_quan[th.data.bn_pick].coupon_no;
  2084 + }
  2085 + if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].coupon_no && th.data.using_quan[th.data.bn_pick].isby) {
  2086 + item.coupon_no = th.data.using_quan[th.data.bn_pick].coupon_no;
  2087 + item.coupon_price = 0;
  2088 + }
  2089 +
  2090 + //老会员成为分销下线需要的参数
  2091 + if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) {
  2092 + //判断一下分享人是不是分享商
  2093 + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => {
  2094 + if (res.data.code == 0) {
  2095 + var user = res.data.data;
  2096 + if (user.is_distribut == 1) {
  2097 + item.first_leader = parseInt(getApp().globalData.first_leader);
  2098 + }
  2099 + }
  2100 + })
  2101 + }
  2102 +
  2103 + var goods = {
  2104 + 'goods_id': gg.goods_id,
  2105 + 'goods_name': gg.goods_name,
  2106 + 'goods_sn': gg.goods_sn,
  2107 + 'goods_num': gg.goods_num,
  2108 + 'market_price': th.data.bn_goods.market_price,
  2109 + 'goods_price': th.data.bn_goods.shop_price,
  2110 + 'member_goods_price': th.data.bn_goods.shop_price,
  2111 + 'store_id': oo.stoid,
  2112 + 'prom_type': th.data.bn_goods.prom_type, //促销活动类型
  2113 + 'prom_id': th.data.bn_goods.prom_id, //促销活动id
  2114 + };
  2115 +
  2116 + //-- 把导购的信息填入--
  2117 + if (gg.guide_id) {
  2118 + goods.guide_id = gg.guide_id;
  2119 + goods.guide_type = gg.guide_type;
  2120 + //调用接口判断是不是会员
  2121 + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => {
  2122 + if (res.data.code == 0) {
  2123 + goods.guide_name = res.data.data.salesman;
  2124 + goods.guide_sn = res.data.data.salesman_no;
  2125 + }
  2126 + })
  2127 + }
  2128 +
  2129 + //--商品的房间号--
  2130 + if (gg.room_id && gg.room_id > 0) {
  2131 + goods.room_id = gg.room_id;
  2132 + }
  2133 +
  2134 + //积分购,先要带is_integral_normal=1
  2135 + if (gg.is_integral_normal) goods.is_integral_normal = 1;
  2136 +
  2137 + //先要带is_pd_normal=1
  2138 + if (gg.is_pd_normal) goods.is_pd_normal = 1;
  2139 +
  2140 + //如果不立即购买或者秒杀,如果是线下库存购买的时候
  2141 + if (goods.prom_type != 1 && goods.prom_type != 6 && th.data.sales_rules == 2) {
  2142 + var isok = 1;
  2143 + await th.check_store_num(goods.goods_id, th.data.bn_pick, gg.goods_num, function (res) {
  2144 + isok = res;
  2145 + });
  2146 + if (!isok) {
  2147 + getApp().confirmBox("商品的门店库存不足");
  2148 + th.data.is_summit_ing = 0;
  2149 + return false;
  2150 + }
  2151 + }
  2152 +
  2153 + //-- 如果有线下取价的话 --
  2154 + if (th.data.bn_goods.is_offline) {
  2155 + item.sum_offline_cut = (th.data.bn_goods.shop_price - th.data.bn_goods.offline_price).toFixed(2);
  2156 + goods.offline_cut = item.sum_offline_cut;
  2157 + goods.pricing_type = th.data.bn_goods.pricing_type;
  2158 + goods.goods_price = th.data.bn_goods.offline_price;
  2159 + goods.member_goods_price = th.data.bn_goods.offline_price;
  2160 + }
  2161 +
  2162 + //--- 如果有优惠促销的金额,要把金额先平摊下去 ---
  2163 + if (th.data.formData.cut_price > 0 && !th.data.ispt_goods) {
  2164 + var g_arr = new Array();
  2165 + g_arr.push(goods);
  2166 + var pt_data = {
  2167 + 'prom_id': goods.prom_id,
  2168 + 'dis': parseFloat(th.data.formData.cut_price),
  2169 + 'goods': g_arr,
  2170 + }
  2171 +
  2172 + var pt_res = null;
  2173 + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
  2174 + is_json: 1,
  2175 + data: pt_data
  2176 + }).then(res => {
  2177 + if (res.data.code == 0) {
  2178 + pt_res = res.data.data;
  2179 + }
  2180 + })
  2181 + if (pt_res) {
  2182 + //平摊赋值
  2183 + goods.account = pt_res[0].fisrt_account;
  2184 + goods.account_yu = pt_res[0].fisrt_account_yu;
  2185 + item.is_discount_amount = 1;
  2186 + }
  2187 + }
  2188 +
  2189 + //--组装优惠券的钱--
  2190 + if (th.data.formData.coupon_price) {
  2191 + item.coupon_price = th.data.formData.coupon_price;
  2192 + item.coupon_no = th.data.using_quan[th.data.bn_pick].coupon_no;
  2193 + goods.quan_num = th.data.formData.coupon_price;
  2194 + goods.quan_no = item.coupon_no;
  2195 + }
  2196 +
  2197 + item.order_goods.push(goods);
  2198 +
  2199 + //--如果有赠品的时候,赠品也要提交---
  2200 + if (th.data.buy_now_gift_goods) {
  2201 + var gift_gg = th.data.buy_now_gift_goods;
  2202 + var g_goods = {
  2203 + 'goods_id': gift_gg.goods_id,
  2204 + 'goods_name': gift_gg.goods_name,
  2205 + 'goods_sn': gift_gg.goods_sn,
  2206 + 'goods_num': gift_gg.buynum,
  2207 + 'market_price': gift_gg.market_price,
  2208 + 'goods_price': 0,
  2209 + 'member_goods_price': 0,
  2210 + 'store_id': oo.stoid,
  2211 + 'is_gift': 1,
  2212 + 'gift_id': gift_gg.gift_id,
  2213 + 'prom_id': gift_gg.prom_id,
  2214 + };
  2215 + item.order_goods.push(g_goods);
  2216 + }
  2217 + pdata.push(item);
  2218 +
  2219 + console.log(pdata);
  2220 + } else {
  2221 + //---------购物车的结算---------
  2222 + if (th.data.is_all_zt == 0 && th.data.user_addr == null) {
  2223 + th.data.is_summit_ing = 0;
  2224 + ff = false;
  2225 + getApp().confirmBox("请新建收货地址");
  2226 + }
  2227 + if (!ff) return false;
  2228 +
  2229 + var addr = th.data.user_addr;
  2230 + if (th.data.is_all_zt == 1) addr = null;
  2231 + var val_arr = t.detail.value;
  2232 +
  2233 +
  2234 + if (th.data.is_all_zt != 1)
  2235 + if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
  2236 + th.data.is_summit_ing = 0;
  2237 + getApp().confirmBox("读取物流失败");
  2238 + return false;
  2239 + }
  2240 +
  2241 + var order_prom_list_cart = th.data.order_prom_list_cart;
  2242 +
  2243 + //--组装推送数据--
  2244 + for (var i = 0; i < order_prom_list_cart.length; i++) {
  2245 + var t_item = order_prom_list_cart[i];
  2246 + var item = {
  2247 + 'user_id': to.globalData.user_id,
  2248 + 'consignee': addr == null ? th.data.userinfo.mobile : addr.consignee,
  2249 + 'province': addr == null ? 0 : addr.province,
  2250 + 'city': addr == null ? 0 : addr.city,
  2251 + 'district': addr == null ? 0 : addr.district,
  2252 + 'twon': addr == null ? 0 : addr.twon,
  2253 + 'address': addr == null ? "" : addr.address,
  2254 + 'more_address': addr == null ? "" : addr.more_address,
  2255 + 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile,
  2256 + 'email': '',
  2257 + 'shipping_code': th.data.is_all_zt == 1 ? 0 : th.data.wu_arr[t_item.wind].code,
  2258 + 'shipping_name': th.data.is_all_zt == 1 ? '' : th.data.wu_arr[t_item.wind].name,
  2259 + 'invoice_title': '',
  2260 + 'goods_price': t_item.goods_price, //商品总价
  2261 + 'shipping_price': t_item.shipping_price, //物流金额
  2262 + 'user_money': t_item.user_money, //使用余额
  2263 + 'total_amount': t_item.total_amount, //订单总价
  2264 + 'order_amount': t_item.order_amount, //应付
  2265 + 'user_note': val_arr['user_note_' + t_item.pickup_id], //用户备注
  2266 + 'store_id': oo.stoid, //商家
  2267 + 'pickup_id': t_item.pickup_id, //门店
  2268 + 'exp_type': t_item.exp_type, //配送方式
  2269 + 'order_goods': new Array(),
  2270 + };
  2271 + //是不是重新提交
  2272 + if (th.data.is_continue == 1) item.is_continue = 1;
  2273 + //----- 如果有线下取价的话 ----
  2274 + if (t_item.is_offline == 1) {
  2275 + item.sum_offline_cut = t_item.offline_price.toFixed(2);
  2276 + }
  2277 +
  2278 + //组装优惠券的钱
  2279 + if (t_item.coupon_price) {
  2280 + item.coupon_price = t_item.coupon_price;
  2281 + item.coupon_no = th.data.using_quan[t_item.pickup_id].coupon_no;
  2282 + } else if (t_item.quan_no) {
  2283 + item.coupon_no = t_item.quan_no;
  2284 + item.coupon_price = 0;
  2285 + }
  2286 +
  2287 + var order_prom_list = {};
  2288 + //--判断有没有优惠活动--
  2289 + if (t_item.order_prom_amount > 0) {
  2290 + order_prom_list.order_prom_id = t_item.order_prom_id;
  2291 + order_prom_list.order_prom_amount = t_item.order_prom_amount;
  2292 + }
  2293 +
  2294 + order_prom_list.discount_amount =0;
  2295 + //--判断优惠活动的提交--
  2296 + if (t_item.cut_price > 0) {
  2297 + order_prom_list.discount_amount += t_item.cut_price;
  2298 + order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json);
  2299 + }
  2300 + //--判断组合优惠活动的提交--
  2301 + if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) {
  2302 + order_prom_list.discount_amount += t_item.zh_cut_price;
  2303 + order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json);
  2304 + }
  2305 + if (t_item.s_intValue > 0) {
  2306 + order_prom_list.give_integral = t_item.s_intValue;
  2307 + }
  2308 + if (t_item.s_coupon_id) {
  2309 + order_prom_list.give_coupon_id = t_item.s_coupon_id;
  2310 + order_prom_list.g_coupon_num = JSON.stringify(t_item.g_coupon_num);
  2311 + }
  2312 + if (t_item.s_libao) {
  2313 + order_prom_list.give_lb_id = t_item.s_libao;
  2314 + order_prom_list.g_lb_num = JSON.stringify(t_item.g_lb_num);
  2315 + }
  2316 + if (Object.keys(order_prom_list).length > 0){
  2317 + if(order_prom_list.discount_amount)
  2318 + order_prom_list.discount_amount= parseFloat(order_prom_list.discount_amount).toFixed(2);
  2319 + if(order_prom_list.order_prom_amount)
  2320 + order_prom_list.order_prom_amount= parseFloat(order_prom_list.order_prom_amount).toFixed(2);
  2321 + item.order_prom_list = order_prom_list;
  2322 + }
  2323 +
  2324 +
  2325 + //老会员成为分销下线需要的参数
  2326 + if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) {
  2327 + //判断一下分享人是不是分享商
  2328 + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => {
  2329 + if (res.data.code == 0) {
  2330 + var user = res.data.data;
  2331 + if (user.is_distribut == 1) {
  2332 + item.first_leader = parseInt(getApp().globalData.first_leader);
  2333 + }
  2334 + }
  2335 + })
  2336 + }
  2337 +
  2338 +
  2339 + //房间号的ids
  2340 + var room_ids = "";
  2341 + //-------------让商品添加到商品列表--------------------
  2342 + for (var k = 0; k < t_item.goods.length; k++) {
  2343 + var g_item = t_item.goods[k];
  2344 + var goods = {
  2345 + 'goods_id': g_item.goods_id,
  2346 + 'goods_name': g_item.goods_name,
  2347 + 'goods_sn': g_item.goods_sn,
  2348 + 'goods_num': g_item.goods_num,
  2349 + 'market_price': g_item.market_price,
  2350 + 'goods_price': g_item.goods_price,
  2351 + 'member_goods_price': g_item.goods_price,
  2352 + 'store_id': oo.stoid,
  2353 + };
  2354 +
  2355 + //-- 线下取价也要写入,组合购的商品不能去线下价格 --
  2356 + if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type!=7) {
  2357 + goods.goods_price = g_item.offline_price;
  2358 + goods.member_goods_price = g_item.offline_price;
  2359 + goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2);
  2360 + goods.pricing_type = g_item.pricing_type;
  2361 + }
  2362 +
  2363 + //--把券的钱,写入从表---
  2364 + if (t_item.quan_youhui_list && t_item.coupon_price) {
  2365 + for (var kk in t_item.quan_youhui_list) {
  2366 + var you_item = t_item.quan_youhui_list[kk];
  2367 + if (g_item.prom_type!=7 && g_item.erpwareid == you_item.WareId) {
  2368 + goods.quan_num = you_item.WareCashSum;
  2369 + goods.quan_no = you_item.CashRepNo;
  2370 + }
  2371 + }
  2372 + }
  2373 +
  2374 + //--判断活动的类型--
  2375 + switch (g_item.prom_type) {
  2376 + case 1:
  2377 + goods.prom_type = g_item.prom_type;
  2378 + goods.prom_id = g_item.prom_id;
  2379 + break;
  2380 + case 3:
  2381 + goods.prom_type = 3;
  2382 + goods.prom_id = g_item.prom_id;
  2383 + if (g_item.is_gift) {
  2384 + goods.is_gift = g_item.is_gift;
  2385 + goods.gift_id = g_item.gift_id;
  2386 + }
  2387 + break;
  2388 + case 5:
  2389 + goods.prom_type = 5;
  2390 + goods.prom_id = g_item.prom_id;
  2391 + if (g_item.is_collocation) {
  2392 + goods.is_collocation = g_item.is_collocation;
  2393 + }
  2394 + break
  2395 + case 7:
  2396 + goods.prom_type = 7;
  2397 + goods.prom_id = g_item.prom_id;
  2398 + break
  2399 + default:
  2400 + goods.prom_type = 0;
  2401 + goods.prom_id = 0;
  2402 + }
  2403 +
  2404 + //如果不立即购买或者秒杀,如果是线下库存购买的时候
  2405 + if (goods.prom_type == 0 && th.data.sales_rules == 2) {
  2406 + var isok = 1;
  2407 + await th.check_store_num(goods.goods_id, t_item.pickup_id, goods.goods_num, function (res) {
  2408 + isok = res;
  2409 + });
  2410 + if (!isok) {
  2411 + getApp().confirmBox(goods.goods_name + "的门店库存不足");
  2412 + th.data.is_summit_ing = 0;
  2413 + return false;
  2414 + }
  2415 + }
  2416 +
  2417 + //把优惠的平摊结果写进去
  2418 + if (g_item.account >= 0 || g_item.account_yu != 0) {
  2419 + if (g_item.account >= 0) goods.account = g_item.account;
  2420 + if (g_item.account_yu != 0) goods.account_yu = g_item.account_yu;
  2421 + item.is_discount_amount = 1;
  2422 + }
  2423 +
  2424 + //导购ID
  2425 + if (g_item.guide_id) {
  2426 + goods.guide_id = g_item.guide_id;
  2427 + goods.guide_type = g_item.guide_type;
  2428 + //调用接口判断是不是会员
  2429 + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => {
  2430 + if (res.data.code == 0) {
  2431 + goods.guide_name = res.data.data.salesman;
  2432 + goods.guide_sn = res.data.data.salesman_no;
  2433 + }
  2434 + })
  2435 + }
  2436 + //如果房间号不为空的时候
  2437 + if (g_item.room_id) {
  2438 + goods.room_id = g_item.room_id;
  2439 + room_ids += g_item.room_id + ",";
  2440 + }
  2441 + item.order_goods.push(goods);
  2442 + }
  2443 +
  2444 + //如果房间号不为空的时候
  2445 + if (room_ids != "") item.room_ids = ut.sub_last(room_ids);
  2446 + pdata.push(item);
  2447 + }
  2448 +
  2449 +
  2450 + }
  2451 +
  2452 + if (pdata.length == 0) return;
  2453 + var str = JSON.stringify(pdata);
  2454 +
  2455 + wx.showLoading({title: "加载中"});
  2456 + wx.request({
  2457 + url: oo.url + '/api/weshop/order/createWxdOrder',
  2458 + data: str,
  2459 + method: 'POST',
  2460 + header: {
  2461 + 'content-type': 'application/json'
  2462 + },// 设置请求的 header
  2463 + success: function (res) {
  2464 +
  2465 +
  2466 + wx.hideLoading();
  2467 + if (res.statusCode == 200) {
  2468 + var data = res.data;
  2469 + if (data.code == 0) {
  2470 + console.log(th.data.is_b_now);
  2471 + //如果是购物车结算,还要删除购物车
  2472 + if (th.data.is_b_now == 0) {
  2473 + console.log(th.data.cartlist_y);
  2474 + var list = th.data.cartlist_y;
  2475 + for (var i = 0; i < list.length; i++) {
  2476 + //删除购物车
  2477 + a.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {});
  2478 + }
  2479 + }
  2480 + var order_amount = 0;
  2481 + pdata.forEach(function (em, ind) {
  2482 + order_amount += em.order_amount;
  2483 + })
  2484 + //要进行判断,如果是用微信支付,就要跳转到支付界面
  2485 + if (order_amount > 0) {
  2486 + th.setData({isclose: 0});
  2487 + //void e.jumpToCart4({
  2488 + // order_sn: data.data,
  2489 + //}, 1);
  2490 + util_pay.pay(data.data, function () {
  2491 + //app.my_warnning("支付成功",1,th);
  2492 + //setTimeout(function () {
  2493 + wx.redirectTo({
  2494 + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data
  2495 + })
  2496 + //},1000)
  2497 +
  2498 + }, function () {
  2499 + //支付失败
  2500 + setTimeout(function () {
  2501 + var cps=getCurrentPages();
  2502 + if(cps.length>1){
  2503 + wx.navigateBack({delta: 1})
  2504 + }else{
  2505 + getApp().goto("/pages/index/index/index");
  2506 + }
  2507 +
  2508 + }, 1000)
  2509 + }, oo.stoid);
  2510 +
  2511 + } else {
  2512 + var dd = {
  2513 + parent_sn: data.data,
  2514 + store_id: oo.stoid,
  2515 + type: 2,
  2516 + };
  2517 + a.post("/api/weshop/order/pay/createOrder", {
  2518 + data: dd,
  2519 + success: function (t) {
  2520 + //console.log(t);
  2521 + if (t.data.code == 0) {
  2522 + //app.my_warnning("支付成功",1,th);
  2523 + //setTimeout(function () {
  2524 + th.setData({isclose: 0});
  2525 + wx.redirectTo({
  2526 + url: "/pages/payment/pay_success/pay_success?type=2&order_sn=" + data.data,
  2527 + })
  2528 + //}, 1000)
  2529 + }
  2530 + },
  2531 + fail: function () {
  2532 +
  2533 + }
  2534 + });
  2535 + }
  2536 +
  2537 + }
  2538 + else {
  2539 + //--内容换行--
  2540 + var msg = data.msg;
  2541 + //赠品活动已经取消,无法赠送,是否继续买单?
  2542 + if (msg.indexOf("是否继续买单") > 0) {
  2543 + wx.showModal({
  2544 + title: "提示",
  2545 + content: data.msg,
  2546 + cancelText: '取消',
  2547 + confirmText: '确定',
  2548 + showCancel: true,
  2549 + success(res){
  2550 + if (res.cancel) {
  2551 + return;
  2552 + } else if (res.confirm) {
  2553 + th.data.is_continue = 1;
  2554 + th.data.is_summit_ing = 0; //是否提交中
  2555 + th.submitForm(sub_value);
  2556 + }
  2557 + }
  2558 + })
  2559 + return;
  2560 + }
  2561 + if (msg.length > 13) {
  2562 + msg = msg.slice(0, 13) + "\r\n" + msg.slice(13);
  2563 + }
  2564 + getApp().confirmBox(msg);
  2565 + th.data.is_summit_ing = 0; //是否提交中
  2566 + }
  2567 + } else {
  2568 + th.data.is_summit_ing = 0; //是否提交中
  2569 + console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
  2570 + }
  2571 + },
  2572 + fail: function () {
  2573 + th.data.is_summit_ing = 0;
  2574 + wx.hideLoading();
  2575 + console.log("index.js wx.request CheckCallUser fail");
  2576 + },
  2577 + complete: function () {
  2578 + }
  2579 + })
  2580 +
  2581 + },
  2582 + //---确认线下门店的数量足不足---
  2583 + async check_store_num(goods_id, pick, goods_num, func){
  2584 + var lock = 0, pick_no, plist, erpwareid;
  2585 + //先读取门店的lock
  2586 + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
  2587 + data: {store_id: os.stoid, wareId: goods_id, storageId: pick, pageSize: 1000}
  2588 + }).then(res => {
  2589 + if (res.data.code == 0 && res.data.data.total > 0) {
  2590 + for (var i in res.data.data.pageData)
  2591 + lock += res.data.data.pageData[i].outQty;
  2592 + }
  2593 + })
  2594 + //先获取门店的编号
  2595 + await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick, {
  2596 + data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick}
  2597 + }).then(res => {
  2598 + if (res.data.code == 0) {
  2599 + pick_no = res.data.data.pickup_no;
  2600 + }
  2601 + })
  2602 + //先获取商品的线下库存
  2603 + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + goods_id, {
  2604 + data: {storeId: os.stoid, goodsId: t.goods_id, pickupId: pick}
  2605 + }).then(res => {
  2606 + if (res.data.code == 0) {
  2607 + erpwareid = res.data.data.erpwareid;
  2608 + }
  2609 + })
  2610 + //读取线下的门店库存
  2611 + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
  2612 + data: {storageNos: pick_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid, pageSize: 2000}
  2613 + }).then(res => {
  2614 + if (res.data.code == 0) {
  2615 + plist = res.data.data.pageData[0];
  2616 + }
  2617 + })
  2618 + var isok = 1;
  2619 + if (goods_num > plist.CanOutQty - lock) {
  2620 + isok = 0;
  2621 + }
  2622 + func(isok);
  2623 + },
  2624 +
  2625 + useCoupon: function () {
  2626 + if (this.data.order.couponNum <= 0) {
  2627 + getApp().my_warnning("无可用优惠券", 0, this);
  2628 + return;
  2629 + }
  2630 +
  2631 + var a = {
  2632 + lid: this.data.coupon ? this.data.coupon.id : "0"
  2633 + };
  2634 + wx.navigateTo({
  2635 + url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a)
  2636 + });
  2637 + },
  2638 + enterAddressPage: function () {
  2639 + getApp().globalData.is_cart_old = 1;
  2640 + this.data.isget_by_quan = {};
  2641 + this.data.enterAddressPage = !0, wx.navigateTo({
  2642 + url: "/pages/user/address_list/address_list"
  2643 + });
  2644 + },
  2645 +
  2646 + //--------购物车购买时,选择自提和物流-----------
  2647 + setexptype_w: function (t) {
  2648 +
  2649 + var def_exp_code = getApp().globalData.userInfo.def_exp_code, th = this;
  2650 + var ty = t.currentTarget.dataset.t, txt = t.currentTarget.dataset.txt,
  2651 + wl_txt = t.currentTarget.dataset.wl_txt,
  2652 + ont = t.currentTarget.dataset.ont;
  2653 +
  2654 + th.setData({[txt]: ty});
  2655 + var iszt = 1;
  2656 +
  2657 + if (ty == 0) {
  2658 + th.setData({is_all_zt: 0});
  2659 + } else {
  2660 + for (var i = 0; i < th.data.cartlist.length; i++) {
  2661 + var item = th.data.cartlist[i];
  2662 + if (item.exp_type == 0) {
  2663 + iszt = 0;
  2664 + break;
  2665 + }
  2666 + }
  2667 +
  2668 + th.setData({is_all_zt: iszt});
  2669 +
  2670 + var ind = t.currentTarget.dataset.ind;
  2671 + var c_item = th.data.cartlist[ind];
  2672 + var pickid = c_item.pickup_id;
  2673 +
  2674 + if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1) {
  2675 + th.data.using_quan[pickid] = {};
  2676 + th.setData({using_quan: th.data.using_quan});
  2677 + }
  2678 +
  2679 +
  2680 + }
  2681 + //判断有没有默认的物流地址值
  2682 + if (def_exp_code != "" && def_exp_code != null && def_exp_code != undefined) {
  2683 + var wu_arr = this.data.wu_arr;
  2684 + if (wu_arr != null && wu_arr != "") {
  2685 + for (var i = 0; i < wu_arr.length; i++) {
  2686 + if (wu_arr[i].shipping_code == def_exp_code) {
  2687 + var set_txt = "cartlist"
  2688 + th.setData({wl_txt: i});
  2689 + }
  2690 + }
  2691 + }
  2692 + }
  2693 + //----计算此时购物车的价格----
  2694 + th.calculatePrice();
  2695 + },
  2696 +
  2697 + //--------立即购买时,选择自提和物流----------
  2698 + setexptype: function (t) {
  2699 + var th = this;
  2700 + var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code;
  2701 + th.setData({bn_exp_type: ty});
  2702 + if (ty == 0) {
  2703 + th.setData({is_all_zt: 0});
  2704 + }
  2705 +
  2706 + //当物流为空的时候。
  2707 + if (ty == 0 && th.data.wu_arr == null) {
  2708 + th.data.isget_by_quan = {};
  2709 + return th.get_wuliu(th.calculatePrice2());
  2710 + }
  2711 +
  2712 + //--自提就要把包邮券清理掉--
  2713 + if (ty == 1) {
  2714 + th.data.isget_by_quan = {};
  2715 + if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].isby == 1) {
  2716 + th.setData({using_quan: {}});
  2717 + }
  2718 + }
  2719 +
  2720 + //判断有没有默认的物流地址值
  2721 + if (def_exp_code != "" && def_exp_code != null && def_exp_code != undefined) {
  2722 + var wu_arr = this.data.wu_arr;
  2723 + if (wu_arr != null && wu_arr != "") {
  2724 + for (var i = 0; i < wu_arr.length; i++) {
  2725 + if (wu_arr[i].shipping_code == def_exp_code) {
  2726 + th.setData({index: i});
  2727 + }
  2728 + }
  2729 + }
  2730 + }
  2731 + th.calculatePrice2()
  2732 +
  2733 + },
  2734 +
  2735 + //--------立即购买时,使用余额--------
  2736 + set_bn_useyuer: function () {
  2737 + var th = this;
  2738 + th.setData({bn_use_money: !th.data.bn_use_money});
  2739 + th.calculatePrice2();
  2740 + },
  2741 + set_js_useyuer: function () {
  2742 + var th = this;
  2743 + th.setData({js_use_money: !th.data.js_use_money});
  2744 + th.calculatePrice();
  2745 + },
  2746 + //-------------------计算物流---------------
  2747 + calculatewuliu: function (code, o_shipping_price, goods_weight,
  2748 + goods_piece, user_addr, freight_free, o_price, rs) {
  2749 + var price = 0, th = this;
  2750 + price += parseFloat(o_shipping_price);
  2751 + //如果是包邮
  2752 + if (freight_free > 0 && o_price >= freight_free) {
  2753 + return 0;
  2754 + }
  2755 + if (user_addr == null) {
  2756 + return 0;
  2757 + }
  2758 + //计算物流的config item;
  2759 + var item = null;
  2760 + //先根据 镇 县 区找计算的config
  2761 + item = th.get_wuliu_config(user_addr.district, code, rs);
  2762 + if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
  2763 + if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
  2764 + if (item == null) item = th.get_wuliu_default(code, rs);
  2765 + if (item == null) return o_shipping_price;
  2766 + var fw_price = 0, fp_price = 0;
  2767 + item = item.config;
  2768 + if (item == null) return o_shipping_price;
  2769 + //------按重量----------
  2770 + if (goods_weight >= 0 && item['money']) {
  2771 + fw_price = parseFloat(item['money']);
  2772 + if (goods_weight > item['first_weight']) {
  2773 + var fw = goods_weight - item['first_weight'];
  2774 + var n = Math.ceil(fw / item['second_weight'])
  2775 + fw_price = fw_price + n * parseFloat(item['add_money']);
  2776 + }
  2777 + }
  2778 + //------按件数----------
  2779 + if (goods_piece > 0 && item['piecemoney']) {
  2780 + fp_price = parseFloat(item['piecemoney']);
  2781 + if (goods_piece > item['first_piece']) {
  2782 + var fp = goods_piece - item['first_piece'];
  2783 + var m = Math.ceil(fp / item['second_piece'])
  2784 + fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
  2785 + }
  2786 + }
  2787 + var rspice = parseFloat(price + fw_price + fp_price);
  2788 + return rspice;
  2789 + },
  2790 +
  2791 + //------------循环获取config-----------
  2792 + get_wuliu_config: function (region_id, code, rs) {
  2793 + var item = null, rslist = rs.pageData;
  2794 + for (var i = 0; i < rslist.length; i++) {
  2795 + if (rslist[i].code == code && rslist[i].region_id == region_id) {
  2796 + item = rslist[i];
  2797 + }
  2798 + }
  2799 + return item;
  2800 + },
  2801 + //-------循环获取config,code default-------
  2802 + get_wuliu_default: function (code, rs) {
  2803 + var item = null, rslist = rs.pageData;
  2804 + for (var i = 0; i < rslist.length; i++) {
  2805 + if (rslist[i].shipping_code == code && rslist[i].is_default == 1) {
  2806 + item = rslist[i];
  2807 + }
  2808 + }
  2809 + return item;
  2810 + },
  2811 +
  2812 + //----------立即购买,选择物流-------------
  2813 + bindPickerChange: function (e) {
  2814 + var ind = e.detail.value
  2815 + this.setData({index: ind});
  2816 + this.calculatePrice2();
  2817 + },
  2818 + //----------购物车结算,选择物流-------------
  2819 + bindPickerChange_w: function (e) {
  2820 + var ind = e.detail.value, txt = e.currentTarget.dataset.txt;
  2821 + this.setData({[txt]: ind});
  2822 + this.calculatePrice();
  2823 + },
  2824 +
  2825 + /*----券的所有操作----*/
  2826 + open_coupon_list: function (e) {
  2827 + var th = this;
  2828 + var pickid = e.currentTarget.dataset.pickid;
  2829 + var bn = e.currentTarget.dataset.bn;
  2830 + var cindx = e.currentTarget.dataset.cind;
  2831 + var get_by_quan_list_cart = th.data.get_by_quan_list_cart[pickid];
  2832 +
  2833 +
  2834 + if (bn == 1) {
  2835 + th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1});
  2836 + } else {
  2837 + //---多单打开券的时候,就要判断券在其他门店是否有使用---
  2838 + var quanlist = th.data.cartlist[cindx].quan_list;
  2839 + var exp_type = th.data.cartlist[cindx].exp_type;
  2840 +
  2841 +
  2842 + //对于在其他门店已经选择了的券 要判断是否显示到界面
  2843 + var t_user = th.data.using_quan[pickid];
  2844 +
  2845 + for (var i in quanlist) {
  2846 + quanlist[i].is_using = th.check_in_sele(quanlist[i].CashRepNo, pickid);
  2847 + if (t_user && quanlist[i].CashRepNo == t_user.coupon_no)
  2848 + quanlist[i].show_red = 1;
  2849 + else
  2850 + quanlist[i].show_red = 0;
  2851 + }
  2852 +
  2853 + if (get_by_quan_list_cart) {
  2854 + for (var i in get_by_quan_list_cart) {
  2855 + get_by_quan_list_cart[i].is_using = th.check_in_sele(get_by_quan_list_cart[i].no, pickid);
  2856 + if (t_user && get_by_quan_list_cart[i].no == t_user.coupon_no)
  2857 + get_by_quan_list_cart[i].show_red = 1;
  2858 + else
  2859 + get_by_quan_list_cart[i].show_red = 0;
  2860 + }
  2861 + th.setData({by_quan_list_cart: get_by_quan_list_cart});
  2862 + } else {
  2863 + th.setData({by_quan_list_cart: null});
  2864 + }
  2865 +
  2866 + console.log("2222222券的列表", quanlist);
  2867 + th.setData({
  2868 + sele_cart_ind: cindx,
  2869 + sele_exp_type: exp_type,
  2870 + open_quan: 1,
  2871 + selected_quan_pick: pickid,
  2872 + selected_quan_list: quanlist,
  2873 + disabled: 1
  2874 + });
  2875 + }
  2876 + },
  2877 + close_coupon: function (e) {
  2878 + var th = this;
  2879 + th.setData({open_quan: 0, disabled: 0});
  2880 + },
  2881 +
  2882 + //---判断券时候在已经选择的列表中---
  2883 + check_in_sele: function (no, pick_id) {
  2884 + var th = this;
  2885 + if (th.data.using_quan.length <= 0) return false;
  2886 + for (var i in th.data.using_quan) {
  2887 + //--如果键值等于本身就要跳出--
  2888 + if (parseInt(i) == parseInt(pick_id)) continue;
  2889 + var item = th.data.using_quan[i];
  2890 + if (item.coupon_no == no) {
  2891 + return true;
  2892 + }
  2893 + }
  2894 + return false;
  2895 + },
  2896 +
  2897 + /*--点击选择券--*/
  2898 + sele_quan_item: function (e) {
  2899 +
  2900 + var ind = e.currentTarget.dataset.ind;
  2901 + var quan_item = this.data.selected_quan_list[ind];
  2902 + var pickid = this.data.selected_quan_pick; //现在选择的是哪一个门店
  2903 + //--如果券是单品使用的时候--
  2904 + if (quan_item && quan_item.UseObjectType && quan_item.UseObjectType == "20") {
  2905 + //---只有多件购买的时候才要计算,//购物车购买和搭配勾的时候---
  2906 + var gg = getApp().get_b_now();
  2907 + if (this.data.is_b_now == 0 || gg.prom_type == 5) {
  2908 + var arr = this.data.order_prom_list_cart;
  2909 + var t_pk_item = null;
  2910 + for (var ii in arr) {
  2911 + var ep = arr[ii];
  2912 + if (pickid == ep.pickup_id) {
  2913 + t_pk_item = ep;
  2914 + break;
  2915 + }
  2916 + }
  2917 + //--寻找券指定的商品--
  2918 + var gd = null;
  2919 + if (t_pk_item) {
  2920 + var goods = t_pk_item.goods;
  2921 + for (var gid in goods) {
  2922 + if (quan_item.UseObjectID == goods[gid].erpwareid) {
  2923 + gd = goods[gid];
  2924 + }
  2925 + }
  2926 + }
  2927 + if (!gd) {
  2928 + getApp().my_warnning("未找到指定商品使用", 0, this, 600);
  2929 + return false;
  2930 + }
  2931 + //计算价格,如果有平摊的实收要计算实收的金额
  2932 + var item_price = gd.goods_price * gd.goods_num;
  2933 + //-- 如果有平摊下去,有实收价格的时候,就要用account_fir来计算价格 --
  2934 + if (gd.account_fir != null && gd.account_fir != undefined) {
  2935 + item_price = gd.account_fir * gd.goods_num;
  2936 + }
  2937 +
  2938 + if (item_price < parseFloat(quan_item.BuySum)) {
  2939 + getApp().my_warnning("该单品金额没有大于等于" + quan_item.BuySum + "元时不能使用优惠券", 0, this, 600);
  2940 + return false;
  2941 + }
  2942 + }
  2943 + }
  2944 +
  2945 + var no_use = e.currentTarget.dataset.no, quanlist = this.data.selected_quan_list;
  2946 + //---所有的券的显示红色选择都清理一遍---
  2947 + for (var i in quanlist) {
  2948 + quanlist[i].show_red = 0;
  2949 + }
  2950 + this.setData({selected_quan_list: quanlist});
  2951 + var by_quanlist = this.data.get_by_quan_list;
  2952 + if (by_quanlist) {
  2953 + //---所有的券的显示红色选择都清理一遍---
  2954 + for (var inb in by_quanlist) {
  2955 + by_quanlist[inb].show_red = 0;
  2956 + }
  2957 + this.setData({get_by_quan_list: by_quanlist});
  2958 + }
  2959 +
  2960 + var by_cart_list = this.data.by_quan_list_cart;
  2961 + if (by_cart_list) {
  2962 + //---所有的券的显示红色选择都清理一遍---
  2963 + for (var inc in by_cart_list) {
  2964 + by_cart_list[inc].show_red = 0;
  2965 + }
  2966 + this.setData({by_quan_list_cart: by_cart_list});
  2967 + }
  2968 +
  2969 + var using_quan = this.data.using_quan;
  2970 + var th = this;
  2971 + //---如果是不使用优惠券---
  2972 + if (no_use == 1) {
  2973 + console.log("有进来吗券", no_use);
  2974 + if (using_quan[th.data.selected_quan_pick]) {
  2975 + using_quan[th.data.selected_quan_pick].is_nouse_red = 1;
  2976 + }
  2977 + else {
  2978 + using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1};
  2979 + }
  2980 + this.setData({using_quan: using_quan, is_coupon: 2222});
  2981 + return;
  2982 + }
  2983 +
  2984 +
  2985 + var txt = "selected_quan_list[" + ind + "].show_red";
  2986 + var obj = {};
  2987 + obj[txt] = 1;
  2988 + if (quan_item.show_red) {
  2989 + obj[txt] = 0;
  2990 + }
  2991 + this.setData(obj);
  2992 + console.log(this.data.selected_quan_list, "选中的券的下标", quan_item, "数据都在这里", txt);
  2993 + if (using_quan[th.data.selected_quan_pick]) {
  2994 + using_quan[th.data.selected_quan_pick].is_nouse_red = 0;
  2995 + }
  2996 + else {
  2997 + using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0};
  2998 + }
  2999 + this.setData({using_quan: using_quan});
  3000 +
  3001 + },
  3002 +
  3003 +
  3004 + /*----- 点击选择包邮券 -----*/
  3005 + sele_quan_item_by: function (e) {
  3006 + var no_use = e.currentTarget.dataset.no;
  3007 + //立即购买的包邮券
  3008 + var by_quanlist = this.data.get_by_quan_list;
  3009 + if (by_quanlist) {
  3010 + //---所有的券的显示红色选择都清理一遍---
  3011 + for (var ind in by_quanlist) {
  3012 + by_quanlist[ind].show_red = 0;
  3013 + }
  3014 + this.setData({get_by_quan_list: by_quanlist});
  3015 + }
  3016 +
  3017 + //--购物车过来的包邮券--
  3018 + var by_cart_list = this.data.by_quan_list_cart;
  3019 + if (by_cart_list) {
  3020 + //---所有的券的显示红色选择都清理一遍---
  3021 + for (var ind in by_cart_list) {
  3022 + by_cart_list[ind].show_red = 0;
  3023 + }
  3024 + this.setData({by_quan_list_cart: by_cart_list});
  3025 + }
  3026 + //普通券
  3027 + var quanlist = this.data.selected_quan_list;
  3028 + if (quanlist) {
  3029 + //---所有的券的显示红色选择都清理一遍---
  3030 + for (var ind in quanlist) {
  3031 + quanlist[ind].show_red = 0;
  3032 + }
  3033 + this.setData({selected_quan_list: quanlist});
  3034 + }
  3035 +
  3036 + var th = this;
  3037 + var using_quan = this.data.using_quan;
  3038 + //---如果是不使用优惠券---
  3039 + if (no_use == 1) {
  3040 + if (using_quan[th.data.selected_quan_pick]) {
  3041 + using_quan[th.data.selected_quan_pick].is_nouse_red = 1;
  3042 + }
  3043 + else {
  3044 + using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1};
  3045 + }
  3046 + this.setData({using_quan: using_quan, is_coupon: 2222});
  3047 + return;
  3048 + }
  3049 +
  3050 + var pickid = th.data.selected_quan_pick; //现在选择的是哪一个门店
  3051 + var ind = e.currentTarget.dataset.ind;
  3052 + //--如果是立即购买的部分--
  3053 + var txt = "";
  3054 + var txt1 = "";
  3055 + var quan_item = null;
  3056 + if (th.data.is_b_now) {
  3057 + quan_item = this.data.get_by_quan_list[ind];
  3058 + txt = "get_by_quan_list[" + ind + "].show_red";
  3059 + var obj = {};
  3060 + obj[txt] = 1;
  3061 + this.setData(obj);
  3062 + } else {
  3063 + txt = "by_quan_list_cart[" + ind + "].show_red";
  3064 + quan_item = th.data.by_quan_list_cart[ind];
  3065 + var obj = {};
  3066 + obj[txt] = 1;
  3067 + this.setData(obj);
  3068 + th.data.get_by_quan_list_cart[pickid] = JSON.parse(JSON.stringify(th.data.by_quan_list_cart)); //要把选中的弄回数组
  3069 + }
  3070 +
  3071 + if (using_quan[th.data.selected_quan_pick]) {
  3072 + using_quan[th.data.selected_quan_pick].is_nouse_red = 0;
  3073 + }
  3074 + else {
  3075 + using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0};
  3076 + }
  3077 + this.setData({using_quan: using_quan});
  3078 + },
  3079 +
  3080 + //--确认使用券---
  3081 + confirm_quan: function () {
  3082 + var using_quan = this.data.using_quan; //正在使用中的券列表
  3083 + var pickid = this.data.selected_quan_pick; //选中的门店ID
  3084 + var th = this;
  3085 + var selected_quan_list = this.data.selected_quan_list; //选择了那个门店的券列表
  3086 + var get_by_quan_list = this.data.get_by_quan_list; //立即购买的包邮券列表
  3087 + var by_quan_list_cart = this.data.by_quan_list_cart; //购物车购买的包邮券列表
  3088 + //选择了的券
  3089 + var sele_quan = null;
  3090 +
  3091 + //循环普通的券
  3092 + for (var i in selected_quan_list) {
  3093 + var item = selected_quan_list[i];
  3094 + if (item.show_red) {
  3095 + th.insert_into_using_quan(item, using_quan, pickid);
  3096 + return;
  3097 + }
  3098 + }
  3099 + //循环包邮的券,立即购买的
  3100 + for (var i in get_by_quan_list) {
  3101 + var item = get_by_quan_list[i];
  3102 + if (item.show_red) {
  3103 + if (th.data.is_no_by[pickid] == 1) {
  3104 + getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th);
  3105 + return false;
  3106 + }
  3107 + if (th.data.is_by[pickid] == 1) {
  3108 + getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th);
  3109 + return false;
  3110 + }
  3111 +
  3112 + th.insert_into_using_quan(item, using_quan, pickid, 1);
  3113 + return;
  3114 + }
  3115 + }
  3116 +
  3117 + //循环包邮的券
  3118 + for (var i in by_quan_list_cart) {
  3119 + var item = by_quan_list_cart[i];
  3120 + if (item.show_red) {
  3121 + if (th.data.is_no_by[pickid] == 1) {
  3122 + getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th);
  3123 + return false;
  3124 + }
  3125 + if (th.data.is_by[pickid] == 1) {
  3126 + getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th);
  3127 + return false;
  3128 + }
  3129 + th.insert_into_using_quan(item, using_quan, pickid, 1);
  3130 + return;
  3131 + }
  3132 + }
  3133 +
  3134 + //选择了的券,看是不是点击了不使用券,点击了不使用优惠券
  3135 + if (using_quan[pickid]) {
  3136 + if (using_quan[pickid].is_nouse_red == 1) {
  3137 + using_quan[pickid] = {is_nouse_red: 1};
  3138 + th.setData({using_quan: using_quan});
  3139 + if (th.data.is_b_now == 1) {
  3140 + th.calculatePrice2();
  3141 + } else {
  3142 + th.calculatePrice();
  3143 + }
  3144 + th.setData({open_quan: 0});
  3145 + return;
  3146 + }
  3147 + }
  3148 + },
  3149 +
  3150 + //----把券插入之后的操作,同时还要重新计算价格----
  3151 + insert_into_using_quan: function (item, using_quan, pickid, isby) {
  3152 + var th = this;
  3153 + if (isby == 1) {
  3154 + using_quan[pickid] = {
  3155 + coupon_no: item.no,
  3156 + money: 0,
  3157 + is_nouse_red: 0,
  3158 + region_list: item.region_list,
  3159 + goods_list: item.goods_list
  3160 + };
  3161 + using_quan[pickid].isby = 1;
  3162 + } else {
  3163 + using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0};
  3164 + using_quan[pickid].isby = 0;
  3165 + }
  3166 + this.setData({using_quan: using_quan});
  3167 + if (th.data.is_b_now == 1) {
  3168 + th.calculatePrice2();
  3169 + } else {
  3170 + th.calculatePrice();
  3171 + }
  3172 + th.setData({open_quan: 0});
  3173 + },
  3174 +
  3175 + cart_set_err: function (e) {
  3176 + var txt = e.currentTarget.dataset.err;
  3177 + var ob = {};
  3178 + ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif";
  3179 + this.setData(ob);
  3180 + },
  3181 + //--验证是否已经冻结--
  3182 + check_is_frozenQuan: function (quanlist, frozenQuan, isby) {
  3183 + console.log("券列表", quanlist);
  3184 + if (!quanlist) return null;
  3185 + if (!frozenQuan) return quanlist;
  3186 + var arr = [];
  3187 + for (var i = 0; i < quanlist.length; i++) {
  3188 + var item = quanlist[i];
  3189 + var is_find = 0;
  3190 + var Q_no = quanlist[i].CashRepNo;
  3191 + if (isby) Q_no = quanlist[i].no;
  3192 + for (var j = 0; j < frozenQuan.length; j++) {
  3193 + var q_no = frozenQuan[j].cashRepNo;
  3194 + if (Q_no == q_no) {
  3195 + is_find = 1;
  3196 + break;
  3197 + }
  3198 + }
  3199 + if (!is_find) arr.push(item);
  3200 + }
  3201 + return arr;
  3202 + },
  3203 +
  3204 + //// 开启物流的弹窗
  3205 + show_wu_arr: function (e) {
  3206 + var wu_arr_txt = e.currentTarget.dataset.txt;
  3207 + var w_sele_index = e.currentTarget.dataset.w_sele_index;
  3208 + var is_express = null;
  3209 + var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1};
  3210 +
  3211 + //--如果是多个门店的时候--
  3212 + if (w_sele_index != undefined) {
  3213 + is_express = this.data.cartlist[w_sele_index].wind;
  3214 + ob['is_express'] = is_express;
  3215 + }
  3216 + this.setData(ob);
  3217 + },
  3218 + // 关闭物流的弹窗
  3219 + close_express: function () {
  3220 + this.setData({open_express: 0, disabled: 0});
  3221 + },
  3222 + // 选择物流
  3223 + click_express_name: function (e) {
  3224 + var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
  3225 + var index = e.currentTarget.dataset.idxe;
  3226 + var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0};
  3227 + ob[this.data.wu_arr_txt] = index;
  3228 + this.setData(ob);
  3229 + },
  3230 +
  3231 + //点击确定物流
  3232 + determine_expres: function (e) {
  3233 + this.setData({open_express: 0});
  3234 + if (this.data.is_b_now == 1)
  3235 + this.calculatePrice2();
  3236 + else
  3237 + this.calculatePrice();
  3238 + },
  3239 +
  3240 + //点击打开优惠券使用说明
  3241 + clik_coupons: function (e) {
  3242 + var ind = e.currentTarget.dataset.idx;
  3243 + var is_open = this.data.selected_quan_list[ind].is_open;
  3244 +
  3245 + if (is_open == 1) is_open = 0;
  3246 + else is_open = 1;
  3247 +
  3248 + var txt = "selected_quan_list[" + ind + "].is_open"
  3249 + var obj = {};
  3250 + obj[txt] = is_open;
  3251 +
  3252 + this.setData(obj);
  3253 + this.setData({disabled: 1})
  3254 + },
  3255 +
  3256 + clik_coupons2: function (e) {
  3257 + var ind = e.currentTarget.dataset.idx;
  3258 + var is_open = this.data.get_by_quan_list[ind].is_open;
  3259 +
  3260 + if (is_open == 1) is_open = 0;
  3261 + else is_open = 1;
  3262 +
  3263 + var txt = "get_by_quan_list[" + ind + "].is_open"
  3264 + var obj = {};
  3265 + obj[txt] = is_open;
  3266 +
  3267 + this.setData(obj);
  3268 + this.setData({disabled: 1})
  3269 + },
  3270 +
  3271 +
  3272 + //设置默认物流
  3273 + select_default_logistics: function () {
  3274 + var th = this;
  3275 + var is_shipping_code = this.data.is_shipping_code
  3276 + getApp().request.put("/api/weshop/users/update", {
  3277 + data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code},
  3278 + success: function (rse) {
  3279 + if (rse.data.code == 0) {
  3280 + getApp().globalData.userInfo.def_exp_code = is_shipping_code;
  3281 + th.setData({open_express: 0});
  3282 + //----计算此时购物车的价格----
  3283 + if (th.data.is_b_now == 1) th.calculatePrice2();
  3284 + else th.calculatePrice();
  3285 + }
  3286 + }
  3287 + })
  3288 + },
  3289 +
  3290 + //更新下默认,在onshow里面
  3291 + update_code(){
  3292 + var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
  3293 + //--定时器,判断wu_arr不未空--
  3294 + var uii = setInterval(function () {
  3295 + if (th.data.wu_arr) {
  3296 + clearInterval(uii);
  3297 + for (var k = 0; k < th.data.wu_arr.length; k++) {
  3298 + var item = th.data.wu_arr[k];
  3299 + if (def_exp_code == item.code) {
  3300 + m_wind = k;
  3301 + }
  3302 + }
  3303 + //--如果是立即购买--
  3304 + if (th.data.is_b_now == 1) {
  3305 + th.setData({index: m_wind, is_express: m_wind});
  3306 + } else {
  3307 + var ui = setInterval(function () {
  3308 + if (th.data.cartlist) {
  3309 + var c_arr = th.data.cartlist;
  3310 + for (var i in c_arr) {
  3311 + c_arr[i].wind = m_wind;
  3312 + }
  3313 + th.setData({cartlist: c_arr, is_express: m_wind})
  3314 + clearInterval(ui);
  3315 + }
  3316 + }, 500)
  3317 + }
  3318 + }
  3319 + }, 500);
  3320 + },
  3321 + //-----获取购物车进来的劵-------
  3322 + get_cart_quan: async function (order_prom_list_cart) {
  3323 + var th = this;
  3324 + var is_xz_yh = 1;
  3325 + //等待值的出现
  3326 + //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () {
  3327 + //var arr=th.data.order_prom_list_cart;
  3328 + var arr = order_prom_list_cart;
  3329 + if (!arr) arr = [];
  3330 + //如果系统有限制使用优惠券
  3331 + if (th.data.is_close_quan) return false;
  3332 +
  3333 + //------------开始计算使用优惠券相关------------
  3334 + for (var ind in arr) {
  3335 + var ep = arr[ind];
  3336 + var goodlist = ep.goods;
  3337 + var pickup_id = ep.pickup_id;
  3338 + //--更优惠券抵用有关,立即购买的,如果是购物车,如果有等级价还有考虑等级价的东西
  3339 + //就要把相应的值,写入cartlist数组中--
  3340 + var ckeck_quan_price = 0,
  3341 + check_quan_price_list = '',
  3342 + check_quan_ware_list = '';
  3343 +
  3344 + for (var i in goodlist) {
  3345 + var gd = goodlist[i];
  3346 + //--如果是秒杀就跳出,如果是赠品,如果是组合购,如果是限制使用优惠券--
  3347 + if (gd.prom_type == 1 || gd.is_gift || gd.prom_type == 7) {
  3348 + continue;
  3349 + }
  3350 + //如果有限制使用优惠券,就要返回
  3351 + if (gd.prom_type == 3) {
  3352 + if (th.data.prom_goods_map[pickup_id][gd.prom_id].is_xz_yh) continue;
  3353 + th.data.prom_goods_map[pickup_id][gd.prom_id].coupon_sele = 1;
  3354 + }
  3355 + is_xz_yh = 0;
  3356 + var item_price = gd.goods_price * gd.goods_num;
  3357 + //-- 如果有平摊下去,有实收价格的时候,就要用account来计算价格 --
  3358 + if (gd.account_fir != null && gd.account_fir != undefined) {
  3359 + item_price = gd.account_fir * gd.goods_num;
  3360 + }
  3361 + ckeck_quan_price += item_price;
  3362 +
  3363 + //--组装价格list--
  3364 + if (check_quan_price_list) {
  3365 + check_quan_price_list += "," + item_price;
  3366 + } else {
  3367 + check_quan_price_list = item_price;
  3368 + }
  3369 + //--组装商品的线下erpwareid--
  3370 + if (check_quan_ware_list) {
  3371 + check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']);
  3372 + } else {
  3373 + check_quan_ware_list = encodeURIComponent(gd['erpwareid']);
  3374 + }
  3375 + }
  3376 + //优惠券优惠的金额要控制到优惠券的选择条件
  3377 + var cut_price = 0;
  3378 + for (var i in th.data.prom_goods_map[pickup_id]) {
  3379 + var obj = th.data.prom_goods_map[pickup_id][i];
  3380 + if (obj.coupon_sele) {
  3381 + cut_price += obj.price - obj.prom_price;
  3382 + }
  3383 + }
  3384 +
  3385 + arr[ind].ckeck_quan_price = ckeck_quan_price - cut_price;
  3386 + arr[ind].check_quan_ware_list = check_quan_ware_list;
  3387 + arr[ind].check_quan_price_list = check_quan_price_list;
  3388 +
  3389 + //是否关闭使用优惠券
  3390 + if (th.data.is_close_quan != 1 && !is_xz_yh) {
  3391 + //--调用接口,获取优惠券的列表,3秒钟内控制接口请求--
  3392 + var url = "/api/weshop/couponList/getUseCouponList";
  3393 + await app.request.promiseGet(url, {
  3394 + data: {
  3395 + storeId: oo.stoid,
  3396 + userId: app.globalData.user_id,
  3397 + BuySum: ckeck_quan_price,
  3398 + WareIds: check_quan_ware_list,
  3399 + pageSize: 100
  3400 + }
  3401 + }).then(res => {
  3402 + if (res.data.code == 0) {
  3403 + var quan_list = res.data.data.pageData;
  3404 + arr[ind].quan_list = th.check_is_frozenQuan(quan_list, th.data.frozenQuan);
  3405 + }
  3406 + })
  3407 + }
  3408 + }
  3409 +
  3410 + //如果是搭配购的立即购买的时候
  3411 + if (th.data.is_b_now) {
  3412 + if (arr && arr.length > 0) {
  3413 + var quanlist = arr[0].quan_list;
  3414 + th.setData({selected_quan_list: quanlist, cartlist: arr})
  3415 + }
  3416 + } else {
  3417 + th.setData({cartlist: arr})
  3418 + th.set_can_num();
  3419 + }
  3420 +
  3421 + //})
  3422 + },
  3423 +
  3424 + //------ 获取立即购买的购物车的劵 --------
  3425 + get_buy_now_quan: function () {
  3426 + var quanlist = null, th = this, frozenQuan = null;
  3427 + var good = this.data.bn_goods;
  3428 + if (good.prom_price) {
  3429 + th.data.ckeck_quan_price = good.prom_price; //如果有优惠价,就用优惠价
  3430 + } else if (good.is_offline) {
  3431 + th.data.ckeck_quan_price = good.offline_price; //如果有线下取价,就用线下价
  3432 + }
  3433 + //--如果商家后台没有限制使用优惠券,同时商品的优惠活动没有限制使用优惠券--
  3434 + if (th.data.is_close_quan != 1 && th.data.bn_goods.is_xz_yh != 1) {
  3435 + var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
  3436 + var url = "/api/weshop/couponList/getUseCouponList";
  3437 + app.request.promiseGet(url0, {1: 1}).then(res => {
  3438 + if (res.data.code == 0) {
  3439 + frozenQuan = res.data.data;
  3440 + th.data.frozenQuan = frozenQuan;
  3441 + }
  3442 + app.request.time_limit_get(6, url, {
  3443 + data: {
  3444 + storeId: oo.stoid,
  3445 + userId: app.globalData.user_id,
  3446 + BuySum: th.data.ckeck_quan_price,
  3447 + WareIds: encodeURIComponent(th.data.check_quan_ware_list),
  3448 + pageSize: 100
  3449 + },
  3450 + success: function (res) {
  3451 + if (res.data.code == 0) {
  3452 + quanlist = res.data.data.pageData;
  3453 + if (quanlist) {
  3454 + quanlist = th.check_is_frozenQuan(quanlist, frozenQuan);
  3455 + th.setData({selected_quan_list: quanlist})
  3456 + }
  3457 + }
  3458 + }
  3459 + })
  3460 + })
  3461 + }
  3462 + },
  3463 +
  3464 + //检查区域是不是包邮
  3465 + check_area: function (arr) {
  3466 + var user_addr = this.data.user_addr;
  3467 + if (!user_addr) return 0;
  3468 + for (var i in arr) {
  3469 + var item = arr[i];
  3470 + if (user_addr.twon == item || user_addr.district == item
  3471 + || user_addr.city == item || user_addr.province == item) {
  3472 + return 0;
  3473 + }
  3474 + }
  3475 + return 1;
  3476 + },
  3477 +
  3478 + //检查立即购买的商品是不是不包邮
  3479 + check_good: function (arr, goods_id) {
  3480 + if (!goods_id) goods_id = this.data.bn_goods.goods_id;
  3481 + for (var i in arr) {
  3482 + var item = arr[i];
  3483 + if (goods_id == item) return 0;
  3484 + }
  3485 + return 1;
  3486 + },
  3487 + check_by_area: function (region_list) {
  3488 + var arr = region_list.split(",");
  3489 + var check = this.check_area(arr);
  3490 + return !check;
  3491 + },
  3492 + check_by_goods: function (goods_list, goods_id) {
  3493 + var arr = goods_list.split(",");
  3494 + var check = this.check_good(arr, goods_id);
  3495 + return !check;
  3496 + },
  3497 + //立即购买获取优惠活动的内容
  3498 + buy_now_prom_goods: function (prom_id, arr, func) {
  3499 + var price = arr.shop_price * arr.goods_num;
  3500 + var prom = null;
  3501 + getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + prom_id, {}).then(res => {
  3502 + if (res.data.code == 0) {
  3503 + prom = res.data.data;
  3504 + return getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
  3505 + data: {
  3506 + price: price,
  3507 + prom_id: prom_id,
  3508 + goods_num: arr.goods_num,
  3509 + user_id: getApp().globalData.user_id,
  3510 + is_bz: prom.is_bz
  3511 + }
  3512 + })
  3513 + } else {
  3514 + func(arr);
  3515 + }
  3516 + }).then(res => {
  3517 + if (res.data.code == 0) {
  3518 + var get_data = res.data.data;
  3519 + arr.is_bz = prom.is_bz; //是不是倍增
  3520 + arr.is_xz_yh = prom.is_xz_yh; //是不是优惠
  3521 + arr.bs = get_data.bs; //是不是倍数
  3522 + arr.is_past = get_data.is_past; //是不是包邮
  3523 + arr.prom_price = get_data.price >= 0 ? get_data.price : price;
  3524 + arr.s_intValue = get_data.intValue;
  3525 + arr.s_coupon_id = get_data.coupon_id;
  3526 + arr.s_coupon_num = get_data.coupon_num;
  3527 + //-- 看是不是有赠品 --
  3528 + if (get_data.gift_id) {
  3529 + arr.gift_id = get_data.gift_id;
  3530 + arr.gift_goods_id = get_data.goods_id;
  3531 + arr.gift_goods_name = get_data.goods_name;
  3532 + arr.gift_goods_color = get_data.goodsinfo.goods_color;
  3533 + arr.gift_goods_spec = get_data.goodsinfo.goods_spec;
  3534 + arr.gift_original_img = get_data.goodsinfo.original_img;
  3535 + arr.gift_weight = get_data.goodsinfo.weight;
  3536 + arr.gift_exp_sum_type = get_data.goodsinfo.exp_sum_type;
  3537 + arr.gift_uniform_exp_sum = get_data.goodsinfo.uniform_exp_sum;
  3538 + arr.gift_limit_num = get_data.limit_num;
  3539 + arr.gift_storecount = get_data.gift_storecount;
  3540 + }
  3541 + arr.s_libao = get_data.libao;
  3542 + arr.s_lb_num = get_data.lb_num;
  3543 + arr.prom_id = prom_id;
  3544 + }
  3545 + func(arr);
  3546 + })
  3547 + },
  3548 + //--检查订单优惠--
  3549 + check_is_order_prom: function (condition, func, pick) {
  3550 + var th = this;
  3551 + if (this.data.is_b_now == 1) pick = this.data.bn_pick;
  3552 + //---获取订单优惠---
  3553 + getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
  3554 + data: {store_id: os.stoid, orderAmount: condition}
  3555 + }).then(res => {
  3556 + if (res.data.code == 0) {
  3557 + var data = res.data.data;
  3558 + th.data.order_prom[pick] = data;
  3559 + }
  3560 + func();
  3561 + })
  3562 + },
  3563 +
  3564 + //--- 加入优惠活动的映射中,同时要有一个good列表 ---
  3565 + add_prom_goods_map: async function (item) {
  3566 + var th = this;
  3567 + var pickid = item.pick_id;
  3568 + var map = th.data.prom_goods_map;
  3569 + var obj = map[pickid];
  3570 +
  3571 + if (map[pickid]) {
  3572 + if (map[pickid][item.prom_id]) {
  3573 + var ob = map[pickid][item.prom_id];
  3574 + ob.price += item.goods_price * item.goods_num;
  3575 + ob.goods_num += item.goods_num;
  3576 + ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
  3577 +
  3578 + } else {
  3579 + var prom = null;
  3580 + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
  3581 + if (res.data.code == 0) {
  3582 + prom = res.data.data;
  3583 + }
  3584 + })
  3585 + var ob = {};
  3586 + ob.prom_id = item.prom_id;
  3587 + ob.price = item.goods_price * item.goods_num;
  3588 + ob.goods_num = item.goods_num;
  3589 + ob.is_bz = prom.is_bz;
  3590 + ob.is_xz_yh = prom.is_xz_yh;
  3591 + ob.goods = new Array();
  3592 + ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
  3593 + map[pickid][item.prom_id] = ob;
  3594 + }
  3595 + } else {
  3596 + var ob = {};
  3597 + var prom = null;
  3598 + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
  3599 + if (res.data.code == 0) {
  3600 + prom = res.data.data;
  3601 + }
  3602 + })
  3603 + ob.prom_id = item.prom_id;
  3604 + ob.price = item.goods_price * item.goods_num;
  3605 + ob.goods_num = item.goods_num;
  3606 + ob.is_bz = prom.is_bz;
  3607 + ob.is_xz_yh = prom.is_xz_yh;
  3608 + ob.goods = new Array();
  3609 + ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
  3610 +
  3611 + var obj = {};
  3612 + obj[item.prom_id] = ob;
  3613 + map[pickid] = obj;
  3614 +
  3615 + }
  3616 + },
  3617 +
  3618 + //计算立即购买赠品的物流费用
  3619 + get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) {
  3620 + var good = this.data.buy_now_gift_goods;
  3621 + var goods_weight = -1, goods_piece = -1;
  3622 + var gift_shipping_price = 0;
  3623 + var th = this;
  3624 + switch (good['exp_sum_type']) {
  3625 + case 1:
  3626 + //统一运费
  3627 + gift_shipping_price += good['uniform_exp_sum'];
  3628 + gift_shipping_price += o_shipping_price;
  3629 + break;
  3630 + case 2:
  3631 + if (goods_weight < 0) goods_weight = 0;
  3632 + //累积商品重量 每种商品的重量 * 数量
  3633 + goods_weight += good['weight'] * good['buynum'];
  3634 + if (goods_weight1 > 0) {
  3635 + goods_weight += goods_weight1;
  3636 + }
  3637 + break;
  3638 + case 3:
  3639 + if (goods_piece < 0) goods_piece = 0;
  3640 + //累积商品数量
  3641 + goods_piece += good['buynum'];
  3642 + if (goods_piece1) {
  3643 + goods_piece += goods_piece1;
  3644 + }
  3645 + break;
  3646 + }
  3647 +
  3648 +
  3649 + //如果有设置不包邮区域的时候
  3650 + if (no_by_data && no_by_data.region_list) {
  3651 + if (th.check_by_area(no_by_data.region_list)) {
  3652 + gift_freight_free = 0;
  3653 + th.data.is_no_by[th.data.bn_pick] = 1;
  3654 + }
  3655 + }
  3656 + //如果有设置不包邮商品
  3657 + if (no_by_data && no_by_data.goods_list && gift_freight_free) {
  3658 + if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) {
  3659 + gift_freight_free = 0;
  3660 + //th.data.is_no_by[th.data.bn_pick]=1;
  3661 + }
  3662 + }
  3663 +
  3664 + var t_shipping_price =
  3665 + this.calculatewuliu(code, gift_shipping_price, goods_weight,
  3666 + goods_piece, user_addr, gift_freight_free, allpice, rs);
  3667 + return t_shipping_price;
  3668 +
  3669 + },
  3670 +
  3671 + //从优惠的映射中拿出商品从表的item
  3672 + item_map_get_goods: function (goods_id, map) {
  3673 + for (var i in map.goods) {
  3674 + if (map.goods[i].goods_id == goods_id) return map.goods[i];
  3675 + }
  3676 + },
  3677 + //从优惠的映射中拿出商品从表的item
  3678 + arr_get_goods: function (goods_id, arr) {
  3679 + for (var i in arr) {
  3680 + if (arr[i].goods_id == goods_id) return arr[i];
  3681 + }
  3682 + },
  3683 +
  3684 + //检查是不是有其他门店的订单在选择了券
  3685 + check_other_use: function (iter, pkid) {
  3686 + var using = this.data.using_quan;
  3687 + var is_use = 0;
  3688 + if (using) {
  3689 + for (var i in using) {
  3690 + if (i == pkid) continue;
  3691 + if (iter.CashRepNo == using[i].coupon_no) {
  3692 + is_use = 1;
  3693 + break;
  3694 + }
  3695 + }
  3696 + }
  3697 + return is_use;
  3698 + },
  3699 + //检查是不是有其他门店的订单在选择了包邮券
  3700 + check_other_use_by: function (iter, pkid) {
  3701 + var using = this.data.using_quan;
  3702 + var is_use = 0;
  3703 + if (using) {
  3704 + for (var i in using) {
  3705 + if (i == pkid) continue;
  3706 + if (iter.no == using[i].coupon_no) {
  3707 + is_use = 1;
  3708 + break;
  3709 + }
  3710 + }
  3711 + }
  3712 + return is_use;
  3713 + },
  3714 +
  3715 + //跳转到购买卡
  3716 + buycard: function () {
  3717 + getApp().goto("/pages/user/plus/plus");
  3718 + getApp().globalData.plus_buy_back = 1;
  3719 + },
  3720 +
  3721 + //跳转关闭弹出框的显示
  3722 + close_offline: function () {
  3723 + this.setData({is_offline_show: 0});
  3724 + },
  3725 +
  3726 + //立即购买显示弹出框
  3727 + bn_pop_offline: function () {
  3728 + var off_price = this.data.bn_goods.shop_price - this.data.bn_goods.offline_price;
  3729 + //是不是线下
  3730 + var is_get_offline = this.data.bn_goods.is_offline;
  3731 + this.setData({is_offline_show: 1, show_off_price: off_price.toFixed(2), is_get_offline: is_get_offline});
  3732 + },
  3733 +
  3734 + //确定使用线下取价
  3735 + sure_offline: function () {
  3736 + var bn_goods = this.data.bn_goods;
  3737 + if (bn_goods && bn_goods.prom_type == 0) {
  3738 + bn_goods.is_offline = 1;
  3739 + this.setData({is_offline_show: 0, bn_goods: bn_goods});
  3740 + this.calculatePrice2();
  3741 + }
  3742 + //就是购物车结算时的
  3743 + else {
  3744 + var index = this.data.pop_offline_index;
  3745 + var txt = "cartlist[" + index + "].is_offline";
  3746 + this.setData({[txt]: 1, is_offline_show: 0,});
  3747 + this.data.old_cartlist[index].is_offline = 1;
  3748 + this.calculatePrice();
  3749 + }
  3750 + },
  3751 +
  3752 +
  3753 + //取消使用线下取价
  3754 + cancle_offline: function () {
  3755 + //判断是不是立即购买
  3756 + var bn_goods = this.data.bn_goods;
  3757 + if (bn_goods && bn_goods.prom_type == 0) {
  3758 + bn_goods.is_offline = 0;
  3759 + this.setData({is_offline_show: 0, bn_goods: bn_goods});
  3760 + this.calculatePrice2();
  3761 + }
  3762 + //就是购物车结算时的
  3763 + else {
  3764 + var index = this.data.pop_offline_index;
  3765 + var txt = "cartlist[" + index + "].is_offline";
  3766 + this.setData({[txt]: 0, is_offline_show: 0,})
  3767 + this.data.old_cartlist[index].is_offline = 0;
  3768 + this.calculatePrice();
  3769 + }
  3770 + },
  3771 +
  3772 + //-- 弹出购物车选择是不是要店铺优惠 --
  3773 + cart_pop_offline: function (e) {
  3774 + var index = e.currentTarget.dataset.index;
  3775 + var item = this.data.cartlist[index];
  3776 + var off_price = item.offline_price;
  3777 + //是不是线下
  3778 + var is_get_offline = item.is_offline;
  3779 + this.setData({
  3780 + pop_offline_index: index,
  3781 + is_offline_show: 1,
  3782 + show_off_price: off_price.toFixed(2),
  3783 + is_get_offline: is_get_offline
  3784 + });
  3785 + },
  3786 +
  3787 + // 是否同意预售商品不退定金
  3788 + switchChange(e) {
  3789 + let isSwitchOn = e.detail;
  3790 + }
  3791 +
  3792 +
  3793 +});
... ...
packageC/pages/payForAnother/payForAnother.json 0 → 100644
  1 +{
  2 + "navigationBarTitleText": "代付付款",
  3 + "enablePullDownRefresh": false,
  4 + "usingComponents": {}
  5 +}
0 6 \ No newline at end of file
... ...
packageC/pages/payForAnother/payForAnother.wxml 0 → 100644
  1 +<!-- <wxs module="filter" src="c_filter.wxs"></wxs> -->
  2 +<!-- <wxs src="filter.wxs" module="util"></wxs> -->
  3 +<wxs module="filters" src="../../../utils/filter.wxs"></wxs>
  4 +
  5 +<view>
  6 + <view class="top">
  7 + <view class="avatar-container"><image class="img-block"></image></view>
  8 + <view class="pdl20 white">
  9 + <view>微信昵称</view>
  10 + <view class="fs26 pdt20">“我有一笔订单需要支付,请帮我代付吧,非常感谢你~”</view>
  11 + </view>
  12 + </view>
  13 +
  14 +
  15 + <view class="pdh20">
  16 + <view class="information bdr14 mgt20 pd20 t-c">
  17 + <view class="fs30">代付金额</view>
  18 + <view class="pdt20 fs50 rmb">100.00</view>
  19 + </view>
  20 +
  21 + <view class="information bdr14 mgt20 fs26">
  22 + <view class="pd20 bdb">代付订单信息</view>
  23 + <view>
  24 + <view class="use-item bfff bdr_t-14 mgt20">
  25 + <image class="dp" src='{{imgUrl}}/miniapp/images/goodscategory/new_store.png'></image>
  26 + <view>{{bn_pickname}}门店名称</view>
  27 + </view>
  28 + <view class="order-detail">
  29 + <view class="goods-img">
  30 + <image class="wh100 bdr14" src="{{bn_goods.original_img}}" binderror='cart_set_err' data-err="bn_goods.original_img"></image>
  31 + </view>
  32 + <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{bn_goods.goods_id}}">
  33 + <view class="goods-name ellipsis-2">{{bn_goods.goods_name}}商品名称</view>
  34 + <!-- 商品属性 -->
  35 + <view class="flex-vertical fs28 xc-ash color-gray n_guige">
  36 + <view class="goods-color">
  37 + <block><text>{{filters.show_gui_ge(bn_goods.goods_spec,bn_goods.goods_color)}}规格1</text></block>
  38 + <!--<block wx:if="{{!bn_goods.goods_spec && !bn_goods.goods_color}}"><text>规格1</text></block>-->
  39 + <!--<block wx:else>-->
  40 + <!--<text wx:if="{{bn_goods.goods_spec!=''}}">{{bn_goods.goods_spec}}<text wx:if="{{bn_goods.goods_color}}">/</text></text>-->
  41 + <!--<text wx:if="{{bn_goods.goods_color}}">{{bn_goods.goods_color}}</text>-->
  42 + <!--</block>-->
  43 + </view>
  44 + </view>
  45 +
  46 + <!-- ---商品名称规格---- -->
  47 + <view class="order-num flex-space-between">
  48 + <view class="co-red">¥<text class="fs36">9.00{{filters.toFix(bn_goods.shop_price,2)}}</text></view>
  49 + <view class="goods-num">x1{{bn_goods.buynum}}</view>
  50 + </view>
  51 + </navigator>
  52 +
  53 + </view>
  54 + </view>
  55 + </view>
  56 +
  57 + <view class="information bdr14 mgt20 pd20 fs26 xc-black3">
  58 + <view class="bold pdv10">代付说明:</view>
  59 + <view class="pdt10">1、代付产品是为了便利亲友之间的付款而设计,请您务必和亲友确认后再付款。</view>
  60 + <view class="pdt10">2、如果发生退款,已支付金额将原路退回付款人。</view>
  61 + <view class="pdt10">3、付款金额以当前页面展示为准。</view>
  62 + </view>
  63 + </view>
  64 +
  65 + <view class="fixedToBottom shadow-1">
  66 + <view class="btn-wrap">
  67 + <button class="tips-btn" formType="submit" id="submitOrder"><text class="iconfont icon-aixin"></text> 慷慨付款</button>
  68 + </view>
  69 + </view>
  70 +
  71 +</view>
  72 +
... ...
packageC/pages/payForAnother/payForAnother.wxss 0 → 100644
  1 +.bdr_t-14 {
  2 + border-top-left-radius: 14rpx;
  3 + border-top-right-radius: 14rpx;
  4 +}
  5 +.bdr_b-14 {
  6 + border-bottom-left-radius: 14rpx;
  7 + border-bottom-right-radius: 14rpx;
  8 +}
  9 +.bdr14 {
  10 + border-radius: 14rpx;
  11 +}
  12 +.mgt20 {
  13 + margin-top: 20rpx;
  14 +}
  15 +.shadow {
  16 + box-shadow: 0 4rpx 12px #e7e9eb;
  17 +}
  18 +.shadow-1 {
  19 + box-shadow: 16rpx 0px 12px #e7e9eb;
  20 +}
  21 +
  22 +
  23 +
  24 +
  25 +page {
  26 + /* background-color: #FAFAFA; */
  27 + background-color: #F0F0F0;
  28 + padding-bottom: 140rpx;
  29 + /* padding: 0 22rpx; */
  30 + /* box-sizing: border-box; */
  31 +}
  32 +.container {
  33 + background-color: #F0F0F0;
  34 + /* padding-top: 28rpx; */
  35 + padding-bottom: 280rpx;
  36 +}
  37 +
  38 +.tab-container {
  39 + font-size: 28rpx;
  40 + margin-top: 20rpx;
  41 + display: flex;
  42 +}
  43 +
  44 +.tab-wrapper {
  45 + background-color: #ccc;
  46 + display: flex;
  47 + border-radius: 40rpx;
  48 + overflow: hidden;
  49 +}
  50 +
  51 +.tab {
  52 + padding: 20rpx 30rpx;
  53 +
  54 +}
  55 +
  56 +
  57 +.tab.active {
  58 + background-color: white;
  59 + border-radius: 40rpx;
  60 +}
  61 +
  62 +
  63 +.user-mes {
  64 + position: relative;
  65 + background-color: #fff;
  66 + font-size: 32rpx;
  67 + color: #444;
  68 + /* margin-top: 28rpx; */
  69 + border-radius: 14rpx;
  70 + padding: 20rpx 70rpx 20rpx 20rpx;
  71 +}
  72 +.user-contact {
  73 + /* padding: 24rpx 26rpx;
  74 + font-weight: 600; */
  75 +}
  76 +
  77 +.location {
  78 + position: relative;
  79 + /* padding: 0 70rpx 24rpx; */
  80 +}
  81 +
  82 +.pos-icon {
  83 + /* position: absolute; */
  84 + /* left: 28rpx;
  85 + top: 6rpx; */
  86 + width: 20rpx;
  87 + height: 24rpx;
  88 + display: inline-block;
  89 +}
  90 +
  91 +.border-img {
  92 + width: 100%;
  93 + height: 12rpx;
  94 +}
  95 +
  96 +.update-logistics {
  97 + position: absolute;
  98 + right: 0;
  99 + top: 0;
  100 + width: 80rpx;
  101 + height: 100%;
  102 + display: flex;
  103 + align-items: center;
  104 + justify-content: center;
  105 +}
  106 +
  107 +.arrow-rigth {
  108 + width: 32rpx;
  109 + height: 32rpx;
  110 +}
  111 +
  112 +.order-meg {
  113 + margin-bottom: 20rpx;
  114 + font-size: 28rpx;
  115 +
  116 +}
  117 +
  118 +.order-detail {
  119 + padding: 30rpx 0;
  120 + border-bottom: 2rpx solid #eee;
  121 + color: #777;
  122 + min-height: 190rpx;
  123 + background-color: #fff;
  124 +
  125 +}
  126 +
  127 +.goods-img {
  128 + float: left;
  129 + width: 200rpx;
  130 + height: 200rpx;
  131 + margin: 0 20rpx;
  132 + background-color: #f0f0f0;
  133 +}
  134 +
  135 +.order-cont {
  136 + float: left;
  137 + width: 438rpx;
  138 +}
  139 +
  140 +.goods-name {
  141 + height: 74rpx;
  142 + line-height: 40rpx;
  143 + overflow: hidden;
  144 + margin-bottom: 16rpx;
  145 + font-size: 28rpx;
  146 + color: #333;
  147 +
  148 +}
  149 +
  150 +.goods-color {
  151 + font-size: 24rpx;
  152 +}
  153 +
  154 +.order-num {
  155 + margin-top: 25rpx;
  156 + font-size: 24rpx;
  157 + line-height: 42rpx;
  158 +}
  159 +
  160 +.set-mes{
  161 + background-color: #fff;
  162 + /* margin-top: 20rpx; */
  163 +}
  164 +.use-item{
  165 + display: flex;
  166 + align-items: center;
  167 + /* height: 80rpx; */
  168 + /* border-bottom: 1px solid #ddd; */
  169 + font-size: 26rpx;
  170 + /* width:95%;
  171 +margin:auto; */
  172 + padding: 20rpx;
  173 +}
  174 +.use-item>view{
  175 + display: flex;
  176 + /* margin-right: 12rpx; */
  177 +}
  178 +.use-item.bfff{
  179 + background-color: #fff;
  180 +}
  181 +.use-item .dp{
  182 + display: block;
  183 + width: 40rpx;
  184 + height: 40rpx;
  185 + /* margin-left: -6rpx; */
  186 +}
  187 +
  188 +.set-item {
  189 + justify-content: space-between;
  190 + background-color: #fff;
  191 +}
  192 +
  193 +.set-btn {
  194 + display: flex;
  195 + font-size: 24rpx;
  196 +}
  197 +
  198 +.set-mes input {
  199 + width: 380rpx;
  200 + height: 50rpx;
  201 + line-height: 50rpx;
  202 + border: 1px solid #ddd;
  203 +}
  204 +
  205 +.use-btn {
  206 + width: 100rpx;
  207 + height: 50rpx;
  208 + margin-left: 20rpx;
  209 + line-height: 50rpx;
  210 + text-align: center;
  211 + background-color: #f23030;
  212 + color: #fff;
  213 +}
  214 +
  215 +.coupon-mes {
  216 + /* box-sizing: border-box; */
  217 + /* height:95rpx; */
  218 + padding: 20rpx;
  219 + background-color: #fff;
  220 + font-size: 30rpx;
  221 + /* color: #444; */
  222 + /* width: 100%; */
  223 + border-radius: 14rpx;
  224 + margin-top: 20rpx;
  225 + /* margin-bottom: 20rpx; */
  226 +}
  227 +
  228 +.coupon-title {
  229 + display: flex;
  230 + justify-content: space-between;
  231 + align-items: center;
  232 + height: 92rpx;
  233 +}
  234 +
  235 +.coupon-title>view {
  236 + display: flex;
  237 +}
  238 +
  239 +.coupon-num {
  240 + height: 36rpx;
  241 + margin-left: 20rpx;
  242 + padding: 0 16rpx;
  243 + line-height: 36rpx;
  244 + text-align: center;
  245 + background-color: #f23030;
  246 + color: #fff;
  247 + font-size: 24rpx;
  248 +}
  249 +
  250 +.leave-word {
  251 + position: relative;
  252 + font-size: 24rpx;
  253 + margin-left: 20rpx;
  254 + flex-grow: 1;
  255 +}
  256 +
  257 +.word-box {
  258 + font-size: 26rpx;
  259 + /* width: 600rpx; */
  260 + /* padding: 10rpx;
  261 + height: 28rpx;
  262 + line-height: 40rpx; */
  263 +}
  264 +
  265 +.max-word {
  266 + position: absolute;
  267 + right: 0;
  268 + bottom: 0;
  269 +}
  270 +
  271 +.information {
  272 + /* padding: 20rpx; */
  273 + background-color: #fff;
  274 + /* margin-bottom: 120rpx; */
  275 +}
  276 +
  277 +.information .item {
  278 + display: flex;
  279 + align-items: center;
  280 + justify-content: space-between;
  281 + /* height: 60rpx;
  282 + line-height: 60rpx; */
  283 + font-size: 24rpx;
  284 + /* color: #333; */
  285 + padding: 20rpx;
  286 +}
  287 +
  288 +.btn-wrap {
  289 + /* height: 94rpx;
  290 + box-sizing: border-box;
  291 + display: flex;
  292 + flex-wrap: wrap;
  293 + justify-content: space-between;
  294 + background-color: white;
  295 + align-items: center; */
  296 + background-color: white;
  297 + padding: 20rpx 30rpx;
  298 +}
  299 +
  300 +.fixedToBottom {
  301 + position: fixed;
  302 + bottom: 0;
  303 + left: 0;
  304 + width: 100%;
  305 +}
  306 +
  307 +.tips-btn {
  308 + color: white;
  309 + background-color: #FE4445;
  310 + /* height: 70rpx;
  311 + line-height: 70rpx; */
  312 + /* padding: 0 42rpx; */
  313 + border-radius: 4rpx;
  314 + width: 100%;
  315 + /* margin-left: 0;
  316 + margin-right: 0; */
  317 +}
  318 +
  319 +.pay-amount {
  320 + /* float: right;
  321 + display: flex;
  322 + align-items: center;
  323 + height: 100rpx;
  324 + font-size: 26rpx;
  325 + margin-right: 40rpx; */
  326 +}
  327 +
  328 +.payable {
  329 + color: #444;
  330 + /* margin-right: 20rpx; */
  331 +}
  332 +
  333 +.shipping-modal {
  334 + z-index: 20;
  335 + position: fixed;
  336 + bottom: 0;
  337 + left: 0;
  338 + right: 0;
  339 + overflow-y: hidden;
  340 + color: #666666;
  341 + background-color: white;
  342 +}
  343 +
  344 +.shipping-nav {
  345 + text-align: center;
  346 + font-size: 35rpx;
  347 + padding-top: 30rpx;
  348 +}
  349 +
  350 +.shipping-list {
  351 + padding: 20rpx 30rpx 40rpx;
  352 + font-size: 28rpx;
  353 +}
  354 +
  355 +.shipping-item {
  356 + display: block;
  357 + padding: 20rpx 0;
  358 +}
  359 +
  360 +.shipping-btn {
  361 + width: 100%;
  362 + color: white;
  363 + background-color: #f23030;
  364 + line-height: 90rpx;
  365 + text-align: center;
  366 + font-size: 40rpx;
  367 +}
  368 +
  369 +/*----------nyf新增,地址---------*/
  370 +.add_new{
  371 + height: 90rpx;
  372 + display: flex;
  373 + align-items: center;
  374 + padding: 0 26rpx;
  375 +}
  376 +.addr_jia{width: 45rpx; height: 45rpx; border: 1rpx solid #ddd;
  377 + margin-right: 15rpx;vertical-align: middle;}
  378 +.yu_er{
  379 + margin-left: 10rpx;
  380 + /* margin-right: 60rpx; */
  381 +}
  382 +.wuliu{margin-left: 20rpx;}
  383 +
  384 +
  385 +/*---- 优惠券列表 -----*/
  386 +.xc-coupon-frame{
  387 + width: 100%;
  388 + height: 92rpx;
  389 +
  390 +}
  391 +.xc-coupon-frame .work-frame{
  392 + width: 100%;
  393 + height: 100%;
  394 + border-bottom:3rpx solid #eee;
  395 + padding: 0 26rpx;
  396 + background-color: white;
  397 +}
  398 +.xc-right{
  399 + width:12rpx;
  400 + height:12rpx;
  401 + border-top:2rpx solid #000;
  402 + border-right:2rpx solid #000;
  403 + transform:rotate(45deg);
  404 + display:inline-block;
  405 + margin-left: 10rpx;
  406 +}
  407 +
  408 +.xc-coupon-frame .work-frame .work{ font-size: 30rpx; line-height: 92rpx; }
  409 +.xc-right-frame{font-size: 30rpx;line-height: 92rpx; margin-right: 10rpx }
  410 +
  411 +/* 自定义弹出窗口 */
  412 +.cx-popup{
  413 + width:100%;
  414 + height:880rpx;
  415 + background: #fff;
  416 + z-index: 35;
  417 + border-top-left-radius: 20rpx;
  418 + border-top-right-radius: 20rpx;
  419 + position:fixed;
  420 + bottom:0;
  421 + left: 0;
  422 + /* padding-bottom: 25rpx; */
  423 +}
  424 +
  425 +.cx-popup .top{
  426 + width:95%;
  427 + height:100rpx;
  428 + border-bottom:3rpx solid #ddd;
  429 + margin: auto;
  430 + margin-top: 30rpx;
  431 +
  432 +}
  433 +.xc-top-content{
  434 + width: 93%;
  435 + height:85rpx;
  436 + padding-top: 30rpx;
  437 + font-size: 34rpx;
  438 + font-weight: 600;
  439 +
  440 +}
  441 +
  442 +
  443 +.xc-valid-coupon{
  444 + width: 90%;
  445 + height:40rpx;
  446 + padding-top: 24rpx;
  447 + overflow: hidden;
  448 +}
  449 +.xc-frame{
  450 + width: 100%;
  451 + height:60%;
  452 +}
  453 +
  454 +.xc-frame .list-frame{
  455 + width: 95%;
  456 + height: 100%;
  457 + overflow-y:scroll;
  458 +
  459 +}
  460 +.xc-close-frame{
  461 + margin-top:-10rpx;
  462 +
  463 +}
  464 +
  465 +.xc-close{
  466 + width: 37rpx;
  467 +height: 37rpx;
  468 +border-radius: 50%;
  469 +border: 3rpx solid #333;
  470 +text-align: center;
  471 +line-height: 34rpx;
  472 +font-size: 29rpx;
  473 +color: #333;
  474 +
  475 +}
  476 +.xc-money{
  477 + color: #af2346;
  478 + font-size: 35rpx;
  479 +}
  480 +
  481 +.xc-money-frame{
  482 + margin-left:35rpx;
  483 +
  484 +}
  485 +.xc-coupon-effect{
  486 + width: 99%;
  487 + min-height: 100rpx;
  488 + border-bottom:3rpx solid #ddd;
  489 +
  490 +
  491 +}
  492 +.xc-goods-coupon{
  493 + width: 85%;
  494 + height:100%;
  495 +
  496 +}
  497 +.xc-title{
  498 + width:50%;
  499 + margin-left:222rpx;
  500 +
  501 +}
  502 +.xc-coupon-money0{
  503 + color: #c91e31;
  504 + font-size: 35rpx;
  505 + line-height: 40rpx;
  506 +
  507 +}
  508 +.xc-coupon-money{
  509 + color: #c91e31;
  510 + font-size: 35rpx;
  511 + line-height: 40rpx;
  512 + padding-top: 10px;
  513 +
  514 +}
  515 +.xc-coupon-money1{
  516 + color: #444;
  517 + font-size: 28rpx;
  518 + line-height: 60rpx;
  519 +
  520 +
  521 +}
  522 +.xc-coupon-time{
  523 + height: 50rpx;
  524 + font-size: 27rpx;
  525 + color: #a4a4a4;
  526 +}
  527 +.xc-coupon-time .time{
  528 + margin-left: 15rpx;
  529 + font-size: 27rpx;
  530 +}
  531 +.xc-coupon-selection{
  532 + height:100%;
  533 +}
  534 +
  535 +.xc-confirm {
  536 + width: 50%;
  537 + border-radius: 50rpx;
  538 + height: 80rpx;
  539 + margin:0 auto;
  540 + background:#d60021;
  541 + color:#fff;
  542 + font-size:28rpx;
  543 + margin-top: 28rpx;
  544 +}
  545 +
  546 +.up{ animation: up .7s; }
  547 +.down{ animation: down 1s; }
  548 +@keyframes up { 0% { transform: translateY(550rpx); } 100% { transform: translateY(0); } }
  549 +@keyframes down { 0% { transform: translateY(0); } 100% { transform: translateY(550rpx); } }
  550 +
  551 +.xc-not-Selection{
  552 + width: 40rpx;
  553 +height: 40rpx;
  554 + background: #eeeeee;
  555 +}
  556 +
  557 +
  558 +.xc-close-express{
  559 + width: 40rpx;
  560 +height: 40rpx;
  561 +border-radius: 50%;
  562 +border: 3rpx solid #333;
  563 +text-align: center;
  564 +font-size:32rpx;
  565 +line-height: 38rpx;
  566 +color: #333;
  567 +margin-top: 5rpx;
  568 +}
  569 +.cx-popup .tops{
  570 + width: 100%;
  571 +height: 145rpx;
  572 +border-bottom: 3rpx solid #eee;
  573 +
  574 +}
  575 +.top-content {
  576 + width: 82%;
  577 +padding-top: 33px;
  578 +height: 100%;
  579 +padding-left: 40rpx;
  580 +}
  581 +.close-frame{
  582 + margin-top: 30rpx;
  583 +
  584 +}
  585 +
  586 +.xc-hook {
  587 +width: 33rpx;
  588 +height: 33rpx;
  589 +transform: rotate(-135deg);
  590 +line-height: 35rpx;
  591 +text-align: center;
  592 +margin-right: 20rpx
  593 +
  594 +
  595 +}
  596 +.xc-hooks {
  597 +width: 30rpx;
  598 +height: 30rpx;
  599 +border: 1rpx solid #999;
  600 +margin-right: 20rpx;
  601 +}
  602 +.express_list_frame{
  603 + display: flex;
  604 +height: 80rpx;
  605 +align-items: center;
  606 +padding-left: 40rpx;
  607 +border-bottom: 1rpx solid #eee;
  608 +
  609 +}
  610 +.express_list{
  611 + width: 100%;
  612 + height: 65%;
  613 + overflow-y: auto;
  614 + margin-bottom: 40rpx;
  615 +
  616 +}
  617 +.xc-confirms {
  618 + box-sizing: border-box;
  619 + width: 40%;
  620 + border-radius: 50rpx;
  621 + height: 80rpx;
  622 + margin:0 auto;
  623 + font-size:28rpx;
  624 + background: #fff;
  625 + color: #333;
  626 + border: 2rpx solid #333;
  627 +}
  628 +
  629 +
  630 +/* 优惠券的改版样式 */
  631 +.xc-coupon-frame{
  632 + /* width: 710rpx; */
  633 + width: 100%;
  634 + height:auto;
  635 + margin: 0 auto;
  636 +
  637 +}
  638 +.xc-coupon-frame .coupon-frame{
  639 + width: 100%;
  640 + height: 200rpx;
  641 + margin-top:10rpx;
  642 + border-bottom: 1rpx solid #eee;
  643 +
  644 +}
  645 +.xc-coupon-frame .coupon-frame .coupon-left{
  646 + width: 215rpx;
  647 + height:100%;
  648 + overflow: hidden;
  649 +}
  650 +.xc-money-frames{
  651 + width:96%;
  652 + margin-top: -10px;
  653 +}
  654 +
  655 +.xc-rmb-symbol{
  656 + font-size:40rpx;
  657 +
  658 +}
  659 +
  660 +.xc-rmb-val{
  661 + font-size:60rpx;
  662 +
  663 +}
  664 +.coupon-explain{
  665 + font-size:25rpx;
  666 +width:100%;
  667 +
  668 +
  669 +}
  670 +.xc-valuer{
  671 + margin-top:39rpx;
  672 + margin-left:28rpx;
  673 + font-size:25rpx;
  674 +}
  675 +.coupon-frame .oval{
  676 + width:155rpx;
  677 + height:83rpx;
  678 + border-radius: 50%;
  679 + right:-78rpx;
  680 + top:-37rpx;
  681 +}
  682 +.coupon-right{
  683 + /* width:490rpx; */
  684 + height: 99%;
  685 + border-top: 1rpx solid #eaeaea;
  686 + /* //border-bottom: 1rpx solid #eaeaea; */
  687 + border-right: 1rpx solid #eaeaea;
  688 + flex-grow: 1;
  689 +}
  690 +.coupon-annotation{
  691 + width: 95%;
  692 + height: 100%;
  693 +
  694 +}
  695 +.xc-brand{
  696 + width:100rpx;
  697 + height:35rpx;
  698 + line-height: 35rpx;
  699 + font-size:21rpx;
  700 + border-radius:10rpx; position: relative; top:-1px;
  701 + margin-right: 8rpx
  702 +}
  703 +.top-frame{
  704 + width:82%;
  705 + height: 75rpx;
  706 + margin-top:10rpx;
  707 +}
  708 +.top-frame .coupon-wode{
  709 + font-size: 25rpx;
  710 + margin-left:10rpx;
  711 + width:340rpx;
  712 + height:88rpx;
  713 +}
  714 +.coupon-code{
  715 + width:60rpx;
  716 + height:60rpx;
  717 + margin-top:5rpx;
  718 +
  719 +}
  720 +.frame{
  721 + width: 100%
  722 +}
  723 +.coupon-time{
  724 + font-size: 23rpx;
  725 + line-height:33rpx;
  726 + color: #333;
  727 +}
  728 +
  729 +.clik-get{
  730 + width:125rpx;
  731 + height:45rpx;
  732 + border-radius: 25rpx;
  733 + line-height: 45rpx;
  734 + font-size:25rpx;
  735 + bottom:67rpx;
  736 + right:6px;
  737 +}
  738 +
  739 +.code-img{
  740 + margin-left:20rpx;
  741 +}
  742 +.bottmo-explain{
  743 +top:145rpx;
  744 +width:94%;
  745 +border-top:1rpx dashed #eee;
  746 +padding-top:8rpx;
  747 +height:38rpx;
  748 +line-height: 51rpx;
  749 +
  750 +}
  751 +.font-word{
  752 + font-size: 22rpx;
  753 +}
  754 +.circle-size{
  755 + background: #a0a0a0;
  756 + width: 27rpx;
  757 + height: 27rpx;
  758 + margin-top:13rpx;
  759 +margin-left:8rpx;
  760 +display: flex;
  761 +
  762 +align-items: center;
  763 +}
  764 +.xc-jiantou{
  765 + /* width: 9rpx;
  766 + height: 9rpx; */
  767 + /* border-top: 2rpx solid #fff;
  768 + border-right: 2rpx solid #fff; */
  769 + transform: rotate(-90deg);
  770 + color: #fff;
  771 + font-size: 15rpx;
  772 + /* display:inline-block;
  773 + margin-top: 6.5rpx; */
  774 + text-align: center;
  775 +width: 24rpx;
  776 +}
  777 +.xc-buttom{
  778 + box-sizing: border-box;
  779 + width:100%;
  780 + min-height:76rpx;
  781 + height:auto;
  782 + line-height:40rpx;
  783 + border-left:1rpx solid #eee;
  784 + border-right:1rpx solid #eee;
  785 + border-bottom:1rpx solid #eee;
  786 +/* margin-left: 6rpx; */
  787 +}
  788 +
  789 +.goods-num{
  790 + font-size: 28rpx;
  791 + color: #333;
  792 +}
  793 +
  794 +.explain-coupon{
  795 + font-size:25rpx;
  796 + padding: 10rpx 10rpx
  797 +}
  798 +.circle-frame{
  799 + width: 20rpx;
  800 + height: auto;
  801 + z-index:1;
  802 + left:210rpx;
  803 +
  804 +}
  805 +.circle-sawtooth{
  806 + width: 11rpx;
  807 + height: 11rpx;
  808 + background: #fff;
  809 +}
  810 +
  811 +.red{background-color: #fe7496;}
  812 +.green{ background-color: #22c7c1;}
  813 +.blue{background-color:#5e82e3;}
  814 +.g_gray{background-color: #aaaaaa}
  815 +
  816 +.f_text{text-align: center; height:96rpx; }
  817 +.xc-hook.sn {
  818 + margin-top:12%;
  819 +width:45rpx;
  820 +height:45rpx;
  821 +font-size:28rpx;
  822 +line-height:44rpx;
  823 +
  824 +
  825 +}
  826 +.xc-hooks.on{
  827 + margin-top:12%;
  828 +width:42rpx;
  829 +height:42rpx;
  830 +}
  831 +.may_use_coupon{
  832 + /* width: 95%; */
  833 + /* height: 68rpx; */
  834 + line-height:78rpx;
  835 + padding: 0 26rpx;
  836 + justify-content: space-between;
  837 + align-items: center;
  838 +}
  839 +.determine-frame{
  840 + width: 100%;
  841 + height: 130rpx;
  842 +
  843 +}
  844 +.xc-determine{
  845 + height: 80rpx;
  846 + width: 40%;
  847 + border-radius: 50rpx;
  848 +background: #d60021;
  849 +color: #fff;
  850 +font-size: 28rpx;
  851 +margin: 0 auto;
  852 +
  853 +}
  854 +.click-buttem{
  855 +width: 90%;
  856 +margin: auto;
  857 +}
  858 +.logistics-name{
  859 + margin-right:20rpx;
  860 +}
  861 +.xc-border{
  862 + border-top:8rpx solid #eee;
  863 +width: 100%
  864 +}
  865 +.main-top{
  866 +margin-top: 20rpx;
  867 +
  868 +}
  869 +.xc-hookts{
  870 +border: 1rpx solid #999;
  871 +
  872 +}
  873 +.xc-hookts.on{
  874 + width:30rpx;
  875 +height:30rpx;
  876 +
  877 +}
  878 +.xc-hookt.sn{
  879 + width: 32rpx;
  880 +height: 32rpx;
  881 +font-size: 28rpx;
  882 +line-height: 34rpx;
  883 +}
  884 +.xc-hookt{
  885 + transform: rotate(-135deg);
  886 +text-align: center;
  887 +
  888 +}
  889 +.main-bottom{
  890 + margin-bottom: 20rpx;
  891 +
  892 +}
  893 +.xc-hookst{
  894 + border: 1rpx solid #999;
  895 +
  896 +}
  897 +.xc-hookst.ons{
  898 + width: 42rpx;
  899 +height: 42rpx;
  900 +margin-left: 20rpx;
  901 +
  902 +}
  903 +.is_use_coupon{
  904 + width: 65%;
  905 +justify-content: flex-end;
  906 +padding-top: 10rpx;
  907 +
  908 +
  909 +}
  910 +.xc-hooka{
  911 + transform: rotate(-135deg);
  912 +text-align: center;
  913 +
  914 +}
  915 +.xc-hooka.sn{
  916 + width: 45rpx;
  917 +height: 45rpx;
  918 +font-size: 28rpx;
  919 +line-height: 44rpx;
  920 +margin-left: 20rpx;
  921 +
  922 +}
  923 +.color-gray{
  924 + color: #808080;
  925 +}
  926 +.n_guige{ display: inline-block; background:rgb(236, 236, 236); color: rgb(63,63,63); padding: 3rpx 10rpx; border-radius: 3rpx }
  927 +.gift_image{ width: 60rpx; height: 60rpx; position: absolute; top: 0; left: 0}
  928 +
  929 +.quan_num_show{ padding: 4rpx 6rpx; background-color:#ea5551; color:#fff; border-radius: 6rpx;margin-left:10rpx;font-size:24rpx;}
  930 +
  931 +.navigator-hover {
  932 + background: none;
  933 + opacity: 1;
  934 +}
  935 +
  936 +
  937 +.plus_buy{
  938 + background-color: #fff;
  939 + margin:15rpx 0;
  940 + padding: 20rpx;
  941 + position: relative;
  942 +}
  943 +
  944 +
  945 +.card_bg {
  946 + box-sizing: border-box;
  947 + padding: 2rpx 10rpx;
  948 + height: 28rpx;
  949 + border-radius: 26rpx;
  950 + font-size: 18rpx;
  951 + line-height: 28rpx;
  952 + max-width: 210rpx;
  953 + background: #333;
  954 + color: #fff;
  955 + margin-left: 8rpx;
  956 + position:relative;
  957 + top:7rpx;
  958 +}
  959 +
  960 +.card_bg image {
  961 + width: 19rpx;
  962 + height: 19rpx;
  963 + margin-right: 8rpx;
  964 +}
  965 +
  966 +/* .card_bg .card_name {
  967 + max-width: 76rpx;
  968 + width: auto;
  969 + overflow: hidden;
  970 + white-space: nowrap;
  971 +} */
  972 +
  973 +.card_name {
  974 + position: relative;
  975 + top: -4rpx;
  976 + margin-left: 6px;
  977 +}
  978 +
  979 +.car_tri_up {
  980 + width: 0;height: 0;
  981 + border-left: 20rpx solid transparent;
  982 + border-right: 20rpx solid transparent;
  983 + border-bottom: 20rpx solid #fff;
  984 + position: absolute;
  985 + right: 20rpx;
  986 + top:-10rpx
  987 +}
  988 +.card_op{
  989 + position: absolute;
  990 + right: 20rpx;
  991 + top:36rpx
  992 +}
  993 +
  994 +
  995 +.circle {
  996 + display: block;
  997 + width: 10rpx;
  998 + height: 10rpx;
  999 + border-radius: 50%;
  1000 + background-color: #ccc;
  1001 + margin: 0 auto;
  1002 +}
  1003 +
  1004 +.item-progress {
  1005 + /* display: flex;
  1006 + flex-direction: column;
  1007 + justify-content: space-around;
  1008 + font-size: 24rpx; */
  1009 +}
  1010 +
  1011 +.icon-yes {
  1012 + font-size: 12px;
  1013 + color: #07c160;
  1014 +}
  1015 +
  1016 +.box {
  1017 + height: 32rpx;
  1018 + display: flex;
  1019 + align-items: center;
  1020 + justify-content: center;
  1021 + position: relative;
  1022 + padding-top: 8rpx;
  1023 +}
  1024 +
  1025 +.line::before {
  1026 + position: absolute;
  1027 + right: 60%;
  1028 + content: '';
  1029 + width: 80%;
  1030 + height: 2rpx;
  1031 + background-color: #f2f2f2;
  1032 +}
  1033 +
  1034 +.date-container {
  1035 + background-color: #F6A299;
  1036 + color: #f23030;
  1037 + font-size: 24rpx;
  1038 + padding: 10rpx 30rpx;
  1039 +}
  1040 +
  1041 +.kefu-container {
  1042 + width: 100rpx;
  1043 + height: 100rpx;
  1044 + border-radius: 50%;
  1045 + position: fixed;
  1046 + right: 10rpx;
  1047 + bottom: 160rpx;
  1048 + background-color: white;
  1049 + display: flex;
  1050 + align-items: center;
  1051 + justify-content: center;
  1052 + box-shadow: 0 4rpx 12px #e7e9eb;
  1053 +}
  1054 +
  1055 +/* .icon-kefu {
  1056 + font-size: 40rpx;
  1057 +}
  1058 + */
  1059 +
  1060 +.icon-daifu {
  1061 + color: #279BF9;
  1062 + font-size: 40rpx;
  1063 + margin-right: 10rpx;
  1064 +}
  1065 +
  1066 +
  1067 +
  1068 +
  1069 +
  1070 +
  1071 +.top {
  1072 + background-color: #FF4F3C;
  1073 + display: flex;
  1074 + padding: 60rpx 20rpx;
  1075 +}
  1076 +
  1077 +.avatar-container {
  1078 + width: 140rpx;
  1079 + height: 140rpx;
  1080 + border-radius: 50%;
  1081 + background-color: white;
  1082 + flex-shrink: 0;
  1083 +}
  1084 +
  1085 +.rmb::before {
  1086 + content: '¥';
  1087 +}
... ...
packageC/pages/payForAnother/zh_calculate.js 0 → 100644
  1 +var regeneratorRuntime = require('../../../utils/runtime.js');
  2 +module.exports = {
  3 + //主要的作用,就是把组合购多余的商品进行拆分,
  4 + //如果没有达成组合购的要求,所有的商品都打回原价购买
  5 + fir_set_arr: function (c_item) {
  6 + //组合活动,以及组合活动从表的商品
  7 + let zh_prom_goods = c_item.zh_prom_goods;
  8 + let goods = c_item.goods; //一个门店中所有的商品
  9 + let tfeel = 0,cut_price=0, offline_price = 0, offline_num = 0;
  10 + let txt_ite = c_item.need_list;
  11 + //多个活动要拿来循环一下
  12 + for (let i in zh_prom_goods) {
  13 + let title = ""; //提示语;
  14 + //其中的一个活动
  15 + let act_item = zh_prom_goods[i];
  16 + let act_goos = act_item.gdlist;
  17 + let act = act_item.act;
  18 +
  19 + let all_num = 0; //商品数量之和
  20 + let all_price0 = 0; //商品数量之和
  21 + let aprice=0; //达到活动条件的购买价格
  22 + let need_to_buy = 0;
  23 + let all_zhqty = 0; //所有商品要求起购数之和
  24 + let no_in_arr = []; //剩余的未加入组合购
  25 + let out_arr=[]; //超出活动限购的商品放入
  26 +
  27 + //-- 寻找一下 --
  28 + function get_num2(ite) {
  29 + for (let v2 in goods) {
  30 + var vh = goods[v2];
  31 + if (vh.goods_id == ite.goods_id) {
  32 + return vh;
  33 + }
  34 + }
  35 + return 0;
  36 + }
  37 +
  38 + for (let j in act_goos) {
  39 + let item = act_goos[j];
  40 + let item_j = goods.find(function (ele) {
  41 + return ele.goods_id == act_goos[j].goods_id;
  42 + })
  43 + //-- 如果有找到的话 --
  44 + if (item_j) {
  45 + act_goos[j].num = item_j.goods_num;
  46 + act_goos[j].goods_price = item_j.goods_price;
  47 + var cart_num=item.cart_num =item_j.goods_num;
  48 + var zh_b_num=item_j.promgoodsbuynum;
  49 + if(item.buyqty>0){
  50 + var cbuy=item.buyqty-zh_b_num;
  51 + //当可买的数量为0
  52 + if(cbuy<=0){
  53 + item.num=0;
  54 + out_arr.push({
  55 + price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,num:cart_num
  56 + })
  57 + }else{
  58 + if(cbuy>=cart_num) item.num =cart_num;
  59 + else{
  60 + item.num =cbuy;
  61 + out_arr.push({
  62 + price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,num:cart_num-cbuy
  63 + })
  64 + }
  65 + }
  66 + }
  67 +
  68 + all_num += item.num;
  69 + //当有起购数的控制的时候
  70 + if (item.zhqty) {
  71 + all_zhqty += item.zhqty;
  72 + if (item.num < item.zhqty) {
  73 + need_to_buy += item.zhqty - item.num;
  74 + }
  75 + if (item.num > item.zhqty) {
  76 + for (let i = 0; i < item.num - item.zhqty; i++) {
  77 + no_in_arr.push({
  78 + price: item.goods_price, goods_id: item.goods_id, offline_price: item_j.offline_price
  79 + })
  80 + }
  81 + }
  82 + } else {
  83 + for (let j = 0; j < item.num; j++) {
  84 + no_in_arr.push({
  85 + price: item.goods_price, goods_id: item.goods_id, offline_price: item_j.offline_price
  86 + })
  87 + }
  88 + }
  89 + } else {
  90 + if (item.zhqty) {
  91 + title = "必买商品未加购,下单立享【" + act.zhprice + "元任选" + act.zhbuyqty + "件】";
  92 + need_to_buy += item.zhqty;
  93 + }
  94 + }
  95 +
  96 + }
  97 +
  98 + //当满足组合的要求:总数要满足,起购数要满足
  99 + if (all_num >= act.zhbuyqty && !need_to_buy) {
  100 + function sortData(a, b) {
  101 + return a.price - b.price
  102 + }
  103 +
  104 + if(no_in_arr.length>0) no_in_arr.sort(sortData);
  105 +
  106 + aprice = act.zhprice;
  107 + if (act.zhbuyqty > all_zhqty) {
  108 + for (let n = 0; n < act.zhbuyqty-all_zhqty; n++) {
  109 + no_in_arr.pop();
  110 + }
  111 + }
  112 + //看一下剩下的数量有没有满足组合购的要求,以及要不要倍增
  113 + if (act.is_bz && no_in_arr.length >= act.zhbuyqty) {
  114 + //看一下是几倍
  115 + let be = parseInt(no_in_arr.length / act.zhbuyqty);
  116 + aprice += be * act.zhprice;
  117 + for (let m = 0; m < be * act.zhbuyqty; m++) {
  118 + no_in_arr.pop();
  119 + }
  120 + }
  121 +
  122 +
  123 + let goods_map = {};
  124 + //算一下剩余的商品
  125 + if(no_in_arr.length) {
  126 + for (let ii in no_in_arr) {
  127 + let item = no_in_arr[ii];
  128 + if (item.offline_price) {
  129 + offline_price += item.price - item.offline_price;
  130 + offline_num += 1;
  131 + }
  132 + if (goods_map[item.goods_id]) {
  133 + var num = goods_map[item.goods_id];
  134 + goods_map[item.goods_id] = ++num;
  135 + } else {
  136 + goods_map[item.goods_id] = 1;
  137 + }
  138 + }
  139 + }
  140 +
  141 + //超量的部分也要计算一下
  142 + if(out_arr.length){
  143 + for (var m in out_arr) {
  144 + var item = out_arr[m];
  145 + if (item.offline_price) {
  146 + offline_price += (item.price - item.offline_price)*item.num;
  147 + offline_num += item.num;
  148 + }
  149 + if (goods_map[item.goods_id]) {
  150 + var num = goods_map[item.goods_id];
  151 + num+=item.num
  152 + goods_map[item.goods_id] =num;
  153 + } else {
  154 + goods_map[item.goods_id] = item.num;
  155 + }
  156 + }
  157 + }
  158 +
  159 + if(Object.keys(goods_map).length) {
  160 + //这里就开始拆分提交订单时的列表
  161 + for (let j in goods_map) {
  162 + //map中存的就是商品的数量
  163 + let num = goods_map[j];
  164 + //找到相应的商品
  165 + let idx = goods.findIndex(function (ele) {
  166 + return ele.goods_id == j;
  167 + })
  168 + goods[idx].goods_num -= num;
  169 + let new_g = JSON.parse(JSON.stringify(goods[idx]));
  170 + new_g.goods_num = num;
  171 + new_g.prom_type = 0;
  172 + new_g.prom_id = 0;
  173 + goods.push(new_g);
  174 + }
  175 + }
  176 +
  177 +
  178 + //-- 只统计是参与活动的商品 --
  179 + for(var ij in goods){
  180 + var iter=goods[ij];
  181 + if(iter.prom_type!=7 || iter.prom_id!=act.id){ continue; }
  182 + all_price0+=iter.goods_num*iter.goods_price;
  183 + }
  184 + //-- 活动的条件已经满足 --
  185 + c_item.zh_prom_goods[act.id].is_has_zh = 1;
  186 + c_item.is_has_zh = 1;
  187 + c_item.zh_prom_goods[act.id].actual_price = aprice;
  188 + c_item.zh_prom_goods[act.id].cut_price =all_price0-aprice;
  189 +
  190 + //-- 设置还需要购买多少件,享受活动,前段显示 --
  191 + let need_to = c_item.need_list;
  192 + let index = this.find_need_to(need_to, act);
  193 + if (index > -1) {
  194 + need_to.splice(index, 1);
  195 + txt_ite = need_to
  196 + }
  197 +
  198 +
  199 + } else {
  200 + for (let ii in goods) {
  201 + let item = goods[ii];
  202 + if (item.prom_type != 7) continue;
  203 + if (item.prom_id != act.id) continue;
  204 + if (item.offline_price) {
  205 + offline_price += item.goods_price - item.offline_price;
  206 + offline_num += 1;
  207 + }
  208 + item.prom_type = 0;
  209 + item.prom_id = 0;
  210 + }
  211 + if (act.zhbuyqty - all_num > need_to_buy) {
  212 + need_to_buy = act.zhbuyqty - all_num;
  213 + }
  214 + //-- 设置还需要购买多少件享受活动,前端显示 --
  215 + let need_to = c_item.need_list;
  216 + let index = this.find_need_to(need_to, act);
  217 + if (title == '') title = "再买" + need_to_buy + "件,下单立享【" + act.zhprice + "元任选" + act.zhbuyqty + "件】";
  218 + if (index != -1) {
  219 + need_to[index].title = title;
  220 + } else {
  221 + if (!need_to) need_to = [];
  222 + let it = {
  223 + id: act.id,
  224 + pickup_id: c_item.pickup_id,
  225 + title: title
  226 + };
  227 + need_to.push(it);
  228 + }
  229 + txt_ite = need_to;
  230 + }
  231 + tfeel += aprice;
  232 + cut_price+=all_price0-aprice;;
  233 + }
  234 +
  235 + c_item.zh_all_price = tfeel;
  236 + c_item.zh_cut_price = cut_price;
  237 +
  238 + if (c_item.is_offline == 1) {
  239 + c_item.offline_price += offline_price;
  240 + c_item.offline_num += offline_num;
  241 + } else {
  242 + c_item.is_offline == 1;
  243 + c_item.offline_price = offline_price;
  244 + c_item.offline_num = offline_num;
  245 + }
  246 +
  247 + },
  248 + //筛选组合购,纯粹的数组按活动id分组
  249 + find_split: function (arr) {
  250 + //过滤只有团购的商品
  251 + let oarr = arr.goods.filter(function (ele) {
  252 + return ele.prom_type == 7
  253 + })
  254 + if (!oarr || oarr.length == 0) return null;
  255 + //看一下有多少个不同的团购
  256 + let map = {},
  257 + dest = [];
  258 + for (let i = 0; i < oarr.length; i++) {
  259 + let ai = oarr[i];
  260 + let index = map[ai.prom_id]
  261 + if (!index) {
  262 + dest.push({
  263 + prom_id: ai.prom_id,
  264 + act: ai.act,
  265 + data: [ai]
  266 + });
  267 + map[ai.prom_id] = dest.length; //存储下标
  268 + } else {
  269 + let dj = dest[index - 1];
  270 + dj.data.push(ai);
  271 + }
  272 + }
  273 + return dest;
  274 + },
  275 +
  276 + find_need_to: function (list, iter) {
  277 + if (!list || list.length <= 0) return -1;
  278 + for (var i in list) {
  279 + var item = list[i];
  280 + if (item.id == iter.id) {
  281 + return i;
  282 + }
  283 + }
  284 + return -1;
  285 + },
  286 + //-- 平摊组合购的价格 --
  287 + calc_zh_split_price: async function (c_arr, th) {
  288 + //-- 循环处理 --
  289 + for (var k in c_arr) {
  290 + var cart_item = c_arr[k]; //就是每一单的意思
  291 + var ord_goods = c_arr[k].goods; //就是每一单的从表的意思
  292 +
  293 + var zh_prom_goods = cart_item.zh_prom_goods; //一单中所有的组合购的集合
  294 + var item_map = {};
  295 + for (let i in zh_prom_goods) {
  296 + let item = zh_prom_goods[i];
  297 + let prom_id = i;
  298 + //如果这个活动还没有达到要求,继续下一个计算
  299 + if (!item.is_has_zh) continue;
  300 + //过滤出相应组合购活动的商品
  301 + let glist = ord_goods.filter(function (ele) {
  302 + return ele.prom_type == 7 && ele.prom_id == i;
  303 + })
  304 + var all_good_price = 0;
  305 + var post_gd=[];
  306 + for (let j in glist) {
  307 + let item = glist[j];
  308 + all_good_price += item.goods_price * item.goods_num;
  309 + var gitem={
  310 + goods_id:item.goods_id,
  311 + goods_num:item.goods_num,
  312 + goods_price:item.goods_price
  313 + }
  314 + post_gd.push(gitem);
  315 + }
  316 + //要进行优惠的计算
  317 + if (all_good_price - item.actual_price) {
  318 + if (cart_item.prom_pt_json) {
  319 + cart_item.prom_pt_json.push({
  320 + "zhprom_id": prom_id,
  321 + "dis": (all_good_price - item.actual_price).toFixed(2),
  322 + "ispt": 0
  323 + })
  324 + } else {
  325 + cart_item.prom_pt_json = [{
  326 + "zhprom_id": prom_id,
  327 + "dis": (all_good_price - item.actual_price).toFixed(2),
  328 + "ispt": 0
  329 + }];
  330 + }
  331 + }
  332 +
  333 + //-- 如果系统要平摊到单品 --
  334 + var pt_data = {
  335 + 'prom_id': prom_id,
  336 + 'dis': parseFloat(all_good_price - item.actual_price).toFixed(2),
  337 + 'goods': post_gd
  338 + }
  339 + var pt_res = null;
  340 + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
  341 + is_json: 1,
  342 + data: pt_data
  343 + }).then(res => {
  344 + if (res.data.code == 0) {
  345 + pt_res = res.data.data;
  346 + }
  347 + })
  348 + if (pt_res) {
  349 + for (var io in glist) {
  350 + var goods_id = glist[io].goods_id;
  351 + item_map[goods_id]={};
  352 + //平摊赋值
  353 + item_map[goods_id].account_fir = th.arr_get_goods(goods_id, pt_res).fisrt_account;
  354 + item_map[goods_id].account_yu_fir = th.arr_get_goods(goods_id, pt_res).fisrt_account_yu;
  355 + if (!th.data.ispt_goods) {
  356 + item_map[goods_id].account = item_map[goods_id].account_fir;
  357 + item_map[goods_id].account_yu = item_map[goods_id].account_yu_fir;
  358 + }
  359 + }
  360 + }
  361 + }
  362 +
  363 + //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表-----------
  364 + for (var jj = 0; jj < ord_goods.length; jj++) {
  365 + if (ord_goods[jj].is_gift) continue;
  366 + if (ord_goods[jj].prom_type == 7 && item_map[ord_goods[jj].goods_id]) {
  367 + ord_goods[jj].account_fir = item_map[ord_goods[jj].goods_id].account_fir;
  368 + ord_goods[jj].account_yu_fir = item_map[ord_goods[jj].goods_id].account_yu_fir;
  369 + ord_goods[jj].account = item_map[ord_goods[jj].goods_id].account;
  370 + ord_goods[jj].account_yu = item_map[ord_goods[jj].goods_id].account_yu;
  371 + }
  372 + }
  373 + }
  374 +
  375 +
  376 + }
  377 +
  378 +
  379 +}
... ...