Commit 008d7115763dedebdbfe40f47e658978919fba38

Authored by taiyuan
2 parents 36f6da22 f8b3df94

Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev

.idea/mshopweapp.iml deleted
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<module type="WEB_MODULE" version="4">
3   - <component name="NewModuleRootManager">
4   - <content url="file://$MODULE_DIR$" />
5   - <orderEntry type="inheritedJdk" />
6   - <orderEntry type="sourceFolder" forTests="false" />
7   - </component>
8   -</module>
9 0 \ No newline at end of file
... ... @@ -51,7 +51,7 @@ App({
51 51 config2: null, //门店配置
52 52 code: null,
53 53 heigth:0,
54   - user_id:null,//13324010,//4755274,
  54 + user_id:null,//5682094,
55 55 buy_now:null,
56 56 picklist:null, //门店列表
57 57 wuliuprice: null, //物流价格表
... ... @@ -129,47 +129,70 @@ App({
129 129 var th=this;
130 130 var pages = getCurrentPages(); //获取加载的页面
131 131 var currentPage = pages[pages.length - 1]; //获取当前页面的对象
132   - var turl="/api/weshop/storeconfig/get/" + th.globalData.setting.stoid;
133   -
134   - th.promiseGet(turl,{}).then(res=>{
135   - var o=res;
136   - if(o.data.code==0){
137   - th.globalData.config2 = o.data.data;
138   - //有配置成要验证过期,因为过期的小程序没有办法审核
139   - if(th.globalData.config2 && th.globalData.config2.is_overdue){
140   -
141   - //要开始验证,小程序有没有购买和过期
142   - if(!currentPage || currentPage.route.indexOf('error/error')==-1 || currentPage.route.indexOf('index/index')==-1){
143   - var tt=this.globalData.wxapp_buy_obj;
144   - if (!tt){
145   - this.get_isbuy(function (){
146   - tt=th.globalData.wxapp_buy_obj;
147   - if (tt.isout == 1){
148   - th.promiseGet('/api/weshop/store/get/'+t.stoid,{}).then(res=>{
149   -
150   - if(!th.err_going){
151   - wx.reLaunch({
152   - url: "/pages/error/error?msg=该商城已到期,暂停浏览1!\r\n可联系:"+res.data.data.store_tel,
153   - });
154   - }
155   - })
156   - }
157   - else if (tt.isbuy == 0){
158   -
159   - if(!th.err_going){
160   - wx.reLaunch({
161   - url: "/pages/error/error?msg=还未购买小程序",
162   - });
163   - }
164   -
165   - }
166   -
167   - })
168   - }
169   - }
170   - }
171   - }
172   - })
  132 +
  133 + if(!th.globalData.wxapp_buy_obj) {
  134 + var turl = "/api/weshop/storeconfig/get/" + th.globalData.setting.stoid;
  135 + th.promiseGet(turl, {}).then(res => {
  136 + var o = res;
  137 + if (o.data.code == 0) {
  138 + th.globalData.config2 = o.data.data;
  139 + //有配置成要验证过期,因为过期的小程序没有办法审核
  140 + if (th.globalData.config2 && th.globalData.config2.is_overdue) {
  141 +
  142 + //要开始验证,小程序有没有购买和过期
  143 + if (!currentPage || currentPage.route.indexOf('error/error') == -1 || currentPage.route.indexOf('index/index') == -1) {
  144 + var tt = this.globalData.wxapp_buy_obj;
  145 + if (!tt) {
  146 + this.get_isbuy(function () {
  147 + tt = th.globalData.wxapp_buy_obj;
  148 + if (tt && tt.isout == 1) {
  149 + th.promiseGet('/api/weshop/store/get/' + t.stoid, {}).then(res => {
  150 +
  151 + if (!th.err_going) {
  152 + wx.reLaunch({
  153 + url: "/pages/error/error?msg=该商城已到期,暂停浏览1!\r\n可联系:" + res.data.data.store_tel,
  154 + });
  155 + }
  156 + })
  157 + }
  158 + else if (tt && tt.isbuy == 0) {
  159 +
  160 + if (!th.err_going) {
  161 + wx.reLaunch({
  162 + url: "/pages/error/error?msg=还未购买小程序",
  163 + });
  164 + }
  165 +
  166 + }
  167 +
  168 + })
  169 + }
  170 + }
  171 + }
  172 + }
  173 + })
  174 +
  175 + }
  176 + else{
  177 + var tt = th.globalData.wxapp_buy_obj;
  178 + if (tt && tt.isout == 1) {
  179 + th.promiseGet('/api/weshop/store/get/' + t.stoid, {}).then(res => {
  180 + if (!th.err_going) {
  181 + wx.reLaunch({
  182 + url: "/pages/error/error?msg=该商城已到期,暂停浏览1!\r\n可联系:" + res.data.data.store_tel,
  183 + });
  184 + }
  185 + })
  186 + }
  187 + else if (tt && tt.isbuy == 0) {
  188 + if (!th.err_going) {
  189 + wx.reLaunch({
  190 + url: "/pages/error/error?msg=还未购买小程序",
  191 + });
  192 + }
  193 +
  194 + }
  195 + }
173 196  
174 197 //获取一下门店的基本信息
175 198 this.getConfig();
... ... @@ -417,11 +440,11 @@ App({
417 440 arr.splice(0, 2);
418 441 }
419 442 var arr_tabbar=["/pages/index/index/index",
420   - "/pages/goods/categoryList/categoryList",
  443 + "/pages/goods/categoryList/categoryList",
421 444 "/pages/goods/categoryList/categoryList?type=2",
422 445 "/pages/goods/categoryList/categoryList?type=1",
423 446 "/pages/cart/cart/cart","/pages/user/index/index",
424   - "/pages/distribution/distribution"];
  447 + "/pages/distribution/distribution"];
425 448 if(arr_tabbar.indexOf(url)!=-1){
426 449 if(url.indexOf("categoryList?type=1")!=-1) this.globalData.cat_type=1;
427 450 if(url.indexOf("categoryList?type=2")!=-1) this.globalData.cat_type=2;
... ... @@ -481,8 +504,8 @@ App({
481 504 success:function (res) {
482 505 th.globalData.pk_store=null;
483 506 if(res.data.code==0 && res.data.data && res.data.data.isstop==0){
484   - //--门店的数量大于5个才要关心门店的分类有没有关闭--
485   - if(res.data.data.category_id && num>5){
  507 + //--门店的数量大于10个才要关心门店的分类有没有关闭--
  508 + if(res.data.data.category_id && num>10){
486 509 th.request.get( "/api/weshop/storagecategory/get/"+os.stoid+"/"+res.data.data.category_id, {
487 510 data: {},
488 511 success: function (ee) {
... ... @@ -537,7 +560,8 @@ App({
537 560 store_id: this.globalData.setting.stoid,
538 561 user_id: this.globalData.user_id,
539 562 state:0,
540   - is_gift:0
  563 + is_gift:0,
  564 + pageSize:300
541 565 },
542 566 success: function(e) {
543 567 var num = 0;
... ... @@ -546,13 +570,11 @@ App({
546 570 num += e.data.data.pageData[i].goods_num;
547 571 }
548 572 }
549   -
550 573 /*---
551 574 wx.setTabBarBadge({ //tabbar右上角添加文本
552 575 index: 2, ////tabbar下标
553 576 text: '' + num //显示的内容
554 577 });--*/
555   -
556 578 //-- 读取服务卡的数量 --
557 579 that.promiseGet("/api/weshop/cartService/page",{
558 580 data:{
... ... @@ -619,6 +641,7 @@ App({
619 641 this.globalData.config=null; //清除config的缓存
620 642 this.globalData.gr_index=0; //商品分组的序列
621 643 this.globalData.pk_store=null;
  644 + this.globalData.wxapp_buy_obj=null
622 645  
623 646 },
624 647  
... ... @@ -719,12 +742,6 @@ App({
719 742 resolve(user_info);
720 743 };
721 744 });
722   -
723   -
724   -
725   -
726   -
727   -
728 745 },
729 746  
730 747  
... ...
packageC/pages/goods/distributionCategoryList/index.js
... ... @@ -302,8 +302,6 @@ Page({
302 302 // brand_id:cid,
303 303 // })
304 304 var lurl = "/packageA/pages/distribution/shop/shop?brand_id=" + bid;
305   - // var lurl = "/packageA/pages/distribution/shop/shop";
306   - // wx.redirectTo({ url: lurl });
307 305 wx.navigateTo({ url: lurl })
308 306 // wx.navigateBack()
309 307 },
... ...
packageC/pages/presell/cart/cart.js
Changes suppressed. Click to show
... ... @@ -3,7 +3,7 @@ var t = getApp(), app = t, a = t.request, e = require(&quot;../../../../utils/common.
3 3 var oo = t.globalData.setting, os = oo;
4 4 var regeneratorRuntime = require('../../../../utils/runtime.js');
5 5 var util_pay = require("../../../../utils/pay.js");
6   -var zh_calc = require("zh_calculate.js");
  6 +
7 7  
8 8 Page({
9 9 data: {
... ... @@ -24,15 +24,6 @@ Page({
24 24 //页面获取的参数
25 25 param: null,
26 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 27 /*-----------当是购物车结算的时候-------------*/
37 28 cartlist: null,
38 29 old_cartlist: null,
... ... @@ -69,7 +60,7 @@ Page({
69 60 ckeck_quan_price: 0,
70 61 check_quan_price_list: '',
71 62 check_quan_ware_list: '',
72   -
  63 + isget_by_quan: {}, //是否调用了接口获取包邮券
73 64 // 设计一个数组来存放已经选择了的券编号,coupon_no是券号,money是面值,coupon_price是真正优惠的价格,数组的下标是pickid
74 65 //using_quan[11]={coupon_no:"1212121",money:"20",coupon_price:"45"}
75 66 using_quan: {},
... ... @@ -120,9 +111,17 @@ Page({
120 111  
121 112 tabs: ['门店自提', '快递邮寄'],
122 113 currentTabIndex: 1,
  114 +
  115 + order_sn:'',
  116 + order_id:'',
  117 +
123 118 },
124 119 onLoad: function (t) {
125   - wx.setNavigationBarTitle({title: "填写订单",})
  120 +
  121 + if(t.order_id) this.data.order_id=t.order_id;
  122 + if(t.order_sn) this.data.order_sn=t.order_sn;
  123 +
  124 + wx.setNavigationBarTitle({title: "订单详情",})
126 125 var th = this;
127 126 this.setData({is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,});
128 127 th.data.param = t;
... ... @@ -134,7 +133,9 @@ Page({
134 133 success: function (s) {
135 134 }
136 135 });
137   -
  136 + if(!getApp().globalData.userInfo){
  137 + getApp().goto("/pages/togoin/togoin");
  138 + }
138 139  
139 140 },
140 141 onUnload: function () {
... ... @@ -153,18 +154,12 @@ Page({
153 154 var th = this;
154 155 th.setData({show_submit: 0}); //让提交先掩藏
155 156 th.data.g_cart_q_time = null;
156   -
157 157 if (th.data.isclose == 0) {
158 158 wx.navigateTo({
159   - url: "/pages/index/index/index"
  159 + url:"/pages/index/index/index"
160 160 })
161   -
162   - } else {
  161 + }else{
163 162 this.getuser_addr(function (ie) {
164   -
165   - console.log("getuser_addr")
166   - console.log(ie)
167   -
168 163 //地址切换要把包邮券清空
169 164 if (!th.data.user_addr || !ie || th.data.user_addr.address_id != ie.address_id) {
170 165 var using_quan = th.data.using_quan;
... ... @@ -183,40 +178,16 @@ Page({
183 178 th.data.prom_goods_map = {};
184 179 th.data.is_summit_ing = 0;
185 180 //更换地址回来要重新调用计算价钱的接口
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   - }
  181 + if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id){
  182 + th.setData({user_addr: ie});
  183 + th.setData({add_back: 1});
  184 + th.calculatePrice2();
199 185 } else {
200 186 th.setData({user_addr: ie});
201 187 }
202 188 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 189 });
  190 +
220 191 var is_card_back = getApp().globalData.is_card_back;
221 192 //--更新默认地址--,看一下是不是跳到地址页面,同时也不是购买等级卡返回的,这里很重要,否则会重新更新收货物流公司
222 193 if (!getApp().globalData.is_cart_old && !is_card_back && !getApp().globalData.plus_buy_back) {
... ... @@ -238,7 +209,8 @@ Page({
238 209 is_close_quan: json_d.is_close_quan,
239 210 sales_rules: ee.sales_rules,
240 211 rank_switch: json_d.rank_switch,
241   - is_default_logistics: is_default_logistics
  212 + is_default_logistics: is_default_logistics,
  213 + sys_switch:json_d,
242 214 });
243 215  
244 216 var rank_switch = json_d.rank_switch;
... ... @@ -317,11 +289,7 @@ Page({
317 289 a.get("/api/weshop/useraddress/page", {
318 290 data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600, t: Math.random()},
319 291 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   - ];---*/
  292 +
325 293 var item = null;
326 294 if (su.data.code == 0 && su.data.data && su.data.data.pageData) {
327 295 var user_addr = su.data.data.pageData;
... ... @@ -349,634 +317,328 @@ Page({
349 317  
350 318 //----------------展示页面,是再获取用户信息之后--------------
351 319 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   - });
  320 + var th = this,
  321 + to = getApp();
  322 + th.setData({
  323 + userinfo: to.globalData.userInfo,
  324 + });
  325 + //选获取地址
  326 + th.getuser_addr(function (addr) {
384 327  
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   - }
  328 + if (addr == null || addr == undefined || addr.length == 0) {
  329 + th.setData({
  330 + enterAddressPage: 1,
395 331 });
396 332  
  333 + } else {
  334 + th.setData({
  335 + user_addr: addr, enterAddressPage: 0,
  336 + });
  337 + }
  338 + //获取立即购买的商品信息
  339 + th.get_buy_goods(th.data.order_id,th.data.order_sn);
  340 + });
  341 + //获取提现金额
  342 + getApp().request.get("/api/weshop/withdrawals/summoney", {
  343 + data: {
  344 + user_id: to.globalData.user_id,
  345 + store_id: oo.stoid,
  346 + status: 0
397 347 },
  348 + success: function (su) {
  349 + console.log("withdrawals");
  350 + if (su.data.code == 0) {
  351 + var yuer = parseFloat(th.data.userinfo.user_money -
  352 + th.data.userinfo.frozen_money - su.data.data.summoney).toFixed(2);
  353 + th.setData({
  354 + txmon: su.data.data.summoney,
  355 + yuer: yuer
  356 + });
  357 + }
  358 + }
398 359 });
399   -
400 360 },
401 361  
  362 + //-----获取商品------
  363 + async get_buy_goods(ord,o_sn) {
  364 + var order = null,
  365 + order_goods = null,
  366 + goods = null,
  367 + pickup = null,
  368 + distr_type = 0,
  369 + exp_type = 0,
  370 + presell=null, //订单从表
  371 + pre_arr=null, //订单内容
  372 + th = this;
  373 +
  374 +
  375 + if(o_sn){
  376 + //获取order信息根据订单编号order_sn
  377 + await getApp().request.promiseGet("/api/weshop/order/page", {
  378 + data: { store_id: os.stoid, order_sn: o_sn,}
  379 + }).then(res => {
  380 + order = res.data.data.pageData[0];
  381 + })
  382 +
402 383  
403   - //-----真的获取购物车,入口--------
404   - get_cart: function () {
405   - var th = this, app = getApp();
406   - a.get("/api/weshop/cart/list", {
  384 + ord=order.order_id;
  385 + }else{
  386 + //---获取订单---
  387 + await getApp().request.promiseGet("/api/weshop/order/get/" + oo.stoid + "/" + ord, {}).then(res => {
  388 + order = res.data.data;
  389 + });
  390 + }
  391 + //---获取订单从表---
  392 + await getApp().request.promiseGet("/api/weshop/ordergoods/page", {
407 393 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   - }
  394 + store_id: oo.stoid,
  395 + order_id: ord
  396 + }
  397 + }).then(res => {
  398 + order_goods = res.data.data.pageData[0];
  399 + });
448 400  
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   - })
  401 + await getApp().request.promiseGet("/api/weshop/order/orderPresell/get/"+oo.stoid+"/"+order.order_id, {}).then(res => {
  402 + presell = res.data.data;
  403 + });
469 404  
470   - if (!isok) {
471   - getApp().my_warnning("组合购的活动已经过期", 0, th);
472   - return false;
473   - }
  405 + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: order_goods.goods_id };
  406 + if(presell.deposit_pay_time>0){
  407 + pre_data.timetype=12;
  408 + }
474 409  
475   - }
476   - }
  410 + pre_data.user_id = order.user_id;
  411 + var isok=1;
  412 + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
  413 + data: pre_data,
  414 + }).then(e => {
  415 + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
  416 + pre_arr = e.data.data.pageData[0];
  417 + }else{
  418 + isok=0;
  419 + }
  420 + })
  421 + if(!isok){
  422 + getApp().confirmBox("活动已经结束,或者会员身份不符合");
  423 + return false;
  424 + }
477 425  
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];
  426 + //等待定金
  427 + if(order.order_status<2 && presell.deposit_pay_time<=0 ){
  428 + th.setData({wait_dj:1})
  429 + }
  430 + //等待尾款
  431 + if(order.order_status<2 && presell.deposit_pay_time>0 && presell.tail_pay_state==0 && presell.presell_type!=1){
  432 + th.setData({wait_wk:1})
  433 + wx.setNavigationBarTitle({title: "支付尾款",})
  434 + }
  435 + //等待发货
  436 + if(order.pay_status==1 && order.shipping_status==0){
  437 + th.setData({wait_fh:1})
  438 + }
494 439  
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   - }
  440 + if(order.pay_status==1 && order.shipping_status==1 && order.order_status<2){
  441 + th.setData({wait_sh:1})
  442 + }
503 443  
504   - }
505 444  
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   - //}
  445 + //------获取预售主表----------
  446 + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell.prom_id, {}).then(res => {
  447 + if (res.data.code == 0 && res.data.data) {
  448 + th.setData({
  449 + act: res.data.data,
  450 + });
538 451  
539   - //-- 把等级卡会优惠多少钱装进去 --
540   - if (car_item.cut_price1) arr[j].card_cut_price += car_item.cut_price1;
  452 + }
  453 + })
541 454  
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 455  
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);
  456 + //---获取商品---
  457 + await getApp().request.promiseGet("/api/weshop/goods/get/" + oo.stoid + "/" + order_goods.goods_id, {}).then(res => {
  458 + goods = res.data.data;
  459 + order.market_price = goods.market_price;
  460 + order.show_img = oo.imghost + goods.original_img;
  461 + });
  462 + //判断使用优惠券的接口需要
  463 + th.data.check_quan_ware_list = goods.erpwareid;
  464 + //---获取门店---
  465 + await getApp().request.promiseGet("/api/weshop/pickup/get/" + oo.stoid + "/" + order.pickup_id, {}).then(res => {
  466 + pickup = res.data.data;
  467 + });
614 468  
  469 + order['is_all_return'] = 0;
  470 + //------------对比一下有没有退款记录------------
  471 + await getApp().request.promiseGet("/api/weshop/order/returngoods/page",{
  472 + data: { order_id: order.order_id, store_id: oo.stoid,
  473 + user_id:order.user_id, pageSize: 200 }
  474 + }).then(rss=>{
  475 + var ttd=rss;
  476 + //----没有相关的退款记录----
  477 + if (ttd.data.data.total==0){
  478 + order['is_all_return'] = 0;
  479 + }else{
  480 + var eea = ttd.data.data.pageData[0];
  481 + //1.退款正在进行中,
  482 + //2.退款被拒绝就要显示可以退款
  483 + //3.退款已经完成
  484 + order['is_all_return']=1;
  485 + order['is_all_return_status'] = ttd.data.data.pageData[0].status;
  486 +
  487 + if (order['order_status'] == 1 && order['pay_status'] == 1) {
  488 + switch (eea.status) {
  489 + case 0:
  490 + case 1:
  491 + order.order_status_detail="退款中";
  492 + order['return_btn'] = 2; break;
  493 + case 2:
  494 + order.order_status_detail="退款完成";
  495 + order['return_btn'] = 4; break;
  496 + case 3:
  497 + order['return_btn'] = 3; break;
  498 + default:
  499 + order['return_btn'] = 0;
615 500 }
616 501 }
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   - }
  502 + }
  503 + })
630 504  
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   - }
  505 + var price=presell.presell_price;
  506 + if(!goods) return false;
  507 + //--判断物流--
  508 + if (goods.distr_type)
  509 + distr_type = goods.distr_type;
  510 + else
  511 + distr_type = pickup.distr_type;
  512 +
  513 + switch (distr_type) {
  514 + case 0:
  515 + exp_type = 1;
  516 + //-- 系统后台有设置要默认的 --
  517 + if (th.data.sys_switch.pickupway && th.data.sys_switch.pickupway == 1) exp_type = 0;
  518 + break; //自选
  519 + case 1:
  520 + exp_type = 1;
653 521  
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   - })
  522 + break //自提
  523 + case 2:
  524 + exp_type = 0;
  525 + break; //物流
  526 + }
702 527  
703   - }, 500)
  528 + //等待发货的时候
  529 + if(th.data.wait_fh){
  530 + var send_time=pre_arr.delivery_date;
  531 + if(pre_arr.delivery_type==2){
  532 + send_time=pre_arr.delivery_daynum*3600;
  533 + }
704 534  
705   - }
  535 + }
  536 +
  537 +
  538 + order.order_goods = order_goods;
  539 + var tail_pay=pre_arr.presell_price*order_goods.goods_num-presell.presell_deposit;
  540 + this.setData({
  541 + order: order,
  542 + distr_type: distr_type,
  543 + pickup: pickup,
  544 + exp_type: exp_type,
  545 + goods: goods,
  546 + presell:presell,
  547 + pre_arr:pre_arr,
  548 + show_submit:1,
  549 + userInfo:getApp().globalData.userInfo,
  550 + tail_pay:tail_pay,
  551 + order_goods:order_goods,
  552 + all_price:pre_arr.presell_price*order_goods.goods_num,
  553 + pickup_id:pickup.pickup_id,
  554 + send_time:send_time
706 555 });
  556 + th.get_diff();
  557 + //统一进行计算金额
  558 + th.calculatePrice2();
  559 + //如果可以
  560 + if(pre_arr.is_usecoupon){
  561 + th.get_buy_now_quan();
  562 + }
707 563 },
708 564  
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 565  
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;
  566 + async calculatePrice2(){
  567 + var th=this;
  568 + if(!this.data.pre_arr) return false;
  569 + //--计算物流--
  570 + if (this.data.exp_type == 0) {
  571 + this.calculate_wuliu();
  572 + } else {
  573 + var allpice =this.data.pre_arr.presell_price*this.data.order_goods.goods_num;
  574 + allpice = allpice.toFixed(2);
  575 + //--看一下有没有订单优惠--
  576 + var o_condition = parseFloat(allpice);
  577 + //---如果有选择优惠券的情况下---
  578 + var quan_price = 0, bn_pick = th.data.pickup.pickup_id;
  579 + var quan_no = null;
  580 + if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
  581 + quan_no = th.data.using_quan[bn_pick].coupon_no;
  582 + //-- 如果使用的券不是包邮券的时候 --
  583 + if (quan_no && th.data.using_quan[bn_pick].isby != 1) {
  584 + //---获取优惠券优惠---
  585 + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", {
  586 + data: {
  587 + storeId: oo.stoid,
  588 + CashRepNo: quan_no,
  589 + WaresSum: th.data.ckeck_quan_price,
  590 + WareIds: th.data.check_quan_ware_list
741 591 }
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   - }
  592 + }).then(res => {
  593 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  594 + quan_price = res.data.data[0].WareCashSum;
752 595 }
  596 + })
  597 + }
753 598  
754   - if (th.data.bn_goods) {
755   - et = th.data.bn_exp_type;
756   - m_wind = th.data.index;
  599 + if(quan_price>0){
  600 + if (quan_price < o_condition) th.setData({quan_price: quan_price})
  601 + else {
  602 + th.setData({quan_price: o_condition})
757 603 }
  604 + o_condition=o_condition-quan_price;
758 605  
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});
  606 + }else{
  607 + th.setData({quan_price: 0})
  608 + }
  609 + if(o_condition<0) o_condition=0;
  610 +
  611 + //如果同意参与订单优惠
  612 + if (o_condition > 0 && this.data.pre_arr.is_useorderyh) {
  613 + th.check_is_order_prom(o_condition, function () {
  614 + var bn_pick=th.data.pickup.pickup_id
  615 + var order_prom_amount = 0;
  616 + var order_prom_id = 0;
  617 + if (th.data.order_prom[bn_pick]) {
  618 + var ord_prom = th.data.order_prom[bn_pick];
  619 + order_prom_id = ord_prom['id'];
  620 + switch (ord_prom['type']) {
  621 + case 0:
  622 + o_condition = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折
  623 + order_prom_amount = (o_condition - order_m).toFixed(2);
  624 + break;
  625 + case 1:
  626 + o_condition = o_condition - ord_prom['expression'];//满额优惠金额
  627 + order_prom_amount = ord_prom['expression'];
  628 + break;
774 629 }
775 630 }
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;
  631 + //--订单优惠的显示--
  632 + if (order_prom_id > 0) {
  633 + var order_prom_txt1 = "order_prom_id";
  634 + var order_prom_txt2 = "order_prom_amount";
  635 + th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount})
977 636 }
978   - },
979   - });
  637 + th.setData({ exp_price: 0, order_m: o_condition })
  638 + })
  639 + }else{
  640 + th.setData({ exp_price: 0, order_m: o_condition })
  641 + }
980 642 }
981 643 },
982 644  
... ... @@ -1010,7 +672,8 @@ Page({
1010 672 },
1011 673 keyUpChangeNum: function (t) {
1012 674 this.setData({
1013   - maxWord: t.detail.value.length
  675 + maxWord: t.detail.value.length,
  676 + user_note:t.detail.value
1014 677 });
1015 678 },
1016 679  
... ... @@ -1176,2618 +839,1797 @@ Page({
1176 839 }
1177 840 },
1178 841  
1179   - //-------------------计算订单价格-------------------
1180   - calculatePrice: function (t, s) {
  842 + set_can_num: function () {
1181 843 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   - })
  844 + //-- 这个地方,循环计算几张优惠券可用--
  845 + for (var iter in th.data.cartlist) {
  846 + var num = 0;
  847 + var c_item = th.data.cartlist[iter];
  848 + var pkid = c_item.pickup_id;
  849 + //-- 普通券 --
  850 + if (c_item.quan_list) {
  851 + for (var iter1 in c_item.quan_list) {
  852 + //判断是不是其他订单有选用
  853 + var is_other_is_use = th.check_other_use(c_item.quan_list[iter1], pkid);
  854 + if (!is_other_is_use) num++;
1212 855 }
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   - }
  856 + }
  857 + //-- 包邮券 --
  858 + var by_quan = th.data.get_by_quan_list_cart[pkid];
  859 + if (by_quan) {
  860 + for (var iter2 in by_quan) {
  861 + //判断是不是其他订单有选用
  862 + var is_other_is_use = th.check_other_use_by(by_quan[iter2], pkid);
  863 + if (!is_other_is_use) num++;
1221 864 }
  865 + }
  866 + var set_txt = "cartlist[" + iter + "].can_num";
  867 + th.setData({[set_txt]: num});
  868 + }
  869 + },
  870 + useCoupon: function () {
  871 + if (this.data.order.couponNum <= 0) {
  872 + getApp().my_warnning("无可用优惠券", 0, this);
  873 + return;
  874 + }
1222 875  
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   - }
  876 + var a = {
  877 + lid: this.data.coupon ? this.data.coupon.id : "0"
  878 + };
  879 + wx.navigateTo({
  880 + url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a)
  881 + });
  882 + },
  883 + enterAddressPage: function () {
  884 + if(!this.data.wait_wk) return false;
1245 885  
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   - }
  886 + getApp().globalData.is_cart_old = 1;
  887 + this.data.isget_by_quan = {};
  888 + this.data.enterAddressPage = !0, wx.navigateTo({
  889 + url: "/pages/user/address_list/address_list"
  890 + });
  891 + },
1283 892  
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 () {
  893 + //--------立即购买时,选择自提和物流----------
  894 + setexptype: function (t) {
1626 895 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;
  896 + var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code;
  897 + th.setData({bn_exp_type: ty});
  898 + if (ty == 0) {
  899 + th.setData({is_all_zt: 0});
1678 900 }
1679 901  
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   -
  902 + //当物流为空的时候。
  903 + if (ty == 0 && th.data.wu_arr == null) {
  904 + th.data.isget_by_quan = {};
  905 + return th.get_wuliu(th.calculatePrice2());
1687 906 }
1688 907  
1689   - //如果有线下取价的时候
1690   - if (good.is_offline) {
1691   - allpice = good.offline_price * good.buynum;
  908 + //--自提就要把包邮券清理掉--
  909 + if (ty == 1) {
  910 + th.data.isget_by_quan = {};
  911 + if (th.data.using_quan[bn_pick] && th.data.using_quan[bn_pick].isby == 1) {
  912 + th.setData({using_quan: {}});
  913 + }
1692 914 }
1693 915  
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});
  916 + //判断有没有默认的物流地址值
  917 + if (def_exp_code != "" && def_exp_code != null && def_exp_code != undefined) {
  918 + var wu_arr = this.data.wu_arr;
  919 + if (wu_arr != null && wu_arr != "") {
  920 + for (var i = 0; i < wu_arr.length; i++) {
  921 + if (wu_arr[i].shipping_code == def_exp_code) {
  922 + th.setData({index: i});
1976 923 }
1977 924 }
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 925 }
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;
  926 + }
  927 + th.calculatePrice2()
2136 928  
2137   - //先要带is_pd_normal=1
2138   - if (gg.is_pd_normal) goods.is_pd_normal = 1;
  929 + },
2139 930  
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   - }
  931 + //--------立即购买时,使用余额--------
  932 + set_bn_useyuer: function () {
  933 + var th = this;
  934 + th.setData({bn_use_money: !th.data.bn_use_money});
  935 + th.calculatePrice2();
  936 + },
  937 + //-------------------计算物流---------------
  938 + calculatewuliu: function (code, o_shipping_price, goods_weight,
  939 + goods_piece, user_addr, freight_free, o_price, rs) {
  940 + var price = 0, th = this;
  941 + price += parseFloat(o_shipping_price);
  942 + //如果是包邮
  943 + if (freight_free > 0 && o_price >= freight_free) {
  944 + return 0;
  945 + }
  946 + if (user_addr == null) {
  947 + return 0;
  948 + }
  949 + //计算物流的config item;
  950 + var item = null;
  951 + //先根据 镇 县 区找计算的config
  952 + item = th.get_wuliu_config(user_addr.district, code, rs);
  953 + if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
  954 + if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
  955 + if (item == null) item = th.get_wuliu_default(code, rs);
  956 + if (item == null) return o_shipping_price;
  957 + var fw_price = 0, fp_price = 0;
  958 + item = item.config;
  959 + if (item == null) return o_shipping_price;
  960 + //------按重量----------
  961 + if (goods_weight >= 0 && item['money']) {
  962 + fw_price = parseFloat(item['money']);
  963 + if (goods_weight > item['first_weight']) {
  964 + var fw = goods_weight - item['first_weight'];
  965 + var n = Math.ceil(fw / item['second_weight'])
  966 + fw_price = fw_price + n * parseFloat(item['add_money']);
2151 967 }
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;
  968 + }
  969 + //------按件数----------
  970 + if (goods_piece > 0 && item['piecemoney']) {
  971 + fp_price = parseFloat(item['piecemoney']);
  972 + if (goods_piece > item['first_piece']) {
  973 + var fp = goods_piece - item['first_piece'];
  974 + var m = Math.ceil(fp / item['second_piece'])
  975 + fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
2160 976 }
  977 + }
  978 + var rspice = parseFloat(price + fw_price + fp_price);
  979 + return rspice;
  980 + },
2161 981  
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   - }
  982 + //------------循环获取config-----------
  983 + get_wuliu_config: function (region_id, code, rs) {
  984 + var item = null, rslist = rs.pageData;
  985 + for (var i = 0; i < rslist.length; i++) {
  986 + if (rslist[i].code == code && rslist[i].region_id == region_id) {
  987 + item = rslist[i];
2187 988 }
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("请新建收货地址");
  989 + }
  990 + return item;
  991 + },
  992 + //-------循环获取config,code default-------
  993 + get_wuliu_default: function (code, rs) {
  994 + var item = null, rslist = rs.pageData;
  995 + for (var i = 0; i < rslist.length; i++) {
  996 + if (rslist[i].shipping_code == code && rslist[i].is_default == 1) {
  997 + item = rslist[i];
2226 998 }
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   -
  999 + }
  1000 + return item;
  1001 + },
2233 1002  
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   - }
  1003 + //----------立即购买,选择物流-------------
  1004 + bindPickerChange: function (e) {
  1005 + var ind = e.detail.value
  1006 + this.setData({index: ind});
  1007 + this.calculatePrice2();
  1008 + },
  1009 + /*----券的所有操作----*/
  1010 + open_coupon_list: function (e) {
  1011 + var th = this;
  1012 + var pickid = e.currentTarget.dataset.pickid;
  1013 + var bn = e.currentTarget.dataset.bn;
  1014 + var cindx = e.currentTarget.dataset.cind;
  1015 + var get_by_quan_list_cart = th.data.get_by_quan_list_cart[pickid];
2240 1016  
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 1017  
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   - }
  1018 + if (bn == 1) {
  1019 + th.setData({open_quan: 1, selected_quan_pick: pickid, disabled: 1});
  1020 + } else {
  1021 + //---多单打开券的时候,就要判断券在其他门店是否有使用---
  1022 + var quanlist = th.data.cartlist[cindx].quan_list;
  1023 + var exp_type = th.data.cartlist[cindx].exp_type;
2286 1024  
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 1025  
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   - }
  1026 + //对于在其他门店已经选择了的券 要判断是否显示到界面
  1027 + var t_user = th.data.using_quan[pickid];
2323 1028  
  1029 + for (var i in quanlist) {
  1030 + quanlist[i].is_using = th.check_in_sele(quanlist[i].CashRepNo, pickid);
  1031 + if (t_user && quanlist[i].CashRepNo == t_user.coupon_no)
  1032 + quanlist[i].show_red = 1;
  1033 + else
  1034 + quanlist[i].show_red = 0;
  1035 + }
2324 1036  
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   - })
  1037 + if (get_by_quan_list_cart) {
  1038 + for (var i in get_by_quan_list_cart) {
  1039 + get_by_quan_list_cart[i].is_using = th.check_in_sele(get_by_quan_list_cart[i].no, pickid);
  1040 + if (t_user && get_by_quan_list_cart[i].no == t_user.coupon_no)
  1041 + get_by_quan_list_cart[i].show_red = 1;
  1042 + else
  1043 + get_by_quan_list_cart[i].show_red = 0;
2336 1044 }
  1045 + th.setData({by_quan_list_cart: get_by_quan_list_cart});
  1046 + } else {
  1047 + th.setData({by_quan_list_cart: null});
  1048 + }
2337 1049  
  1050 + th.setData({
  1051 + sele_cart_ind: cindx,
  1052 + sele_exp_type: exp_type,
  1053 + open_quan: 1,
  1054 + selected_quan_pick: pickid,
  1055 + selected_quan_list: quanlist,
  1056 + disabled: 1
  1057 + });
  1058 + }
  1059 + },
  1060 + close_coupon: function (e) {
  1061 + var th = this;
  1062 + th.setData({open_quan: 0, disabled: 0});
  1063 + },
2338 1064  
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);
  1065 + //---判断券时候在已经选择的列表中---
  1066 + check_in_sele: function (no, pick_id) {
  1067 + var th = this;
  1068 + if (th.data.using_quan.length <= 0) return false;
  1069 + for (var i in th.data.using_quan) {
  1070 + //--如果键值等于本身就要跳出--
  1071 + if (parseInt(i) == parseInt(pick_id)) continue;
  1072 + var item = th.data.using_quan[i];
  1073 + if (item.coupon_no == no) {
  1074 + return true;
2447 1075 }
  1076 + }
  1077 + return false;
  1078 + },
2448 1079  
  1080 + /*--点击选择券--*/
  1081 + sele_quan_item: function (e) {
  1082 + var th = this;
  1083 + var ind = e.currentTarget.dataset.ind;
  1084 + var quan_item = this.data.selected_quan_list[ind];
  1085 + var pickid = this.data.pickup.pickup_id; //现在选择的是哪一个门店
2449 1086  
  1087 + var no_use = e.currentTarget.dataset.no, quanlist = this.data.selected_quan_list;
  1088 + //---所有的券的显示红色选择都清理一遍---
  1089 + for (var i in quanlist) {
  1090 + quanlist[i].show_red = 0;
  1091 + }
  1092 + this.setData({selected_quan_list: quanlist});
  1093 + var by_quanlist = this.data.get_by_quan_list;
  1094 + if (by_quanlist) {
  1095 + //---所有的券的显示红色选择都清理一遍---
  1096 + for (var inb in by_quanlist) {
  1097 + by_quanlist[inb].show_red = 0;
  1098 + }
  1099 + this.setData({get_by_quan_list: by_quanlist});
2450 1100 }
2451 1101  
2452   - if (pdata.length == 0) return;
2453   - var str = JSON.stringify(pdata);
  1102 + var by_cart_list = this.data.by_quan_list_cart;
  1103 + if (by_cart_list) {
  1104 + //---所有的券的显示红色选择都清理一遍---
  1105 + for (var inc in by_cart_list) {
  1106 + by_cart_list[inc].show_red = 0;
  1107 + }
  1108 + this.setData({by_quan_list_cart: by_cart_list});
  1109 + }
2454 1110  
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);
  1111 + var using_quan = this.data.using_quan;
2510 1112  
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 () {
  1113 + //---如果是不使用优惠券---
  1114 + if (no_use == 1) {
  1115 + if (using_quan[pickid]) {
  1116 + using_quan[pickid].is_nouse_red = 1;
  1117 + }
  1118 + else {
  1119 + using_quan[pickid] = {is_nouse_red: 1};
  1120 + }
  1121 + this.setData({using_quan: using_quan, is_coupon: 2222});
  1122 + return;
  1123 + }
2532 1124  
2533   - }
2534   - });
2535   - }
2536 1125  
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   - })
  1126 + var txt = "selected_quan_list[" + ind + "].show_red";
  1127 + var obj = {};
  1128 + obj[txt] = 1;
  1129 + if (quan_item.show_red) {
  1130 + obj[txt] = 0;
  1131 + }
  1132 + this.setData(obj);
  1133 + console.log(this.data.selected_quan_list, "选中的券的下标", quan_item, "数据都在这里", txt);
  1134 + if (using_quan[pickid]) {
  1135 + using_quan[pickid].is_nouse_red = 0;
  1136 + }
  1137 + else {
  1138 + using_quan[pickid] = {is_nouse_red: 0};
  1139 + }
  1140 + this.setData({using_quan: using_quan});
2580 1141  
2581 1142 },
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;
  1143 + /*----- 点击选择包邮券 -----*/
  1144 + sele_quan_item_by: function (e) {
  1145 + var no_use = e.currentTarget.dataset.no;
  1146 + //立即购买的包邮券
  1147 + var by_quanlist = this.data.get_by_quan_list;
  1148 + if (by_quanlist) {
  1149 + //---所有的券的显示红色选择都清理一遍---
  1150 + for (var ind in by_quanlist) {
  1151 + by_quanlist[ind].show_red = 0;
2600 1152 }
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;
  1153 + this.setData({get_by_quan_list: by_quanlist});
  1154 + }
  1155 +
  1156 + //--购物车过来的包邮券--
  1157 + var by_cart_list = this.data.by_quan_list_cart;
  1158 + if (by_cart_list) {
  1159 + //---所有的券的显示红色选择都清理一遍---
  1160 + for (var ind in by_cart_list) {
  1161 + by_cart_list[ind].show_red = 0;
2608 1162 }
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];
  1163 + this.setData({by_quan_list_cart: by_cart_list});
  1164 + }
  1165 + //普通券
  1166 + var quanlist = this.data.selected_quan_list;
  1167 + if (quanlist) {
  1168 + //---所有的券的显示红色选择都清理一遍---
  1169 + for (var ind in quanlist) {
  1170 + quanlist[ind].show_red = 0;
2616 1171 }
2617   - })
2618   - var isok = 1;
2619   - if (goods_num > plist.CanOutQty - lock) {
2620   - isok = 0;
  1172 + this.setData({selected_quan_list: quanlist});
2621 1173 }
2622   - func(isok);
2623   - },
2624 1174  
2625   - useCoupon: function () {
2626   - if (this.data.order.couponNum <= 0) {
2627   - getApp().my_warnning("无可用优惠券", 0, this);
  1175 + var th = this;
  1176 + var using_quan = this.data.using_quan;
  1177 + //---如果是不使用优惠券---
  1178 + if (no_use == 1) {
  1179 + if (using_quan[th.data.selected_quan_pick]) {
  1180 + using_quan[th.data.selected_quan_pick].is_nouse_red = 1;
  1181 + }
  1182 + else {
  1183 + using_quan[th.data.selected_quan_pick] = {is_nouse_red: 1};
  1184 + }
  1185 + this.setData({using_quan: using_quan, is_coupon: 2222});
2628 1186 return;
2629 1187 }
2630 1188  
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});
  1189 + var pickid = th.data.selected_quan_pick; //现在选择的是哪一个门店
  1190 + var ind = e.currentTarget.dataset.ind;
  1191 + //--如果是立即购买的部分--
  1192 + var txt = "";
  1193 + var txt1 = "";
  1194 + var quan_item = null;
  1195 + if (th.data.is_b_now) {
  1196 + quan_item = this.data.get_by_quan_list[ind];
  1197 + txt = "get_by_quan_list[" + ind + "].show_red";
  1198 + var obj = {};
  1199 + obj[txt] = 1;
  1200 + this.setData(obj);
2659 1201 } 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   -
  1202 + txt = "by_quan_list_cart[" + ind + "].show_red";
  1203 + quan_item = th.data.by_quan_list_cart[ind];
  1204 + var obj = {};
  1205 + obj[txt] = 1;
  1206 + this.setData(obj);
  1207 + th.data.get_by_quan_list_cart[pickid] = JSON.parse(JSON.stringify(th.data.by_quan_list_cart)); //要把选中的弄回数组
  1208 + }
2679 1209  
  1210 + if (using_quan[th.data.selected_quan_pick]) {
  1211 + using_quan[th.data.selected_quan_pick].is_nouse_red = 0;
2680 1212 }
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   - }
  1213 + else {
  1214 + using_quan[th.data.selected_quan_pick] = {is_nouse_red: 0};
2692 1215 }
2693   - //----计算此时购物车的价格----
2694   - th.calculatePrice();
  1216 + this.setData({using_quan: using_quan});
2695 1217 },
2696   -
2697   - //--------立即购买时,选择自提和物流----------
2698   - setexptype: function (t) {
  1218 + //--确认使用券---
  1219 + confirm_quan: function () {
  1220 + var using_quan = this.data.using_quan; //正在使用中的券列表
  1221 + var pickid = this.data.pickup.pickup_id; //选中的门店ID
2699 1222 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   - }
  1223 + var selected_quan_list = this.data.selected_quan_list; //选择了那个门店的券列表
  1224 + var get_by_quan_list = this.data.get_by_quan_list; //立即购买的包邮券列表
  1225 + var by_quan_list_cart = this.data.by_quan_list_cart; //购物车购买的包邮券列表
2705 1226  
2706   - //当物流为空的时候。
2707   - if (ty == 0 && th.data.wu_arr == null) {
2708   - th.data.isget_by_quan = {};
2709   - return th.get_wuliu(th.calculatePrice2());
  1227 + //循环普通的券
  1228 + for (var i in selected_quan_list) {
  1229 + var item = selected_quan_list[i];
  1230 + if (item.show_red) {
  1231 + th.insert_into_using_quan(item, using_quan, pickid);
  1232 + return;
  1233 + }
2710 1234 }
  1235 + //循环包邮的券,立即购买的
  1236 + for (var i in get_by_quan_list) {
  1237 + var item = get_by_quan_list[i];
  1238 + if (item.show_red) {
  1239 + if (th.data.is_no_by[pickid] == 1) {
  1240 + getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th);
  1241 + return false;
  1242 + }
  1243 + if (th.data.is_by[pickid] == 1) {
  1244 + getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th);
  1245 + return false;
  1246 + }
2711 1247  
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: {}});
  1248 + th.insert_into_using_quan(item, using_quan, pickid, 1);
  1249 + return;
2717 1250 }
2718 1251 }
2719 1252  
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   - }
  1253 + //循环包邮的券
  1254 + for (var i in by_quan_list_cart) {
  1255 + var item = by_quan_list_cart[i];
  1256 + if (item.show_red) {
  1257 + if (th.data.is_no_by[pickid] == 1) {
  1258 + getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th);
  1259 + return false;
  1260 + }
  1261 + if (th.data.is_by[pickid] == 1) {
  1262 + getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th);
  1263 + return false;
2728 1264 }
  1265 + th.insert_into_using_quan(item, using_quan, pickid, 1);
  1266 + return;
2729 1267 }
2730 1268 }
2731   - th.calculatePrice2()
  1269 +
  1270 + //选择了的券,看是不是点击了不使用券,点击了不使用优惠券
  1271 + if (using_quan[pickid]) {
  1272 + if (using_quan[pickid].is_nouse_red == 1) {
  1273 + using_quan[pickid] = {is_nouse_red: 1};
  1274 + th.calculatePrice2();
  1275 + th.setData({open_quan: 0});
  1276 + th.setData({using_quan: using_quan});
  1277 + }
  1278 + }
  1279 +
  1280 +
2732 1281  
2733 1282 },
2734 1283  
2735   - //--------立即购买时,使用余额--------
2736   - set_bn_useyuer: function () {
  1284 + //----把券插入之后的操作,同时还要重新计算价格----
  1285 + insert_into_using_quan: function (item, using_quan, pickid, isby) {
2737 1286 var th = this;
2738   - th.setData({bn_use_money: !th.data.bn_use_money});
  1287 + if (isby == 1) {
  1288 + using_quan[pickid] = {
  1289 + coupon_no: item.no,
  1290 + money: 0,
  1291 + is_nouse_red: 0,
  1292 + region_list: item.region_list,
  1293 + goods_list: item.goods_list
  1294 + };
  1295 + using_quan[pickid].isby = 1;
  1296 + } else {
  1297 + using_quan[pickid] = {coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0};
  1298 + using_quan[pickid].isby = 0;
  1299 + }
  1300 + this.setData({using_quan: using_quan});
2739 1301 th.calculatePrice2();
  1302 + th.setData({open_quan: 0});
2740 1303 },
2741   - set_js_useyuer: function () {
2742   - var th = this;
2743   - th.setData({js_use_money: !th.data.js_use_money});
2744   - th.calculatePrice();
  1304 +
  1305 + cart_set_err: function (e) {
  1306 + var txt = e.currentTarget.dataset.err;
  1307 + var ob = {};
  1308 + ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif";
  1309 + this.setData(ob);
2745 1310 },
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']);
  1311 + //--验证是否已经冻结--
  1312 + check_is_frozenQuan: function (quanlist, frozenQuan, isby) {
  1313 + console.log("券列表", quanlist);
  1314 + if (!quanlist) return null;
  1315 + if (!frozenQuan) return quanlist;
  1316 + var arr = [];
  1317 + for (var i = 0; i < quanlist.length; i++) {
  1318 + var item = quanlist[i];
  1319 + var is_find = 0;
  1320 + var Q_no = quanlist[i].CashRepNo;
  1321 + if (isby) Q_no = quanlist[i].no;
  1322 + for (var j = 0; j < frozenQuan.length; j++) {
  1323 + var q_no = frozenQuan[j].cashRepNo;
  1324 + if (Q_no == q_no) {
  1325 + is_find = 1;
  1326 + break;
  1327 + }
2785 1328 }
  1329 + if (!is_find) arr.push(item);
2786 1330 }
2787   - var rspice = parseFloat(price + fw_price + fp_price);
2788   - return rspice;
  1331 + return arr;
2789 1332 },
2790 1333  
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   - }
  1334 + //// 开启物流的弹窗
  1335 + show_wu_arr: function (e) {
  1336 + var wu_arr_txt = e.currentTarget.dataset.txt;
  1337 + var w_sele_index = e.currentTarget.dataset.w_sele_index;
  1338 + var is_express = null;
  1339 + var ob = {open_express: 1, wu_arr_txt: wu_arr_txt, disabled: 1};
  1340 +
  1341 + //--如果是多个门店的时候--
  1342 + if (w_sele_index != undefined) {
  1343 + is_express = this.data.cartlist[w_sele_index].wind;
  1344 + ob['is_express'] = is_express;
2798 1345 }
2799   - return item;
  1346 + this.setData(ob);
2800 1347 },
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;
  1348 + // 关闭物流的弹窗
  1349 + close_express: function () {
  1350 + this.setData({open_express: 0, disabled: 0});
2810 1351 },
2811   -
2812   - //----------立即购买,选择物流-------------
2813   - bindPickerChange: function (e) {
2814   - var ind = e.detail.value
2815   - this.setData({index: ind});
2816   - this.calculatePrice2();
  1352 + // 选择物流
  1353 + click_express_name: function (e) {
  1354 + var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
  1355 + var index = e.currentTarget.dataset.idxe;
  1356 + var ob = {is_express: index, is_shipping_code: shippingcode, disabled: 0};
  1357 + ob[this.data.wu_arr_txt] = index;
  1358 + this.setData(ob);
2817 1359 },
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();
  1360 +
  1361 + //点击确定物流
  1362 + determine_expres: function (e) {
  1363 + this.setData({open_express: 0});
  1364 + this.calculatePrice2();
2823 1365 },
2824 1366  
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];
  1367 + //点击打开优惠券使用说明
  1368 + clik_coupons: function (e) {
  1369 + var ind = e.currentTarget.dataset.idx;
  1370 + var is_open = this.data.selected_quan_list[ind].is_open;
2832 1371  
  1372 + if (is_open == 1) is_open = 0;
  1373 + else is_open = 1;
2833 1374  
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;
  1375 + var txt = "selected_quan_list[" + ind + "].is_open"
  1376 + var obj = {};
  1377 + obj[txt] = is_open;
2840 1378  
  1379 + this.setData(obj);
  1380 + this.setData({disabled: 1})
  1381 + },
2841 1382  
2842   - //对于在其他门店已经选择了的券 要判断是否显示到界面
2843   - var t_user = th.data.using_quan[pickid];
  1383 + clik_coupons2: function (e) {
  1384 + var ind = e.currentTarget.dataset.idx;
  1385 + var is_open = this.data.get_by_quan_list[ind].is_open;
2844 1386  
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   - }
  1387 + if (is_open == 1) is_open = 0;
  1388 + else is_open = 1;
2852 1389  
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   - }
  1390 + var txt = "get_by_quan_list[" + ind + "].is_open"
  1391 + var obj = {};
  1392 + obj[txt] = is_open;
2865 1393  
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});
  1394 + this.setData(obj);
  1395 + this.setData({disabled: 1})
2880 1396 },
2881 1397  
2882   - //---判断券时候在已经选择的列表中---
2883   - check_in_sele: function (no, pick_id) {
  1398 +
  1399 + //设置默认物流
  1400 + select_default_logistics: function () {
2884 1401 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;
  1402 + var is_shipping_code = this.data.is_shipping_code
  1403 + getApp().request.put("/api/weshop/users/update", {
  1404 + data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code},
  1405 + success: function (rse) {
  1406 + if (rse.data.code == 0) {
  1407 + getApp().globalData.userInfo.def_exp_code = is_shipping_code;
  1408 + th.setData({open_express: 0});
  1409 + //----计算此时购物车的价格----
  1410 + th.calculatePrice2();
  1411 +
  1412 + }
2892 1413 }
2893   - }
2894   - return false;
  1414 + })
2895 1415 },
2896 1416  
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;
  1417 + //更新下默认,在onshow里面
  1418 + update_code(){
  1419 + var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
  1420 + //--定时器,判断wu_arr不未空--
  1421 + var uii = setInterval(function () {
  1422 + if (th.data.wu_arr) {
  1423 + clearInterval(uii);
  1424 + for (var k = 0; k < th.data.wu_arr.length; k++) {
  1425 + var item = th.data.wu_arr[k];
  1426 + if (def_exp_code == item.code) {
  1427 + m_wind = k;
2915 1428 }
2916 1429 }
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];
  1430 + //--如果是立即购买--
  1431 + if (th.data.is_b_now == 1) {
  1432 + th.setData({index: m_wind, is_express: m_wind});
  1433 + } else {
  1434 + var ui = setInterval(function () {
  1435 + if (th.data.cartlist) {
  1436 + var c_arr = th.data.cartlist;
  1437 + for (var i in c_arr) {
  1438 + c_arr[i].wind = m_wind;
  1439 + }
  1440 + th.setData({cartlist: c_arr, is_express: m_wind})
  1441 + clearInterval(ui);
2924 1442 }
2925   - }
  1443 + }, 500)
2926 1444 }
2927   - if (!gd) {
2928   - getApp().my_warnning("未找到指定商品使用", 0, this, 600);
2929   - return false;
  1445 + }
  1446 + }, 500);
  1447 + },
  1448 + //-----获取购物车进来的劵-------
  1449 + get_cart_quan: async function (order_prom_list_cart) {
  1450 + var th = this;
  1451 + var is_xz_yh = 1;
  1452 + //等待值的出现
  1453 + //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () {
  1454 + //var arr=th.data.order_prom_list_cart;
  1455 + var arr = order_prom_list_cart;
  1456 + if (!arr) arr = [];
  1457 + //如果系统有限制使用优惠券
  1458 + if (th.data.is_close_quan) return false;
  1459 +
  1460 + //------------开始计算使用优惠券相关------------
  1461 + for (var ind in arr) {
  1462 + var ep = arr[ind];
  1463 + var goodlist = ep.goods;
  1464 + var pickup_id = ep.pickup_id;
  1465 + //--更优惠券抵用有关,立即购买的,如果是购物车,如果有等级价还有考虑等级价的东西
  1466 + //就要把相应的值,写入cartlist数组中--
  1467 + var ckeck_quan_price = 0,
  1468 + check_quan_price_list = '',
  1469 + check_quan_ware_list = '';
  1470 +
  1471 + for (var i in goodlist) {
  1472 + var gd = goodlist[i];
  1473 + //--如果是秒杀就跳出,如果是赠品,如果是组合购,如果是限制使用优惠券--
  1474 + if (gd.prom_type == 1 || gd.is_gift || gd.prom_type == 7) {
  1475 + continue;
  1476 + }
  1477 + //如果有限制使用优惠券,就要返回
  1478 + if (gd.prom_type == 3) {
  1479 + if (th.data.prom_goods_map[pickup_id][gd.prom_id].is_xz_yh) continue;
  1480 + th.data.prom_goods_map[pickup_id][gd.prom_id].coupon_sele = 1;
2930 1481 }
2931   - //计算价格,如果有平摊的实收要计算实收的金额
  1482 + is_xz_yh = 0;
2932 1483 var item_price = gd.goods_price * gd.goods_num;
2933   - //-- 如果有平摊下去,有实收价格的时候,就要用account_fir来计算价格 --
  1484 + //-- 如果有平摊下去,有实收价格的时候,就要用account来计算价格 --
2934 1485 if (gd.account_fir != null && gd.account_fir != undefined) {
2935 1486 item_price = gd.account_fir * gd.goods_num;
2936 1487 }
  1488 + ckeck_quan_price += item_price;
2937 1489  
2938   - if (item_price < parseFloat(quan_item.BuySum)) {
2939   - getApp().my_warnning("该单品金额没有大于等于" + quan_item.BuySum + "元时不能使用优惠券", 0, this, 600);
2940   - return false;
  1490 + //--组装价格list--
  1491 + if (check_quan_price_list) {
  1492 + check_quan_price_list += "," + item_price;
  1493 + } else {
  1494 + check_quan_price_list = item_price;
  1495 + }
  1496 + //--组装商品的线下erpwareid--
  1497 + if (check_quan_ware_list) {
  1498 + check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']);
  1499 + } else {
  1500 + check_quan_ware_list = encodeURIComponent(gd['erpwareid']);
2941 1501 }
2942 1502 }
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;
  1503 + //优惠券优惠的金额要控制到优惠券的选择条件
  1504 + var cut_price = 0;
  1505 + for (var i in th.data.prom_goods_map[pickup_id]) {
  1506 + var obj = th.data.prom_goods_map[pickup_id][i];
  1507 + if (obj.coupon_sele) {
  1508 + cut_price += obj.price - obj.prom_price;
  1509 + }
2956 1510 }
2957   - this.setData({get_by_quan_list: by_quanlist});
2958   - }
2959 1511  
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;
  1512 + arr[ind].ckeck_quan_price = ckeck_quan_price - cut_price;
  1513 + arr[ind].check_quan_ware_list = check_quan_ware_list;
  1514 + arr[ind].check_quan_price_list = check_quan_price_list;
  1515 +
  1516 + //是否关闭使用优惠券
  1517 + if (th.data.is_close_quan != 1 && !is_xz_yh) {
  1518 + //--调用接口,获取优惠券的列表,3秒钟内控制接口请求--
  1519 + var url = "/api/weshop/couponList/getUseCouponList";
  1520 + await app.request.promiseGet(url, {
  1521 + data: {
  1522 + storeId: oo.stoid,
  1523 + userId: app.globalData.user_id,
  1524 + BuySum: ckeck_quan_price,
  1525 + WareIds: check_quan_ware_list,
  1526 + pageSize: 100
  1527 + }
  1528 + }).then(res => {
  1529 + if (res.data.code == 0) {
  1530 + var quan_list = res.data.data.pageData;
  1531 + arr[ind].quan_list = th.check_is_frozenQuan(quan_list, th.data.frozenQuan);
  1532 + }
  1533 + })
2965 1534 }
2966   - this.setData({by_quan_list_cart: by_cart_list});
2967 1535 }
2968 1536  
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};
  1537 + //如果是搭配购的立即购买的时候
  1538 + if (th.data.is_b_now) {
  1539 + if (arr && arr.length > 0) {
  1540 + var quanlist = arr[0].quan_list;
  1541 + th.setData({selected_quan_list: quanlist, cartlist: arr})
2979 1542 }
2980   - this.setData({using_quan: using_quan, is_coupon: 2222});
2981   - return;
  1543 + } else {
  1544 + th.setData({cartlist: arr})
  1545 + th.set_can_num();
2982 1546 }
  1547 + },
2983 1548  
  1549 + //------ 获取立即购买的购物车的劵 --------
  1550 + get_buy_now_quan: function () {
  1551 + var quanlist = null, th = this, frozenQuan = null;
  1552 + var allprice =this.data.pre_arr.presell_price*this.data.order_goods.goods_num;
  1553 + th.data.ckeck_quan_price = allprice;
2984 1554  
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};
  1555 + //--如果商家后台没有限制使用优惠券,同时商品的优惠活动没有限制使用优惠券--
  1556 + if (th.data.is_close_quan != 1) {
  1557 + var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
  1558 + var url = "/api/weshop/couponList/getUseCouponList";
  1559 + app.request.promiseGet(url0, {1: 1}).then(res => {
  1560 + if (res.data.code == 0) {
  1561 + frozenQuan = res.data.data;
  1562 + th.data.frozenQuan = frozenQuan;
  1563 + }
  1564 + app.request.time_limit_get(6, url, {
  1565 + data: {
  1566 + storeId: oo.stoid,
  1567 + userId: app.globalData.user_id,
  1568 + BuySum: th.data.ckeck_quan_price,
  1569 + WareIds: encodeURIComponent(th.data.check_quan_ware_list),
  1570 + pageSize: 100
  1571 + },
  1572 + success: function (res) {
  1573 + if (res.data.code == 0) {
  1574 + quanlist = res.data.data.pageData;
  1575 + if (quanlist) {
  1576 + quanlist = th.check_is_frozenQuan(quanlist, frozenQuan);
  1577 + th.setData({selected_quan_list: quanlist})
  1578 + }
  1579 + }
  1580 + }
  1581 + })
  1582 + })
2998 1583 }
2999   - this.setData({using_quan: using_quan});
3000   -
3001 1584 },
3002 1585  
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;
  1586 + //检查区域是不是包邮
  1587 + check_area: function (arr) {
  1588 + var user_addr = this.data.user_addr;
  1589 + if (!user_addr) return 0;
  1590 + for (var i in arr) {
  1591 + var item = arr[i];
  1592 + if (user_addr.twon == item || user_addr.district == item
  1593 + || user_addr.city == item || user_addr.province == item) {
  1594 + return 0;
3013 1595 }
3014   - this.setData({get_by_quan_list: by_quanlist});
3015 1596 }
  1597 + return 1;
  1598 + },
3016 1599  
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});
  1600 + //检查立即购买的商品是不是不包邮
  1601 + check_good: function (arr, goods_id) {
  1602 + if (!goods_id) goods_id = this.data.bn_goods.goods_id;
  1603 + for (var i in arr) {
  1604 + var item = arr[i];
  1605 + if (goods_id == item) return 0;
3034 1606 }
  1607 + return 1;
  1608 + },
  1609 + check_by_area: function (region_list) {
  1610 + var arr = region_list.split(",");
  1611 + var check = this.check_area(arr);
  1612 + return !check;
  1613 + },
  1614 + check_by_goods: function (goods_list, goods_id) {
  1615 + var arr = goods_list.split(",");
  1616 + var check = this.check_good(arr, goods_id);
  1617 + return !check;
  1618 + },
  1619 +
3035 1620  
  1621 + //--检查订单优惠--
  1622 + check_is_order_prom: function (condition, func, pick) {
3036 1623 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};
  1624 + pick = this.data.pickup.pickup_id;
  1625 + //---获取订单优惠---
  1626 + getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
  1627 + data: {store_id: os.stoid, orderAmount: condition}
  1628 + }).then(res => {
  1629 + if (res.data.code == 0) {
  1630 + var data = res.data.data;
  1631 + th.data.order_prom[pick] = data;
3045 1632 }
3046   - this.setData({using_quan: using_quan, is_coupon: 2222});
3047   - return;
3048   - }
  1633 + func();
  1634 + })
  1635 + },
3049 1636  
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);
  1637 + //--- 加入优惠活动的映射中,同时要有一个good列表 ---
  1638 + add_prom_goods_map: async function (item) {
  1639 + var th = this;
  1640 + var pickid = item.pick_id;
  1641 + var map = th.data.prom_goods_map;
  1642 + var obj = map[pickid];
  1643 +
  1644 + if (map[pickid]) {
  1645 + if (map[pickid][item.prom_id]) {
  1646 + var ob = map[pickid][item.prom_id];
  1647 + ob.price += item.goods_price * item.goods_num;
  1648 + ob.goods_num += item.goods_num;
  1649 + ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
  1650 +
  1651 + } else {
  1652 + var prom = null;
  1653 + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
  1654 + if (res.data.code == 0) {
  1655 + prom = res.data.data;
  1656 + }
  1657 + })
  1658 + var ob = {};
  1659 + ob.prom_id = item.prom_id;
  1660 + ob.price = item.goods_price * item.goods_num;
  1661 + ob.goods_num = item.goods_num;
  1662 + ob.is_bz = prom.is_bz;
  1663 + ob.is_xz_yh = prom.is_xz_yh;
  1664 + ob.goods = new Array();
  1665 + ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
  1666 + map[pickid][item.prom_id] = ob;
  1667 + }
3062 1668 } else {
3063   - txt = "by_quan_list_cart[" + ind + "].show_red";
3064   - quan_item = th.data.by_quan_list_cart[ind];
  1669 + var ob = {};
  1670 + var prom = null;
  1671 + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
  1672 + if (res.data.code == 0) {
  1673 + prom = res.data.data;
  1674 + }
  1675 + })
  1676 + ob.prom_id = item.prom_id;
  1677 + ob.price = item.goods_price * item.goods_num;
  1678 + ob.goods_num = item.goods_num;
  1679 + ob.is_bz = prom.is_bz;
  1680 + ob.is_xz_yh = prom.is_xz_yh;
  1681 + ob.goods = new Array();
  1682 + ob.goods.push({goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num});
  1683 +
3065 1684 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   - }
  1685 + obj[item.prom_id] = ob;
  1686 + map[pickid] = obj;
3070 1687  
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 1688 }
3077   - this.setData({using_quan: using_quan});
3078 1689 },
3079 1690  
3080   - //--确认使用券---
3081   - confirm_quan: function () {
3082   - var using_quan = this.data.using_quan; //正在使用中的券列表
3083   - var pickid = this.data.selected_quan_pick; //选中的门店ID
  1691 + //计算立即购买赠品的物流费用
  1692 + 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) {
  1693 + var good = this.data.buy_now_gift_goods;
  1694 + var goods_weight = -1, goods_piece = -1;
  1695 + var gift_shipping_price = 0;
3084 1696 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;
  1697 + switch (good['exp_sum_type']) {
  1698 + case 1:
  1699 + //统一运费
  1700 + gift_shipping_price += good['uniform_exp_sum'];
  1701 + gift_shipping_price += o_shipping_price;
  1702 + break;
  1703 + case 2:
  1704 + if (goods_weight < 0) goods_weight = 0;
  1705 + //累积商品重量 每种商品的重量 * 数量
  1706 + goods_weight += good['weight'] * good['buynum'];
  1707 + if (goods_weight1 > 0) {
  1708 + goods_weight += goods_weight1;
3106 1709 }
3107   - if (th.data.is_by[pickid] == 1) {
3108   - getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th);
3109   - return false;
  1710 + break;
  1711 + case 3:
  1712 + if (goods_piece < 0) goods_piece = 0;
  1713 + //累积商品数量
  1714 + goods_piece += good['buynum'];
  1715 + if (goods_piece1) {
  1716 + goods_piece += goods_piece1;
3110 1717 }
3111   -
3112   - th.insert_into_using_quan(item, using_quan, pickid, 1);
3113   - return;
3114   - }
  1718 + break;
3115 1719 }
3116 1720  
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;
  1721 +
  1722 + //如果有设置不包邮区域的时候
  1723 + if (no_by_data && no_by_data.region_list) {
  1724 + if (th.check_by_area(no_by_data.region_list)) {
  1725 + gift_freight_free = 0;
  1726 + th.data.is_no_by[bn_pick] = 1;
3131 1727 }
3132 1728 }
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;
  1729 + //如果有设置不包邮商品
  1730 + if (no_by_data && no_by_data.goods_list && gift_freight_free) {
  1731 + if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) {
  1732 + gift_freight_free = 0;
3146 1733 }
3147 1734 }
  1735 +
  1736 + var t_shipping_price =
  1737 + this.calculatewuliu(code, gift_shipping_price, goods_weight,
  1738 + goods_piece, user_addr, gift_freight_free, allpice, rs);
  1739 + return t_shipping_price;
  1740 +
3148 1741 },
3149 1742  
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;
  1743 + //从优惠的映射中拿出商品从表的item
  1744 + item_map_get_goods: function (goods_id, map) {
  1745 + for (var i in map.goods) {
  1746 + if (map.goods[i].goods_id == goods_id) return map.goods[i];
3165 1747 }
3166   - this.setData({using_quan: using_quan});
3167   - if (th.data.is_b_now == 1) {
3168   - th.calculatePrice2();
3169   - } else {
3170   - th.calculatePrice();
  1748 + },
  1749 + //从优惠的映射中拿出商品从表的item
  1750 + arr_get_goods: function (goods_id, arr) {
  1751 + for (var i in arr) {
  1752 + if (arr[i].goods_id == goods_id) return arr[i];
3171 1753 }
3172   - th.setData({open_quan: 0});
3173 1754 },
3174 1755  
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;
  1756 + //检查是不是有其他门店的订单在选择了券
  1757 + check_other_use: function (iter, pkid) {
  1758 + var using = this.data.using_quan;
  1759 + var is_use = 0;
  1760 + if (using) {
  1761 + for (var i in using) {
  1762 + if (i == pkid) continue;
  1763 + if (iter.CashRepNo == using[i].coupon_no) {
  1764 + is_use = 1;
3196 1765 break;
3197 1766 }
3198 1767 }
3199   - if (!is_find) arr.push(item);
3200 1768 }
3201   - return arr;
  1769 + return is_use;
3202 1770 },
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;
  1771 + //检查是不是有其他门店的订单在选择了包邮券
  1772 + check_other_use_by: function (iter, pkid) {
  1773 + var using = this.data.using_quan;
  1774 + var is_use = 0;
  1775 + if (using) {
  1776 + for (var i in using) {
  1777 + if (i == pkid) continue;
  1778 + if (iter.no == using[i].coupon_no) {
  1779 + is_use = 1;
  1780 + break;
  1781 + }
  1782 + }
3215 1783 }
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();
  1784 + return is_use;
3238 1785 },
3239 1786  
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 1787  
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 1788  
3260   - if (is_open == 1) is_open = 0;
3261   - else is_open = 1;
  1789 + //----计算物流的钱----
  1790 + calculate_wuliu() {
  1791 + var to = getApp(), th = this;
  1792 + to.getConfig2(function (ee) {
  1793 + to.getwuliuprice(async function (rs) {
  1794 + var o_shipping_price = 0,
  1795 + goods_weight = -1,
  1796 + goods_piece = -1,
  1797 + good = th.data.goods,
  1798 + quan_price=0,
  1799 + exp_price=0;
3262 1800  
3263   - var txt = "get_by_quan_list[" + ind + "].is_open"
3264   - var obj = {};
3265   - obj[txt] = is_open;
  1801 + var quan_no = null;
  1802 + var bn_pick=th.data.pickup.pickup_id;
  1803 + var allpice =th.data.all_price;
3266 1804  
3267   - this.setData(obj);
3268   - this.setData({disabled: 1})
3269   - },
  1805 + if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
  1806 + quan_no = th.data.using_quan[bn_pick].coupon_no;
3270 1807  
  1808 + if (quan_no) {
  1809 + if (th.data.using_quan[bn_pick].isby != 1) {
  1810 + //---获取优惠券优惠---
  1811 + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", {
  1812 + data: {
  1813 + storeId: oo.stoid,
  1814 + CashRepNo: quan_no,
  1815 + WaresSum: th.data.ckeck_quan_price,
  1816 + WareIds: th.data.check_quan_ware_list
  1817 + }
  1818 + }).then(res => {
  1819 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  1820 + quan_price = res.data.data[0].WareCashSum;
  1821 + }
  1822 + })
3271 1823  
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();
  1824 + if(quan_price>0) {
  1825 + if (quan_price < allpice) th.setData({quan_price: quan_price})
  1826 + else {
  1827 + th.setData({quan_price: allpice})
  1828 + }
  1829 + }else{
  1830 + th.setData({quan_price: 0})
  1831 + }
  1832 + }
  1833 + }else{
  1834 + th.setData({quan_price: 0})
3285 1835 }
3286   - }
3287   - })
3288   - },
3289 1836  
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;
  1837 + //-----------当地址不为空,且是物流时,计算物流费用----------
  1838 + if (th.data.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) {
  1839 + //看是不是有调用过包邮券,如果活动可以使用优化券的情况下
  1840 + if (!th.data.isget_by_quan[bn_pick] && th.data.is_usecoupon) {
  1841 + var condition = allpice - quan_price;
  1842 + //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额,见到优惠券的钱---
  1843 + getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", {
  1844 + data: {
  1845 + store_id: os.stoid,
  1846 + isuse: 0,
  1847 + condition: condition,
  1848 + user_id: getApp().globalData.user_id,
  1849 + pageSize: 2000
  1850 + }
  1851 + }).then(res => {
  1852 + if (res.data.code == 0 && res.data.data.total > 0) {
  1853 + //此时要循环判断包邮的地区,不包邮商品是不是符合
  1854 + var arr = [], quanlist = res.data.data.pageData;
  1855 + quanlist = th.check_is_frozenQuan(quanlist, th.data.frozenQuan, 1);
  1856 + for (var i in quanlist) {
  1857 + var item = quanlist[i];
  1858 + if (item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域
  1859 + if (item.goods_list && th.check_by_goods(item.goods_list)) continue; //如果是不包邮商品
  1860 + arr.push(item);
  1861 + }
  1862 + if (arr) {
  1863 + th.setData({get_by_quan_list: arr});
  1864 + }
  1865 + th.data.isget_by_quan[bn_pick] = 1;
  1866 + }
  1867 + })
  1868 + }
  1869 + if (quan_no && th.data.using_quan[bn_pick].isby == 1) {
  1870 + exp_price=0;
  1871 + }else{
  1872 + switch (good['exp_sum_type']) {
  1873 + case 1:
  1874 + //统一运费
  1875 + o_shipping_price += good['uniform_exp_sum'];
  1876 + break;
  1877 + case 2:
  1878 + if (goods_weight < 0) goods_weight = 0;
  1879 + //累积商品重量 每种商品的重量 * 数量
  1880 + goods_weight += good['weight'] * th.data.order.order_goods['goods_num'];
  1881 + break;
  1882 + case 3:
  1883 + if (goods_piece < 0) goods_piece = 0;
  1884 + //累积商品数量
  1885 + goods_piece += th.data.order.order_goods['goods_num'];
  1886 + break;
  1887 + }
  1888 +
  1889 + var code = th.data.wu_arr[th.data.index].code;
  1890 + var freight_free = ee.freight_free; //全场满多少包邮
  1891 + var shipping_price =
  1892 + th.calculatewuliu(code, o_shipping_price, goods_weight,
  1893 + goods_piece, th.data.user_addr, freight_free, allpice, rs);
  1894 + exp_price = parseFloat(shipping_price).toFixed(2);
3301 1895 }
3302   - }
3303   - //--如果是立即购买--
3304   - if (th.data.is_b_now == 1) {
3305   - th.setData({index: m_wind, is_express: m_wind});
  1896 + th.wuliu_next(allpice,quan_price,exp_price);
3306 1897 } 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)
  1898 + th.wuliu_next(allpice,quan_price,exp_price);
3317 1899 }
3318   - }
3319   - }, 500);
  1900 + });
  1901 + });
3320 1902 },
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;
  1903 + //相同的东西统一在一起
  1904 + wuliu_next( allpice,quan_price,exp_price){
  1905 + var th=this;
  1906 + var o_condition =parseFloat(allpice)-parseFloat(quan_price);
  1907 + if(o_condition<0) o_condition=0;
  1908 + //如果同意参与订单优惠
  1909 + if (o_condition > 0 && this.data.pre_arr.is_useorderyh) {
  1910 + th.check_is_order_prom(o_condition, function () {
  1911 + var bn_pick=th.data.pickup.pickup_id
  1912 + var order_prom_amount = 0;
  1913 + var order_prom_id = 0;
  1914 + var order_m=0;
  1915 + if (th.data.order_prom[bn_pick]) {
  1916 + var ord_prom = th.data.order_prom[bn_pick];
  1917 + order_prom_id = ord_prom['id'];
  1918 + switch (ord_prom['type']) {
  1919 + case 0:
  1920 + order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折
  1921 + order_prom_amount = (o_condition - order_m).toFixed(2);
  1922 + break;
  1923 + case 1:
  1924 + order_m = o_condition - ord_prom['expression'];//满额优惠金额
  1925 + order_prom_amount = ord_prom['expression'];
  1926 + break;
  1927 + }
  1928 + o_condition=order_m;
3354 1929 }
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;
  1930 +
  1931 + //--订单优惠的显示--
  1932 + if (order_prom_id > 0) {
  1933 + var order_prom_txt1 = "order_prom_id";
  1934 + var order_prom_txt2 = "order_prom_amount";
  1935 + th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount})
3360 1936 }
3361   - ckeck_quan_price += item_price;
3362 1937  
3363   - //--组装价格list--
3364   - if (check_quan_price_list) {
3365   - check_quan_price_list += "," + item_price;
  1938 + th.setData({ exp_price: exp_price, order_m: parseFloat(o_condition) +parseFloat(exp_price) })
  1939 +
  1940 + })
  1941 + }else{
  1942 + th.setData({ exp_price: exp_price, order_m: parseFloat(o_condition)+parseFloat(exp_price) })
  1943 + }
  1944 + },
  1945 +
  1946 + //-- 获取时间差 --
  1947 + get_diff(){
  1948 +
  1949 + switch (this.data.act.presell_type) {
  1950 + //部分定金
  1951 + case 0:
  1952 + if (this.data.act.pay_begindate > ut.gettimestamp()) {
  1953 + this.setData({no_start: 1})
  1954 + } else if (this.data.act.pay_enddate < ut.gettimestamp()) {
  1955 + this.setData({is_end: 1})
3366 1956 } else {
3367   - check_quan_price_list = item_price;
  1957 + var end_time = this.data.act.pay_enddate;
  1958 + var e_str = ut.formatTime(end_time);
  1959 + var new_date = new Date(); //新建一个日期对象,默认现在的时间
  1960 + var old_date = new Date(e_str.replace(/-/g, '/')); //设置过去的一个时间点,"yyyy-MM-dd HH:mm:ss"格式化日期
  1961 + var difftime = (new_date - old_date) / 1000; //计算时间差,并把毫秒转换成秒
  1962 + var days = parseInt(difftime / 86400); // 天 24*60*60*1000
  1963 + var hours = parseInt(difftime / 3600) - 24 * days; // 小时 60*60 总小时数-过去的小时数=现在的小时数
  1964 + var minutes = parseInt(difftime % 3600 / 60); // 分钟 -(day*24) 以60秒为一整份 取余 剩下秒数 秒数/60 就是分钟数
  1965 + var seconds = parseInt(difftime % 60); // 以60秒为一整份 取余 剩下秒数
  1966 + this.setData({days: days, hours: hours, minutes: minutes, seconds: seconds})
3368 1967 }
3369   - //--组装商品的线下erpwareid--
3370   - if (check_quan_ware_list) {
3371   - check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']);
  1968 + break;
  1969 + //全额付款
  1970 + case 1:
  1971 + if (this.data.act.start_time > ut.gettimestamp()) {
  1972 + this.setData({no_start: 1})
  1973 + } else if (this.data.act.end_time < ut.gettimestamp()) {
  1974 + this.setData({is_end: 1})
3372 1975 } 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;
  1976 + var end_time = this.data.act.end_time;
  1977 + var e_str = ut.formatTime(end_time);
  1978 + var new_date = new Date(); //新建一个日期对象,默认现在的时间
  1979 + var old_date = new Date(e_str.replace(/-/g, '/')); //设置过去的一个时间点,"yyyy-MM-dd HH:mm:ss"格式化日期
  1980 + var difftime = (new_date - old_date) / 1000; //计算时间差,并把毫秒转换成秒
  1981 + var days = parseInt(difftime / 86400); // 天 24*60*60*1000
  1982 + var hours = parseInt(difftime / 3600) - 24 * days; // 小时 60*60 总小时数-过去的小时数=现在的小时数
  1983 + var minutes = parseInt(difftime % 3600 / 60); // 分钟 -(day*24) 以60秒为一整份 取余 剩下秒数 秒数/60 就是分钟数
  1984 + var seconds = parseInt(difftime % 60); // 以60秒为一整份 取余 剩下秒数
  1985 + this.setData({days: days, hours: hours, minutes: minutes, seconds: seconds})
3382 1986 }
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;
  1987 + break;
3388 1988  
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 1989 }
  1990 + },
3409 1991  
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();
  1992 +
  1993 + //显示支付选择
  1994 + show_pay: function () {
  1995 + this.setData({show_pay_type: 1});
  1996 + },
  1997 + //关闭支付
  1998 + close_show_pay: function () {
  1999 + this.setData({show_pay_type: 0});
  2000 + },
  2001 + //--弹起支付框--
  2002 + to_pay() {
  2003 + //--物流支付时要有地址--
  2004 + if (this.data.exp_type == 0 && this.data.user_addr == null) {
  2005 + return getApp().my_warnning("请选择收货地址", 0, this);
3419 2006 }
3420 2007  
3421   - //})
  2008 + this.setData({show_pay_type: 1});
3422 2009 },
3423 2010  
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; //如果有线下取价,就用线下价
  2011 + //选择支付方式
  2012 + set_pay_type: function (e) {
  2013 + var type = e.currentTarget.dataset.type;
  2014 + this.to_pay_type(type);
  2015 + },
  2016 +
  2017 + //--立即支付--
  2018 + to_pay_type: function (ind) {
  2019 + var th = this;
  2020 + //--物流支付时要有地址--
  2021 + if (th.data.exp_type == 0 && th.data.user_addr == null) {
  2022 + return getApp().my_warnning("请选择收货地址", 0, th);
  2023 + }
  2024 +
  2025 + //---支付参数--
  2026 + var dd = {
  2027 + order_sn: th.data.order.order_sn,
  2028 + order_id: th.data.order.order_id,
  2029 + store_id: oo.stoid,
  2030 + exp_type: th.data.exp_type,
  2031 + user_id: getApp().globalData.userInfo.user_id,
  2032 + prom_id: th.data.pre_arr.presell_id,
  2033 + tail_pay_type: ind,//0微信支付 1余额支付
  2034 + };
  2035 +
  2036 + if (th.data.exp_type == 0) {
  2037 + var index = th.data.index;
  2038 + dd.shipping_code = th.data.wu_arr[index].code;
  2039 + dd.shipping_name = th.data.wu_arr[index].name;
  2040 + dd.shipping_price = parseFloat(th.data.exp_price);
  2041 + dd.addressid = th.data.user_addr.address_id;
3432 2042 }
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})
  2043 +
  2044 + if(th.data.order_prom_amount>0){
  2045 + var e={
  2046 + order_prom_id:th.data.order_prom_id,
  2047 + order_prom_amount:th.data.order_prom_amount,
  2048 + }
  2049 + dd.order_prom_list=e;
  2050 + }
  2051 +
  2052 + var bn_pick=th.data.pickup_id;
  2053 + var quan_no='';
  2054 + if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
  2055 + quan_no = th.data.using_quan[bn_pick].coupon_no;
  2056 + if(quan_no){
  2057 + dd.coupon_no=quan_no;
  2058 + if(th.data.quan_price) dd.coupon_price=th.data.quan_price;
  2059 + }
  2060 + if(th.data.user_note){
  2061 + dd.user_note=th.data.user_note;
  2062 + }
  2063 + dd.order_amount= parseFloat(th.data.order_m-th.data.presell.presell_deposit).toFixed(2);
  2064 +
  2065 + console.log(JSON.stringify(dd));
  2066 + wx.request({
  2067 + url: oo.url + '/api/weshop/order/pay/payPresellWk',
  2068 + data: JSON.stringify(dd),
  2069 + method: 'POST',
  2070 + header: {
  2071 + 'content-type': 'application/json'
  2072 + },// 设置请求的 header
  2073 + success: function (t) {
  2074 + th.close_show_pay();
  2075 +
  2076 + //---用微信支付---
  2077 + if (dd.tail_pay_type == 0) {
  2078 + var n = t.data.data;
  2079 + th.weixinPay(n,
  2080 + function () {
  2081 + //---用余额支付---
  2082 + getApp().my_warnning("支付成功", 1, th);
  2083 +
  2084 +
  2085 + var send_time=th.data.pre_arr.delivery_date;
  2086 + if(th.data.pre_arr.delivery_type==2){
  2087 + send_time=th.data.pre_arr.delivery_daynum*3600;
3456 2088 }
  2089 +
  2090 + setTimeout(function () {
  2091 + th.setData({isclose: 0,'order.order_status':1,'order.pay_status':1,'wait_wk':0,'presell.tail_pay_state':1,'wait_sh':1,send_time:send_time});
  2092 + }, 1000)
  2093 +
  2094 + }, function () {
  2095 + getApp().my_warnning("支付失败", 0, th);
  2096 + })
  2097 + } else {
  2098 + if (t.data.code == 0) {
  2099 +
  2100 + var send_time=th.data.pre_arr.delivery_date;
  2101 + if(th.data.pre_arr.delivery_type==2){
  2102 + send_time=th.data.pre_arr.delivery_daynum*3600;
3457 2103 }
  2104 + //---用余额支付---
  2105 + getApp().my_warnning("支付成功", 1, th);
  2106 + setTimeout(function () {
  2107 + th.setData({isclose: 0,'order.order_status':1,'order.pay_status':1,'wait_wk':0,'presell.tail_pay_state':1,'wait_sh':1,send_time:send_time});
  2108 + }, 1000)
  2109 + } else {
  2110 + getApp().my_warnning(t.data.msg, 1, th);
3458 2111 }
3459   - })
3460   - })
3461   - }
  2112 + }
  2113 + }
  2114 + });
3462 2115 },
3463 2116  
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;
  2117 + //------调起支付框--------
  2118 + weixinPay: function (n, success, fail) {
  2119 + if (!n) return false;
  2120 + var th = this;
  2121 + wx.requestPayment({
  2122 + timeStamp: String(n.timeStamp),
  2123 + nonceStr: n.nonceStr,
  2124 + package: n.packageValue,
  2125 + signType: n.signType,
  2126 + paySign: n.paySign,
  2127 + success: function (n) {
  2128 + console.log(n), getApp().showSuccess("支付成功!");
  2129 + "function" == typeof success && success();
  2130 + },
  2131 + fail: function (n) {
  2132 + console.log(n), "requestPayment:fail" == n.errMsg ? getApp().my_warnning("支付失败", 0, th) : "requestPayment:fail cancel" == n.errMsg ? getApp().my_warnning("您已取消支付", 0, th) : getApp().my_warnning("支付失败:" + n.errMsg.substr("requestPayment:fail ".length), 0, th),
  2133 + "function" == typeof fail && fail();
3473 2134 }
3474   - }
3475   - return 1;
  2135 + });
3476 2136 },
3477 2137  
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;
  2138 +
  2139 + show_liuyan:function () {
  2140 + this.setData({sh_liuyan:true})
3486 2141 },
3487   - check_by_area: function (region_list) {
3488   - var arr = region_list.split(",");
3489   - var check = this.check_area(arr);
3490   - return !check;
  2142 + close_liuyan(){
  2143 + this.setData({sh_liuyan:false})
3491 2144 },
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;
  2145 +
  2146 + //--------点击选择----------
  2147 + set_wuliu: function (e) {
  2148 + var type = e.currentTarget.dataset.type;
  2149 + this.setData({
  2150 + exp_type: type
  2151 + });
  2152 + this.calculatePrice2();
3496 2153 },
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
  2154 +
  2155 +
  2156 + //--------立即支付----------
  2157 + async jumpToCart4(e) {
  2158 + var th=this;
  2159 + if(this.data.optionIsGoup)
  2160 + wx.navigateTo({
  2161 + url: "/pages/team/team_confirm/team_confirm?orderSn=" + this.data.order.order_sn + "&orderPay=true"
  2162 + })
  2163 + var order=this.data.order;
  2164 + var order_goods=this.data.order_goods;
  2165 +
  2166 + var wlist="";
  2167 +
  2168 + var good=order_goods;
  2169 + //线下取价功能已经关闭或者过期
  2170 + if(!th.data.is_open_offline && good.offline_cut>0){
  2171 + wx.showModal({
  2172 + title: '提示',
  2173 + content: '线下取价功能已经关闭或者过期!'
  2174 + });
  2175 + return false;
  2176 + }
  2177 + //如果不是小程序有的功能,直接提示要去3.0处理
  2178 + if(good.prom_type==2 ){
  2179 + wx.showModal({
  2180 + title: '提示',
  2181 + content: '小程序还未有该活动,请到3.0公众号支付'
  2182 + });
  2183 + return false;
  2184 + }
  2185 +
  2186 + //要每件每件的商品进行检查,看有么有超出库存,超出限购
  2187 + var goodsbuynum=0,promgoodsbuynum=0,gg=null;
  2188 + //获取单品的现在的活动状态
  2189 + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, {
  2190 + }).then(res=>{
  2191 + gg=res.data.data;
  2192 + })
  2193 + var limit = gg.viplimited;
  2194 + var store_count = gg.store_count;
  2195 + good.erpwareid=gg.erpwareid;
  2196 +
  2197 + //---要获得商品,该用户买了多少件,同步应用---
  2198 + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  2199 + data: {
  2200 + store_id: os.stoid,
  2201 + user_id: getApp().globalData.user_id,
  2202 + goods_id: good.goods_id,
  2203 + prom_type: good.prom_type,
  2204 + prom_id: good.prom_id
  2205 + },
  2206 + }).then(res => {
  2207 + var buy_num_data = res.data.data;
  2208 + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
  2209 + goodsbuynum = buy_num_data.goodsbuynum;
  2210 + })
  2211 +
  2212 + var buyed_mum2=goodsbuynum+good.goods_num;
  2213 + if (buyed_mum2 > limit && limit > 0) {
  2214 +
  2215 + var content=gg.goods_name+'购买数量超出商品限购,请取消订单';
  2216 + th.toast(content);
  2217 + return false;
  2218 + }
  2219 +
  2220 + //当是组合优惠的时候
  2221 + if(good.prom_type==7){
  2222 + //如果有组合购
  2223 + var isok = 1;
  2224 + var url="/api/weshop/prom/zhbuy/get/"+os.stoid+"/"+good.prom_id+"/"+getApp().globalData.userInfo.user_id;
  2225 + await getApp().request.promiseGet(url, {}).then(res => {
  2226 + if(res.data.code==0 && res.data.data){
  2227 + if(res.data.data.is_show!=1){
  2228 + isok=0;
  2229 + }
  2230 + //如果活动已经结束
  2231 + if(res.data.data.is_end==1){
  2232 + isok=0;
  2233 + }
  2234 + //已经结束
  2235 + if(ut.gettimestamp()>res.data.data.end_time){
  2236 + isok=0;
  2237 + }
  2238 + //还未开始
  2239 + if(ut.gettimestamp()<res.data.data.start_time){
  2240 + isok=0;
  2241 + }
  2242 +
  2243 + }else{
  2244 + //未找到商品的活动
  2245 + isok = 0;
3511 2246 }
  2247 +
3512 2248 })
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;
  2249 + if (!isok){
  2250 + var content=gg.goods_name+'活动已经结束,请取消订单';
  2251 + th.toast(content);
  2252 + return false;
  2253 + }
  2254 +
  2255 + var url1 = "/api/weshop/prom/zhbuyGoods/page";
  2256 + var req_data = {
  2257 + page: 1,
  2258 + pageSize: 1,
  2259 + store_id: os.stoid,
  2260 + zh_id: good.prom_id,
  2261 + goods_id:good.goods_id
  2262 + }
  2263 + await getApp().request.promiseGet(url1, {
  2264 + data: req_data
  2265 + }).then(res => {
  2266 + if (ut.ajax_ok(res)) {
  2267 + var gdlist = res.data.data.pageData[0];
  2268 + good.buyqty=gdlist.buyqty;
  2269 + }
  2270 + })
  2271 +
  2272 + var num=good['buyqty'];
  2273 + console.log(1111);
  2274 + console.log(num);
  2275 + //---- 要计算商品的限购 -----
  2276 + if(good['buyqty']>0){
  2277 + if(good.goods_num+promgoodsbuynum>good['buyqty']){
  2278 +
  2279 + var content= good['goods_name']+"超出活动限购\n";
  2280 + th.toast(content);
  2281 + return false;
  2282 + }
3540 2283 }
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 2284 }
3560   - func();
3561   - })
3562   - },
3563 2285  
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];
  2286 + //如果优惠促销和搭配购的时候
  2287 + if((good.prom_type==3 || good.prom_type==5) && good.is_collocation!=1 && good.is_gift!=1){
  2288 + var p_ok=1;
  2289 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
  2290 + if(res.data.code==0){
  2291 + var r_data=res.data.data;
  2292 + if(!r_data.collocationPromList && good.prom_type==5){
3570 2293  
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});
  2294 + var content=good.goods_name+'未找到活动,请取消订单重新购买';
  2295 + th.toast(content);
  2296 + p_ok=0;
  2297 + }
  2298 + if(!r_data.promGoodsLists && good.prom_type==3){
3577 2299  
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;
  2300 + var content=good.goods_name+'未找到活动,请取消订单重新购买';
  2301 + th.toast(content);
  2302 + p_ok=0;
  2303 + }
  2304 + }else{
  2305 +
  2306 + var content=good.goods_name+'未找到活动,请取消订单重新购买';
  2307 + th.toast(content);
  2308 + p_ok=0;
3583 2309 }
3584 2310 })
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;
  2311 + if(!p_ok) return false;
3594 2312 }
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;
  2313 +
  2314 + //商品的普通购买 ,不要进行判断
  2315 + if((good.prom_type==1 || good.prom_type==6 || good.prom_type==4) && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal){
  2316 + if(gg.prom_type!=good.prom_type) {
  2317 +
  2318 + var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
  2319 + th.toast(content);
  2320 + return false;
3601 2321 }
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});
  2322 + }else{
  2323 + if((gg.prom_type==1 || gg.prom_type==3 || gg.prom_type==5 || gg.prom_type==6 || gg.prom_type==4)
  2324 + && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
  2325 + var prom=null;
  2326 + //---如果是活动的时候---
  2327 + var prom=null,th=this;
  2328 + if(gg.prom_type==1){
  2329 + await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+gg.prom_id,{
  2330 + }).then(res=>{
  2331 + if(res.data.code==0){
  2332 + prom=res.data.data;
  2333 + }
  2334 + })
  2335 + }
  2336 + if(gg.prom_type==6){
  2337 + await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+gg.prom_id,{
  2338 + }).then(res=>{
  2339 + if(res.data.code==0){
  2340 + prom=res.data.data;
  2341 + }
  2342 + })
  2343 + }
3610 2344  
3611   - var obj = {};
3612   - obj[item.prom_id] = ob;
3613   - map[pickid] = obj;
  2345 + if(gg.prom_type==4){
  2346 + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
  2347 + data:{store_id:os.stoid,goods_id:gg.goods_id}
  2348 + }).then(res=>{
  2349 + if(res.data.code==0 && res.data.data && res.data.data.pageData){
  2350 + prom=res.data.data.pageData[0];
  2351 + }
  2352 + })
  2353 + }
3614 2354  
3615   - }
3616   - },
  2355 + if(prom){
  2356 + var t_now=ut.gettimestamp();
  2357 + if(prom.is_end==0 && prom.start_time<t_now && prom.end_time>t_now){
3617 2358  
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;
  2359 + var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
  2360 + th.toast(content);
  2361 + return false;
  2362 + }
  2363 + }
3636 2364 }
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;
  2365 + else{
  2366 + //不是赠品的时候
  2367 + if(!good.is_gift && good.prom_type!=3){
  2368 + var t_ok=1;
  2369 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
  2370 + if(res.data.code==0){
  2371 + var r_data=res.data.data;
  2372 + //-- 参加了全局的优惠活动 --
  2373 + if(r_data.promGoodsLists){
  2374 +
  2375 + var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
  2376 + th.toast(content);
  2377 + t_ok=0;
  2378 + }
  2379 + }
  2380 + })
  2381 + if(!t_ok) return false;
  2382 + }
  2383 +
  2384 + //-- 如果有参加线下取价 --
  2385 + if(good.offline_cut>0) wlist+=encodeURIComponent(gg.erpwareid)+",";
3644 2386 }
3645   - break;
3646   - }
  2387 + //赠品和搭配购不判断商品金额
  2388 + var isok=1;
  2389 + var card_field=th.data.card_field;
  2390 + //如果会员是等级会员,商品有等级价,且不是活动商品
  2391 + if(!good.is_gift && !good.is_collocation && good.prom_type!=8) {
  2392 + if (card_field && gg[card_field] > 0) {
  2393 + if (good.goods_price != gg[card_field] && good.offline_cut<=0) isok = 0;
  2394 + if (good.goods_price >gg[card_field] && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过
  2395 +
  2396 + } else {
  2397 + if (good.goods_price != gg.shop_price && good.offline_cut<=0) isok = 0;
  2398 + if (good.goods_price> gg.shop_price && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过
  2399 + }
  2400 + var is_h=0;
  2401 + if (!isok) {
  2402 +
  2403 + var content=gg.goods_name + '商品的价格发生了变化,请取消订单重新购买';
  2404 + th.toast(content);
  2405 + return false;
  2406 + }
  2407 + }
  2408 +
  2409 +
  2410 + if(good.goods_num>store_count){
  2411 +
  2412 + var content=gg.goods_name+'商品的库存不足,请取消订单';
  2413 + th.toast(content);
  2414 + return false;
  2415 + }
3647 2416  
3648 2417  
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 2418 }
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;
  2419 +
  2420 + console.log("------------------------------------");
  2421 + //---如果是活动的时候---
  2422 + var prom=null,goodsinfo=good,th=this;
  2423 + if(goodsinfo.prom_type==1){
  2424 + await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+goodsinfo.prom_id,{
  2425 + }).then(res=>{
  2426 + if(res.data.code==0){
  2427 + prom=res.data.data;
  2428 + }
  2429 + })
  2430 + }
  2431 + if(goodsinfo.prom_type==6 && !good.is_pd_normal){
  2432 + await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{
  2433 + }).then(res=>{
  2434 + if(res.data.code==0){
  2435 + prom=res.data.data;
  2436 + }
  2437 + })
3661 2438 }
3662   - }
3663 2439  
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;
  2440 + if(goodsinfo.prom_type==4 && !good.is_integral_normal){
  2441 + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
  2442 + data:{store_id:os.stoid,goods_id:goodsinfo.goods_id}
  2443 + }).then(res=>{
  2444 + if(res.data.code==0 && res.data.data && res.data.data.pageData){
  2445 + prom=res.data.data.pageData[0];
  2446 + }
  2447 + })
  2448 + }
3668 2449  
3669   - },
  2450 + //----------如果有活动,并且在进行中,就不计算线下库存---------------
  2451 + if(prom){
  2452 + var now=ut.gettimestamp();
  2453 + if(prom.is_end==1 && prom.end_time<now){
3670 2454  
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   - },
  2455 + var content=goodsinfo.goods_name+'商品的活动已经结束,请取消订单重新购买';
  2456 + th.toast(content);
  2457 + return false;
  2458 + }
3683 2459  
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;
  2460 + buyed_mum2=promgoodsbuynum+good.goods_num;
  2461 + if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) {
  2462 +
  2463 + var content=goodsinfo.goods_name+'购买数量超出商品活动限购,请取消订单重新购买';
  2464 + th.toast(content);
  2465 + return false;
  2466 + }
  2467 +
  2468 + if(goodsinfo.prom_type==4){
  2469 + if (good.goods_num > prom.limitqty-prom.buy_num) {
  2470 +
  2471 + var content=goodsinfo.goods_name+'购买数量超出商品活动库存,请取消订单';
  2472 + th.toast(content);
  2473 + return false;
  2474 + }
  2475 + }else{
  2476 + var redis_num = 0;
  2477 + //------判断活动是否抢光-----
  2478 + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
  2479 + os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, {
  2480 + }).then(res => {
  2481 + redis_num = res.data.data;
  2482 + });
  2483 +
  2484 + if (good.goods_num > redis_num) {
  2485 +
  2486 + var content=gg.goods_name+'超出商品活动库存,请取消订单';
  2487 + th.toast(content);
  2488 + return false;
  2489 + }
3694 2490 }
  2491 +
3695 2492 }
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;
  2493 +
  2494 +
  2495 +
  2496 + //-- 要判断一下线下取价价格是不是发生改变 --
  2497 + if(wlist!="" && th.data.is_open_offline && th.data.is_open_offline>0){
  2498 + wlist=ut.sub_last(wlist);
  2499 + var keyid=order.pickup_id;
  2500 + var user_info=getApp().globalData.userInfo;
  2501 + if(!keyid) return false;
  2502 + var offarr=null;
  2503 + await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", {
  2504 + data:{
  2505 + VIPId:encodeURIComponent(user_info.erpvipid),
  2506 + store_id:os.stoid,
  2507 + PickupId:keyid,
  2508 + WareIds:wlist},
  2509 + },
  2510 + ).then(res=>{
  2511 + if(res.data.code==0 && res.data.data && res.data.data.length>0){
  2512 + offarr=res.data.data;
  2513 + }
  2514 + })
  2515 + if(!offarr && offarr.length<=0 ){
  2516 + wx.showModal({ title: '获取线下取价失败',});
  2517 + }
  2518 + var newarr=ut.convert_arr_key(offarr,'WareId');
  2519 + //-- 循环判断线下的价格 --
  2520 + for(var k in order_goods){
  2521 + var good=order_goods[k];
  2522 + //判断线下取价是不是一样
  2523 + if(newarr[good.erpwareid] &&
  2524 + parseFloat(newarr[good.erpwareid].WarePrice)!=parseFloat(good.goods_price)){
  2525 +
  2526 + var content=good.goods_name + '商品的价格发生了变化,请取消订单重新购买';
  2527 + th.toast(content);
  2528 + return false;
3709 2529 }
3710 2530 }
  2531 +
3711 2532 }
3712   - return is_use;
3713   - },
3714 2533  
3715   - //跳转到购买卡
3716   - buycard: function () {
3717   - getApp().goto("/pages/user/plus/plus");
3718   - getApp().globalData.plus_buy_back = 1;
3719   - },
  2534 + /*---
  2535 + o.jumpToCart4({
  2536 + order_sn: this.data.order.order_sn,
  2537 + order_amount: this.data.order.order_amount,
  2538 + type: 1 //正常单
  2539 + }, 1);--*/
  2540 +
  2541 + util_pay.pay(this.data.order.order_sn, function() {
  2542 + wx.showToast({title: '支付成功'})
  2543 + wx.navigateBack();
  2544 + },null,os.stoid,1);
3720 2545  
3721   - //跳转关闭弹出框的显示
3722   - close_offline: function () {
3723   - this.setData({is_offline_show: 0});
3724   - },
3725 2546  
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 2547 },
3733 2548  
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   - }
  2549 +
  2550 + //--------取消订单---------
  2551 + cancelOrder: function(e) {
  2552 + var t = this,th=t, ord_id = this.data.order.order_id,order=this.data.order;
  2553 +
  2554 + wx.showModal({
  2555 + title: "是否取消订单?",
  2556 + success: function(e) {
  2557 + if(!e.confirm) return false;
  2558 + //如果是秒杀和拼单的商品,取消订单要返回redis,并取消订单
  2559 + //if(is_skill==1 || is_zsorder>=2){
  2560 + getApp().request.post("/api/weshop/order/cancelOrder/"+os.stoid+"/"+ord_id+"/"+getApp().globalData.user_id,{
  2561 + data:{},
  2562 + success: function(t) {
  2563 + if(t.data.code==0){
  2564 + th.setData({'order.order_status':3});
  2565 + wx.setStorageSync("order:order_list:update", !0);
  2566 + }
  2567 +
  2568 + },
  2569 + })
  2570 +
  2571 + }
  2572 + });
3750 2573 },
3751 2574  
3752 2575  
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   - }
  2576 + //-----删除订单-----
  2577 + deleteOrderData: function(t) {
  2578 + var th=this;
  2579 + var order_id=this.data.order.order_id;
  2580 + var up_data={
  2581 + order_id: order_id,isdel:1
  2582 + };
  2583 + if(th.data.order.order_status!=6){
  2584 + up_data.order_status=5;
  2585 + }
  2586 + wx.showModal({
  2587 + title: "是否删除订单?",
  2588 + success: function(tt) {
  2589 + tt.confirm && getApp().request.put("/api/weshop/order/updatebyId", {
  2590 + data: up_data,
  2591 + success: function (t) {
  2592 + getApp().my_warnning("删除成功",1,th);
  2593 + setTimeout(function () {
  2594 + getApp().goto("/pages/user/order_list/order_list");
  2595 + },1000);
  2596 + }
  2597 + })
  2598 + }
  2599 + });
3770 2600 },
3771 2601  
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
  2602 + go_goods:function (e) {
  2603 + var url=e.currentTarget.dataset.url;
  2604 + getApp().goto(url);
  2605 + },
  2606 + toast(msg){
  2607 + wx.showToast({
  2608 + title: msg,
  2609 + icon: 'none',
  2610 + duration: 3000
  2611 + })
  2612 + },
  2613 + //--------确认收货---------
  2614 + confirmOrder: function(e) {
  2615 + var th=this;
  2616 + var o = this.data.order.order_id,order=this.data.order;
  2617 + wx.showModal({
  2618 + title: "是否确认收货?",
  2619 + success: function(t) {
  2620 + t.confirm && getApp().request.post("/api/weshop/order/confirmOrder/"+os.stoid+"/"+o+"/"+getApp().globalData.user_id,{
  2621 + success:function (e) {
  2622 + if(e.data.code==0){
  2623 + th.setData({})
  2624 + }
  2625 + }
  2626 + })
  2627 + }
3784 2628 });
3785 2629 },
3786   -
3787   - // 是否同意预售商品不退定金
3788   - switchChange(e) {
3789   - let isSwitchOn = e.detail;
3790   - }
  2630 +
  2631 +
  2632 +
3791 2633  
3792 2634  
3793 2635 });
... ...
packageC/pages/presell/cart/cart.json
1 1 {
2   - "navigationBarTitleText": "填写订单",
  2 + "navigationBarTitleText": "订单详情",
3 3 "enablePullDownRefresh": false,
4 4 "usingComponents": {
5 5 "warn": "/components/long_warn/long_warn"
... ...
packageC/pages/presell/cart/cart.wxml
... ... @@ -2,747 +2,661 @@
2 2 <wxs src="filter.wxs" module="util"></wxs>
3 3 <wxs module="filters" src="../../../../utils/filter.wxs"></wxs>
4 4  
5   -<form bindsubmit="submitForm">
6   - <view class="container">
7   -
8   - <!-- 支付进度 -->
9   - <view class="information bdr14 mgt20">
10   - <view class="item ai-center" style="justify-content: flex-start;">
11   - <view class="pdr20"><text class="iconfont icon-qianbao fs60"></text></view>
12   - <!-- <view class="">
13   - <view>等待尾款支付开始</view>
14   - <view>2021.10.01 00:00:00 - 2021.10.10 23:59:59</view>
15   - </view> -->
16   - <view class="">
17   - <view>等待买家付尾款</view>
18   - <view class="fs22">请于*天**小时**分**秒内付款完成,超时订单将自动取消</view>
19   - </view>
20   - </view>
21   - <view class="pdb20 flex t-c fs22 c-7b">
22   - <view class="f1">
23   - <view>付定金</view>
24   - <view class="box">
25   - <text class="iconfont icon-yes"></text>
26   - </view>
27   - </view>
28   - <view class="f1">
29   - <view>付尾款</view>
30   - <view class="box line"><text class="circle"></text></view>
31   - </view>
32   - <view class="f1">
33   - <view>商家发货</view>
34   - <view class="box line"><text class="circle"></text></view>
35   - </view>
36   - <view class="f1">
37   - <view>交易完成</view>
38   - <view class="box line"><text class="circle"></text></view>
39   - </view>
40   - </view>
41   - </view>
42   -
43   - <!-- 退款完成 -->
44   - <view class="information bdr14 mgt20">
45   - <view class="item ai-center" style="justify-content: flex-start;">
46   - <view class="pdr20"><text class="iconfont icon-tkcg fs60"></text></view>
47   - <view class="">退款完成(定金)</view>
48   - </view>
49   - </view>
50   -
51   - <!-- 立即购买的时候 -->
52   - <block wx:if="{{is_b_now==1}}">
53   - <view class="tab-container">
54   - <view class="tab-wrapper">
55   - <view hidden="{{bn_t_exp_t==2}}" bindtap='setexptype' data-t='1' class="tab {{bn_exp_type == 1? 'active':''}}"
56   - data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >门店自提</view>
57   -
58   - <view hidden="{{bn_t_exp_t==1}}" bindtap='setexptype' data-t='0' class="tab {{bn_exp_type== 0 ? 'active':''}}"
59   - data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >快递邮寄</view>
60   -
61   - </view>
62   - </view>
63   - </block>
64   - <!-- 购物购买只有一单的时候 -->
65   - <block wx:if="{{is_b_now==0 && cartlist.length==1}}">
66   - <view class="tab-container">
67   - <view class="tab-wrapper">
68   - <view hidden="{{cartlist[0].distr_t==2}}" bindtap='setexptype_w' data-ind="0" data-t='1' class="tab {{cartlist[0].exp_type == 1? 'active':''}}"
69   - data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >门店自提</view>
70   -
71   - <view hidden="{{cartlist[0].distr_t==1}}" bindtap='setexptype_w' data-ind="0" data-t='0' class="tab {{cartlist[0].exp_type== 0 ? 'active':''}}"
72   - data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}" >快递邮寄</view>
73   -
74   - </view>
75   - </view>
76   - </block>
77   -
78   -
79   - <!--要进行判断地址是否显示---->
80   - <view bindtap="enterAddressPage" class="user-mes mgt20" hidden='{{(bn_exp_type==1 && is_b_now==1) || (is_all_zt==1 && is_b_now==0)}}'>
81   - <!---默认地址显示------>
82   - <block wx:if="{{user_addr!=null}}">
83   -
84   - <view class="user-contact">
85   - <text class="bold fs36 pdr20">{{user_addr.consignee}}</text>
86   - <text class="fs28">{{user_addr.mobile}}</text>
87   - </view>
88   - <view class="location">
89   - <view class="address fs26 pdt20">
90   - <view class="pos-icon">
91   - <image class="wh100 bdr14" src="{{imgUrl}}/miniapp/images/goodscategory/new_position.png"></image>
92   - </view>
93   - {{user_addr.more_address}}{{' '}}{{user_addr.address}}
94   - </view>
95   -
96   - </view>
97   - <view class="update-logistics">
98   - <!-- <image class="arrow-rigth" src="{{imgUrl}}/miniapp/images/new_position.png"></image> -->
99   - <view class="xc-right"></view>
100   - </view>
101   - </block>
102   - <!---先增地址------>
103   - <block wx:else>
104   - <view class="add_new">
105   - <image class="addr_jia" src="{{imgUrl}}/miniapp/images/jia.png"></image>添加地址
106   - </view>
107   - </block>
108   - <!-- <view class="border-img">
109   - <image class="wh100" src="{{imgUrl}}/miniapp/images/order/new_dividing_line.png"></image>
110   - </view> -->
111   - </view>
112   -
113   - <!-- -------------------购物车进来,有可能多单-------------------- -->
114   - <block wx:if="{{is_b_now==0}}">
115   - <!-- <view class="xc-border main-top"></view> -->
116   - <view wx:for="{{cartlist}}" wx:for-index="pidx">
117   - <view class="use-item bfff bdr_t-14 mgt20">
118   - <image class="dp" src='{{imgUrl}}/miniapp/images/goodscategory/new_store.png'></image>
119   - <!-- <view>门店:{{item.pname}}</view> -->
120   - <view>{{item.pname}}</view>
121   - </view>
122   - <view class="order-detail" wx:for="{{item.goods}}" wx:for-index="idx" wx:for-item="items">
123   - <!----商品图片----->
124   - <view class="goods-img" style="position: relative">
125   - <image wx:if="{{items.is_gift}}" src="{{imgUrl}}/miniapp/images/giveaway.png" class="gift_image"></image>
126   - <image class="wh100 bdr14" src="{{items.original_img}}" binderror='cart_set_err' data-err='cartlist[{{pidx}}].goods[{{idx}}].original_img'></image>
127   - </view>
128   - <!----商品名称规格---->
129   - <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{items.goods_id}}">
130   - <view class="goods-name ellipsis-2">{{items.goods_name}}</view>
131   - <!-- 商品属性 -->
132   - <view class="flex-vertical fs28 color-gray n_guige">
133   - <view class="goods-color">
134   - <block><text>{{filters.show_gui_ge(items.goods_spec,items.goods_color)}}</text></block>
135   - <!--<block wx:if="{{!items.goods_spec && !items.goods_color}}"><text>规格1</text></block>-->
136   - <!--<block wx:else>-->
137   - <!--<text wx:if="{{items.goods_spec!=''}}">{{items.goods_spec}}<text wx:if="{{items.goods_color}}">/</text></text>-->
138   - <!--<text wx:if="{{items.goods_color}}">{{items.goods_color}}</text>-->
139   - <!--</block>-->
140   - </view>
141   - </view>
142   -
143   -
144   - <!-----商品名称规格------>
145   - <view class="order-num flex-space-between">
146   - <view class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text></view>
147   - <view class="goods-num">x{{items.goods_num}}</view>
148   - </view>
149   - </navigator>
150   - </view>
151   -
152   - <!-- 如果是等级卡的商品,会员没有注册,要提醒注册 -->
153   - <view class="plus_buy fs28" wx:if="{{item.card_cut_price>0}}">
154   - <view class="flex">
155   - <view class="card_bg ellipsis-1" style="margin-right: 10rpx;">
156   - <image src="{{imgUrl}}/miniapp/images/plus/dj_icon.png"></ image>
157   - <text class="card_name">{{show_card.CardName}}</text>
158   - </view>
159   - <view>立减 <text style="color:#f23030;">{{filters.toFix(item.card_cut_price,2) }}</text> 元</view>
160   - </view>
161   - <view>
162   - <text style="color: #999;margin-left: 4rpx;">vip超级会员仅需{{show_card.CardFee}}元</text>
163   - </view>
164   - <!-- 三角形 -->
165   - <view class="car_tri_up"></view>
166   - <!-- 立即开通跳转 -->
167   - <view bindtap="buycard" class="card_op">立即开通</view>
168   - </view>
169   -
170   -
171   - <!-----使用优惠券------>
172   - <view class="xc-coupon-frame flex-center" data-bn="0" bindtap="open_coupon_list" wx:if="{{(item.quan_list && item.quan_list.length>0) || get_by_quan_list_cart[item.pickup_id]!=null}}"
173   - data-cind="{{pidx}}" data-pickid="{{item.pickup_id}}">
174   - <view class="work-frame flex-space-between">
175   - <view class="work">优惠券<text class="quan_num_show fs20">{{item.can_num}}张可用</text></view>
176   - <view class="xc-right-frame">
177   - <text wx:if="{{using_quan[item.pickup_id].is_nouse}}">不使用</text>
178   - <text wx:if="{{using_quan[item.pickup_id].money}}">¥{{using_quan[item.pickup_id].money}}元优惠券</text>
179   - <text wx:if="{{using_quan[item.pickup_id].isby}}">包邮券</text>
180   - <view class="xc-right"></view>
181   - </view>
182   - </view>
183   - </view>
184   -
185   -
186   - <view class="set-mes bdr_b-14">
187   - <view wx:if="{{order.store_prom}}">
188   - <icon color="#f23030" size="16" type="info"></icon>
189   - {{order.store_prom}}
190   - </view>
191   -
192   - <!-- 当是物流很多单的时候 -->
193   - <view class="use-item flex-space-between" wx:if="{{cartlist.length>1}}">
194   - <view class="flex-vertical" >
195   - <view bindtap='setexptype_w' data-ind="{{pidx}}" data-t='1' data-txt='cartlist[{{pidx}}].exp_type'
196   - style="padding-right:26rpx;display:{{item.distr_t==2?'none':'flex;align-items: center'}};">
197   - <!-- <icon bindtap='setexptype_w' data-t='1' data-txt='cartlist[{{pidx}}].exp_type' color="{{item.exp_type==1?'red':'gray'}}" size="16" type="success"></icon> -->
198   -
199   - <block wx:if="{{item.exp_type==1}}">
200   - <!-- <view class="circle white xc-hookt fs20 red-b sn"><text>Γ</text></view> -->
201   - <icon data-t='0' data-txt='cartlist[{{pidx}}].exp_type' color="red" size="16" type="success"></icon>
202   - </block>
203   - <block wx:else>
204   - <view class="circle xc-hookts on"></view>
205   - </block>
206   - <view bindtap='setexptype_w' data-ind="{{pidx}}" data-t='1' data-txt='cartlist[{{pidx}}].exp_type' class="yu_er">门店自提</view>
207   - </view>
208   -
209   - <view data-t='0' data-txt='cartlist[{{pidx}}].exp_type' data-ind="{{pidx}}" bindtap="setexptype_w" style="display:{{item.distr_t==1?'none':'flex;align-items: center'}};">
210   - <!-- <icon bindtap='setexptype_w' data-t='0' data-txt='cartlist[{{pidx}}].exp_type' color="{{item.exp_type==0?'red':'gray'}}" size="16" type="success"></icon> -->
211   - <block wx:if="{{item.exp_type==0}}">
212   - <!-- <view class="circle white xc-hookt fs20 red-b sn"><text>Γ</text></view> -->
213   - <icon data-t='0' data-txt='cartlist[{{pidx}}].exp_type' color="red" size="16" type="success"></icon>
214   - </block>
215   - <block wx:else>
216   - <view class="circle xc-hookts on"></view>
217   - </block>
218   -
219   - <view bindtap='setexptype_w' data-t='0' data-ind="{{pidx}}" data-txt='cartlist[{{pidx}}].exp_type' data-wl_txt='cartlist[{{pidx}}].wind'
220   - class="yu_er">快递邮寄</view>
221   - </view>
222   - </view>
223   -
224   -
225   - <!-- 点击显示物流选择,如果是默认使用的情况不成立 -->
226   - <view wx:if="{{!is_default_logistics && item.exp_type!=1}}" class="flex-vertical" bindtap="show_wu_arr" data-txt='cartlist[{{pidx}}].wind' data-w_sele_index="{{pidx}}" style="padding-right:6rpx;">
227   - <view>{{wu_arr[item.wind].name}}</view>
228   - <view class="xc-right"></view>
229   - </view>
230   -
231   - </view>
232   -
233   - <!-- 当是物流,只有一单的时候 -->
234   - <block wx:else >
235   - <view class="use-item flex-space-between" wx:if="{{item.exp_type==0 && !is_default_logistics}}">
236   - <view class="flex jc_sb" style="width: 100%; padding: 0 13rpx;">
237   - <view>选择物流</view>
238   - <view class="flex-vertical" bindtap="show_wu_arr" data-txt='cartlist[{{pidx}}].wind' data-w_sele_index="{{pidx}}" style="padding-right:6rpx;">
239   - <view>{{wu_arr[item.wind].name}}</view>
240   - <view class="xc-right"></view>
241   - </view>
242   - </view>
243   - </view>
244   - </block>
245   -
246   -
247   - </view>
248   -
249   - <!-- 留言 -->
250   - <view class="coupon-mes flex-vertical">
251   - <view>留言</view>
252   - <view class="leave-word">
253   - <input placeholder-class="fs28" placeholder='给商家留言,最多100字' bindinput="keyUpChangeNum" disabled="{{disabled}}"
254   - class="word-box" maxlength="100" name="user_note_{{item.pickup_id}}"></input>
255   -
256   - </view>
257   - </view>
  5 +<form bindsubmit="submitForm" wx:if="{{show_submit}}">
  6 + <view class="container">
  7 + <!-- 支付进度 -->
  8 + <view class="information bdr14 mgt20">
  9 + <view class="item ai-center" style="justify-content: flex-start;">
  10 + <view class="pdr20">
  11 + <text class="iconfont icon-qianbao fs60"></text>
  12 + </view>
  13 +
  14 + <view wx:if="{{wait_dj}}">
  15 + <view>等待买家付定金</view>
  16 + <view>{{filters.format_time(presell.kw_start_time,1)}} -
  17 + {{filters.format_time(presell.kw_end_time,1)}}
  18 + </view>
  19 + </view>
  20 +
  21 + <view wx:if="{{wait_wk && no_start}}">
  22 + <view>等待尾款支付开始</view>
  23 + <view>{{filters.format_time(presell.kw_start_time,1)}} -
  24 + {{filters.format_time(presell.kw_end_time,1)}}
  25 + </view>
  26 + </view>
  27 +
  28 +
  29 + <view wx:if="{{wait_sh}}">
  30 + <view>等待收货</view>
  31 + <view>{{order.order_sn}}</view>
  32 + </view>
  33 +
  34 + <view wx:if="{{wait_wk && !no_start}}">
  35 + <view>等待买家付尾款</view>
  36 + <view class="fs22">请于{{days}}天{{hours}}小时{{minutes}}分{{seconds}}秒内付款完成,超时订单将自动取消</view>
  37 + </view>
  38 + <view wx:if="{{wait_fh}}">
  39 + <view>等待商家发货</view>
  40 + <view class="fs22">将在{{filters.format_time(send_time,1)}}后发货</view>
  41 + </view>
  42 + <view wx:if="{{order.order_status==2}}">
  43 + <view>待评价</view>
  44 + <view>{{order.order_sn}}</view>
  45 + </view>
  46 + <view wx:if="{{order.order_status==3}}">
  47 + <view>已取消</view>
  48 + <view>{{order.order_sn}}</view>
  49 + </view>
  50 + <view wx:if="{{order.order_status==4}}">
  51 + <view>已完成</view>
  52 + <view>{{order.order_sn}}</view>
  53 + </view>
  54 + <view wx:if="{{order.order_status==5}}">
  55 + <view>已作废</view>
  56 + <view>{{order.order_sn}}</view>
  57 + </view>
  58 + <view wx:if="{{order.order_status==6}}">
  59 + <view>退款退货完成</view>
  60 + <view>{{order.order_sn}}</view>
  61 + </view>
  62 + </view>
  63 +
  64 +
  65 + <view class="pdb20 flex t-c fs22 c-7b">
  66 + <view class="f1">
  67 + <view wx:if="{{presell.presell_type!==1}}">付定金</view>
  68 + <view wx:else>支付金额</view>
  69 + <view wx:if="{{presell.deposit_pay_time>0}}" class="box">
  70 + <text class="iconfont icon-yes"></text>
  71 + </view>
  72 + <view wx:else class="box">
  73 + <text class="circle1"></text>
  74 + </view>
  75 + </view>
  76 + <view class="f1" wx:if="{{presell.presell_type!=1}}">
  77 + <view>付尾款</view>
  78 + <view wx:if="{{presell.tail_pay_state==1}}" class="box line">
  79 + <text class="iconfont icon-yes"></text>
  80 + </view>
  81 + <view wx:else class="box line">
  82 + <text class="circle1"></text>
  83 + </view>
  84 + </view>
  85 + <view class="f1">
  86 + <view>商家发货</view>
  87 + <view wx:if="{{order.pay_status==2 || order.shipping_status==1}}" class="box line">
  88 + <text class="iconfont icon-yes"></text>
  89 + </view>
  90 + <view wx:else class="box line">
  91 + <text class="circle1"></text>
  92 + </view>
  93 + </view>
  94 + <view class="f1">
  95 + <view>交易完成</view>
  96 + <view wx:if="{{order.order_status==4}}" class="box line">
  97 + <text class="iconfont icon-yes"></text>
  98 + </view>
  99 + <view wx:else class="box line">
  100 + <text class="circle1"></text>
  101 + </view>
  102 + </view>
  103 + </view>
  104 + </view>
  105 +
  106 + <!-- 退款完成 -->
  107 + <!--
  108 + <view class="information bdr14 mgt20">
  109 + <view class="item ai-center" style="justify-content: flex-start;">
  110 + <view class="pdr20"><text class="iconfont icon-tkcg fs60"></text></view>
  111 + <view class="">退款完成(定金)</view>
  112 + </view>
  113 + </view>-->
  114 +
  115 + <block wx:if="{{wait_wk}}">
  116 + <!-- 立即购买的时候 -->
  117 + <view class="tab-wrapper">
  118 + <view hidden="{{distr_type==2}}" bindtap='set_wuliu' data-type='1'
  119 + class="tab {{exp_type == 1? 'active':''}}"
  120 + data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}">门店自提
  121 + </view>
  122 +
  123 + <view hidden="{{distr_type==1}}" bindtap='set_wuliu' data-type='0'
  124 + class="tab {{exp_type== 0 ? 'active':''}}"
  125 + data-txt='cartlist[0].exp_type' data-wl_txt='cartlist[0].wind' data-index="{{index}}">快递邮寄
  126 + </view>
  127 + </view>
  128 + <!----要进行判断地址是否显示---->
  129 + <view bindtap="enterAddressPage" class="user-mes mgt20"
  130 + hidden='{{exp_type==1 }}'>
  131 + <!-----默认地址显示---->
  132 + <block wx:if="{{user_addr!=null}}">
  133 + <view class="user-contact">
  134 + <text class="bold fs36 pdr20">{{user_addr.consignee}}</text>
  135 + <text class="fs28">{{user_addr.mobile}}</text>
  136 + </view>
  137 + <view class="location flex ai_c" style="font-size: 28rpx">
  138 + <view class="pos-icon">
  139 + <image class="wh100" style="vertical-align: top"
  140 + src="{{imgUrl}}/miniapp/images/goodscategory/new_position.png"></image>
  141 + </view>
  142 + <view class="address">{{user_addr.more_address}}{{' '}}{{user_addr.address}}</view>
  143 +
  144 + </view>
  145 + <view class="update-logistics">
  146 + <image class="arrow-rigth" src="{{imgUrl}}/miniapp/images/icon-arrowdown.png"></image>
  147 + </view>
  148 + </block>
  149 + <!-----先增地址------>
  150 + <block wx:else>
  151 + <view class="add_new">
  152 + <image class="addr_jia" src="{{imgUrl}}/miniapp/images/jia.png"></image>
  153 + 添加地址
  154 + </view>
  155 + </block>
  156 + </view>
  157 + </block>
  158 +
  159 + <view class="user-mes" style="margin-top: 20rpx" wx:if="{{order.pay_status==1 && order.exp_type==0}}">
  160 + <view class="user-contact" style=" margin-left: 20rpx">
  161 + {{order.consignee}}{{'  '}}{{order.mobile}}
  162 + </view>
  163 + <view class="location flex ">
  164 +
  165 + <view class="pos-icon" style="width: 26rpx; height: 26rpx">
  166 + <image class="wh100" src="{{imgUrl}}/miniapp/images/iconfont-shouhuodizhi.png"></image>
  167 + </view>
  168 + <view class="address">{{order.more_address}} {{order.address}}</view>
  169 + </view>
  170 +
  171 + </view>
  172 +
  173 +
  174 +
  175 + <view class="use-item bfff bdr_t-14 mgt20">
  176 + <image class="dp" src='{{imgUrl}}/miniapp/images/goodscategory/new_store.png'></image>
  177 + <view>{{pickup.pickup_name}}</view>
  178 + </view>
  179 + <view class="order-detail">
  180 + <view class="goods-img" bindtap="go_goods" data-url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{goods.goods_id}}&pre_id={{pre_arr.id}}">
  181 + <image class="wh100 bdr14" src="{{imgUrl}}{{goods.original_img}}" binderror='cart_set_err'
  182 + data-err="goods.original_img"></image>
  183 + </view>
  184 + <navigator class="order-cont"
  185 + url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{goods.goods_id}}&pre_id={{pre_arr.id}}">
  186 + <view class="goods-name ellipsis-2">{{goods.goods_name}}</view>
  187 + <!-- 商品属性 -->
  188 + <view class="flex-vertical fs28 xc-ash color-gray n_guige">
  189 + <view class="goods-color">
  190 + <block>
  191 + <text>{{filters.show_gui_ge(goods.goods_spec,goods.goods_color)}}</text>
  192 + </block>
  193 + </view>
  194 + </view>
  195 + <!-- ---商品名称规格---- -->
  196 + <view class="order-num flex-space-between">
  197 + <view class="co-red">¥
  198 + <text class="fs36">{{filters.toFix(pre_arr.presell_price,2)}}</text>
  199 + </view>
  200 + <view class="goods-num">×{{order.order_goods.goods_num}}</view>
  201 + </view>
  202 + </navigator>
  203 +
  204 + </view>
  205 +
  206 + <!-- 如果是等级卡的商品,会员没有注册,要提醒注册 -->
  207 + <view class="plus_buy fs28" wx:if="{{card_cut_price>0}}">
  208 + <view class="flex">
  209 + <view class="card_bg ellipsis-1" style="margin-right: 10rpx;">
  210 + <image src="{{imgUrl}}/miniapp/images/plus/dj_icon.png"></
  211 + image>
  212 + <text class="card_name">{{show_card.CardName}}</text>
  213 + </view>
  214 + <view>立减
  215 + <text style="color:#f23030;">{{filters.toFix(card_cut_price,2) }}</text>
  216 + 元
  217 + </view>
  218 + </view>
  219 + <view>
  220 + <text style="color: #999;margin-left: 4rpx;">vip超级会员仅需{{show_card.CardFee}}元</text>
  221 + </view>
  222 + <!-- 三角形 -->
  223 + <view class="car_tri_up"></view>
  224 + <!-- 立即开通跳转 -->
  225 + <view bindtap="buycard" class="card_op">立即开通</view>
  226 + </view>
  227 +
  228 +
  229 + <view class="set-mes bdr_b-14" wx:if="{{presell.deposit_pay_time>0 && presell.tail_pay_state==0 && !no_start && !wait_dj}}">
  230 + <view wx:if="{{order.store_prom}}">
  231 + <icon color="#f23030" size="16" type="info"></icon>
  232 + {{order.store_prom}}
  233 + </view>
  234 +
  235 + <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{pickup_id}}"
  236 + wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}">
  237 + <view class="work-frame flex-space-between">
  238 + <view class="work">
  239 + 优惠券
  240 + <text class="quan_num_show">{{(selected_quan_list?selected_quan_list.length:0)+
  241 + (get_by_quan_list?get_by_quan_list.length:0)}}张可用
  242 + </text>
  243 + </view>
  244 + <view class="xc-right-frame">
  245 + <text wx:if="{{using_quan[pickup_id].is_nouse_red}}">不使用</text>
  246 + <block wx:else>
  247 + <text wx:if="{{using_quan[pickup_id].money}}">¥{{using_quan[pickup_id].money}}元优惠券</text>
  248 + <text wx:if="{{using_quan[pickup_id].isby}}">包邮券</text>
  249 + </block>
  250 + <view class="xc-right"></view>
  251 + </view>
  252 + </view>
  253 + </view>
  254 +
  255 + <view class="xc-coupon-frame" wx:if="{{bn_exp_type==0 && !is_default_logistics}}">
  256 + <view class="flex-space-between" style="padding: 20rpx 25rpx; font-size: 30rpx;">
  257 + <view>选择物流</view>
  258 + <view class="flex-vertical" bindtap="show_wu_arr" data-txt='index' style="margin-right: 12rpx;">
  259 + <view class="logistics-name">{{wu_arr[index].name}}</view>
  260 + <view class="xc-right"></view>
  261 + </view>
  262 + </view>
  263 + </view>
  264 + </view>
  265 + <!-- 留言 -->
  266 + <view class="coupon-mes flex-vertical">
  267 + <view>留言</view>
  268 + <view class="leave-word" wx:if="{{sh_liuyan}}">
  269 + <input placeholder-class="fs28" bindblur="close_liuyan" focus="{{sh_liuyan}}" bindinput="keyUpChangeNum"
  270 + value="{{user_note}}"
  271 + class="word-box" maxlength="100" name="user_note"></input>
  272 + </view>
  273 +
  274 + <view wx:if="{{!sh_liuyan}}" bindtap="show_liuyan">
  275 + <text class="fs26 {{user_note?'':'gray'}} note_text">{{user_note?user_note:'给商家留言,最多100字'}}</text>
  276 + </view>
  277 +
  278 + </view>
258 279  
259 280 <!-- 是否参与店铺优惠 -->
260   - <view class="coupon-mes flex-vertical" data-index="{{index}}" bindtap="cart_pop_offline" wx:if="{{item.offline_price}}">
261   - <view>店铺优惠</view>
262   - <view class="leave-word fs32" style="color: #999;">
263   - 省{{filters.toFix(item.offline_price,2)}}元
264   - </view>
265   - <block wx:if="{{item.is_offline}}">
266   - <text style="color: #d7642b;">-¥{{filters.toFix(item.offline_price,2)}}</text>
267   - </block>
268   - <block wx:else>
269   - <text style="color: #d7642b;">不使用优惠</text>
270   - </block>
271   - <!-- 右边点击 -->
272   - <view class="xc-right" style="margin-right: 12rpx; border-color: #d7642b;"></view>
  281 + <view class="coupon-mes flex-vertical" bindtap="bn_pop_offline" wx:if="{{bn_goods.offline_price}}">
  282 + <view>店铺优惠</view>
  283 + <view class="leave-word fs32" style="color: #999;">
  284 + 省{{filters.toFix(bn_goods.shop_price-bn_goods.offline_price,2)}}元
  285 + </view>
  286 + <block wx:if="{{bn_goods.is_offline}}">
  287 + <text style="color: #d7642b;">-¥{{filters.toFix(bn_goods.shop_price-bn_goods.offline_price,2)}}</text>
  288 + </block>
  289 + <block wx:else>
  290 + <text style="color: #d7642b;">不使用优惠</text>
  291 + </block>
  292 + <!-- 右边点击 -->
  293 + <view class="xc-right" style="margin-right: 12rpx; border-color: #d7642b;"></view>
273 294 </view>
274 295  
275   - </view>
276   -
277   - <!-- ---使用余额---- -->
278   - <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}">
279   - <view class="use-item" bindtap='set_js_useyuer'>
280   - <icon color="{{js_use_money?'red':'gray'}}" size="16" type="success"></icon>
281   - <view class="yu_er">使用余额 :¥{{yuer}} </view>
282   - </view>
283   - </view>
284   -
285   - </block>
286   -
287   - <!-- ----立即购买------ -->
288   - <!-- <view class="xc-border xc-border"></view> -->
289   - <block wx:if="{{is_b_now==1}}">
290   - <view class="use-item bfff bdr_t-14 mgt20">
291   - <image class="dp" src='{{imgUrl}}/miniapp/images/goodscategory/new_store.png'> </image>
292   - <view>{{bn_pickname}}</view>
293   - <!-- <view>门店:{{bn_pickname}}</view> -->
294   - </view>
295   - <view class="order-detail">
296   - <view class="goods-img">
297   - <image class="wh100 bdr14" src="{{bn_goods.original_img}}" binderror='cart_set_err' data-err="bn_goods.original_img"></image>
298   - </view>
299   - <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{bn_goods.goods_id}}">
300   - <view class="goods-name ellipsis-2">{{bn_goods.goods_name}}</view>
301   - <!-- 商品属性 -->
302   - <view class="flex-vertical fs28 xc-ash color-gray n_guige">
303   - <view class="goods-color">
304   - <block><text>{{filters.show_gui_ge(bn_goods.goods_spec,bn_goods.goods_color)}}</text></block>
305   - <!--<block wx:if="{{!bn_goods.goods_spec && !bn_goods.goods_color}}"><text>规格1</text></block>-->
306   - <!--<block wx:else>-->
307   - <!--<text wx:if="{{bn_goods.goods_spec!=''}}">{{bn_goods.goods_spec}}<text wx:if="{{bn_goods.goods_color}}">/</text></text>-->
308   - <!--<text wx:if="{{bn_goods.goods_color}}">{{bn_goods.goods_color}}</text>-->
309   - <!--</block>-->
310   - </view>
311   - </view>
312   -
313   - <!-- ---商品名称规格---- -->
314   - <view class="order-num flex-space-between">
315   - <view class="co-red">¥<text class="fs36">{{filters.toFix(bn_goods.shop_price,2)}}</text></view>
316   - <view class="goods-num">x{{bn_goods.buynum}}</view>
317   - </view>
318   - </navigator>
319   -
320   - </view>
321   - <!-- 赠品的显示 -->
322   - <view class="order-detail" wx:if="{{buy_now_gift_goods}}">
323   - <view class="goods-img" style="position: relative">
324   - <image src="{{imgUrl}}/miniapp/images/giveaway.png" class="gift_image"></image>
325   -
326   - <image class="wh100 bdr14" src="{{buy_now_gift_goods.original_img}}" binderror='cart_set_err' data-err="buy_now_gift_goods.original_img"></image>
327   - </view>
328   - <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{buy_now_gift_goods.goods_id}}">
329   - <view class="goods-name ellipsis-2">{{buy_now_gift_goods.goods_name}}</view>
330   - <!-- 商品属性 -->
331   - <view class="flex-vertical fs28 xc-ash color-gray n_guige">
332   - <view class="goods-color">
333   - <block><text>{{filters.show_gui_ge(buy_now_gift_goods.goods_spec,buy_now_gift_goods.goods_color)}}</text></block>
334   - </view>
335   - </view>
336   - <!-- ---商品名称规格---- -->
337   - <view class="order-num flex-space-between">
338   - <view class="co-red">¥<text class="fs36">0</text></view>
339   - <view class="goods-num">x{{buy_now_gift_goods.buynum}}</view>
340   - </view>
341   - </navigator>
342   - </view>
343   -
344   -
345   - <block wx:if="{{collocation_goods}}">
346   - <!-- 搭配购买的功能实现 -->
347   - <view class="order-detail" wx:for="{{collocation_goods}}">
348   - <view class="goods-img">
349   - <image class="wh100 bdr14" src="{{imgUrl+item.original_img}}" binderror='err_img_collocation' data-err="item.original_img"></image>
350   - </view>
351   - <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}">
352   - <view class="goods-name ellipsis-2">{{item.goods_name}}</view>
353   - <!-- 商品属性 -->
354   - <view class="flex-vertical fs28 xc-ash color-gray n_guige">
355   - <view class="goods-color">
356   - <block><text>{{filters.show_gui_ge(item.goods_spec,item.goods_color)}}</text></block>
357   - </view>
358   - </view>
359   - <!-- ---商品名称规格---- -->
360   - <view class="order-num flex-space-between">
361   - <view class="co-red">¥<text class="fs36">{{item.price}}</text></view>
362   - <view class="goods-num">x{{item.goods_num}}</view>
363   - </view>
364   - </navigator>
365   - </view>
366   - </block>
367   -
368   - <!-- 如果是等级卡的商品,会员没有注册,要提醒注册 -->
369   - <view class="plus_buy fs28" wx:if="{{card_cut_price>0}}">
370   - <view class="flex">
371   - <view class="card_bg ellipsis-1" style="margin-right: 10rpx;">
372   - <image src="{{imgUrl}}/miniapp/images/plus/dj_icon.png"></ image>
373   - <text class="card_name">{{show_card.CardName}}</text>
374   - </view>
375   - <view>立减 <text style="color:#f23030;">{{filters.toFix(card_cut_price,2) }}</text> 元</view>
376   - </view>
377   - <view>
378   - <text style="color: #999;margin-left: 4rpx;">vip超级会员仅需{{show_card.CardFee}}元</text>
379   - </view>
380   - <!-- 三角形 -->
381   - <view class="car_tri_up"></view>
382   - <!-- 立即开通跳转 -->
383   - <view bindtap="buycard" class="card_op">立即开通</view>
384   - </view>
385   -
386   -
387   - <view class="set-mes bdr_b-14">
388   - <view wx:if="{{order.store_prom}}">
389   - <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}}
390   - </view>
391   -
392   - <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{bn_pick}}" wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}">
393   - <view class="work-frame flex-space-between">
394   - <view class="work">
395   - 优惠券 <text class="quan_num_show">{{(selected_quan_list?selected_quan_list.length:0)+ (get_by_quan_list?get_by_quan_list.length:0)}}张可用</text>
396   - </view>
397   - <view class="xc-right-frame">
398   - <text wx:if="{{using_quan[bn_pick].is_nouse}}">不使用</text>
399   - <block wx:else>
400   - <text wx:if="{{using_quan[bn_pick].money}}">¥{{using_quan[bn_pick].money}}元优惠券</text>
401   - <text wx:if="{{using_quan[bn_pick].isby}}">包邮券</text>
402   - </block>
403   - <view class="xc-right"></view>
404   - </view>
405   - </view>
406   - </view>
407   -
408   - <view class="xc-coupon-frame" wx:if="{{bn_exp_type==0 && !is_default_logistics}}">
409   - <view class="flex-space-between" style="padding: 20rpx 25rpx; font-size: 30rpx;">
410   - <view>选择物流</view>
411   - <view class="flex-vertical" bindtap="show_wu_arr" data-txt='index' style="margin-right: 12rpx;">
412   - <view class="logistics-name">{{wu_arr[index].name}}</view>
413   - <view class="xc-right"></view>
414   - </view>
415   - </view>
416   - </view>
417   - </view>
418   - <!-- 留言 -->
419   - <view class="coupon-mes flex-vertical">
420   - <view>留言</view>
421   - <view class="leave-word">
422   - <input placeholder-class="fs28" placeholder='给商家留言,最多100字' bindinput="keyUpChangeNum" disabled="{{disabled}}"
423   - class="word-box" maxlength="100" name="user_note"></input>
424   - </view>
425   - </view>
426   -
427   - <!-- 是否参与店铺优惠 -->
428   - <view class="coupon-mes flex-vertical" bindtap="bn_pop_offline" wx:if="{{bn_goods.offline_price}}">
429   - <view>店铺优惠</view>
430   - <view class="leave-word fs32" style="color: #999;">
431   - 省{{filters.toFix(bn_goods.shop_price-bn_goods.offline_price,2)}}元
432   - </view>
433   - <block wx:if="{{bn_goods.is_offline}}">
434   - <text style="color: #d7642b;">-¥{{filters.toFix(bn_goods.shop_price-bn_goods.offline_price,2)}}</text>
435   - </block>
436   - <block wx:else>
437   - <text style="color: #d7642b;">不使用优惠</text>
438   - </block>
439   - <!-- 右边点击 -->
440   - <view class="xc-right" style="margin-right: 12rpx; border-color: #d7642b;"></view>
441   - </view>
442   -
443   -
444   - <!-----使用余额------>
445   - <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}">
446   - <view class="use-item" bindtap='set_bn_useyuer'>
447   - <icon color="{{bn_use_money?'red':'gray'}}" size="16" type="success"></icon>
448   - <view class="yu_er">使用余额 :¥{{yuer}} </view>
449   - </view>
450   - </view>
451   -
452   - </block>
453   -
454   - <view class="information bdr14">
455   - <view class="item" wx:if="{{formData.all_price>0}}">
456   - <view>商品金额</view>
457   - <view class="co-red">¥ {{formData.all_price}}元</view>
458   - </view>
459   - <view class="item" wx:if="{{formData.shipping_price>0}}">
460   - <view>配送费用</view>
461   - <view class="co-red">¥ {{formData.shipping_price}}元</view>
462   - </view>
463   - <view class="item" wx:if="{{formData.coupon_price>0}}">
464   - <view>使用优惠券</view>
465   - <view class="co-red">- ¥ {{formData.coupon_price}}元</view>
466   - </view>
467   - <!-- 优惠活动优惠金额 -->
468   - <view class="item" wx:if="{{formData.cut_price>0}}">
469   - <view>优惠活动</view>
470   - <view class="co-red">- ¥ {{filters.toFix(formData.cut_price,2)}}元</view>
471   - </view>
472   - <!-- 组合购优惠金额 -->
473   - <view class="item" wx:if="{{formData.zh_cut_price>0 || formData.zh_cut_price<0}}">
474   - <view>组合购优惠</view>
475   - <view class="co-red">- ¥ {{filters.toFix(formData.zh_cut_price,2)}}元</view>
476   - </view>
477   -
478   - <!-- 订单优惠优惠金额 -->
479   - <view class="item" wx:if="{{formData.order_prom_amount>0}}">
480   - <view>订单优惠</view>
481   - <view class="co-red">- ¥ {{filters.toFix(formData.order_prom_amount,2)}}元</view>
482   - </view>
483   - <view class="item" wx:if="{{formData.user_money>0}}">
484   - <view>使用余额</view>
485   - <view class="co-red">- ¥ {{formData.user_money}}元</view>
486   - </view>
487   - </view>
488   -
489   - <view class="information bdr14 mgt20">
490   - <view class="item">
491   - <view>阶段一:定金(待付款)</view>
492   - <view class="co-red">¥9.99元</view>
493   - </view>
494   - <view class="item">
495   - <view>阶段二:尾款</view>
496   - <view class="co-red">¥88元</view>
497   - </view>
498   - </view>
499   -
500   - <view class="information bdr14 mgt20">
501   - <view class="item ai-center">
502   - <view>我同意预售商品不退定金</view>
503   - <switch type="switch" checked="" bindchange="switchChange"/>
504   - </view>
505   - </view>
506   -
507   - </view>
508   -
509   - <view class="fixedToBottom shadow-1" wx:if="{{show_submit}}">
510   - <!-- <view class="date-container">尾款时间:2021.10.01 00:00:00 - 2021.10.10 23:59:59</view> -->
511   - <view class="date-container">请于*天**小时**分**秒内付款完成,超时订单将自动取消</view>
512   - <view class="btn-wrap">
513   - <view class="pay-amount">
514   - <view class="payable">应付金额:<text class="co-red"><text class="fs24">¥</text>{{formData.order_amount}}</text></view>
515   - <!-- 预售 -->
516   - <!-- <view class="payable">尾款:<text class="co-red"><text class="fs24">¥</text>{{formData.order_amount}}</text></view> -->
517   - </view>
518   - <button class="tips-btn" formType="submit" id="submitOrder">提交订单</button>
519   - <!-- 预售 -->
520   - <!-- <button class="tips-btn" formType="submit" id="submitOrder">立即支付</button> -->
521   - </view>
522   - </view>
  296 +
  297 + <view class="information bdr14">
  298 + <view class="item" wx:if="{{allpice>0}}">
  299 + <view>商品金额</view>
  300 + <view class="co-red">¥ {{filters.toFix(allpice,2)}}元</view>
  301 + </view>
  302 + <view class="item" wx:if="{{exp_price>0}}">
  303 + <view>配送费用</view>
  304 + <view class="co-red">¥ {{filters.toFix(exp_price,2)}}元</view>
  305 + </view>
  306 +
  307 + <view class="item" wx:if="{{quan_price>0}}">
  308 + <view>优惠券优惠</view>
  309 + <view class="co-red">¥ -{{filters.toFix(quan_price,2)}}元</view>
  310 + </view>
  311 +
  312 + <view class="item" wx:if="{{order_prom_amount>0}}">
  313 + <view>订单优惠</view>
  314 + <view class="co-red">¥ -{{filters.toFix(order_prom_amount,2)}}元</view>
  315 + </view>
  316 +
  317 + </view>
  318 +
  319 + <view class="information bdr14 mgt20">
  320 + <block wx:if="{{act.presell_type==0}}">
  321 + <view class="item">
  322 + <view>阶段一:定金(待付款)</view>
  323 + <view class="co-red">¥{{filters.toFix(pre_arr.presell_money*order.order_goods.goods_num,2)}}元</view>
  324 + </view>
  325 + <view class="item">
  326 + <view>阶段二:尾款</view>
  327 + <view class="co-red">¥{{filters.toFix(tail_pay,2)}}元</view>
  328 + </view>
  329 + </block>
  330 + </view>
  331 + </view>
  332 +
  333 + <!-- 要支付尾款的时候 -->
  334 + <view class="fixedToBottom shadow-1" wx:if="{{wait_wk}}">
  335 + <view wx:if="{{no_start}}" class="date-container">尾款时间{{filters.format_time(presell.kw_start_time,1)}} -
  336 + {{filters.format_time(presell.kw_end_time,1)}}
  337 + </view>
  338 + <view wx:elif="{{is_end}}" class="date-container">尾款时间已经结束</view>
  339 + <view wx:elif="{{wait_wk && !no_start}}" class="date-container">
  340 + 请于{{days}}天{{hours}}小时{{minutes}}分{{seconds}}秒内付款完成,超时订单将自动取消
  341 + </view>
  342 +
  343 + <view class="btn-wrap">
  344 + <view class="pay-amount">
  345 + <view class="payable">应付金额:
  346 + <text class="co-red"> <text class="fs24">¥</text>{{filters.toFix(order_m-presell.presell_deposit,2)}}</text>
  347 + </view>
  348 + </view>
  349 + <button wx:if="{{no_start || is_end || is_complete}}" class="tips-btn gray">提交订单</button>
  350 + <button wx:else class="tips-btn" bindtap="show_pay">提交订单</button>
  351 + <!-- 预售 -->
  352 + <!-- <button class="tips-btn" formType="submit" id="submitOrder">立即支付</button> -->
  353 + </view>
  354 + </view>
  355 + <!-- 当订单不是支付尾款的时候 -->
  356 + <view class="fixedToBottom shadow-1" wx:else style="background-color: #fff;display: flex; justify-content: flex-end; padding: 10rpx 0">
  357 + <view bindtap="cancelOrder" data-id="{{order.order_id}}" class="tips-btn2" wx:if="{{wait_dj}}">取消订单</view>
  358 + <view bindtap="jumpToCart4" class="tips-btn2" wx:if="{{wait_dj}}">立即付款</view>
  359 + <block wx:if="{{!(order.has_rt || order.return_btn==2 || order.return_btn==4)}}">
  360 + <navigator bindtap="confirmOrder" class="tips-btn2" hidden="{{!wait_sh}}">收货确认</navigator>
  361 + </block>
  362 +
  363 + <view class="tips-btn2" wx:if="{{order.order_status==3}}" bindtap="deleteOrderData" data-order_id="{{order.order_id}}" >删除订单</view>
  364 +
  365 +
  366 + <navigator class="tips-btn2" hidden="{{!order.shipping_btn}}" url="/pages/user/express/express?order_id={{order.order_id}}">查看物流</navigator>
  367 +
  368 +
  369 + <block wx:if="{{order.return_btn==undefined && order.is_all_return!=1}}">
  370 + <navigator class="tips-btn2" wx:if="{{(order.order_status==0&&order.pay_status==1) && !order.is_bedistri}}" url="/pages/order/refund_order/refund_order?order_id={{order.order_id}}">申请退款</navigator>
  371 + <navigator class="tips-btn2" wx:if="{{(order.order_status==1&&order.pay_status==1) && !order.is_bedistri}}" url="/pages/order/refund_order/refund_order?order_id={{order.order_id}}">申请退款</navigator>
  372 + </block>
  373 + <block wx:else>
  374 + <view class="tips-btn2" wx:if="{{order.is_all_return_status==2 && order.isdel==0}}" bindtap="deleteOrderData" data-order_id="{{order.order_id}}" >删除订单</view>
  375 + <navigator class="tips-btn2" wx:if="{{order.is_all_return_status==3 && order.order_status<2}}" url="/pages/order/refund_order/refund_order?order_id={{order.order_id}}">重新退款</navigator>
  376 + <navigator class="tips-btn2" wx:if="{{order.is_all_return_status==0 || order.is_all_return_status==1}}"
  377 + url="/pages/user/return_goods_info/return_goods_info?order_id={{order.order_id}}">退款详情</navigator>
  378 + </block>
  379 +
  380 +
  381 + <block wx:if="{{order.order_status==2 }}">
  382 + <navigator class="tips-btn2" url="/packageB/pages/user/add_comment/add_comment?goods_id={{order_goods.goods_id}}&order_id={{order.order_id}}}">去评价</navigator>
  383 + </block>
  384 +
  385 + </view>
  386 +
  387 +
523 388 </form>
524 389  
525 390 <!-- 使用券列表的弹窗 -->
526 391 <view wx:if='{{open_quan==1}}'>
527   - <view class="cover-layer flex-center " bindtap='close_coupon'> </view>
528   - <view class="cx-popup {{open_quan==true?'up' : 'down'}}">
529   - <!-- 最上面 -->
530   - <view class="top flex">
531   - <view class="xc-top-content t-c">
532   - <view class="xc-title">优惠券使用</view>
533   - </view>
534   - <view class="xc-close-frame" bindtap='close_coupon'>
535   - <view class="xc-close">×</view>
536   - </view>
537   - </view>
538   - <!-- 使用优惠券和不使用优惠券层-->
539   - <view class="may_use_coupon fs28 flex"> 可使用的优惠券
540   - <view class=" is_use_coupon flex-vertical" bindtap="sele_quan_item" data-no="1">不使用优惠券
541   - <block wx:if="{{using_quan[selected_quan_pick].is_nouse_red}}">
542   - <view class="circle white xc-hooka fs20 red-b sn"><text>Γ</text></view>
543   - </block>
544   - <block wx:else>
545   - <view class="circle xc-hookst ons"></view>
546   - </block>
547   - </view>
548   - </view>
549   -
550   - <!-- 中间券内容显示 -->
551   - <view class="xc-frame flex-level">
552   - <view class="list-frame">
553   - <view wx:for="{{selected_quan_list}}" bindtap="sele_quan_item" wx:if="{{!item.is_using}}" data-ind="{{q_index}}"
554   - wx:for-item="item" wx:for-index="q_index">
555   - <view class="xc-coupon-frame flex-center" data-ind="{{q_index}}">
556   - <view class="coupon-frame flex rel">
557   - <!-- 锯齿 -->
558   - <include src="juchi_part.wxml" />
559   - <!-- 左边 -->
560   - <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
561   - <view class="white xc-money-frames">
562   - <view class="f_text"><text class="xc-rmb-symbol">¥</text><text class="xc-rmb-val">{{item.Sum}}</text></view>
563   - <view class="coupon-explain t-c" wx:if="{{item.BuySum>0}}">满{{item.BuySum}}元可用</view>
564   - <view class="coupon-explain t-c" wx:else>满0元可用</view>
565   - </view>
566   - </view>
567   - <!-- 右边 -->
568   - <view class="coupon-right flex-center rel">
569   - <view class="coupon-annotation flex">
570   - <view class="flex top-frame">
571   - <view class="frame">
572   - <view class="coupon-wode ib flex ellipsis-2 ">
573   - <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">{{filter.get_type_card(item.UseObjectType)}}</text>
574   - <block>{{item.Sum}}元优惠券</block>
575   - </view>
576   - <view class="coupon-time">{{filters.replace_time2(item.BeginDate)}}至{{item.ValidDate?filters.replace_time2(item.ValidDate):'不限'}}</view>
577   - </view>
578   - </view>
579   - <block wx:if="{{item.show_red}}">
580   - <view class="circle white xc-hook fs20 red-b sn"><text>Γ</text></view>
581   - </block>
582   - <block wx:else>
583   - <view class="circle xc-hooks on"></view>
584   - </block>
585   - </view>
586   - <include src="remark_click_part.wxml" />
587   - </view>
588   - </view>
589   - </view>
590   - <!-- 打开是说明 -->
591   - <include src="remark_part.wxml" />
592   - </view>
593   - <!-- 包邮券的显示,立即购买 -->
594   - <block wx:if="{{ is_b_now && bn_exp_type==0}}">
595   - <view wx:for="{{get_by_quan_list}}" bindtap="sele_quan_item_by" wx:if="{{!item.is_using}}" data-ind="{{byq_index}}"
596   - wx:for-item="item" wx:for-index="byq_index">
597   - <view class="xc-coupon-frame flex-center" data-ind="{{byq_index}}">
598   - <view class="coupon-frame flex rel">
599   - <!-- 锯齿 -->
600   - <include src="juchi_part.wxml" />
601   - <!-- 左边 -->
602   - <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
603   - <view class="white xc-money-frames">
604   - <view class="f_text"><text class="xc-rmb-val">包邮券</text></view>
605   - <view class="coupon-explain t-c" wx:if="{{item.condition>0}}">满{{item.condition}}元可用</view>
606   - <view class="coupon-explain t-c" wx:else>满0元可用</view>
607   - </view>
608   - </view>
609   - <!-- 右边 -->
610   - <view class="coupon-right flex-center rel">
611   - <view class="coupon-annotation flex">
612   - <view class="flex top-frame">
613   - <view class="frame">
614   - <view class="coupon-wode ib flex ellipsis-2 ">
615   - <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">{{filter.get_type_card(0)}}</text>
616   - <block>包邮券</block>
617   - </view>
618   - <view class="coupon-time">{{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}}</view>
619   - </view>
620   - </view>
621   - <block wx:if="{{item.show_red}}">
622   - <view class="circle white xc-hook fs20 red-b sn"><text>Γ</text></view>
623   - </block>
624   - <block wx:else>
625   - <view class="circle xc-hooks on"></view>
626   - </block>
627   - </view>
628   - <include src="remark_click_part2.wxml" />
629   - </view>
630   - </view>
631   - </view>
632   - <!-- 打开是说明 -->
633   - <include src="remark_part.wxml" />
634   - </view>
635   - </block>
636   -
637   - <!-- 包邮券的显示,购物车购买 -->
638   - <block wx:if="{{!is_b_now && sele_exp_type==0}}">
639   - <view wx:for="{{by_quan_list_cart}}" bindtap="sele_quan_item_by" wx:if="{{!item.is_using}}" data-ind="{{byq_index}}"
640   - wx:for-item="item" wx:for-index="byq_index">
641   - <view class="xc-coupon-frame flex-center" data-ind="{{byq_index}}">
642   - <view class="coupon-frame flex rel">
643   - <!-- 锯齿 -->
644   - <include src="juchi_part.wxml" />
645   - <!-- 左边 -->
646   - <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
647   - <view class="white xc-money-frames">
648   - <view class="f_text"><text class="xc-rmb-val">包邮券</text></view>
649   - <view class="coupon-explain t-c" wx:if="{{item.condition>0}}">满{{item.condition}}元可用</view>
650   - <view class="coupon-explain t-c" wx:else>满0元可用</view>
651   - </view>
652   - </view>
653   - <!-- 右边 -->
654   - <view class="coupon-right flex-center rel">
655   - <view class="coupon-annotation flex">
656   - <view class="flex top-frame">
657   - <view class="frame">
658   - <view class="coupon-wode ib flex ellipsis-2 ">
659   - <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">{{filter.get_type_card(0)}}</text>
660   - <block>包邮券</block>
661   - </view>
662   - <view class="coupon-time">{{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}}</view>
663   - </view>
664   - </view>
665   - <block wx:if="{{item.show_red}}">
666   - <view class="circle white xc-hook fs20 red-b sn"><text>Γ</text></view>
667   - </block>
668   - <block wx:else>
669   - <view class="circle xc-hooks on"></view>
670   - </block>
671   - </view>
672   - <include src="remark_click_part2.wxml" />
673   - </view>
674   - </view>
675   - </view>
676   - <!-- 打开是说明 -->
677   - <include src="remark_part.wxml" />
678   - </view>
679   - </block>
680   -
681   -
682   - </view>
683   - </view>
684   - <!-- 最底下确定层-->
685   - <view class="determine-frame">
686   - <view class="xc-confirm flex-center" bindtap="confirm_quan"> 确定 </view>
687   - </view>
688   - </view>
  392 + <view class="cover-layer flex-center " bindtap='close_coupon'></view>
  393 + <view class="cx-popup {{open_quan==true?'up' : 'down'}}">
  394 + <!-- 最上面 -->
  395 + <view class="top flex">
  396 + <view class="xc-top-content t-c">
  397 + <view class="xc-title">优惠券使用</view>
  398 + </view>
  399 + <view class="xc-close-frame" bindtap='close_coupon'>
  400 + <view class="xc-close">×</view>
  401 + </view>
  402 + </view>
  403 + <!-- 使用优惠券和不使用优惠券层-->
  404 + <view class="may_use_coupon fs28 flex"> 可使用的优惠券
  405 + <view class=" is_use_coupon flex-vertical" bindtap="sele_quan_item" data-no="1">不使用优惠券
  406 + <block wx:if="{{using_quan[selected_quan_pick].is_nouse_red}}">
  407 + <view class="circle white xc-hooka fs20 red-b sn">
  408 + <text>Γ</text>
  409 + </view>
  410 + </block>
  411 + <block wx:else>
  412 + <view class="circle xc-hookst ons"></view>
  413 + </block>
  414 + </view>
  415 + </view>
  416 +
  417 + <!-- 中间券内容显示 -->
  418 + <view class="xc-frame flex-level">
  419 + <view class="list-frame">
  420 + <view wx:for="{{selected_quan_list}}" bindtap="sele_quan_item" wx:if="{{!item.is_using}}"
  421 + data-ind="{{q_index}}"
  422 + wx:for-item="item" wx:for-index="q_index">
  423 + <view class="xc-coupon-frame flex-center" data-ind="{{q_index}}">
  424 + <view class="coupon-frame flex rel">
  425 + <!-- 锯齿 -->
  426 + <include src="juchi_part.wxml"/>
  427 + <!-- 左边 -->
  428 + <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
  429 + <view class="white xc-money-frames">
  430 + <view class="f_text">
  431 + <text class="xc-rmb-symbol">¥</text>
  432 + <text class="xc-rmb-val">{{item.Sum}}</text>
  433 + </view>
  434 + <view class="coupon-explain t-c" wx:if="{{item.BuySum>0}}">满{{item.BuySum}}元可用
  435 + </view>
  436 + <view class="coupon-explain t-c" wx:else>满0元可用</view>
  437 + </view>
  438 + </view>
  439 + <!-- 右边 -->
  440 + <view class="coupon-right flex-center rel">
  441 + <view class="coupon-annotation flex">
  442 + <view class="flex top-frame">
  443 + <view class="frame">
  444 + <view class="coupon-wode ib flex ellipsis-2 ">
  445 + <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">
  446 + {{filter.get_type_card(item.UseObjectType)}}
  447 + </text>
  448 + <block>{{item.Sum}}元优惠券</block>
  449 + </view>
  450 + <view class="coupon-time">
  451 + {{filters.replace_time2(item.BeginDate)}}至{{item.ValidDate?filters.replace_time2(item.ValidDate):'不限'}}
  452 + </view>
  453 + </view>
  454 + </view>
  455 + <block wx:if="{{item.show_red}}">
  456 + <view class="circle white xc-hook fs20 red-b sn">
  457 + <text>Γ</text>
  458 + </view>
  459 + </block>
  460 + <block wx:else>
  461 + <view class="circle xc-hooks on"></view>
  462 + </block>
  463 + </view>
  464 + <include src="remark_click_part.wxml"/>
  465 + </view>
  466 + </view>
  467 + </view>
  468 + <!-- 打开是说明 -->
  469 + <include src="remark_part.wxml"/>
  470 + </view>
  471 + <!-- 包邮券的显示,立即购买 -->
  472 + <block wx:if="{{ is_b_now && bn_exp_type==0}}">
  473 + <view wx:for="{{get_by_quan_list}}" bindtap="sele_quan_item_by" wx:if="{{!item.is_using}}"
  474 + data-ind="{{byq_index}}"
  475 + wx:for-item="item" wx:for-index="byq_index">
  476 + <view class="xc-coupon-frame flex-center" data-ind="{{byq_index}}">
  477 + <view class="coupon-frame flex rel">
  478 + <!-- 锯齿 -->
  479 + <include src="juchi_part.wxml"/>
  480 + <!-- 左边 -->
  481 + <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
  482 + <view class="white xc-money-frames">
  483 + <view class="f_text">
  484 + <text class="xc-rmb-val">包邮券</text>
  485 + </view>
  486 + <view class="coupon-explain t-c" wx:if="{{item.condition>0}}">
  487 + 满{{item.condition}}元可用
  488 + </view>
  489 + <view class="coupon-explain t-c" wx:else>满0元可用</view>
  490 + </view>
  491 + </view>
  492 + <!-- 右边 -->
  493 + <view class="coupon-right flex-center rel">
  494 + <view class="coupon-annotation flex">
  495 + <view class="flex top-frame">
  496 + <view class="frame">
  497 + <view class="coupon-wode ib flex ellipsis-2 ">
  498 + <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">
  499 + {{filter.get_type_card(0)}}
  500 + </text>
  501 + <block>包邮券</block>
  502 + </view>
  503 + <view class="coupon-time">
  504 + {{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}}
  505 + </view>
  506 + </view>
  507 + </view>
  508 + <block wx:if="{{item.show_red}}">
  509 + <view class="circle white xc-hook fs20 red-b sn">
  510 + <text>Γ</text>
  511 + </view>
  512 + </block>
  513 + <block wx:else>
  514 + <view class="circle xc-hooks on"></view>
  515 + </block>
  516 + </view>
  517 + <include src="remark_click_part2.wxml"/>
  518 + </view>
  519 + </view>
  520 + </view>
  521 + <!-- 打开是说明 -->
  522 + <include src="remark_part.wxml"/>
  523 + </view>
  524 + </block>
  525 +
  526 + <!-- 包邮券的显示,购物车购买 -->
  527 + <block wx:if="{{!is_b_now && sele_exp_type==0}}">
  528 + <view wx:for="{{by_quan_list_cart}}" bindtap="sele_quan_item_by" wx:if="{{!item.is_using}}"
  529 + data-ind="{{byq_index}}"
  530 + wx:for-item="item" wx:for-index="byq_index">
  531 + <view class="xc-coupon-frame flex-center" data-ind="{{byq_index}}">
  532 + <view class="coupon-frame flex rel">
  533 + <!-- 锯齿 -->
  534 + <include src="juchi_part.wxml"/>
  535 + <!-- 左边 -->
  536 + <view class="coupon-left rel {{filter.setcolor(item.UseObjectType)}} flex-center">
  537 + <view class="white xc-money-frames">
  538 + <view class="f_text">
  539 + <text class="xc-rmb-val">包邮券</text>
  540 + </view>
  541 + <view class="coupon-explain t-c" wx:if="{{item.condition>0}}">
  542 + 满{{item.condition}}元可用
  543 + </view>
  544 + <view class="coupon-explain t-c" wx:else>满0元可用</view>
  545 + </view>
  546 + </view>
  547 + <!-- 右边 -->
  548 + <view class="coupon-right flex-center rel">
  549 + <view class="coupon-annotation flex">
  550 + <view class="flex top-frame">
  551 + <view class="frame">
  552 + <view class="coupon-wode ib flex ellipsis-2 ">
  553 + <text class="xc-brand t-c ib white {{filter.setcolor(item.UseObjectType)}}">
  554 + {{filter.get_type_card(0)}}
  555 + </text>
  556 + <block>包邮券</block>
  557 + </view>
  558 + <view class="coupon-time">
  559 + {{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}}
  560 + </view>
  561 + </view>
  562 + </view>
  563 + <block wx:if="{{item.show_red}}">
  564 + <view class="circle white xc-hook fs20 red-b sn">
  565 + <text>Γ</text>
  566 + </view>
  567 + </block>
  568 + <block wx:else>
  569 + <view class="circle xc-hooks on"></view>
  570 + </block>
  571 + </view>
  572 + <include src="remark_click_part2.wxml"/>
  573 + </view>
  574 + </view>
  575 + </view>
  576 + <!-- 打开是说明 -->
  577 + <include src="remark_part.wxml"/>
  578 + </view>
  579 + </block>
  580 +
  581 +
  582 + </view>
  583 + </view>
  584 + <!-- 最底下确定层-->
  585 + <view class="determine-frame">
  586 + <view class="xc-confirm flex-center" bindtap="confirm_quan"> 确定</view>
  587 + </view>
  588 + </view>
689 589 </view>
  590 +
690 591 <!----弹起选择物流名的列表---->
691 592 <view wx:if='{{open_express==1}}'>
692   - <view class="cover-layer flex-center " bindtap='close_express'>
693   - </view>
694   -
695   - <view class="cx-popup radius {{open_express==1?'up' : 'down'}}">
696   - <view class="tops flex">
697   - <view class="top-content fs32">
698   - <view>选择物流名字</view>
699   - </view>
700   - <view class="close-frame" bindtap='close_express'>
701   - <view class="xc-close-express">×</view>
702   - </view>
703   - </view>
704   - <view class="express_list">
705   - <view wx:for="{{wu_arr}}" wx:for-item="express_list" wx:for-index="idx">
706   - <view class="express_list_frame" bindtap="click_express_name" data-shippingcode="{{express_list.shipping_code}}"
707   - data-name="{{express_list.name}}" data-idxe="{{idx}}">
708   -
709   - <block wx:if="{{is_express==idx}}">
710   - <view class="circle white xc-hook fs20 red-b"><text>Γ</text></view>
711   - </block>
712   - <block wx:else>
713   - <view class="circle xc-hooks"></view>
714   - </block>
715   - <view class="fs30">{{express_list.name}}</view>
716   -
717   - </view>
718   - </view>
719   - </view>
720   - <view class="flex click-buttem">
721   - <view class="xc-determine flex-center" bindtap="determine_expres">
722   - <view class="flex-vertical t-c">确定</view>
723   - </view>
724   - <view class="xc-confirms flex-center" bindtap="select_default_logistics">
725   - <view class="flex-vertical t-c">设为默认</view>
726   - </view>
727   - </view>
728   -
729   - </view>
  593 + <view class="cover-layer flex-center " bindtap='close_express'>
  594 + </view>
  595 +
  596 + <view class="cx-popup radius {{open_express==1?'up' : 'down'}}">
  597 + <view class="tops flex">
  598 + <view class="top-content fs32">
  599 + <view>选择物流名字</view>
  600 + </view>
  601 + <view class="close-frame" bindtap='close_express'>
  602 + <view class="xc-close-express">×</view>
  603 + </view>
  604 + </view>
  605 + <view class="express_list">
  606 + <view wx:for="{{wu_arr}}" wx:for-item="express_list" wx:for-index="idx">
  607 + <view class="express_list_frame" bindtap="click_express_name"
  608 + data-shippingcode="{{express_list.shipping_code}}"
  609 + data-name="{{express_list.name}}" data-idxe="{{idx}}">
  610 +
  611 + <block wx:if="{{is_express==idx}}">
  612 + <view class="circle white xc-hook fs20 red-b">
  613 + <text>Γ</text>
  614 + </view>
  615 + </block>
  616 + <block wx:else>
  617 + <view class="circle xc-hooks"></view>
  618 + </block>
  619 + <view class="fs30">{{express_list.name}}</view>
  620 +
  621 + </view>
  622 + </view>
  623 + </view>
  624 + <view class="flex click-buttem">
  625 + <view class="xc-determine flex-center" bindtap="determine_expres">
  626 + <view class="flex-vertical t-c">确定</view>
  627 + </view>
  628 + <view class="xc-confirms flex-center" bindtap="select_default_logistics">
  629 + <view class="flex-vertical t-c">设为默认</view>
  630 + </view>
  631 + </view>
  632 +
  633 + </view>
730 634 </view>
731 635 <warn id="warn"></warn>
732   -<!-- 是不是使用店铺优惠pop -->
733   -<view class="cover-layer flex ai-center" bindtap="close_offline" wx:if="{{is_offline_show}}">
734   - <view style="background-color: #fff; width: 540rpx; margin: 0 auto; border-radius: 20rpx;">
735   - <view class="fs32" style="text-align: center;height: 80rpx; line-height: 80rpx;">店铺优惠</view>
736   - <view class="flex jc_sb ai-center fs28" style="height: 80rpx; width: 400rpx; margin-left: 70rpx;">
737   - <view catchtap="sure_offline" class="flex ai-center" >优惠¥{{show_off_price}}
738   - <icon style="margin-left: 10rpx;" color="{{is_get_offline?'red':'gray'}}" size="14" type="success" role="img"></icon></view>
739   - <view catchtap="cancle_offline" class="flex ai-center" >不用优惠
740   - <icon style="margin-left: 10rpx;" color="{{is_get_offline!=1?'red':'gray'}}" size="14" type="success" role="img"></icon> </view>
741   - </view>
742   - </view>
743   -</view>
  636 +
744 637  
745 638 <!-- 客服 -->
746 639 <view class="kefu-container shadow-1">
747   - <text class="iconfont icon-kefu fs60 co-red"></text>
  640 + <block wx:if="{{sys_switch.weapp_customertype}}">
  641 + <button wx:if="{{sys_switch.weapp_customertype}}" class="kefu-btn"
  642 + open-type="contact"
  643 + session-from="wechat|{{userInfo.user_id}}|{{userInfo.nickname}}|{{userInfo.head_pic}}">
  644 + <text class="iconfont icon-kefu fs60 co-red"></text>
  645 + </button>
  646 + </block>
  647 + <block wx:else>
  648 + <text class="iconfont icon-kefu fs60 co-red"></text>
  649 + </block>
748 650 </view>
  651 +
  652 +<!--支付的方式选择,0微信支付 1余额支付-->
  653 +<block wx:if="{{show_pay_type}}">
  654 + <view class="cover-layer" bindtap="close_show_pay"></view>
  655 + <view class="pay_type_view">
  656 + <view class="title">请选择支付方式</view>
  657 + <view class="anniu_view">
  658 + <view bindtap="set_pay_type" data-type="0">微信支付</view>
  659 + <view bindtap="set_pay_type" data-type="1">余额支付</view>
  660 + </view>
  661 + </view>
  662 +</block>
... ...
packageC/pages/presell/cart/cart.wxss
... ... @@ -42,13 +42,17 @@ page {
42 42  
43 43 .tab-wrapper {
44 44 background-color: #ccc;
45   - display: flex;
46   - border-radius: 40rpx;
47   - overflow: hidden;
  45 + display: flex;
  46 + border-radius: 40rpx;
  47 + overflow: hidden;
  48 + width: auto;
  49 + margin-top: 20rpx;
  50 + align-self: baseline;
  51 + font-size: 30rpx;
48 52 }
49 53  
50 54 .tab {
51   - padding: 20rpx 30rpx;
  55 + padding: 15rpx 25rpx;
52 56  
53 57 }
54 58  
... ... @@ -66,7 +70,7 @@ page {
66 70 color: #444;
67 71 /* margin-top: 28rpx; */
68 72 border-radius: 14rpx;
69   - padding: 20rpx 70rpx 20rpx 20rpx;
  73 + padding: 20rpx;
70 74 }
71 75 .user-contact {
72 76 /* padding: 24rpx 26rpx;
... ... @@ -320,6 +324,10 @@ margin:auto; */
320 324 margin-right: 0;
321 325 }
322 326  
  327 +.tips-btn.gray{
  328 +background-color:#e5e5e5;color: #666;
  329 +}
  330 +
323 331 .pay-amount {
324 332 /* float: right;
325 333 display: flex;
... ... @@ -996,12 +1004,22 @@ margin-left: 20rpx;
996 1004 }
997 1005  
998 1006  
  1007 +
  1008 +.circle1 {
  1009 + display: block;
  1010 + width: 10rpx;
  1011 + height: 10rpx;
  1012 + border-radius: 50%;
  1013 + margin: 0 auto;
  1014 + background-color: #ccc;
  1015 +}
  1016 +
  1017 +
999 1018 .circle {
1000 1019 display: block;
1001 1020 width: 10rpx;
1002 1021 height: 10rpx;
1003 1022 border-radius: 50%;
1004   - background-color: #ccc;
1005 1023 margin: 0 auto;
1006 1024 }
1007 1025  
... ... @@ -1056,7 +1074,42 @@ margin-left: 20rpx;
1056 1074 box-shadow: 0 4rpx 12px #e7e9eb;
1057 1075 }
1058 1076  
1059   -/* .icon-kefu {
1060   - font-size: 40rpx;
  1077 +.kefu-btn{
  1078 + width: 100%;
  1079 + height: 100%;
  1080 + text-align: center;
  1081 + line-height: 100rpx;
  1082 + border: none;
  1083 + background: none;
  1084 + border-radius: 50rpx;
  1085 +}
  1086 +
  1087 +.pay_type_view{width: 500rpx;height: 220rpx; position: fixed; background: #fff;z-index: 12;
  1088 + left: 50%; margin-left: -250rpx; top: 50%; margin-top: -110rpx; text-align: center; border-radius: 12rpx;}
  1089 +.pay_type_view .title{ height:100rpx; line-height: 100rpx; border-bottom: 1rpx solid #ededed;}
  1090 +.anniu_view{display: flex;height: 120rpx; line-height: 120rpx;}
  1091 +.anniu_view>view{width: 50%; border-right:1rpx solid #ededed;}
  1092 +
  1093 +.gray{color:#aaa}
  1094 +.note_text{
  1095 + width: 300rpx;margin-left: 20rpx;height: 52rpx; line-height: 52rpx; display: inline-block
1061 1096 }
1062   - */
  1097 +
  1098 +
  1099 +
  1100 +.tips-btn2 {
  1101 + display: inline-block;
  1102 + width: 140rpx;
  1103 + height: 60rpx;
  1104 + line-height: 60rpx;
  1105 + text-align: center;
  1106 + font-size: 30rpx;
  1107 + color: #fff;
  1108 + background-color: #f23030;
  1109 + /* margin-left: 2rpx; */
  1110 + margin-right: 12rpx;
  1111 + border-radius: 10rpx;
  1112 +
  1113 +}
  1114 +
  1115 +
... ...
packageC/pages/presell/cart/cart2_pre.js
... ... @@ -52,7 +52,7 @@ Page({
52 52 isclose:1,
53 53 is_express:0,//选择物流的控制器
54 54 yuer:0,
55   -
  55 + agree_no_ref:0
56 56 },
57 57 onLoad: function(t) {
58 58 var th = this; this.setData({ is_b_now: 1});
... ... @@ -241,7 +241,6 @@ Page({
241 241 }
242 242 }
243 243  
244   -
245 244 //先获取是否有关闭使用优惠券
246 245 getApp().getConfig2(function (ee) {
247 246 var json_d = JSON.parse(ee.switch_list);
... ... @@ -398,8 +397,9 @@ Page({
398 397 });
399 398 });
400 399 },
401   - //--------------------提交订单-----------------------
402   - submitForm: async function(t){
  400 +
  401 + // -- 支付的下一步 --
  402 + submitForm_next:async function(t){
403 403 if(this.data.is_summit_ing==1) return false; //--提交中退出--
404 404 this.data.is_summit_ing=1;
405 405  
... ... @@ -409,217 +409,230 @@ Page({
409 409  
410 410 //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候
411 411 if(th.data.bn_exp_type == 0 && th.data.user_addr==null && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){
412   - ff = false;
413   - getApp().my_warnning("请选择收货地址",0,this);
414   - this.data.is_summit_ing = 0;
  412 + ff = false;
  413 + getApp().my_warnning("请选择收货地址",0,this);
  414 + this.data.is_summit_ing = 0;
415 415 }
416 416 if (!ff) return false;
417 417 var addr = th.data.user_addr;
418 418 if (th.data.bn_exp_type == 1) addr=null;
419 419  
420 420 if(th.data.bn_exp_type==0 && (th.data.kt_type!=3)) {
421   - if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
422   - getApp().my_warnning("读取物流失败",0,this);
423   - this.data.is_summit_ing = 0;
424   - return false;
425   - }
  421 + if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
  422 + getApp().my_warnning("读取物流失败",0,this);
  423 + this.data.is_summit_ing = 0;
  424 + return false;
  425 + }
426 426 }
427   -
428   - //阶梯团强制带1,自提~~~
429   - if(th.data.kt_type==3 ){
430   - th.data.bn_exp_type=1;
431   - }
432   -
  427 +
  428 + //阶梯团强制带1,自提~~~
  429 + if(th.data.kt_type==3 ){
  430 + th.data.bn_exp_type=1;
  431 + }
  432 +
433 433 var item={
434   - 'user_id':app.globalData.user_id,
435   - 'consignee': addr == null ? "" : addr.consignee,
436   - 'province': addr == null ? 0 : addr.province,
437   - 'city': addr == null ? 0 : addr.city,
438   - 'district': addr == null ? 0 : addr.district,
439   - 'twon': addr == null ? 0 : addr.twon,
440   - 'address': addr == null ? "": addr.address,
441   - 'more_address': addr == null ? "" : addr.more_address,
442   - 'mobile': addr == null ? th.data.userinfo.mobile:addr.mobile,
443   - 'email':'',
444   - 'invoice_title':'',
445   - 'goods_price': th.data.formData.all_price, //商品总价
446   - 'shipping_price': th.data.formData.shipping_price, //物流金额
447   - 'user_money': th.data.formData.user_money, //使用余额
448   - 'total_amount': th.data.formData.total_amount, //订单总价
449   - 'order_amount': th.data.formData.order_amount, //应付
450   - 'user_note': t.detail.value.user_note, //用户备注
451   - 'store_id':os.stoid, //商家
452   - 'pickup_id': th.data.bn_pick, //门店
453   - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
454   - 'prom_id': th.data.bn_goods.prom_id, //促销活动id
455   - 'order_goods':new Array(),
456   - };
457   -
458   - //老会员成为分销下线需要的参数
459   - if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){
460   - //判断一下分享人是不是分享商
461   - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{
462   - if(res.data.code==0){
463   - var user= res.data.data;
464   - if(user.is_distribut==1){
465   - item.first_leader=parseInt(getApp().globalData.first_leader);
466   - }
467   - }
468   - })
469   - }
470   -
471   - if(th.data.qh!='')
472   - {
473   - item.team_qh=th.data.qh;
474   - item.pt_listno=th.data.qh;
475   - }
476   -
477   - var gg =app.get_b_now();
478   - var goods={
479   - 'goods_id': gg.goods_id,
480   - 'goods_name': gg.goods_name,
481   - 'goods_sn': gg.goods_sn,
482   - 'goods_num': gg.goods_num,
483   - 'market_price': th.data.bn_goods.market_price,
484   - 'goods_price': th.data.bn_goods.shop_price,
485   - 'member_goods_price': th.data.bn_goods.shop_price,
486   - 'store_id': os.stoid,
487   - 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
488   - 'prom_id': th.data.bn_goods.prom_id, //促销活动id
489   - };
490   -
491   - //--导购分享过来的id--
492   - if(gg.guide_id){
  434 + 'user_id':app.globalData.user_id,
  435 + 'consignee': addr == null ? "" : addr.consignee,
  436 + 'province': addr == null ? 0 : addr.province,
  437 + 'city': addr == null ? 0 : addr.city,
  438 + 'district': addr == null ? 0 : addr.district,
  439 + 'twon': addr == null ? 0 : addr.twon,
  440 + 'address': addr == null ? "": addr.address,
  441 + 'more_address': addr == null ? "" : addr.more_address,
  442 + 'mobile': addr == null ? th.data.userinfo.mobile:addr.mobile,
  443 + 'email':'',
  444 + 'invoice_title':'',
  445 + 'goods_price': th.data.formData.all_price, //商品总价
  446 + 'shipping_price': th.data.formData.shipping_price, //物流金额
  447 + 'user_money': th.data.formData.user_money, //使用余额
  448 + 'total_amount': th.data.formData.total_amount, //订单总价
  449 + 'order_amount': th.data.formData.order_amount, //应付
  450 + 'user_note': t.detail.value.user_note, //用户备注
  451 + 'store_id':os.stoid, //商家
  452 + 'pickup_id': th.data.bn_pick, //门店
  453 + 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
  454 + 'prom_id': th.data.bn_goods.prom_id, //促销活动id
  455 + 'order_goods':new Array(),
  456 + };
  457 +
  458 + //老会员成为分销下线需要的参数
  459 + if(getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader){
  460 + //判断一下分享人是不是分享商
  461 + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid+"/"+getApp().globalData.first_leader,{}).then(res=>{
  462 + if(res.data.code==0){
  463 + var user= res.data.data;
  464 + if(user.is_distribut==1){
  465 + item.first_leader=parseInt(getApp().globalData.first_leader);
  466 + }
  467 + }
  468 + })
  469 + }
  470 +
  471 + if(th.data.qh!='')
  472 + {
  473 + item.team_qh=th.data.qh;
  474 + item.pt_listno=th.data.qh;
  475 + }
  476 +
  477 + var gg =app.get_b_now();
  478 + var goods={
  479 + 'goods_id': gg.goods_id,
  480 + 'goods_name': gg.goods_name,
  481 + 'goods_sn': gg.goods_sn,
  482 + 'goods_num': gg.goods_num,
  483 + 'market_price': th.data.bn_goods.market_price,
  484 + 'goods_price': th.data.bn_goods.shop_price,
  485 + 'member_goods_price': th.data.bn_goods.shop_price,
  486 + 'store_id': os.stoid,
  487 + 'prom_type':th.data.bn_goods.prom_type, //促销活动类型
  488 + 'prom_id': th.data.bn_goods.prom_id, //促销活动id
  489 + };
  490 +
  491 + //--导购分享过来的id--
  492 + if(gg.guide_id){
493 493 goods.guide_id=gg.guide_id;
494 494 goods.guide_type=gg.guide_type;
495 495 //调用接口判断是不是会员
496 496 await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/"+os.stoid+"/"+gg.guide_id,{}).then(res=>{
497   - if(res.data.code==0){
498   - goods.guide_name=res.data.data.salesman;
499   - goods.guide_sn=res.data.data.salesman_no;
500   - }
501   - })
502   - }
  497 + if(res.data.code==0){
  498 + goods.guide_name=res.data.data.salesman;
  499 + goods.guide_sn=res.data.data.salesman_no;
  500 + }
  501 + })
  502 + }
503 503  
504 504 //--商品的房间号--
505 505 if(gg.room_id && gg.room_id>0){
506 506 item.room_ids=gg.room_id;
507 507 goods.room_id=gg.room_id;
508 508 }
509   -
510   - if(th.data.bn_goods.is_normal){goods.is_pd_normal=1;}
511   -
512   - item.order_goods.push(goods);
513   - pdata.push(item);
514   -
515   - if (pdata.length==0) return;
516   - var str = JSON.stringify(pdata);
517   - wx.showLoading({title: "加载中"});
518   - wx.request({
519   - url: os.url + '/api/weshop/order/createWxdOrder',
520   - data: str,
521   - method: 'POST',
522   - header: {
523   - 'content-type': 'application/json'
524   - },// 设置请求的 header
525   - success: function (res) {
526   -
527   - wx.hideLoading();
528   - if (res.statusCode == 200) {
529   - var data=res.data;
530   - if(data.code==0){
531   - console.log(th.data.is_b_now);
532   - //如果是购物车结算,还要删除购物车
533   - if (th.data.is_b_now == 0) {
534   - console.log(th.data.cartlist_y);
535   - var list = th.data.cartlist_y;
536   - for (var i = 0; i < list.length; i++) {
537   - //删除购物车
538   - getApp().request.delete("/api/weshop/cart/del/" + os.stoid + "/" + list[i].id, {});
539   - }
540   - }
541   - var order_amount = 0;
542   - pdata.forEach(function (em, ind) {
543   - order_amount += em.order_amount;
544   - })
545   - //要进行判断,如果是用微信支付,就要跳转到支付界面
546   - if (order_amount > 0) {
547   - th.setData({ isclose: 0 });
548   - //void e.jumpToCart4({
549   - // order_sn: data.data,
550   - // type:1,
551   - // }, 1);
552   - util_pay.pay(data.data, function() {
553   - setTimeout(function () {
554   - wx.reLaunch({
555   - //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data,
556   - url: "/pages/team/team_success/team_success?ordersn=" + data.data,
557   - })
558   - },1000)
559   - }, function () {
560   - //支付失败
561   - setTimeout(function () {
562   - //wx.navigateBack({ delta: 1 })
563   - wx.reLaunch({
564   - url: "/pages/user/order_list/order_list",
565   - })
566   - },1000)
567   -
568   - },os.stoid,1);
569 509  
570   - } else {
571   - var dd = {
572   - parent_sn: data.data,
573   - store_id: os.stoid,
574   - type: 1,
575   - };
576   - //return false;
577   - getApp().request.post("/api/weshop/order/pay/createOrder", {
578   - data: dd,
579   - success: function (t) {
580   - console.log(t);
581   - app.my_warnning("支付成功",1,th);
582   - setTimeout(function () {
583   - th.setData({ isclose: 0 });
584   -
585   - if(th.data.is_normal==1){
586   - /*--
587   - wx.navigateTo({
588   - url: "/pages/user/order_list/order_list",
589   - })--*/
590   - var url="/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data;
591   - wx.reLaunch({
592   - url: url
593   - })
594   -
595   - }else{
596   - wx.reLaunch({
597   - url: "/pages/team/team_success/team_success?ordersn=" + data.data,
598   - })
  510 + if(th.data.bn_goods.is_normal){goods.is_pd_normal=1;}
  511 +
  512 + item.order_goods.push(goods);
  513 + pdata.push(item);
  514 +
  515 + if (pdata.length==0) return;
  516 + var str = JSON.stringify(pdata);
  517 + wx.showLoading({title: "加载中"});
  518 + wx.request({
  519 + url: os.url + '/api/weshop/order/createWxdOrder',
  520 + data: str,
  521 + method: 'POST',
  522 + header: {
  523 + 'content-type': 'application/json'
  524 + },// 设置请求的 header
  525 + success: function (res) {
  526 +
  527 + wx.hideLoading();
  528 + if (res.statusCode == 200) {
  529 + var data=res.data;
  530 + if(data.code==0){
  531 + console.log(th.data.is_b_now);
  532 + //如果是购物车结算,还要删除购物车
  533 + if (th.data.is_b_now == 0) {
  534 + console.log(th.data.cartlist_y);
  535 + var list = th.data.cartlist_y;
  536 + for (var i = 0; i < list.length; i++) {
  537 + //删除购物车
  538 + getApp().request.delete("/api/weshop/cart/del/" + os.stoid + "/" + list[i].id, {});
  539 + }
  540 + }
  541 + var order_amount = 0;
  542 + pdata.forEach(function (em, ind) {
  543 + order_amount += em.order_amount;
  544 + })
  545 + //要进行判断,如果是用微信支付,就要跳转到支付界面
  546 + if (order_amount > 0) {
  547 + th.setData({ isclose: 0 });
  548 + util_pay.pay(data.data, function() {
  549 + var url="/packageC/pages/presell/cart/cart?order_sn="+data.data;
  550 + setTimeout(function () {
  551 + wx.reLaunch({ url: url,})
  552 + },1000)
  553 + }, function () {
  554 + //支付失败
  555 + setTimeout(function () {
  556 + //wx.navigateBack({ delta: 1 })
  557 + wx.reLaunch({
  558 + url: "/pages/user/order_list/order_list",
  559 + })
  560 + },1000)
  561 +
  562 + },os.stoid,1);
  563 +
  564 + } else {
  565 + var dd = {
  566 + parent_sn: data.data,
  567 + store_id: os.stoid,
  568 + type: 1,
  569 + };
  570 + //return false;
  571 + getApp().request.post("/api/weshop/order/pay/createOrder", {
  572 + data: dd,
  573 + success: function (t) {
  574 + console.log(t);
  575 + app.my_warnning("支付成功",1,th);
  576 + setTimeout(function () {
  577 + th.setData({ isclose: 0 });
  578 +
  579 +
  580 + var url="/packageC/pages/presell/cart/cart?order_sn="+data.data;
  581 + wx.reLaunch({
  582 + url: url
  583 + })
  584 +
  585 +
  586 +
  587 + }, 1000)
  588 + }
  589 + });
599 590 }
600   -
601   - }, 1000)
602 591 }
603   - });
  592 + else{
  593 + th.data.is_summit_ing=0; //是否提交中
  594 + getApp().confirmBox(data.msg);
  595 + }
  596 + } else {
  597 + th.data.is_summit_ing=0; //是否提交中
  598 + console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
604 599 }
605   - }
606   - else{
607   - th.data.is_summit_ing=0; //是否提交中
608   - getApp().confirmBox(data.msg);
609   - }
610   - } else {
611   - th.data.is_summit_ing=0; //是否提交中
612   - console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
613   - }
614   - },
615   - fail: function () {
616   - th.data.is_summit_ing=0; //是否提交中
617   - wx.hideLoading();
618   - console.log("index.js wx.request CheckCallUser fail");
619   - },
620   - complete: function () {}
621   - })
  600 + },
  601 + fail: function () {
  602 + th.data.is_summit_ing=0; //是否提交中
  603 + wx.hideLoading();
  604 + console.log("index.js wx.request CheckCallUser fail");
  605 + },
  606 + complete: function () {}
  607 + })
622 608 },
  609 +
  610 +
  611 + //--------------------提交订单-----------------------
  612 + submitForm: function(t){
  613 + var th=this;
  614 + //如果商家不同意退定义
  615 + if(!this.data.act.is_refundmoney && !th.agree_no_ref){
  616 + wx.showModal({
  617 + content: ' 预售商品不允许退定金!是否继续下单?',
  618 + showCancel: true,//是否显示取消按钮
  619 + cancelText:"我在想想",//默认是“取消”
  620 + confirmText:"继续下单",//默认是“确定”
  621 + success: function (res) {
  622 + if (res.cancel) {
  623 + //点击取消,默认隐藏弹框
  624 + } else {
  625 + th.setData({agree_no_ref:1})
  626 + th.submitForm_next(t)
  627 + }
  628 + },
  629 + })
  630 +
  631 + }else{
  632 + this.submitForm_next(t);
  633 + }
  634 + },
  635 +
623 636 useCoupon: function() {
624 637 if (this.data.order.couponNum <= 0) {
625 638 //return t.showWarning("无可用优惠券");
... ... @@ -828,5 +841,11 @@ Page({
828 841 buycard:function(){
829 842 getApp().goto("/pages/user/plus/plus");
830 843 getApp().globalData.plus_buy_back=1;
831   - }
  844 + },
  845 +
  846 + switchChange:function (e) {
  847 + console.log(e,111);
  848 + this.setData({agree_no_ref:e.detail.value});
  849 + }
  850 +
832 851 });
... ...
packageC/pages/presell/cart/cart2_pre.wxml
1   -<wxs module="filters" src="../../../utils/filter.wxs"></wxs>
  1 +<wxs module="filters" src="../../../../utils/filter.wxs"></wxs>
2 2 <form bindsubmit="submitForm">
3 3 <view class="container">
4 4 <view class="tab-container" wx:if="{{act.presell_type==1}}">
... ... @@ -99,7 +99,6 @@
99 99 </view>
100 100 </view>
101 101 </block>
102   -
103 102 <!--阶梯团是不显示的
104 103 <block wx:if="{{kt_type!=3 || is_normal==1 }}">
105 104 <view class="use-item" hidden='{{bn_exp_type==1}}'>
... ... @@ -109,7 +108,6 @@
109 108 </picker>
110 109 </view>
111 110 </block>-->
112   -
113 111 </view>
114 112  
115 113  
... ... @@ -122,6 +120,14 @@
122 120 </view>
123 121 </block>
124 122  
  123 + <!-- 不下单的时候退款定金 -->
  124 + <view class="information bdr14" style="margin-bottom: 20rpx" wx:if="{{!act.is_refundmoney}}">
  125 + <view wx:if="{{act.presell_type==0}}" class="item ai-center">
  126 + <view >我同意预售商品不退定金</view>
  127 + <switch style="transform: scale(0.7);position: relative; right: -24rpx" type="switch" checked="{{agree_no_ref?true:false}}" bindchange="switchChange"/>
  128 + </view>
  129 + </view>
  130 +
125 131 <view class="information bdr14">
126 132 <!-----使用余额------>
127 133 <view class="set-mes" wx:if="{{userinfo.user_money>0 && yuer>0}}">
... ... @@ -130,7 +136,7 @@
130 136 <view class="yu_er">使用余额 :¥{{yuer}} </view>
131 137 </view>
132 138 </view>
133   - <view class="item" wx:if="{{kt_type<3 || is_normal==1}}">
  139 + <view class="item" wx:if="{{act.presell_type==1}}">
134 140 <view>商品金额</view>
135 141 <view class="co-red">¥ {{formData.all_price}}元</view>
136 142 </view>
... ...
packageC/pages/presell/cart/cart2_pre.wxss
... ... @@ -245,8 +245,8 @@ margin:auto; */
245 245 .information .item {
246 246 display: flex;
247 247 justify-content: space-between;
248   - height: 60rpx;
249   - line-height: 60rpx;
  248 + height: 80rpx;
  249 + line-height: 80rpx;
250 250 font-size: 26rpx;
251 251 color: #777;
252 252 }
... ...
packageC/pages/presell/cart/zh_calculate.js deleted
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   -}
packageC/pages/presell/goodsInfo/g_filter.wxs
... ... @@ -97,10 +97,24 @@ var g_filters = {
97 97 } else {
98 98 return value.toFixed(0);
99 99 };
100   - },
  100 + },
  101 +
  102 + //跳转的接口
  103 + get_goods_url:function(item){
  104 +
  105 + console.log(item,111)
  106 + var url1="/pages/goods/goodsInfo/goodsInfo?goods_id="+item.goods_id
  107 + if(item.prom_type==8){
  108 + url1="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&pre_id="+item.id
  109 + }
  110 + return url1;
  111 + }
  112 +
  113 +
101 114 }
102 115 module.exports = {
103 116 is_has_rank:g_filters.is_has_rank,
104 117 get_card_price:g_filters.get_card_price,
105   - num:g_filters.num,
  118 + num:g_filters.num,
  119 + get_goods_url:g_filters.get_goods_url,
106 120 }
107 121 \ No newline at end of file
... ...
packageC/pages/presell/goodsInfo/goodsInfo.js
1 1 var ut = require("../../../../utils/util.js"),
2 2 e = require("../../../../utils/common.js"),
3 3 a = require("../../../../utils/wxParse/wxParse.js"),
4   - s = getApp(),app=s,
  4 + s = getApp(), app = s,
5 5 i = s.request,
6 6 rq = i,
7 7 oo = s.globalData,
... ... @@ -247,14 +247,15 @@ Page({
247 247 fir_goods: null,
248 248  
249 249 share_hidden: false,
250   - pre_arr:null,
  250 + pre_arr: null,
251 251 },
252 252  
253 253 //------初始化加载----------
254 254 onLoad: function (t) {
255   - var ee = this, that = ee, th = ee,
256   - pre_id=t.pre_id,
257   - gid=t.goods_id,
  255 + var ee = this, that = ee, th = ee,
  256 + pre_id = t.pre_id,
  257 + gid = t.goods_id,
  258 + presell_id = t.prom_id,
258 259 first_leader = t.first_leader,
259 260 room_id = t.room_id,
260 261 room_user_share = t.room_user_share; //如果是会员分享带有room_id的话,那么接下来会员分享就不传room_id
... ... @@ -305,8 +306,9 @@ Page({
305 306 }
306 307 }
307 308  
308   - this.data.gid=gid;
309   - this.data.pre_id=pre_id;
  309 + this.setData({
  310 + gid:gid,pre_id:pre_id,presell_id:presell_id
  311 + })
310 312  
311 313 if (first_leader) {
312 314 console.log("log---".first_leader);
... ... @@ -425,17 +427,17 @@ Page({
425 427 },
426 428  
427 429  
428   - //--- 设置一下默认库存的数量 ----
429   - set_def_storage(ee) {
430   - var that = this, th = this;
431   - that.data.fir_def_store = ee;
432   - that.setData({
433   - def_pick_store: ee,
434   - sto_sele_name: ee.pickup_name,
435   - sto_sele_id: ee.pickup_id,
436   - sto_sele_distr: ee.distr_type
437   - })
438   - },
  430 + //--- 设置一下默认库存的数量 ----
  431 + set_def_storage(ee) {
  432 + var that = this, th = this;
  433 + that.data.fir_def_store = ee;
  434 + that.setData({
  435 + def_pick_store: ee,
  436 + sto_sele_name: ee.pickup_name,
  437 + sto_sele_id: ee.pickup_id,
  438 + sto_sele_distr: ee.distr_type
  439 + })
  440 + },
439 441  
440 442  
441 443 //------------程序初始化入口-------------
... ... @@ -590,7 +592,7 @@ Page({
590 592 //-- 如果是预览图片,页面不重新更新 --
591 593 var show_prew_img = this.data.show_prew_img
592 594 if (show_prew_img) {
593   - this.data.show_prew_img = 0; return false;
  595 + this.data.show_prew_img = 0; return false;
594 596 }
595 597  
596 598 //优惠券要实时更新
... ... @@ -611,202 +613,204 @@ Page({
611 613 }, 300)
612 614  
613 615 this.data.is_timer = 1;
614   - var ee = this,gid = this.data.gid,i = getApp().request;
  616 + var ee = this, gid = this.data.gid, i = getApp().request;
615 617  
616 618 this.wait_for_store_config();
617 619 this.get_pre_prom(function () {
618   - i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, {
619   - failRollback: !0,
620   - success: function (t) {
621   - console.log(t);
622   - if (t.data.code == 0) {
623   - if (t.data.data.is_on_sale != 1) {
624   - wx.showModal({
625   - title: '商品已经下架',
626   - showCancel: !1,
627   - complete: function () {
628   - wx.navigateBack();
629   - }
630   - });
631   - }
632   - var timestamp = Date.parse(new Date());
633   - timestamp = timestamp / 1000;
634   - if (t.data.data.on_time > timestamp) {
635   - wx.showModal({
636   - title: '商品还未上架',
637   - showCancel: !1,
638   - complete: function () {
639   - wx.navigateBack();
640   - }
641   - });
642   - }
  620 + i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, {
  621 + failRollback: !0,
  622 + success: function (t) {
  623 + console.log(t);
  624 + if (t.data.code == 0) {
  625 + if (t.data.data.is_on_sale != 1) {
  626 + wx.showModal({
  627 + title: '商品已经下架',
  628 + showCancel: !1,
  629 + complete: function () {
  630 + wx.navigateBack();
  631 + }
  632 + });
  633 + }
  634 + var timestamp = Date.parse(new Date());
  635 + timestamp = timestamp / 1000;
  636 + if (t.data.data.on_time > timestamp) {
  637 + wx.showModal({
  638 + title: '商品还未上架',
  639 + showCancel: !1,
  640 + complete: function () {
  641 + wx.navigateBack();
  642 + }
  643 + });
  644 + }
643 645  
644   - if (t.data.data.down_time > 0) {
645   - if (t.data.data.down_time < timestamp) {
646   - wx.showModal({
647   - title: '商品已经到期下架',
648   - showCancel: !1,
649   - complete: function () {
650   - wx.navigateBack();
651   - }
652   - });
653   - }
654   - }
655   - //动态获取商品名称
656   - wx.setNavigationBarTitle({
657   - title: t.data.data.goods_name,
658   - });
  646 + if (t.data.data.down_time > 0) {
  647 + if (t.data.data.down_time < timestamp) {
  648 + wx.showModal({
  649 + title: '商品已经到期下架',
  650 + showCancel: !1,
  651 + complete: function () {
  652 + wx.navigateBack();
  653 + }
  654 + });
  655 + }
  656 + }
  657 + //动态获取商品名称
  658 + wx.setNavigationBarTitle({
  659 + title: t.data.data.goods_name,
  660 + });
659 661  
660   - //-- 把商品的赋值 --
661   - ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data));
  662 + //-- 把商品的赋值 --
  663 + ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data));
  664 + ee.data.sele_g_id=t.data.data.goods_id;
  665 + ee.data.sele_g=t.data.data;
662 666  
663   - //获取用户的默认门店
664   - getApp().get_user_store(function (e) {
665   - if (!e) {
666   - th.data.fir_def_store = {}; //赋值空对象
667   - return false;
668   - }
669   - var ee = JSON.parse(JSON.stringify(e));
  667 + //获取用户的默认门店
  668 + getApp().get_user_store(function (e) {
  669 + if (!e) {
  670 + th.data.fir_def_store = {}; //赋值空对象
  671 + return false;
  672 + }
  673 + var ee = JSON.parse(JSON.stringify(e));
  674 +
  675 + if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type;
  676 + //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对--
  677 + if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) {
  678 + ee.is_no_dis = 1;
  679 + }
670 680  
671   - if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type;
672   - //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对--
673   - if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) {
674   - ee.is_no_dis = 1;
  681 + var appd = getApp().globalData;
  682 + var w_time = setInterval(function () {
  683 + if (that.data.is_get_local_ok == 0) return false;
  684 + clearInterval(w_time);
  685 + var e = JSON.parse(JSON.stringify(ee));
  686 +
  687 + //如果有开启近距离的话,同时距离优不一样了
  688 + if (that.data.lat != null) {
  689 + //如果经纬度有变化的话
  690 + if (e && appd.lat == that.data.lat && appd.lon == that.data.lon && e.distance > 0) {
  691 + that.set_def_storage(e);
  692 +
  693 + } else {
  694 + //要用接口是获取距离,js的计算不准
  695 + getApp().request.promiseGet("/api/weshop/pickup/list", {
  696 + data: {
  697 + store_id: os.stoid,
  698 + pickup_id: e.pickup_id,
  699 + lat: th.data.lat,
  700 + lon: th.data.lon
  701 + },
  702 + }).then(res => {
  703 + if (res.data.code == 0) {
  704 + e = res.data.data.pageData[0];
  705 + if (e) {
  706 + e.is_no_dis = ee.is_no_dis;
  707 + appd.pk_store = e;
  708 + that.set_def_storage(e);
675 709 }
676 710  
677   - var appd = getApp().globalData;
678   - var w_time = setInterval(function () {
679   - if (that.data.is_get_local_ok == 0) return false;
680   - clearInterval(w_time);
681   - var e = JSON.parse(JSON.stringify(ee));
682   -
683   - //如果有开启近距离的话,同时距离优不一样了
684   - if (that.data.lat != null) {
685   - //如果经纬度有变化的话
686   - if (e && appd.lat == that.data.lat && appd.lon == that.data.lon && e.distance > 0) {
687   - that.set_def_storage(e);
688   -
689   - } else {
690   - //要用接口是获取距离,js的计算不准
691   - getApp().request.promiseGet("/api/weshop/pickup/list", {
692   - data: {
693   - store_id: os.stoid,
694   - pickup_id: e.pickup_id,
695   - lat: th.data.lat,
696   - lon: th.data.lon
697   - },
698   - }).then(res => {
699   - if (res.data.code == 0) {
700   - e = res.data.data.pageData[0];
701   - if (e) {
702   - e.is_no_dis = ee.is_no_dis;
703   - appd.pk_store = e;
704   - that.set_def_storage(e);
705   - }
706   -
707   - }
708   - })
709   - }
710   - appd.lat = that.data.lat;
711   - appd.lon = that.data.lon;
712   -
713   - } else {
714   - if (e) {
715   - e.distance = null;
716   -
717   - that.set_def_storage(e);
718   - }
719   - }
720   - }, 500)
721   - });
  711 + }
  712 + })
  713 + }
  714 + appd.lat = that.data.lat;
  715 + appd.lon = that.data.lon;
722 716  
  717 + } else {
  718 + if (e) {
  719 + e.distance = null;
723 720  
  721 + that.set_def_storage(e);
  722 + }
  723 + }
  724 + }, 500)
  725 + });
724 726  
725   - t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss');
726 727  
727   - var cur_price = t.data.data.shop_price;
728   - if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) {
729   - var cfile = getApp().globalData.userInfo.card_field;
730   - if (t.data.data[cfile]) {
731   - cur_price = t.data.data[cfile];
732   - }
733   - }
734   - var txt = (cur_price / t.data.data.market_price * 10).toFixed(2).toString();
735   - txt = parseFloat(txt);
736 728  
737   - t.data.data['disc'] = txt;
738   - if (t.data.data.original_img.indexOf(o.imghost) == -1)
739   - t.data.data.original_img = o.imghost + t.data.data.original_img;
  729 + t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss');
  730 +
  731 + var cur_price = t.data.data.shop_price;
  732 + if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) {
  733 + var cfile = getApp().globalData.userInfo.card_field;
  734 + if (t.data.data[cfile]) {
  735 + cur_price = t.data.data[cfile];
  736 + }
  737 + }
  738 + var txt = (cur_price / t.data.data.market_price * 10).toFixed(2).toString();
  739 + txt = parseFloat(txt);
740 740  
741   - if (t.data.data.goods_content == null) t.data.data.goods_content = "";
  741 + t.data.data['disc'] = txt;
  742 + if (t.data.data.original_img.indexOf(o.imghost) == -1)
  743 + t.data.data.original_img = o.imghost + t.data.data.original_img;
742 744  
743   - //-----商品详情---
744   - if (!t.data.data.goods_content) t.data.data.goods_content = " ";
745   - a.wxParse("content", "html", t.data.data.goods_content, ee, 6);
746   - e.wxParseAddFullImageUrl(ee, "content");
  745 + if (t.data.data.goods_content == null) t.data.data.goods_content = "";
747 746  
748   - ee.setData({
749   - data: t.data.data,
750   - sele_g: t.data.data,
751   - userInfo: getApp().globalData.userInfo
752   - });
  747 + //-----商品详情---
  748 + if (!t.data.data.goods_content) t.data.data.goods_content = " ";
  749 + a.wxParse("content", "html", t.data.data.goods_content, ee, 6);
  750 + e.wxParseAddFullImageUrl(ee, "content");
753 751  
754   - //获取门店
755   - ee.get_sto();
756   - ee.get_sku(o.stoid, t.data.data, gid);
757   -
758   -
759   - ee.data.g_buy_num = new Map();
760   -
761   - if (ee.data.cat_name == '') {
762   - //过去国别,分类,品牌的名称
763   - i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, {
764   - success: function (t) {
765   - var dd = t.data.data;
766   - if (t.data.code == 0) {
767   - th.setData({
768   - cat_name: dd.name
769   - });
770   - }
771   - }
772   - });
773   - //过去国别,分类,品牌的名称
774   - i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, {
775   - success: function (t) {
776   - var dd = t.data.data;
777   - if (t.data.code == 0) {
778   - th.setData({
779   - brand_name: dd.name
780   - });
781   - }
782   - }
783   - });
784   - //过去国别,分类,品牌的名称
785   - i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, {
786   - success: function (t) {
787   - var dd = t.data.data;
788   - if (t.data.code == 0) {
789   - th.setData({
790   - nation_name: dd.name
791   - });
792   - }
793   - }
794   - });
795   - }
  752 + ee.setData({
  753 + data: t.data.data,
  754 + sele_g: t.data.data,
  755 + userInfo: getApp().globalData.userInfo
  756 + });
796 757  
  758 + //获取门店
  759 + ee.get_sto();
  760 + ee.get_sku(o.stoid, t.data.data, gid);
  761 +
  762 +
  763 + ee.data.g_buy_num = new Map();
  764 +
  765 + if (ee.data.cat_name == '') {
  766 + //过去国别,分类,品牌的名称
  767 + i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, {
  768 + success: function (t) {
  769 + var dd = t.data.data;
  770 + if (t.data.code == 0) {
  771 + th.setData({
  772 + cat_name: dd.name
  773 + });
  774 + }
797 775 }
798   - else {
799   - wx.showModal({
800   - title: t.data.msg,
801   - showCancel: !1,
802   - complete: function () {
803   - wx.navigateBack();
804   - }
  776 + });
  777 + //过去国别,分类,品牌的名称
  778 + i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, {
  779 + success: function (t) {
  780 + var dd = t.data.data;
  781 + if (t.data.code == 0) {
  782 + th.setData({
  783 + brand_name: dd.name
  784 + });
  785 + }
  786 + }
  787 + });
  788 + //过去国别,分类,品牌的名称
  789 + i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, {
  790 + success: function (t) {
  791 + var dd = t.data.data;
  792 + if (t.data.code == 0) {
  793 + th.setData({
  794 + nation_name: dd.name
805 795 });
  796 + }
806 797 }
  798 + });
807 799 }
808   - });
809   - ee.data.enterAddressPage && (this.data.enterAddressPage = !1);
  800 +
  801 + }
  802 + else {
  803 + wx.showModal({
  804 + title: t.data.msg,
  805 + showCancel: !1,
  806 + complete: function () {
  807 + wx.navigateBack();
  808 + }
  809 + });
  810 + }
  811 + }
  812 + });
  813 + ee.data.enterAddressPage && (this.data.enterAddressPage = !1);
810 814 })
811 815  
812 816  
... ... @@ -931,12 +935,12 @@ Page({
931 935 var th = this;
932 936 var ind = t.currentTarget.dataset.openSpecModal_ind;
933 937 if (!ind) ind = t.currentTarget.dataset.openspecmodal_ind;
934   - th.setData({
935   - open_ind_store: ind
  938 + th.setData({
  939 + open_ind_store: ind
936 940 });
937   -
  941 +
938 942 th.add_cart_func(t);
939   -
  943 +
940 944 },
941 945  
942 946  
... ... @@ -951,7 +955,7 @@ Page({
951 955 return s.my_warnning("还未登录!", 0, this);
952 956 }
953 957  
954   - var e = this,th = e, o = this.data.sele_g,a = o.goods_id;
  958 + var e = this, th = e, o = this.data.sele_g, a = o.goods_id;
955 959 //----------添加到购物车时,要判断限购数量,--------
956 960 e.get_buy_num(o, function (ee) {
957 961 //---判断商品是否超出限购---
... ... @@ -994,7 +998,7 @@ Page({
994 998 goods_name: o.goods_name,
995 999 goods_sn: o.goods_sn,
996 1000 sku: o.sku,
997   - presell_list_id:th.data.presellList.id,
  1001 + presell_list_id: th.data.presellList.id,
998 1002 };
999 1003  
1000 1004 //---是不是从收藏夹出来的---
... ... @@ -1011,7 +1015,6 @@ Page({
1011 1015 }
1012 1016  
1013 1017 //让商品带上房间号
1014   - //让商品带上房间号
1015 1018 if (th.data.sys_switch.is_skuroom_id == 1) {
1016 1019 if (th.data.data.goods_id == getApp().globalData.room_goods_id) {
1017 1020 newd.room_id = getApp().globalData.room_id;
... ... @@ -1020,10 +1023,6 @@ Page({
1020 1023 if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id;
1021 1024 }
1022 1025  
1023   - //如果是积分够,is_integral_normal就要有积分购普通购买字段
1024   - if (o.prom_type == 4) {
1025   - newd.is_integral_normal = 1;
1026   - }
1027 1026  
1028 1027 //如果有线下取价
1029 1028 if (o.offline_price) {
... ... @@ -1031,16 +1030,16 @@ Page({
1031 1030 newd.pricing_type = o.pricing_type;
1032 1031 }
1033 1032  
1034   - newd.goods_price = th.data.prom_price;
1035   - newd.member_goods_price = th.data.prom_price,
1036   - newd.prom_type = 8;
1037   - newd.prom_id = o.prom_id;
  1033 + newd.goods_price = th.data.prom_price;
  1034 + newd.member_goods_price = th.data.prom_price,
  1035 + newd.prom_type = 8;
  1036 + newd.prom_id = o.prom_id;
  1037 +
  1038 + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
  1039 + if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
  1040 + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
1038 1041  
1039   - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
1040   - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
1041   - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
1042 1042  
1043   -
1044 1043 })
1045 1044 },
1046 1045  
... ... @@ -1128,7 +1127,7 @@ Page({
1128 1127 }
1129 1128 })
1130 1129  
1131   - }else {
  1130 + } else {
1132 1131 newd['pick_name'] = th.data.sto_sele_name;
1133 1132 newd['pick_dis'] = th.data.sto_sele_distr;
1134 1133 th.buyNow(newd);
... ... @@ -1137,18 +1136,18 @@ Page({
1137 1136  
1138 1137 //----------立即购买-----------
1139 1138 buyNow: function (e) {
1140   -
  1139 +
1141 1140 this.setData({
1142 1141 openSpecModal: 0,
1143 1142 openSpecModal_inte: 0,
1144 1143 openSpecModal_inte_normal: 0,
1145 1144 openSpecModal_pt: 0,
1146 1145 })
1147   -
1148   - app.set_b_now(e);
  1146 +
  1147 + app.set_b_now(e);
1149 1148 getApp().goto("/packageC/pages/presell/cart/cart2_pre");
1150   -
1151   -
  1149 +
  1150 +
1152 1151 },
1153 1152  
1154 1153 //----------增加购买数量-----------
... ... @@ -1164,20 +1163,6 @@ Page({
1164 1163 this.checkCartNum(Number(t.detail.value));
1165 1164 },
1166 1165  
1167   - //----------增加购买数量-----------
1168   - addCartNum_inte: function (t) {
1169   - this.checkCartNum_inte(this.data.goodsInputNum + 1);
1170   - },
1171   - //----------减少购买数量-----------
1172   - subCartNum_inte: function (t) {
1173   - this.checkCartNum_inte(this.data.goodsInputNum - 1);
1174   - },
1175   - //----------输入框输入购买数量-----------
1176   - inputCartNum_inte: function (t) {
1177   - this.checkCartNum_inte(Number(t.detail.value));
1178   - },
1179   -
1180   -
1181 1166 //------检查数量是不是超出限购------
1182 1167 checkCartNum: function (t) {
1183 1168 var th = this;
... ... @@ -1214,18 +1199,7 @@ Page({
1214 1199 }
1215 1200 }
1216 1201  
1217   -
1218   -
1219 1202 var e = th.data.sele_g.store_count;
1220   - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
1221   - if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
1222   - if (!th.data.def_pick_store) {
1223   - wx.showModal({ title: '请选择门店', });
1224   - return false;
1225   - } else {
1226   - e = th.data.def_pick_store.CanOutQty;
1227   - }
1228   - }
1229 1203 if (!e) e = 0;
1230 1204 //库存不足,不增加
1231 1205 if (e < t) {
... ... @@ -1235,90 +1209,11 @@ Page({
1235 1209 }
1236 1210 t > e || 0 == e ? t = e : t < 1 && (t = 1);
1237 1211 th.setData({ goodsInputNum: t });
1238   - th.is_show_more_buy();
  1212 + //th.is_show_more_buy();
1239 1213  
1240 1214 })
1241 1215 },
1242 1216  
1243   - //----- 检查一下积分购的限购之类的问题 -----
1244   - checkCartNum_inte: function (t) {
1245   - var th = this;
1246   - this.get_buy_num(this.data.data, async function () {
1247   -
1248   - //--判断商品是否超出限购--
1249   - if (th.data.g_buy_num != null && th.data.data.viplimited > 0) {
1250   -
1251   - var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id);
1252   -
1253   - if (t + gd_buy_num > th.data.sele_g.viplimited) {
1254   - wx.showModal({
1255   - title: '超出商品限购',
1256   - });
1257   -
1258   - var num = th.data.sele_g.viplimited - gd_buy_num;
1259   - if (num < 0) num = 0;
1260   - th.setData({ goodsInputNum: num })
1261   - return false;
1262   - }
1263   - }
1264   -
1265   - //--判断商品是否超出活动限购--
1266   - if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) {
1267   - if (t + th.data.prom_buy_num > th.data.prom_buy_limit) {
1268   - wx.showModal({
1269   - title: '超出商品活动限购',
1270   - });
1271   -
1272   - var num = th.data.prom_buy_limit - th.data.prom_buy_num;
1273   - if (num < 0) num = 0;
1274   - th.setData({ goodsInputNum: num })
1275   - return false;
1276   - }
1277   - }
1278   -
1279   - if (th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) {
1280   - var redis_num = 0;
1281   - //------判断活动是否抢光-----
1282   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
1283   - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, {
1284   - 1: 1
1285   - }).then(res => {
1286   - redis_num = res.data.data;
1287   - });
1288   -
1289   - if (t > redis_num) {
1290   - wx.showModal({
1291   - title: '超出商品活动库存',
1292   - });
1293   - th.setData({ goodsInputNum: redis_num })
1294   - return false;
1295   - }
1296   -
1297   - }
1298   -
1299   - var e = th.data.sele_g.store_count;
1300   - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
1301   - if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
1302   - if (!th.data.def_pick_store) {
1303   - wx.showModal({ title: '请选择门店', });
1304   - return false;
1305   - } else {
1306   - e = th.data.def_pick_store.CanOutQty;
1307   - }
1308   - }
1309   - if (!e) e = 0;
1310   - //库存不足,不增加
1311   - if (e < t) {
1312   - wx.showModal({ title: '库存不足', });
1313   - if (e < 0) e = 0;
1314   - th.setData({ goodsInputNum: e }); return false;
1315   - }
1316   - t > e || 0 == e ? t = e : t < 1 && (t = 1);
1317   - th.setData({ goodsInputNum: t });
1318   - })
1319   - },
1320   -
1321   -
1322 1217 closeSpecModal: function () {
1323 1218 if (this.data.openSpecModal_pt && this.data.is_normal) {
1324 1219 this.get_sto();
... ... @@ -1722,8 +1617,8 @@ Page({
1722 1617 is_on_sale: 1,
1723 1618 pageSize: 500,
1724 1619 orderField: 'sort',
1725   - prom_id:tt.data.presellForm.id,
1726   - prom_type:8,
  1620 + prom_id: tt.data.presellForm.id,
  1621 + prom_type: 8,
1727 1622 }
1728 1623 }).then(res => {
1729 1624 var e = res;
... ... @@ -1852,65 +1747,38 @@ Page({
1852 1747  
1853 1748 //选择了不同的规格的时候要判断是不是有活动正在进行中
1854 1749 async sele_spec_chech_activity() {
1855   - //---如果是活动的时候---
1856   - var prom = null, goodsinfo = this.data.sele_g, th = this;
1857   - if (goodsinfo.prom_type == 1) {
1858   - await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {
1859   - }).then(res => {
1860   - if (res.data.code == 0) {
1861   - prom = res.data.data;
1862   - }
1863   - })
1864   - }
1865   - if (goodsinfo.prom_type == 6) {
1866   - await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {
1867   - }).then(res => {
1868   - if (res.data.code == 0) {
1869   - prom = res.data.data;
1870   - }
1871   - })
1872   - }
1873   -
1874   - if (goodsinfo.prom_type == 4) {
1875   - await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {
1876   - }).then(res => {
1877   - if (res.data.code == 0) {
1878   - prom = res.data.data;
1879   - }
1880   - })
1881   - }
1882   -
1883   - //----------如果有活动,并且在进行中,就不计算线下库存---------------
1884   - var now = ut.gettimestamp();
1885   - if (prom) {
1886   - if (prom.is_end == 0 && prom.end_time > now && prom.start_time < now) {
1887   - th.setData({
1888   - prom_type: goodsinfo.prom_type,
1889   - prom_price: prom.price,
1890   - prom_buy_limit: prom.buy_limit,
1891   - prom_end_time: prom.end_time,
1892   - prom_start_time: prom.start_time,
1893   - prom_st: 1,
1894   - })
1895   - return false;
  1750 + var prom = null, goodsinfo = this.data.sele_g, th = this;
  1751 +
  1752 + var all_pre_goods=th.data.all_pre_goods;
  1753 + if(all_pre_goods){
  1754 + var userInfo = getApp().globalData.userInfo;
  1755 + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: th.data.gid };
  1756 + if (userInfo) {
  1757 + pre_data.user_id = userInfo.user_id;
  1758 + }
  1759 + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
  1760 + data: pre_data,
  1761 + }).then(e => {
  1762 + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
  1763 + all_pre_goods=e.data.data.pageData;
  1764 + th.data.all_pre_goods=e.data.data.pageData;
  1765 + }
  1766 + })
1896 1767 }
1897   - }
1898   - //---设置普通商品---
1899   - th.setData({
1900   - prom_type: 0,
1901   - prom_price: null,
1902   - prom_buy_limit: null,
1903   - prom_end_time: null,
1904   - prom_start_time: null,
1905   - prom_st: null,
1906   - })
1907 1768  
  1769 +
  1770 + var idx=all_pre_goods.findIndex(function (ele) {
  1771 + return ele.goods_id==goodsinfo.goods_id;
  1772 + })
  1773 + var pre_arr =all_pre_goods[idx];
  1774 + th.setData({ pre_arr: pre_arr })
  1775 + th.data.prom_buy_limit=pre_arr.vip_butyqty;
1908 1776 },
1909 1777  
1910 1778  
1911 1779 //---------拿出门店分类和门店------------
1912 1780 get_sto(e) {
1913   - var th = this,is_normal = e;
  1781 + var th = this, is_normal = e;
1914 1782  
1915 1783 if (e == 1) {
1916 1784 th.setData({ is_normal: 1 })
... ... @@ -2854,10 +2722,7 @@ Page({
2854 2722 };
2855 2723  
2856 2724 //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团
2857   - var type = this.data.prom_type;
2858   - if (type == 6) type = 2;
2859   - if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3;
2860   -
  2725 + var type = 8;
2861 2726 wx.showLoading({
2862 2727 title: '生成中...',
2863 2728 })
... ... @@ -2949,12 +2814,8 @@ Page({
2949 2814 context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit);
2950 2815 }
2951 2816  
2952   - var share_title = th.data.data.goods_name;
2953   - if (th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) {
2954   - share_title = th.data.prom_act.share_title;
2955   - if (!share_title) share_title = th.data.prom_act.title;
2956   - if (th.data.prom_type == 4) share_title = th.data.prom_act.name;
2957   - }
  2817 + var share_title = th.data.presellForm.share_title;
  2818 + share_title ? share_title : th.data.data.goods_name;
2958 2819  
2959 2820 //---产品名称---
2960 2821 //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
... ... @@ -2962,34 +2823,34 @@ Page({
2962 2823 context.setFillStyle("black");
2963 2824 context.setFontSize(21.3 * unit)
2964 2825 th.draw_Text(context, share_title,
2965   - 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit);
  2826 + 80 * unit, 200 * unit, 200 * unit, 279 * unit, unit);
2966 2827  
2967 2828 //------产品的价格-------
2968   - context.setFontSize(23 * unit)
  2829 + context.setFontSize(22 * unit)
2969 2830 context.setFillStyle("red")
2970 2831  
2971 2832  
2972   - var pri0 = th.data.data.shop_price;
2973   - if (th.data.prom_act)
2974   - pri0 = th.data.prom_act.price;
  2833 + var pri0 = th.data.presellList.presell_money;
  2834 + // if (th.data.prom_act)
  2835 + // pri0 = th.data.prom_act.price;
2975 2836 pri0 = parseFloat(pri0).toFixed(2);
2976 2837 var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25;
2977 2838 context.fillText("¥", wd1 - 15, 185 * unit);
2978   - context.setFontSize(31 * unit)
  2839 + context.setFontSize(22 * unit)
2979 2840 context.fillText(pri0, wd1, 185 * unit);
2980 2841  
2981 2842 //---市场价划掉---
2982   - context.setFillStyle("gray")
  2843 + context.setFillStyle("red")
2983 2844 context.setFontSize(22 * unit)
2984 2845 pri0 = "¥" + th.data.data.market_price.toFixed(2);
2985 2846 var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25;
2986   - context.fillText(pri0, wd2, 213 * unit);
  2847 + context.fillText('定金', wd2, 213 * unit);
2987 2848  
2988   - context.setStrokeStyle('gray');
2989   - context.setLineWidth(1 * unit);
2990   - context.moveTo(wd2 - 5, 206 * unit);
2991   - context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit);
2992   - context.stroke();
  2849 + // context.setStrokeStyle('gray');
  2850 + // context.setLineWidth(1 * unit);
  2851 + // context.moveTo(wd2 - 5, 206 * unit);
  2852 + // context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit);
  2853 + // context.stroke();
2993 2854  
2994 2855 } else {
2995 2856 context.setFillStyle("black");
... ... @@ -3009,227 +2870,82 @@ Page({
3009 2870 context.fillText(text, 38 * unit, 235 * unit);
3010 2871  
3011 2872 }
3012   -
  2873 + console.log(th.data.share_goods_img);
  2874 + let share_goods_img=th.data.presellForm.share_img;
  2875 + share_goods_img?share_goods_img:th.data.data.share_goods_img;
3013 2876 //---中间大图---
3014 2877 context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit);
3015   - //-------大图后面就不一样了-----------
3016   - switch (type) {
3017   - case 0: //普通商品的展示
3018   - case 4:
3019   - //中间的几个字
3020   - if (th.data.poster && parseInt(th.data.poster.style) == 2) {
3021   - if (parseInt(th.data.poster.show_quality)) {
3022   - var g_path = "../../../../images/share/s_gou.png";
3023   - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
3024   - context.setFillStyle("red")
3025   - context.setFontSize(18 * unit)
3026   - context.fillText("正品保证", 84 * unit, 690 * unit);
3027   -
3028   - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
3029   - context.setFillStyle("red")
3030   - context.setFontSize(18 * unit)
3031   - context.fillText("纯实体店", 246 * unit, 690 * unit);
3032   -
3033   - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
3034   - context.setFillStyle("red")
3035   - context.setFontSize(18 * unit)
3036   - context.fillText("官方验证", 420 * unit, 690 * unit);
3037   - }
3038   -
3039   - } else {
3040   - var g_path = "../../../../images/share/s_gou.png";
3041   - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
3042   - context.setFillStyle("red")
3043   - context.setFontSize(18 * unit)
3044   - context.fillText("正品保证", 84 * unit, 690 * unit);
3045   -
3046   - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
3047   - context.setFillStyle("red")
3048   - context.setFontSize(18 * unit)
3049   - context.fillText("纯实体店", 246 * unit, 690 * unit);
3050   -
3051   - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
3052   - context.setFillStyle("red")
3053   - context.setFontSize(18 * unit)
3054   - context.fillText("官方验证", 420 * unit, 690 * unit);
3055   - }
3056   -
3057   -
3058   - //---画线---
3059   - context.setLineWidth(1 * unit)
3060   - context.moveTo(32 * unit, 710 * unit)
3061   - context.lineTo(520 * unit, 710 * unit)
3062   - context.stroke();
3063   -
3064   - //---文字---
3065   - context.setFillStyle("black")
3066   - context.setFontSize(22 * unit)
3067   -
3068   - if (type == 0) {
3069   - // 原来start --->
3070   - context.setFontSize(24 * unit)
3071   - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit);
3072   -
3073   - context.setFontSize(22 * unit)
3074   - context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit);
3075   - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit);
3076   -
3077   - } else {
3078   - context.setFontSize(24 * unit)
3079   - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit);
3080   - context.setFontSize(22 * unit)
3081   - context.fillText("长按识别二维码", 40 * unit, 806 * unit);
3082   - context.fillText("立即开始兑换", 40 * unit, 846 * unit);
3083   - }
3084   -
3085   - //---二维吗图---
3086   - //-- 自定义海报 --
3087   - if (th.data.poster) {
3088   - var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
3089   - var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
3090   - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
3091   - } else {
3092   - //---二维吗图---
3093   - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
3094   - }
3095   -
3096   - break;
3097   - case 1: //秒杀商品的展示
3098   - //---画线---
3099   - context.setLineWidth(1 * unit)
3100   - context.moveTo(32 * unit, 670 * unit)
3101   - context.lineTo(520 * unit, 670 * unit)
3102   - context.stroke();
3103   -
3104   - //画秒杀的图片
3105   - var miaos_path = '../../../../images/share/miao_share.png';
3106   - context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit);
3107   -
3108   - context.setFillStyle("black")
3109   - context.setFontSize(24 * unit)
3110   - context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit);
3111   - //---文字---
3112   - context.setFontSize(22 * unit)
3113   - context.setFillStyle("black")
3114   - context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit);
3115   - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit);
3116   -
3117   -
3118   - //---二维吗图---
3119   - //-- 自定义海报 --
3120   - if (th.data.poster) {
3121   - var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
3122   - var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
3123   - context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit);
3124   - } else {
3125   - //---二维吗图---
3126   - context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit);
3127   - }
3128   - break;
3129   -
3130   - case 2: //会员团和商家团的展示
3131   - //---画线---
3132   - context.setLineWidth(1 * unit)
3133   - context.moveTo(32 * unit, 670 * unit)
3134   - context.lineTo(520 * unit, 670 * unit)
3135   - context.stroke();
3136   - //---文字---
3137 2878  
3138   - context.setFillStyle("black")
3139   - context.setFontSize(24 * unit)
3140   - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit);
3141   -
3142   - //绘制成团图片
3143   - var ct_img = "../../../../images/share/ct_num.png";
3144   - context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit);
3145   - var ct_num = th.data.prom_act.ct_num;
3146   - context.setFontSize(14 * unit)
3147   - context.font = 'normal';
  2879 + //预售
  2880 + /* if (th.data.poster && parseInt(th.data.poster.style) == 2) {
  2881 + if (parseInt(th.data.poster.show_quality)) {
  2882 + var g_path = "../../../../images/share/s_gou.png";
  2883 + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
3148 2884 context.setFillStyle("red")
3149   - if (ct_num < 10) {
3150   - context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit);
3151   - } else {
3152   - context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit);
3153   - }
3154   - context.setFontSize(22 * unit)
3155   - context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit);
  2885 + context.setFontSize(18 * unit)
  2886 + context.fillText("正品保证", 84 * unit, 690 * unit);
3156 2887  
3157   - context.setFillStyle("gray")
3158   - context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit);
3159   - context.setFillStyle("black")
3160   - context.font = 'normal bold 18px sans-serif';
3161   - context.setFontSize(21.3 * unit)
3162   - context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit);
3163   -
3164   -
3165   - //---二维吗图---
3166   - //-- 自定义海报 --
3167   - if (th.data.poster) {
3168   - var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
3169   - var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
3170   - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
3171   - } else {
3172   - //---二维吗图---
3173   - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
3174   - }
3175   - break
3176   - case 3: //阶梯团的展示
3177   - //---画线---
3178   - context.setLineWidth(1 * unit)
3179   - context.moveTo(32 * unit, 670 * unit)
3180   - context.lineTo(520 * unit, 670 * unit)
3181   - context.stroke();
3182   - //---文字---
  2888 + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
  2889 + context.setFillStyle("red")
  2890 + context.setFontSize(18 * unit)
  2891 + context.fillText("纯实体店", 246 * unit, 690 * unit);
3183 2892  
3184   - context.setFillStyle("black")
3185   - context.setFontSize(24 * unit)
3186   - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit);
3187   -
3188   - //---绘制中间阶梯的价格---
3189   - var list = th.data.prom_act.ct_rylist;
3190   - for (var i = 0; i < list.length; i++) {
3191   - var item = list[i];
3192   - var wi = i * 90 * unit;
3193   - context.font = 'normal';
3194   - context.setFontSize(16 * unit)
3195   - context.setFillStyle("red")
3196   - context.fillText("¥", 40 * unit + wi, 756 * unit);
3197   - context.setFontSize(22 * unit)
3198   - var pri = parseFloat(item.price).toFixed(2);
3199   - context.fillText(pri, 56 * unit + wi, 756 * unit);
3200   - context.setFillStyle("gray")
3201   - context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit);
3202   - }
3203   - //----------------下面部分----------------
3204   - // context.setFillStyle("gray")
3205   - // context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit);
3206   - // context.setFillStyle("black")
3207   - // context.font = 'normal bold 18px sans-serif';
3208   - // context.setFontSize(22 * unit)
3209   - // context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit);
3210   - //context.setFillStyle("gray")
3211   - context.setFillStyle("black")
3212   - context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit);
3213   - //context.font = 'normal bold 18px sans-serif';
3214   - context.setFontSize(21 * unit)
3215   - context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit);
3216   -
3217   -
3218   - //-- 自定义海报 --
3219   - if (th.data.poster) {
3220   - var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
3221   - var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
3222   - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
3223   - } else {
3224   - //---二维吗图---
3225   - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
3226   - }
3227   - break
  2893 + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
  2894 + context.setFillStyle("red")
  2895 + context.setFontSize(18 * unit)
  2896 + context.fillText("官方验证", 420 * unit, 690 * unit);
  2897 + }
  2898 + } else {
  2899 + var g_path = "../../../../images/share/s_gou.png";
  2900 + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
  2901 + context.setFillStyle("red")
  2902 + context.setFontSize(18 * unit)
  2903 + context.fillText("正品保证", 84 * unit, 690 * unit);
3228 2904  
  2905 + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
  2906 + context.setFillStyle("red")
  2907 + context.setFontSize(18 * unit)
  2908 + context.fillText("纯实体店", 246 * unit, 690 * unit);
3229 2909  
  2910 + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
  2911 + context.setFillStyle("red")
  2912 + context.setFontSize(18 * unit)
  2913 + context.fillText("官方验证", 420 * unit, 690 * unit);
  2914 + } */
  2915 +
  2916 + //---画线---
  2917 + context.setLineWidth(1 * unit)
  2918 + context.moveTo(32 * unit, 665 * unit)
  2919 + context.lineTo(520 * unit, 665 * unit)
  2920 + context.stroke();
  2921 +
  2922 + //---文字---
  2923 + context.setFillStyle("black")
  2924 + // context.setFontSize(22 * unit)
  2925 + context.setFontSize(24 * unit)
  2926 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit);
  2927 + context.setFillStyle("red")
  2928 + context.setFontSize(20 * unit)
  2929 + var presell_price = `预售价:${th.data.presellList.presell_price}`
  2930 + context.fillText(presell_price, 40 * unit, 801 * unit);
  2931 + context.setFillStyle("black")
  2932 + context.setFontSize(22 * unit)
  2933 + context.fillText("特惠好物,限时预售", 40 * unit, 836 * unit);
  2934 + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit);
  2935 +
  2936 + //---二维吗图---
  2937 + //-- 自定义海报 --
  2938 + if (th.data.poster) {
  2939 + var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
  2940 + var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
  2941 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
  2942 + } else {
  2943 + //---二维吗图---
  2944 + context.drawImage(vpath, 390 * unit, 756 * unit, 130 * unit, 116 * unit);
3230 2945 }
3231 2946  
3232 2947  
  2948 +
3233 2949 //--- 如果是自定义海报的时候 ---
3234 2950 if (th.data.poster && parseInt(th.data.poster.style) == 2) {
3235 2951  
... ... @@ -3437,9 +3153,12 @@ Page({
3437 3153 return false;
3438 3154 }
3439 3155  
3440   - var img_url = ee.data.data.original_img;
3441   - if ((this.data.prom_type == 1 || this.data.prom_type == 6) && this.data.prom_act.share_imgurl) {
3442   - img_url = this.data.iurl + this.data.prom_act.share_imgurl;
  3156 + // var img_url = ee.data.data.original_img;
  3157 + var img_url = ee.data.presellForm.share_img;
  3158 + img_url?img_url:ee.data.data.original_img;
  3159 +
  3160 + if (img_url) {
  3161 + img_url = this.data.iurl + img_url;
3443 3162 }
3444 3163  
3445 3164 //获取商品是分享图信息
... ... @@ -3839,7 +3558,6 @@ Page({
3839 3558 //s.showWarning("设置默认门店地址失败", null, 500, !1);
3840 3559 getApp().my_warnning("设置默认门店地址失败", 0, th)
3841 3560 }
3842   -
3843 3561 }
3844 3562 });
3845 3563  
... ... @@ -4136,103 +3854,80 @@ Page({
4136 3854 });
4137 3855 },
4138 3856  
4139   - is_show_more_buy: function () {
4140   - var prom_goods = this.data.prom_goods;
4141   - var per_price = this.data.sele_g.shop_price
4142   - if (this.data.card_field && this.data.sele_g[this.data.card_field] > 0) {
4143   - per_price = this.data.sele_g[this.data.card_field];
4144   - }
4145   - var all_price = per_price * this.data.goodsInputNum;
4146   - var con = null;
4147   - for (var i in prom_goods) {
4148   - var item = prom_goods[i];
4149   - if (item.prom_type == 1) {
4150   - if (item.condition > this.data.goodsInputNum) {
4151   - con = item;
4152   - con.need = (item.condition - this.data.goodsInputNum).toFixed(2) + "件";
4153   - break;
4154   - }
4155   - } else {
4156   - if (item.condition > all_price) {
4157   - con = item;
4158   - con.need = (item.condition - all_price).toFixed(2) + "元";
4159   - break;
4160   - }
4161   - }
4162   - }
4163   -
4164   - this.setData({ hui_condition: con });
4165 3857  
  3858 + onShareTimeline() {
  3859 + var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : '';
  3860 + if (!store_name)
  3861 + store_name = getApp().globalData.setting.appName;
  3862 + return {
  3863 + title: this.data.data.goods_name + '-' + store_name,
  3864 + imageUrl: this.data.gallery[0].image_url,
  3865 + }
4166 3866 },
4167 3867  
4168   - closeSpecModal_inte: function () {
4169   - this.setData({ openSpecModal_inte: 0 });
  3868 + clickCollapse() {
  3869 + this.setData({ flag: !this.data.flag, })
4170 3870 },
4171   - closeSpecModal_inte_normal: function () {
4172   - this.setData({ openSpecModal_inte_normal: 0 });
4173   - //要进行还原
4174   - this.get_sto();
4175   - this.setData({
4176   - sele_g: this.data.data,
4177   - gid: this.data.data.goods_id
4178   - })
4179 3871  
4180   - this.sele_spec_chech_activity();
  3872 + clickShare() {
  3873 + this.setData({ share_hidden: true, });
4181 3874 },
4182 3875  
4183   - addCart_inte: function (t) {
4184   - this.add_cart_func_inte(t);
  3876 + send() {
  3877 + this.setData({ share_hidden: false, });
4185 3878 },
4186 3879  
  3880 + cancel() {
  3881 + this.setData({
  3882 + share_hidden: false,
  3883 + });
  3884 + },
4187 3885  
4188   - onShareTimeline() {
4189   - var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : '';
4190   - if (!store_name)
4191   - store_name = getApp().globalData.setting.appName;
4192   - return {
4193   - title: this.data.data.goods_name + '-' + store_name,
4194   - imageUrl: this.data.gallery[0].image_url,
  3886 + //积分购和拼团的普通购买的的时候,要判断有没有全场优惠活动
  3887 + check_nor_promgood(goods_id, back) {
  3888 + getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + goods_id, {
  3889 + success: function (res) {
  3890 + if (res.data.code == 0 && res.data.data && res.data.data.promGoodsLists && res.data.data.promGoodsLists.length > 0) {
  3891 + var obj = {
  3892 + act_id: res.data.data.promGoodsLists[0].prom_id,
  3893 + }
  3894 + back(obj);
  3895 + } else {
  3896 + back(0)
4195 3897 }
4196   - },
4197   -
4198   - clickCollapse() {
4199   - this.setData({flag: !this.data.flag,})
4200   - },
4201   -
4202   - clickShare() {
4203   - this.setData({share_hidden: true,});
4204   - },
4205   -
4206   - send() {
4207   - this.setData({share_hidden: false,});
4208   - },
4209   -
4210   - cancel() {
4211   - this.setData({
4212   - share_hidden: false,
4213   - });
4214   - },
  3898 + }
  3899 + })
  3900 + },
4215 3901  
4216   - //积分购和拼团的普通购买的的时候,要判断有没有全场优惠活动
4217   - check_nor_promgood(goods_id, back) {
4218   - getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + goods_id, {
4219   - success: function (res) {
4220   - if (res.data.code == 0 && res.data.data && res.data.data.promGoodsLists && res.data.data.promGoodsLists.length > 0) {
4221   - var obj = {
4222   - act_id: res.data.data.promGoodsLists[0].prom_id,
4223   - }
4224   - back(obj);
4225   - } else {
4226   - back(0)
4227   - }
  3902 + //获取预售的信息
  3903 + async get_pre_prom(func) {
  3904 + var th = this;
  3905 + var presell_id = null;
  3906 + var pre_arr = null;
  3907 +
  3908 + if(!th.data.pre_id){
  3909 + var presell_id=th.data.presell_id;
  3910 + var url="/api/weshop/marketing/marketingPresellList/list"
  3911 + var rd={
  3912 + store_id:os.stoid,
  3913 + presell_id:presell_id,
  3914 + goods_id:th.data.gid
  3915 + }
  3916 + //------获取预售从表----------
  3917 + await getApp().request.promiseGet(url, {
  3918 + data:rd
  3919 + }).then(res => {
  3920 + if (res.data.code == 0 && res.data.data && res.data.data.length>0) {
  3921 + var arr =res.data.data[0];
  3922 + presell_id = arr.presell_id;
  3923 + th.setData({
  3924 + presellList: arr,
  3925 + })
4228 3926 }
4229 3927 })
4230   - },
4231 3928  
4232   - async get_pre_prom(func){
4233   - var th = this;
4234   - var presell_id = null;
4235   - var pre_arr = null;
  3929 +
  3930 + }else{
4236 3931 //------获取预售从表----------
4237 3932 await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + th.data.pre_id, {}).then(res => {
4238 3933 if (res.data.code == 0 && res.data.data) {
... ... @@ -4243,38 +3938,71 @@ Page({
4243 3938 })
4244 3939 }
4245 3940 })
4246   - if (!presell_id) {
4247   - wx.showToast({title: "未找到活动商品", icon: 'none', duration: 3000})
  3941 + }
  3942 +
  3943 +
  3944 + if (!presell_id) {
  3945 + wx.showToast({ title: "未找到活动商品", icon: 'none', duration: 3000 });
  3946 + ut.wx_back();
  3947 + return false;
  3948 + }
  3949 + //------获取预售主表----------
  3950 + await getApp().request.promiseGet(`/api/weshop/marketing/marketingPresellForm/get/${os.stoid}/${presell_id}`, {}).then(res => {
  3951 + if (res.data.code == 0 && res.data.data) {
  3952 + var act_data=res.data.data;
  3953 + if(act_data.is_end){
  3954 + wx.showToast({ title: "活动已经结束", icon: 'none', duration: 3000 });
  3955 + ut.wx_back();
4248 3956 return false;
4249 3957 }
4250   - //------获取预售主表----------
4251   - await getApp().request.promiseGet(`/api/weshop/marketing/marketingPresellForm/get/${os.stoid}/${presell_id}`, {}).then(res => {
4252   - if (res.data.code == 0 && res.data.data) {
4253   - th.setData({
4254   - presellForm: res.data.data,
4255   - });
4256   - th.countDown(res.data.data.end_time)
4257   - }
4258   - })
4259   - var userInfo = getApp().globalData.userInfo;
4260   - var pre_data = {store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: th.data.gid};
4261   - if (userInfo) {
4262   - pre_data.user_id = userInfo.user_id;
4263   - }
4264   - await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
4265   - data: pre_data,
4266   - }).then(e => {
4267   - if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
4268   - pre_arr = e.data.data.pageData[0];
4269   - th.setData({pre_arr: pre_arr})
4270   - }
  3958 + if(act_data.isuse==0){
  3959 + wx.showToast({ title: "活动未启用", icon: 'none', duration: 3000 });
  3960 + ut.wx_back();
  3961 + return false;
  3962 + }
  3963 +
  3964 + var end_time=act_data.pay_enddate;
  3965 + if(act_data.presell_type==1){
  3966 + end_time=act_data.end_time;
  3967 + }
  3968 + if(end_time<ut.gettimestamp()){
  3969 + wx.showToast({ title: "活动已经结束", icon: 'none', duration: 3000 });
  3970 + ut.wx_back();
  3971 + return false;
  3972 + }
  3973 +
  3974 + th.setData({
  3975 + presellForm: res.data.data,
  3976 + });
  3977 + th.countDown(res.data.data.end_time)
  3978 + }
  3979 + })
  3980 + var userInfo = getApp().globalData.userInfo;
  3981 + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1,prom_type:8,prom_id:presell_id };
  3982 + if (userInfo) {
  3983 + pre_data.user_id = userInfo.user_id;
  3984 + }
  3985 + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
  3986 + data: pre_data,
  3987 + }).then(e => {
  3988 + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
  3989 +
  3990 + th.data.all_pre_goods=e.data.data.pageData;
  3991 +
  3992 + var idx=e.data.data.pageData.findIndex(function (ele) {
  3993 + return ele.id== th.data.presellList.id;
4271 3994 })
4272   - if (!pre_arr) {
4273   - wx.showToast({title: "当前会员身份不符,无法参与", icon: 'none', duration: 3000})
4274   - }
4275   - if (func) {
4276   - func();
4277   - }
  3995 + pre_arr = e.data.data.pageData[idx];
  3996 + th.setData({ pre_arr: pre_arr })
  3997 + th.data.prom_buy_limit=pre_arr.vip_butyqty;
  3998 + }
  3999 + })
  4000 + if (!pre_arr) {
  4001 + wx.showToast({ title: "当前会员身份不符,无法参与", icon: 'none', duration: 3000 })
  4002 + }
  4003 + if (func) {
  4004 + func();
4278 4005 }
  4006 + }
4279 4007  
4280 4008 });
... ...
packageC/pages/presell/goodsInfo/goodsInfo.wxml
... ... @@ -104,7 +104,7 @@
104 104 </view>
105 105 </view>
106 106 </view>
107   - <view class="fs24" style="padding-bottom:20rpx">
  107 + <view wx:if="{{presellForm.presell_type==0}}" class="fs24" style="padding-bottom:20rpx">
108 108 <view class="stock" style="color:#999">尾款:{{filters.format_time(presellForm.pay_begindate,1)}}-{{filters.format_time(presellForm.pay_enddate,1)}}</view>
109 109 </view>
110 110 <view class="goods-num">
... ... @@ -495,20 +495,28 @@
495 495 </navigator>
496 496 </view>
497 497  
498   - <view class="fs24 f1 flex ai-center bg-FF4732 t-c white" style="border-radius:10rpx ">
499   - <view class="pdh20">
  498 + <view class="fs24 f1 flex ai-center bg-FF4732 t-c white" style="border-radius:10rpx;justify-content: center">
  499 + <view style="padding: 0 6rpx">
500 500 <view class="">{{filters.format_time(presellForm.end_time,2)}} 预售结束</view>
501 501 <!-- <view class="">08.30 23:59:59 开始发货</view> -->
502 502 <view class="" wx:if="{{presellForm.delivery_type==1}}">{{filters.format_time(presellForm.delivery_date,2)}} 开始发货</view>
503 503 <view class="" wx:else>付款{{presellForm.delivery_daynum}} 天后发货</view>
504 504 </view>
505 505  
506   - <view class="pdh20 line" bindtap="openSpecModel" data-ind="2">
507   - <view class="">支付定金</view>
  506 + <view class="line" bindtap="openSpecModel" data-ind="2" style="margin-left: 10rpx; padding-left: 10rpx">
  507 + <block wx:if="{{presellForm.presell_type==0}}">
  508 + <view class="">支付定金</view>
508 509 <view class="flex">
509 510 定金
510 511 <text class="rmb">{{presellList.presell_money}}</text>
511 512 </view>
  513 + </block>
  514 + <block wx:else>
  515 + <view class="">支付金额</view>
  516 + <view class="flex">
  517 + <text class="rmb" style="margin-left:10rpx;">{{presellList.presell_price}}</text>
  518 + </view>
  519 + </block>
512 520 </view>
513 521 </view>
514 522 </view>
... ... @@ -534,29 +542,15 @@
534 542 券后¥<text class="fs32">{{sele_g.offline_price}}</text>
535 543 </view>
536 544 </view>
537   - <block wx:if="{{prom_type==0}}">
538   - <view class="flex">
539   - <view class="spec-goods-stock">已售:{{sele_g.sales_sum}}</view>
540   - <block wx:if="{{sales_rules==2}}">
541   - <view class="spec-goods-stock" wx:if="{{def_pick_store && def_pick_store.CanOutQty}}">
542   - 可售:{{def_pick_store.CanOutQty}}
543   - </view>
544   - <view class="spec-goods-stock" wx:else>可售:0</view>
545   - </block>
546   - <block wx:else>
547   - <view class="spec-goods-stock">可售:{{sele_g.store_count}}</view>
548   - </block>
549   - </view>
550   - </block>
551   - <block wx:if="{{prom_type==1}}">
  545 +
552 546 <view class="flex">
553   - <view class="spec-goods-stock" wx:if="{{prom_st>0}}">
554   - 已售:{{prom_act.buy_num+prom_act.virtual}}
  547 + <view class="spec-goods-stock">
  548 + 已售:{{pre_arr.buy_goodnum+pre_arr.virtual_qty}}
555 549 </view>
556   - <view class="spec-goods-stock" wx:else>已售:{{prom_act.buy_num}}</view>
557   - <view class="spec-goods-stock">可售:{{prom_act.goods_num-prom_act.buy_num}}</view>
  550 + <view class="spec-goods-stock">可售:{{pre_arr.presell_sumqty-pre_arr.buy_goodnum}}</view>
558 551 </view>
559   - </block>
  552 +
  553 +
560 554 </view>
561 555 <!-- 选择门店模块 -->
562 556 <view class="flex-space-between address ai_end xc-width ">
... ... @@ -653,7 +647,8 @@
653 647 <block wx:else>
654 648 <view wx:if="{{openSpecModal_ind==2}}" bindtap="addCart"
655 649 data-openSpecModal_ind="{{openSpecModal_ind}}" class="spec-cart-btn spec-buy" data-action="buy">
656   - 支付定金(¥{{presellList.presell_money}})
  650 + <text wx:if="{{presellForm.presell_type==0}}">支付定金(¥{{pre_arr.presell_money}})</text>
  651 + <text wx:else>支付金额(¥{{pre_arr.presell_price}})</text>
657 652 </view>
658 653 </block>
659 654  
... ...
packageC/pages/presell/list/list.js
... ... @@ -51,7 +51,7 @@ Page({
51 51 })
52 52  
53 53 var userInfo=getApp().globalData.userInfo;
54   - if(userInfo && goodlist.length==0){
  54 + if(userInfo && this.data.goodlist.length==0){
55 55 //调用列表
56 56 this.get_list();
57 57 }else{
... ...
packageC/pages/presell/list/list.wxml
... ... @@ -62,7 +62,7 @@
62 62  
63 63 </view>
64 64 <view class="kill-btn ">
65   - <navigator url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{item.goods_id}}">去抢购</navigator>
  65 + <navigator url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{item.goods_id}}&pre_id={{item.id}}">去抢购</navigator>
66 66 </view>
67 67 </view>
68 68 </view>
... ...
pages/cart/cart/cart.js
... ... @@ -301,11 +301,12 @@ Page({
301 301 //如果秒杀活动都去掉了,或者结束了,那么这个商品也没有必要留着
302 302 if (item.prom_type == 1) {
303 303 var prom = null;
  304 + var now = ut.gettimestamp();
304 305 await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + item.prom_id, {}).then(res => {
305 306 if (res.data.code == 0) prom = res.data.data;
306 307 })
307   - //---如果有活动,不算在一起---
308   - if (!prom && prom.is_end == 0 && prom.end_time > now && prom.start_time < now) {
  308 + //---如果互动都已经过期,或者还未开始,或者无活动
  309 + if (!prom || prom.is_end == 1 || prom.end_time < now || prom.start_time > now) {
309 310 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
310 311 a.delete(url, {
311 312 success: function (t) {
... ... @@ -513,9 +514,9 @@ Page({
513 514 }
514 515 }else{
515 516 //-- 此时要实时更新线下取价价格 --
516   - for(var i=0;i<arr.length;i++){
  517 + for(var ij in arr){
517 518 //每个门店都去看下线下取价
518   - var list=arr[i];
  519 + var list=arr[ij];
519 520 for(var i in list.goods){
520 521 list.goods[i].offline_price=0
521 522 }
... ...
pages/cart/cart_wk/cart_wk.js
... ... @@ -350,7 +350,6 @@ Page({
350 350 //--立即支付--
351 351 to_pay_type: function (ind) {
352 352 var th = this;
353   -
354 353 //--物流支付时要有地址--
355 354 if (th.data.exp_type == 0 && th.data.user_addr == null) {
356 355 return getApp().my_warnning("请选择收货地址", 0, th);
... ...
pages/cart/cart_wk/cart_wk.wxml
... ... @@ -46,7 +46,6 @@
46 46  
47 47 <!--商品图片显示-->
48 48 <view class='center'>
49   -
50 49 <view class='cen_img'>
51 50 <image src="{{order.show_img}}" binderror="bind_bnerr" data-errorimg="order.show_img"></image>
52 51 </view>
... ... @@ -61,22 +60,6 @@
61 60  
62 61 </view>
63 62  
64   -<!--取货方式-->
65   -
66   -<!-- <view class='quhou bdr_b-14'>
67   - <view bindtap="set_wuliu" data-type="1" class='qu_fs' wx:if="{{distr_type==0 || distr_type==1}}">
68   - <image wx:if="{{exp_type==0}}" src='{{imgUrl}}/miniapp/images/kon.png'></image>
69   - <image wx:if="{{exp_type==1}}" src='{{imgUrl}}/miniapp/images/dd.png'></image>
70   - <text class='qu_wz'>门店自提</text>
71   - </view>
72   -
73   - <view bindtap="set_wuliu" data-type="0" class='qu_fs' wx:if="{{distr_type==0 || distr_type==2}}">
74   - <image wx:if="{{exp_type==0}}" src='{{imgUrl}}/miniapp/images/dd.png'></image>
75   - <image wx:if="{{exp_type==1}}" src='{{imgUrl}}/miniapp/images/kon.png'></image>
76   - <text class='qu_wz'>快递邮寄</text>
77   - </view>
78   -</view> -->
79   -
80 63 <view class="use-item bdr_b-14 jc_sb" wx:if='{{exp_type==0 && !is_default_logistics}}'>
81 64 <view>选择物流:</view>
82 65 <view class="flex-vertical" bindtap="show_wu_arr" data-txt='index' style="margin-right: 8rpx;">
... ...
pages/goods/goodsInfo/goodsInfo.js
Changes suppressed. Click to show
1 1 var t = require("../../../utils/util.js"),
2   - ut = t,
3   - e = require("../../../utils/common.js"),
4   - a = require("../../../utils/wxParse/wxParse.js"),
5   - s = getApp(),
6   - i = s.request,
7   - rq = i,
8   - oo = s.globalData,
9   - o = s.globalData.setting,
10   - os = o;
  2 + ut = t,
  3 + e = require("../../../utils/common.js"),
  4 + a = require("../../../utils/wxParse/wxParse.js"),
  5 + s = getApp(),
  6 + i = s.request,
  7 + rq = i,
  8 + oo = s.globalData,
  9 + o = s.globalData.setting,
  10 + os = o;
11 11 //评价加载更多
12   -var more = function(e) {
13   - return e && e.__esModule ? e : {
14   - default: e
15   - };
16   - }(require("../../../utils/LoadMore.js")),
17   - n = new more.default();
  12 +var more = function (e) {
  13 + return e && e.__esModule ? e : {
  14 + default: e
  15 + };
  16 +}(require("../../../utils/LoadMore.js")),
  17 + n = new more.default();
18 18 var utils = require('../../../utils/util.js');
19 19 var regeneratorRuntime = require('../../../utils/runtime.js');
  20 +const { app } = require("../../../utils/common.js");
20 21  
21 22 Page({
22 23 data: {
... ... @@ -31,7 +32,7 @@ Page({
31 32 resourceUrl: o.h5_url, //公众号那边的图片文件域名
32 33 iurl: o.imghost,
33 34 defaultAvatar: o.resourceUrl + "/static/images/user68.jpg",
34   -
  35 +
35 36 data: null,
36 37 content: "", //商品详情
37 38 comments: null, //商品评论
... ... @@ -80,25 +81,25 @@ Page({
80 81 id: 1,
81 82 num: 0
82 83 },
83   - {
84   - name: "有图",
85   - id: 5,
86   - num: 0
87   - },
  84 + {
  85 + name: "有图",
  86 + id: 5,
  87 + num: 0
  88 + },
88 89  
89   - {
90   - name: "好评",
91   - id: 2,
92   - num: 0
93   - }, {
94   - name: "中评",
95   - id: 3,
96   - num: 0
97   - }, {
98   - name: "差评",
99   - id: 4,
100   - num: 0
101   - },
  90 + {
  91 + name: "好评",
  92 + id: 2,
  93 + num: 0
  94 + }, {
  95 + name: "中评",
  96 + id: 3,
  97 + num: 0
  98 + }, {
  99 + name: "差评",
  100 + id: 4,
  101 + num: 0
  102 + },
102 103 ],
103 104  
104 105 select: {
... ... @@ -126,7 +127,7 @@ Page({
126 127 def_pickpu_list: null, //一开始5个门店list
127 128 sec_pick_index: 0, //第二级门店选择ID
128 129 fir_pick_index: 0, //第一级门店选择ID
129   - all_pick_list:null,//所有的门店先记录起来
  130 + all_pick_list: null,//所有的门店先记录起来
130 131 //同一条形码的所有商品
131 132 sku_g: null,
132 133 sku_g_pt: null, //---拼单的普通购买---
... ... @@ -219,7 +220,7 @@ Page({
219 220 new_user: 0, //新用户
220 221  
221 222 def_pick_store: null, // 默认的门店
222   - fir_def_store:null, //客户默认的门店的
  223 + fir_def_store: null, //客户默认的门店的
223 224 lat: null, //维度
224 225 lon: null, //经度
225 226  
... ... @@ -229,122 +230,122 @@ Page({
229 230 open_ind_store: 0, //哪里打开的门店列表的控制属性
230 231 default_store: {}, //创建添加默认门店地址的对象
231 232  
232   - comments_no_more:0,
233   - get_c:0, //获取评价是不是成
234   - is_collect_load:0, //是不是处理
235   - is_newsales_rules:0, //是否开启最新的门店规则,此时会新读门店,当点击选择门店时会触发读取线下库存
236   - sales_rules:1, //默认是线上销售
  233 + comments_no_more: 0,
  234 + get_c: 0, //获取评价是不是成
  235 + is_collect_load: 0, //是不是处理
  236 + is_newsales_rules: 0, //是否开启最新的门店规则,此时会新读门店,当点击选择门店时会触发读取线下库存
  237 + sales_rules: 1, //默认是线上销售
237 238  
238   - wait_for_user_store:null,
239   - prom_goods:null, //商品优惠列表
240   - order_prom:null, //订单优惠
241   - collocationGoods:null, //搭配购
242   -
243   - poster:null, //自定义海报
244   - share_b_img:'', //自定义分享的背景
245   -
246   - showPoster: false,
247   - hui_condition:null,
248   - sto_sele_name_1:'',//分享的门店名称
249   - fir_goods:null,
  239 + wait_for_user_store: null,
  240 + prom_goods: null, //商品优惠列表
  241 + order_prom: null, //订单优惠
  242 + collocationGoods: null, //搭配购
250 243  
251   - share_hidden: false,
  244 + poster: null, //自定义海报
  245 + share_b_img: '', //自定义分享的背景
  246 +
  247 + showPoster: false,
  248 + hui_condition: null,
  249 + sto_sele_name_1: '',//分享的门店名称
  250 + fir_goods: null,
  251 +
  252 + share_hidden: false,
252 253 },
253 254  
254 255 //------初始化加载----------
255   - onLoad: function(t) {
  256 + onLoad: function (t) {
256 257  
257 258  
258 259  
259 260 var ee = this,
260   - that = ee,
261   - th = ee,
262   - gid = t.goods_id,
263   - first_leader=t.first_leader,
264   - room_id=t.room_id,
265   - room_user_share=t.room_user_share; //如果是会员分享带有room_id的话,那么接下来会员分享就不传room_id
266   -
267   - //-- 自定义海报 --
268   - getApp().request.promiseGet("/api/weshop/goods/poster/page", {
269   - data:{store_id:os.stoid, type:1, is_use:1}
270   - }).then(res=>{
271   - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0]){
272   -
273   - var poster_data=res.data.data.pageData[0];
274   - var json_str=poster_data.jsonStr;
275   -
276   - if(json_str){
277   - var json_data=JSON.parse(json_str);
278   - if(json_data.bg_img){
279   -
280   - //-- 把图片那到本地 --
281   - wx.getImageInfo({
282   - src:json_data.bg_img,
283   - success: function(res) {
284   - var path= res.path;
285   - th.setData({share_b_img:path})
286   - },
287   - fail: function(res) {}
288   - });
289   - }
290   - th.setData({poster:json_data})
291   -
292   - }
293   - }
294   - })
295   -
  261 + that = ee,
  262 + th = ee,
  263 + gid = t.goods_id,
  264 + first_leader = t.first_leader,
  265 + room_id = t.room_id,
  266 + room_user_share = t.room_user_share; //如果是会员分享带有room_id的话,那么接下来会员分享就不传room_id
  267 +
  268 + //-- 自定义海报 --
  269 + getApp().request.promiseGet("/api/weshop/goods/poster/page", {
  270 + data: { store_id: os.stoid, type: 1, is_use: 1 }
  271 + }).then(res => {
  272 + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0]) {
  273 +
  274 + var poster_data = res.data.data.pageData[0];
  275 + var json_str = poster_data.jsonStr;
  276 +
  277 + if (json_str) {
  278 + var json_data = JSON.parse(json_str);
  279 + if (json_data.bg_img) {
  280 +
  281 + //-- 把图片那到本地 --
  282 + wx.getImageInfo({
  283 + src: json_data.bg_img,
  284 + success: function (res) {
  285 + var path = res.path;
  286 + th.setData({ share_b_img: path })
  287 + },
  288 + fail: function (res) { }
  289 + });
  290 + }
  291 + th.setData({ poster: json_data })
  292 +
  293 + }
  294 + }
  295 + })
  296 +
296 297 //---获取手机地址坐标--
297 298 //--如果tg_id是空的话,分享回来--
298 299 if (gid == undefined || gid == null || gid == "") {
299   - var gid_str = decodeURIComponent(t.scene);
300   - gid_str=gid_str.split("_");
301   - gid=gid_str[0];
302   - if(gid_str.length>1){
303   - first_leader=gid_str[1];
304   - }
305   - //-- 如果有room_id的获取 --
306   - if(gid_str.length>2 && gid_str[2]){
307   - room_id=gid_str[2];
308   - room_user_share=1;
309   - }
310   -
  300 + var gid_str = decodeURIComponent(t.scene);
  301 + gid_str = gid_str.split("_");
  302 + gid = gid_str[0];
  303 + if (gid_str.length > 1) {
  304 + first_leader = gid_str[1];
  305 + }
  306 + //-- 如果有room_id的获取 --
  307 + if (gid_str.length > 2 && gid_str[2]) {
  308 + room_id = gid_str[2];
  309 + room_user_share = 1;
  310 + }
  311 +
311 312 }
312 313  
313   - ee.setData({ gid: gid});
314   - if(first_leader){
315   - console.log("log---".first_leader);
316   - getApp().globalData.first_leader=first_leader;
  314 + ee.setData({ gid: gid });
  315 + if (first_leader) {
  316 + console.log("log---".first_leader);
  317 + getApp().globalData.first_leader = first_leader;
317 318 //调用接口判断是不是会员
318   - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+os.stoid+"/"+first_leader,{}).then(res=>{
319   - if(res.data.code==0){
320   - getApp().globalData.guide_id=res.data.data.id;
  319 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
  320 + if (res.data.code == 0) {
  321 + getApp().globalData.guide_id = res.data.data.id;
321 322 }
322 323 })
323 324 }
324 325  
325 326 //-- 如果有房间号 --
326   - if(room_id){
327   - getApp().globalData.room_id=room_id;
328   - getApp().globalData.room_goods_id=gid;
329   - //如果是会员分享过来的要记录
330   - if(room_user_share)
331   - getApp().globalData.room_user_share=room_user_share;
  327 + if (room_id) {
  328 + getApp().globalData.room_id = room_id;
  329 + getApp().globalData.room_goods_id = gid;
  330 + //如果是会员分享过来的要记录
  331 + if (room_user_share)
  332 + getApp().globalData.room_user_share = room_user_share;
332 333 }
333 334  
334   - var c_guide_id=t.c_guide_id;
335   - if(c_guide_id){
336   - th.data.c_guide_id=c_guide_id;
  335 + var c_guide_id = t.c_guide_id;
  336 + if (c_guide_id) {
  337 + th.data.c_guide_id = c_guide_id;
337 338 }
338   -
339   - getApp().getConfig(function(e) {
340   - ee.setData({sto_sele_name_1:e.store_name})
341   - })
  339 +
  340 + getApp().getConfig(function (e) {
  341 + ee.setData({ sto_sele_name_1: e.store_name })
  342 + })
342 343  
343 344 //----获取系统参数-----
344   - getApp().getConfig2(function(e) {
  345 + getApp().getConfig2(function (e) {
345 346 ee.setData({
346 347 bconfig: e,
347   - sales_rules:e.sales_rules,
  348 + sales_rules: e.sales_rules,
348 349 });
349 350  
350 351 if (e.categoryset.indexOf("," + 1 + ",") != -1) {
... ... @@ -362,13 +363,13 @@ Page({
362 363 is_show_gb: 1
363 364 });
364 365 }
365   -
  366 + console.log(e);
366 367 var json_d = JSON.parse(e.switch_list);
367 368 ee.setData({
368 369 store_config: e,
369   - sys_switch:json_d,
  370 + sys_switch: json_d,
370 371 is_closecoupon: json_d.is_closecoupon,
371   - is_newsales_rules:json_d.is_newsales_rules
  372 + is_newsales_rules: json_d.is_newsales_rules
372 373 });
373 374 ee.init(gid);
374 375 //------几人评价-------
... ... @@ -379,39 +380,39 @@ Page({
379 380 });
380 381  
381 382 //计算等级价相关
382   - var swithc_list=e.switch_list;
383   - var sw_arr=JSON.parse(swithc_list);
  383 + var swithc_list = e.switch_list;
  384 + var sw_arr = JSON.parse(swithc_list);
384 385 //---如果后台又开等级卡的开关---
385   - if(sw_arr.rank_switch && sw_arr.rank_switch=="2"){
386   - th.setData({rank_switch:true});
  386 + if (sw_arr.rank_switch && sw_arr.rank_switch == "2") {
  387 + th.setData({ rank_switch: true });
387 388 //---回调卡的列表---
388   - th.getPlusCardType(function(ob){
389   - th.setData({card_list:ob.card_list});
  389 + th.getPlusCardType(function (ob) {
  390 + th.setData({ card_list: ob.card_list });
390 391 var ti = setInterval(function () {
391 392 var user = getApp().globalData.userInfo;
392 393 if (!user) return false;
393 394 clearInterval(ti);
394 395  
395   - if(user.card_field && user['card_expiredate']){
  396 + if (user.card_field && user['card_expiredate']) {
396 397 var str = user['card_expiredate'].replace(/-/g, '/');
397 398 var end = new Date(str);
398 399 end = Date.parse(end) / 1000;
399 400 var now = ut.gettimestamp();
400 401 //--- 判断是等级会员,且在有效期范围内 ---
401   - if(user.card_field && now<end){
402   - var card_name=ob.name_map.get(user.card_field);
  402 + if (user.card_field && now < end) {
  403 + var card_name = ob.name_map.get(user.card_field);
403 404 //if(card_name.length>6) card_name=card_name.substring(0,6);
404 405  
405   - var is_near_date=0;
406   - if(end-now<60*60*30*24) is_near_date=1; //如果小于30天
407   - th.setData({card_field:user.card_field,card_name:card_name,card_list:ob.card_list,is_near_date:is_near_date});
  406 + var is_near_date = 0;
  407 + if (end - now < 60 * 60 * 30 * 24) is_near_date = 1; //如果小于30天
  408 + th.setData({ card_field: user.card_field, card_name: card_name, card_list: ob.card_list, is_near_date: is_near_date });
408 409 }
409 410 }
410 411 }, 500)
411 412 })
412 413 }
413 414  
414   - },1);
  415 + }, 1);
415 416  
416 417 //获取用户设备信息,屏幕宽度
417 418 wx.getSystemInfo({
... ... @@ -421,36 +422,36 @@ Page({
421 422 })
422 423 }
423 424 });
424   -
  425 +
425 426 //获取用户的默认门店
426   - getApp().get_user_store(function(e) {
427   - if(!e) {
428   - th.data.fir_def_store={}; //赋值空对象
  427 + getApp().get_user_store(function (e) {
  428 + if (!e) {
  429 + th.data.fir_def_store = {}; //赋值空对象
429 430 return false;
430 431 }
431   - var ee=JSON.parse(JSON.stringify(e));
  432 + var ee = JSON.parse(JSON.stringify(e));
432 433 //--定时器推迟一下--
433 434 setTimeout(function () {
434   - if(th.data.fir_goods) var g_distr_type=th.data.fir_goods.distr_type;
  435 + if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type;
435 436 //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对--
436   - if(ee.distr_type!=0 && g_distr_type!=0 && ee.distr_type!=g_distr_type ){
  437 + if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) {
437 438 //th.data.fir_def_store={}; //赋值空对象
438 439 //return false;
439   - //th.data.fir_def_store.is_no_dis=1;
440   - ee.is_no_dis=1;
  440 + //th.data.fir_def_store.is_no_dis=1;
  441 + ee.is_no_dis = 1;
441 442 }
442 443  
443   - var appd=getApp().globalData;
444   - var w_time = setInterval(function() {
  444 + var appd = getApp().globalData;
  445 + var w_time = setInterval(function () {
445 446 if (that.data.is_get_local_ok == 0) return false;
446 447 clearInterval(w_time);
447 448 var distance = null;
448   - var e=JSON.parse(JSON.stringify(ee));
  449 + var e = JSON.parse(JSON.stringify(ee));
449 450  
450 451 //如果有开启近距离的话,同时距离优不一样了
451 452 if (that.data.lat != null) {
452 453 //如果经纬度有变化的话
453   - if(e && appd.lat==that.data.lat && appd.lon==that.data.lon && e.distance>0 ){
  454 + if (e && appd.lat == that.data.lat && appd.lon == that.data.lon && e.distance > 0) {
454 455 //that.data.fir_def_store=e;
455 456 // that.setData({
456 457 // def_pick_store: e,
... ... @@ -458,18 +459,18 @@ Page({
458 459 // sto_sele_id: e.pickup_id,
459 460 // sto_sele_distr: e.distr_type
460 461 // })
461   - that.set_def_storage(e);
462   -
463   - }else{
  462 + that.set_def_storage(e);
  463 +
  464 + } else {
464 465 //要用接口是获取距离,js的计算不准
465   - getApp().request.promiseGet("/api/weshop/pickup/list",{
466   - data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon},
467   - }).then(res=>{
468   - if(res.data.code==0){
469   - e=res.data.data.pageData[0];
470   - if (e){
471   - e.is_no_dis=ee.is_no_dis;
472   - appd.pk_store=e;
  466 + getApp().request.promiseGet("/api/weshop/pickup/list", {
  467 + data: { store_id: os.stoid, pickup_id: e.pickup_id, lat: th.data.lat, lon: th.data.lon },
  468 + }).then(res => {
  469 + if (res.data.code == 0) {
  470 + e = res.data.data.pageData[0];
  471 + if (e) {
  472 + e.is_no_dis = ee.is_no_dis;
  473 + appd.pk_store = e;
473 474 // that.data.fir_def_store=e;
474 475 // that.setData({
475 476 // def_pick_store: e,
... ... @@ -477,17 +478,17 @@ Page({
477 478 // sto_sele_id: e.pickup_id,
478 479 // sto_sele_distr: e.distr_type
479 480 // })
480   - that.set_def_storage(e);
  481 + that.set_def_storage(e);
481 482 }
482 483  
483 484 }
484 485 })
485 486 }
486 487 //e.distance = distance;
487   - appd.lat=that.data.lat;
488   - appd.lon=that.data.lon;
  488 + appd.lat = that.data.lat;
  489 + appd.lon = that.data.lon;
489 490  
490   - }else{
  491 + } else {
491 492 if (e) {
492 493 e.distance = null;
493 494 // that.data.fir_def_store=e;
... ... @@ -497,86 +498,86 @@ Page({
497 498 // sto_sele_id: e.pickup_id,
498 499 // sto_sele_distr: e.distr_type
499 500 // })
500   - that.set_def_storage(e);
  501 + that.set_def_storage(e);
501 502 }
502 503 }
503 504 }, 500)
504   - },700)
505   - });
506   -
  505 + }, 700)
  506 + });
  507 +
507 508 //更新点击量
508   - getApp().request.put("/api/weshop/goods/updateClick",{
509   - data:{store_id:os.stoid,goods_id:gid}
510   - })
  509 + getApp().request.put("/api/weshop/goods/updateClick", {
  510 + data: { store_id: os.stoid, goods_id: gid }
  511 + })
511 512 },
512   -
513   -
  513 +
  514 +
514 515 //--- 设置一下默认库存的数量 ----
515   - set_def_storage(ee){
516   - var that=this,th=this;
517   - getApp().getConfig2(function(e){
518   - var sales_rules=e.sales_rules;
519   - if(sales_rules==2){
520   - getApp().waitfor2(that,"wait_for_user_store","fir_goods",function(){
521   - var lock=0,plist=null;
522   - var gd=that.data.fir_goods;
523   - //先读取门店的lock,采用链式写法,少用await
524   - getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
525   - data:{store_id:os.stoid,wareId:that.data.fir_goods.goods_id,storageId:ee.pickup_id,pageSize:1000}
526   - }).then(res=>{
527   - if(res.data.code==0 && res.data.data.total>0){
528   - for(var i in res.data.data.pageData)
529   - lock+=res.data.data.pageData[i].outQty
530   - }
531   - //---通过接口获取门店的线下库存信息--
532   - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
533   - data:{storageNos:ee.pickup_no,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid}
534   - })
535   - }).then(res=>{
536   - if(res.data.code==0 && res.data.data.total>0){
537   - plist=res.data.data.pageData[0];
538   - }
539   - if(plist && plist.CanOutQty-lock>0){
540   - ee.CanOutQty=plist.CanOutQty-lock;
541   - }else{
542   - ee.CanOutQty=0;
543   - }
544   - //--给门店赋值线下库存--
545   - that.data.fir_def_store=ee;
546   - that.setData({
547   - def_pick_store: ee,
548   - sto_sele_name: ee.pickup_name,
549   - sto_sele_id: ee.pickup_id,
550   - sto_sele_distr: ee.distr_type
551   - })
552   - })
553   - })
554   - }else{
555   - that.data.fir_def_store=ee;
556   - that.setData({
557   - def_pick_store: ee,
558   - sto_sele_name: ee.pickup_name,
559   - sto_sele_id: ee.pickup_id,
560   - sto_sele_distr: ee.distr_type
561   - })
562   - }
563   - })
564   -
565   - },
566   -
  516 + set_def_storage(ee) {
  517 + var that = this, th = this;
  518 + getApp().getConfig2(function (e) {
  519 + var sales_rules = e.sales_rules;
  520 + if (sales_rules == 2) {
  521 + getApp().waitfor2(that, "wait_for_user_store", "fir_goods", function () {
  522 + var lock = 0, plist = null;
  523 + var gd = that.data.fir_goods;
  524 + //先读取门店的lock,采用链式写法,少用await
  525 + getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
  526 + data: { store_id: os.stoid, wareId: that.data.fir_goods.goods_id, storageId: ee.pickup_id, pageSize: 1000 }
  527 + }).then(res => {
  528 + if (res.data.code == 0 && res.data.data.total > 0) {
  529 + for (var i in res.data.data.pageData)
  530 + lock += res.data.data.pageData[i].outQty
  531 + }
  532 + //---通过接口获取门店的线下库存信息--
  533 + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
  534 + data: { storageNos: ee.pickup_no, wareIds: encodeURIComponent(th.data.data.erpwareid), storeId: os.stoid }
  535 + })
  536 + }).then(res => {
  537 + if (res.data.code == 0 && res.data.data.total > 0) {
  538 + plist = res.data.data.pageData[0];
  539 + }
  540 + if (plist && plist.CanOutQty - lock > 0) {
  541 + ee.CanOutQty = plist.CanOutQty - lock;
  542 + } else {
  543 + ee.CanOutQty = 0;
  544 + }
  545 + //--给门店赋值线下库存--
  546 + that.data.fir_def_store = ee;
  547 + that.setData({
  548 + def_pick_store: ee,
  549 + sto_sele_name: ee.pickup_name,
  550 + sto_sele_id: ee.pickup_id,
  551 + sto_sele_distr: ee.distr_type
  552 + })
  553 + })
  554 + })
  555 + } else {
  556 + that.data.fir_def_store = ee;
  557 + that.setData({
  558 + def_pick_store: ee,
  559 + sto_sele_name: ee.pickup_name,
  560 + sto_sele_id: ee.pickup_id,
  561 + sto_sele_distr: ee.distr_type
  562 + })
  563 + }
  564 + })
  565 +
  566 + },
  567 +
567 568  
568 569 //------------程序初始化入口-------------
569 570 async init(gid) {
570 571 var ee = this,
571   - th = ee,
572   - gallery = null,
573   - is_collect = 0,
574   - collect_id = 0,
575   - categories3 = ee.data.categories3,
576   - fir_com = null,
577   - fir_quan = null,
578   - mapurl = null,
579   - mapurl_f_img = null;
  572 + th = ee,
  573 + gallery = null,
  574 + is_collect = 0,
  575 + collect_id = 0,
  576 + categories3 = ee.data.categories3,
  577 + fir_com = null,
  578 + fir_quan = null,
  579 + mapurl = null,
  580 + mapurl_f_img = null;
580 581  
581 582  
582 583 //------图片滚动----------
... ... @@ -655,8 +656,8 @@ Page({
655 656 goods_id: gid,
656 657 pageSize: 3,
657 658 parent_id: 0,
658   - page:1,
659   - is_show:1,
  659 + page: 1,
  660 + is_show: 1,
660 661 },
661 662 }).then(res => {
662 663 fir_com = res.data.data.pageData;
... ... @@ -678,7 +679,7 @@ Page({
678 679 type: 1,
679 680 pageSize: 3,
680 681 page: 1,
681   - is_share:0,
  682 + is_share: 0,
682 683 },
683 684 }).then(res1 => {
684 685 fir_quan = res1.data.data.pageData;
... ... @@ -709,21 +710,21 @@ Page({
709 710 },
710 711  
711 712 //---展示---
712   - onShow: function() {
713   - console.log('djfijsaoifjoisadjfoij');
714   - var goods_list = null,th = this,that=this;
715   - var show_prew_img= this.data.show_prew_img
716   - if(show_prew_img){
717   - show_prew_img=0;
  713 + onShow: function () {
  714 + console.log('djfijsaoifjoisadjfoij');
  715 + var goods_list = null, th = this, that = this;
  716 + var show_prew_img = this.data.show_prew_img
  717 + if (show_prew_img) {
  718 + show_prew_img = 0;
718 719 return false;
719 720 }
720 721  
721 722 //优惠券要实时更新
722   - getApp().getConfig2(function(e) {
  723 + getApp().getConfig2(function (e) {
723 724 var json_d = JSON.parse(e.switch_list);
724   - th.setData({is_closecoupon: json_d.is_closecoupon})
725   - th.setData({is_open_offline: json_d.is_pricing_open})
726   - },1)
  725 + th.setData({ is_closecoupon: json_d.is_closecoupon })
  726 + th.setData({ is_open_offline: json_d.is_pricing_open })
  727 + }, 1)
727 728  
728 729  
729 730 var ui = setInterval(function () {
... ... @@ -737,20 +738,21 @@ Page({
737 738  
738 739 this.data.is_timer = 1;
739 740 var ee = this,
740   - gid = this.data.gid,
741   - i = getApp().request;
  741 + gid = this.data.gid,
  742 + i = getApp().request;
742 743  
743 744 this.wait_for_store_config();
744 745  
745 746 i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, {
746 747 failRollback: !0,
747   - success: function(t) {
  748 + success: function (t) {
  749 + console.log(t);
748 750 if (t.data.code == 0) {
749 751 if (t.data.data.is_on_sale != 1) {
750 752 wx.showModal({
751 753 title: '商品已经下架',
752 754 showCancel: !1,
753   - complete: function() {
  755 + complete: function () {
754 756 wx.navigateBack();
755 757 }
756 758 });
... ... @@ -762,7 +764,7 @@ Page({
762 764 wx.showModal({
763 765 title: '商品还未上架',
764 766 showCancel: !1,
765   - complete: function() {
  767 + complete: function () {
766 768 wx.navigateBack();
767 769 }
768 770 });
... ... @@ -773,7 +775,7 @@ Page({
773 775 wx.showModal({
774 776 title: '商品已经到期下架',
775 777 showCancel: !1,
776   - complete: function() {
  778 + complete: function () {
777 779 wx.navigateBack();
778 780 }
779 781 });
... ... @@ -781,46 +783,46 @@ Page({
781 783 }
782 784 //动态获取商品名称
783 785 wx.setNavigationBarTitle({
784   - title: t.data.data.goods_name,
  786 + title: t.data.data.goods_name,
785 787 });
786 788  
787 789 //-- 判断是不是组合购活动,必须要登录后才能判断 --
788   - if(getApp().globalData.userInfo && t.data.data.prom_type==7 ){
789   - //获取活动信息
790   - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" +
791   - t.data.data.prom_id+"/"+getApp().globalData.userInfo.user_id;
792   - getApp().request.get(url, {
793   - success:function (e) {
794   - if (e.data.code == 0 && e.data.data) {
795   - if(ut.gettimestamp()<e.data.data.start_time){
796   - return false;
797   - }
798   - if (e.data.data.is_end == 0 && ut.gettimestamp()<e.data.data.end_time ) {
799   - //-- 获取商品列表 --
800   - th.setData({zh_act:e.data.data });
801   - }
802   -
803   - }
  790 + if (getApp().globalData.userInfo && t.data.data.prom_type == 7) {
  791 + //获取活动信息
  792 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" +
  793 + t.data.data.prom_id + "/" + getApp().globalData.userInfo.user_id;
  794 + getApp().request.get(url, {
  795 + success: function (e) {
  796 + if (e.data.code == 0 && e.data.data) {
  797 + if (ut.gettimestamp() < e.data.data.start_time) {
  798 + return false;
804 799 }
805   - });
  800 + if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) {
  801 + //-- 获取商品列表 --
  802 + th.setData({ zh_act: e.data.data });
  803 + }
  804 +
  805 + }
  806 + }
  807 + });
806 808 }
807 809  
808   - //-- 把商品的赋值 --
809   - ee.data.fir_goods=JSON.parse(JSON.stringify(t.data.data));
  810 + //-- 把商品的赋值 --
  811 + ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data));
810 812 ee.check_is_youhui(ee.data.gid);
811 813  
812 814 t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss');
813   -
814   - var cur_price=t.data.data.shop_price;
815   - if(getApp().globalData.userInfo && getApp().globalData.userInfo.card_field){
816   - var cfile=getApp().globalData.userInfo.card_field;
817   - if(t.data.data[cfile]){
818   - cur_price=t.data.data[cfile];
819   - }
820   - }
821   - var txt =(cur_price / t.data.data.market_price * 10).toFixed(2).toString();
822   - txt=parseFloat(txt);
823   -
  815 +
  816 + var cur_price = t.data.data.shop_price;
  817 + if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) {
  818 + var cfile = getApp().globalData.userInfo.card_field;
  819 + if (t.data.data[cfile]) {
  820 + cur_price = t.data.data[cfile];
  821 + }
  822 + }
  823 + var txt = (cur_price / t.data.data.market_price * 10).toFixed(2).toString();
  824 + txt = parseFloat(txt);
  825 +
824 826 t.data.data['disc'] = txt;
825 827  
826 828 if (t.data.data.original_img.indexOf(o.imghost) == -1)
... ... @@ -829,55 +831,55 @@ Page({
829 831 if (t.data.data.goods_content == null) t.data.data.goods_content = "";
830 832  
831 833 //-----商品详情---
832   - if(!t.data.data.goods_content) t.data.data.goods_content=" ";
  834 + if (!t.data.data.goods_content) t.data.data.goods_content = " ";
833 835 a.wxParse("content", "html", t.data.data.goods_content, ee, 6);
834 836 e.wxParseAddFullImageUrl(ee, "content");
835 837  
836 838 ee.setData({
837 839 data: t.data.data,
838 840 sele_g: t.data.data,
839   - userInfo:getApp().globalData.userInfo
  841 + userInfo: getApp().globalData.userInfo
840 842 });
841 843  
842 844  
843 845 //获取统一条形码,普通商品和优惠促销的商品
844   - if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 2 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7){
  846 + if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 2 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7) {
845 847 //默认门店要拿下门店库存
846   - if(that.data.sales_rules==2 && that.data.is_newsales_rules){
  848 + if (that.data.sales_rules == 2 && that.data.is_newsales_rules) {
847 849 //获取门店
848 850 ee.get_sto();
849 851 //--等待某个值只运行---,这里有可能因为导航的时间太久,而不能计算门店库存
850   - /*---
851   - getApp().waitfor2(that,"wait_for_user_store","fir_def_store",function(){
852   - if(th.data.fir_def_store && th.data.fir_def_store.pickup_id ){
853   - var lock=0,plist=null;
854   - //先读取门店的lock,采用链式写法,少用await
855   - getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
856   - data:{store_id:os.stoid,wareId:ee.data.data.goods_id,storageId:that.data.fir_def_store.pickup_id,pageSize:1000}
857   - }).then(res=>{
858   - if(res.data.code==0 && res.data.data.total>0){
859   - for(var i in res.data.data.pageData)
860   - lock+=res.data.data.pageData[i].outQty
861   - }
862   - //---通过接口获取门店的线下库存信息--
863   - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
864   - data:{storageNos:that.data.fir_def_store.pickup_no,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid}
865   - })
866   - }).then(res=>{
867   - if(res.data.code==0 && res.data.data.total>0){
868   - plist=res.data.data.pageData[0];
869   - }
870   - if(plist && plist.CanOutQty-lock>0){
871   - that.data.fir_def_store.CanOutQty=plist.CanOutQty-lock;
872   - }else{
873   - that.data.fir_def_store.CanOutQty=0;
874   - }
875   - //--给门店赋值线下库存--
876   - th.setData({def_pick_store:that.data.fir_def_store});
877   - })
878   - }
879   - })--*/
880   - }else{
  852 + /*---
  853 + getApp().waitfor2(that,"wait_for_user_store","fir_def_store",function(){
  854 + if(th.data.fir_def_store && th.data.fir_def_store.pickup_id ){
  855 + var lock=0,plist=null;
  856 + //先读取门店的lock,采用链式写法,少用await
  857 + getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
  858 + data:{store_id:os.stoid,wareId:ee.data.data.goods_id,storageId:that.data.fir_def_store.pickup_id,pageSize:1000}
  859 + }).then(res=>{
  860 + if(res.data.code==0 && res.data.data.total>0){
  861 + for(var i in res.data.data.pageData)
  862 + lock+=res.data.data.pageData[i].outQty
  863 + }
  864 + //---通过接口获取门店的线下库存信息--
  865 + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
  866 + data:{storageNos:that.data.fir_def_store.pickup_no,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid}
  867 + })
  868 + }).then(res=>{
  869 + if(res.data.code==0 && res.data.data.total>0){
  870 + plist=res.data.data.pageData[0];
  871 + }
  872 + if(plist && plist.CanOutQty-lock>0){
  873 + that.data.fir_def_store.CanOutQty=plist.CanOutQty-lock;
  874 + }else{
  875 + that.data.fir_def_store.CanOutQty=0;
  876 + }
  877 + //--给门店赋值线下库存--
  878 + th.setData({def_pick_store:that.data.fir_def_store});
  879 + })
  880 + }
  881 + })--*/
  882 + } else {
881 883 //获取门店
882 884 ee.get_sto();
883 885 }
... ... @@ -887,8 +889,8 @@ Page({
887 889 else {
888 890 var gg = "", item = t.data.data;
889 891  
890   - if(item.goods_spec=="null" || item.goods_spec==null ) item.goods_spec="";
891   - if(item.goods_color=="null" || item.goods_color==null) item.goods_color="";
  892 + if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = "";
  893 + if (item.goods_color == "null" || item.goods_color == null) item.goods_color = "";
892 894  
893 895 if (item.goods_spec != "" && item.goods_color != "") {
894 896 gg = item.goods_spec + "/" + item.goods_color;
... ... @@ -911,7 +913,7 @@ Page({
911 913 if (ee.data.cat_name == '') {
912 914 //过去国别,分类,品牌的名称
913 915 i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, {
914   - success: function(t) {
  916 + success: function (t) {
915 917 var dd = t.data.data;
916 918 if (t.data.code == 0) {
917 919 th.setData({
... ... @@ -922,7 +924,7 @@ Page({
922 924 });
923 925 //过去国别,分类,品牌的名称
924 926 i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, {
925   - success: function(t) {
  927 + success: function (t) {
926 928 var dd = t.data.data;
927 929 if (t.data.code == 0) {
928 930 th.setData({
... ... @@ -933,7 +935,7 @@ Page({
933 935 });
934 936 //过去国别,分类,品牌的名称
935 937 i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, {
936   - success: function(t) {
  938 + success: function (t) {
937 939 var dd = t.data.data;
938 940 if (t.data.code == 0) {
939 941 th.setData({
... ... @@ -945,77 +947,77 @@ Page({
945 947 }
946 948  
947 949 }
948   - else{
949   - wx.showModal({
950   - title: t.data.msg,
951   - showCancel: !1,
952   - complete: function() {
953   - wx.navigateBack();
954   - }
955   - });
956   - }
957   - }
  950 + else {
  951 + wx.showModal({
  952 + title: t.data.msg,
  953 + showCancel: !1,
  954 + complete: function () {
  955 + wx.navigateBack();
  956 + }
  957 + });
  958 + }
  959 + }
958 960 });
959 961 this.data.enterAddressPage && (this.data.enterAddressPage = !1);
960 962  
961 963 },
962   - enterAddress: function() {
  964 + enterAddress: function () {
963 965 this.data.enterAddressPage = !0, wx.navigateTo({
964 966 url: "/pages/user/address_list/address_list?operate=selectAddress"
965 967 });
966 968 },
967   - onUnload: function() {
968   - for(var i = 1; i < 100; i++) {
969   - clearInterval(i);
970   - }
  969 + onUnload: function () {
  970 + for (var i = 1; i < 100; i++) {
  971 + clearInterval(i);
  972 + }
971 973 },
972   - onHide: function() {
  974 + onHide: function () {
973 975 this.data.is_timer = 0;
974   - for(var i = 1; i < 100; i++) {
  976 + for (var i = 1; i < 100; i++) {
975 977 clearInterval(i);
976 978 }
977 979 },
978 980 //----------三个选项按钮-----------
979   - tabClick: function(t) {
  981 + tabClick: function (t) {
980 982 var e = t.currentTarget.id;
981 983 this.setData({
982 984 activeCategoryId: e
983 985 }), 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment();
984 986 },
985   - tabClick2: function(t) {
  987 + tabClick2: function (t) {
986 988 this.setData({
987 989 activeCategoryId2: t.currentTarget.id
988 990 });
989 991 },
990 992  
991   - tabClick3: function(t) {
  993 + tabClick3: function (t) {
992 994 var e = this;
993 995 if (t.currentTarget.id != this.data.activeCategoryId3) {
994 996 e.data.c_curr_p = 1;
995 997 this.setData({
996 998 activeCategoryId3: t.currentTarget.id,
997   - comments: null,comments_no_more:0,get_c:0,
  999 + comments: null, comments_no_more: 0, get_c: 0,
998 1000 });
999 1001 this.requestComments_new();
1000 1002 }
1001 1003 },
1002 1004  
1003   - doScrollTop: function() {
  1005 + doScrollTop: function () {
1004 1006 wx.pageScrollTo({
1005 1007 scrollTop: 0
1006 1008 });
1007 1009 },
1008 1010  
1009   - tabComment: function() {
  1011 + tabComment: function () {
1010 1012 this.setData({
1011   - activeCategoryId: 2,comments_no_more:0,get_c:0
  1013 + activeCategoryId: 2, comments_no_more: 0, get_c: 0
1012 1014 }), this.data.comments || this.requestComments_new();
1013 1015 },
1014 1016  
1015 1017 //商品详情的时候调用
1016   - tabGoodsContent: function() {
  1018 + tabGoodsContent: function () {
1017 1019 var th = this,
1018   - i = getApp().request;
  1020 + i = getApp().request;
1019 1021 this.setData({
1020 1022 activeCategoryId: 1
1021 1023 });
... ... @@ -1023,7 +1025,7 @@ Page({
1023 1025 if (th.data.cat_name == '') {
1024 1026 //过去国别,分类,品牌的名称
1025 1027 i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, {
1026   - success: function(t) {
  1028 + success: function (t) {
1027 1029 var dd = t.data.data;
1028 1030 if (t.data.code == 0) {
1029 1031 th.setData({
... ... @@ -1034,7 +1036,7 @@ Page({
1034 1036 });
1035 1037 //过去国别,分类,品牌的名称
1036 1038 i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, {
1037   - success: function(t) {
  1039 + success: function (t) {
1038 1040 var dd = t.data.data;
1039 1041 if (t.data.code == 0) {
1040 1042 th.setData({
... ... @@ -1045,7 +1047,7 @@ Page({
1045 1047 });
1046 1048 //过去国别,分类,品牌的名称
1047 1049 i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, {
1048   - success: function(t) {
  1050 + success: function (t) {
1049 1051 var dd = t.data.data;
1050 1052 if (t.data.code == 0) {
1051 1053 th.setData({
... ... @@ -1060,8 +1062,8 @@ Page({
1060 1062 //获取redis中的数量
1061 1063 async getactLen(func) {
1062 1064 var r_num = 0,
1063   - prom_type = this.data.prom_type,
1064   - prom_id = this.data.prom_id;
  1065 + prom_type = this.data.prom_type,
  1066 + prom_id = this.data.prom_id;
1065 1067 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, {
1066 1068 1: 1
1067 1069 }).then(res => {
... ... @@ -1074,16 +1076,16 @@ Page({
1074 1076 },
1075 1077  
1076 1078 //------------加入购物车--------------
1077   - addCart: function(t) {
  1079 + addCart: function (t) {
1078 1080 var th = this;
1079 1081 var ind = t.currentTarget.dataset.openSpecModal_ind;
1080   - if(!ind) ind = t.currentTarget.dataset.openspecmodal_ind;
  1082 + if (!ind) ind = t.currentTarget.dataset.openspecmodal_ind;
1081 1083 th.setData({
1082 1084 open_ind_store: ind
1083 1085 });
1084 1086 //如果是秒杀的话,要看redis够不够
1085 1087 if (this.data.prom_type == 1) {
1086   - this.getactLen(function(num) {
  1088 + this.getactLen(function (num) {
1087 1089 if (num < th.data.goodsInputNum) {
1088 1090 getApp().my_warnning("秒杀库存不足!", 0, th);
1089 1091 return false;
... ... @@ -1095,27 +1097,27 @@ Page({
1095 1097 th.add_cart_func(t);
1096 1098 }
1097 1099 },
1098   -
1099   -
1100   -
  1100 +
  1101 +
  1102 +
1101 1103 //-- 加入购物的函数 --
1102   - add_cart_func_inte: function(t) {
  1104 + add_cart_func_inte: function (t) {
1103 1105 var i = getApp().request;
1104 1106 if (oo.user_id == null) {
1105 1107 return s.my_warnning("还未登录!", 0, this);
1106 1108 }
1107   - if(!getApp().globalData.userInfo){
1108   - return s.my_warnning("还未登录!", 0, this);
1109   - }
1110   -
  1109 + if (!getApp().globalData.userInfo) {
  1110 + return s.my_warnning("还未登录!", 0, this);
  1111 + }
  1112 +
1111 1113 var e = this,
1112   - th = e,
1113   - a = 0,
1114   - o = this.data.data;
  1114 + th = e,
  1115 + a = 0,
  1116 + o = this.data.data;
1115 1117 a = o.goods_id;
1116   -
  1118 +
1117 1119 //----------添加到购物车时,要判断限购数量,--------
1118   - e.get_buy_num(o, function(ee) {
  1120 + e.get_buy_num(o, function (ee) {
1119 1121 //---判断商品是否超出限购---
1120 1122 if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) {
1121 1123 if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) {
... ... @@ -1136,14 +1138,14 @@ Page({
1136 1138 return false;
1137 1139 }
1138 1140 }
1139   -
  1141 +
1140 1142 if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th);
1141 1143 if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined)
1142 1144 this.setData({
1143 1145 sto_sele_name: ""
1144 1146 });
1145 1147 if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th);
1146   -
  1148 +
1147 1149 //--------------此时操作的数据------------
1148 1150 var newd = {
1149 1151 goods_id: o.goods_id,
... ... @@ -1152,72 +1154,72 @@ Page({
1152 1154 user_id: oo.user_id,
1153 1155 store_id: th.data.stoid,
1154 1156 goods_price: th.data.prom_price,
1155   - integral:th.data.prom_integral,
  1157 + integral: th.data.prom_integral,
1156 1158 member_goods_price: o.shop_price,
1157 1159 goods_name: o.goods_name,
1158 1160 goods_sn: o.goods_sn,
1159 1161 sku: o.sku,
1160   - };
1161   -
  1162 + };
  1163 +
1162 1164 //---是不是从收藏夹出来的---
1163   - if(th.data.c_guide_id){
  1165 + if (th.data.c_guide_id) {
1164 1166 newd['guide_id'] = th.data.c_guide_id;
1165   - newd['guide_type']=2;
1166   - if ("add" == t.currentTarget.dataset.action) newd['guide_type']=3;
1167   - }else{
1168   - if(getApp().globalData.guide_id){
  1167 + newd['guide_type'] = 2;
  1168 + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3;
  1169 + } else {
  1170 + if (getApp().globalData.guide_id) {
1169 1171 newd['guide_id'] = getApp().globalData.guide_id;
1170   - newd['guide_type']=0;
1171   - if ("add" == t.currentTarget.dataset.action) newd['guide_type']=1;
  1172 + newd['guide_type'] = 0;
  1173 + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1;
1172 1174 }
1173 1175 }
1174   -
  1176 +
1175 1177 //让商品带上房间号
1176 1178 //让商品带上房间号
1177   - if(th.data.sys_switch.is_skuroom_id==1){
1178   - if(th.data.data.goods_id==getApp().globalData.room_goods_id){
1179   - newd.room_id=getApp().globalData.room_id;
  1179 + if (th.data.sys_switch.is_skuroom_id == 1) {
  1180 + if (th.data.data.goods_id == getApp().globalData.room_goods_id) {
  1181 + newd.room_id = getApp().globalData.room_id;
1180 1182 }
1181   - }else{
1182   - if(newd.goods_id==getApp().globalData.room_goods_id) newd.room_id=getApp().globalData.room_id;
  1183 + } else {
  1184 + if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id;
1183 1185 }
1184   -
  1186 +
1185 1187 //如果是积分够,is_integral_normal就要有积分购普通购买字段
1186 1188 //if(o.prom_type==4){
1187   - //newd.is_integral_normal=1;
  1189 + //newd.is_integral_normal=1;
1188 1190 //}
1189   -
1190   - //-----如果是秒杀,团购,积分购,拼团-----
1191   - newd.prom_type = th.data.prom_type;
1192   - newd.prom_id = th.data.prom_id;
1193   - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
1194   - if (o.store_count <e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
1195   -
1196   -
1197   - th.add_cart_next(e,t,a,o,newd); //立即购买下一步
1198   -
1199   - })
1200   - },
1201   -
  1191 +
  1192 + //-----如果是秒杀,团购,积分购,拼团-----
  1193 + newd.prom_type = th.data.prom_type;
  1194 + newd.prom_id = th.data.prom_id;
  1195 + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
  1196 + if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
  1197 +
  1198 +
  1199 + th.add_cart_next(e, t, a, o, newd); //立即购买下一步
  1200 +
  1201 + })
  1202 + },
  1203 +
1202 1204 //-- 加入购物的函数 --
1203   - add_cart_func: function(t) {
  1205 + add_cart_func: function (t) {
1204 1206 var i = getApp().request;
1205 1207 if (oo.user_id == null) {
1206 1208 return s.my_warnning("还未登录!", 0, this);
1207 1209 }
1208   -
1209   - if(!getApp().globalData.userInfo){
1210   - return s.my_warnning("还未登录!", 0, this);
1211   - }
1212   -
  1210 +
  1211 + if (!getApp().globalData.userInfo) {
  1212 + return s.my_warnning("还未登录!", 0, this);
  1213 + }
  1214 +
1213 1215 var e = this,
1214   - th = e,
1215   - a = 0,
1216   - o = this.data.sele_g;
  1216 + th = e,
  1217 + a = 0,
  1218 + o = this.data.sele_g;
1217 1219 a = o.goods_id;
1218 1220  
1219 1221 //----------添加到购物车时,要判断限购数量,--------
1220   - e.get_buy_num(o, function(ee) {
  1222 + e.get_buy_num(o, function (ee) {
1221 1223 //---判断商品是否超出限购---
1222 1224 if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) {
1223 1225 if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) {
... ... @@ -1258,193 +1260,193 @@ Page({
1258 1260 goods_name: o.goods_name,
1259 1261 goods_sn: o.goods_sn,
1260 1262 sku: o.sku,
1261   - };
1262   -
  1263 + };
  1264 +
1263 1265 //---是不是从收藏夹出来的---
1264   - if(th.data.c_guide_id){
  1266 + if (th.data.c_guide_id) {
1265 1267 newd['guide_id'] = th.data.c_guide_id;
1266   - newd['guide_type']=2;
1267   - if ("add" == t.currentTarget.dataset.action) newd['guide_type']=3;
1268   - }else{
1269   - if(getApp().globalData.guide_id){
  1268 + newd['guide_type'] = 2;
  1269 + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3;
  1270 + } else {
  1271 + if (getApp().globalData.guide_id) {
1270 1272 newd['guide_id'] = getApp().globalData.guide_id;
1271   - newd['guide_type']=0;
1272   - if ("add" == t.currentTarget.dataset.action) newd['guide_type']=1;
  1273 + newd['guide_type'] = 0;
  1274 + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1;
1273 1275 }
1274 1276 }
1275 1277  
1276 1278 //让商品带上房间号
1277 1279 //让商品带上房间号
1278   - if(th.data.sys_switch.is_skuroom_id==1){
1279   - if(th.data.data.goods_id==getApp().globalData.room_goods_id){
1280   - newd.room_id=getApp().globalData.room_id;
  1280 + if (th.data.sys_switch.is_skuroom_id == 1) {
  1281 + if (th.data.data.goods_id == getApp().globalData.room_goods_id) {
  1282 + newd.room_id = getApp().globalData.room_id;
1281 1283 }
1282   - }else{
1283   - if(newd.goods_id==getApp().globalData.room_goods_id) newd.room_id=getApp().globalData.room_id;
  1284 + } else {
  1285 + if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id;
1284 1286 }
1285 1287  
1286 1288 //如果是积分够,is_integral_normal就要有积分购普通购买字段
1287   - if(o.prom_type==4){
1288   - newd.is_integral_normal=1;
  1289 + if (o.prom_type == 4) {
  1290 + newd.is_integral_normal = 1;
1289 1291 }
1290   -
1291   - //如果有线下取价
1292   - if(o.offline_price){
1293   - newd.offline_price=o.offline_price;
1294   - newd.pricing_type=o.pricing_type;
1295   - }
1296   -
  1292 +
  1293 + //如果有线下取价
  1294 + if (o.offline_price) {
  1295 + newd.offline_price = o.offline_price;
  1296 + newd.pricing_type = o.pricing_type;
  1297 + }
  1298 +
1297 1299 //-----如果是秒杀,团购,积分购,拼团-----
1298 1300 if (th.data.prom_type == 1) {
1299 1301 newd.goods_price = th.data.prom_price;
1300 1302 newd.member_goods_price = th.data.prom_price,
1301   - newd.prom_type = th.data.prom_type;
  1303 + newd.prom_type = th.data.prom_type;
1302 1304 newd.prom_id = th.data.prom_id;
1303 1305  
1304 1306 if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
1305   - if (o.store_count <e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
1306   -
1307   - th.add_cart_next(e,t,a,o,newd); //加入购物车下一步
1308   -
1309   - }else if(o.prom_type==7){
1310   -
1311   - //判断进行中的活动,是不是要判断线下库存
1312   - th.check_zh_acting(function (ee){
1313   - newd.prom_id = 0;
1314   - newd.prom_type = 0;
1315   - if(ee && th.data.sele_g.act){
1316   - newd.prom_id = th.data.sele_g.act.id;
1317   - newd.prom_type = 7;
1318   - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
1319   - if (o.store_count <e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
1320   - th.add_cart_next(e,t,a,o,newd); //加入购物车下一步
1321   - return false;
1322   - }else{
1323   - //---如果是线下门店销售的时候---
1324   - if(th.data.sales_rules==2){
1325   - var pick=th.get_pick_from_list(th.data.sto_sele_id)
1326   - //---通过接口获取门店的线下库存信息--
1327   - getApp().request.get("/api/weshop/goods/getWareStorages",{
1328   - data:{storageNos:pick.pickup_no,wareIds:encodeURIComponent(th.data.sele_g.erpwareid),storeId:os.stoid},
1329   - success:function(res){
1330   - if(res.data.code==0){
1331   - if(res.data.data.pageData.length>0){
1332   - var CanOutQty=res.data.data.pageData[0].CanOutQty;
1333   - if(CanOutQty<e.data.goodsInputNum){
1334   - return s.my_warnning("库存不足!", 0, th);
1335   - }
1336   - //在调一次接口,读取商品的预出库的数量,lock
1337   - getApp().request.get("/api/weshop/order/ware/lock/page",{
1338   - data:{store_id:os.stoid,wareId:th.data.sele_g.goods_id,storageId:pick.pickup_id,pageSize:1000},
1339   - success:function(res_data){
1340   - if(res_data.data.code==0 && res_data.data.data.total>0){
1341   -
1342   - var lock=0;
1343   - for(var i in res_data.data.data.pageData){
1344   - lock+=res_data.data.data.pageData[i].outQty;
1345   - }
1346   -
1347   - if(CanOutQty<=lock){
1348   - return s.my_warnning("库存不足!", 0, th);
1349   - }
1350   - th.add_cart_next(e,t,a,o,newd,CanOutQty-lock);
1351   - }else{
1352   - th.add_cart_next(e,t,a,o,newd,CanOutQty);
1353   - }
1354   - }
1355   - })
1356   - }else{
1357   - return s.my_warnning("库存不足!", 0, th);
1358   - }
1359   -
1360   - }
1361   - }
1362   - })
1363   - }else{
1364   - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
1365   - if (o.store_count <e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
1366   - th.add_cart_next(e,t,a,o,newd); //加入购物车下一步
1367   - }
1368   - }
1369   - })
  1307 + if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
  1308 +
  1309 + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
  1310 +
  1311 + } else if (o.prom_type == 7) {
  1312 +
  1313 + //判断进行中的活动,是不是要判断线下库存
  1314 + th.check_zh_acting(function (ee) {
  1315 + newd.prom_id = 0;
  1316 + newd.prom_type = 0;
  1317 + if (ee && th.data.sele_g.act) {
  1318 + newd.prom_id = th.data.sele_g.act.id;
  1319 + newd.prom_type = 7;
  1320 + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
  1321 + if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
  1322 + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
  1323 + return false;
  1324 + } else {
  1325 + //---如果是线下门店销售的时候---
  1326 + if (th.data.sales_rules == 2) {
  1327 + var pick = th.get_pick_from_list(th.data.sto_sele_id)
  1328 + //---通过接口获取门店的线下库存信息--
  1329 + getApp().request.get("/api/weshop/goods/getWareStorages", {
  1330 + data: { storageNos: pick.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid },
  1331 + success: function (res) {
  1332 + if (res.data.code == 0) {
  1333 + if (res.data.data.pageData.length > 0) {
  1334 + var CanOutQty = res.data.data.pageData[0].CanOutQty;
  1335 + if (CanOutQty < e.data.goodsInputNum) {
  1336 + return s.my_warnning("库存不足!", 0, th);
  1337 + }
  1338 + //在调一次接口,读取商品的预出库的数量,lock
  1339 + getApp().request.get("/api/weshop/order/ware/lock/page", {
  1340 + data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, storageId: pick.pickup_id, pageSize: 1000 },
  1341 + success: function (res_data) {
  1342 + if (res_data.data.code == 0 && res_data.data.data.total > 0) {
  1343 +
  1344 + var lock = 0;
  1345 + for (var i in res_data.data.data.pageData) {
  1346 + lock += res_data.data.data.pageData[i].outQty;
  1347 + }
  1348 +
  1349 + if (CanOutQty <= lock) {
  1350 + return s.my_warnning("库存不足!", 0, th);
  1351 + }
  1352 + th.add_cart_next(e, t, a, o, newd, CanOutQty - lock);
  1353 + } else {
  1354 + th.add_cart_next(e, t, a, o, newd, CanOutQty);
  1355 + }
  1356 + }
  1357 + })
  1358 + } else {
  1359 + return s.my_warnning("库存不足!", 0, th);
  1360 + }
  1361 +
  1362 + }
  1363 + }
  1364 + })
  1365 + } else {
  1366 + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
  1367 + if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
  1368 + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
  1369 + }
  1370 + }
  1371 + })
1370 1372  
1371 1373 }
1372   - else if ( th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 2 || th.data.prom_type == 4 || th.data.prom_type == 5) {
  1374 + else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 2 || th.data.prom_type == 4 || th.data.prom_type == 5) {
1373 1375 newd.prom_type = 0;
1374 1376 newd.prom_id = 0;
1375 1377  
1376 1378 //---如果是线下门店销售的时候---
1377   - if(th.data.sales_rules==2){
1378   - var pick=th.get_pick_from_list(th.data.sto_sele_id)
  1379 + if (th.data.sales_rules == 2) {
  1380 + var pick = th.get_pick_from_list(th.data.sto_sele_id)
1379 1381 //---通过接口获取门店的线下库存信息--
1380   - getApp().request.get("/api/weshop/goods/getWareStorages",{
1381   - data:{storageNos:pick.pickup_no,wareIds:encodeURIComponent(th.data.sele_g.erpwareid),storeId:os.stoid},
1382   - success:function(res){
1383   - if(res.data.code==0){
1384   - if(res.data.data.pageData.length>0){
1385   - var CanOutQty=res.data.data.pageData[0].CanOutQty;
1386   - if(CanOutQty<e.data.goodsInputNum){
  1382 + getApp().request.get("/api/weshop/goods/getWareStorages", {
  1383 + data: { storageNos: pick.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid },
  1384 + success: function (res) {
  1385 + if (res.data.code == 0) {
  1386 + if (res.data.data.pageData.length > 0) {
  1387 + var CanOutQty = res.data.data.pageData[0].CanOutQty;
  1388 + if (CanOutQty < e.data.goodsInputNum) {
1387 1389 return s.my_warnning("库存不足!", 0, th);
1388 1390 }
1389 1391 //在调一次接口,读取商品的预出库的数量,lock
1390   - getApp().request.get("/api/weshop/order/ware/lock/page",{
1391   - data:{store_id:os.stoid,wareId:th.data.sele_g.goods_id,storageId:pick.pickup_id,pageSize:1000},
1392   - success:function(res_data){
1393   - if(res_data.data.code==0 && res_data.data.data.total>0){
1394   -
1395   - var lock=0;
1396   - for(var i in res_data.data.data.pageData){
1397   - lock+=res_data.data.data.pageData[i].outQty;
  1392 + getApp().request.get("/api/weshop/order/ware/lock/page", {
  1393 + data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, storageId: pick.pickup_id, pageSize: 1000 },
  1394 + success: function (res_data) {
  1395 + if (res_data.data.code == 0 && res_data.data.data.total > 0) {
  1396 +
  1397 + var lock = 0;
  1398 + for (var i in res_data.data.data.pageData) {
  1399 + lock += res_data.data.data.pageData[i].outQty;
1398 1400 }
1399 1401  
1400   - if(CanOutQty<=lock){
  1402 + if (CanOutQty <= lock) {
1401 1403 return s.my_warnning("库存不足!", 0, th);
1402 1404 }
1403   - th.add_cart_next(e,t,a,o,newd,CanOutQty-lock);
1404   - }else{
1405   - th.add_cart_next(e,t,a,o,newd,CanOutQty);
  1405 + th.add_cart_next(e, t, a, o, newd, CanOutQty - lock);
  1406 + } else {
  1407 + th.add_cart_next(e, t, a, o, newd, CanOutQty);
1406 1408 }
1407 1409 }
1408 1410 })
1409   - }else{
  1411 + } else {
1410 1412 return s.my_warnning("库存不足!", 0, th);
1411 1413 }
1412 1414  
1413 1415 }
1414 1416 }
1415 1417 })
1416   - }else{
  1418 + } else {
1417 1419 if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
1418   - if (o.store_count <e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
1419   - th.add_cart_next(e,t,a,o,newd); //加入购物车下一步
  1420 + if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
  1421 + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
1420 1422 }
1421 1423 }
1422 1424 })
1423 1425 },
1424 1426  
1425 1427 //---加入购物车的最后一步---
1426   - add_cart_next(e,t,a,o,newd,CanOutQty){
1427   - var th=this,i=getApp().request;
  1428 + add_cart_next(e, t, a, o, newd, CanOutQty) {
  1429 + var th = this, i = getApp().request;
1428 1430 //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------
1429   - if(o.prom_type!=1 && ((o.prom_type!=6 && o.prom_type!=4) || th.data.is_normal)){
1430   - var conf=th.data.bconfig;
1431   - if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']){
1432   - var s_list=JSON.parse(conf.switch_list);
1433   - var now=ut.gettimestamp();
1434   -
  1431 + if (o.prom_type != 1 && ((o.prom_type != 6 && o.prom_type != 4) || th.data.is_normal)) {
  1432 + var conf = th.data.bconfig;
  1433 + if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']) {
  1434 + var s_list = JSON.parse(conf.switch_list);
  1435 + var now = ut.gettimestamp();
  1436 +
1435 1437  
1436 1438 var str = getApp().globalData.userInfo['card_expiredate'].replace(/-/g, '/');
1437 1439 var end = new Date(str);
1438 1440 end = Date.parse(end) / 1000;
1439 1441  
1440 1442 //--如果后台有开启等级价的功能,而且会员的等级没有过期的情况下--
1441   - if(parseInt(s_list.rank_switch)==2 && end>now){
1442   - var card_price=o[getApp().globalData.userInfo['card_field']];
  1443 + if (parseInt(s_list.rank_switch) == 2 && end > now) {
  1444 + var card_price = o[getApp().globalData.userInfo['card_field']];
1443 1445 //如果会员有等级价
1444   - if(getApp().globalData.userInfo['card_field']!=undefined && getApp().globalData.userInfo['card_field']!=null
1445   - && getApp().globalData.userInfo['card_field']!="" && card_price>0){
1446   - newd.goods_price=card_price;
1447   - newd.member_goods_price=card_price;
  1446 + if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null
  1447 + && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) {
  1448 + newd.goods_price = card_price;
  1449 + newd.member_goods_price = card_price;
1448 1450 }
1449 1451 }
1450 1452 }
... ... @@ -1453,7 +1455,7 @@ Page({
1453 1455 //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d);
1454 1456 if ("add" == t.currentTarget.dataset.action) {
1455 1457  
1456   - if(th.data.prom_goods){
  1458 + if (th.data.prom_goods) {
1457 1459 newd.prom_type = 3;
1458 1460 newd.prom_id = th.data.prom_goods[0].prom_id;
1459 1461 }
... ... @@ -1466,7 +1468,7 @@ Page({
1466 1468 goods_id: a,
1467 1469 pick_id: e.data.sto_sele_id,
1468 1470 },
1469   - success: function(re) {
  1471 + success: function (re) {
1470 1472  
1471 1473 //-------如果购物车中有相关的数据---------
1472 1474 if (re.data.data.total > 0) {
... ... @@ -1474,12 +1476,12 @@ Page({
1474 1476 var item = re.data.data.pageData[0];
1475 1477  
1476 1478 //判断数量,要看下购物车中有没有该商品
1477   - if(CanOutQty){
1478   - if(item.goods_num+ th.data.goodsInputNum>CanOutQty){
  1479 + if (CanOutQty) {
  1480 + if (item.goods_num + th.data.goodsInputNum > CanOutQty) {
1479 1481 return s.my_warnning("库存不足!", 0, th);
1480 1482 }
1481   - }else{
1482   - if(item.goods_num+ th.data.goodsInputNum>o.store_count){
  1483 + } else {
  1484 + if (item.goods_num + th.data.goodsInputNum > o.store_count) {
1483 1485 return s.my_warnning("库存不足!", 0, th);
1484 1486 }
1485 1487 }
... ... @@ -1488,15 +1490,15 @@ Page({
1488 1490 id: item.id,
1489 1491 goods_num: e.data.goodsInputNum + item.goods_num,
1490 1492 goods_price: newd.goods_price,
1491   - member_goods_price:newd.goods_price,
  1493 + member_goods_price: newd.goods_price,
1492 1494 store_id: th.data.stoid,
1493 1495 };
1494 1496  
1495 1497 //---是不是从收藏夹出来的---
1496   - if(th.data.c_guide_id){
  1498 + if (th.data.c_guide_id) {
1497 1499 updata['guide_id'] = th.data.c_guide_id;
1498   - updata['guide_type']=3; //加入购物车之后就变成了3
1499   - }else {
  1500 + updata['guide_type'] = 3; //加入购物车之后就变成了3
  1501 + } else {
1500 1502 if (getApp().globalData.guide_id) {
1501 1503 updata['guide_id'] = getApp().globalData.guide_id;
1502 1504 updata['guide_type'] = 0;
... ... @@ -1505,7 +1507,7 @@ Page({
1505 1507  
1506 1508 i.put("/api/weshop/cart/update", {
1507 1509 data: updata,
1508   - success: function(t) {
  1510 + success: function (t) {
1509 1511 getApp().my_warnning('加入购物车成功', 1, th, 450);
1510 1512 var c_num = th.data.cartGoodsNum + th.data.goodsInputNum;
1511 1513 th.setData({
... ... @@ -1519,7 +1521,7 @@ Page({
1519 1521  
1520 1522 i.post("/api/weshop/cart/save", {
1521 1523 data: newd,
1522   - success: function(t) {
  1524 + success: function (t) {
1523 1525 getApp().my_warnning('加入购物车成功', 1, th, 450);
1524 1526 var c_num = th.data.cartGoodsNum + e.data.goodsInputNum;
1525 1527 th.setData({
... ... @@ -1536,20 +1538,20 @@ Page({
1536 1538 //else "exchange" == t.currentTarget.dataset.action ? this.exchange(d) : this.buyNow(d);
1537 1539 else {
1538 1540  
1539   - if(th.data.prom_goods){
1540   - var prom_d=th.data.prom_goods;
1541   - for(var i in prom_d){
  1541 + if (th.data.prom_goods) {
  1542 + var prom_d = th.data.prom_goods;
  1543 + for (var i in prom_d) {
1542 1544 //判断活动有俩种条件,0元 1件
1543   - var condition_t=prom_d[i].prom_type;
1544   - switch(condition_t) {
  1545 + var condition_t = prom_d[i].prom_type;
  1546 + switch (condition_t) {
1545 1547 case 0: //按钱
1546   - if(newd.goods_price>=condition_t){
  1548 + if (newd.goods_price >= condition_t) {
1547 1549 newd.prom_type = 3;
1548 1550 newd.prom_id = prom_d[i].prom_id;
1549 1551 }
1550 1552 break
1551 1553 case 1://按购买数量
1552   - if(newd.goods_num>=condition_t){
  1554 + if (newd.goods_num >= condition_t) {
1553 1555 newd.prom_type = 3;
1554 1556 newd.prom_id = prom_d[i].prom_id;
1555 1557 }
... ... @@ -1567,7 +1569,7 @@ Page({
1567 1569  
1568 1570  
1569 1571 //----------购买虚拟商品------
1570   - buyVirtualGoods: function(e) {
  1572 + buyVirtualGoods: function (e) {
1571 1573 Object.assign(e, {
1572 1574 goods_name: this.data.data.goods.goods_name,
1573 1575 spec_name: this.data.select.specName,
... ... @@ -1577,102 +1579,102 @@ Page({
1577 1579 });
1578 1580 },
1579 1581 //----------积分兑换---------
1580   - exchange: function(e) {
  1582 + exchange: function (e) {
1581 1583 this.data.shippingCost < 0 || this.data.select.stock <= 0 || wx.navigateTo({
1582 1584 url: "/pages/cart/integral/integral?" + t.Obj2Str(e)
1583 1585 });
1584 1586 },
1585   -
1586   -
  1587 +
  1588 +
1587 1589 //----------立即购买-----------
1588   - buyNow: function(e) {
  1590 + buyNow: function (e) {
1589 1591 // this.data.shippingCost < 0 || this.data.select.stock <= 0 || (Object.assign(e, {
1590 1592 // action: "buy_now"
1591 1593 // }),
1592 1594 this.setData({
1593   - openSpecModal:0,
1594   - openSpecModal_inte:0,
1595   - openSpecModal_inte_normal:0,
1596   - openSpecModal_pt:0,
  1595 + openSpecModal: 0,
  1596 + openSpecModal_inte: 0,
  1597 + openSpecModal_inte_normal: 0,
  1598 + openSpecModal_pt: 0,
1597 1599 })
1598   -
1599   - if(e.prom_type==4){
1600   - s.set_b_now(e);
1601   - var url="/pages/cart/cart2_inte/cart2_inte?is_bnow=1&goods_id=" + e.goods_id;
1602   - getApp().goto(url);
1603   - }else{
1604   - //要判断积分购的普通购买有没有参加优惠活动
1605   - if(e.is_integral_normal==1){
1606   - this.check_nor_promgood(e.goods_id,function(res){
1607   - if(res && res.cat_id){
1608   - e.prom_type=3;
1609   - e.prom_id=res.cat_id
1610   - }
1611   - s.set_b_now(e);
1612   - /*--
1613   - wx.redirectTo({
1614   - url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id,
1615   - });--*/
1616   - getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id)
1617   -
1618   - })
1619   - }else{
1620   - s.set_b_now(e);
1621   - /*--
1622   - wx.redirectTo({
1623   - url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id,
1624   - });--*/
1625   - getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id)
1626   - }
1627   -
1628   - }
  1600 +
  1601 + if (e.prom_type == 4) {
  1602 + s.set_b_now(e);
  1603 + var url = "/pages/cart/cart2_inte/cart2_inte?is_bnow=1&goods_id=" + e.goods_id;
  1604 + getApp().goto(url);
  1605 + } else {
  1606 + //要判断积分购的普通购买有没有参加优惠活动
  1607 + if (e.is_integral_normal == 1) {
  1608 + this.check_nor_promgood(e.goods_id, function (res) {
  1609 + if (res && res.cat_id) {
  1610 + e.prom_type = 3;
  1611 + e.prom_id = res.cat_id
  1612 + }
  1613 + s.set_b_now(e);
  1614 + /*--
  1615 + wx.redirectTo({
  1616 + url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id,
  1617 + });--*/
  1618 + getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id)
  1619 +
  1620 + })
  1621 + } else {
  1622 + s.set_b_now(e);
  1623 + /*--
  1624 + wx.redirectTo({
  1625 + url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id,
  1626 + });--*/
  1627 + getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id)
  1628 + }
  1629 +
  1630 + }
1629 1631 },
1630 1632  
1631 1633 //----------增加购买数量-----------
1632   - addCartNum: function(t) {
  1634 + addCartNum: function (t) {
1633 1635 this.checkCartNum(this.data.goodsInputNum + 1);
1634 1636 },
1635 1637 //----------减少购买数量-----------
1636   - subCartNum: function(t) {
  1638 + subCartNum: function (t) {
1637 1639 this.checkCartNum(this.data.goodsInputNum - 1);
1638 1640 },
1639 1641 //----------输入框输入购买数量-----------
1640   - inputCartNum: function(t) {
  1642 + inputCartNum: function (t) {
1641 1643 this.checkCartNum(Number(t.detail.value));
1642 1644 },
1643   -
  1645 +
1644 1646 //----------增加购买数量-----------
1645   - addCartNum_inte: function(t) {
  1647 + addCartNum_inte: function (t) {
1646 1648 this.checkCartNum_inte(this.data.goodsInputNum + 1);
1647 1649 },
1648 1650 //----------减少购买数量-----------
1649   - subCartNum_inte: function(t) {
  1651 + subCartNum_inte: function (t) {
1650 1652 this.checkCartNum_inte(this.data.goodsInputNum - 1);
1651 1653 },
1652 1654 //----------输入框输入购买数量-----------
1653   - inputCartNum_inte: function(t) {
  1655 + inputCartNum_inte: function (t) {
1654 1656 this.checkCartNum_inte(Number(t.detail.value));
1655 1657 },
1656   -
  1658 +
1657 1659  
1658 1660 //------检查数量是不是超出限购------
1659   - checkCartNum: function(t) {
  1661 + checkCartNum: function (t) {
1660 1662 var th = this;
1661   - this.get_buy_num(this.data.sele_g, async function() {
  1663 + this.get_buy_num(this.data.sele_g, async function () {
1662 1664  
1663 1665 //--判断商品是否超出限购--
1664 1666 if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) {
1665 1667  
1666   - var gd_buy_num=th.data.g_buy_num.get(th.data.sele_g.goods_id);
  1668 + var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id);
1667 1669  
1668 1670 if (t + gd_buy_num > th.data.sele_g.viplimited) {
1669 1671 wx.showModal({
1670 1672 title: '超出商品限购',
1671 1673 });
1672 1674  
1673   - var num= th.data.sele_g.viplimited-gd_buy_num;
1674   - if(num<0) num=0;
1675   - th.setData({goodsInputNum:num})
  1675 + var num = th.data.sele_g.viplimited - gd_buy_num;
  1676 + if (num < 0) num = 0;
  1677 + th.setData({ goodsInputNum: num })
1676 1678 return false;
1677 1679 }
1678 1680 }
... ... @@ -1684,9 +1686,9 @@ Page({
1684 1686 title: '超出商品活动限购',
1685 1687 });
1686 1688  
1687   - var num=th.data.prom_buy_limit- th.data.prom_buy_num ;
1688   - if(num<0) num=0;
1689   - th.setData({goodsInputNum:num})
  1689 + var num = th.data.prom_buy_limit - th.data.prom_buy_num;
  1690 + if (num < 0) num = 0;
  1691 + th.setData({ goodsInputNum: num })
1690 1692 return false;
1691 1693 }
1692 1694 }
... ... @@ -1695,7 +1697,7 @@ Page({
1695 1697 var redis_num = 0;
1696 1698 //------判断活动是否抢光-----
1697 1699 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
1698   - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, {
  1700 + os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, {
1699 1701 1: 1
1700 1702 }).then(res => {
1701 1703 redis_num = res.data.data;
... ... @@ -1705,131 +1707,133 @@ Page({
1705 1707 wx.showModal({
1706 1708 title: '超出商品活动库存',
1707 1709 });
1708   - th.setData({goodsInputNum:redis_num})
  1710 + th.setData({ goodsInputNum: redis_num })
1709 1711 return false;
1710 1712 }
1711 1713 }
1712 1714 var e = th.data.sele_g.store_count;
1713   - var p_type=th.data.prom_type; //&& p_type!=1 && p_type!=4
1714   - if(th.data.sales_rules==2 && (p_type!=1 && p_type!=4 && p_type!=6 || th.data.openSpecModal_inte_normal==1 || th.data.is_normal== 1) ){
1715   - if(!th.data.def_pick_store){
  1715 + var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
  1716 + if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
  1717 + if (!th.data.def_pick_store) {
1716 1718 wx.showModal({ title: '请选择门店', });
1717 1719 return false;
1718   - }else{
1719   - e=th.data.def_pick_store.CanOutQty;
  1720 + } else {
  1721 + e = th.data.def_pick_store.CanOutQty;
1720 1722 }
1721 1723 }
1722   - if(!e) e=0;
  1724 + if (!e) e = 0;
1723 1725 //库存不足,不增加
1724   - if(e<t){ wx.showModal({ title: '库存不足', });
1725   - if(e<0) e=0;
1726   - th.setData({ goodsInputNum: e }); return false;
  1726 + if (e < t) {
  1727 + wx.showModal({ title: '库存不足', });
  1728 + if (e < 0) e = 0;
  1729 + th.setData({ goodsInputNum: e }); return false;
1727 1730 }
1728 1731 t > e || 0 == e ? t = e : t < 1 && (t = 1);
1729 1732 th.setData({ goodsInputNum: t });
1730   - th.is_show_more_buy();
  1733 + th.is_show_more_buy();
1731 1734  
1732 1735 })
1733 1736 },
1734 1737  
1735 1738 //----- 检查一下积分购的限购之类的问题 -----
1736   - checkCartNum_inte: function(t) {
  1739 + checkCartNum_inte: function (t) {
1737 1740 var th = this;
1738   - this.get_buy_num(this.data.data, async function() {
1739   -
  1741 + this.get_buy_num(this.data.data, async function () {
  1742 +
1740 1743 //--判断商品是否超出限购--
1741 1744 if (th.data.g_buy_num != null && th.data.data.viplimited > 0) {
1742   -
1743   - var gd_buy_num=th.data.g_buy_num.get(th.data.sele_g.goods_id);
1744   -
  1745 +
  1746 + var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id);
  1747 +
1745 1748 if (t + gd_buy_num > th.data.sele_g.viplimited) {
1746 1749 wx.showModal({
1747 1750 title: '超出商品限购',
1748 1751 });
1749   -
1750   - var num= th.data.sele_g.viplimited-gd_buy_num;
1751   - if(num<0) num=0;
1752   - th.setData({goodsInputNum:num})
  1752 +
  1753 + var num = th.data.sele_g.viplimited - gd_buy_num;
  1754 + if (num < 0) num = 0;
  1755 + th.setData({ goodsInputNum: num })
1753 1756 return false;
1754 1757 }
1755 1758 }
1756   -
  1759 +
1757 1760 //--判断商品是否超出活动限购--
1758 1761 if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) {
1759 1762 if (t + th.data.prom_buy_num > th.data.prom_buy_limit) {
1760 1763 wx.showModal({
1761 1764 title: '超出商品活动限购',
1762 1765 });
1763   -
1764   - var num=th.data.prom_buy_limit- th.data.prom_buy_num ;
1765   - if(num<0) num=0;
1766   - th.setData({goodsInputNum:num})
  1766 +
  1767 + var num = th.data.prom_buy_limit - th.data.prom_buy_num;
  1768 + if (num < 0) num = 0;
  1769 + th.setData({ goodsInputNum: num })
1767 1770 return false;
1768 1771 }
1769 1772 }
1770   -
  1773 +
1771 1774 if (th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) {
1772 1775 var redis_num = 0;
1773 1776 //------判断活动是否抢光-----
1774 1777 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
1775   - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, {
  1778 + os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, {
1776 1779 1: 1
1777 1780 }).then(res => {
1778 1781 redis_num = res.data.data;
1779 1782 });
1780   -
  1783 +
1781 1784 if (t > redis_num) {
1782 1785 wx.showModal({
1783 1786 title: '超出商品活动库存',
1784 1787 });
1785   - th.setData({goodsInputNum:redis_num})
  1788 + th.setData({ goodsInputNum: redis_num })
1786 1789 return false;
1787 1790 }
1788   -
  1791 +
1789 1792 }
1790   -
  1793 +
1791 1794 var e = th.data.sele_g.store_count;
1792   - var p_type=th.data.prom_type; //&& p_type!=1 && p_type!=4
1793   - if(th.data.sales_rules==2 && (p_type!=1 && p_type!=4 && p_type!=6 || th.data.openSpecModal_inte_normal==1 || th.data.is_normal== 1) ){
1794   - if(!th.data.def_pick_store){
  1795 + var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
  1796 + if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
  1797 + if (!th.data.def_pick_store) {
1795 1798 wx.showModal({ title: '请选择门店', });
1796 1799 return false;
1797   - }else{
1798   - e=th.data.def_pick_store.CanOutQty;
  1800 + } else {
  1801 + e = th.data.def_pick_store.CanOutQty;
1799 1802 }
1800 1803 }
1801   - if(!e) e=0;
  1804 + if (!e) e = 0;
1802 1805 //库存不足,不增加
1803   - if(e<t){ wx.showModal({ title: '库存不足', });
1804   - if(e<0) e=0;
1805   - th.setData({ goodsInputNum: e }); return false;
  1806 + if (e < t) {
  1807 + wx.showModal({ title: '库存不足', });
  1808 + if (e < 0) e = 0;
  1809 + th.setData({ goodsInputNum: e }); return false;
1806 1810 }
1807 1811 t > e || 0 == e ? t = e : t < 1 && (t = 1);
1808   - th.setData({ goodsInputNum: t });
  1812 + th.setData({ goodsInputNum: t });
1809 1813 })
1810 1814 },
1811 1815  
1812 1816  
1813   - closeSpecModal: function() {
1814   - if(this.data.openSpecModal_pt && this.data.is_normal){
1815   - this.get_sto();
1816   - this.setData({
1817   - sele_g:this.data.data,
1818   - gid:this.data.data.goods_id
1819   - })
1820   -
1821   - this.sele_spec_chech_activity();
1822   -
1823   - }
1824   -
  1817 + closeSpecModal: function () {
  1818 + if (this.data.openSpecModal_pt && this.data.is_normal) {
  1819 + this.get_sto();
  1820 + this.setData({
  1821 + sele_g: this.data.data,
  1822 + gid: this.data.data.goods_id
  1823 + })
  1824 +
  1825 + this.sele_spec_chech_activity();
  1826 +
  1827 + }
  1828 +
1825 1829 this.setData({
1826 1830 openSpecModal: !1,
1827 1831 openSpecModal_pt: !1
1828 1832 });
1829 1833 },
1830   -
1831   - openSpecModel: function(t) {
1832   - var th=this;
  1834 +
  1835 + openSpecModel: function (t) {
  1836 + var th = this;
1833 1837 var open_store = t.currentTarget.dataset.ind;
1834 1838 this.setData({
1835 1839 store: 0,
... ... @@ -1849,7 +1853,7 @@ Page({
1849 1853 var ind = t.currentTarget.dataset.ind;
1850 1854  
1851 1855 //回调。判断是不是优惠促销
1852   - th.check_is_prom_goods(function (){
  1856 + th.check_is_prom_goods(function () {
1853 1857 th.setData({
1854 1858 openSpecModal: !0,
1855 1859 openSpecModal_ind: ind,
... ... @@ -1858,127 +1862,129 @@ Page({
1858 1862 th.get_off_price();
1859 1863 })
1860 1864 },
1861   -
  1865 +
1862 1866 //判断是不是优惠促销
1863   - check_is_prom_goods:function(callback){
1864   - var th=this;
1865   - var usr=getApp().globalData.userInfo;
1866   - if(this.data.sele_g.prom_type!=0 && this.data.sele_g.prom_type!=3){
1867   - callback();
1868   - }else{
1869   - //-- 判断有没有优惠活动 --
1870   - getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+th.data.sele_g.goods_id+"/0", {}).then(res => {
1871   - if(res.data.code==0){
1872   - var r_data=res.data.data;
1873   - th.data.prom_goods=r_data.promGoodsLists;
1874   - if(!th.data.prom_goods){
1875   - callback();
1876   - return false;
1877   - }
1878   -
1879   - ///api/weshop/order/getWPayOrder?store_id=1&user_id=5682366&prom_id=1&goods_id=1
1880   - getApp().promiseGet("/api/weshop/order/getWPayOrder",{
1881   - data:{store_id:os.stoid,user_id:usr.user_id,goods_id:th.data.sele_g.goods_id,prom_id:th.data.prom_goods[0].prom_id}
1882   - }).then(res=>{
1883   - if(res.data.code==0){
1884   - wx.showToast({
1885   - title: "您已经购买了该商品待支付中",
1886   - icon: 'none',
1887   - duration: 2000
1888   - })
1889   - setTimeout(function (){
1890   - getApp().goto("/pages/user/order_detail/order_detail?order_id=" + res.data.data.order_id,)
1891   - },1000)
1892   - }
1893   - //未找到相关记录
1894   - else{
1895   - callback();
1896   - }
1897   - })
1898   - }
1899   -
1900   - })
1901   -
1902   - }
1903   - },
1904   -
1905   -
1906   -
  1867 + check_is_prom_goods: function (callback) {
  1868 + var th = this;
  1869 + var usr = getApp().globalData.userInfo;
  1870 + if (this.data.sele_g.prom_type != 0 && this.data.sele_g.prom_type != 3) {
  1871 + callback();
  1872 + } else {
  1873 + //-- 判断有没有优惠活动 --
  1874 + getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0", {}).then(res => {
  1875 + if (res.data.code == 0) {
  1876 + var r_data = res.data.data;
  1877 + th.data.prom_goods = r_data.promGoodsLists;
  1878 + if (!th.data.prom_goods) {
  1879 + callback();
  1880 + return false;
  1881 + }
  1882 +
  1883 + ///api/weshop/order/getWPayOrder?store_id=1&user_id=5682366&prom_id=1&goods_id=1
  1884 + getApp().promiseGet("/api/weshop/order/getWPayOrder", {
  1885 + data: { store_id: os.stoid, user_id: usr.user_id, goods_id: th.data.sele_g.goods_id, prom_id: th.data.prom_goods[0].prom_id }
  1886 + }).then(res => {
  1887 + if (res.data.code == 0) {
  1888 + wx.showToast({
  1889 + title: "您已经购买了该商品待支付中",
  1890 + icon: 'none',
  1891 + duration: 2000
  1892 + })
  1893 + setTimeout(function () {
  1894 + getApp().goto("/pages/user/order_detail/order_detail?order_id=" + res.data.data.order_id,)
  1895 + }, 1000)
  1896 + }
  1897 + //未找到相关记录
  1898 + else {
  1899 + callback();
  1900 + }
  1901 + })
  1902 + }
  1903 +
  1904 + })
  1905 +
  1906 + }
  1907 + },
  1908 +
  1909 +
  1910 +
1907 1911 //----获取线下价格-------
1908   - get_off_price(){
1909   - var th=this;
1910   - //没有开启就返回
1911   - if(!th.data.is_open_offline) return false;
1912   - //先看下购买的功能有没有到期
1913   - getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=6",{}).then(res=>{
1914   - //未购买
1915   - if(res.data.code!=0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length){
1916   - return false;
1917   - }else{
1918   - //已经过期
1919   - var item=res.data.data.pageData[0];
1920   - if(item.end_time<ut.gettimestamp()){
1921   - return false;
1922   - }
1923   - }
1924   -
1925   -
1926   - var cur_goods=this.data.sele_g;
1927   - var cur_price=cur_goods.shop_price;
1928   - if(th.data.card_field && cur_goods[th.data.card_field]>0){
1929   - cur_price=cur_goods[th.data.card_field];
1930   - }
1931   -
1932   - var user_info = getApp().globalData.userInfo;
1933   - //获取一下接口,判断是不是有线下接口,必须是普通商品,全局优惠活动也是不行
1934   - if(cur_goods.prom_type==0 && !this.data.prom_goods){
1935   - cur_goods.offline_price=null;
1936   - //如果没有门店,不用计算线下价格
1937   - var def_pick_store=this.data.def_pick_store;
1938   - if(!def_pick_store) return false;
1939   - getApp().request.get("/api/weshop/goods/listWarePrice", {
1940   - data:{VIPId:encodeURIComponent(user_info.erpvipid),
1941   - store_id:os.stoid,
1942   - PickupId:def_pick_store.pickup_id,
1943   - WareIds:encodeURIComponent(cur_goods.erpwareid)},
1944   - success:function(res){
1945   - if(res.data.code==0 && res.data.data && res.data.data.length>0){
1946   - var datalist=res.data.data;
1947   - if(datalist[0].WarePrice<cur_price){
1948   - cur_goods.offline_price=datalist[0].WarePrice; //存储线下活动的价格
1949   - cur_goods.pricing_type=datalist[0].PriceType; //存储线下活动的类型
1950   - }
1951   - }
1952   - th.setData({sele_g:cur_goods});
1953   - }
1954   -
1955   - })
1956   - }
1957   -
1958   - })
1959   -
1960   -
1961   - },
1962   -
1963   -
  1912 + get_off_price() {
  1913 + var th = this;
  1914 + //没有开启就返回
  1915 + if (!th.data.is_open_offline) return false;
  1916 + //先看下购买的功能有没有到期
  1917 + getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=6", {}).then(res => {
  1918 + //未购买
  1919 + if (res.data.code != 0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length) {
  1920 + return false;
  1921 + } else {
  1922 + //已经过期
  1923 + var item = res.data.data.pageData[0];
  1924 + if (item.end_time < ut.gettimestamp()) {
  1925 + return false;
  1926 + }
  1927 + }
  1928 +
  1929 +
  1930 + var cur_goods = this.data.sele_g;
  1931 + var cur_price = cur_goods.shop_price;
  1932 + if (th.data.card_field && cur_goods[th.data.card_field] > 0) {
  1933 + cur_price = cur_goods[th.data.card_field];
  1934 + }
  1935 +
  1936 + var user_info = getApp().globalData.userInfo;
  1937 + //获取一下接口,判断是不是有线下接口,必须是普通商品,全局优惠活动也是不行
  1938 + if (cur_goods.prom_type == 0 && !this.data.prom_goods) {
  1939 + cur_goods.offline_price = null;
  1940 + //如果没有门店,不用计算线下价格
  1941 + var def_pick_store = this.data.def_pick_store;
  1942 + if (!def_pick_store) return false;
  1943 + getApp().request.get("/api/weshop/goods/listWarePrice", {
  1944 + data: {
  1945 + VIPId: encodeURIComponent(user_info.erpvipid),
  1946 + store_id: os.stoid,
  1947 + PickupId: def_pick_store.pickup_id,
  1948 + WareIds: encodeURIComponent(cur_goods.erpwareid)
  1949 + },
  1950 + success: function (res) {
  1951 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  1952 + var datalist = res.data.data;
  1953 + if (datalist[0].WarePrice < cur_price) {
  1954 + cur_goods.offline_price = datalist[0].WarePrice; //存储线下活动的价格
  1955 + cur_goods.pricing_type = datalist[0].PriceType; //存储线下活动的类型
  1956 + }
  1957 + }
  1958 + th.setData({ sele_g: cur_goods });
  1959 + }
  1960 +
  1961 + })
  1962 + }
  1963 +
  1964 + })
  1965 +
  1966 +
  1967 + },
  1968 +
  1969 +
1964 1970 //---------点击收藏和不收藏------------
1965   - collectGoods: function() {
  1971 + collectGoods: function () {
1966 1972 var t = this,
1967   - i = getApp().request;
  1973 + i = getApp().request;
1968 1974 var user_id = s.globalData.user_id;
1969 1975 if (user_id == '') {
1970   - getApp().getUserFir(function() {});
  1976 + getApp().getUserFir(function () { });
1971 1977 getApp().showWarning("未登录");
1972 1978 return false;
1973 1979 } else {
1974 1980  
1975   - if(t.data.is_collect_load) return false;
1976   - t.data.is_collect_load=1;
  1981 + if (t.data.is_collect_load) return false;
  1982 + t.data.is_collect_load = 1;
1977 1983  
1978 1984 if (t.data.is_collect == 1) { //删除收藏
1979 1985 i.delete("/api/weshop/goodscollect/del/" + o.stoid + "/" + t.data.collect_id, {
1980   - success: function(e) {
1981   - t.data.is_collect_load=0;
  1986 + success: function (e) {
  1987 + t.data.is_collect_load = 0;
1982 1988 if (e.data.code == 0) {
1983 1989 t.setData({
1984 1990 is_collect: 0,
... ... @@ -1997,15 +2003,15 @@ Page({
1997 2003 add_time: timestamp,
1998 2004 };
1999 2005 //加入收藏夹就是导购的ID
2000   - if(getApp().globalData.guide_id){
2001   - d.guide_id=getApp().globalData.guide_id;
2002   - d.guide_type=2;
  2006 + if (getApp().globalData.guide_id) {
  2007 + d.guide_id = getApp().globalData.guide_id;
  2008 + d.guide_type = 2;
2003 2009 }
2004 2010  
2005 2011 i.post("/api/weshop/goodscollect/save", { //添加收藏
2006 2012 data: d,
2007   - success: function(e) {
2008   - t.data.is_collect_load=0;
  2013 + success: function (e) {
  2014 + t.data.is_collect_load = 0;
2009 2015 if (e.data.code == 0) {
2010 2016 t.setData({
2011 2017 is_collect: 1,
... ... @@ -2019,13 +2025,13 @@ Page({
2019 2025 },
2020 2026  
2021 2027 //---------联系客服------------
2022   - contactService: function() {
2023   - s.getConfig(function(t) {
  2028 + contactService: function () {
  2029 + s.getConfig(function (t) {
2024 2030 if (t.store_tel == undefined) {
2025 2031 getApp().request.get("/api/weshop/store/get/" + os.stoid, {
2026 2032 isShowLoading: 1,
2027 2033 data: {},
2028   - success: function(rs) {
  2034 + success: function (rs) {
2029 2035 getApp().globalData.config = rs.data.data;
2030 2036 if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) {
2031 2037 getApp().my_warnning("商家未设置电话", 0, th);
... ... @@ -2040,44 +2046,44 @@ Page({
2040 2046 });
2041 2047 },
2042 2048 //-------获取购物车数量----------
2043   - requestCardNum: function() {
  2049 + requestCardNum: function () {
2044 2050 var t = this;
2045 2051 getApp().request.get("/api/weshop/cart/page", {
2046 2052 data: {
2047 2053 store_id: o.stoid,
2048 2054 user_id: s.globalData.user_id,
2049   - state:0,
2050   - is_gift:0
  2055 + state: 0,
  2056 + is_gift: 0
2051 2057 },
2052   - success: function(e) {
  2058 + success: function (e) {
2053 2059 var num = 0;
2054 2060 for (var i = 0; i < e.data.data.pageData.length; i++) {
2055 2061 num += e.data.data.pageData[i].goods_num;
2056 2062 }
2057 2063  
2058 2064 //-- 读取服务卡的数量 --
2059   - getApp().promiseGet("/api/weshop/cartService/page",{
2060   - data:{
  2065 + getApp().promiseGet("/api/weshop/cartService/page", {
  2066 + data: {
2061 2067 store_id: s.globalData.setting.stoid,
2062 2068 user_id: s.globalData.user_id,
2063 2069 }
2064   - }).then(res=>{
  2070 + }).then(res => {
2065 2071 for (var i = 0; i < res.data.data.pageData.length; i++) {
2066 2072 num += res.data.data.pageData[i].goods_num;
2067 2073 }
2068   - t.setData({cartGoodsNum:num});
  2074 + t.setData({ cartGoodsNum: num });
2069 2075 })
2070 2076 }
2071 2077 });
2072 2078 },
2073 2079  
2074   - previewCommentImgs: function(t) {
  2080 + previewCommentImgs: function (t) {
2075 2081 var e = this.data.comments[t.currentTarget.dataset.cidx].img;
2076 2082 var b = e.slice()
2077   - for(var i in b){
  2083 + for (var i in b) {
2078 2084 b[i] = this.data.iurl + e[i];
2079 2085 }
2080   - this.data.show_prew_img=1;
  2086 + this.data.show_prew_img = 1;
2081 2087  
2082 2088 wx.previewImage({
2083 2089 current: b[t.currentTarget.dataset.id],
... ... @@ -2085,106 +2091,106 @@ Page({
2085 2091 });
2086 2092 },
2087 2093  
2088   - previewCommentImgs_w: function(t) {
  2094 + previewCommentImgs_w: function (t) {
2089 2095 var e = this.data.comments[t.currentTarget.dataset.cidx].weapp_img;
2090 2096 var b = e.slice()
2091 2097 for (var i in b) {
2092 2098 b[i] = this.data.iurl + e[i];
2093 2099 }
2094   - this.data.show_prew_img=1;
  2100 + this.data.show_prew_img = 1;
2095 2101 wx.previewImage({
2096 2102 current: b[t.currentTarget.dataset.id],
2097 2103 urls: b
2098 2104 });
2099 2105 },
2100 2106  
2101   - previewGoodsCommentImgs: function(t) {
  2107 + previewGoodsCommentImgs: function (t) {
2102 2108 var e = this,
2103   - a = this.data.data.comment[t.currentTarget.dataset.cidx].img;
2104   - a = a.map(function(t) {
  2109 + a = this.data.data.comment[t.currentTarget.dataset.cidx].img;
  2110 + a = a.map(function (t) {
2105 2111 return e.data.url + t;
2106 2112 }), wx.previewImage({
2107 2113 current: a[t.currentTarget.dataset.id],
2108 2114 urls: a
2109 2115 });
2110   - this.data.show_prew_img=1;
  2116 + this.data.show_prew_img = 1;
2111 2117 },
2112   - closePromModal: function() {
  2118 + closePromModal: function () {
2113 2119 this.setData({
2114 2120 openPromModal: !1
2115 2121 });
2116 2122 },
2117   - openPromModal: function() {
  2123 + openPromModal: function () {
2118 2124 this.setData({
2119 2125 openPromModal: !0
2120 2126 });
2121 2127 },
2122 2128  
2123 2129 //--点击分享事件---
2124   - onShareAppMessage: function(t) {
2125   -
  2130 + onShareAppMessage: function (t) {
  2131 +
2126 2132 var th = this;
2127 2133 var price = th.data.data.shop_price;
2128 2134 if (th.data.prom_act) {
2129 2135 price = th.data.prom_act.price;
2130 2136  
2131 2137 }
2132   - var title= th.data.data.goods_name;
2133   - var img=th.data.data.original_img;
2134   - if(th.data.prom_type==6 || th.data.prom_type==1 || th.data.prom_type==4){
2135   - title=th.data.prom_act.share_title;
2136   - if(!title) title=th.data.prom_act.title;
2137   - if(th.data.prom_type==4) title=th.data.prom_act.name;
2138   -
2139   - if(th.data.prom_act.share_imgurl)
2140   - img=th.data.iurl+th.data.prom_act.share_imgurl;
  2138 + var title = th.data.data.goods_name;
  2139 + var img = th.data.data.original_img;
  2140 + if (th.data.prom_type == 6 || th.data.prom_type == 1 || th.data.prom_type == 4) {
  2141 + title = th.data.prom_act.share_title;
  2142 + if (!title) title = th.data.prom_act.title;
  2143 + if (th.data.prom_type == 4) title = th.data.prom_act.name;
  2144 +
  2145 + if (th.data.prom_act.share_imgurl)
  2146 + img = th.data.iurl + th.data.prom_act.share_imgurl;
  2147 + }
  2148 +
  2149 +
  2150 + var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + th.data.gid;
  2151 + if (getApp().globalData.user_id) {
  2152 + url += "&first_leader=" + getApp().globalData.user_id;
2141 2153 }
2142 2154  
2143   -
2144   - var url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + th.data.gid;
2145   - if(getApp().globalData.user_id){
2146   - url+="&first_leader="+getApp().globalData.user_id;
  2155 + //-- 如果房间分享,且不是会员分享的 --
  2156 + if (getApp().globalData.room_id &&
  2157 + th.data.data.goods_id == getApp().globalData.room_goods_id &&
  2158 + !getApp().globalData.room_user_share
  2159 + ) {
  2160 + url += "&room_id=" + getApp().globalData.room_id + "&room_user_share=1";
2147 2161 }
2148   -
2149   - //-- 如果房间分享,且不是会员分享的 --
2150   - if(getApp().globalData.room_id &&
2151   - th.data.data.goods_id==getApp().globalData.room_goods_id &&
2152   - !getApp().globalData.room_user_share
2153   - ){
2154   - url+="&room_id="+getApp().globalData.room_id+"&room_user_share=1";
2155   - }
2156   -
2157   - var ob={
2158   - title: price + "元 " +title,
2159   - path:url,
  2162 +
  2163 + var ob = {
  2164 + title: price + "元 " + title,
  2165 + path: url,
2160 2166 imageUrl: img,
2161   - };
2162   - if(th.data.prom_type==6){
2163   - title+='\n'+th.data.prom_act.share_remark;
2164   - ob.title=title;
2165   - ob.desc=th.data.prom_act.share_remark;
2166   - }
2167   -
2168   - //如果是积分购的时候
2169   - if(th.data.prom_type==4){
2170   - var name = th.data.prom_act.name;
2171   - //-- 积分购的 --
2172   - var pri0 = th.data.prom_act.addmoney;
2173   - var integral=th.data.prom_act.integral;
2174   - var text="";
2175   - if(integral){text=integral+"积分"; }
2176   - if(pri0 && integral){ text+="+";}
2177   - if(pri0){ text+="¥"+pri0;}
2178   -
2179   - ob.title= text+" "+name;
2180   - }
2181   -
  2167 + };
  2168 + if (th.data.prom_type == 6) {
  2169 + title += '\n' + th.data.prom_act.share_remark;
  2170 + ob.title = title;
  2171 + ob.desc = th.data.prom_act.share_remark;
  2172 + }
  2173 +
  2174 + //如果是积分购的时候
  2175 + if (th.data.prom_type == 4) {
  2176 + var name = th.data.prom_act.name;
  2177 + //-- 积分购的 --
  2178 + var pri0 = th.data.prom_act.addmoney;
  2179 + var integral = th.data.prom_act.integral;
  2180 + var text = "";
  2181 + if (integral) { text = integral + "积分"; }
  2182 + if (pri0 && integral) { text += "+"; }
  2183 + if (pri0) { text += "¥" + pri0; }
  2184 +
  2185 + ob.title = text + " " + name;
  2186 + }
  2187 +
2182 2188 return ob;
2183   -
  2189 +
2184 2190 },
2185 2191  
2186 2192 //-----图片失败,默认图片-----
2187   - bind_bnerr: function(e) {
  2193 + bind_bnerr: function (e) {
2188 2194 var _errImg = e.target.dataset.errorimg;
2189 2195 var _errObj = {};
2190 2196 _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif";
... ... @@ -2192,7 +2198,7 @@ Page({
2192 2198 },
2193 2199  
2194 2200 //-----图片失败,默认图片-----
2195   - bind_bnerr2: function(e) {
  2201 + bind_bnerr2: function (e) {
2196 2202  
2197 2203 var _errImg = e.target.dataset.errorimg;
2198 2204 var _errObj = {};
... ... @@ -2202,76 +2208,79 @@ Page({
2202 2208  
2203 2209 //----------装载同一条形码的商品----------
2204 2210 async get_sku(stoid, gd, g_id, is_normal, func) {
2205   - var tt = this,arrdata=null;
2206   - var now=ut.gettimestamp();
  2211 + console.log('get_sku');
  2212 + var tt = this, arrdata = null;
  2213 + var now = ut.gettimestamp();
2207 2214 await getApp().request.promiseGet("/api/weshop/goods/page", {
2208 2215 data: {
2209 2216 store_id: o.stoid,
2210 2217 sku: gd.sku,
2211   - more_spec:gd.more_spec,
  2218 + more_spec: gd.more_spec,
2212 2219 isonsale: 1,
2213 2220 is_on_sale: 1,
2214   - pageSize:500,
2215   - orderField: 'sort'
  2221 + pageSize: 500,
  2222 + orderField: 'sort'
2216 2223 }
2217 2224 }).then(res => {
2218 2225 var e = res;
2219 2226 if (e.data.code == 0) arrdata = e.data.data.pageData;
2220 2227 })
2221   - if(!arrdata) return false;
  2228 + if (!arrdata) return false;
2222 2229  
2223 2230 var arrsku = new Array();
2224 2231 var gitem = null;
2225   - var gb = 1,gg = "";
  2232 + var gb = 1, gg = "";
2226 2233 for (var i = 0; i < arrdata.length; i++) {
2227   - var goodsinfo=arrdata[i],prom=null;
  2234 + var goodsinfo = arrdata[i], prom = null;
2228 2235 if (goodsinfo.goods_id != g_id) {
2229   -
2230   - switch(goodsinfo.prom_type){
2231   - case 1:
2232   - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+goodsinfo.prom_id,{
2233   - }).then(res=>{
2234   - if(res.data.code==0) prom=res.data.data;
2235   - })
2236   -
2237   - break;
2238   - case 6:
2239   - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{
2240   - }).then(res=>{
2241   - if(res.data.code==0) prom=res.data.data;
2242   - })
2243   -
2244   - break;
2245   - case 2:
2246   - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/"+os.stoid+"/"+goodsinfo.goods_id+"/"+goodsinfo.prom_id,{
2247   - }).then(res=>{
2248   - if(res.data.code==0) prom=res.data.data;
2249   - })
2250   - break;
2251   - case 4:
2252   - await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/"+os.stoid+"/"+goodsinfo.goods_id+"/"+goodsinfo.prom_id,{
2253   - }).then(res=>{
2254   - if(res.data.code==0) prom=res.data.data;
2255   - })
2256   - break
2257   -
2258   - }
2259   -
2260   -
  2236 +
  2237 + switch (goodsinfo.prom_type) {
  2238 + case 1:
  2239 + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {
  2240 + }).then(res => {
  2241 + if (res.data.code == 0) prom = res.data.data;
  2242 + })
  2243 +
  2244 + break;
  2245 + case 6:
  2246 + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {
  2247 + }).then(res => {
  2248 + console.log(res);
  2249 + if (res.data.code == 0) prom = res.data.data;
  2250 + })
  2251 +
  2252 + break;
  2253 + case 2:
  2254 + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {
  2255 + }).then(res => {
  2256 + if (res.data.code == 0) prom = res.data.data;
  2257 + })
  2258 + break;
  2259 + case 4:
  2260 + await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {
  2261 + }).then(res => {
  2262 + if (res.data.code == 0) prom = res.data.data;
  2263 + })
  2264 + break
  2265 +
  2266 + }
  2267 +
  2268 +
2261 2269 }
2262 2270 //---如果有活动,不算在一起---
2263   - if(prom){
2264   - if(goodsinfo.prom_type==1 || goodsinfo.prom_type==6){
2265   - if(prom.is_end==0 && prom.end_time>now && prom.start_time<now) continue;
2266   - }else{
2267   - continue;
2268   - }
  2271 + if (prom) {
  2272 + if (goodsinfo.prom_type == 1 || goodsinfo.prom_type == 6) {
  2273 + console.log(prom);
  2274 + if (prom.is_end == 0 && prom.end_time > now && prom.start_time < now) continue;
  2275 + } else {
  2276 + continue;
  2277 + }
2269 2278 }
2270   -
2271 2279  
2272   - var item = arrdata[i],gg = "";
2273   - if(item.goods_spec=="null" || item.goods_spec==null) item.goods_spec="";
2274   - if(item.goods_color=="null" || item.goods_color==null) item.goods_color="";
  2280 +
  2281 + var item = arrdata[i], gg = "";
  2282 + if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = "";
  2283 + if (item.goods_color == "null" || item.goods_color == null) item.goods_color = "";
2275 2284  
2276 2285 if (item.goods_spec != "" && item.goods_color != "") {
2277 2286 gg = item.goods_spec + "/" + item.goods_color;
... ... @@ -2283,10 +2292,10 @@ Page({
2283 2292 }
2284 2293 item.gg = gg;
2285 2294  
2286   - if(item.spec_img)
2287   - item.original_img=os.imghost+item.spec_img;
  2295 + if (item.spec_img)
  2296 + item.original_img = os.imghost + item.spec_img;
2288 2297 else
2289   - item.original_img=os.imghost+item.original_img;
  2298 + item.original_img = os.imghost + item.original_img;
2290 2299  
2291 2300  
2292 2301 if (item.goods_id == g_id) {
... ... @@ -2312,16 +2321,16 @@ Page({
2312 2321 },
2313 2322  
2314 2323 //-----------选择属性的按钮事件----------
2315   - sele_spec: function(e) {
2316   - var that=this,ee=this,th=this;
  2324 + sele_spec: function (e) {
  2325 + var that = this, ee = this, th = this;
2317 2326 var gid = e.currentTarget.dataset.gid;
2318   - var nor=e.currentTarget.dataset.nor;
2319   -
  2327 + var nor = e.currentTarget.dataset.nor;
  2328 +
2320 2329 var sku_g = this.data.sku_g;
2321   - if(nor){
2322   - sku_g = this.data.sku_g_pt;
2323   - }
2324   -
  2330 + if (nor) {
  2331 + sku_g = this.data.sku_g_pt;
  2332 + }
  2333 +
2325 2334 var item = null;
2326 2335 for (var i in sku_g) {
2327 2336 if (sku_g[i].goods_id == gid) {
... ... @@ -2333,41 +2342,41 @@ Page({
2333 2342 sele_g: item,
2334 2343 gid: gid
2335 2344 });
2336   -
2337   -
2338 2345  
2339   - that.check_is_youhui(gid,that.data.is_normal);
2340   -
2341   - var ty=0;
  2346 +
  2347 +
  2348 + that.check_is_youhui(gid, that.data.is_normal);
  2349 +
  2350 + var ty = 0;
2342 2351 this.get_sto(that.data.is_normal);
2343   -
2344   -
  2352 +
  2353 +
2345 2354 //默认门店要拿下门店库存
2346   - if(that.data.sales_rules==2 && that.data.def_pick_store){
2347   - var lock=0,plist=null;
  2355 + if (that.data.sales_rules == 2 && that.data.def_pick_store) {
  2356 + var lock = 0, plist = null;
2348 2357 //先读取门店的lock,采用链式写法,少用await
2349   - getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
2350   - data:{store_id:os.stoid,wareId:ee.data.sele_g.goods_id,storageId:that.data.def_pick_store.pickup_id,pageSize:1000}
2351   - }).then(res=>{
2352   - if(res.data.code==0 && res.data.data.total>0){
2353   - for(var i in res.data.data.pageData)
2354   - lock+=res.data.data.pageData[i].outQty
  2358 + getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
  2359 + data: { store_id: os.stoid, wareId: ee.data.sele_g.goods_id, storageId: that.data.def_pick_store.pickup_id, pageSize: 1000 }
  2360 + }).then(res => {
  2361 + if (res.data.code == 0 && res.data.data.total > 0) {
  2362 + for (var i in res.data.data.pageData)
  2363 + lock += res.data.data.pageData[i].outQty
2355 2364 }
2356 2365 //---通过接口获取门店的线下库存信息--
2357   - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
2358   - data:{storageNos:that.data.def_pick_store.pickup_no,wareIds:encodeURIComponent(th.data.sele_g.erpwareid),storeId:os.stoid}
  2366 + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
  2367 + data: { storageNos: that.data.def_pick_store.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid }
2359 2368 })
2360   - }).then(res=>{
2361   - if(res.data.code==0 && res.data.data.total>0){
2362   - plist=res.data.data.pageData[0];
  2369 + }).then(res => {
  2370 + if (res.data.code == 0 && res.data.data.total > 0) {
  2371 + plist = res.data.data.pageData[0];
2363 2372 }
2364   - if(plist && plist.CanOutQty-lock>0){
2365   - that.data.def_pick_store.CanOutQty=plist.CanOutQty-lock;
2366   - }else{
2367   - that.data.def_pick_store.CanOutQty=0;
  2373 + if (plist && plist.CanOutQty - lock > 0) {
  2374 + that.data.def_pick_store.CanOutQty = plist.CanOutQty - lock;
  2375 + } else {
  2376 + that.data.def_pick_store.CanOutQty = 0;
2368 2377 }
2369 2378 //--给门店赋值线下库存--
2370   - th.setData({def_pick_store:that.data.def_pick_store});
  2379 + th.setData({ def_pick_store: that.data.def_pick_store });
2371 2380 })
2372 2381 }
2373 2382  
... ... @@ -2376,58 +2385,58 @@ Page({
2376 2385 },
2377 2386  
2378 2387 //选择了不同的规格的时候要判断是不是有活动正在进行中
2379   - async sele_spec_chech_activity(){
  2388 + async sele_spec_chech_activity() {
2380 2389 //---如果是活动的时候---
2381   - var prom=null,goodsinfo=this.data.sele_g,th=this;
2382   - if(goodsinfo.prom_type==1){
2383   - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+goodsinfo.prom_id,{
2384   - }).then(res=>{
2385   - if(res.data.code==0){
2386   - prom=res.data.data;
  2390 + var prom = null, goodsinfo = this.data.sele_g, th = this;
  2391 + if (goodsinfo.prom_type == 1) {
  2392 + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {
  2393 + }).then(res => {
  2394 + if (res.data.code == 0) {
  2395 + prom = res.data.data;
  2396 + }
  2397 + })
  2398 + }
  2399 + if (goodsinfo.prom_type == 6) {
  2400 + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {
  2401 + }).then(res => {
  2402 + if (res.data.code == 0) {
  2403 + prom = res.data.data;
2387 2404 }
2388 2405 })
2389 2406 }
2390   - if(goodsinfo.prom_type==6){
2391   - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{
2392   - }).then(res=>{
2393   - if(res.data.code==0){
2394   - prom=res.data.data;
  2407 +
  2408 + if (goodsinfo.prom_type == 4) {
  2409 + await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {
  2410 + }).then(res => {
  2411 + if (res.data.code == 0) {
  2412 + prom = res.data.data;
2395 2413 }
2396 2414 })
2397 2415 }
2398   -
2399   - if(goodsinfo.prom_type==4){
2400   - await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/"+os.stoid+"/"+goodsinfo.goods_id+"/"+goodsinfo.prom_id,{
2401   - }).then(res=>{
2402   - if(res.data.code==0){
2403   - prom=res.data.data;
2404   - }
2405   - })
2406   - }
2407   -
  2416 +
2408 2417 //----------如果有活动,并且在进行中,就不计算线下库存---------------
2409   - var now=ut.gettimestamp();
2410   - if(prom){
2411   - if(prom.is_end==0 && prom.end_time>now && prom.start_time<now){
  2418 + var now = ut.gettimestamp();
  2419 + if (prom) {
  2420 + if (prom.is_end == 0 && prom.end_time > now && prom.start_time < now) {
2412 2421 th.setData({
2413   - prom_type:goodsinfo.prom_type,
2414   - prom_price:prom.price,
2415   - prom_buy_limit:prom.buy_limit,
2416   - prom_end_time:prom.end_time,
2417   - prom_start_time:prom.start_time,
2418   - prom_st:1,
  2422 + prom_type: goodsinfo.prom_type,
  2423 + prom_price: prom.price,
  2424 + prom_buy_limit: prom.buy_limit,
  2425 + prom_end_time: prom.end_time,
  2426 + prom_start_time: prom.start_time,
  2427 + prom_st: 1,
2419 2428 })
2420 2429 return false;
2421 2430 }
2422 2431 }
2423 2432 //---设置普通商品---
2424 2433 th.setData({
2425   - prom_type:0,
2426   - prom_price:null,
2427   - prom_buy_limit:null,
2428   - prom_end_time:null,
2429   - prom_start_time:null,
2430   - prom_st:null,
  2434 + prom_type: 0,
  2435 + prom_price: null,
  2436 + prom_buy_limit: null,
  2437 + prom_end_time: null,
  2438 + prom_start_time: null,
  2439 + prom_st: null,
2431 2440 })
2432 2441  
2433 2442 },
... ... @@ -2435,20 +2444,20 @@ Page({
2435 2444  
2436 2445 //---------拿出门店分类和门店------------
2437 2446 get_sto(e) {
2438   - var th = this,that=this;
2439   - var is_normal=e;
2440   -
2441   - if(e==1){
2442   - th.setData({is_normal:1})
2443   - }else{
2444   - th.setData({is_normal:0})
2445   - }
2446   -
2447   - var timer_get = setInterval(function() {
  2447 + var th = this, that = this;
  2448 + var is_normal = e;
  2449 +
  2450 + if (e == 1) {
  2451 + th.setData({ is_normal: 1 })
  2452 + } else {
  2453 + th.setData({ is_normal: 0 })
  2454 + }
  2455 +
  2456 + var timer_get = setInterval(function () {
2448 2457 if (th.data.is_get_local_ok == 0) return false;
2449   - var dd = null,i = getApp().request;
2450   - if (!th.data.sele_g) return false;
2451   -
  2458 + var dd = null, i = getApp().request;
  2459 + if (!th.data.sele_g) return false;
  2460 +
2452 2461 var g_distr_type = th.data.sele_g.distr_type;
2453 2462 if (g_distr_type != 0) {
2454 2463 dd = {
... ... @@ -2470,52 +2479,52 @@ Page({
2470 2479 dd.lon = th.data.lon;
2471 2480 }
2472 2481 clearInterval(timer_get);
2473   -
2474   - //如果会员是有默认的门店话
2475   - if(!th.data.def_pick_store && th.data.fir_def_store){
2476   - th.setData({def_pick_store:th.data.fir_def_store});
2477   - }
2478   -
2479   - /*--最新的,不用这里筛选配送方式
2480   - if(th.data.def_pick_store && g_distr_type!=0 && th.data.def_pick_store.distr_type!=0 && th.data.def_pick_store.distr_type!=g_distr_type ){
2481   - th.setData({def_pick_store:null});
2482   - }--*/
2483   -
2484   -
2485   - wx.showLoading({
2486   - title:'加载中.'
2487   - });
  2482 +
  2483 + //如果会员是有默认的门店话
  2484 + if (!th.data.def_pick_store && th.data.fir_def_store) {
  2485 + th.setData({ def_pick_store: th.data.fir_def_store });
  2486 + }
  2487 +
  2488 + /*--最新的,不用这里筛选配送方式
  2489 + if(th.data.def_pick_store && g_distr_type!=0 && th.data.def_pick_store.distr_type!=0 && th.data.def_pick_store.distr_type!=g_distr_type ){
  2490 + th.setData({def_pick_store:null});
  2491 + }--*/
  2492 +
  2493 +
  2494 + wx.showLoading({
  2495 + title: '加载中.'
  2496 + });
2488 2497 //----------获取门店----------------
2489 2498 getApp().request.promiseGet("/api/weshop/pickup/list", {
2490 2499 data: dd,
2491 2500 }).then(res => {
2492 2501 var e = res;
2493   -
2494   - if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length>0) {
2495   -
2496   - var his_cate_num=0;
2497   - for(let i in e.data.data.pageData){
2498   - let item=e.data.data.pageData[i];
2499   - if(item.category_id>0){
2500   - his_cate_num=1;break;
  2502 +
  2503 + if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) {
  2504 +
  2505 + var his_cate_num = 0;
  2506 + for (let i in e.data.data.pageData) {
  2507 + let item = e.data.data.pageData[i];
  2508 + if (item.category_id > 0) {
  2509 + his_cate_num = 1; break;
2501 2510 }
2502 2511 }
2503   - e.his_cate_num=his_cate_num;
  2512 + e.his_cate_num = his_cate_num;
2504 2513  
2505 2514  
2506 2515 //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店
2507   - if(dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store)=='{}') && th.data.bconfig && th.data.bconfig.is_sort_storage){
  2516 + if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) {
2508 2517 th.setData({
2509   - def_pick_store:e.data.data.pageData[0],
  2518 + def_pick_store: e.data.data.pageData[0],
2510 2519 sto_sele_name: e.data.data.pageData[0].pickup_name,
2511 2520 sto_sele_id: e.data.data.pageData[0].pickup_id,
2512 2521 sto_sele_distr: e.data.data.pageData[0].distr_type
2513 2522 });
2514   - th.data.fir_def_store=e.data.data.pageData[0];
  2523 + th.data.fir_def_store = e.data.data.pageData[0];
2515 2524 }
2516 2525  
2517 2526 //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 --
2518   - if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store)!='{}'){
  2527 + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}') {
2519 2528 for (var k = 0; k < e.data.data.pageData.length; k++) {
2520 2529 if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) {
2521 2530 e.data.data.pageData.splice(k, 1); //删除
... ... @@ -2526,17 +2535,17 @@ Page({
2526 2535 }
2527 2536  
2528 2537  
2529   - th.setData({all_pick_list:e.data.data.pageData});
  2538 + th.setData({ all_pick_list: e.data.data.pageData });
2530 2539  
2531 2540 //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购--
2532   - if(th.data.sales_rules==2 && !th.data.is_newsales_rules && ((th.data.prom_type!=1 && th.data.prom_type!=6 && th.data.prom_type!=4) || is_normal==1)){
2533   - setTimeout(function(){
  2541 + if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4) || is_normal == 1)) {
  2542 + setTimeout(function () {
2534 2543 th.deal_pickup_dline(e);
2535   - },800)
2536   - }else{
2537   - setTimeout(function(){
  2544 + }, 800)
  2545 + } else {
  2546 + setTimeout(function () {
2538 2547 th.deal_pickup(e); //--普通门店排版--
2539   - },800)
  2548 + }, 800)
2540 2549 }
2541 2550 }
2542 2551 })
... ... @@ -2544,29 +2553,29 @@ Page({
2544 2553  
2545 2554 },
2546 2555  
2547   -
  2556 +
2548 2557 //------------处理门店---------------
2549   - deal_pickup(e){
2550   - var th=this;
2551   - if(!th.data.sele_g) return false
2552   -
2553   - var g_distr_type=th.data.sele_g.distr_type;
2554   - wx.hideLoading();
  2558 + deal_pickup(e) {
  2559 + var th = this;
  2560 + if (!th.data.sele_g) return false
  2561 +
  2562 + var g_distr_type = th.data.sele_g.distr_type;
  2563 + wx.hideLoading();
2555 2564  
2556 2565 //单总量超出10个的时候,同时门店有分类
2557   - if (e.data.data.total > 10 && e.his_cate_num ) {
  2566 + if (e.data.data.total > 10 && e.his_cate_num) {
2558 2567 getApp().request.get("/api/weshop/storagecategory/page", {
2559 2568 data: {
2560 2569 store_id: o.stoid,
2561 2570 is_show: 1,
2562 2571 pageSize: 1000,
2563   - orderField:"sort",
2564   - orderType:'asc',
  2572 + orderField: "sort",
  2573 + orderType: 'asc',
2565 2574 },
2566   - success: function(ee) {
  2575 + success: function (ee) {
2567 2576 if (ee.data.code == 0) {
2568   -
2569   - if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) {
  2577 +
  2578 + if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) {
2570 2579 var def_arr = new Array();
2571 2580 var ishas = 0;
2572 2581 //-- 开始就看5个门店 --
... ... @@ -2587,7 +2596,7 @@ Page({
2587 2596 //----要进行门店分组--------
2588 2597 for (var i = 0; i < sto_arr.length; i++) {
2589 2598 //找一下这个门店有没有在分类数组内
2590   - var find2 = 0, find2name = "",sort=0;
  2599 + var find2 = 0, find2name = "", sort = 0;
2591 2600 for (var m = 0; m < sto_cate.length; m++) {
2592 2601 if (sto_arr[i].category_id == sto_cate[m].cat_id) {
2593 2602 find2 = sto_cate[m].cat_id;
... ... @@ -2614,7 +2623,7 @@ Page({
2614 2623 var item = {
2615 2624 cat_id: find2,
2616 2625 name: find2name,
2617   - sort:sort,
  2626 + sort: sort,
2618 2627 s_arr: arr0
2619 2628 };
2620 2629 newarr.push(item);
... ... @@ -2630,7 +2639,7 @@ Page({
2630 2639 var item = {
2631 2640 cat_id: find2,
2632 2641 name: find2name,
2633   - sort:sort,
  2642 + sort: sort,
2634 2643 s_arr: arr0
2635 2644 };
2636 2645 newarr.push(item);
... ... @@ -2639,18 +2648,18 @@ Page({
2639 2648 }
2640 2649 }
2641 2650 }
2642   -
2643   - //门店分类要排序下
2644   - function compare(property){
2645   - return function(a,b){
2646   - var value1 = a[property];
2647   - var value2 = b[property];
2648   - return value1 - value2;
2649   - }
2650   - }
2651   - if(newarr.length>0)
2652   - newarr.sort(compare("sort"));
2653   -
  2651 +
  2652 + //门店分类要排序下
  2653 + function compare(property) {
  2654 + return function (a, b) {
  2655 + var value1 = a[property];
  2656 + var value2 = b[property];
  2657 + return value1 - value2;
  2658 + }
  2659 + }
  2660 + if (newarr.length > 0)
  2661 + newarr.sort(compare("sort"));
  2662 +
2654 2663  
2655 2664 //----安排其他的分类-----
2656 2665 if (qita.length > 0) {
... ... @@ -2661,7 +2670,7 @@ Page({
2661 2670 };
2662 2671 newarr.push(item);
2663 2672 }
2664   -
  2673 +
2665 2674 th.setData({
2666 2675 is_show_sto_cat: 1,
2667 2676 all_sto: newarr
... ... @@ -2674,7 +2683,7 @@ Page({
2674 2683 });
2675 2684 //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
2676 2685 if (!th.data.def_pick_store) {
2677   - th.setData({def_pick_store:e.data.data.pageData[0]})
  2686 + th.setData({ def_pick_store: e.data.data.pageData[0] })
2678 2687 }
2679 2688 }
2680 2689 } else {
... ... @@ -2684,13 +2693,13 @@ Page({
2684 2693 });
2685 2694 //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
2686 2695 if (!th.data.def_pick_store) {
2687   - th.setData({def_pick_store:e.data.data.pageData[0]})
  2696 + th.setData({ def_pick_store: e.data.data.pageData[0] })
2688 2697 }
2689 2698  
2690 2699 }
2691 2700 }
2692 2701 });
2693   - } else {
  2702 + } else {
2694 2703 th.setData({
2695 2704 is_show_sto_cat: 0,
2696 2705 only_pk: e.data.data.pageData
... ... @@ -2698,7 +2707,7 @@ Page({
2698 2707 //-----如果没有默认门店,要取第一个门店作为默认店------
2699 2708 if (!th.data.def_pick_store && th.data.bconfig && th.data.bconfig.is_sort_storage) {
2700 2709 th.setData({
2701   - def_pick_store:e.data.data.pageData[0],
  2710 + def_pick_store: e.data.data.pageData[0],
2702 2711 sto_sele_name: e.data.data.pageData[0].pickup_name,
2703 2712 sto_sele_id: e.data.data.pageData[0].pickup_id,
2704 2713 sto_sele_distr: e.data.data.pageData[0].distr_type
... ... @@ -2706,66 +2715,66 @@ Page({
2706 2715 }
2707 2716 }
2708 2717 },
2709   -
  2718 +
2710 2719 //------------处理线下门店库存--------
2711   - deal_pickup_dline(e){
2712   - var pkno=[],th=this;
2713   - if(!th.data.sele_g) return false;
2714   -
2715   - if(this.data.def_pick_store){
  2720 + deal_pickup_dline(e) {
  2721 + var pkno = [], th = this;
  2722 + if (!th.data.sele_g) return false;
  2723 +
  2724 + if (this.data.def_pick_store) {
2716 2725 pkno.push(this.data.def_pick_store.pickup_no);
2717 2726 }
2718   - for(var i in e.data.data.pageData){
2719   - var item=e.data.data.pageData[i];
2720   - if(pkno.indexOf(item.pickup_no)<0)
  2727 + for (var i in e.data.data.pageData) {
  2728 + var item = e.data.data.pageData[i];
  2729 + if (pkno.indexOf(item.pickup_no) < 0)
2721 2730 pkno.push(item.pickup_no);
2722 2731 }
2723   - pkno.sort();
2724   - var pkno_str=pkno.join(",");
2725   - var o_plist=e.data.data.pageData;
2726   - var new_list=[];
2727   - var is_find_def_store=0;
  2732 + pkno.sort();
  2733 + var pkno_str = pkno.join(",");
  2734 + var o_plist = e.data.data.pageData;
  2735 + var new_list = [];
  2736 + var is_find_def_store = 0;
2728 2737  
2729 2738  
2730   - var g_distr_type=th.data.sele_g.distr_type;
2731   - var lock=[];
  2739 + var g_distr_type = th.data.sele_g.distr_type;
  2740 + var lock = [];
2732 2741 //先读取门店的lock,采用链式写法,少用await
2733   - getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
2734   - data:{store_id:os.stoid,wareId:th.data.sele_g.goods_id,pageSize:1000}
2735   - }).then(res=>{
2736   - if(res.data.code==0 && res.data.data.total>0){
2737   - lock=res.data.data.pageData
  2742 + getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
  2743 + data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, pageSize: 1000 }
  2744 + }).then(res => {
  2745 + if (res.data.code == 0 && res.data.data.total > 0) {
  2746 + lock = res.data.data.pageData
2738 2747 }
2739 2748 //---通过接口获取门店的线下库存信息--
2740   - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
2741   - data:{storageNos:pkno_str,wareIds:encodeURIComponent(th.data.sele_g.erpwareid),storeId:os.stoid,pageSize:2000}
  2749 + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
  2750 + data: { storageNos: pkno_str, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid, pageSize: 2000 }
2742 2751 })
2743   - }).then(res=>{
  2752 + }).then(res => {
2744 2753  
2745   - wx.hideLoading();
2746   - if(res.data.code==0){
2747   - if(res.data.data.pageData && res.data.data.pageData.length>0){
2748   - var plist=res.data.data.pageData;
2749   - var def_pick_store=th.data.def_pick_store;
  2754 + wx.hideLoading();
  2755 + if (res.data.code == 0) {
  2756 + if (res.data.data.pageData && res.data.data.pageData.length > 0) {
  2757 + var plist = res.data.data.pageData;
  2758 + var def_pick_store = th.data.def_pick_store;
2750 2759 //以原来的数组为外循环,保证距离的顺序
2751   - for(var kk in o_plist){
2752   - for(var ii in plist){
  2760 + for (var kk in o_plist) {
  2761 + for (var ii in plist) {
2753 2762 //线下的门店小心
2754   - var n_item=plist[ii];
2755   - if(n_item.StorageNo==o_plist[kk].pickup_no){
  2763 + var n_item = plist[ii];
  2764 + if (n_item.StorageNo == o_plist[kk].pickup_no) {
2756 2765  
2757 2766 //拿到锁库的数量
2758   - var lock_num=th.find_lock_num(o_plist[kk].pickup_id,lock);
  2767 + var lock_num = th.find_lock_num(o_plist[kk].pickup_id, lock);
2759 2768 //可出库数大于预出库库存的数量,可以判断为有库存
2760   - if(n_item.CanOutQty>lock_num){
2761   - o_plist[kk].CanOutQty=n_item.CanOutQty-lock_num;
  2769 + if (n_item.CanOutQty > lock_num) {
  2770 + o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num;
2762 2771 new_list.push(o_plist[kk]);
2763 2772 //--如果找到默认门店,同时也应该判断配送方式对不对--
2764   - if(th.data.fir_def_store && n_item.StorageNo==th.data.fir_def_store.pickup_no && (g_distr_type==0 || th.data.fir_def_store.distr_type==0 || th.data.def_pick_store.distr_type==g_distr_type ) ){
2765   - th.data.fir_def_store.CanOutQty=n_item.CanOutQty-lock_num;
2766   - if(def_pick_store.pickup_id==th.data.fir_def_store.pickup_id)
2767   - th.setData({def_pick_store:th.data.fir_def_store})
2768   - is_find_def_store=1;
  2773 + if (th.data.fir_def_store && n_item.StorageNo == th.data.fir_def_store.pickup_no && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) {
  2774 + th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num;
  2775 + if (def_pick_store.pickup_id == th.data.fir_def_store.pickup_id)
  2776 + th.setData({ def_pick_store: th.data.fir_def_store })
  2777 + is_find_def_store = 1;
2769 2778 }
2770 2779 }
2771 2780 break;
... ... @@ -2774,55 +2783,55 @@ Page({
2774 2783 }
2775 2784  
2776 2785 //数据组装下
2777   - var em={};em.data={};em.data.data={};
2778   - em.data.data.total=new_list.length;
2779   - em.data.data.pageData=new_list;
2780   - em.data.data.pageData=new_list;
  2786 + var em = {}; em.data = {}; em.data.data = {};
  2787 + em.data.data.total = new_list.length;
  2788 + em.data.data.pageData = new_list;
  2789 + em.data.data.pageData = new_list;
2781 2790  
2782 2791 //--如果找到默认门店,同时也应该判断配送方式对不对--
2783   - if(th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id && (g_distr_type==0 || th.data.fir_def_store.distr_type==0 || th.data.def_pick_store.distr_type==g_distr_type ) ){
2784   - th.data.fir_def_store.CanOutQty=0;
  2792 + if (th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) {
  2793 + th.data.fir_def_store.CanOutQty = 0;
2785 2794 //--当选择的门店是客户默认的门店的时候--
2786   - if(th.data.def_pick_store && th.data.fir_def_store.pickup_id==th.data.def_pick_store.pickup_id) {
2787   - th.setData({def_pick_store:th.data.fir_def_store});
  2795 + if (th.data.def_pick_store && th.data.fir_def_store.pickup_id == th.data.def_pick_store.pickup_id) {
  2796 + th.setData({ def_pick_store: th.data.fir_def_store });
2788 2797 em.data.data.pageData.unshift(th.data.def_pick_store);
2789   - }else{
2790   - em.data.data.pageData.splice(1,0,th.data.fir_def_store);
  2798 + } else {
  2799 + em.data.data.pageData.splice(1, 0, th.data.fir_def_store);
2791 2800 }
2792 2801 }
2793 2802  
2794 2803 //---把数组组装进去---
2795 2804 th.deal_pickup(em);
2796   - }else{
2797   - th.setData({def_pick_store:null,all_sto:null,only_pk:null,def_pickpu_list:null})
  2805 + } else {
  2806 + th.setData({ def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null })
2798 2807 }
2799   - }else{
2800   - th.setData({def_pick_store:null,all_sto:null,only_pk:null,def_pickpu_list:null})
  2808 + } else {
  2809 + th.setData({ def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null })
2801 2810 }
2802 2811 })
2803 2812 },
2804 2813  
2805   - find_lock_num(pick_id,lock){
2806   - var lock_num=0;
2807   - if(!lock) return 0;
2808   - if(lock.length<0) return 0;
2809   - for(var i in lock){
2810   - if(pick_id==lock[i].pickupId){
2811   - lock_num+=lock[i].outQty;
  2814 + find_lock_num(pick_id, lock) {
  2815 + var lock_num = 0;
  2816 + if (!lock) return 0;
  2817 + if (lock.length < 0) return 0;
  2818 + for (var i in lock) {
  2819 + if (pick_id == lock[i].pickupId) {
  2820 + lock_num += lock[i].outQty;
2812 2821 }
2813 2822 }
2814 2823 return lock_num;
2815 2824 },
2816 2825  
2817 2826 //----------取货门店被点击的效果------
2818   - getmendian: function(t) {
  2827 + getmendian: function (t) {
2819 2828 this.setData({
2820 2829 ismend: 1,
2821 2830 });
2822 2831 },
2823 2832  
2824 2833 //----------隐藏取货门店,选取门店----------
2825   - hidemend: function(e) {
  2834 + hidemend: function (e) {
2826 2835 var pid = e.target.dataset.p_id;
2827 2836 var pname = e.target.dataset.p_name;
2828 2837 var p_distr_t = e.target.dataset.p_dis;
... ... @@ -2836,7 +2845,7 @@ Page({
2836 2845 },
2837 2846  
2838 2847 //------显示取货2级----------
2839   - show_sec: function(t) {
  2848 + show_sec: function (t) {
2840 2849 var index = t.target.dataset.index;
2841 2850 var item = this.data.all_sto[index];
2842 2851 this.setData({
... ... @@ -2846,43 +2855,43 @@ Page({
2846 2855 },
2847 2856  
2848 2857 //------隐藏取货门店2级----
2849   - hide_sec_mend: function() {
  2858 + hide_sec_mend: function () {
2850 2859 this.setData({
2851 2860 is_sec_mend: 0,
2852 2861 });
2853 2862 },
2854 2863  
2855 2864 //评论的调用
2856   - requestComments_new: async function(){
2857   - var e = this, th = e,ee=e; var tp = e.data.activeCategoryId3;
  2865 + requestComments_new: async function () {
  2866 + var e = this, th = e, ee = e; var tp = e.data.activeCategoryId3;
2858 2867 var t = '/api/weshop/comment/pageComment?page=' + e.data.c_curr_p;
2859 2868  
2860 2869 wx.showLoading();
2861 2870 var req_where = {
2862   - store_id: o.stoid, pageSize: 5,is_show:1,
  2871 + store_id: o.stoid, pageSize: 5, is_show: 1,
2863 2872 parent_id: 0, goods_id: th.data.gid, commenttype: tp,
2864 2873 }
2865 2874 if (getApp().globalData.userInfo) {
2866 2875 req_where.userId = getApp().globalData.userInfo.user_id;
2867 2876 }
2868 2877  
2869   - var rs_data=null;
2870   - await getApp().request.promiseGet(t, { data: req_where}).then(res=>{
  2878 + var rs_data = null;
  2879 + await getApp().request.promiseGet(t, { data: req_where }).then(res => {
2871 2880 var tot = res.data.data.total;
2872 2881 e.data.c_curr_p++;
2873 2882 e.setData({
2874 2883 com_num: tot, //已经有加载
2875 2884 });
2876   - if (res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){
2877   - rs_data=res.data.data.pageData;
2878   - }else{
2879   - th.setData({comments_no_more:1,auto:1});
  2885 + if (res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) {
  2886 + rs_data = res.data.data.pageData;
  2887 + } else {
  2888 + th.setData({ comments_no_more: 1, auto: 1 });
2880 2889 }
2881 2890 })
2882 2891  
2883   - if (rs_data){
  2892 + if (rs_data) {
2884 2893 //var cda = th.data.comments;
2885   - var cda = rs_data,com_data=th.data.comments;
  2894 + var cda = rs_data, com_data = th.data.comments;
2886 2895 for (var ind in cda) {
2887 2896 var ep = cda[ind];
2888 2897 if (cda[ind].head_pic == '') {
... ... @@ -2896,13 +2905,13 @@ Page({
2896 2905 }
2897 2906  
2898 2907 //--测量多有字的宽带,计算有多少行--
2899   - var widh=ut.measureText(ep.content,30);
2900   - var lines=widh/712;
2901   - cda[ind].seeMore=false;
2902   - if(lines>3) cda[ind].seeMore=true;
  2908 + var widh = ut.measureText(ep.content, 30);
  2909 + var lines = widh / 712;
  2910 + cda[ind].seeMore = false;
  2911 + if (lines > 3) cda[ind].seeMore = true;
2903 2912  
2904 2913 await getApp().request.promiseGet("/api/weshop/comment/pageComment", {
2905   - data: {store_id: o.stoid, parent_id: ep.comment_id }
  2914 + data: { store_id: o.stoid, parent_id: ep.comment_id }
2906 2915 }).then(res => {
2907 2916 if (res.data.data.pageData && res.data.data.pageData.length > 0) {
2908 2917 cda[ind].replay_list = res.data.data.pageData;
... ... @@ -2913,16 +2922,16 @@ Page({
2913 2922 if (!com_data) com_data = cda;
2914 2923 else com_data = com_data.concat(cda);
2915 2924  
2916   - th.setData({ comments: com_data});
  2925 + th.setData({ comments: com_data });
2917 2926 }
2918   - th.setData({get_c: 1});
  2927 + th.setData({ get_c: 1 });
2919 2928 wx.hideLoading();
2920 2929 },
2921 2930  
2922 2931 //加载更多是靠这个函数
2923   - onReachBottom: function() {
2924   - if (this.data.activeCategoryId == 2){
2925   - if(!this.data.comments_no_more) this.requestComments_new();
  2932 + onReachBottom: function () {
  2933 + if (this.data.activeCategoryId == 2) {
  2934 + if (!this.data.comments_no_more) this.requestComments_new();
2926 2935 }
2927 2936  
2928 2937 var goods_list = this.selectComponent("#goods_list"); //组件的id
... ... @@ -2932,20 +2941,18 @@ Page({
2932 2941 //--------检查是否活动,活动是否开始,或者是否结束-------
2933 2942 async check_prom(gid, prom_type, prom_id) {
2934 2943 var ee = this,
2935   - th = ee;
2936   - if (prom_type == 3 || prom_type == 0 || prom_type == 2 || prom_type == 5 || prom_type == 7) {
  2944 + th = ee;
  2945 + if (prom_type == 3 || prom_type == 0 || prom_type == 2 || prom_type == 5 || prom_type == 7) {
2937 2946 this.setData({
2938 2947 prom_type: 0,
2939 2948 isshow: 1,
2940 2949 });
2941 2950 return false;
2942 2951 }
2943   -
2944   -
2945   -
2946   - //if (prom_type != 3 && prom_type!=0){
2947   - //---判断秒杀----
2948   - if (prom_type == 1) {
  2952 +
  2953 + //if (prom_type != 3 && prom_type!=0){
  2954 + //---判断秒杀----
  2955 + if (prom_type == 1) {
2949 2956 //-------判断活动是否抢光---------
2950 2957 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, {
2951 2958 1: 1
... ... @@ -2958,8 +2965,8 @@ Page({
2958 2965 });
2959 2966 //拿取价格并且判断时间--
2960 2967 getApp().request.get("/api/ms/flash_sale/get/" +
2961   - os.stoid + "/" + prom_id, {
2962   - success: function(t) {
  2968 + os.stoid + "/" + prom_id, {
  2969 + success: function (t) {
2963 2970 if (t.data.code != 0) {
2964 2971 ee.setData({
2965 2972 prom_type: 0,
... ... @@ -3047,73 +3054,73 @@ Page({
3047 3054 })
3048 3055 }
3049 3056  
3050   - if(prom_type==4){
3051   - //th.setData({is_integral_normal:1});
3052   - var rdata={
3053   - store_id:o.stoid,stype:1,stypeup:1,goods_id:gid
3054   - }
3055   -
3056   - var integrals=0;
3057   - var get_datas= {
3058   - user_id:getApp().globalData.user_id, store_id:o.stoid,
3059   - };
3060   - await getApp().request.promiseGet("/api/weshop/users/getAllPoints", {
3061   - data: get_datas
3062   - }).then(res => {
3063   - if(res.data.code==0){
3064   - integrals=res.data.data.Integral;
3065   - }
3066   - })
3067   -
3068   - //获取一下积分活动
3069   - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList", {
3070   - data: rdata
3071   - }).then(res => {
3072   - //调用接口有数据的时候
3073   - if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0) {
3074   - var inte_data=res.data.data.pageData[0];
3075   - var can_integral=(parseFloat(integrals)>=parseFloat(inte_data.integral));
3076   - ee.setData({
3077   - prom_price:parseFloat(inte_data.addmoney),
3078   - prom_integral:parseFloat(inte_data.integral),
3079   - prom_type: 4,
3080   - prom_id: inte_data.id,
3081   - prom_buy_limit: inte_data.limitvipqty,
3082   - prom_act: inte_data,
3083   - isshow: 1,
3084   - can_integral:can_integral,
3085   - is_shopbuy: parseInt(inte_data.is_shopbuy?inte_data.is_shopbuy:0)
3086   - });
3087   - ee.get_sto();
3088   -
3089   - }else{
3090   - ee.setData({prom_type: 0, isshow: 1,});
3091   - ee.get_sku(os.stoid, ee.data.data, gid);
3092   - ee.get_sto();
3093   - return false;
3094   - }
3095   - })
3096   -
3097   - }
3098   -
3099   -
  3057 + if (prom_type == 4) {
  3058 + //th.setData({is_integral_normal:1});
  3059 + var rdata = {
  3060 + store_id: o.stoid, stype: 1, stypeup: 1, goods_id: gid
  3061 + }
  3062 +
  3063 + var integrals = 0;
  3064 + var get_datas = {
  3065 + user_id: getApp().globalData.user_id, store_id: o.stoid,
  3066 + };
  3067 + await getApp().request.promiseGet("/api/weshop/users/getAllPoints", {
  3068 + data: get_datas
  3069 + }).then(res => {
  3070 + if (res.data.code == 0) {
  3071 + integrals = res.data.data.Integral;
  3072 + }
  3073 + })
  3074 +
  3075 + //获取一下积分活动
  3076 + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList", {
  3077 + data: rdata
  3078 + }).then(res => {
  3079 + //调用接口有数据的时候
  3080 + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) {
  3081 + var inte_data = res.data.data.pageData[0];
  3082 + var can_integral = (parseFloat(integrals) >= parseFloat(inte_data.integral));
  3083 + ee.setData({
  3084 + prom_price: parseFloat(inte_data.addmoney),
  3085 + prom_integral: parseFloat(inte_data.integral),
  3086 + prom_type: 4,
  3087 + prom_id: inte_data.id,
  3088 + prom_buy_limit: inte_data.limitvipqty,
  3089 + prom_act: inte_data,
  3090 + isshow: 1,
  3091 + can_integral: can_integral,
  3092 + is_shopbuy: parseInt(inte_data.is_shopbuy ? inte_data.is_shopbuy : 0)
  3093 + });
  3094 + ee.get_sto();
  3095 +
  3096 + } else {
  3097 + ee.setData({ prom_type: 0, isshow: 1, });
  3098 + ee.get_sku(os.stoid, ee.data.data, gid);
  3099 + ee.get_sto();
  3100 + return false;
  3101 + }
  3102 + })
  3103 +
  3104 + }
  3105 +
  3106 +
3100 3107 //---判断拼单----
3101 3108 if (prom_type == 6) {
3102 3109 //-------判断活动是否抢光---------
3103 3110 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, {
3104 3111 1: 1
3105 3112 }).then(res => {
  3113 + console.log(res,3114);
3106 3114 var em = res;
3107 3115 if (em.data.code == 0) {
3108   -
3109   -
3110 3116 if (em.data.data <= 0) ee.setData({
3111 3117 prom_r_null: 1
3112 3118 });
3113 3119 //拿取价格并且判断时间--
3114 3120 getApp().request.get("/api/weshop/teamlist/get/" +
3115   - os.stoid + "/" + prom_id, {
3116   - success: function(t) {
  3121 + os.stoid + "/" + prom_id, {
  3122 + success: function (t) {
  3123 + console.log(t,3124);
3117 3124 if (t.data.code != 0) {
3118 3125 ee.setData({
3119 3126 prom_type: 0,
... ... @@ -3155,6 +3162,31 @@ Page({
3155 3162 return false;
3156 3163 }
3157 3164  
  3165 + /*-- 判断拼单是否启用 --*/
  3166 + if (!t.data.data.is_show) {
  3167 + console.log('没启用');
  3168 + wx.setNavigationBarTitle({
  3169 + title: '系统提示',
  3170 + });
  3171 + wx.showToast({
  3172 + title:'此商品暂时没有拼单活动',
  3173 + icon:'none',
  3174 + success(){
  3175 + setTimeout(()=>{
  3176 + wx.navigateBack()
  3177 + },2000)
  3178 + }
  3179 + });
  3180 + return false
  3181 + ee.setData({
  3182 + prom_type: 0,
  3183 + isshow: 1,
  3184 + });
  3185 + ee.get_sku(os.stoid, ee.data.data, gid);
  3186 + ee.get_sto();
  3187 + return false;
  3188 + }
  3189 +
3158 3190 //-------查看自己是不是有买过该团的商品,并还为支付,或者在进行中-------
3159 3191 getApp().request.get("/api/weshop/order/page", {
3160 3192 data: {
... ... @@ -3164,7 +3196,7 @@ Page({
3164 3196 pageSize: 1,
3165 3197 page: 1
3166 3198 },
3167   - success: function(e) {
  3199 + success: function (e) {
3168 3200 if (e.data.code == 0 && e.data.data.pageData.length > 0) {
3169 3201 var odr = e.data.data.pageData[0];
3170 3202 th.data.buy_order = odr;
... ... @@ -3183,17 +3215,17 @@ Page({
3183 3215 }
3184 3216 }).then(res => {
3185 3217 var now = ut.gettimestamp();
3186   - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){
3187   - var tgr = res.data.data.pageData[0];
3188   - //如果团的时间已经到了
3189   - if (now >= tgr.kt_end_time) {
3190   - th.update_jiti(tgr.id);
3191   - } else {
3192   - th.setData({
3193   - user_order_pt_state: 2
3194   - });
3195   - }
3196   - }
  3218 + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) {
  3219 + var tgr = res.data.data.pageData[0];
  3220 + //如果团的时间已经到了
  3221 + if (now >= tgr.kt_end_time) {
  3222 + th.update_jiti(tgr.id);
  3223 + } else {
  3224 + th.setData({
  3225 + user_order_pt_state: 2
  3226 + });
  3227 + }
  3228 + }
3197 3229 })
3198 3230  
3199 3231 } else {
... ... @@ -3214,10 +3246,10 @@ Page({
3214 3246 });
3215 3247  
3216 3248 //----------查看阶梯团------------
3217   - if (t.data.data.ct_rylist != "null" && t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) {
  3249 + if (t.data.data.ct_rylist != "null" && t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) {
3218 3250 t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist);
3219 3251 var max_num = 0;
3220   - t.data.data.ct_rylist.forEach(function(val, ind) {
  3252 + t.data.data.ct_rylist.forEach(function (val, ind) {
3221 3253 if (parseInt(val.rynum) > max_num) max_num = parseInt(val.rynum);
3222 3254 })
3223 3255 t.data.data.max_ct_num = max_num;
... ... @@ -3269,24 +3301,24 @@ Page({
3269 3301 //--获取有多少人在开团--
3270 3302 async get_team_group(prom_id) {
3271 3303 var teamgroup = [],
3272   - th = this,
3273   - grounp_tatal = 0;
  3304 + th = this,
  3305 + grounp_tatal = 0;
3274 3306 //如果活动是开团不是商家团
3275 3307 if (this.data.prom_act.kttype > 1) {
3276   -
3277   - var req_data={
3278   - store_id: os.stoid,
3279   - pageSize: 3,
3280   - page: 1,
3281   - state: 2,
3282   - team_id: prom_id,
3283   - ordernum:1
3284   - };
3285   -
3286   - if(this.data.prom_act.kttype==3 && this.data.prom_act.max_ct_num ){
3287   - req_data.max_num=this.data.prom_act.max_ct_num;
3288   - }
3289   -
  3308 +
  3309 + var req_data = {
  3310 + store_id: os.stoid,
  3311 + pageSize: 3,
  3312 + page: 1,
  3313 + state: 2,
  3314 + team_id: prom_id,
  3315 + ordernum: 1
  3316 + };
  3317 +
  3318 + if (this.data.prom_act.kttype == 3 && this.data.prom_act.max_ct_num) {
  3319 + req_data.max_num = this.data.prom_act.max_ct_num;
  3320 + }
  3321 +
3290 3322 //获取活动从表信息team_id
3291 3323 await getApp().request.promiseGet("/api/weshop/teamgroup/page", {
3292 3324 data: req_data
... ... @@ -3358,7 +3390,7 @@ Page({
3358 3390 prom_time_text: '距结束还剩:',
3359 3391 prom_st: 1
3360 3392 })
3361   - setTimeout(function() {
  3393 + setTimeout(function () {
3362 3394 th.countDown(endTime2)
3363 3395 }, 1000);
3364 3396 return false;
... ... @@ -3385,17 +3417,17 @@ Page({
3385 3417 th.setData({
3386 3418 djs: obj
3387 3419 });
3388   - setTimeout(function() {
  3420 + setTimeout(function () {
3389 3421 th.countDown(endTime)
3390 3422 }, 1000);
3391 3423 },
3392 3424  
3393 3425  
3394 3426 //-------------获取购买数量的总函数----------------
3395   - get_buy_num: function(gd, func) {
  3427 + get_buy_num: function (gd, func) {
3396 3428 var map = this.data.g_buy_num,
3397   - th = this,
3398   - user_id = getApp().globalData.user_id;
  3429 + th = this,
  3430 + user_id = getApp().globalData.user_id;
3399 3431 if (user_id == null) {
3400 3432 map.set(gd.goods_id, 0);
3401 3433 th.setData({
... ... @@ -3416,7 +3448,7 @@ Page({
3416 3448 user_id: user_id,
3417 3449 goods_id: gd.goods_id
3418 3450 },
3419   - success: function(t) {
  3451 + success: function (t) {
3420 3452 if (t.data.code == 0) {
3421 3453 var g_buy_num = t.data.data.goodsbuynum;
3422 3454 if (gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6) {
... ... @@ -3430,7 +3462,7 @@ Page({
3430 3462 prom_id: gd.prom_id
3431 3463 },
3432 3464 //-----获取-----
3433   - success: function(tt) {
  3465 + success: function (tt) {
3434 3466 if (tt.data.code == 0) {
3435 3467 map.set(gd.goods_id, g_buy_num);
3436 3468 th.setData({
... ... @@ -3455,7 +3487,7 @@ Page({
3455 3487 },
3456 3488  
3457 3489 //--拼单推荐的显示---
3458   - tj_Click: function(e) {
  3490 + tj_Click: function (e) {
3459 3491 var ind = parseInt(e.target.dataset.ind);
3460 3492 this.setData({
3461 3493 is_show_gz: ind
... ... @@ -3463,22 +3495,22 @@ Page({
3463 3495 },
3464 3496  
3465 3497 //--------拼团玩法显示详情--------
3466   - show_pt_xx: function(e) {
  3498 + show_pt_xx: function (e) {
3467 3499 this.setData({
3468 3500 pd_xx: 1,
3469 3501 })
3470 3502 },
3471   - close_pt_xx: function() {
  3503 + close_pt_xx: function () {
3472 3504 this.setData({
3473 3505 pd_xx: 0,
3474 3506 })
3475 3507 },
3476 3508  
3477 3509 //--点击弹起拼单--
3478   - openSpecModel_pt: function(e) {
  3510 + openSpecModel_pt: function (e) {
3479 3511  
3480 3512  
3481   - this.setData({ open_ind_store: 4,goodsInputNum:1});//拼团直接给4
  3513 + this.setData({ open_ind_store: 4, goodsInputNum: 1 });//拼团直接给4
3482 3514  
3483 3515  
3484 3516 //--先判断会员状态--
... ... @@ -3496,23 +3528,23 @@ Page({
3496 3528 if (ind == 1) {
3497 3529 //如果拼单的sku data是空的,就要先获取一下
3498 3530 if (th.data.sku_g_pt) {
3499   - th.get_sto(1);
  3531 + th.get_sto(1);
3500 3532 th.setData({
3501 3533 is_normal: ind,
3502 3534 openSpecModal_pt: 1
3503 3535 });
3504 3536 } else {
3505   - th.get_sto(1);
3506   - th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function() {
  3537 + th.get_sto(1);
  3538 + th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () {
3507 3539 th.setData({
3508 3540 is_normal: ind,
3509 3541 openSpecModal_pt: 1
3510 3542 });
3511 3543 });
3512   - }
3513   - th.check_is_youhui(th.data.gid,1);
  3544 + }
  3545 + th.check_is_youhui(th.data.gid, 1);
3514 3546 } else {
3515   -
  3547 +
3516 3548 //拼单商品从这里进,先判断有没有买过商品,
3517 3549 getApp().request.get("/api/weshop/order/page", {
3518 3550 data: {
... ... @@ -3522,7 +3554,7 @@ Page({
3522 3554 pageSize: 1,
3523 3555 page: 1
3524 3556 },
3525   - success: function(e) {
  3557 + success: function (e) {
3526 3558 //--跳转到已经购买的情况--
3527 3559 if (e.data.data.pageData.length > 0) {
3528 3560 var odr = e.data.data.pageData[0];
... ... @@ -3530,7 +3562,7 @@ Page({
3530 3562 if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) {
3531 3563 wx.showModal({
3532 3564 title: "您已经购买了该商品待支付中",
3533   - success: function(a) {
  3565 + success: function (a) {
3534 3566 if (a.confirm) {
3535 3567 wx.navigateTo({
3536 3568 url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id,
... ... @@ -3539,15 +3571,15 @@ Page({
3539 3571 }
3540 3572 });
3541 3573 } else if (odr.pt_status == 1 && odr.order_status == 1) {
3542   -
3543   - if(this.data.is_go_to_team_show) return false;
3544   - this.data.is_go_to_team_show=1;
3545   - wx.showLoading();
3546   -
3547   - /*---
3548   - wx.redirectTo({
3549   - url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn,
3550   - });--*/
  3574 +
  3575 + if (this.data.is_go_to_team_show) return false;
  3576 + this.data.is_go_to_team_show = 1;
  3577 + wx.showLoading();
  3578 +
  3579 + /*---
  3580 + wx.redirectTo({
  3581 + url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn,
  3582 + });--*/
3551 3583 getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn);
3552 3584  
3553 3585 } else {
... ... @@ -3569,7 +3601,7 @@ Page({
3569 3601 },
3570 3602  
3571 3603 //-----------------拼单生成方法---------------------
3572   - addCart_pt: function() {
  3604 + addCart_pt: function () {
3573 3605 var th = this;
3574 3606 if (this.data.is_normal == 0) {
3575 3607 //看一下有没有起购数,如果有起购数,要计算起购数
... ... @@ -3585,18 +3617,18 @@ Page({
3585 3617 }
3586 3618 },
3587 3619  
3588   - addcart_pt_func: function() {
  3620 + addcart_pt_func: function () {
3589 3621 if (oo.user_id == null) {
3590 3622 s.my_warnning("还未登录!", 0, this);
3591 3623 return;
3592 3624 }
3593 3625 var e = this,
3594   - th = e,
3595   - o = this.data.sele_g;
  3626 + th = e,
  3627 + o = this.data.sele_g;
3596 3628 if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
3597 3629  
3598 3630 //----------添加到购物车时,要判断限购数量,--------
3599   - e.get_buy_num(o, async function(ee) {
  3631 + e.get_buy_num(o, async function (ee) {
3600 3632  
3601 3633 //---判断商品是否超出限购---
3602 3634 if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) {
... ... @@ -3606,30 +3638,30 @@ Page({
3606 3638 content: '超出商品限购'
3607 3639 });
3608 3640  
3609   - var num=th.data.prom_buy_limit-th.data.prom_buy_num;
3610   - if(num<0) num=0;
3611   - th.setData({goodsInputNum:num})
  3641 + var num = th.data.prom_buy_limit - th.data.prom_buy_num;
  3642 + if (num < 0) num = 0;
  3643 + th.setData({ goodsInputNum: num })
3612 3644 return false;
3613 3645 }
3614 3646 }
3615 3647 //---判断商品是否超出活动限购,拼团的普通购买不计算活动的限购---
3616   - if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal!=1) {
  3648 + if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal != 1) {
3617 3649 if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) {
3618 3650 wx.showModal({
3619 3651 title: '提示',
3620 3652 content: '超出商品活动限购'
3621 3653 });
3622 3654  
3623   - var num=th.data.prom_buy_limit-th.data.prom_buy_num;
3624   - if(num<0) num=0;
3625   - th.setData({goodsInputNum:num})
  3655 + var num = th.data.prom_buy_limit - th.data.prom_buy_num;
  3656 + if (num < 0) num = 0;
  3657 + th.setData({ goodsInputNum: num })
3626 3658 return false;
3627 3659 }
3628 3660 }
3629 3661  
3630 3662 var redis_num = 0
3631 3663 //不是普通购买的时候
3632   - if(th.data.is_normal!=1){
  3664 + if (th.data.is_normal != 1) {
3633 3665 //-------判断活动是否抢光---------
3634 3666 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + th.data.sele_g.prom_id, {
3635 3667 1: 1
... ... @@ -3643,7 +3675,7 @@ Page({
3643 3675 content: '超出商品活动库存'
3644 3676 });
3645 3677  
3646   - th.setData({goodsInputNum:redis_num})
  3678 + th.setData({ goodsInputNum: redis_num })
3647 3679  
3648 3680 return false;
3649 3681 }
... ... @@ -3651,7 +3683,7 @@ Page({
3651 3683  
3652 3684 if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th);
3653 3685 if (th.data.goodsInputNum > o.store_count) {
3654   - th.setData({goodsInputNum:o.store_count})
  3686 + th.setData({ goodsInputNum: o.store_count })
3655 3687 return s.my_warnning("超出商品库存", 0, th);
3656 3688 }
3657 3689  
... ... @@ -3674,42 +3706,42 @@ Page({
3674 3706 };
3675 3707  
3676 3708 //---是不是从收藏夹出来的---
3677   - if(th.data.c_guide_id){
  3709 + if (th.data.c_guide_id) {
3678 3710 newd['guide_id'] = th.data.c_guide_id;
3679   - newd['guide_type']=2;
  3711 + newd['guide_type'] = 2;
3680 3712  
3681   - }else{
3682   - if(getApp().globalData.guide_id){
  3713 + } else {
  3714 + if (getApp().globalData.guide_id) {
3683 3715 newd['guide_id'] = getApp().globalData.guide_id;
3684   - newd['guide_type']=0;
  3716 + newd['guide_type'] = 0;
3685 3717  
3686 3718 }
3687 3719 }
3688 3720  
3689 3721 //让商品带上房间号
3690   - if(th.data.sys_switch.is_skuroom_id==1){
3691   - if(th.data.data.goods_id==getApp().globalData.room_goods_id){
3692   - newd.room_id=getApp().globalData.room_id;
  3722 + if (th.data.sys_switch.is_skuroom_id == 1) {
  3723 + if (th.data.data.goods_id == getApp().globalData.room_goods_id) {
  3724 + newd.room_id = getApp().globalData.room_id;
3693 3725 }
3694   - }else{
3695   - if(newd.goods_id==getApp().globalData.room_goods_id){
3696   - newd.room_id=getApp().globalData.room_id;
  3726 + } else {
  3727 + if (newd.goods_id == getApp().globalData.room_goods_id) {
  3728 + newd.room_id = getApp().globalData.room_id;
3697 3729 }
3698 3730 }
3699 3731  
3700 3732 //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------
3701 3733  
3702   - if(th.data.is_normal == 1){
3703   - var conf=th.data.bconfig;
3704   - if(conf.switch_list){
3705   - var s_list=JSON.parse(conf.switch_list);
  3734 + if (th.data.is_normal == 1) {
  3735 + var conf = th.data.bconfig;
  3736 + if (conf.switch_list) {
  3737 + var s_list = JSON.parse(conf.switch_list);
3706 3738 //如果后台有开启等级价的功能
3707   - if(parseInt(s_list.rank_switch)==2){
3708   - var card_price=o[getApp().globalData.userInfo['card_field']];
  3739 + if (parseInt(s_list.rank_switch) == 2) {
  3740 + var card_price = o[getApp().globalData.userInfo['card_field']];
3709 3741 //如果会员有等级价
3710   - if(getApp().globalData.userInfo['card_field']!=undefined && getApp().globalData.userInfo['card_field']!=null
3711   - && getApp().globalData.userInfo['card_field']!="" && card_price>0){
3712   - newd.goods_price=card_price;
  3742 + if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null
  3743 + && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) {
  3744 + newd.goods_price = card_price;
3713 3745 }
3714 3746 }
3715 3747 }
... ... @@ -3717,7 +3749,7 @@ Page({
3717 3749  
3718 3750  
3719 3751 //-----如果是秒杀,团购,积分购,拼团,且不是普通购买-----
3720   - if (th.data.prom_type == 6 && th.data.is_normal!= 1) {
  3752 + if (th.data.prom_type == 6 && th.data.is_normal != 1) {
3721 3753 newd.goods_price = th.data.prom_price;
3722 3754 newd.prom_type = th.data.prom_type;
3723 3755 newd.prom_id = th.data.prom_id;
... ... @@ -3739,23 +3771,23 @@ Page({
3739 3771 newd['pick_name'] = th.data.sto_sele_name;
3740 3772 newd['pick_dis'] = th.data.sto_sele_distr;
3741 3773 newd['is_normal'] = th.data.is_normal;
3742   -
3743   - if(newd['is_normal']){
3744   - newd['is_pd_normal']=1;
3745   - //判断一下有没有全局优惠活动
3746   - th.check_nor_promgood(newd.goods_id,function(e){
3747   - if(e && e.act_id){
3748   - newd['prom_type']=3;
3749   - newd['prom_id']=e.act_id;
3750   - }
3751   - th.buyNow(newd)
3752   - })
3753   - }
  3774 +
  3775 + if (newd['is_normal']) {
  3776 + newd['is_pd_normal'] = 1;
  3777 + //判断一下有没有全局优惠活动
  3778 + th.check_nor_promgood(newd.goods_id, function (e) {
  3779 + if (e && e.act_id) {
  3780 + newd['prom_type'] = 3;
  3781 + newd['prom_id'] = e.act_id;
  3782 + }
  3783 + th.buyNow(newd)
  3784 + })
  3785 + }
3754 3786 else th.buyNow_pt(newd);
3755 3787 })
3756 3788 },
3757 3789 //----------立即购买_pt-----------
3758   - buyNow_pt: function(e) {
  3790 + buyNow_pt: function (e) {
3759 3791 s.set_b_now(e);
3760 3792 wx.navigateTo({
3761 3793 url: "/pages/cart/cart2_pt/cart2_pt?is_bnow=1&goods_id=" + e.goods_id,
... ... @@ -3763,27 +3795,27 @@ Page({
3763 3795 },
3764 3796  
3765 3797 //-------跳转pt商品-------
3766   - go_to_nopay: function() {
3767   - var th = this;
3768   - url="/pages/user/order_detail/order_detail?order_id=" + th.data.buy_order.order_id;
3769   - getApp().goto(url);
3770   -
  3798 + go_to_nopay: function () {
  3799 + var th = this;
  3800 + url = "/pages/user/order_detail/order_detail?order_id=" + th.data.buy_order.order_id;
  3801 + getApp().goto(url);
  3802 +
3771 3803 },
3772 3804 //-------跳转pt teamshow-------
3773   - go_to_team_show: function() {
3774   -
3775   - if(this.data.is_go_to_team_show) return false;
3776   - this.data.is_go_to_team_show=1;
3777   - wx.showLoading();
3778   -
3779   - var th = this;
3780   - var url="/pages/team/team_success/team_success?ordersn=" + th.data.buy_order.order_sn;
3781   - /*--
3782   - wx.redirectTo({
3783   - url:url,
3784   - })--*/
3785   - getApp().goto(url);
3786   -
  3805 + go_to_team_show: function () {
  3806 +
  3807 + if (this.data.is_go_to_team_show) return false;
  3808 + this.data.is_go_to_team_show = 1;
  3809 + wx.showLoading();
  3810 +
  3811 + var th = this;
  3812 + var url = "/pages/team/team_success/team_success?ordersn=" + th.data.buy_order.order_sn;
  3813 + /*--
  3814 + wx.redirectTo({
  3815 + url:url,
  3816 + })--*/
  3817 + getApp().goto(url);
  3818 +
3787 3819 },
3788 3820  
3789 3821 //---拼团倒计时---
... ... @@ -3828,7 +3860,7 @@ Page({
3828 3860 setTimeout(th.countDown2, 1000);
3829 3861 },
3830 3862 //跳转参加团
3831   - go_cj_team: function(e) {
  3863 + go_cj_team: function (e) {
3832 3864 var ind = e.currentTarget.dataset.ind;
3833 3865 var item = this.data.teamgroup[ind];
3834 3866 var id = item.id;
... ... @@ -3842,7 +3874,7 @@ Page({
3842 3874 pageSize: 1,
3843 3875 page: 1
3844 3876 },
3845   - success: function(e) {
  3877 + success: function (e) {
3846 3878 if (e.data.code != 0) {
3847 3879 getApp().my_warnning("读取订单失败", 0, th);
3848 3880 return fasle;
... ... @@ -3854,7 +3886,7 @@ Page({
3854 3886 if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) {
3855 3887 wx.showModal({
3856 3888 title: "您已经购买了该商品待支付中",
3857   - success: function(a) {
  3889 + success: function (a) {
3858 3890 if (a.confirm) {
3859 3891 wx.navigateTo({
3860 3892 url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id,
... ... @@ -3863,16 +3895,16 @@ Page({
3863 3895 }
3864 3896 });
3865 3897 } else if (odr.pt_status == 1 && odr.order_status == 1) {
3866   -
3867   - if(this.data.is_go_to_team_show) return false;
3868   - this.data.is_go_to_team_show=1;
3869   - wx.showLoading();
3870   - /*--
3871   - wx.redirectTo({
3872   - url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn,
3873   - });--*/
3874 3898  
3875   - getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn);
  3899 + if (this.data.is_go_to_team_show) return false;
  3900 + this.data.is_go_to_team_show = 1;
  3901 + wx.showLoading();
  3902 + /*--
  3903 + wx.redirectTo({
  3904 + url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn,
  3905 + });--*/
  3906 +
  3907 + getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn);
3876 3908  
3877 3909 } else {
3878 3910 wx.navigateTo({
... ... @@ -3892,7 +3924,7 @@ Page({
3892 3924 },
3893 3925  
3894 3926 //跳到团更多
3895   - go_t_more: function() {
  3927 + go_t_more: function () {
3896 3928 var team_id = this.data.prom_id;
3897 3929 wx.navigateTo({
3898 3930 url: "/pages/team/team_more/team_more?team_id=" + team_id,
... ... @@ -3900,11 +3932,11 @@ Page({
3900 3932 },
3901 3933  
3902 3934 //--点赞功能--
3903   - click_zan: function(e) {
  3935 + click_zan: function (e) {
3904 3936 var com_id = e.currentTarget.dataset.com_id;
3905 3937 var item_id = e.currentTarget.dataset.item_id;
3906 3938 var app = getApp(),
3907   - th = this;
  3939 + th = this;
3908 3940  
3909 3941 if (app.globalData.userInfo == null || app.globalData.userInfo == undefined) {
3910 3942 app.confirmBox("您还未登录");
... ... @@ -3923,7 +3955,7 @@ Page({
3923 3955 goods_id: th.data.gid,
3924 3956 comment_id: com_id
3925 3957 },
3926   - success: function(ee) {
  3958 + success: function (ee) {
3927 3959  
3928 3960 if (ee.data.code == "-1") {
3929 3961 app.my_warnning("不能给自己点赞", 0, th);
... ... @@ -3952,7 +3984,7 @@ Page({
3952 3984 th.setData(_errObj);
3953 3985 }
3954 3986  
3955   - setTimeout(function() {
  3987 + setTimeout(function () {
3956 3988 th.data.iszaning = 0;
3957 3989 }, 500)
3958 3990  
... ... @@ -3961,7 +3993,7 @@ Page({
3961 3993 },
3962 3994  
3963 3995 /*----券的开关---*/
3964   - switchCoupon: async function(event) {
  3996 + switchCoupon: async function (event) {
3965 3997 var coupon = event.currentTarget.dataset.coupon;
3966 3998 var app = getApp();
3967 3999 var url = "/api/weshop/prom/coupon/pageCouponList";
... ... @@ -3978,7 +4010,7 @@ Page({
3978 4010 pageSize: 100,
3979 4011 page: 1,
3980 4012 user_id: app.globalData.user_id,
3981   - is_share:0
  4013 + is_share: 0
3982 4014 }
3983 4015 }).then(res => {
3984 4016 wx.hideLoading();
... ... @@ -4009,13 +4041,13 @@ Page({
4009 4041 },
4010 4042  
4011 4043 //--查看评价--
4012   - look_pj: function() {
  4044 + look_pj: function () {
4013 4045 this.tabComment();
4014 4046 this.doScrollTop();
4015 4047 },
4016 4048  
4017 4049 //-----领取券-----
4018   - get_quan: function(e) {
  4050 + get_quan: function (e) {
4019 4051 var cid = e.currentTarget.dataset.cid;
4020 4052 var index = e.currentTarget.dataset.ind;
4021 4053 var item = this.data.quan_list[index];
... ... @@ -4051,17 +4083,17 @@ Page({
4051 4083 'store_id': os.stoid,
4052 4084 'type': 5
4053 4085 };
4054   -
4055   - //-- 导购ID --
4056   - if(getApp().globalData.guide_id){
4057   - pdata.guide_id=getApp().globalData.guide_id;
4058   - }
4059   -
  4086 +
  4087 + //-- 导购ID --
  4088 + if (getApp().globalData.guide_id) {
  4089 + pdata.guide_id = getApp().globalData.guide_id;
  4090 + }
  4091 +
4060 4092 var app = getApp(),
4061   - th = this;
  4093 + th = this;
4062 4094 app.request.post("/api/weshop/couponList/saveCouponList", {
4063 4095 data: pdata,
4064   - success: function(res) {
  4096 + success: function (res) {
4065 4097 if (res.data.code == 0) {
4066 4098 app.my_warnning("领取成功", 1, th);
4067 4099 lq_num++;
... ... @@ -4081,9 +4113,9 @@ Page({
4081 4113 }
4082 4114 })
4083 4115 },
4084   -
  4116 +
4085 4117 //--定义的保存图片方法,分享团---
4086   - saveImageToPhotosAlbum: function() {
  4118 + saveImageToPhotosAlbum: function () {
4087 4119 //--先判断会员状态--
4088 4120 var user_info = getApp().globalData.userInfo;
4089 4121 if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
... ... @@ -4091,12 +4123,12 @@ Page({
4091 4123 wx.navigateTo({ url: '/pages/togoin/togoin', })
4092 4124 return false;
4093 4125 }
4094   -
4095   - if(this.data.share_hidden) {
4096   - this.setData({
4097   - share_hidden: false,
4098   - });
4099   - };
  4126 +
  4127 + if (this.data.share_hidden) {
  4128 + this.setData({
  4129 + share_hidden: false,
  4130 + });
  4131 + };
4100 4132  
4101 4133 //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团
4102 4134 var type = this.data.prom_type;
... ... @@ -4107,7 +4139,7 @@ Page({
4107 4139 title: '生成中...',
4108 4140 })
4109 4141 var that = this,
4110   - th = that;
  4142 + th = that;
4111 4143 //设置画板显示,才能开始绘图
4112 4144 that.setData({
4113 4145 canvasHidden: false
... ... @@ -4116,230 +4148,230 @@ Page({
4116 4148 var app = getApp();
4117 4149 var unit = that.data.screenWidth / 750 * 1.35; //基础单位,
4118 4150 var path2 = that.data.data.original_img;
4119   - var scene = th.data.gid+"";
4120   - var user_id = getApp().globalData.user_id?getApp().globalData.user_id:0;
4121   - if(user_id>0) {
4122   - scene+="_"+user_id;
  4151 + var scene = th.data.gid + "";
  4152 + var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0;
  4153 + if (user_id > 0) {
  4154 + scene += "_" + user_id;
  4155 + }
  4156 + //-- 如果不是会员分享过来的要分享给别人 --
  4157 + if (getApp().globalData.room_id && th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) {
  4158 + //固定房间是第3个字符
  4159 + if (!user_id) scene += "_0";
  4160 + scene += "_" + getApp().globalData.room_id;
4123 4161 }
4124   - //-- 如果不是会员分享过来的要分享给别人 --
4125   - if(getApp().globalData.room_id && th.data.data.goods_id==getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) {
4126   - //固定房间是第3个字符
4127   - if(!user_id) scene+="_0";
4128   - scene+="_"+getApp().globalData.room_id ;
4129   - }
4130 4162 ///二微码
4131 4163 var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" +
4132   - os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo";
  4164 + os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo";
4133 4165  
4134 4166 console.log(path3);
4135 4167  
4136 4168 //读取文件成功则OK--
4137 4169 wx.getImageInfo({
4138 4170 src: path3,
4139   - success: function(res) {
  4171 + success: function (res) {
4140 4172 //回调写法
4141   - th.get_head_temp(th.get_goods_temp, function() {
  4173 + th.get_head_temp(th.get_goods_temp, function () {
4142 4174 var vpath = res.path;
4143 4175 var context = wx.createCanvasContext('share');
4144 4176 //先画背景
4145 4177 var pg_path = "../../../images/share/share_bg.png";
4146   -
4147   - // context.fillStyle="#FFFFFF";
4148   - // context.fillRect(0,0,554 * unit, 899 * unit);
4149   -
4150   - //-- 如果有自定义海报的时候,判断背景的图片 --
4151   - if(th.data.share_b_img){
4152   - pg_path=th.data.share_b_img;
4153   - }
  4178 +
  4179 + // context.fillStyle="#FFFFFF";
  4180 + // context.fillRect(0,0,554 * unit, 899 * unit);
  4181 +
  4182 + //-- 如果有自定义海报的时候,判断背景的图片 --
  4183 + if (th.data.share_b_img) {
  4184 + pg_path = th.data.share_b_img;
  4185 + }
4154 4186 context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
4155   -
4156   - //-- 是自定义海报的情况下 --
4157   - if(th.data.poster && parseInt(th.data.poster.style)==2) {
4158   - //在线上分享人的情况下
4159   - if(parseInt(th.data.poster.show_headpic)){
4160   - //获取坐标
4161   - var x=parseFloat(th.data.poster.head_x)*2;
4162   - var y=parseFloat(th.data.poster.head_y)*2;
4163   - var x1=(x+90) *unit;
4164   - var y1=(y+50) *unit;
4165   - //--昵称---
4166   - context.setFontSize(24 * unit)
4167   - context.setFillStyle("black")
4168   - context.fillText(app.globalData.userInfo.nickname, x1, y1);
4169   - var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit;
4170   - //强烈推荐 改许程
4171   - var tj_path = "../../../images/share/q_tj.png";
4172   - context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit);
4173   - context.setFontSize(16 * unit)
4174   - context.setLineJoin('round'); //交点设置成圆角
4175   - context.setFillStyle("white")
4176   - context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit);
4177   -
4178   - //context.setFillStyle("black")
4179   - //context.setFontSize(24 * unit)
4180   - //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit);
4181   - }
4182   - } else {
4183   - //--昵称---
4184   - context.setFontSize(24 * unit)
4185   - context.setFillStyle("black")
4186   - context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit);
4187   - var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit;
4188   - //强烈推荐 改许程
4189   - var tj_path = "../../../images/share/q_tj.png";
4190   - context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit);
4191   - context.setFontSize(16 * unit);
4192   - context.setLineJoin('round'); //交点设置成圆角
4193   - context.setFillStyle("white");
4194   - context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit);
4195   - }
4196   -
4197   - var share_title=th.data.data.goods_name;
4198   - if(th.data.prom_type==1 || th.data.prom_type==6 || th.data.prom_type==4){
4199   - share_title=th.data.prom_act.share_title;
4200   - if(!share_title) share_title=th.data.prom_act.title;
4201   - if(th.data.prom_type==4) share_title=th.data.prom_act.name;
  4187 +
  4188 + //-- 是自定义海报的情况下 --
  4189 + if (th.data.poster && parseInt(th.data.poster.style) == 2) {
  4190 + //在线上分享人的情况下
  4191 + if (parseInt(th.data.poster.show_headpic)) {
  4192 + //获取坐标
  4193 + var x = parseFloat(th.data.poster.head_x) * 2;
  4194 + var y = parseFloat(th.data.poster.head_y) * 2;
  4195 + var x1 = (x + 90) * unit;
  4196 + var y1 = (y + 50) * unit;
  4197 + //--昵称---
  4198 + context.setFontSize(24 * unit)
  4199 + context.setFillStyle("black")
  4200 + context.fillText(app.globalData.userInfo.nickname, x1, y1);
  4201 + var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit;
  4202 + //强烈推荐 改许程
  4203 + var tj_path = "../../../images/share/q_tj.png";
  4204 + context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit);
  4205 + context.setFontSize(16 * unit)
  4206 + context.setLineJoin('round'); //交点设置成圆角
  4207 + context.setFillStyle("white")
  4208 + context.fillText('强烈推荐', x1 + width + 8 * unit, y1 - 1 * unit);
  4209 +
  4210 + //context.setFillStyle("black")
  4211 + //context.setFontSize(24 * unit)
  4212 + //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit);
  4213 + }
  4214 + } else {
  4215 + //--昵称---
  4216 + context.setFontSize(24 * unit)
  4217 + context.setFillStyle("black")
  4218 + context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit);
  4219 + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit;
  4220 + //强烈推荐 改许程
  4221 + var tj_path = "../../../images/share/q_tj.png";
  4222 + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit);
  4223 + context.setFontSize(16 * unit);
  4224 + context.setLineJoin('round'); //交点设置成圆角
  4225 + context.setFillStyle("white");
  4226 + context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit);
  4227 + }
  4228 +
  4229 + var share_title = th.data.data.goods_name;
  4230 + if (th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) {
  4231 + share_title = th.data.prom_act.share_title;
  4232 + if (!share_title) share_title = th.data.prom_act.title;
  4233 + if (th.data.prom_type == 4) share_title = th.data.prom_act.name;
4202 4234 }
4203 4235  
4204 4236 //---产品名称---
4205 4237 //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
4206   - if(type!=4){
4207   - context.setFillStyle("black");
4208   - context.setFontSize(21.3 * unit)
4209   - th.draw_Text(context, share_title,
4210   - 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit);
4211   -
4212   - //------产品的价格-------
4213   - context.setFontSize(23 * unit)
4214   - context.setFillStyle("red")
4215   -
4216   -
4217   - var pri0 = th.data.data.shop_price;
4218   - if (th.data.prom_act)
4219   - pri0 = th.data.prom_act.price;
4220   - pri0 = parseFloat(pri0).toFixed(2);
4221   - var wd1=th.data.screenWidth-ut.measureText(pri0, 31 * unit)-25;
4222   - context.fillText("¥", wd1-15, 185 * unit);
4223   - context.setFontSize(31 * unit)
4224   - context.fillText(pri0, wd1, 185 * unit);
4225   -
4226   - //---市场价划掉---
4227   - context.setFillStyle("gray")
4228   - context.setFontSize(22 * unit)
4229   - pri0="¥" + th.data.data.market_price.toFixed(2);
4230   - var wd2=th.data.screenWidth-ut.measureText(pri0, 22 * unit)-25;
4231   - context.fillText(pri0, wd2, 213 * unit);
4232   -
4233   - context.setStrokeStyle('gray');
4234   - context.setLineWidth(1 * unit);
4235   - context.moveTo(wd2-5, 206 * unit);
4236   - context.lineTo(wd2+ut.measureText(pri0, 22 * unit)+5, 206 * unit);
4237   - context.stroke();
4238   -
4239   - }else{
4240   - context.setFillStyle("black");
4241   - context.setFontSize(21.3 * unit)
4242   - th.draw_Text(context, share_title,
4243   - 38 * unit, 170 * unit, 20 * unit, 300*unit, unit);
4244   - //------ 产品的价格 -----
4245   - var pri0 = th.data.prom_act.addmoney;
4246   - var integral=th.data.prom_act.integral;
4247   - var text= "";
4248   - if(integral){text=integral+"积分"; }
4249   - if(pri0 && integral){ text+="+";}
4250   - if(pri0){ text+="¥"+pri0;}
4251   -
4252   - if(!pri0 && !integral){ text="0积分";}
4253   - context.setFillStyle("red");
4254   - context.fillText(text, 38 * unit, 235 * unit);
4255   -
4256   - }
4257   -
  4238 + if (type != 4) {
  4239 + context.setFillStyle("black");
  4240 + context.setFontSize(21.3 * unit)
  4241 + th.draw_Text(context, share_title,
  4242 + 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit);
  4243 +
  4244 + //------产品的价格-------
  4245 + context.setFontSize(23 * unit)
  4246 + context.setFillStyle("red")
  4247 +
  4248 +
  4249 + var pri0 = th.data.data.shop_price;
  4250 + if (th.data.prom_act)
  4251 + pri0 = th.data.prom_act.price;
  4252 + pri0 = parseFloat(pri0).toFixed(2);
  4253 + var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25;
  4254 + context.fillText("¥", wd1 - 15, 185 * unit);
  4255 + context.setFontSize(31 * unit)
  4256 + context.fillText(pri0, wd1, 185 * unit);
  4257 +
  4258 + //---市场价划掉---
  4259 + context.setFillStyle("gray")
  4260 + context.setFontSize(22 * unit)
  4261 + pri0 = "¥" + th.data.data.market_price.toFixed(2);
  4262 + var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25;
  4263 + context.fillText(pri0, wd2, 213 * unit);
  4264 +
  4265 + context.setStrokeStyle('gray');
  4266 + context.setLineWidth(1 * unit);
  4267 + context.moveTo(wd2 - 5, 206 * unit);
  4268 + context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit);
  4269 + context.stroke();
  4270 +
  4271 + } else {
  4272 + context.setFillStyle("black");
  4273 + context.setFontSize(21.3 * unit)
  4274 + th.draw_Text(context, share_title,
  4275 + 38 * unit, 170 * unit, 20 * unit, 300 * unit, unit);
  4276 + //------ 产品的价格 -----
  4277 + var pri0 = th.data.prom_act.addmoney;
  4278 + var integral = th.data.prom_act.integral;
  4279 + var text = "";
  4280 + if (integral) { text = integral + "积分"; }
  4281 + if (pri0 && integral) { text += "+"; }
  4282 + if (pri0) { text += "¥" + pri0; }
  4283 +
  4284 + if (!pri0 && !integral) { text = "0积分"; }
  4285 + context.setFillStyle("red");
  4286 + context.fillText(text, 38 * unit, 235 * unit);
  4287 +
  4288 + }
  4289 +
4258 4290 //---中间大图---
4259 4291 context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit);
4260 4292 //-------大图后面就不一样了-----------
4261 4293 switch (type) {
4262 4294 case 0: //普通商品的展示
4263   - case 4:
  4295 + case 4:
4264 4296 //中间的几个字
4265   - if(th.data.poster && parseInt(th.data.poster.style)==2 ){
4266   - if(parseInt(th.data.poster.show_quality)){
4267   - var g_path = "../../../images/share/s_gou.png";
4268   - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
4269   - context.setFillStyle("red")
4270   - context.setFontSize(18 * unit)
4271   - context.fillText("正品保证", 84 * unit, 690 * unit);
4272   -
4273   - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
4274   - context.setFillStyle("red")
4275   - context.setFontSize(18 * unit)
4276   - context.fillText("纯实体店", 246 * unit, 690 * unit);
4277   -
4278   - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
4279   - context.setFillStyle("red")
4280   - context.setFontSize(18 * unit)
4281   - context.fillText("官方验证", 420 * unit, 690 * unit);
4282   - }
4283   -
4284   - }else{
4285   - var g_path = "../../../images/share/s_gou.png";
4286   - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
4287   - context.setFillStyle("red")
4288   - context.setFontSize(18 * unit)
4289   - context.fillText("正品保证", 84 * unit, 690 * unit);
4290   -
4291   - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
4292   - context.setFillStyle("red")
4293   - context.setFontSize(18 * unit)
4294   - context.fillText("纯实体店", 246 * unit, 690 * unit);
4295   -
4296   - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
4297   - context.setFillStyle("red")
4298   - context.setFontSize(18 * unit)
4299   - context.fillText("官方验证", 420 * unit, 690 * unit);
4300   - }
4301   -
4302   -
4303   - //---画线---
4304   - context.setLineWidth(1 * unit)
4305   - context.moveTo(32 * unit, 710 * unit)
4306   - context.lineTo(520 * unit, 710 * unit)
4307   - context.stroke();
4308   -
4309   - //---文字---
4310   - context.setFillStyle("black")
4311   - context.setFontSize(22 * unit)
4312   -
4313   - if(type==0){
4314   - // 原来start --->
4315   - context.setFontSize(24 * unit)
4316   - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit);
4317   -
4318   - context.setFontSize(22 * unit)
4319   - context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit);
4320   - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit);
4321   -
4322   - }else{
4323   - context.setFontSize(24 * unit)
4324   - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit);
4325   - context.setFontSize(22 * unit)
4326   - context.fillText("长按识别二维码", 40 * unit, 806 * unit);
4327   - context.fillText("立即开始兑换", 40 * unit, 846 * unit);
4328   -
4329   -
4330   - }
4331   -
  4297 + if (th.data.poster && parseInt(th.data.poster.style) == 2) {
  4298 + if (parseInt(th.data.poster.show_quality)) {
  4299 + var g_path = "../../../images/share/s_gou.png";
  4300 + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
  4301 + context.setFillStyle("red")
  4302 + context.setFontSize(18 * unit)
  4303 + context.fillText("正品保证", 84 * unit, 690 * unit);
  4304 +
  4305 + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
  4306 + context.setFillStyle("red")
  4307 + context.setFontSize(18 * unit)
  4308 + context.fillText("纯实体店", 246 * unit, 690 * unit);
  4309 +
  4310 + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
  4311 + context.setFillStyle("red")
  4312 + context.setFontSize(18 * unit)
  4313 + context.fillText("官方验证", 420 * unit, 690 * unit);
  4314 + }
  4315 +
  4316 + } else {
  4317 + var g_path = "../../../images/share/s_gou.png";
  4318 + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
  4319 + context.setFillStyle("red")
  4320 + context.setFontSize(18 * unit)
  4321 + context.fillText("正品保证", 84 * unit, 690 * unit);
  4322 +
  4323 + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
  4324 + context.setFillStyle("red")
  4325 + context.setFontSize(18 * unit)
  4326 + context.fillText("纯实体店", 246 * unit, 690 * unit);
  4327 +
  4328 + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
  4329 + context.setFillStyle("red")
  4330 + context.setFontSize(18 * unit)
  4331 + context.fillText("官方验证", 420 * unit, 690 * unit);
  4332 + }
  4333 +
  4334 +
  4335 + //---画线---
  4336 + context.setLineWidth(1 * unit)
  4337 + context.moveTo(32 * unit, 710 * unit)
  4338 + context.lineTo(520 * unit, 710 * unit)
  4339 + context.stroke();
  4340 +
  4341 + //---文字---
  4342 + context.setFillStyle("black")
  4343 + context.setFontSize(22 * unit)
  4344 +
  4345 + if (type == 0) {
  4346 + // 原来start --->
  4347 + context.setFontSize(24 * unit)
  4348 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit);
  4349 +
  4350 + context.setFontSize(22 * unit)
  4351 + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit);
  4352 + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit);
  4353 +
  4354 + } else {
  4355 + context.setFontSize(24 * unit)
  4356 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit);
  4357 + context.setFontSize(22 * unit)
  4358 + context.fillText("长按识别二维码", 40 * unit, 806 * unit);
  4359 + context.fillText("立即开始兑换", 40 * unit, 846 * unit);
  4360 +
  4361 +
  4362 + }
  4363 +
4332 4364 //---二维吗图---
4333   - //-- 自定义海报 --
4334   - if(th.data.poster){
4335   - var erm_x= parseFloat(th.data.poster.ewm_x)*2;
4336   - var erm_y= parseFloat(th.data.poster.ewm_y)*2;
4337   - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
4338   - }else{
4339   - //---二维吗图---
4340   - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
4341   - }
4342   -
  4365 + //-- 自定义海报 --
  4366 + if (th.data.poster) {
  4367 + var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
  4368 + var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
  4369 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
  4370 + } else {
  4371 + //---二维吗图---
  4372 + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
  4373 + }
  4374 +
4343 4375 break;
4344 4376 case 1: //秒杀商品的展示
4345 4377 //---画线---
... ... @@ -4351,27 +4383,27 @@ Page({
4351 4383 //画秒杀的图片
4352 4384 var miaos_path = '../../../images/share/miao_share.png';
4353 4385 context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit);
4354   -
4355   - context.setFillStyle("black")
4356   - context.setFontSize(24 * unit)
4357   - context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit);
  4386 +
  4387 + context.setFillStyle("black")
  4388 + context.setFontSize(24 * unit)
  4389 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit);
4358 4390 //---文字---
4359 4391 context.setFontSize(22 * unit)
4360 4392 context.setFillStyle("black")
4361 4393 context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit);
4362 4394 context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit);
4363   -
4364   -
  4395 +
  4396 +
4365 4397 //---二维吗图---
4366 4398 //-- 自定义海报 --
4367   - if(th.data.poster){
4368   - var erm_x= parseFloat(th.data.poster.ewm_x)*2;
4369   - var erm_y= parseFloat(th.data.poster.ewm_y)*2;
4370   - context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit);
4371   - }else{
4372   - //---二维吗图---
4373   - context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit);
4374   - }
  4399 + if (th.data.poster) {
  4400 + var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
  4401 + var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
  4402 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit);
  4403 + } else {
  4404 + //---二维吗图---
  4405 + context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit);
  4406 + }
4375 4407 break;
4376 4408  
4377 4409 case 2: //会员团和商家团的展示
... ... @@ -4381,10 +4413,10 @@ Page({
4381 4413 context.lineTo(520 * unit, 670 * unit)
4382 4414 context.stroke();
4383 4415 //---文字---
4384   -
4385   - context.setFillStyle("black")
4386   - context.setFontSize(24 * unit)
4387   - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit);
  4416 +
  4417 + context.setFillStyle("black")
  4418 + context.setFontSize(24 * unit)
  4419 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit);
4388 4420  
4389 4421 //绘制成团图片
4390 4422 var ct_img = "../../../images/share/ct_num.png";
... ... @@ -4400,25 +4432,25 @@ Page({
4400 4432 }
4401 4433 context.setFontSize(22 * unit)
4402 4434 context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit);
4403   -
4404   - context.setFillStyle("gray")
  4435 +
  4436 + context.setFillStyle("gray")
4405 4437 context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit);
4406 4438 context.setFillStyle("black")
4407 4439 context.font = 'normal bold 18px sans-serif';
4408 4440 context.setFontSize(21.3 * unit)
4409 4441 context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit);
4410   -
4411   -
  4442 +
  4443 +
4412 4444 //---二维吗图---
4413 4445 //-- 自定义海报 --
4414   - if(th.data.poster){
4415   - var erm_x= parseFloat(th.data.poster.ewm_x)*2;
4416   - var erm_y= parseFloat(th.data.poster.ewm_y)*2;
4417   - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
4418   - }else{
4419   - //---二维吗图---
4420   - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
4421   - }
  4446 + if (th.data.poster) {
  4447 + var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
  4448 + var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
  4449 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
  4450 + } else {
  4451 + //---二维吗图---
  4452 + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
  4453 + }
4422 4454 break
4423 4455 case 3: //阶梯团的展示
4424 4456 //---画线---
... ... @@ -4427,11 +4459,11 @@ Page({
4427 4459 context.lineTo(520 * unit, 670 * unit)
4428 4460 context.stroke();
4429 4461 //---文字---
4430   -
4431   - context.setFillStyle("black")
4432   - context.setFontSize(24 * unit)
4433   - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit);
4434   -
  4462 +
  4463 + context.setFillStyle("black")
  4464 + context.setFontSize(24 * unit)
  4465 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit);
  4466 +
4435 4467 //---绘制中间阶梯的价格---
4436 4468 var list = th.data.prom_act.ct_rylist;
4437 4469 for (var i = 0; i < list.length; i++) {
... ... @@ -4448,80 +4480,80 @@ Page({
4448 4480 context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit);
4449 4481 }
4450 4482 //----------------下面部分----------------
4451   - // context.setFillStyle("gray")
4452   - // context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit);
4453   - // context.setFillStyle("black")
4454   - // context.font = 'normal bold 18px sans-serif';
4455   - // context.setFontSize(22 * unit)
4456   - // context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit);
  4483 + // context.setFillStyle("gray")
  4484 + // context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit);
  4485 + // context.setFillStyle("black")
  4486 + // context.font = 'normal bold 18px sans-serif';
  4487 + // context.setFontSize(22 * unit)
  4488 + // context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit);
4457 4489 //context.setFillStyle("gray")
4458   - context.setFillStyle("black")
4459   - context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit);
  4490 + context.setFillStyle("black")
  4491 + context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit);
4460 4492 //context.font = 'normal bold 18px sans-serif';
4461 4493 context.setFontSize(21 * unit)
4462 4494 context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit);
4463   -
4464   -
4465   - //-- 自定义海报 --
4466   - if(th.data.poster){
4467   - var erm_x= parseFloat(th.data.poster.ewm_x)*2;
4468   - var erm_y= parseFloat(th.data.poster.ewm_y)*2;
4469   - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
4470   - }else{
4471   - //---二维吗图---
4472   - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
4473   - }
  4495 +
  4496 +
  4497 + //-- 自定义海报 --
  4498 + if (th.data.poster) {
  4499 + var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
  4500 + var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
  4501 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
  4502 + } else {
  4503 + //---二维吗图---
  4504 + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
  4505 + }
4474 4506 break
4475   -
4476   -
  4507 +
  4508 +
  4509 + }
  4510 +
  4511 +
  4512 + //--- 如果是自定义海报的时候 ---
  4513 + if (th.data.poster && parseInt(th.data.poster.style) == 2) {
  4514 +
  4515 + //如果显示会员信息的话
  4516 + if (parseInt(th.data.poster.show_headpic)) {
  4517 + //获取坐标
  4518 + var x = parseFloat(th.data.poster.head_x) * 2;
  4519 + var y = parseFloat(th.data.poster.head_y) * 2;
  4520 + //---绘制圆形要放在最后----
  4521 + context.save();
  4522 + context.beginPath();
  4523 + var h_x = x * unit;
  4524 + var h_y = y * unit;
  4525 + var h_r = 40 * unit;
  4526 + var cx = h_x + h_r;
  4527 + var cy = h_y + h_r;
  4528 + context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
  4529 + context.closePath();
  4530 + context.fill();
  4531 + context.clip();
  4532 + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
  4533 + context.restore();
  4534 + }
  4535 +
  4536 + } else {
  4537 + //---绘制圆形要放在最后----
  4538 + context.save();
  4539 + context.beginPath();
  4540 + var h_x = 60 * unit;
  4541 + var h_y = 24 * unit;
  4542 + var h_r = 40 * unit;
  4543 + var cx = h_x + h_r;
  4544 + var cy = h_y + h_r;
  4545 + context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
  4546 + context.closePath();
  4547 + context.fill();
  4548 + context.clip();
  4549 + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
  4550 + context.restore();
4477 4551 }
4478   -
4479   -
4480   - //--- 如果是自定义海报的时候 ---
4481   - if(th.data.poster && parseInt(th.data.poster.style)==2){
4482   -
4483   - //如果显示会员信息的话
4484   - if(parseInt(th.data.poster.show_headpic)){
4485   - //获取坐标
4486   - var x= parseFloat(th.data.poster.head_x)*2;
4487   - var y=parseFloat(th.data.poster.head_y)*2;
4488   - //---绘制圆形要放在最后----
4489   - context.save();
4490   - context.beginPath();
4491   - var h_x = x* unit;
4492   - var h_y = y * unit;
4493   - var h_r = 40 * unit;
4494   - var cx = h_x + h_r;
4495   - var cy = h_y + h_r;
4496   - context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
4497   - context.closePath();
4498   - context.fill();
4499   - context.clip();
4500   - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
4501   - context.restore();
4502   - }
4503   -
4504   - }else{
4505   - //---绘制圆形要放在最后----
4506   - context.save();
4507   - context.beginPath();
4508   - var h_x = 60 * unit;
4509   - var h_y = 24 * unit;
4510   - var h_r = 40 * unit;
4511   - var cx = h_x + h_r;
4512   - var cy = h_y + h_r;
4513   - context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
4514   - context.closePath();
4515   - context.fill();
4516   - context.clip();
4517   - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
4518   - context.restore();
4519   - }
4520   -
4521   -
  4552 +
  4553 +
4522 4554 //把画板内容绘制成图片,并回调 画板图片路径
4523   - context.draw(false, function() {
4524   - setTimeout(function() {
  4555 + context.draw(false, function () {
  4556 + setTimeout(function () {
4525 4557 wx.canvasToTempFilePath({
4526 4558 x: 0,
4527 4559 y: 0,
... ... @@ -4530,40 +4562,40 @@ Page({
4530 4562 destWidth: 1.2 * 750 * 750 / that.data.screenWidth,
4531 4563 destHeight: 1.2 * 1217 * 750 / that.data.screenWidth,
4532 4564 canvasId: 'share',
4533   - success: function (res) {
4534   -
4535   - that.setData({
4536   - shareImgPath: res.tempFilePath,
4537   - canvasHidden: true
4538   - })
  4565 + success: function (res) {
4539 4566  
4540   - if (!res.tempFilePath) {
4541   - wx.showModal({
4542   - title: '提示',
4543   - content: '图片绘制中,请稍后重试',
4544   - showCancel: false
4545   - })
4546   - return false;
4547   - }
  4567 + that.setData({
  4568 + shareImgPath: res.tempFilePath,
  4569 + canvasHidden: true
  4570 + })
4548 4571  
4549   - // wx.previewImage({
4550   - // //将图片预览出来
4551   - // urls: [that.data.shareImgPath]
4552   - // });
4553   - that.setData({
4554   - showPoster: true,
4555   - });
4556   - wx.hideLoading();
  4572 + if (!res.tempFilePath) {
  4573 + wx.showModal({
  4574 + title: '提示',
  4575 + content: '图片绘制中,请稍后重试',
  4576 + showCancel: false
  4577 + })
  4578 + return false;
4557 4579 }
  4580 +
  4581 + // wx.previewImage({
  4582 + // //将图片预览出来
  4583 + // urls: [that.data.shareImgPath]
  4584 + // });
  4585 + that.setData({
  4586 + showPoster: true,
  4587 + });
  4588 + wx.hideLoading();
  4589 + }
4558 4590 })
4559 4591 }, 500)
4560 4592  
4561 4593 });
4562 4594 });
4563 4595 },
4564   - fail: function(res) {
4565   - console.log(res);
4566   - wx.hideLoading();
  4596 + fail: function (res) {
  4597 + console.log(res);
  4598 + wx.hideLoading();
4567 4599  
4568 4600 }
4569 4601 });
... ... @@ -4571,7 +4603,7 @@ Page({
4571 4603  
4572 4604  
4573 4605 //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
4574   - draw_Text: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) {
  4606 + draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) {
4575 4607 var lineWidth = 0;
4576 4608 var lastSubStrIndex = 0; //每次开始截取的字符串的索引
4577 4609 var han = 0;
... ... @@ -4600,7 +4632,7 @@ Page({
4600 4632  
4601 4633 // ----视频图片----
4602 4634 // 图片计数器
4603   - swiperChange: function(e) {
  4635 + swiperChange: function (e) {
4604 4636 var that = this;
4605 4637 if (e.detail.current > 0) {
4606 4638 that.setData({
... ... @@ -4621,7 +4653,7 @@ Page({
4621 4653 },
4622 4654  
4623 4655 /*---视频相关--*/
4624   - videopicture: function(e) {
  4656 + videopicture: function (e) {
4625 4657 var vipi = e.currentTarget.dataset.vipi;
4626 4658 this.setData({
4627 4659 videopicture: vipi,
... ... @@ -4631,14 +4663,14 @@ Page({
4631 4663 });
4632 4664 },
4633 4665  
4634   - videoPlay: function(e) {
  4666 + videoPlay: function (e) {
4635 4667 var _index = e.currentTarget.id
4636 4668 this.setData({
4637 4669 _index: _index,
4638 4670 noon: 1
4639 4671 })
4640 4672  
4641   - setTimeout(function() {
  4673 + setTimeout(function () {
4642 4674 //将点击视频进行播放
4643 4675 var videoContext = wx.createVideoContext(_index)
4644 4676 videoContext.play();
... ... @@ -4648,7 +4680,7 @@ Page({
4648 4680  
4649 4681  
4650 4682 //--获取头像的本地缓存,回调写法--
4651   - get_head_temp: function(tt, func) {
  4683 + get_head_temp: function (tt, func) {
4652 4684 var ee = this;
4653 4685 if (ee.data.share_head) {
4654 4686 tt(func);
... ... @@ -4664,12 +4696,12 @@ Page({
4664 4696 path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn");
4665 4697 wx.getImageInfo({
4666 4698 src: path2,
4667   - success: function(res) {
  4699 + success: function (res) {
4668 4700 //res.path是网络图片的本地地址
4669 4701 ee.data.share_head = res.path;
4670 4702 tt(func);
4671 4703 },
4672   - fail: function(res) {
  4704 + fail: function (res) {
4673 4705 ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的
4674 4706 tt(func);
4675 4707 }
... ... @@ -4677,35 +4709,35 @@ Page({
4677 4709 }
4678 4710 },
4679 4711 //--获取商品图片的本地缓存,回调写法--
4680   - get_goods_temp: function(tt) {
  4712 + get_goods_temp: function (tt) {
4681 4713 var ee = this;
4682 4714 if (ee.data.share_goods_img) {
4683 4715 tt();
4684 4716 return false;
4685 4717 }
4686 4718  
4687   - var img_url=ee.data.data.original_img;
4688   - if((this.data.prom_type==1 || this.data.prom_type==6) && this.data.prom_act.share_imgurl){
4689   - img_url=this.data.iurl+this.data.prom_act.share_imgurl;
  4719 + var img_url = ee.data.data.original_img;
  4720 + if ((this.data.prom_type == 1 || this.data.prom_type == 6) && this.data.prom_act.share_imgurl) {
  4721 + img_url = this.data.iurl + this.data.prom_act.share_imgurl;
4690 4722 }
4691 4723  
4692 4724 //获取商品是分享图信息
4693 4725 wx.getImageInfo({
4694 4726 src: img_url,
4695   - success: function(res) {
4696   - //res.path是网络图片的本地地址
4697   - ee.data.share_goods_img = res.path;
4698   - tt();
  4727 + success: function (res) {
  4728 + //res.path是网络图片的本地地址
  4729 + ee.data.share_goods_img = res.path;
  4730 + tt();
4699 4731 },
4700   - fail: function(res) {
4701   - ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的
4702   - tt();
  4732 + fail: function (res) {
  4733 + ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的
  4734 + tt();
4703 4735 }
4704 4736 });
4705 4737 },
4706 4738  
4707 4739 //--外侧评价的点击效果---
4708   - clik_evaluate: function(e) {
  4740 + clik_evaluate: function (e) {
4709 4741 var val = e.currentTarget.dataset.val;
4710 4742 this.setData({
4711 4743 activeCategoryId: 2,
... ... @@ -4716,19 +4748,19 @@ Page({
4716 4748 },
4717 4749  
4718 4750 //--跳转到商品详情页面--
4719   - go_goods: function(e) {
  4751 + go_goods: function (e) {
4720 4752 var gid = e.currentTarget.dataset.gid;
4721 4753 var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid;
4722 4754 getApp().goto(url);
4723 4755 },
4724 4756  
4725 4757 //--跳转到支付尾款界面--
4726   - go_pay_wk: function() {
  4758 + go_pay_wk: function () {
4727 4759 var url = "/pages/cart/cart_wk/cart_wk?order_id=" + this.data.wk_order_id;
4728 4760 getApp().goto(url);
4729 4761 },
4730 4762  
4731   - pop_err_img: function(e) {
  4763 + pop_err_img: function (e) {
4732 4764 var txt = e.currentTarget.dataset.errorimg;
4733 4765 var ob = {};
4734 4766 ob[txt] = this.data.iurl + "/miniapp/images/default_g_img.gif";
... ... @@ -4736,11 +4768,11 @@ Page({
4736 4768 },
4737 4769  
4738 4770 //--调用更新阶梯团的接口--
4739   - update_jiti: function(id) {
  4771 + update_jiti: function (id) {
4740 4772 var th = this;
4741 4773 //--更新阶梯团--
4742 4774 getApp().request.put("/api/weshop/teamgroup/updateTeamOrder/" + os.stoid + "/" + id, {
4743   - success: function(ee) {
  4775 + success: function (ee) {
4744 4776 //--等于0是要去支付尾款,接口调用失败,就要去查看参团详情--
4745 4777 if (ee.data.code == 0) {
4746 4778 th.setData({
... ... @@ -4755,21 +4787,21 @@ Page({
4755 4787 })
4756 4788 },
4757 4789 // 选择门店
4758   - choice_store: function(ee) {
  4790 + choice_store: function (ee) {
4759 4791 var th = this;
4760   - var ind=ee.currentTarget.dataset.ind;
  4792 + var ind = ee.currentTarget.dataset.ind;
4761 4793 var bconfig = th.data.bconfig;
4762 4794  
4763   - if(!th.data.only_pk && !th.data.def_pickpu_list){
  4795 + if (!th.data.only_pk && !th.data.def_pickpu_list) {
4764 4796 getApp().confirmBox("门店库存不足", null, 25000, !1);
4765 4797 return false;
4766 4798 }
4767 4799  
4768   - if(th.data.only_pk && !th.data.only_pk.length){
  4800 + if (th.data.only_pk && !th.data.only_pk.length) {
4769 4801 getApp().confirmBox("门店库存不足", null, 25000, !1);
4770 4802 return false;
4771 4803 }
4772   - if(th.data.def_pickpu_list && !th.data.def_pickpu_list.length){
  4804 + if (th.data.def_pickpu_list && !th.data.def_pickpu_list.length) {
4773 4805 getApp().confirmBox("门店库存不足", null, 25000, !1);
4774 4806 return false;
4775 4807 }
... ... @@ -4778,7 +4810,7 @@ Page({
4778 4810 if (bconfig && bconfig.is_sort_storage) {
4779 4811 wx.getLocation({
4780 4812 type: 'gcj02',
4781   - success: function(res) {
  4813 + success: function (res) {
4782 4814  
4783 4815 th.data.lat = res.latitude;
4784 4816 th.data.lon = res.longitude;
... ... @@ -4789,7 +4821,7 @@ Page({
4789 4821 //th.onShow();
4790 4822 th.get_sto(th.data.is_normal);
4791 4823 },
4792   - fail: function(res) {
  4824 + fail: function (res) {
4793 4825 //th.onShow();
4794 4826 th.data.is_get_local_ok = 1;
4795 4827 th.get_sto(th.data.is_normal);
... ... @@ -4808,19 +4840,19 @@ Page({
4808 4840  
4809 4841 }
4810 4842 })
4811   - }else{
  4843 + } else {
4812 4844 th.data.is_get_local_ok = 1;
4813 4845 th.get_sto(th.data.is_normal);
4814 4846 }
4815 4847  
4816   - if(ind!=undefined && ind!=null ){
  4848 + if (ind != undefined && ind != null) {
4817 4849 this.setData({
4818 4850 open_ind_store: ind,
4819 4851 store: 1,
4820 4852 openSpecModal: !1,
4821 4853 openSpecModal_pt: !1
4822 4854 })
4823   - }else{
  4855 + } else {
4824 4856 this.setData({
4825 4857 store: 1,
4826 4858 openSpecModal: !1,
... ... @@ -4829,17 +4861,17 @@ Page({
4829 4861 }
4830 4862 },
4831 4863 //关闭选择门店
4832   - close_popup: function(e) {
4833   - var th=this;
  4864 + close_popup: function (e) {
  4865 + var th = this;
4834 4866 this.setData({
4835 4867 store: 0,
4836 4868 choice_sort_store: 0,
4837 4869 sort_store: 0,
4838   - fir_pick_index:0,
4839   - sec_pick_index:0
  4870 + fir_pick_index: 0,
  4871 + sec_pick_index: 0
4840 4872 })
4841 4873  
4842   - var openindstore=this.data.open_ind_store;
  4874 + var openindstore = this.data.open_ind_store;
4843 4875 if (openindstore == 1) {
4844 4876 th.setData({
4845 4877 openSpecModal: !0,
... ... @@ -4871,23 +4903,23 @@ Page({
4871 4903 },
4872 4904  
4873 4905 //选择更多门店
4874   - more_store: function() {
  4906 + more_store: function () {
4875 4907 this.setData({
4876 4908 sort_store: 1
4877 4909 });
4878 4910 },
4879   - sort_store: function() {
  4911 + sort_store: function () {
4880 4912  
4881 4913 },
4882 4914 // 返回按钮
4883   - returns: function() {
  4915 + returns: function () {
4884 4916 this.setData({
4885 4917 sort_store: 0,
4886 4918 choice_sort_store: 0
4887 4919 });
4888 4920 },
4889 4921 //---选择分类门店---
4890   - choice_sort_store: function(e) {
  4922 + choice_sort_store: function (e) {
4891 4923 var index = e.currentTarget.dataset.index;
4892 4924 var region_name = e.currentTarget.dataset.region;
4893 4925 var item = this.data.all_sto[index];
... ... @@ -4900,9 +4932,9 @@ Page({
4900 4932 });
4901 4933 },
4902 4934  
4903   - choose_for_store_fir: function(e) {
  4935 + choose_for_store_fir: function (e) {
4904 4936 var index_c = e.currentTarget.dataset.ind;
4905   - var th=this;
  4937 + var th = this;
4906 4938 th.setData({
4907 4939 fir_pick_index: index_c
4908 4940 })
... ... @@ -4910,53 +4942,53 @@ Page({
4910 4942 },
4911 4943  
4912 4944 //如果开启线下库存,已经急速库存才会使用
4913   - async check_the_pick(item,func){
4914   - var th=this;
4915   - var goodsinfo=th.data.sele_g;
4916   - var erpwareid=goodsinfo.erpwareid;
4917   - var plist=null;
4918   - var lock=0;
  4945 + async check_the_pick(item, func) {
  4946 + var th = this;
  4947 + var goodsinfo = th.data.sele_g;
  4948 + var erpwareid = goodsinfo.erpwareid;
  4949 + var plist = null;
  4950 + var lock = 0;
4919 4951  
4920 4952 //---如果是活动的时候,同时不是普通购买---
4921   - if((th.data.prom_type==1 || th.data.prom_type==6 || th.data.prom_type==4) && !th.data.is_normal ) {
  4953 + if ((th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) && !th.data.is_normal) {
4922 4954 func(); return false;
4923 4955 }
4924 4956  
4925   - if(this.data.sales_rules!=2){
  4957 + if (this.data.sales_rules != 2) {
4926 4958 func();
4927   - }else{
  4959 + } else {
4928 4960  
4929 4961 //先读取门店的lock
4930   - await getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
4931   - data:{store_id:os.stoid,wareId:goodsinfo.goods_id,storageId:item.pickup_id,pageSize:1000}
4932   - }).then(res=>{
4933   - if(res.data.code==0 && res.data.data.total>0){
4934   - for(var i in res.data.data.pageData )
4935   - lock+=res.data.data.pageData[i].outQty;
  4962 + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
  4963 + data: { store_id: os.stoid, wareId: goodsinfo.goods_id, storageId: item.pickup_id, pageSize: 1000 }
  4964 + }).then(res => {
  4965 + if (res.data.code == 0 && res.data.data.total > 0) {
  4966 + for (var i in res.data.data.pageData)
  4967 + lock += res.data.data.pageData[i].outQty;
4936 4968 }
4937 4969 })
4938 4970 //读取线下的门店库存
4939   - await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
4940   - data:{storageNos:item.pickup_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid}
4941   - }).then(res=>{
4942   - if(res.data.code==0 && res.data.data.total>0){
4943   - plist=res.data.data.pageData[0];
  4971 + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
  4972 + data: { storageNos: item.pickup_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid }
  4973 + }).then(res => {
  4974 + if (res.data.code == 0 && res.data.data.total > 0) {
  4975 + plist = res.data.data.pageData[0];
4944 4976 }
4945 4977 })
4946 4978  
4947   - if(plist && plist.CanOutQty-lock>0){
4948   - item.CanOutQty=plist.CanOutQty-lock;
  4979 + if (plist && plist.CanOutQty - lock > 0) {
  4980 + item.CanOutQty = plist.CanOutQty - lock;
4949 4981 func();
4950 4982 return false;
4951 4983 }
4952   - getApp().my_warnning(item.pickup_name+"库存不足!", 0, th);
  4984 + getApp().my_warnning(item.pickup_name + "库存不足!", 0, th);
4953 4985  
4954 4986 }
4955 4987 },
4956 4988  
4957 4989  
4958 4990 //确定def_pick为选择的门店
4959   - sure_pick: function(e) {
  4991 + sure_pick: function (e) {
4960 4992 var th = this;
4961 4993 var item = null;
4962 4994 var openindstore = th.data.open_ind_store;
... ... @@ -4974,20 +5006,20 @@ Page({
4974 5006 item = th.data.sec_sto.s_arr[index];
4975 5007 }
4976 5008  
4977   - if(!th.data.sele_g) return false;
4978   - //判断门店的配送方式是不是匹配
4979   - var g_distr_type = th.data.sele_g.distr_type;
4980   - if(item.distr_type!=0 && g_distr_type!=0 && item.distr_type!=g_distr_type){
4981   - wx.showToast({
4982   - title: "门店配送方式不匹配",
4983   - icon: 'none',
4984   - duration: 2000
4985   - });
4986   - return false;
4987   - }
4988   -
  5009 + if (!th.data.sele_g) return false;
  5010 + //判断门店的配送方式是不是匹配
  5011 + var g_distr_type = th.data.sele_g.distr_type;
  5012 + if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) {
  5013 + wx.showToast({
  5014 + title: "门店配送方式不匹配",
  5015 + icon: 'none',
  5016 + duration: 2000
  5017 + });
  5018 + return false;
  5019 + }
  5020 +
4989 5021 //--回调函数的用法--
4990   - th.check_the_pick(item,function(){
  5022 + th.check_the_pick(item, function () {
4991 5023 th.setData({
4992 5024 def_pick_store: item,
4993 5025 sto_sele_name: item.pickup_name,
... ... @@ -5023,15 +5055,15 @@ Page({
5023 5055 choice_sort_store: 0,
5024 5056 sort_store: 0
5025 5057 })
5026   - }
5027   - //如果商品没有其他活动,要取一下线下价格
5028   - th.get_off_price();
  5058 + }
  5059 + //如果商品没有其他活动,要取一下线下价格
  5060 + th.get_off_price();
5029 5061 })
5030 5062 },
5031 5063 //---点击二级之后的选择---
5032   - choose_for_store: function(e) {
  5064 + choose_for_store: function (e) {
5033 5065 var index_c = e.currentTarget.dataset.ind;
5034   - var th=this;
  5066 + var th = this;
5035 5067 th.setData({
5036 5068 sec_pick_index: index_c,
5037 5069 fir_pick_index: index_c
... ... @@ -5039,7 +5071,7 @@ Page({
5039 5071  
5040 5072 },
5041 5073 //把选择的门店设置成默认的门店def_pick
5042   - set_def_pick: function(e) {
  5074 + set_def_pick: function (e) {
5043 5075 var th = this;
5044 5076 var item = null;
5045 5077 if (th.data.choice_sort_store == 0) {
... ... @@ -5053,30 +5085,30 @@ Page({
5053 5085 var index = th.data.sec_pick_index;
5054 5086 item = th.data.sec_sto.s_arr[index];
5055 5087 }
5056   -
5057   - //判断门店的配送方式是不是匹配
5058   - var g_distr_type = th.data.sele_g.distr_type;
5059   - if(item.distr_type!=0 && g_distr_type!=0 && item.distr_type!=g_distr_type){
5060   - wx.showToast({
5061   - title: "门店配送方式不匹配",
5062   - icon: 'none',
5063   - duration: 2000
5064   - });
5065   - return false;
5066   - }
  5088 +
  5089 + //判断门店的配送方式是不是匹配
  5090 + var g_distr_type = th.data.sele_g.distr_type;
  5091 + if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) {
  5092 + wx.showToast({
  5093 + title: "门店配送方式不匹配",
  5094 + icon: 'none',
  5095 + duration: 2000
  5096 + });
  5097 + return false;
  5098 + }
5067 5099  
5068 5100 //先设置之前,要判断是不是有库存
5069   - th.check_the_pick(item,function(){
  5101 + th.check_the_pick(item, function () {
5070 5102 var store_id = o.stoid;
5071 5103 var user_id = getApp().globalData.user_id;
5072 5104 var def_pickup_id = item.pickup_id;
5073 5105  
5074 5106 getApp().request.put('/api/weshop/users/update', {
5075 5107 data: {
5076   - user_id:user_id,
5077   - def_pickup_id:def_pickup_id
  5108 + user_id: user_id,
  5109 + def_pickup_id: def_pickup_id
5078 5110 },
5079   - success: function(res) {
  5111 + success: function (res) {
5080 5112 if (res.data.code == 0) {
5081 5113 if (th.data.choice_sort_store == 0) th.setData({
5082 5114 fir_pick_index: 0
... ... @@ -5084,7 +5116,7 @@ Page({
5084 5116 getApp().globalData.pk_store = item;
5085 5117 } else {
5086 5118 //s.showWarning("设置默认门店地址失败", null, 500, !1);
5087   - getApp().my_warnning("设置默认门店地址失败",0,th)
  5119 + getApp().my_warnning("设置默认门店地址失败", 0, th)
5088 5120 }
5089 5121  
5090 5122 }
... ... @@ -5133,27 +5165,27 @@ Page({
5133 5165 sort_store: 0,
5134 5166 })
5135 5167 }
5136   -
5137   - //如果商品没有其他活动,要取一下线下价格
5138   - th.get_off_price();
5139   -
  5168 +
  5169 + //如果商品没有其他活动,要取一下线下价格
  5170 + th.get_off_price();
  5171 +
5140 5172 })
5141 5173 },
5142 5174  
5143   - wait_for_store_config: function() {
  5175 + wait_for_store_config: function () {
5144 5176 var th = this;
5145   - var t_time = setInterval(function() {
  5177 + var t_time = setInterval(function () {
5146 5178 if (th.data.bconfig == null) false;
5147 5179 var e = th.data.bconfig;
5148 5180 if (e && e.is_sort_storage) {
5149 5181 wx.getLocation({
5150 5182 type: 'gcj02',
5151   - success: function(res) {
  5183 + success: function (res) {
5152 5184 th.data.lat = res.latitude;
5153 5185 th.data.lon = res.longitude;
5154 5186 th.data.is_get_local_ok = 1;
5155 5187 },
5156   - fail: function(res) {
  5188 + fail: function (res) {
5157 5189 if (res.errCode == 2) {
5158 5190 th.setData({
5159 5191 is_gps: 0
... ... @@ -5178,9 +5210,9 @@ Page({
5178 5210 }, 500)
5179 5211 },
5180 5212 //显示全部
5181   - toggleHandler: function(e) {
  5213 + toggleHandler: function (e) {
5182 5214 var that = this,
5183   - index = e.currentTarget.dataset.index;
  5215 + index = e.currentTarget.dataset.index;
5184 5216 for (var i = 0; i < that.data.comments.length; i++) {
5185 5217 if (index == i) {
5186 5218 for (var i = 0; i < that.data.comments.length; i++) {
... ... @@ -5195,9 +5227,9 @@ Page({
5195 5227 },
5196 5228  
5197 5229 //收起更多
5198   - toggleContent: function(e) {
  5230 + toggleContent: function (e) {
5199 5231 var that = this,
5200   - index = e.currentTarget.dataset.index;
  5232 + index = e.currentTarget.dataset.index;
5201 5233 for (var i = 0; i < that.data.comments.length; i++) {
5202 5234 if (index == i) {
5203 5235 that.data.comments[index].auto = true;
... ... @@ -5213,394 +5245,385 @@ Page({
5213 5245 getPlusCardType: function (func) {
5214 5246 var storid = os.stoid;
5215 5247 var th = this;
5216   - var user=getApp().globalData.userInfo;
5217   - if(!user) return false;
  5248 + var user = getApp().globalData.userInfo;
  5249 + if (!user) return false;
5218 5250 getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => {
5219 5251 var plusCard = res.data.data;
5220 5252 var arr = [1219, 2089, 3031];
5221 5253 var new_arr = new Array();
5222   - var card_name_map=new Map();
5223   -
5224   - var list=[];
5225   - for (var i = 0; i < plusCard.length; i++) {
5226   - if((!user || user.card_field==null || user.card_field=="") && plusCard[i].IsStopBuy==true) continue;
5227   - var name="card"+plusCard[i].CorrPrice.toLowerCase();
5228   - card_name_map.set(name,plusCard[i].CardName);
5229   - list.push(plusCard[i]);
  5254 + var card_name_map = new Map();
  5255 +
  5256 + var list = [];
  5257 + for (var i = 0; i < plusCard.length; i++) {
  5258 + if ((!user || user.card_field == null || user.card_field == "") && plusCard[i].IsStopBuy == true) continue;
  5259 + var name = "card" + plusCard[i].CorrPrice.toLowerCase();
  5260 + card_name_map.set(name, plusCard[i].CardName);
  5261 + list.push(plusCard[i]);
5230 5262 }
5231   -
5232   - var ob={"card_list":list,"name_map":card_name_map};
  5263 +
  5264 + var ob = { "card_list": list, "name_map": card_name_map };
5233 5265 func(ob);
5234 5266 })
5235 5267 },
5236 5268  
5237   - go_plus:function(){
  5269 + go_plus: function () {
5238 5270 getApp().goto("/pages/user/plus/plus");
5239 5271 },
5240   - go_card_info:function(){
  5272 + go_card_info: function () {
5241 5273 getApp().goto("/pages/user/cardinfo/cardinfo");
5242 5274 },
5243 5275 //-- 根据ID拿出门店 --
5244   - get_pick_from_list(pid){
5245   - var all_pick_list=this.data.all_pick_list;
5246   - for(var i in all_pick_list){
5247   - var item=all_pick_list[i];
5248   - if(item.pickup_id==pid){
  5276 + get_pick_from_list(pid) {
  5277 + var all_pick_list = this.data.all_pick_list;
  5278 + for (var i in all_pick_list) {
  5279 + var item = all_pick_list[i];
  5280 + if (item.pickup_id == pid) {
5249 5281 return item;
5250 5282 }
5251 5283 }
5252 5284 },
5253 5285 //-----显示优惠券的时候情况-----
5254   - show_more_cx:function () {
5255   - if(this.data.is_more_cx){
5256   - this.setData({is_more_cx:0});
5257   - }else{
5258   - this.setData({is_more_cx:1});
  5286 + show_more_cx: function () {
  5287 + if (this.data.is_more_cx) {
  5288 + this.setData({ is_more_cx: 0 });
  5289 + } else {
  5290 + this.setData({ is_more_cx: 1 });
5259 5291 }
5260 5292 },
5261 5293  
5262 5294 //----跳转到搭配购买----
5263   - go_prom_list:function () {
5264   -
5265   - var url= "../../../packageA/pages/prom_list/prom_list?goods_id="+this.data.gid;
5266   - var room_id= getApp().globalData.room_id;
5267   - if(room_id && this.data.gid==getApp().globalData.room_goods_id){
5268   - url+="&room_id="+room_id;
5269   - }
5270   - wx.navigateTo({ url: url,})
  5295 + go_prom_list: function () {
  5296 +
  5297 + var url = "../../../packageA/pages/prom_list/prom_list?goods_id=" + this.data.gid;
  5298 + var room_id = getApp().globalData.room_id;
  5299 + if (room_id && this.data.gid == getApp().globalData.room_goods_id) {
  5300 + url += "&room_id=" + room_id;
  5301 + }
  5302 + wx.navigateTo({ url: url, })
5271 5303 },
5272 5304  
5273 5305 //---检查有没有优惠活动---
5274   - check_is_youhui:function(gid,is_nor){
5275   - var th=this;
5276   - //如果是普通购买的时候,要进行调用
5277   - if(is_nor){
5278   - getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid+"/"+gid, {
5279   - success:function(res){
5280   - if(res.data.code==0){
5281   - var r_data=res.data.data;
5282   - th.setData({
5283   - prom_goods:r_data.promGoodsLists,
5284   - })
5285   - th.is_show_more_buy();
5286   - }
5287   - },
5288   - })
5289   -
5290   - }else{
5291   - //调用接口判断订单优惠,
5292   - getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+gid+"/0", {
5293   - success:function(res){
5294   - if(res.data.code==0){
5295   - var r_data=res.data.data;
5296   - var max=0,min=0;
5297   - if(r_data.collocationList){
5298   - for(var i in r_data.collocationList){
5299   - if(max==0) max=r_data.collocationList[i].price;
5300   - if(min==0) min=r_data.collocationList[i].price;
5301   -
5302   - if(max<parseFloat(r_data.collocationList[i].price)) max=r_data.collocationList[i].price;
5303   - if(min>parseFloat(r_data.collocationList[i].price)) min=r_data.collocationList[i].price;
5304   - }
5305   - r_data.collocationPromList.max=(max+th.data.data.shop_price).toFixed(2);
5306   - r_data.collocationPromList.min=(min+th.data.data.shop_price).toFixed(2);
5307   - }
5308   - th.setData({
5309   - order_prom:r_data.promOrder,
5310   - collocationGoods:r_data.collocationPromList,
5311   - prom_goods:r_data.promGoodsLists,
5312   - })
5313   - th.is_show_more_buy();
5314   - }
5315   - }
5316   -
5317   - })
5318   - }
5319   -
5320   -
5321   - },
5322   -
5323   - closePoster() {
5324   - this.setData({
5325   - showPoster: false,
5326   - });
5327   - },
5328   -
5329   - // 保存图片到手机
5330   - savePic() {
5331   - console.log('保存图片');
5332   - var self = this;
5333   - // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限
5334   - this.getSetting().then((res) => {
5335   - // 判断用户是否授权了保存到相册的权限,如果没有发起授权
5336   - if (!res.authSetting['scope.writePhotosAlbum']) {
5337   - this.authorize().then(() => {
5338   - // 同意授权后保存下载文件
5339   - this.saveImage(self.data.shareImgPath)
5340   - .then(() => {
5341   - self.setData({
5342   - showPoster: false
5343   - });
5344   - });
5345   - })
5346   - } else {
5347   - // 如果已经授权,保存下载文件
5348   - this.saveImage(self.data.shareImgPath)
5349   - .then(() => {
5350   - self.setData({
5351   - showPoster: false
5352   - });
5353   - });
5354   - }
5355   -
5356   - })
5357   - },
5358   -
5359   - // 获取用户已经授予了哪些权限
5360   - getSetting() {
5361   - return new Promise((resolve, reject) => {
5362   - wx.getSetting({
5363   - success: res => {
5364   - resolve(res)
5365   - }
5366   - })
5367   - })
5368   - },
5369   -
5370   - // 发起首次授权请求
5371   - authorize() {
5372   - // isFirst 用来记录是否为首次发起授权,
5373   - // 如果首次授权拒绝后,isFirst赋值为1
5374   - let isFirst = wx.getStorageSync('isFirst') || 0;
5375   - return new Promise((resolve, reject) => {
5376   - wx.authorize({
5377   - scope: 'scope.writePhotosAlbum',
5378   - // 同意授权
5379   - success: () => {
5380   - resolve();
5381   - },
5382   - // 拒绝授权,这里是用户拒绝授权后的回调
5383   - fail: res => {
5384   - if(isFirst === 0) {
5385   - wx.setStorageSync('isFirst', 1);
5386   - wx.showToast({
5387   - title: '保存失败',
5388   - icon: 'none',
5389   - duration: 1000
5390   - })
5391   - } else {
5392   - this.showModal();
5393   - }
5394   - console.log('拒绝授权');
5395   - reject();
5396   - }
5397   - })
5398   - })
5399   - },
5400   -
5401   -
5402   - // 保存图片到系统相册
5403   - saveImage(saveUrl) {
5404   - var self = this;
5405   - return new Promise((resolve, reject) => {
5406   - wx.saveImageToPhotosAlbum({
5407   - filePath: saveUrl,
5408   - success: (res) => {
5409   - wx.showToast({
5410   - title: '保存成功',
5411   - duration: 1000,
5412   - });
5413   - self.setData({
5414   - showPlaybill: 'true'
5415   - });
5416   - resolve();
5417   - },
5418   - fail: () => {
5419   - wx.showToast({
5420   - title: '保存失败',
5421   - duration: 1000,
5422   - });
5423   - }
5424   - })
5425   - })
5426   - },
5427   -
5428   - previewImage() {
5429   - this.data.show_prew_img=1;
5430   - wx.previewImage({
5431   - //将图片预览出来
5432   - urls: [this.data.shareImgPath]
5433   - });
5434   - },
5435   -
5436   - is_show_more_buy:function(){
5437   - var prom_goods=this.data.prom_goods;
5438   - var per_price=this.data.sele_g.shop_price
5439   - if(this.data.card_field && this.data.sele_g[this.data.card_field]>0){
5440   - per_price=this.data.sele_g[this.data.card_field];
5441   - }
5442   - var all_price=per_price*this.data.goodsInputNum;
5443   - var con=null;
5444   - for(var i in prom_goods){
5445   - var item=prom_goods[i];
5446   - if(item.prom_type==1){
5447   - if(item.condition>this.data.goodsInputNum) {
5448   - con=item;
5449   - con.need=(item.condition-this.data.goodsInputNum).toFixed(2)+"件";
5450   - break;
5451   - }
5452   - }else{
5453   - if(item.condition>all_price){
5454   - con=item;
5455   - con.need=(item.condition-all_price).toFixed(2)+"元";
5456   - break;
5457   - }
5458   - }
5459   - }
5460   -
5461   - this.setData({hui_condition:con});
5462   -
5463   - },
5464   -
5465   - //-- 积分购 --
5466   - go_pay_integral:function(){
5467   - this.get_sto(0)
5468   - this.setData({openSpecModal_inte:1,goodsInputNum:1});
5469   - },
5470   - //-- 积分购普通购买 --
5471   - go_pay_integral_normal:function(){
5472   - var th=this;
5473   - if (th.data.sku_g_pt) {
5474   - this.get_sto(1)
5475   - this.setData({openSpecModal_inte_normal:1});
5476   - }else{
5477   - th.get_sto(1);
5478   - th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function() {
5479   - th.setData({
5480   - is_normal: 1,
5481   - openSpecModal_inte_normal:1
5482   - });
5483   - });
5484   - }
5485   - this.check_is_youhui(th.data.gid,1);
5486   - },
5487   -
5488   - closeSpecModal_inte:function(){
5489   - this.setData({openSpecModal_inte:0});
5490   - } ,
5491   - closeSpecModal_inte_normal:function(){
5492   - this.setData({openSpecModal_inte_normal:0});
5493   - //要进行还原
5494   - this.get_sto();
5495   - this.setData({
5496   - sele_g:this.data.data,
5497   - gid:this.data.data.goods_id
5498   - })
5499   -
5500   - this.sele_spec_chech_activity();
5501   - },
5502   -
5503   - addCart_inte:function(t){
5504   - this.add_cart_func_inte(t);
5505   - },
5506   -
5507   -
5508   -
5509   -
5510   - onShareTimeline() {
5511   - var store_name=getApp().globalData.config?getApp().globalData.config.store_name:'';
5512   - if(!store_name)
5513   - store_name=getApp().globalData.setting.appName;
5514   - return {
5515   - title:this.data.data.goods_name + '-' + store_name,
5516   - imageUrl:this.data.gallery[0].image_url,
5517   - }
5518   - },
5519   -
5520   -
5521   - clickCollapse() {
5522   - this.setData({
5523   - flag: !this.data.flag,
5524   - })
5525   - },
5526   -
5527   - clickShare() {
5528   - this.setData({
5529   - share_hidden: true,
5530   - });
5531   - },
5532   -
5533   - send() {
5534   - this.setData({
5535   - share_hidden:false,
5536   - });
5537   - },
5538   -
5539   - cancel() {
5540   - this.setData({
5541   - share_hidden:false,
5542   - });
5543   - },
5544   -
5545   - //积分购和拼团的普通购买的的时候,要判断有没有全场优惠活动
5546   - check_nor_promgood(goods_id,back){
5547   - getApp().request.get("/api/weshop/goods/getGoodsPromNormal/"+os.stoid+"/"+goods_id,{
5548   - success:function(res){
5549   - if(res.data.code==0 && res.data.data && res.data.data.promGoodsLists && res.data.data.promGoodsLists.length>0){
5550   - var obj={
5551   - act_id:res.data.data.promGoodsLists[0].prom_id,
5552   - }
5553   - back(obj);
5554   - }else{
5555   - back(0)
5556   - }
5557   - }
5558   - })
5559   - },
5560   -
5561   - go_zh:function (e) {
5562   - var id=e.currentTarget.dataset.id;
5563   - getApp().goto("/packageB/pages/zuhegou/index/index?id="+id);
5564   - },
5565   -
5566   - check_zh_acting:function (func) {
5567   - var isok = 1,item=this.data.sele_g;
5568   - //如果有组合购
5569   - var url="/api/weshop/prom/zhbuy/get/"+os.stoid+"/"+item.prom_id+"/"+getApp().globalData.userInfo.user_id;
5570   - getApp().request.promiseGet(url, {}).then(res => {
5571   - if(res.data.code==0 && res.data.data){
5572   - if(res.data.data.is_show!=1){
5573   - isok=0;
5574   - }
5575   - //如果活动已经结束
5576   - if(res.data.data.is_end==1){
5577   - isok=0;
5578   - }
5579   - //已经结束
5580   - if(ut.gettimestamp()>res.data.data.end_time){
5581   - isok=0;
5582   - }
5583   - //还未开始
5584   - if(ut.gettimestamp()<res.data.data.start_time){
5585   - isok=0;
5586   - }
5587   -
5588   - }else{
5589   - //未找到商品的活动
5590   - isok = 0;
5591   - }
5592   - item.act=res.data.data;
5593   - func(isok);
5594   - })
5595   - }
5596   -
5597   -
5598   -
5599   -
5600   -
5601   -
5602   -
5603   -
5604   -
5605   -
  5306 + check_is_youhui: function (gid, is_nor) {
  5307 + var th = this;
  5308 + //如果是普通购买的时候,要进行调用
  5309 + if (is_nor) {
  5310 + getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + gid, {
  5311 + success: function (res) {
  5312 + if (res.data.code == 0) {
  5313 + var r_data = res.data.data;
  5314 + th.setData({
  5315 + prom_goods: r_data.promGoodsLists,
  5316 + })
  5317 + th.is_show_more_buy();
  5318 + }
  5319 + },
  5320 + })
  5321 +
  5322 + } else {
  5323 + //调用接口判断订单优惠,
  5324 + getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0", {
  5325 + success: function (res) {
  5326 + console.log(res);
  5327 + if (res.data.code == 0) {
  5328 + var r_data = res.data.data;
  5329 + var max = 0, min = 0;
  5330 + if (r_data.collocationList) {
  5331 + for (var i in r_data.collocationList) {
  5332 + if (max == 0) max = r_data.collocationList[i].price;
  5333 + if (min == 0) min = r_data.collocationList[i].price;
  5334 +
  5335 + if (max < parseFloat(r_data.collocationList[i].price)) max = r_data.collocationList[i].price;
  5336 + if (min > parseFloat(r_data.collocationList[i].price)) min = r_data.collocationList[i].price;
  5337 + }
  5338 + r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2);
  5339 + r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2);
  5340 + }
  5341 + th.setData({
  5342 + order_prom: r_data.promOrder,
  5343 + collocationGoods: r_data.collocationPromList,
  5344 + prom_goods: r_data.promGoodsLists,
  5345 + })
  5346 + th.is_show_more_buy();
  5347 + }
  5348 + }
  5349 +
  5350 + })
  5351 + }
  5352 +
  5353 +
  5354 + },
  5355 +
  5356 + closePoster() {
  5357 + this.setData({
  5358 + showPoster: false,
  5359 + });
  5360 + },
  5361 +
  5362 + // 保存图片到手机
  5363 + savePic() {
  5364 + console.log('保存图片');
  5365 + var self = this;
  5366 + // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限
  5367 + this.getSetting().then((res) => {
  5368 + // 判断用户是否授权了保存到相册的权限,如果没有发起授权
  5369 + if (!res.authSetting['scope.writePhotosAlbum']) {
  5370 + this.authorize().then(() => {
  5371 + // 同意授权后保存下载文件
  5372 + this.saveImage(self.data.shareImgPath)
  5373 + .then(() => {
  5374 + self.setData({
  5375 + showPoster: false
  5376 + });
  5377 + });
  5378 + })
  5379 + } else {
  5380 + // 如果已经授权,保存下载文件
  5381 + this.saveImage(self.data.shareImgPath)
  5382 + .then(() => {
  5383 + self.setData({
  5384 + showPoster: false
  5385 + });
  5386 + });
  5387 + }
  5388 +
  5389 + })
  5390 + },
  5391 +
  5392 + // 获取用户已经授予了哪些权限
  5393 + getSetting() {
  5394 + return new Promise((resolve, reject) => {
  5395 + wx.getSetting({
  5396 + success: res => {
  5397 + resolve(res)
  5398 + }
  5399 + })
  5400 + })
  5401 + },
  5402 +
  5403 + // 发起首次授权请求
  5404 + authorize() {
  5405 + // isFirst 用来记录是否为首次发起授权,
  5406 + // 如果首次授权拒绝后,isFirst赋值为1
  5407 + let isFirst = wx.getStorageSync('isFirst') || 0;
  5408 + return new Promise((resolve, reject) => {
  5409 + wx.authorize({
  5410 + scope: 'scope.writePhotosAlbum',
  5411 + // 同意授权
  5412 + success: () => {
  5413 + resolve();
  5414 + },
  5415 + // 拒绝授权,这里是用户拒绝授权后的回调
  5416 + fail: res => {
  5417 + if (isFirst === 0) {
  5418 + wx.setStorageSync('isFirst', 1);
  5419 + wx.showToast({
  5420 + title: '保存失败',
  5421 + icon: 'none',
  5422 + duration: 1000
  5423 + })
  5424 + } else {
  5425 + this.showModal();
  5426 + }
  5427 + console.log('拒绝授权');
  5428 + reject();
  5429 + }
  5430 + })
  5431 + })
  5432 + },
  5433 +
  5434 +
  5435 + // 保存图片到系统相册
  5436 + saveImage(saveUrl) {
  5437 + var self = this;
  5438 + return new Promise((resolve, reject) => {
  5439 + wx.saveImageToPhotosAlbum({
  5440 + filePath: saveUrl,
  5441 + success: (res) => {
  5442 + wx.showToast({
  5443 + title: '保存成功',
  5444 + duration: 1000,
  5445 + });
  5446 + self.setData({
  5447 + showPlaybill: 'true'
  5448 + });
  5449 + resolve();
  5450 + },
  5451 + fail: () => {
  5452 + wx.showToast({
  5453 + title: '保存失败',
  5454 + duration: 1000,
  5455 + });
  5456 + }
  5457 + })
  5458 + })
  5459 + },
  5460 +
  5461 + previewImage() {
  5462 + this.data.show_prew_img = 1;
  5463 + wx.previewImage({
  5464 + //将图片预览出来
  5465 + urls: [this.data.shareImgPath]
  5466 + });
  5467 + },
  5468 +
  5469 + is_show_more_buy: function () {
  5470 + var prom_goods = this.data.prom_goods;
  5471 + var per_price = this.data.sele_g.shop_price
  5472 + if (this.data.card_field && this.data.sele_g[this.data.card_field] > 0) {
  5473 + per_price = this.data.sele_g[this.data.card_field];
  5474 + }
  5475 + var all_price = per_price * this.data.goodsInputNum;
  5476 + var con = null;
  5477 + for (var i in prom_goods) {
  5478 + var item = prom_goods[i];
  5479 + if (item.prom_type == 1) {
  5480 + if (item.condition > this.data.goodsInputNum) {
  5481 + con = item;
  5482 + con.need = (item.condition - this.data.goodsInputNum).toFixed(2) + "件";
  5483 + break;
  5484 + }
  5485 + } else {
  5486 + if (item.condition > all_price) {
  5487 + con = item;
  5488 + con.need = (item.condition - all_price).toFixed(2) + "元";
  5489 + break;
  5490 + }
  5491 + }
  5492 + }
  5493 +
  5494 + this.setData({ hui_condition: con });
  5495 +
  5496 + },
  5497 +
  5498 + //-- 积分购 --
  5499 + go_pay_integral: function () {
  5500 + this.get_sto(0)
  5501 + this.setData({ openSpecModal_inte: 1, goodsInputNum: 1 });
  5502 + },
  5503 + //-- 积分购普通购买 --
  5504 + go_pay_integral_normal: function () {
  5505 + var th = this;
  5506 + if (th.data.sku_g_pt) {
  5507 + this.get_sto(1)
  5508 + this.setData({ openSpecModal_inte_normal: 1 });
  5509 + } else {
  5510 + th.get_sto(1);
  5511 + th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () {
  5512 + th.setData({
  5513 + is_normal: 1,
  5514 + openSpecModal_inte_normal: 1
  5515 + });
  5516 + });
  5517 + }
  5518 + this.check_is_youhui(th.data.gid, 1);
  5519 + },
  5520 +
  5521 + closeSpecModal_inte: function () {
  5522 + this.setData({ openSpecModal_inte: 0 });
  5523 + },
  5524 + closeSpecModal_inte_normal: function () {
  5525 + this.setData({ openSpecModal_inte_normal: 0 });
  5526 + //要进行还原
  5527 + this.get_sto();
  5528 + this.setData({
  5529 + sele_g: this.data.data,
  5530 + gid: this.data.data.goods_id
  5531 + })
  5532 +
  5533 + this.sele_spec_chech_activity();
  5534 + },
  5535 +
  5536 + addCart_inte: function (t) {
  5537 + this.add_cart_func_inte(t);
  5538 + },
  5539 +
  5540 +
  5541 +
  5542 +
  5543 + onShareTimeline() {
  5544 + var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : '';
  5545 + if (!store_name)
  5546 + store_name = getApp().globalData.setting.appName;
  5547 + return {
  5548 + title: this.data.data.goods_name + '-' + store_name,
  5549 + imageUrl: this.data.gallery[0].image_url,
  5550 + }
  5551 + },
  5552 +
  5553 +
  5554 + clickCollapse() {
  5555 + this.setData({
  5556 + flag: !this.data.flag,
  5557 + })
  5558 + },
  5559 +
  5560 + clickShare() {
  5561 + this.setData({
  5562 + share_hidden: true,
  5563 + });
  5564 + },
  5565 +
  5566 + send() {
  5567 + this.setData({
  5568 + share_hidden: false,
  5569 + });
  5570 + },
  5571 +
  5572 + cancel() {
  5573 + this.setData({
  5574 + share_hidden: false,
  5575 + });
  5576 + },
  5577 +
  5578 + //积分购和拼团的普通购买的的时候,要判断有没有全场优惠活动
  5579 + check_nor_promgood(goods_id, back) {
  5580 + getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + goods_id, {
  5581 + success: function (res) {
  5582 + if (res.data.code == 0 && res.data.data && res.data.data.promGoodsLists && res.data.data.promGoodsLists.length > 0) {
  5583 + var obj = {
  5584 + act_id: res.data.data.promGoodsLists[0].prom_id,
  5585 + }
  5586 + back(obj);
  5587 + } else {
  5588 + back(0)
  5589 + }
  5590 + }
  5591 + })
  5592 + },
  5593 +
  5594 + go_zh: function (e) {
  5595 + var id = e.currentTarget.dataset.id;
  5596 + getApp().goto("/packageB/pages/zuhegou/index/index?id=" + id);
  5597 + },
  5598 +
  5599 + check_zh_acting: function (func) {
  5600 + var isok = 1, item = this.data.sele_g;
  5601 + //如果有组合购
  5602 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item.prom_id + "/" + getApp().globalData.userInfo.user_id;
  5603 + getApp().request.promiseGet(url, {}).then(res => {
  5604 + if (res.data.code == 0 && res.data.data) {
  5605 + if (res.data.data.is_show != 1) {
  5606 + isok = 0;
  5607 + }
  5608 + //如果活动已经结束
  5609 + if (res.data.data.is_end == 1) {
  5610 + isok = 0;
  5611 + }
  5612 + //已经结束
  5613 + if (ut.gettimestamp() > res.data.data.end_time) {
  5614 + isok = 0;
  5615 + }
  5616 + //还未开始
  5617 + if (ut.gettimestamp() < res.data.data.start_time) {
  5618 + isok = 0;
  5619 + }
  5620 +
  5621 + } else {
  5622 + //未找到商品的活动
  5623 + isok = 0;
  5624 + }
  5625 + item.act = res.data.data;
  5626 + func(isok);
  5627 + })
  5628 + }
5606 5629 });
... ...
pages/goods/goodsInfo/goodsInfo.wxml
... ... @@ -900,6 +900,7 @@
900 900 <image class="cs-img" src="{{iurl}}/miniapp/images/custom-service.png"></image>
901 901 <view>客服</view>
902 902 </view>
  903 +
903 904 <view bindtap="collectGoods" class="custom-service cart-ico new_split">
904 905 <image hidden="{{is_collect}}" class="cs-img" src="{{iurl}}/miniapp/images/heart.png"></image>
905 906 <image hidden="{{!is_collect}}" class="cs-img" src="{{iurl}}/miniapp/images/heart-h.png"></image>
... ...
pages/goods/goodsList/g_filter.wxs
... ... @@ -79,8 +79,20 @@ var g_filters = {
79 79 if(min_name.length>4) min_name=min_name.substring(0, 8);
80 80 return min_name;
81 81 },
  82 + //跳转的接口
  83 + get_goods_url:function(item){
  84 +
  85 + console.log(item,111)
  86 + var url1="/pages/goods/goodsInfo/goodsInfo?goods_id="+item.goods_id
  87 + if(item.prom_type==8){
  88 + url1="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&prom_id="+item.prom_id
  89 + }
  90 + return url1;
  91 + }
82 92 }
  93 +
83 94 module.exports = {
84 95 is_has_rank:g_filters.is_has_rank,
85 96 get_card_price:g_filters.get_card_price,
  97 + get_goods_url:g_filters.get_goods_url,
86 98 }
87 99 \ No newline at end of file
... ...
pages/goods/search/g_filter.wxs
... ... @@ -80,8 +80,20 @@ var g_filters = {
80 80 if(min_name.length>7 ) min_name=min_name.substring(0, 8);
81 81 return min_name;
82 82 },
  83 +
  84 +
  85 + get_goods_url:function(item){
  86 + console.log(item,111)
  87 + var url1="/pages/goods/goodsInfo/goodsInfo?goods_id="+item.goods_id
  88 + if(item.prom_type==8){
  89 + url1="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&prom_id="+item.prom_id
  90 + }
  91 + return url1;
  92 + }
83 93 }
  94 +
84 95 module.exports = {
85 96 is_has_rank:g_filters.is_has_rank,
86   - get_card_price:g_filters.get_card_price,
  97 + get_card_price:g_filters.get_card_price,
  98 + get_goods_url:g_filters.get_goods_url
87 99 }
88 100 \ No newline at end of file
... ...
pages/goods/search/search.wxml
... ... @@ -28,7 +28,7 @@
28 28 </navigator>
29 29 </view>
30 30 <view class="choice_list">
31   - <navigator class="choice_item flex ai-center" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}" wx:for="{{requestData}}" wx:key="{{index}}">
  31 + <navigator class="choice_item flex ai-center" url="{{g_filter.get_goods_url(item)}}" wx:for="{{requestData}}" wx:key="{{index}}">
32 32 <view class="img-wrap">
33 33 <image src="{{item.original_img}}" lazy-load="true" binderror="bind_bnerr" data-errorimg="requestData[{{index}}].original_img"></image>
34 34 </view>
... ...
pages/index/index/index.js
... ... @@ -48,6 +48,7 @@ Page({
48 48 pindGoods: null, //拼单数据
49 49 newGoods: null, //新商品
50 50 hotGoods: null, //hot商品
  51 + preGoods:null, //预售商品
51 52 //----控制是是否显示计时器---
52 53 is_timer: 1,
53 54 ishow: 0,
... ... @@ -291,18 +292,48 @@ Page({
291 292 },
292 293  
293 294 async onShow() {
294   - var th = this;
295   - //-- 登录回来判断弹框 --
296   - var userInfo = getApp().globalData.userInfo;
297   - if (userInfo) {
298   - th.is_festival();
299   - var new_nav = th.data.new_nav;
300   - if (new_nav == "") {
301   - th.is_new();
302   - }
303   - }
  295 + var th = this;
  296 + //-- 登录回来判断弹框 --
  297 + var user_id=getApp().globalData.user_id;
  298 +
  299 + if(!user_id){
  300 + var userinfo=wx.getStorageSync('userinfo');
  301 + if(userinfo) user_id=userinfo.user_id
  302 + }
  303 +
  304 + if (user_id) {
  305 + th.is_festival();
  306 + var new_nav = th.data.new_nav;
  307 + if (new_nav == "") {
  308 + th.is_new();
  309 + }
  310 + }
  311 +
  312 + var pre_data={store_id:os.stoid,is_end:0,timetype:1,isuse:1};
  313 + if(user_id){
  314 + pre_data.user_id= user_id;
  315 + }
  316 +
  317 + getApp().request.get("/api/weshop/marketing/marketingPresellList/page",{
  318 + data:pre_data,
  319 + success:function (e) {
  320 + if(e.data.code==0 && e.data.data.pageData && e.data.data.pageData.length>0 ){
  321 + var pre_data=e.data.data.pageData;
  322 + var arr = new Array();
  323 + //--三个三个一组---
  324 + for (var i = 0; i < pre_data.length; i += 3) {
  325 + arr.push(pre_data.slice(i, i + 3));
  326 + }
  327 + th.setData({
  328 + preGoods: arr
  329 + });
  330 + }
  331 + }
  332 + })
  333 +
304 334  
305   - //优惠券要实时更新
  335 +
  336 + //优惠券要实时更新
306 337 getApp().getConfig2(function (e) {
307 338 var json_d = JSON.parse(e.switch_list);
308 339 th.setData({ is_closecoupon: json_d.is_closecoupon })
... ... @@ -343,7 +374,7 @@ Page({
343 374 } else {
344 375 getApp().globalData.isLoad_ad = 1;
345 376 }
346   - }, 500)
  377 + }, 1500)
347 378  
348 379  
349 380  
... ... @@ -461,34 +492,7 @@ Page({
461 492 //th.countDown();
462 493 }
463 494 });
464   - //-----预售----
465   - //调用接口获取数据
466   - await getApp().request.get("/api/weshop/marketing/marketingPresellList/page", {
467   - data: {
468   - is_end: 0,
469   - store_id: os.stoid,
470   - pageSize: 10,
471   - timetype: 1
472   - },
473   - success: function (res) {
474   - if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) {
475   - var list = th.data.goodlist ? th.data.goodlist : [];
476   - var arr = res.data.data.pageData;
477   - //数组合起来
478   - for (var i in arr) {
479   - list.push(arr[i]);
480   - }
481   - th.setData({ goodlist: list });
482   - if (arr.length < 10) {
483   - th.setData({ no_more: 1 })
484   - }
485   - } else {
486   - th.setData({ no_more: 1 })
487   - }
488   - th.setData({ is_get: 1 })
489 495  
490   - }
491   - });
492 496  
493 497 //----拼单-----
494 498 await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", {
... ... @@ -1121,4 +1125,14 @@ Page({
1121 1125 this.close_full_screen();
1122 1126 },
1123 1127  
  1128 + go_pre:function (e) {
  1129 + var userInfo=getApp().globalData.userInfo;
  1130 + if(!userInfo){
  1131 + getApp().goto("/pages/togoin/togoin");
  1132 + return false;
  1133 + }
  1134 + var url=e.currentTarget.dataset.url;
  1135 + getApp().goto(url);
  1136 + }
  1137 +
1124 1138 });
1125 1139 \ No newline at end of file
... ...
pages/index/index/index.wxml
... ... @@ -153,8 +153,8 @@
153 153 </view>
154 154 </navigator>
155 155 <view class="seckill-list">
156   - <swiper class="s_prom" indicator-dots="{{false}}" bindchange="flashSwiperChange" next-margin="25rpx">
157   - <swiper-item wx:for="{{saleGoods}}" wx:key="{{index}}" class="p_swiper" wx:key="saleGoods">
  156 + <swiper class="s_prom" indicator-dots="{{false}}" bindchange="flashSwiperChange" next-margin="105rpx">
  157 + <swiper-item wx:for="{{saleGoods}}" wx:key="{{index}}" class="p_swiper" wx:key="saleGoods" style="750rpx !important;">
158 158 <navigator class="nav" hover-class="none" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{aitem.goods_id}}&title={{aitem.goods_name}}" wx:for="{{item}}" wx:key="item" wx:for-item="aitem" wx:for-index="aind">
159 159 <view class="imgview ">
160 160 <image src="{{url+aitem.original_img}}" mode="aspectFill" lazy-load="true" data-errorimg="saleGoods[{{index}}][{{aind}}].original_img" binderror="bind_bnerr3" data-img="{{aitem.original_img}}"></image>
... ... @@ -181,9 +181,8 @@
181 181  
182 182  
183 183 <!--预售-->
184   - <!--
185 184 <view class="seckill" wx:if="{{preGoods!=null && preGoods.length!=0 }}">
186   - <navigator url="/packageC/pages/presell/list/list" hover-class="none">
  185 + <navigator bindtap="go_pre" data-url="/packageC/pages/presell/list/list" hover-class="none">
187 186 <view class="seckill-time">
188 187 <view class="classname flex ai_c">
189 188 <i class="iconfont icon-presell"></i>
... ... @@ -198,11 +197,13 @@
198 197 <view class="seckill-list">
199 198 <swiper class="s_prom" indicator-dots="{{false}}" bindchange="flashSwiperChange" next-margin="25rpx">
200 199 <swiper-item wx:for="{{preGoods}}" wx:key="*this" class="p_swiper" >
201   - <navigator class="nav" hover-class="none" url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{aitem.goods_id}}&title={{aitem.goods_name}}" wx:for="{{item}}" wx:key="item" wx:for-item="aitem" wx:for-index="aind">
  200 + <navigator bindtap="go_pre" class="nav" hover-class="none"
  201 + data-url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id={{aitem.goods_id}}&pre_id={{aitem.id}}"
  202 + wx:for="{{item}}" wx:key="item" wx:for-item="aitem" wx:for-index="aind">
202 203 <view class="imgview presell">
203 204 <image src="{{url+aitem.original_img}}" mode="aspectFill" lazy-load="true" data-errorimg="preGoods[{{index}}][{{aind}}].original_img" binderror="bind_bnerr3" data-img="{{aitem.original_img}}"></image>
204 205 </view>
205   - <view class="ellipsis-2 mar-top10" style="height: 70rpx;">{{aitem.goods_name}}</view>
  206 + <view class="ellipsis-2 mar-top10" style="height: 75rpx; width: 200rpx">{{aitem.goods_name}}</view>
206 207 <view class="co-red mar-top10 flex jc_sb ali-c">
207 208 <view>
208 209 <text><text class="fs20">¥</text>{{aitem.presell_price}}</text>
... ... @@ -215,7 +216,7 @@
215 216 </swiper>
216 217 </view>
217 218 </view>
218   - - -->
  219 +
219 220  
220 221  
221 222 <!----拼单---->
... ...
pages/index/index/index.wxss
... ... @@ -433,7 +433,7 @@
433 433 .p_swiper {
434 434 display: flex;
435 435 padding: 0 10rpx;
436   - box-sizing: border-box;
  436 + box-sizing: content-box;
437 437 }
438 438  
439 439 .nav {
... ...
pages/user/order_list/order_list.js
... ... @@ -135,150 +135,171 @@ Page({
135 135 },
136 136  
137 137  
138   - /*---------获取订单列表--------*/
139   - requestOrderList: function (t) {
140   - var rd = Math.random() * 100;
141   - var e = this, th = e, r = e.data.url + "/api/weshop/order/page?rd=" + rd, a = "";
142   - switch (t) {
143   - case "1":
144   - r += "&wait_status=0"; break;
145   - case "2":
146   - r += "&wait_status=1"; break;
147   - case "3":
148   - r += "&wait_status=2"; break;
149   - case "4":
150   - r += "&order_status=2"; break;
151   - }
152   - r+="&isdel=0";
153   - if(this.data.searchContent) {
154   - r+="&keyWord=" + this.data.searchContent;
155   - }
156   - this.setData({ activeCategoryId: t }); r = r + "&page=" + e.data.currentPage;
157   - s.request(r, function (t) {
158   -
159   - th.setData({ is_get: 1 });
160   - var data = e.data.orderList;
161   - data.forEach(async function (item, ind) {
162   - var tt = null;
163   - await getApp().request.promiseGet('/api/weshop/ordergoods/list', {
164   - data: { order_id: item.order_id, store_id: os.stoid, pageSize: 600 },
165   - }).then(res => {
166   - tt = res;
167   - })
168   -
169   - var glist = tt.data.data.pageData;
170   - for(var i in glist){
171   - if(glist[i].is_gift){
172   - data[ind].is_prom=1;
173   - }
  138 + /*---------获取订单列表--------*/
  139 + requestOrderList: function (t) {
  140 + var rd = Math.random() * 100;
  141 + var e = this, th = e, r = e.data.url + "/api/weshop/order/page?rd=" + rd, a = "";
  142 + switch (t) {
  143 + case "1":
  144 + r += "&wait_status=0";
  145 + break;
  146 + case "2":
  147 + r += "&wait_status=1";
  148 + break;
  149 + case "3":
  150 + r += "&wait_status=2";
  151 + break;
  152 + case "4":
  153 + r += "&order_status=2";
  154 + break;
174 155 }
175   -
176   -
177   - //------------对比一下有没有退款记录------------
178   - await getApp().request.promiseGet("/api/weshop/order/returngoods/page", {
179   - data: {
180   - order_id: item.order_id, store_id: os.stoid,
181   - user_id: oo.user_id, pageSize: 20
182   - }
183   - }).then(rs => {
184   - var ttd = rs;
185   - //--看一下订单的总数量--
186   - var gtype_num = tt.data.data.total;
187   - if (ttd.data.data.pageData == undefined) return false;
188   - var goodslist = tt.data.data.pageData;
189   -
190   - //----没有相关的退款记录----
191   - if (ttd.data.data.total == 0) {
192   - data[ind]['is_all_return'] = 0;
193   - goodslist.forEach(function (ee, ii) {
194   - if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1 && gtype_num > 1) {
195   - item.goodslist = goodslist;
196   - if (th.check_for_return_btn(item)) {
197   - goodslist[ii]['return_btn'] = 1;
  156 + r += "&isdel=0";
  157 + if (this.data.searchContent) {
  158 + r += "&keyWord=" + this.data.searchContent;
  159 + }
  160 + this.setData({activeCategoryId: t});
  161 + r = r + "&page=" + e.data.currentPage;
  162 + s.request(r, function (t) {
  163 +
  164 + th.setData({is_get: 1});
  165 + var data = e.data.orderList;
  166 + data.forEach(async function (item, ind) {
  167 + var tt = null;
  168 + await getApp().request.promiseGet('/api/weshop/ordergoods/list', {
  169 + data: {order_id: item.order_id, store_id: os.stoid, pageSize: 600},
  170 + }).then(res => {
  171 + tt = res;
  172 + })
  173 + var glist = tt.data.data.pageData;
  174 + for (var i in glist) {
  175 + if (glist[i].is_gift) {
  176 + data[ind].is_prom = 1;
  177 + }
198 178 }
199   - }
200 179  
201   - });
202   - } else {
203   - //--------整单退--------
204   - if (ttd.data.data.pageData[0]['goods_id_list'] != null
205   - && ttd.data.data.pageData[0]['goods_id_list'] != '') {
206   - var eea = ttd.data.data.pageData[0];
207   - //1.退款正在进行中,
208   - //2.退款被拒绝就要显示可以退款
209   - //3.退款已经完成
210   - data[ind]['is_all_return'] = 1;
211   - data[ind]['is_all_return_status'] = ttd.data.data.pageData[0].status;
212   -
213   - if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1) {
214   - switch (eea.status) {
215   - case 0:
216   - case 1:
217   - data[ind]['return_btn'] = 2; break;
218   - case 2:
219   - data[ind]['return_btn'] = 4; break;
220   - case 3:
221   - data[ind]['return_btn'] = 3; break;
222   - default:
223   - data[ind]['return_btn'] = 0;
  180 + data[ind]['ord_url']='/pages/user/order_detail/order_detail';
  181 + //-- 如果是优惠活动 --
  182 + if(glist[0].prom_type==8){
  183 + await getApp().request.promiseGet('/api/weshop/order/orderPresell/get/'+os.stoid+'/'+item.order_id, {
  184 + }).then(res => {
  185 + if(res.data.code==0){
  186 + data[ind]['presell'] = res.data.data;
  187 + data[ind]['ord_url']='/packageC/pages/presell/cart/cart';
  188 + }
  189 + })
224 190 }
225   - }
226   - } else {
227   - //1.退款正在进行中,
228   - //2.退款被拒绝就要显示可以退款
229   - //3.退款已经完成
230   - data[ind]['is_all_return'] = 0;
231   - var rt_ok_num = 0;
232   - //if(data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1) {
233   - goodslist.forEach(function (eeb, iii) {
234   - if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1)
235   - goodslist[iii]['return_btn'] = 1; //申请退款
236   - ttd.data.data.pageData.forEach(function (eea, ii) {
237   - var st = eea.status;
238   - if (eea.goods_id == eeb.goods_id) {
239   - switch (eea.status) {
240   - case 0:
241   - case 1://退款处理中
242   - data[ind]['has_rt'] = 1; //有部分退
243   - goodslist[iii]['return_btn'] = 2; break;
244   - case 2://退款完成
245   - data[ind]['has_rt'] = 1; //有部分退
246   - goodslist[iii]['return_btn'] = 4; rt_ok_num++; break;
247   - case 3://已拒绝,重新退款
248   - goodslist[iii]['return_btn'] = 3; break;
249   - default:
250   - if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1)
251   - goodslist[iii]['return_btn'] = 1; //申请退款
  191 + //------------对比一下有没有退款记录------------
  192 + await getApp().request.promiseGet("/api/weshop/order/returngoods/page", {
  193 + data: {
  194 + order_id: item.order_id, store_id: os.stoid,
  195 + user_id: oo.user_id, pageSize: 20
  196 + }
  197 + }).then(rs => {
  198 + var ttd = rs;
  199 + //--看一下订单的总数量--
  200 + var gtype_num = tt.data.data.total;
  201 + if (ttd.data.data.pageData == undefined) return false;
  202 + var goodslist = tt.data.data.pageData;
  203 +
  204 + //----没有相关的退款记录----
  205 + if (ttd.data.data.total == 0) {
  206 + data[ind]['is_all_return'] = 0;
  207 + goodslist.forEach(function (ee, ii) {
  208 + if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1 && gtype_num > 1) {
  209 + item.goodslist = goodslist;
  210 + if (th.check_for_return_btn(item)) {
  211 + goodslist[ii]['return_btn'] = 1;
  212 + }
  213 + }
  214 +
  215 + });
  216 + } else {
  217 + //--------整单退--------
  218 + if (ttd.data.data.pageData[0]['goods_id_list'] != null
  219 + && ttd.data.data.pageData[0]['goods_id_list'] != '') {
  220 + var eea = ttd.data.data.pageData[0];
  221 + //1.退款正在进行中,
  222 + //2.退款被拒绝就要显示可以退款
  223 + //3.退款已经完成
  224 + data[ind]['is_all_return'] = 1;
  225 + data[ind]['is_all_return_status'] = ttd.data.data.pageData[0].status;
  226 +
  227 + if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1) {
  228 + switch (eea.status) {
  229 + case 0:
  230 + case 1:
  231 + data[ind]['return_btn'] = 2;
  232 + break;
  233 + case 2:
  234 + data[ind]['return_btn'] = 4;
  235 + break;
  236 + case 3:
  237 + data[ind]['return_btn'] = 3;
  238 + break;
  239 + default:
  240 + data[ind]['return_btn'] = 0;
  241 + }
  242 + }
  243 + } else {
  244 + //1.退款正在进行中,
  245 + //2.退款被拒绝就要显示可以退款
  246 + //3.退款已经完成
  247 + data[ind]['is_all_return'] = 0;
  248 + var rt_ok_num = 0;
  249 + //if(data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1) {
  250 + goodslist.forEach(function (eeb, iii) {
  251 + if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1)
  252 + goodslist[iii]['return_btn'] = 1; //申请退款
  253 + ttd.data.data.pageData.forEach(function (eea, ii) {
  254 + var st = eea.status;
  255 + if (eea.goods_id == eeb.goods_id) {
  256 + switch (eea.status) {
  257 + case 0:
  258 + case 1://退款处理中
  259 + data[ind]['has_rt'] = 1; //有部分退
  260 + goodslist[iii]['return_btn'] = 2;
  261 + break;
  262 + case 2://退款完成
  263 + data[ind]['has_rt'] = 1; //有部分退
  264 + goodslist[iii]['return_btn'] = 4;
  265 + rt_ok_num++;
  266 + break;
  267 + case 3://已拒绝,重新退款
  268 + goodslist[iii]['return_btn'] = 3;
  269 + break;
  270 + default:
  271 + if (data[ind]['order_status'] == 1 && data[ind]['pay_status'] == 1)
  272 + goodslist[iii]['return_btn'] = 1; //申请退款
  273 + }
  274 + return;
  275 + }
  276 + });
  277 + });
  278 + //}
  279 + }
252 280 }
253   - return;
254   - }
255   - });
256   - });
257   - //}
258   - }
259   - }
260 281  
261   - //--如果是全部退款,也就可以删除--
262   - if (rt_ok_num == goodslist.length) {
263   - data[ind]['is_all_return_status'] = 2;
264   - }
  282 + //--如果是全部退款,也就可以删除--
  283 + if (rt_ok_num == goodslist.length) {
  284 + data[ind]['is_all_return_status'] = 2;
  285 + }
265 286  
266 287  
267   - data[ind]['order_goods'] = goodslist;
268   - var g_num = 0;
269   - goodslist.forEach(function (ee, ii) {
270   - if (ee.return_btn != 4)
271   - g_num += ee.goods_num;
272   - });
273   - data[ind]['g_num'] = g_num;
274   - })
275   - th.setData({ orderList: data, });
  288 + data[ind]['order_goods'] = goodslist;
  289 + var g_num = 0;
  290 + goodslist.forEach(function (ee, ii) {
  291 + if (ee.return_btn != 4)
  292 + g_num += ee.goods_num;
  293 + });
  294 + data[ind]['g_num'] = g_num;
  295 + })
  296 + th.setData({orderList: data,});
276 297  
277   - });
278   - e.data.currentPage++ ,
279   - wx.stopPullDownRefresh();
280   - }, null, { store_id: os.stoid, user_id: oo.user_id });
281   - },
  298 + });
  299 + e.data.currentPage++ ,
  300 + wx.stopPullDownRefresh();
  301 + }, null, {store_id: os.stoid, user_id: oo.user_id});
  302 + },
282 303 //滑倒底部
283 304 onReachBottom: function() {
284 305 if(this.data.currentIndex == 0) {
... ... @@ -433,398 +454,387 @@ Page({
433 454 });
434 455 },
435 456  
436   - /*----------跳转支付-----------*/
437   - async jumpToCart4(t) {
438   - var o_index = t.currentTarget.dataset.idx;
439   - var e = this.data.orderList[o_index];
440   - var th = this;
441   - var order=e ;
442   - var order_goods=e.order_goods;
443   -
444   - var wlist="";
445   - for(var i in order_goods){
446   - var good=order_goods[i];
447   - //线下取价功能已经关闭或者过期
448   - if(!th.data.is_open_offline && good.offline_cut>0){
449   - wx.showModal({
450   - title: '提示',
451   - content: '线下取价功能已经关闭或者过期!'
452   - });
453   - return false;
454   - }
455   - //如果不是小程序有的功能,直接提示要去3.0处理
456   - if(good.prom_type==2 ){
457   - wx.showModal({
458   - title: '提示',
459   - content: '小程序还未有该活动,请到3.0公众号支付'
460   - });
461   - return false;
462   - }
463   - //要每件每件的商品进行检查,看有么有超出库存,超出限购
464   - var good= order_goods[i],goodsbuynum=0,promgoodsbuynum=0,gg=null;
465   - //获取单品的现在的活动状态
466   - await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, {
467   - }).then(res=>{
468   - gg=res.data.data;
469   - })
470   - var limit = gg.viplimited;
471   - var store_count = gg.store_count;
472   - good.erpwareid=gg.erpwareid;
473   -
474   - //---要获得商品,该用户买了多少件,同步应用---
475   - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
476   - data: {
477   - store_id: os.stoid,
478   - user_id: getApp().globalData.user_id,
479   - goods_id: good.goods_id,
480   - prom_type: good.prom_type,
481   - prom_id: good.prom_id
482   - },
483   - }).then(res => {
484   - var buy_num_data = res.data.data;
485   - if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
486   - goodsbuynum = buy_num_data.goodsbuynum;
487   - })
488   -
489   - var buyed_mum2=goodsbuynum+good.goods_num;
490   - if (buyed_mum2 > limit && limit > 0) {
491   - var content=gg.goods_name+'购买数量超出商品限购,请取消订单';
492   - th.toast(content);
493   - return false;
494   - }
  457 + /*----------跳转支付-----------*/
  458 + async jumpToCart4(t) {
  459 + var o_index = t.currentTarget.dataset.idx;
  460 + var e = this.data.orderList[o_index];
  461 + var th = this;
  462 + var order = e;
  463 + var order_goods = e.order_goods;
  464 +
  465 + var wlist = "";
  466 + for (var i in order_goods) {
  467 + var good = order_goods[i];
  468 + //线下取价功能已经关闭或者过期
  469 + if (!th.data.is_open_offline && good.offline_cut > 0) {
  470 + wx.showModal({
  471 + title: '提示',
  472 + content: '线下取价功能已经关闭或者过期!'
  473 + });
  474 + return false;
  475 + }
  476 + //如果不是小程序有的功能,直接提示要去3.0处理
  477 + if (good.prom_type == 2) {
  478 + wx.showModal({
  479 + title: '提示',
  480 + content: '小程序还未有该活动,请到3.0公众号支付'
  481 + });
  482 + return false;
  483 + }
  484 + //要每件每件的商品进行检查,看有么有超出库存,超出限购
  485 + var good = order_goods[i], goodsbuynum = 0, promgoodsbuynum = 0, gg = null;
  486 + //获取单品的现在的活动状态
  487 + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, {}).then(res => {
  488 + gg = res.data.data;
  489 + })
  490 + var limit = gg.viplimited;
  491 + var store_count = gg.store_count;
  492 + good.erpwareid = gg.erpwareid;
  493 +
  494 + //---要获得商品,该用户买了多少件,同步应用---
  495 + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  496 + data: {
  497 + store_id: os.stoid,
  498 + user_id: getApp().globalData.user_id,
  499 + goods_id: good.goods_id,
  500 + prom_type: good.prom_type,
  501 + prom_id: good.prom_id
  502 + },
  503 + }).then(res => {
  504 + var buy_num_data = res.data.data;
  505 + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
  506 + goodsbuynum = buy_num_data.goodsbuynum;
  507 + })
  508 +
  509 + var buyed_mum2 = goodsbuynum + good.goods_num;
  510 + if (buyed_mum2 > limit && limit > 0) {
  511 + var content = gg.goods_name + '购买数量超出商品限购,请取消订单';
  512 + th.toast(content);
  513 + return false;
  514 + }
495 515  
496   - //当是组合优惠的时候
497   - if(good.prom_type==7){
498   - //如果有组合购
499   - var isok = 1;
500   - var url="/api/weshop/prom/zhbuy/get/"+os.stoid+"/"+good.prom_id+"/"+getApp().globalData.userInfo.user_id;
501   - await getApp().request.promiseGet(url, {}).then(res => {
502   - if(res.data.code==0 && res.data.data){
503   - if(res.data.data.is_show!=1){
504   - isok=0;
  516 + //当是组合优惠的时候
  517 + if (good.prom_type == 7) {
  518 + //如果有组合购
  519 + var isok = 1;
  520 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + good.prom_id + "/" + getApp().globalData.userInfo.user_id;
  521 + await getApp().request.promiseGet(url, {}).then(res => {
  522 + if (res.data.code == 0 && res.data.data) {
  523 + if (res.data.data.is_show != 1) {
  524 + isok = 0;
  525 + }
  526 + //如果活动已经结束
  527 + if (res.data.data.is_end == 1) {
  528 + isok = 0;
  529 + }
  530 + //已经结束
  531 + if (ut.gettimestamp() > res.data.data.end_time) {
  532 + isok = 0;
  533 + }
  534 + //还未开始
  535 + if (ut.gettimestamp() < res.data.data.start_time) {
  536 + isok = 0;
  537 + }
  538 +
  539 + } else {
  540 + //未找到商品的活动
  541 + isok = 0;
505 542 }
506   - //如果活动已经结束
507   - if(res.data.data.is_end==1){
508   - isok=0;
  543 +
  544 + })
  545 + if (!isok) {
  546 + var content = gg.goods_name + '活动已经结束,请取消订单';
  547 + th.toast(content);
  548 + return false;
  549 + }
  550 +
  551 + var url1 = "/api/weshop/prom/zhbuyGoods/page";
  552 + var req_data = {
  553 + page: 1,
  554 + pageSize: 1,
  555 + store_id: os.stoid,
  556 + zh_id: good.prom_id,
  557 + goods_id: good.goods_id
  558 + }
  559 + await getApp().request.promiseGet(url1, {
  560 + data: req_data
  561 + }).then(res => {
  562 + if (ut.ajax_ok(res)) {
  563 + var gdlist = res.data.data.pageData[0];
  564 + good.buyqty = gdlist.buyqty;
509 565 }
510   - //已经结束
511   - if(ut.gettimestamp()>res.data.data.end_time){
512   - isok=0;
  566 + })
  567 +
  568 + var num = good['buyqty'];
  569 + console.log(1111);
  570 + console.log(num);
  571 + //---- 要计算商品的限购 -----
  572 + if (good['buyqty'] > 0) {
  573 + if (good.goods_num + promgoodsbuynum > good['buyqty']) {
  574 +
  575 + var content = good['goods_name'] + "超出活动限购\n";
  576 + th.toast(content);
  577 + return false;
513 578 }
514   - //还未开始
515   - if(ut.gettimestamp()<res.data.data.start_time){
516   - isok=0;
  579 + }
  580 + }
  581 +
  582 + //如果优惠促销和搭配购的时候
  583 + if ((good.prom_type == 3 || good.prom_type == 5) && good.is_gift != 1 && good.is_collocation != 1) {
  584 + var p_ok = 1;
  585 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => {
  586 + if (res.data.code == 0) {
  587 + var r_data = res.data.data;
  588 + if (!r_data.collocationPromList && good.prom_type == 5) {
  589 +
  590 + var content = good.goods_name + '未找到活动,请取消订单重新购买';
  591 + th.toast(content)
  592 +
  593 + p_ok = 0;
  594 + }
  595 + if (!r_data.promGoodsLists && good.prom_type == 3) {
  596 +
  597 + var content = good.goods_name + '未找到活动,请取消订单重新购买';
  598 + th.toast(content);
  599 + p_ok = 0;
  600 + }
  601 + } else {
  602 +
  603 + var content = good.goods_name + '未找到活动,请取消订单重新购买'
  604 + th.toast(content);
  605 + p_ok = 0;
517 606 }
  607 + })
  608 + if (!p_ok) return false;
  609 + }
518 610  
519   - }else{
520   - //未找到商品的活动
521   - isok = 0;
  611 + //商品的普通购买 ,不要进行判断
  612 + if ((good.prom_type == 1 || good.prom_type == 6 || good.prom_type == 4 || good.prom_type == 8)
  613 + && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal) {
  614 + if (gg.prom_type != good.prom_type) {
  615 + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
  616 + th.toast(content);
  617 + return false;
522 618 }
523 619  
524   - })
525   - if (!isok){
526   - var content=gg.goods_name+'活动已经结束,请取消订单';
527   - th.toast(content);
528   - return false;
  620 + } else {
  621 + if ((gg.prom_type == 1 || gg.prom_type == 3 || gg.prom_type == 5 || gg.prom_type == 6 || gg.prom_type == 4)
  622 + && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
  623 + var prom = null;
  624 + //---如果是活动的时候---
  625 + var prom = null, th = this;
  626 + if (gg.prom_type == 1) {
  627 + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => {
  628 + if (res.data.code == 0) {
  629 + prom = res.data.data;
  630 + }
  631 + })
  632 + }
  633 + if (gg.prom_type == 6) {
  634 + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => {
  635 + if (res.data.code == 0) {
  636 + prom = res.data.data;
  637 + }
  638 + })
  639 + }
  640 +
  641 + if (gg.prom_type == 4) {
  642 + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", {
  643 + data: {store_id: os.stoid, goods_id: gg.goods_id}
  644 + }).then(res => {
  645 + if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
  646 + prom = res.data.data.pageData[0];
  647 + }
  648 + })
  649 + }
  650 +
  651 + if (prom) {
  652 + var t_now = ut.gettimestamp();
  653 + if (prom.is_end == 0 && prom.start_time < t_now && prom.end_time > t_now) {
  654 +
  655 + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
  656 + th.toast(content);
  657 + return false;
  658 + }
  659 + }
  660 + }
  661 + else {
  662 + if (!good.is_gift && good.prom_type != 3) {
  663 + var t_ok = 1;
  664 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => {
  665 + if (res.data.code == 0) {
  666 + var r_data = res.data.data;
  667 + //-- 参加了全局的优惠活动 --
  668 + if (r_data.promGoodsLists) {
  669 + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
  670 + th.toast(content);
  671 + t_ok = 0;
  672 + }
  673 + }
  674 + })
  675 + if (!t_ok) return false;
  676 + }
  677 + //-- 如果有参加线下取价 --
  678 + if (good.offline_cut > 0) wlist += encodeURIComponent(gg.erpwareid) + ",";
  679 + }
  680 + //赠品和搭配购不判断商品金额
  681 + var isok = 1;
  682 + var card_field = th.data.card_field;
  683 +
  684 + //-- 如果会员是等级会员,商品有等级价,且不是活动商品,同时线下取价的要放在最后来判断 --
  685 + if (!good.is_gift && !good.is_collocation) {
  686 + if (card_field && gg[card_field] > 0) {
  687 + if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0;
  688 + if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  689 +
  690 + } else {
  691 + if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0;
  692 + if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  693 + }
  694 + var is_h = 0;
  695 + if (!isok) {
  696 +
  697 + var content = gg.goods_name + '商品的价格发生了变化,请取消订单重新购买1'
  698 + th.toast(content);
  699 + return false;
  700 + }
  701 + }
  702 +
  703 + //--如果是线下库存的时候--
  704 + if (th.data.conf.sales_rules == 2) {
  705 + var ob = {};
  706 + await th.check_down_line_next(gg, good.goods_num, order.pickup_id, function (obj) {
  707 + ob = obj;
  708 + })
  709 + if (ob.code == -1) {
  710 +
  711 + var content = gg.goods_name + '门店库存不足,请取消订单';
  712 + th.toast(content);
  713 + return false;
  714 + }
  715 +
  716 + } else {
  717 + if (good.goods_num > store_count) {
  718 +
  719 + var content = gg.goods_name + '商品的库存不足,请取消订单';
  720 + th.toast(content);
  721 + return false;
  722 + }
  723 +
  724 + }
  725 + }
  726 +
  727 + console.log("------------------------------------");
  728 + //---如果是活动的时候---
  729 + var prom = null, goodsinfo = good, th = this;
  730 + if (goodsinfo.prom_type == 1) {
  731 + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => {
  732 + if (res.data.code == 0) {
  733 + prom = res.data.data;
  734 + }
  735 + })
  736 + }
  737 + if (goodsinfo.prom_type == 6 && !good.is_pd_normal) {
  738 + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => {
  739 + if (res.data.code == 0) {
  740 + prom = res.data.data;
  741 + }
  742 + })
529 743 }
530 744  
531   - var url1 = "/api/weshop/prom/zhbuyGoods/page";
532   - var req_data = {
533   - page: 1,
534   - pageSize: 1,
535   - store_id: os.stoid,
536   - zh_id: good.prom_id,
537   - goods_id:good.goods_id
  745 + if (goodsinfo.prom_type == 4 && !good.is_integral_normal) {
  746 + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", {
  747 + data: {store_id: os.stoid, goods_id: goodsinfo.goods_id}
  748 + }).then(res => {
  749 + if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
  750 + prom = res.data.data.pageData[0];
  751 + }
  752 + })
538 753 }
539   - await getApp().request.promiseGet(url1, {
540   - data: req_data
541   - }).then(res => {
542   - if (ut.ajax_ok(res)) {
543   - var gdlist = res.data.data.pageData[0];
544   - good.buyqty=gdlist.buyqty;
  754 +
  755 + //----------如果有活动,并且在进行中,就不计算线下库存---------------
  756 + if (prom) {
  757 + var now = ut.gettimestamp();
  758 + if (prom.is_end == 1 && prom.end_time < now) {
  759 +
  760 + var content = goodsinfo.goods_name + '商品的活动已经结束,请取消订单'
  761 + th.toast(content);
  762 + return false;
545 763 }
546   - })
547 764  
548   - var num=good['buyqty'];
549   - console.log(1111);
550   - console.log(num);
551   - //---- 要计算商品的限购 -----
552   - if(good['buyqty']>0){
553   - if(good.goods_num+promgoodsbuynum>good['buyqty']){
  765 + buyed_mum2 = promgoodsbuynum + good.goods_num;
  766 + if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) {
554 767  
555   - var content= good['goods_name']+"超出活动限购\n";
  768 + var content = goodsinfo.goods_name + '购买数量超出商品活动限购,请取消订单'
556 769 th.toast(content);
557 770 return false;
558 771 }
559   - }
560   - }
561 772  
  773 + if (goodsinfo.prom_type == 4) {
  774 + if (good.goods_num > prom.limitqty - prom.buy_num) {
562 775  
563   -
564   - //如果优惠促销和搭配购的时候
565   - if((good.prom_type==3 || good.prom_type==5) && good.is_gift!=1 && good.is_collocation!=1){
566   - var p_ok=1;
567   - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
568   - if(res.data.code==0){
569   - var r_data=res.data.data;
570   - if(!r_data.collocationPromList && good.prom_type==5){
571   -
572   - var content=good.goods_name+'未找到活动,请取消订单重新购买';
573   - th.toast(content)
574   -
575   - p_ok=0;
576   - }
577   - if(!r_data.promGoodsLists && good.prom_type==3){
578   -
579   - var content=good.goods_name+'未找到活动,请取消订单重新购买';
580   - th.toast(content);
581   - p_ok=0;
582   - }
583   - }else{
584   -
585   - var content=good.goods_name+'未找到活动,请取消订单重新购买'
586   - th.toast(content);
587   - p_ok=0;
588   - }
589   - })
590   - if(!p_ok) return false;
591   - }
592   -
593   - //商品的普通购买 ,不要进行判断
594   - if((good.prom_type==1 || good.prom_type==6 || good.prom_type==4 )
595   - && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal){
596   - if(gg.prom_type!=good.prom_type) {
597   - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
598   - th.toast(content);
599   - return false;
600   - }
601   -
602   - }else{
603   - if((gg.prom_type==1 || gg.prom_type==3 || gg.prom_type==5 || gg.prom_type==6 || gg.prom_type==4)
604   - && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
605   - var prom=null;
606   - //---如果是活动的时候---
607   - var prom=null,th=this;
608   - if(gg.prom_type==1){
609   - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+gg.prom_id,{
610   - }).then(res=>{
611   - if(res.data.code==0){
612   - prom=res.data.data;
613   - }
614   - })
615   - }
616   - if(gg.prom_type==6){
617   - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+gg.prom_id,{
618   - }).then(res=>{
619   - if(res.data.code==0){
620   - prom=res.data.data;
621   - }
622   - })
623   - }
624   -
625   - if(gg.prom_type==4){
626   - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
627   - data:{store_id:os.stoid,goods_id:gg.goods_id}
628   - }).then(res=>{
629   - if(res.data.code==0 && res.data.data && res.data.data.pageData){
630   - prom=res.data.data.pageData[0];
631   - }
632   - })
633   - }
634   -
635   - if(prom){
636   - var t_now=ut.gettimestamp();
637   - if(prom.is_end==0 && prom.start_time<t_now && prom.end_time>t_now){
638   -
639   - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
640   - th.toast(content);
641   - return false;
642   - }
643   - }
644   - }
645   - else{
646   - if(!good.is_gift && good.prom_type!=3 ){
647   - var t_ok=1;
648   - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
649   - if(res.data.code==0){
650   - var r_data=res.data.data;
651   - //-- 参加了全局的优惠活动 --
652   - if(r_data.promGoodsLists){
653   - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买';
654   - th.toast(content);
655   - t_ok=0;
656   - }
657   - }
658   - })
659   - if(!t_ok) return false;
660   - }
661   - //-- 如果有参加线下取价 --
662   - if(good.offline_cut>0) wlist+=encodeURIComponent(gg.erpwareid)+",";
663   - }
664   - //赠品和搭配购不判断商品金额
665   - var isok=1;
666   - var card_field=th.data.card_field;
667   -
668   - //-- 如果会员是等级会员,商品有等级价,且不是活动商品,同时线下取价的要放在最后来判断 --
669   - if(!good.is_gift && !good.is_collocation) {
670   - if (card_field && gg[card_field] > 0) {
671   - if (good.goods_price != gg[card_field] && good.offline_cut<=0) isok = 0;
672   - if (good.goods_price >gg[card_field] && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过
673   -
674   - } else {
675   - if (good.goods_price != gg.shop_price && good.offline_cut<=0) isok = 0;
676   - if (good.goods_price> gg.shop_price && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过
677   - }
678   - var is_h=0;
679   - if (!isok) {
680   -
681   - var content=gg.goods_name + '商品的价格发生了变化,请取消订单重新购买'
682   - th.toast(content);
683   - return false;
684   - }
685   - }
686   -
687   - //--如果是线下库存的时候--
688   - if(th.data.conf.sales_rules==2){
689   - var ob={};
690   - await th.check_down_line_next(gg,good.goods_num,order.pickup_id,function(obj){
691   - ob=obj;
692   - })
693   - if(ob.code==-1){
694   -
695   - var content=gg.goods_name+'门店库存不足,请取消订单';
696   - th.toast(content);
697   - return false;
698   - }
699   -
700   - }else{
701   - if(good.goods_num>store_count){
702   -
703   - var content=gg.goods_name+'商品的库存不足,请取消订单';
704   - th.toast(content);
705   - return false;
706   - }
707   -
708   - }
709   - }
710   -
711   - console.log("------------------------------------");
712   - //---如果是活动的时候---
713   - var prom=null,goodsinfo=good,th=this;
714   - if(goodsinfo.prom_type==1){
715   - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+goodsinfo.prom_id,{
716   - }).then(res=>{
717   - if(res.data.code==0){
718   - prom=res.data.data;
719   - }
720   - })
721   - }
722   - if(goodsinfo.prom_type==6 && !good.is_pd_normal){
723   - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{
724   - }).then(res=>{
725   - if(res.data.code==0){
726   - prom=res.data.data;
727   - }
728   - })
729   - }
730   -
731   - if(goodsinfo.prom_type==4 && !good.is_integral_normal){
732   - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
733   - data:{store_id:os.stoid,goods_id:goodsinfo.goods_id}
734   - }).then(res=>{
735   - if(res.data.code==0 && res.data.data && res.data.data.pageData){
736   - prom=res.data.data.pageData[0];
737   - }
738   - })
739   - }
740   -
741   - //----------如果有活动,并且在进行中,就不计算线下库存---------------
742   - if(prom){
743   - var now=ut.gettimestamp();
744   - if(prom.is_end==1 && prom.end_time<now){
745   -
746   - var content=goodsinfo.goods_name+'商品的活动已经结束,请取消订单'
747   - th.toast(content);
748   - return false;
749   - }
750   -
751   - buyed_mum2=promgoodsbuynum+good.goods_num;
752   - if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) {
753   -
754   - var content=goodsinfo.goods_name+'购买数量超出商品活动限购,请取消订单'
755   - th.toast(content);
756   - return false;
757   - }
758   -
759   - if(goodsinfo.prom_type==4){
760   - if (good.goods_num > prom.limitqty-prom.buy_num) {
761   -
762   - var content=goodsinfo.goods_name+'购买数量超出商品活动库存,请取消订单'
763   - th.toast(content);
764   - return false;
765   - }
766   - }else{
767   - var redis_num = 0;
768   - //------判断活动是否抢光-----
769   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
770   - os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, {
771   - }).then(res => {
772   - redis_num = res.data.data;
773   - });
774   -
775   - if (good.goods_num > redis_num) {
776   -
777   - var content=gg.goods_name+'超出商品活动库存,请取消订单';
778   - th.toast(content);
779   - return false;
780   - }
781   - }
782   -
783   - }
784   - }
785   -
786   - //-- 要判断一下线下取价价格是不是发生改变 --
787   - if(wlist!="" && th.data.is_open_offline && th.data.is_open_offline>0){
788   - wlist=ut.sub_last(wlist);
789   - var keyid=order.pickup_id;
790   - var user_info=getApp().globalData.userInfo;
791   - if(!keyid) return false;
792   - var offarr=null;
793   - await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", {
794   - data:{
795   - VIPId:encodeURIComponent(user_info.erpvipid),
796   - store_id:os.stoid,
797   - PickupId:keyid,
798   - WareIds:wlist},
799   - },
800   - ).then(res=>{
801   - if(res.data.code==0 && res.data.data && res.data.data.length>0){
802   - offarr=res.data.data;
803   - }
804   - })
805   - if(!offarr && offarr.length<=0){
806   - th.toast('获取线下取价失败');
807   - }
808   - var newarr=ut.convert_arr_key(offarr,'WareId');
809   - //-- 循环判断线下的价格 --
810   - for(var k in order_goods){
811   - var good=order_goods[k];
812   - //判断线下取价是不是一样
813   - if(newarr[good.erpwareid] &&
814   - parseFloat(newarr[good.erpwareid].WarePrice)!=parseFloat(good.goods_price)){
815   -
816   - var content=good.goods_name + '商品的价格发生了变化,请取消订单重新购买';
817   - th.toast(content);
818   - return false;
819   - }
820   - }
821   -
822   - }
  776 + var content = goodsinfo.goods_name + '购买数量超出商品活动库存,请取消订单'
  777 + th.toast(content);
  778 + return false;
  779 + }
  780 + } else {
  781 + var redis_num = 0;
  782 + //------判断活动是否抢光-----
  783 + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
  784 + os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, {}).then(res => {
  785 + redis_num = res.data.data;
  786 + });
  787 +
  788 + if (good.goods_num > redis_num) {
  789 +
  790 + var content = gg.goods_name + '超出商品活动库存,请取消订单';
  791 + th.toast(content);
  792 + return false;
  793 + }
  794 + }
823 795  
824   - return false;
825   -
826   - th.pay_next(e,o_index);
827   - },
  796 + }
  797 + }
  798 +
  799 + //-- 要判断一下线下取价价格是不是发生改变 --
  800 + if (wlist != "" && th.data.is_open_offline && th.data.is_open_offline > 0) {
  801 + wlist = ut.sub_last(wlist);
  802 + var keyid = order.pickup_id;
  803 + var user_info = getApp().globalData.userInfo;
  804 + if (!keyid) return false;
  805 + var offarr = null;
  806 + await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", {
  807 + data: {
  808 + VIPId: encodeURIComponent(user_info.erpvipid),
  809 + store_id: os.stoid,
  810 + PickupId: keyid,
  811 + WareIds: wlist
  812 + },
  813 + },
  814 + ).then(res => {
  815 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  816 + offarr = res.data.data;
  817 + }
  818 + })
  819 + if (!offarr && offarr.length <= 0) {
  820 + th.toast('获取线下取价失败');
  821 + }
  822 + var newarr = ut.convert_arr_key(offarr, 'WareId');
  823 + //-- 循环判断线下的价格 --
  824 + for (var k in order_goods) {
  825 + var good = order_goods[k];
  826 + //判断线下取价是不是一样
  827 + if (newarr[good.erpwareid] &&
  828 + parseFloat(newarr[good.erpwareid].WarePrice) != parseFloat(good.goods_price)) {
  829 +
  830 + var content = good.goods_name + '商品的价格发生了变化,请取消订单重新购买';
  831 + th.toast(content);
  832 + return false;
  833 + }
  834 + }
  835 + }
  836 + th.pay_next(e, o_index);
  837 + },
828 838  
829 839  
830 840 pay_next(e,o_index){
... ...
pages/user/order_list/order_list.wxml
... ... @@ -40,27 +40,46 @@
40 40 <text selectable='true'>订单编号:{{item.order_sn}}</text>
41 41 <!-- 商品评价状态 -->
42 42 <view class="flex-center c-r">
43   - <!-- 订单状态 -->
44   - <view wx:if="{{item.pt_status==1 && item.pt_prom_id>0}}">组团中</view>
45   - <view wx:if="{{(item.order_status==0&&item.pay_status==0)}}">未支付</view>
46   - <block wx:if="{{!(item.is_all_return_status==0 || item.is_all_return_status==1)}}">
47   - <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==0)}}">待发货</view>
48   - <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==1)}}">待收货</view>
49   - <view wx:if="{{(item.order_status==2)}}">待评价</view>
50   - <view wx:if="{{item.order_status==4}}">已评价</view>
51   - <view wx:if="{{item.order_status==3 && item.pt_status!=6}}" class="flex-center" >已取消<view class="lin"></view>
52   - <image src="{{iurl}}miniapp/images/trash.png" bindtap="deleteOrderData" data-index="{{index}}" data-order_id="{{item.order_id}}"></image>
53   - </view>
54   - <view wx:if="{{item.pt_status==2 && item.pt_tail_money>0}}">待支付尾款</view>
55   - <view wx:if="{{item.order_status==6}}">退款成功</view>
56   - <view wx:if="{{item.pt_status==6}}"><text style="font-size: 26rpx;">支付尾款失败</text></view>
57   - </block>
58   - <block wx:else>退款中</block>
59   - <!--
60   - <view class="flex" wx:if="{{(item.order_status==0&&item.pay_status==0)}}">
61   - <view class="lin"></view>
62   - <image src="{{iurl}}miniapp/images/trash.png" bindtap="deleteOrderData" data-index="{{index}}" data-order_id="{{item.order_id}}"></image>
63   - </view>-->
  43 +
  44 + <block wx:if="{{item.presell}}">
  45 + <block wx:if="{{item.order_status==3}}">
  46 + <text wx:if="{{item.presell.tail_pay_state==2}}">尾款支付失败</text>
  47 + </block>
  48 + <block wx:else>
  49 + <text wx:if="{{!item.presell.deposit_pay_time}}">待支付定金</text>
  50 + <text wx:if="{{item.presell.presell_type!=1 && item.presell.deposit_pay_time && !item.presell.tail_pay_state}}">待尾款</text>
  51 + </block>
  52 +
  53 + <block wx:if="{{!(item.is_all_return_status==0 || item.is_all_return_status==1)}}">
  54 + <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==0)}}">待发货</view>
  55 + <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==1)}}">待收货</view>
  56 + <view wx:if="{{(item.order_status==2)}}">待评价</view>
  57 + <view wx:if="{{item.order_status==4}}">已评价</view>
  58 + <view wx:if="{{item.order_status==3 && item.pt_status!=6}}" class="flex-center" >已取消<view class="lin"></view>
  59 + <image src="{{iurl}}miniapp/images/trash.png" bindtap="deleteOrderData" data-index="{{index}}" data-order_id="{{item.order_id}}"></image>
  60 + </view>
  61 + </block>
  62 + <block wx:else>退款中</block>
  63 +
  64 + </block>
  65 + <block wx:else>
  66 + <!-- 订单状态 -->
  67 + <view wx:if="{{item.pt_status==1 && item.pt_prom_id>0}}">组团中</view>
  68 + <view wx:if="{{(item.order_status==0&&item.pay_status==0)}}">未支付</view>
  69 + <block wx:if="{{!(item.is_all_return_status==0 || item.is_all_return_status==1)}}">
  70 + <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==0)}}">待发货</view>
  71 + <view wx:if="{{(item.order_status==1&&item.pay_status==1&&item.shipping_status==1)}}">待收货</view>
  72 + <view wx:if="{{(item.order_status==2)}}">待评价</view>
  73 + <view wx:if="{{item.order_status==4}}">已评价</view>
  74 + <view wx:if="{{item.order_status==3 && item.pt_status!=6}}" class="flex-center" >已取消<view class="lin"></view>
  75 + <image src="{{iurl}}miniapp/images/trash.png" bindtap="deleteOrderData" data-index="{{index}}" data-order_id="{{item.order_id}}"></image>
  76 + </view>
  77 + <view wx:if="{{item.pt_status==2 && item.pt_tail_money>0}}">待支付尾款</view>
  78 + <view wx:if="{{item.order_status==6}}">退款成功</view>
  79 + <view wx:if="{{item.pt_status==6}}"><text style="font-size: 26rpx;">支付尾款失败</text></view>
  80 + </block>
  81 + <block wx:else>退款中</block>
  82 + </block>
64 83  
65 84 </view>
66 85 </view>
... ... @@ -70,7 +89,7 @@
70 89 <!-- 单个商品 -->
71 90 <!-- wx:if="{{goods.return_btn!=4}}" -->
72 91 <view>
73   - <navigator class="detail_commodity flex-vertical padding" wx:for="{{item.order_goods}}" wx:for-item="goods" wx:for-index="pinx" url="/pages/user/order_detail/order_detail?order_id={{item.order_id}}">
  92 + <navigator class="detail_commodity flex-vertical padding" wx:for="{{item.order_goods}}" wx:for-item="goods" wx:for-index="pinx" url="{{item.ord_url}}?order_id={{item.order_id}}">
74 93 <!-- 商品图片 -->
75 94 <navigator class="rel">
76 95 <image src="{{resourceUrl+goods.original_img}}" binderror="bind_bnerr" lazy-load="{{true}}" data-errorimg="orderList[{{index}}].order_goods[{{pinx}}].original_img"></image>
... ... @@ -173,15 +192,22 @@
173 192 </block>
174 193 <navigator class="commodity_To_evaluate flex-level View_evaluation" hidden="{{!(item.exp_type==0&&item.pay_status==1&&item.shipping_status==1)}}" url="/pages/user/express/express?order_id={{item.order_id}}">查看物流</navigator>
175 194 <navigator class="commodity_To_evaluate flex-level View_evaluation" hidden="{{!(item.exp_type==0&&item.pay_status==1&&item.shipping_status==2)}}" url="/pages/user/express/express?order_id={{item.order_id}}">查看物流</navigator>
176   - <navigator class="commodity_To_evaluate flex-level View_evaluation" url="/pages/user/order_detail/order_detail?order_id={{item.order_id}}">订单详情</navigator>
  195 +
  196 + <navigator class="commodity_To_evaluate flex-level View_evaluation" url="{{item.ord_url}}?order_id={{item.order_id}}">订单详情</navigator>
177 197  
178 198 <block wx:if="{{!(item.has_rt || item.return_btn==2 || item.return_btn==4)}}">
179 199 <view bindtap="confirmOrder" data-zsorder="{{item.is_zsorder}}" class="commodity_To_evaluate flex-level comment_go" data-id="{{item.order_id}}" hidden="{{!(item.order_status==1&&item.pay_status==1&&item.shipping_status==1)}}">确认收货</view>
180 200 <view bindtap="confirmOrder" data-zsorder="{{item.is_zsorder}}" class="commodity_To_evaluate flex-level comment_go" data-id="{{item.order_id}}" hidden="{{!(item.order_status==1&&item.pay_status==1&&item.shipping_status==2)}}">确认收货</view>
181 201 </block>
182   -
183   -
184   - <block wx:if="{{item.order_status==2 && item.is_zsorder!=4}}">
  202 +
  203 + <block wx:if="{{item.presell && item.presell.presell_type!=1}}">
  204 + <navigator class="commodity_To_evaluate flex-level comment_go" url="/packageC/pages/presell/cart/cart?order_id={{item.order_id}}" data-idx="{{index}}" wx:if="{{item.order_status<3 && item.presell.deposit_pay_time>0 && item.presell.tail_pay_state==0}}">支付尾款</navigator>
  205 +
  206 + </block>
  207 +
  208 +
  209 +
  210 + <block wx:if="{{item.order_status==2 && item.is_zsorder!=4}}">
185 211 <navigator wx:if="{{item.order_goods.length>1}}" class="order-btn white"
186 212 url="/packageB/pages/user/comment/comment?status=0&order_id={{item.order_id}}">评价</navigator>
187 213 <navigator wx:else class="order-btn white red-b"
... ... @@ -193,10 +219,15 @@
193 219 <navigator class="commodity_To_evaluate flex-level comment_go" bindtap="jumpToCart4" data-idx="{{index}}" wx:if="{{(item.order_status==0&&item.pay_status==0)}}">立即支付</navigator>
194 220  
195 221 <!-- 积分购 拼团 搭配购没有有再来一单 -->
196   - <block wx:if="{{(item.pay_status==1 || item.order_status==3) && item.pt_prom_id<=0 && item.integral<=0 && item.order_goods[0].prom_type!=5 }}">
  222 + <block wx:if="{{(item.pay_status==1 || item.order_status==3) && !item.presell && item.pt_prom_id<=0 && item.integral<=0 && item.order_goods[0].prom_type!=5 }}">
197 223 <view bindtap="moreOrder" class="commodity_To_evaluate flex-level comment_go"
198 224 data-index="{{index}}" >再来一单</view>
199 225 </block>
  226 +
  227 +
  228 +
  229 +
  230 +
200 231  
201 232 </view>
202 233 </view>
... ...
pages/user/order_list/order_list.wxss
... ... @@ -533,11 +533,14 @@ page {
533 533 }
534 534 .search-btn {
535 535 color: white;
536   - font-size: 14px;
  536 + font-size: 28rpx;
537 537 background-color: #FF3B3D;
538   - padding: 8px 20px;
539   - border-radius: 0 4px 4px 0;
  538 + padding: 6rpx 40rpx;
  539 + border-radius: 0 4px 4px 0;
  540 + line-height: 60rpx;
540 541 }
  542 +
  543 +
541 544 .picker-container {
542 545 padding-right: 10rpx;
543 546 align-items: center;
... ...
setting.js deleted
1   -module.exports = {
2   - appName: "派派通",
3   - versionCode: "1.0.0",
4   - appLogo: "../../../images/logo.png",
5   - // url: "https://test-weshop.yolipai.net",
6   - url: "https://test-weshop.xinda100.cn",
7   - //url:"https://weshop.yolipai.net", //外网的网址
8   - //url:"http://172.20.3.121:8085", //明海的网址
9   - //url:"http://172.20.3.102:8085", //自己的网址
10   - banner_err:"../../../images/del/logo.png",
11   - imghost: "https://mshopimg.yolipai.net/",
12   - share: {},
13   - stoid:1,
14   -
15   -};
utils/auth.js
... ... @@ -153,8 +153,10 @@ module.exports = {
153 153 ab.get("/api/weshop/users/get/" + oo.stoid+"/"+app_d.user_id, {
154 154 data:{r:Math.random()},
155 155 success: function (e) {
156   - app_d.userInfo = e.data.data;
157   - "function" == typeof t && t(e.data.data);
  156 + app_d.userInfo = e.data.data;
  157 + app_d.user_id = e.data.data.user_id;
  158 + wx.setStorageSync("userinfo",app_d.userInfo);
  159 + "function" == typeof t && t(e.data.data);
158 160 },
159 161 });
160 162 }else{
... ... @@ -186,7 +188,9 @@ module.exports = {
186 188 ab.get("/api/weshop/users/get/" + oo.stoid + "/" + app_d.user_id, {
187 189 isShowLoading:0,
188 190 success: function (e) {
189   - app_d.userInfo = e.data.data;
  191 + app_d.userInfo = e.data.data;
  192 + app_d.user_id = e.data.data.user_id;
  193 + wx.setStorageSync("userinfo",app_d.userInfo);
190 194 "function" == typeof t && t(e.data.data);
191 195 },
192 196 });
... ...
utils/util.js
... ... @@ -481,6 +481,14 @@ function ajax_ok2(res){
481 481 return 0;
482 482 }
483 483  
  484 +function wx_back() {
  485 + var arr=getCurrentPages();
  486 + if(arr.length<=2){
  487 + getApp().goto("/pages/index/index/index");
  488 + }else{
  489 + wx.navigateBack();
  490 + }
  491 +}
484 492  
485 493 module.exports = {
486 494 formatTime: function(e, r) {
... ... @@ -591,5 +599,6 @@ module.exports = {
591 599 sha1:sha1, //sha1进行签名
592 600 convert_arr_key:convert_arr_key, //将JS数组对象按其某个键值重组成Map对象
593 601 ajax_ok:ajax_ok, //将JS数组对象按其某个键值重组成Map对象
594   - ajax_ok2:ajax_ok2 //将JS数组对象按其某个键值重组成Map对象
  602 + ajax_ok2:ajax_ok2, //将JS数组对象按其某个键值重组成Map对象
  603 + wx_back:wx_back
595 604 };
... ...