Commit 86d7cb9f6c9667c002c7c63b599a7f5c2a96ab07

Authored by yvan.ni
1 parent 2f090dbe

购物车

pages/cart/cart/cart.js
1 -var t = getApp(), a = t.request, oo = t.globalData.setting, app = getApp(), rq = t.request; 1 +var t = getApp(),
  2 + a = t.request,
  3 + oo = t.globalData.setting,
  4 + app = getApp(),
  5 + rq = t.request;
2 var regeneratorRuntime = require('../../../utils/runtime.js'); 6 var regeneratorRuntime = require('../../../utils/runtime.js');
3 7
4 Page({ 8 Page({
5 - data: {  
6 - url: t.globalData.setting.url,  
7 - resourceUrl: t.globalData.setting.resourceUrl,  
8 - requestData: null,  
9 - checkAllToggle: 0,  
10 - total_fee:0,  
11 - allsto:null,  
12 - imgUrl:t.globalData.setting.imghost,  
13 - },  
14 - onLoad: function() {  
15 -  
16 - wx.setNavigationBarTitle({ title: "购物车",})  
17 -  
18 - var a = this;  
19 - t.auth.hadAuth() && t.getUserInfo(function() {  
20 - a.getCardList(); 9 + data: {
  10 + url: t.globalData.setting.url,
  11 + resourceUrl: t.globalData.setting.resourceUrl,
  12 + iurl: t.globalData.setting.imghost,
  13 + requestData: null,
  14 + checkAllToggle: 0,
  15 + total_fee: 0,
  16 + allsto: null,
  17 + imgUrl: t.globalData.setting.imghost,
  18 + is_has_flash:0, //是否又秒杀活动
  19 + },
  20 + onLoad: function() {
  21 + wx.setNavigationBarTitle({title: "购物车", })
  22 + var a = this;
  23 + //判断是否有登陆
  24 + t.auth.hadAuth() && t.getUserInfo(function() {
  25 + a.getCardList();
  26 + });
  27 + },
  28 + onShow: function() {
  29 + var th=this;
  30 + this.getCardList();
  31 + //--获取是否又秒杀活动--
  32 + getApp().request.promiseGet("/api/ms/flash_sale/spikepage", {
  33 + data: {
  34 + store_id: oo.stoid,
  35 + timetype: 2,
  36 + is_end: 0,
  37 + is_show: 1,
  38 + pageSize: 1
  39 + },
  40 + }).then(res => {
  41 + if(res.data.code==0 && res.data.data && res.data.data.pageData.length>0){
  42 + th.setData({is_has_flash:1})
  43 + }
  44 + });
  45 +
  46 + },
  47 +
  48 + //-------------获取购物车列表,要安装门店进行分类订单-----------
  49 + getCardList: function() {
  50 + var th = this;
  51 + //如果门店还未读出来的时候
  52 + if (th.data.allsto == null) {
  53 + //读取门店
  54 + app.get_allsto(function(e) {
  55 + th.setData({
  56 + allsto: e
21 }); 57 });
22 - },  
23 - onShow: function() {  
24 - this.getCardList();  
25 - },  
26 -  
27 - //-------------获取购物车列表,要安装门店进行分类订单-----------  
28 - getCardList: function () {  
29 - var th = this;  
30 - //如果门店还未读出来的时候  
31 - if (th.data.allsto==null){  
32 - //读取门店  
33 - app.get_allsto(function(e){  
34 - th.setData({ allsto: e});  
35 - th.get_cart();  
36 - })  
37 - }else{ th.get_cart();} 58 + th.get_cart();
  59 + })
  60 + } else {
  61 + th.get_cart();
  62 + }
38 }, 63 },
39 //-----真的获取购物车-------- 64 //-----真的获取购物车--------
40 - get_cart:function(){  
41 - var th=this; 65 + get_cart: function() {
  66 + var th = this;
42 var rd = Math.random().toString(36).substr(2, 15); 67 var rd = Math.random().toString(36).substr(2, 15);
43 getApp().request.get("/api/weshop/cart/list", { 68 getApp().request.get("/api/weshop/cart/list", {
44 data: { 69 data: {
45 - user_id: app.globalData.user_id, rd: rd,  
46 - store_id: oo.stoid,pageSize:600},  
47 - success: function (su) { 70 + user_id: app.globalData.user_id,
  71 + rd: rd,
  72 + store_id: oo.stoid,
  73 + pageSize: 600
  74 + },
  75 + success: function(su) {
48 console.log("333"); 76 console.log("333");
49 - console.log(th.data.allsto);  
50 - 77 + console.log(th.data.allsto);
  78 +
51 //按门店分类的数组 79 //按门店分类的数组
52 var arr = new Array(); 80 var arr = new Array();
53 var carr = su.data.data.pageData; 81 var carr = su.data.data.pageData;
@@ -55,32 +83,39 @@ Page({ @@ -55,32 +83,39 @@ Page({
55 var item = carr[i]; 83 var item = carr[i];
56 item.original_img = oo.imghost + item.original_img; 84 item.original_img = oo.imghost + item.original_img;
57 85
58 - item.selected=0;  
59 - 86 + item.selected = 0;
  87 +
60 var pcid = item.pick_id; 88 var pcid = item.pick_id;
61 var find = 0; 89 var find = 0;
62 //---------循环查找门店--- 90 //---------循环查找门店---
63 - if (arr.length>0){  
64 - for (var j = 0; j < arr.length; j++) {  
65 - if (arr[j].pid == pcid) {  
66 - arr[j].goods.push(item);  
67 - find = 1;  
68 - break;  
69 - } 91 + if (arr.length > 0) {
  92 + for (var j = 0; j < arr.length; j++) {
  93 + if (arr[j].pid == pcid) {
  94 + arr[j].goods.push(item);
  95 + find = 1;
  96 + break;
70 } 97 }
  98 + }
71 } 99 }
72 100
73 //------如果没有找到----- 101 //------如果没有找到-----
74 if (find == 0) { 102 if (find == 0) {
75 var pikname = ''; 103 var pikname = '';
76 //找到门店名称 104 //找到门店名称
77 - for (var k=0;k<th.data.allsto.length;k++){  
78 - if (pcid == th.data.allsto[k].pickup_id){  
79 - pikname = th.data.allsto[k].pickup_name;break; 105 + for (var k = 0; k < th.data.allsto.length; k++) {
  106 + if (pcid == th.data.allsto[k].pickup_id) {
  107 + pikname = th.data.allsto[k].pickup_name;
  108 + break;
80 } 109 }
81 } 110 }
82 - var narr = new Array(); narr.push(item);  
83 - var ie = { pid: pcid, pname: pikname, goods: narr,selected:0}; 111 + var narr = new Array();
  112 + narr.push(item);
  113 + var ie = {
  114 + pid: pcid,
  115 + pname: pikname,
  116 + goods: narr,
  117 + selected: 0
  118 + };
84 arr.push(ie); 119 arr.push(ie);
85 } 120 }
86 } 121 }
@@ -90,478 +125,587 @@ Page({ @@ -90,478 +125,587 @@ Page({
90 125
91 th.setData({ 126 th.setData({
92 requestData: arr, 127 requestData: arr,
93 - }),  
94 - th.doCheckAll(), wx.stopPullDownRefresh(); 128 + }),
  129 + th.doCheckAll(), wx.stopPullDownRefresh();
95 } 130 }
96 }); 131 });
97 }, 132 },
98 //删除商品 133 //删除商品
99 delete_th_item: function(t) { 134 delete_th_item: function(t) {
100 - var e = this;  
101 - var a=rq;  
102 - console.log(a);  
103 - wx.showModal({  
104 - title: "确定删除",  
105 - success: function(s) {  
106 - if (s.confirm) {  
107 - var r =t.currentTarget.dataset.cartid;  
108 - var url = '/api/weshop/cart/del/'+oo.stoid+'/'+r;  
109 - a.delete(url, {  
110 - success: function(t) {  
111 - e.getCardList();  
112 - }  
113 - });  
114 - } 135 + var e = this;
  136 + var a = rq;
  137 + console.log(a);
  138 + wx.showModal({
  139 + title: "确定删除?",
  140 + success: function(s) {
  141 + if (s.confirm) {
  142 + var r = t.currentTarget.dataset.cartid;
  143 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + r;
  144 + a.delete(url, {
  145 + success: function(t) {
  146 + e.getCardList();
115 } 147 }
116 - });  
117 - },  
118 -  
119 - //-----------------点击输入修改商品数量---------------  
120 - valueToNum: function(t) {  
121 - var a = t.currentTarget.dataset.item;  
122 - var b = t.currentTarget.dataset.pitems;  
123 - a = this.data.requestData[b].goods[a];  
124 - var e=a;  
125 - if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) {  
126 - var s = {  
127 - goods_num: a,  
128 - goods_id:e.goods_id,  
129 - id: e.id,  
130 - store_id:oo.stoid  
131 - };  
132 - this.postCardList(s, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);  
133 - }  
134 - },  
135 -  
136 - //-------------加数量---------------------  
137 - addNum: function(t) {  
138 - var a = t.currentTarget.dataset.item;  
139 - var b = t.currentTarget.dataset.pitems;  
140 - a = this.data.requestData[b].goods[a];  
141 -  
142 - if (!(a.goods_num >= a.store_count)) {  
143 - var e = {  
144 - goods_num: a.goods_num + 1,  
145 - id: a.id,  
146 - goods_id:a.goods_id,  
147 - store_id:oo.stoid  
148 - };  
149 - this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);  
150 - }  
151 - },  
152 - //-------------减数量---------------------  
153 - subNum: function(t) {  
154 - var a = t.currentTarget.dataset.item;  
155 - var b = t.currentTarget.dataset.pitems;  
156 - a = this.data.requestData[b].goods[a];  
157 -  
158 - if(a.goods_num - 1<0) return false;  
159 -  
160 - if (1 != a.goods_num) {  
161 - var e = {  
162 - goods_num: a.goods_num - 1,  
163 - id: a.id,  
164 - goods_id: a.goods_id,  
165 - store_id:oo.stoid  
166 - };  
167 - this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);  
168 - }  
169 - },  
170 - //---------------全选,全选的时候要判断是否门店的匹配方式一致--------------  
171 - checkAll: function() {  
172 - var e = this, dda = e.data.requestData, tfeel = 0,text_arr="";  
173 - for (var i = 0; i < dda.length; i++) {  
174 - var item=dda[i].goods;  
175 - if (!e.data.checkAllToggle){  
176 - var txt = "requestData[" +i+ "].selected";  
177 - e.setData({ [txt]:0,});  
178 - }  
179 - var fir=0;  
180 - for(var j=0;j<item.length;j++){  
181 - if (fir == 0) {fir=item[j].distr_type;}  
182 - else{  
183 - //如果同一门店有不同门店的商品,不能同一配送  
184 - if (fir != item[j].distr_type && !e.data.checkAllToggle && item[j].distr_type!=0 ){  
185 - text_arr+=item[j].goods_name+" "; break;  
186 - }  
187 - }  
188 - var txt = "requestData[" + i + "].goods["+j+"].selected"  
189 - e.setData({  
190 - [txt]: !e.data.checkAllToggle,  
191 - })  
192 - if (!e.data.checkAllToggle)  
193 - tfeel += item[j].goods_num * item[j].goods_price; 148 + });
194 } 149 }
195 } 150 }
  151 + });
  152 + },
196 153
197 - if (text_arr!=""){  
198 - wx.showModal({ title: '提示', content: text_arr+'不能与门店中其他商品一起结算,配送方式不一致' }); return false;  
199 - e.setData({  
200 - total_fee: tfeel.toFixed(2),  
201 - });  
202 - }else{  
203 - e.setData({  
204 - checkAllToggle: !e.data.checkAllToggle,  
205 - total_fee: tfeel.toFixed(2),  
206 - }); 154 + //-----------------点击输入修改商品数量---------------
  155 + valueToNum: function(t) {
  156 + var a = t.currentTarget.dataset.item;
  157 + var b = t.currentTarget.dataset.pitems;
  158 + a = this.data.requestData[b].goods[a];
  159 + var e = a;
  160 + if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) {
  161 + var s = {
  162 + goods_num: a,
  163 + goods_id: e.goods_id,
  164 + id: e.id,
  165 + store_id: oo.stoid
  166 + };
  167 + this.postCardList(s, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
  168 + }
  169 + },
  170 +
  171 + //-------------加数量---------------------
  172 + addNum: function(t) {
  173 + var a = t.currentTarget.dataset.item;
  174 + var b = t.currentTarget.dataset.pitems;
  175 + a = this.data.requestData[b].goods[a];
  176 +
  177 + if (!(a.goods_num >= a.store_count)) {
  178 + var e = {
  179 + goods_num: a.goods_num + 1,
  180 + id: a.id,
  181 + goods_id: a.goods_id,
  182 + store_id: oo.stoid
  183 + };
  184 + isShowLoading: 0;
  185 + this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
  186 + }
  187 + },
  188 + //-------------减数量---------------------
  189 + subNum: function(t) {
  190 + var a = t.currentTarget.dataset.item;
  191 + var b = t.currentTarget.dataset.pitems;
  192 + a = this.data.requestData[b].goods[a];
  193 +
  194 + if (a.goods_num - 1 < 0) return false;
  195 +
  196 + if (1 != a.goods_num) {
  197 + var e = {
  198 + goods_num: a.goods_num - 1,
  199 + id: a.id,
  200 + goods_id: a.goods_id,
  201 + store_id: oo.stoid
  202 + };
  203 + this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
  204 + }
  205 + },
  206 + //---------------全选,全选的时候要判断是否门店的匹配方式一致--------------
  207 + checkAll: function() {
  208 + var e = this,
  209 + dda = e.data.requestData,
  210 + tfeel = 0,
  211 + text_arr = "";
  212 + for (var i = 0; i < dda.length; i++) {
  213 + var item = dda[i].goods;
  214 + if (!e.data.checkAllToggle) {
  215 + var txt = "requestData[" + i + "].selected";
  216 + e.setData({
  217 + [txt]: 0,
  218 + });
207 } 219 }
208 - },  
209 -  
210 - //------门店全选按钮,要判断是否门店的匹配方式一致---------  
211 - check_th_all_item:function(ele){  
212 - var e=this,pitems = ele.currentTarget.dataset.pitems,item = this.data.requestData[pitems].goods;  
213 - var sele = this.data.requestData[pitems].selected;  
214 -  
215 - var isok = 1, fir = 0, iarr = item;  
216 - if (!sele && item.length > 0 ){  
217 -  
218 - console.log(item);  
219 - for (var i = 0; i < iarr.length; i++) {  
220 - if (iarr[i].distr_type != 0) {  
221 - if (fir == 0) { fir = iarr[i].distr_type; }  
222 - else {  
223 - if (fir != iarr[i].distr_type && iarr[i].distr_type!=0 ) { isok = 0; break; }  
224 - } 220 + var fir = 0;
  221 + for (var j = 0; j < item.length; j++) {
  222 + if (fir == 0) {
  223 + fir = item[j].distr_type;
  224 + } else {
  225 + //如果同一门店有不同门店的商品,不能同一配送
  226 + if (fir != item[j].distr_type && !e.data.checkAllToggle && item[j].distr_type != 0) {
  227 + text_arr += item[j].goods_name + " ";
  228 + break;
225 } 229 }
226 } 230 }
227 - } 231 + var txt = "requestData[" + i + "].goods[" + j + "].selected"
  232 + e.setData({
  233 + [txt]: !e.data.checkAllToggle,
  234 + })
  235 + if (!e.data.checkAllToggle)
  236 + tfeel += item[j].goods_num * item[j].goods_price;
  237 + }
  238 + }
228 239
229 - if (!isok) {  
230 - wx.showModal({ title: '提示', content: '同一门店自提和物流的商品不能同时结算' }); return false; 240 + if (text_arr != "") {
  241 + wx.showModal({
  242 + title: '提示',
  243 + content: text_arr + '不能与门店中其他商品一起结算,配送方式不一致'
  244 + });
  245 + return false;
  246 + e.setData({
  247 + total_fee: tfeel.toFixed(2),
  248 + });
  249 + } else {
  250 + e.setData({
  251 + checkAllToggle: !e.data.checkAllToggle,
  252 + total_fee: tfeel.toFixed(2),
  253 + });
  254 + }
  255 + },
  256 +
  257 + //------门店全选按钮,要判断是否门店的匹配方式一致---------
  258 + check_th_all_item: function(ele) {
  259 + var e = this,
  260 + pitems = ele.currentTarget.dataset.pitems,
  261 + item = this.data.requestData[pitems].goods;
  262 + var sele = this.data.requestData[pitems].selected;
  263 +
  264 + var isok = 1,
  265 + fir = 0,
  266 + iarr = item;
  267 + if (!sele && item.length > 0) {
  268 +
  269 + console.log(item);
  270 + for (var i = 0; i < iarr.length; i++) {
  271 + if (iarr[i].distr_type != 0) {
  272 + if (fir == 0) {
  273 + fir = iarr[i].distr_type;
  274 + } else {
  275 + if (fir != iarr[i].distr_type && iarr[i].distr_type != 0) {
  276 + isok = 0;
  277 + break;
  278 + }
  279 + }
231 } 280 }
  281 + }
  282 + }
232 283
233 - for(var i=0;i<item.length;i++){  
234 - var txt = "requestData[" + pitems + "].goods[" + i+ "].selected";  
235 - e.setData({  
236 - [txt]: Number(!sele),  
237 - });  
238 - }  
239 - var txt = "requestData[" + pitems + "].selected";  
240 - e.setData({  
241 - [txt]: Number(!sele),  
242 - });  
243 - this.doCheckAll();  
244 - },  
245 -  
246 - //---------------单选,也要判断门店的配送方式是否一致--------------  
247 - check_th_item: function(t) {  
248 - var e=this, item = t.currentTarget.dataset.item,pitems = t.currentTarget.dataset.pitems;  
249 - a = this.data.requestData[pitems].goods[item];  
250 - var isok=1,fir=0;  
251 - var iarr = e.data.requestData[pitems].goods;  
252 -  
253 -  
254 - //当数量大于1,且是选择的时候  
255 - if (iarr.length > 1 && !a.selected){  
256 - for (var i = 0; i < iarr.length;i++){  
257 - //---当不是本身选择项目----  
258 - var sel = iarr[i].selected;  
259 - if (iarr[i].distr_type != 0 && (sel || iarr[i].id==a.id)) {  
260 - if (fir == 0) { fir = iarr[i].distr_type; }  
261 - else {  
262 - if (fir != iarr[i].distr_type && iarr[i].distr_type != 0) { isok = 0; break; }  
263 - }  
264 - } 284 + if (!isok) {
  285 + wx.showModal({
  286 + title: '提示',
  287 + content: '同一门店自提和物流的商品不能同时结算'
  288 + });
  289 + return false;
  290 + }
  291 +
  292 + for (var i = 0; i < item.length; i++) {
  293 + var txt = "requestData[" + pitems + "].goods[" + i + "].selected";
  294 + e.setData({
  295 + [txt]: Number(!sele),
  296 + });
  297 + }
  298 + var txt = "requestData[" + pitems + "].selected";
  299 + e.setData({
  300 + [txt]: Number(!sele),
  301 + });
  302 + this.doCheckAll();
  303 + },
  304 +
  305 + //---------------单选,也要判断门店的配送方式是否一致--------------
  306 + check_th_item: function(t) {
  307 + var e = this,
  308 + item = t.currentTarget.dataset.item,
  309 + pitems = t.currentTarget.dataset.pitems;
  310 + a = this.data.requestData[pitems].goods[item];
  311 + var isok = 1,
  312 + fir = 0;
  313 + var iarr = e.data.requestData[pitems].goods;
  314 +
  315 +
  316 + //当数量大于1,且是选择的时候
  317 + if (iarr.length > 1 && !a.selected) {
  318 + for (var i = 0; i < iarr.length; i++) {
  319 + //---当不是本身选择项目----
  320 + var sel = iarr[i].selected;
  321 + if (iarr[i].distr_type != 0 && (sel || iarr[i].id == a.id)) {
  322 + if (fir == 0) {
  323 + fir = iarr[i].distr_type;
  324 + } else {
  325 + if (fir != iarr[i].distr_type && iarr[i].distr_type != 0) {
  326 + isok = 0;
  327 + break;
  328 + }
265 } 329 }
266 } 330 }
267 - if(!isok){  
268 - wx.showModal({ title: '提示', content: '同一门店自提和物流的商品不能同时结算' });  
269 - }else{  
270 - var txt = "requestData[" + pitems + "].goods[" + item + "].selected";  
271 - e.setData({  
272 - [txt]: Number(!a.selected),  
273 - });  
274 - this.doCheckAll(); 331 + }
  332 + }
  333 + if (!isok) {
  334 + wx.showModal({
  335 + title: '提示',
  336 + content: '同一门店自提和物流的商品不能同时结算'
  337 + });
  338 + } else {
  339 + var txt = "requestData[" + pitems + "].goods[" + item + "].selected";
  340 + e.setData({
  341 + [txt]: Number(!a.selected),
  342 + });
  343 + this.doCheckAll();
  344 + }
  345 + },
  346 + //----------检查是否全选---------
  347 + doCheckAll: function() {
  348 + var th = this,
  349 + tfeel = 0,
  350 + ischeck = 1,
  351 + car = this.data.requestData;
  352 + for (var a = 0; a < car.length; a++) {
  353 + var item = car[a].goods;
  354 + var is_s_sele = 1;
  355 + for (var c = 0; c < item.length; c++) {
  356 + if (item[c].selected == 0) {
  357 + ischeck = 0;
  358 + is_s_sele = 0;
  359 + } else {
  360 + tfeel += item[c].goods_num * item[c].goods_price;
275 } 361 }
276 - },  
277 - //----------检查是否全选---------  
278 - doCheckAll: function() {  
279 - var th=this,tfeel=0,ischeck = 1,car = this.data.requestData;  
280 - for (var a = 0; a < car.length; a++) {  
281 - var item = car[a].goods;  
282 - var is_s_sele=1;  
283 - for (var c = 0; c < item.length;c++){  
284 - if(item[c].selected==0){  
285 - ischeck=0;  
286 - is_s_sele=0;  
287 - }  
288 - else{ tfeel += item[c].goods_num * item[c].goods_price; }  
289 - } 362 + }
290 363
291 - var txt = "requestData[" + a+ "].selected";  
292 - th.setData({  
293 - [txt]: Number(is_s_sele), 364 + var txt = "requestData[" + a + "].selected";
  365 + th.setData({
  366 + [txt]: Number(is_s_sele),
  367 + });
  368 +
  369 + }
  370 + this.setData({
  371 + checkAllToggle: ischeck,
  372 + total_fee: tfeel.toFixed(2),
  373 + });
  374 + },
  375 +
  376 + //----------------------更新购物数量,加减,调用接口---------------------
  377 + postCardList: function(t, item, pitem) {
  378 + var e = this;
  379 + var user_id = getApp().globalData.user_id;
  380 + console.log('update');
  381 + console.log(t);
  382 + rq.get("/api/weshop/goods/get/" + oo.stoid + "/" + t.goods_id, {
  383 + isShowLoading:0,
  384 + async success(d) {
  385 + var limit = d.data.data.viplimited;
  386 + var store_count = d.data.data.store_count;
  387 +
  388 + var goodsinfo = e.data.requestData[pitem].goods[item];
  389 + var promgoodsbuynum = 0;
  390 + var goodsbuynum = 0;
  391 + //--要获得商品,该用户买了多少件,同步应用--
  392 + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  393 + data: {
  394 + store_id: oo.stoid,
  395 + user_id: user_id,
  396 + goods_id: goodsinfo.goods_id,
  397 + prom_type: goodsinfo.prom_type,
  398 + prom_id: goodsinfo.prom_id
  399 + },
  400 + }).then(res => {
  401 + var buy_num_data = res.data.data;
  402 + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
  403 + goodsbuynum = buy_num_data.goodsbuynum;
  404 + })
  405 +
  406 + var buyed_mum2 = t.goods_num + goodsbuynum;
  407 + if (buyed_mum2 > limit && limit > 0) {
  408 + wx.showModal({
  409 + title: '提示',
  410 + content: '购买数量超出商品限购'
  411 + });
  412 + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
  413 + var cbuy = limit - buyed_mum;
  414 + e.setData({
  415 + [txt]: cbuy > 0 ? cbuy : 0,
294 }); 416 });
  417 + return false;
  418 + }
295 419
  420 + if (t.goods_num > store_count) {
  421 + wx.showModal({
  422 + title: '提示',
  423 + content: '购买数量超出商品库存'
  424 + });
  425 + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
  426 + e.setData({
  427 + [txt]: store_count
  428 + });
  429 + return false;
296 } 430 }
297 - this.setData({  
298 - checkAllToggle: ischeck,  
299 - total_fee: tfeel.toFixed(2),  
300 - });  
301 - },  
302 -  
303 - //----------------------更新购物数量,加减,调用接口---------------------  
304 - postCardList: function (t, item, pitem) {  
305 - var e = this;  
306 - var user_id=getApp().globalData.user_id;  
307 - console.log('update');  
308 - console.log(t);  
309 - rq.get("/api/weshop/goods/get/" + oo.stoid + "/" + t.goods_id, {  
310 - async success(d) {  
311 - var limit = d.data.data.viplimited;  
312 - var store_count = d.data.data.store_count;  
313 -  
314 - var goodsinfo=e.data.requestData[pitem ].goods[item];  
315 - var promgoodsbuynum=0;  
316 - var goodsbuynum=0;  
317 - //--要获得商品,该用户买了多少件,同步应用--  
318 - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum",{  
319 - data: {  
320 - store_id: oo.stoid,  
321 - user_id: user_id,  
322 - goods_id: goodsinfo.goods_id,  
323 - prom_type:goodsinfo.prom_type,  
324 - prom_id:goodsinfo.prom_id  
325 - },  
326 - }).then(res=>{  
327 - var buy_num_data=res.data.data;  
328 - if(buy_num_data.promgoodsbuynum) promgoodsbuynum=buy_num_data.promgoodsbuynum;  
329 - goodsbuynum=buy_num_data.goodsbuynum;  
330 - })  
331 -  
332 - var buyed_mum2 = t.goods_num + goodsbuynum;  
333 - if (buyed_mum2>limit && limit>0){  
334 - wx.showModal({ title: '提示', content: '购买数量超出商品限购'});  
335 - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";  
336 - var cbuy = limit - buyed_mum;  
337 - e.setData({ [txt]: cbuy > 0 ? cbuy:0, });  
338 - return false;  
339 - }  
340 431
341 - if (t.goods_num > store_count) {  
342 - wx.showModal({ title: '提示', content: '购买数量超出商品库存' });  
343 - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";  
344 - e.setData({ [txt]: store_count });  
345 - return false;  
346 - } 432 + if (goodsinfo.prom_type == 1) {
  433 + //读取秒杀
  434 + rq.get("/api/ms/flash_sale/getFlashSaleOne/" + oo.stoid + "/" + goodsinfo.prom_id, {
  435 + isShowLoading: 0,
  436 + success: function(res_d) {
  437 + var false_data = res_d.data.data;
  438 +
  439 + //--判断库存--
  440 + if (t.goods_num > false_data.goods_num - false_data.buy_num) {
  441 + wx.showModal({
  442 + title: '提示',
  443 + content: '购买数量超出活动库存'
  444 + });
  445 + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
  446 + e.setData({
  447 + [txt]: false_data.goods_num - false_data.buy_num
  448 + });
  449 + return false;
  450 + }
347 451
348 - if(goodsinfo.prom_type==1){  
349 - //读取秒杀  
350 - rq.get("/api/ms/flash_sale/getFlashSaleOne/" + oo.stoid + "/" + goodsinfo.prom_id, {  
351 - success: function (res_d) {  
352 - var false_data=res_d.data.data;  
353 -  
354 - //--判断库存--  
355 - if (t.goods_num > false_data.goods_num-false_data.buy_num){  
356 - wx.showModal({ title: '提示', content: '购买数量超出活动库存' });  
357 - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";  
358 - e.setData({ [txt]: false_data.goods_num-false_data.buy_num });  
359 - return false;  
360 - }  
361 -  
362 - //--判断redis数量是否已经超出--  
363 - if(t.goods_num >false_data.redisnum){  
364 - wx.showModal({ title: '提示', content: '购买数量超出商品库存' });  
365 - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";  
366 - e.setData({ [txt]: false_data.redisnum });  
367 - return false;  
368 - }  
369 -  
370 - //--活动的限购是不是要判断--  
371 - if(t.goods_num+promgoodsbuynum >false_data.buy_limit && false_data.buy_limit>0){  
372 - wx.showModal({ title: '提示', content: '购买数量超出秒杀限购' });  
373 - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";  
374 - e.setData({ [txt]: false_data.false_data.buy_limit });  
375 - return false;  
376 - }  
377 -  
378 - e.update_cart(t,pitem,item);  
379 - }  
380 - })  
381 - }else{  
382 - e.update_cart(t,pitem,item);  
383 - } 452 + //--判断redis数量是否已经超出--
  453 + if (t.goods_num > false_data.redisnum) {
  454 + wx.showModal({
  455 + title: '提示',
  456 + content: '购买数量超出商品库存'
  457 + });
  458 + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
  459 + e.setData({
  460 + [txt]: false_data.redisnum
  461 + });
  462 + return false;
384 } 463 }
385 - });  
386 - },  
387 -  
388 - //更新购物车  
389 - update_cart:function(t,pitem,item){  
390 - var e=this;  
391 - getApp().request.put("/api/weshop/cart/update", {  
392 - data: t,  
393 - success: function (ee) {  
394 - var txt = "requestData[" + pitem + "].goods[" + item+"].goods_num"; 464 +
  465 + //--活动的限购是不是要判断--
  466 + if (t.goods_num + promgoodsbuynum > false_data.buy_limit && false_data.buy_limit > 0) {
  467 + wx.showModal({
  468 + title: '提示',
  469 + content: '购买数量超出秒杀限购'
  470 + });
  471 + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
395 e.setData({ 472 e.setData({
396 - [txt]: t.goods_num, 473 + [txt]: false_data.false_data.buy_limit
397 }); 474 });
398 - e.doCheckAll(); 475 + return false;
  476 + }
  477 +
  478 + e.update_cart(t, pitem, item);
399 } 479 }
  480 + })
  481 + } else {
  482 + e.update_cart(t, pitem, item);
  483 + }
  484 + }
  485 + });
  486 + },
  487 +
  488 + //更新购物车
  489 + update_cart: function(t, pitem, item) {
  490 + var e = this;
  491 + getApp().request.put("/api/weshop/cart/update", {
  492 + data: t,
  493 + success: function(ee) {
  494 + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num";
  495 + e.setData({
  496 + [txt]: t.goods_num,
400 }); 497 });
401 - },  
402 -  
403 - //-------下拉刷新---------  
404 - onPullDownRefresh: function(t) {  
405 - this.getCardList();  
406 - },  
407 -  
408 - //--------------去结算------------  
409 - async checkout() {  
410 - var glist=""; //用逗号隔开的  
411 - var map=new Map(); //使用map值键进行运算  
412 - var map_limit=new Map(); //使用map值键进行存储限购  
413 - var g_arr = new Array(); //已选的商品列表  
414 - var user_id=getApp().globalData.user_id;  
415 - var th=this;  
416 -  
417 - var ab = 0;//选中  
418 - console.log('checkout');  
419 - for (var i=0;i<this.data.requestData.length;i++){  
420 - var i_arr = this.data.requestData[i].goods;  
421 - for (var j = 0; j < i_arr.length;j++ ){  
422 - if (i_arr[j].selected){  
423 - //map 的key是不会重复,会覆盖,,  
424 - var ie = { goods_id: i_arr[j].goods_id, id: i_arr[j].id, goods_price: i_arr[j].goods_price};  
425 - g_arr.push(ie);  
426 - if(map.has(i_arr[j].goods_id + "")){  
427 - var num11 = map.get(i_arr[j].goods_id + "");  
428 - var num22 = parseInt(i_arr[j].goods_num)+parseInt(num11);  
429 - map.set(i_arr[j].goods_id + "", num22);  
430 - }else{  
431 - map.set(i_arr[j].goods_id + "", i_arr[j].goods_num);  
432 - }  
433 - glist += i_arr[j].goods_id+",";  
434 - ab=1;  
435 - }else{  
436 - rq.put("/api/weshop/cart/update", {  
437 - data: { id: i_arr[j].id, selected: 0,store_id:oo.stoid },  
438 - success: function (ee) {  
439 - console.log(ee);  
440 - }  
441 - });  
442 - } 498 + e.doCheckAll();
  499 + }
  500 + });
  501 + },
  502 +
  503 + //-------下拉刷新---------
  504 + onPullDownRefresh: function(t) {
  505 + this.getCardList();
  506 + },
  507 +
  508 + //--------------去结算------------
  509 + async checkout() {
  510 + var glist = ""; //用逗号隔开的
  511 + var map = new Map(); //使用map值键进行运算
  512 + var map_limit = new Map(); //使用map值键进行存储限购
  513 + var g_arr = new Array(); //已选的商品列表
  514 + var user_id = getApp().globalData.user_id;
  515 + var th = this;
  516 +
  517 + var ab = 0; //选中
  518 + console.log('checkout');
  519 + for (var i = 0; i < this.data.requestData.length; i++) {
  520 + var i_arr = this.data.requestData[i].goods;
  521 + for (var j = 0; j < i_arr.length; j++) {
  522 + if (i_arr[j].selected) {
  523 + //map 的key是不会重复,会覆盖,,
  524 + var ie = {
  525 + goods_id: i_arr[j].goods_id,
  526 + id: i_arr[j].id,
  527 + goods_price: i_arr[j].goods_price
  528 + };
  529 + g_arr.push(ie);
  530 + if (map.has(i_arr[j].goods_id + "")) {
  531 + var num11 = map.get(i_arr[j].goods_id + "");
  532 + var num22 = parseInt(i_arr[j].goods_num) + parseInt(num11);
  533 + map.set(i_arr[j].goods_id + "", num22);
  534 + } else {
  535 + map.set(i_arr[j].goods_id + "", i_arr[j].goods_num);
443 } 536 }
  537 + glist += i_arr[j].goods_id + ",";
  538 + ab = 1;
  539 + } else {
  540 + rq.put("/api/weshop/cart/update", {
  541 + data: {
  542 + id: i_arr[j].id,
  543 + selected: 0,
  544 + store_id: oo.stoid
  545 + },
  546 + success: function(ee) {
  547 + console.log(ee);
  548 + }
  549 + });
444 } 550 }
445 - if (ab==0){t.my_warnning("未选择商品",0,th);return false; }  
446 -  
447 - glist = glist.substring(0, glist.length - 1);  
448 - //--取一下商品的限购 以及活动的限购,redis数量--  
449 - rq.get("/api/weshop/goods/getGoodsListNum", {  
450 - data: { goodsidlist: glist, store_id: oo.stoid },  
451 - async success(ee) {  
452 - console.log(ee);  
453 - if(ee.data.code==0){  
454 - var ddata = ee.data.data, isok = 1, gname="",err="";  
455 - //--组装--  
456 - for (var ij=0;ij<ddata.length;ij++){  
457 - var val=ddata[ij];  
458 - var obj = map_limit.get(val.goods_id+"");  
459 - if(obj) continue;  
460 -  
461 - var promgoodsbuynum=0;  
462 - var goodsbuynum=0;  
463 - //--要获得商品,该用户买了多少件,同步应用--  
464 - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum",{  
465 - data: {  
466 - store_id: oo.stoid,  
467 - user_id: user_id,  
468 - goods_id: val.goods_id,  
469 - prom_type:val.prom_type,  
470 - prom_id:val.prom_id  
471 - },  
472 - }).then(res=>{  
473 - var buy_num_data=res.data.data;  
474 - if(buy_num_data.promgoodsbuynum) promgoodsbuynum=buy_num_data.promgoodsbuynum;  
475 - goodsbuynum=buy_num_data.goodsbuynum;  
476 - })  
477 - var ie={promgoodsbuynum:promgoodsbuynum,goodsbuynum:goodsbuynum};  
478 - map_limit.set(val.goods_id + "", ie);  
479 - }  
480 -  
481 - try{  
482 - ddata.forEach(function(val,ind){  
483 - var num = map.get(val.goods_id+"");  
484 - if (num<=0) {  
485 - isok = 0; gname = val.goods_name;  
486 - throw "购买数量不能为0";return false;  
487 - }  
488 - if ( num>val.store_count) {  
489 - isok = 0; gname = val.goods_name;  
490 - throw "超出库存"; return false;  
491 - }  
492 - if ( num>val.redisnum && val.redisnum) {  
493 - isok = 0; gname = val.goods_name;  
494 - throw "超出活动库存"; return false;  
495 - }  
496 - if ( num>val.goods_num-val.buy_num && val.goods_num) {  
497 - isok = 0; gname = val.goods_name;  
498 - throw "超出活动库存";return false;  
499 - }  
500 -  
501 - var buyed=map_limit.get(val.goods_id+"");  
502 - if (num+buyed.goodsbuynum>val.viplimited && val.viplimited>0) {  
503 - isok = 0; gname = val.goods_name;  
504 - throw "超出商品限购";return false;  
505 - }  
506 -  
507 - if (num+buyed.promgoodsbuynum>val.buy_limit && val.buy_limit>0) {  
508 - isok = 0; gname = val.goods_name;  
509 - throw "超出活动限购";return false;  
510 - }  
511 -  
512 - for (var i = 0; i < g_arr.length;i++){  
513 - if (g_arr[i].goods_id==val.goods_id){  
514 - if(g_arr[i].goods_price != val.shop_price && g_arr[i].goods_price!=val.prom_price){  
515 - isok = 0; gname = val.goods_name;  
516 - throw "商品价格已经变化";  
517 - }  
518 - rq.put("/api/weshop/cart/update", {  
519 - data: { id: g_arr[i].id, selected: 1,store_id:oo.stoid },  
520 - success: function (ee) {  
521 - console.log(ee);  
522 - }  
523 - });  
524 - }  
525 - }  
526 -  
527 - })  
528 - } catch (e) { err=e;}  
529 - if (isok==0){  
530 - if (gname.length > 10) {  
531 - gname = gname.substr(0, 10); gname+="...";  
532 - }  
533 - t.confirmBox(gname+":"+ err); return false; 551 + }
  552 + }
  553 + if (ab == 0) {
  554 + t.my_warnning("未选择商品", 0, th);
  555 + return false;
  556 + }
  557 +
  558 + glist = glist.substring(0, glist.length - 1);
  559 + //--取一下商品的限购 以及活动的限购,redis数量--
  560 + rq.get("/api/weshop/goods/getGoodsListNum", {
  561 + data: {
  562 + goodsidlist: glist,
  563 + store_id: oo.stoid
  564 + },
  565 + async success(ee) {
  566 + console.log(ee);
  567 + if (ee.data.code == 0) {
  568 + var ddata = ee.data.data,
  569 + isok = 1,
  570 + gname = "",
  571 + err = "";
  572 + //--组装--
  573 + for (var ij = 0; ij < ddata.length; ij++) {
  574 + var val = ddata[ij];
  575 + var obj = map_limit.get(val.goods_id + "");
  576 + if (obj) continue;
  577 +
  578 + var promgoodsbuynum = 0;
  579 + var goodsbuynum = 0;
  580 + //--要获得商品,该用户买了多少件,同步应用--
  581 + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  582 + data: {
  583 + store_id: oo.stoid,
  584 + user_id: user_id,
  585 + goods_id: val.goods_id,
  586 + prom_type: val.prom_type,
  587 + prom_id: val.prom_id
  588 + },
  589 + }).then(res => {
  590 + var buy_num_data = res.data.data;
  591 + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
  592 + goodsbuynum = buy_num_data.goodsbuynum;
  593 + })
  594 + var ie = {
  595 + promgoodsbuynum: promgoodsbuynum,
  596 + goodsbuynum: goodsbuynum
  597 + };
  598 + map_limit.set(val.goods_id + "", ie);
  599 + }
  600 +
  601 + try {
  602 + ddata.forEach(function(val, ind) {
  603 + var num = map.get(val.goods_id + "");
  604 + if (num <= 0) {
  605 + isok = 0;
  606 + gname = val.goods_name;
  607 + throw "购买数量不能为0";
  608 + return false;
  609 + }
  610 + if (num > val.store_count) {
  611 + isok = 0;
  612 + gname = val.goods_name;
  613 + throw "超出库存";
  614 + return false;
  615 + }
  616 + if (num > val.redisnum && val.redisnum) {
  617 + isok = 0;
  618 + gname = val.goods_name;
  619 + throw "超出活动库存";
  620 + return false;
  621 + }
  622 + if (num > val.goods_num - val.buy_num && val.goods_num) {
  623 + isok = 0;
  624 + gname = val.goods_name;
  625 + throw "超出活动库存";
  626 + return false;
  627 + }
  628 +
  629 + var buyed = map_limit.get(val.goods_id + "");
  630 + if (num + buyed.goodsbuynum > val.viplimited && val.viplimited > 0) {
  631 + isok = 0;
  632 + gname = val.goods_name;
  633 + throw "超出商品限购";
  634 + return false;
  635 + }
  636 +
  637 + if (num + buyed.promgoodsbuynum > val.buy_limit && val.buy_limit > 0) {
  638 + isok = 0;
  639 + gname = val.goods_name;
  640 + throw "超出活动限购";
  641 + return false;
  642 + }
  643 +
  644 + for (var i = 0; i < g_arr.length; i++) {
  645 + if (g_arr[i].goods_id == val.goods_id) {
  646 + if (g_arr[i].goods_price != val.shop_price && g_arr[i].goods_price != val.prom_price) {
  647 + isok = 0;
  648 + gname = val.goods_name;
  649 + throw "商品价格已经变化";
  650 + }
  651 + rq.put("/api/weshop/cart/update", {
  652 + data: {
  653 + id: g_arr[i].id,
  654 + selected: 1,
  655 + store_id: oo.stoid
  656 + },
  657 + success: function(ee) {
  658 + console.log(ee);
534 } 659 }
535 - wx.navigateTo({  
536 - url: "/pages/cart/cart2/cart2"  
537 - }); 660 + });
538 } 661 }
  662 + }
  663 +
  664 + })
  665 + } catch (e) {
  666 + err = e;
539 } 667 }
540 - });  
541 - },  
542 -  
543 - //结算到最后一个商品  
544 - set_last: function (ab, isok, gname){  
545 - if (isok == 0) {  
546 - t.my_warnning(gname + "商品超出库存",0,this);  
547 - } else {  
548 - ab ? wx.navigateTo({  
549 - url: "/pages/cart/cart2/cart2"  
550 - }) : t.my_warnning("还没有选中商品",0,this); 668 + if (isok == 0) {
  669 + t.confirmBox(gname + ":" + err);
  670 + return false;
  671 + }
  672 + wx.navigateTo({
  673 + url: "/pages/cart/cart2/cart2"
  674 + });
  675 + }
551 } 676 }
552 - }, 677 + });
  678 + },
  679 +
  680 + //结算到最后一个商品
  681 + set_last: function(ab, isok, gname) {
  682 + if (isok == 0) {
  683 + t.my_warnning(gname + "商品超出库存", 0, this);
  684 + } else {
  685 + ab ? wx.navigateTo({
  686 + url: "/pages/cart/cart2/cart2"
  687 + }) : t.my_warnning("还没有选中商品", 0, this);
  688 + }
  689 + },
553 690
554 691
555 //图片失败,默认图片 692 //图片失败,默认图片
556 - bind_bnerr2: function (e) { 693 + bind_bnerr2: function(e) {
557 var _errImg = e.target.dataset.errorimg; 694 var _errImg = e.target.dataset.errorimg;
558 var _errurl = e.target.dataset.url; 695 var _errurl = e.target.dataset.url;
559 var ii = _errurl.indexOf(oo.imghost); 696 var ii = _errurl.indexOf(oo.imghost);
560 if (ii != -1) { 697 if (ii != -1) {
561 this.setData({ 698 this.setData({
562 - [_errImg]: oo.imghost+"/miniapp/images/default_g_img.gif", 699 + [_errImg]: oo.imghost + "/miniapp/images/default_g_img.gif",
563 }) 700 })
564 } 701 }
  702 + },
  703 + //设置点击按钮为true或者false
  704 + radio_chick: function(checked, num) {
  705 + var th = this;
  706 + var requestData = th.data.requestData;
  707 +
  708 +
565 } 709 }
566 710
567 -}); 711 -});
  712 +});
568 \ No newline at end of file 713 \ No newline at end of file
pages/cart/cart/cart.wxml
1 <view class="container" wx:if="{{requestData.length>0}}"> 1 <view class="container" wx:if="{{requestData.length>0}}">
2 - <view class="login-in pd-bg-fff">  
3 - <block wx:for="{{requestData}}" wx:key="{{index}}" wx:for-index="pidx">  
4 - <view class="shmd_m">  
5 - <view bindtap="check_th_all_item" class="goods-ico" data-pitems="{{pidx}}" >  
6 - <icon color="{{checkAllToggle||item.selected?'red':'gray'}}" size="16" type="success"></icon>  
7 - </view>  
8 - <view class="shmd">门店:{{item.pname}}</view> 2 +
  3 + <!-- 广告图片 -->
  4 + <navigator class="picture" url="/pages/activity/seckill_list/seckill_list" wx:if="{{is_has_flash}}">
  5 + <image class="picture" src="{{iurl}}miniapp/images/stores/Seckill.png"></image>
  6 + </navigator>
  7 +
  8 + <!-- 购物车商品框架 -->
  9 + <view class="login-in">
  10 + <!-- 编辑 -->
  11 + <view class="padding flex-vertical-between fs26 Storenum">
  12 + <view class="flex">
  13 + <view>商品数量:</view>
  14 + <view class="goods_num">{{requestData.length}}</view>
  15 + </view>
  16 + <view>编辑</view>
  17 + </view>
  18 + <block wx:for="{{requestData}}" wx:key="{{index}}" wx:for-index="pidx">
  19 + <!-- 门店底下的商品 -->
  20 + <view class="store">
  21 + <view class="shmd_m padding">
  22 + <radio color="red" bindtap="check_th_all_item" class="goods-ico flex-center"
  23 + checked="{{checkAllToggle||item.selected}}" data-pitems="{{pidx}}"></radio>
  24 + <view class="flex-center">
  25 + <image src="{{iurl}}miniapp/images/stores/store.png"></image>
  26 + <view class="shmd fs24">{{item.pname}}</view>
9 </view> 27 </view>
10 - <view class="order-item" data-item="{{idx}}" wx:for="{{item.goods}}"  
11 - wx:for-item="items"  
12 - wx:for-index="idx" wx:key="{{index}}">  
13 - <view bindtap="check_th_item" class="goods-ico" data-check="{{items.selected}}" data-item="{{idx}}" data-pitems="{{pidx}}">  
14 - <icon color="{{checkAllToggle||items.selected?'red':'gray'}}" size="16" type="success"></icon> 28 + </view>
  29 + <view class="order-item padding" data-item="{{idx}}" wx:for="{{item.goods}}" wx:for-item="items" wx:for-index="idx" wx:key="{{index}}">
  30 + <view bindtap="check_th_item" class="goods-ico" data-check="{{items.selected}}" data-item="{{idx}}" data-pitems="{{pidx}}">
  31 + <radio color="red" checked="{{checkAllToggle||items.selected}}"></radio>
  32 + </view>
  33 + <navigator class="goods-img rel" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{items.goods_id}}">
  34 + <image class="wh100" src="{{items.original_img}}" binderror="bind_bnerr2" data-errorimg="requestData[{{pidx}}].goods[{{idx}}].original_img" data-url="{{items.original_img}}"></image>
  35 + <view class="abs flex-center fs26" wx:if="{{items.distr_type==0}}">自选</view>
  36 + <view class="abs flex-center fs26" wx:if="{{items.distr_type==1}}">自提</view>
  37 + <view class="abs flex-center fs26" wx:if="{{items.distr_type==2}}">物流</view>
  38 + </navigator>
  39 + <view class="goods-cont">
  40 + <view class="goods-name">
  41 + <navigator class="ellipsis-2 fs24" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{items.goods_id}}">{{items.goods_name}}</navigator>
  42 + <view class="Specifications flex-center">{{items.goods_color+items.goods_spec.length
  43 + <1? '规格1': ''}}{{items.goods_color}}{{items.goods_color.length>0?"/":''}}{{items.goods_spec}}</view>
  44 + </view>
  45 +
  46 + <view class="flex alend jc_sb">
  47 + <view class="goods-price co-red baseline ellipsis-1">
  48 + <view class="fs20">¥</view>
  49 + <view class="fs28">{{items.goods_price}}</view>
15 </view> 50 </view>
16 - <navigator class="goods-img" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{items.goods_id}}">  
17 - <image class="wh100" src="{{items.original_img}}"  
18 - binderror="bind_bnerr2" data-errorimg="requestData[{{pidx}}].goods[{{idx}}].original_img"  
19 - data-url="{{items.original_img}}" ></image>  
20 - </navigator>  
21 - <view class="goods-cont">  
22 - <navigator class="goods-name ellipsis-2" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{items.goods_id}}">{{items.goods_name}}</navigator>  
23 - <view class="goods-attribute ellipsis-2">{{items.spec_key_name}}</view>  
24 - <view class="goods-price co-red">¥{{items.goods_price}}</view>  
25 - <view bindtap="delete_th_item" class="btn-del" data-cartid="{{items.id}}">  
26 - <image class="wh100" src="{{imgUrl}}/miniapp/images/dele.png"></image>  
27 - </view>  
28 - <view class="count">  
29 - <view bindtap="subNum" class="sub" data-pitems="{{pidx}}" data-item="{{idx}}">-</view>  
30 - <input bindblur="valueToNum" data-pitems="{{pidx}}" data-item="{{idx}}" type="number" value="{{items.goods_num}}"></input>  
31 - <view bindtap="addNum" class="add" data-pitems="{{pidx}}" data-item="{{idx}}">+</view>  
32 - </view> 51 + <view class="count">
  52 + <view bindtap="subNum" class="sub fs28" data-pitems="{{pidx}}" data-item="{{idx}}">一</view>
  53 + <input class="goodadd" bindblur="valueToNum" data-pitems="{{pidx}}" data-item="{{idx}}" type="number" value="{{items.goods_num}}"></input>
  54 + <view class="add" bindtap="addNum" data-pitems="{{pidx}}" data-item="{{idx}}">+</view>
33 </view> 55 </view>
  56 + </view>
34 </view> 57 </view>
35 - </block>  
36 - </view> 58 + </view>
  59 + </view>
  60 + </block>
  61 + </view>
37 62
38 - <view class="pay-for">  
39 - <label bindtap="checkAll" class="checkbox">  
40 - <icon class="ico-check" color="{{checkAllToggle?'red':'gray'}}" size="20" type="success"></icon>全选  
41 - </label>  
42 - <button bindtap="checkout" class="pay-btn">去结算</button>  
43 - <view class="consumer">  
44 - <view class="total">总计 : <text class="co-red">{{total_fee}}</text>  
45 - </view>  
46 - <text class="tips">不包含运费</text> 63 + <view class="pay-for flex-vertical-between">
  64 + <view class="allradio flex-vertical-between">
  65 + <view class="flex-vertical">
  66 + <radio bindtap="checkAll" color="red" checked="{{checkAllToggle}}"></radio>
  67 + <view class="all fs30">全选</view>
  68 + </view>
  69 + <view class="consumer">
  70 + <view class="fs30 baseline">
  71 + <view class="total">合计:</view>
  72 + <text class="co-red">¥{{total_fee}}</text>
  73 + </view>
  74 + <view class="flex-level-right">
  75 + <text class="tips fs20">不含运费</text>
47 </view> 76 </view>
  77 + </view>
  78 + </view>
  79 + <view>
  80 + <button wx:if="{{true}}" bindtap="checkout" class="pay-btn">结算(2)</button>
  81 + <button wx:if="{{false}}" bindtap="checkout" class="pay-btn">删除</button>
48 </view> 82 </view>
  83 + </view>
49 </view> 84 </view>
50 <view class="no-data" wx:if="{{!requestData||requestData.length==0}}"> 85 <view class="no-data" wx:if="{{!requestData||requestData.length==0}}">
51 - <image class="cart-image" src="{{imgUrl}}/miniapp/images/cart-null.png"></image>  
52 - <view class="no-data-title">购物车暂无商品</view>  
53 - <navigator class="lookat" openType="switchTab" url="/pages/index/index/index"> 去逛逛 </navigator> 86 + <image class="cart-image" src="{{imgUrl}}/miniapp/images/cart-null.png"></image>
  87 + <view class="no-data-title">购物车暂无商品</view>
  88 + <navigator class="lookat" openType="switchTab" url="/pages/index/index/index"> 去逛逛 </navigator>
54 </view> 89 </view>
55 90
56 91
pages/cart/cart/cart.wxss
1 page { 1 page {
2 - background-color: #fff; 2 + background-color: #fff;
  3 + font-family: crosoft yahei;
  4 +}
  5 +
  6 +.padding {
  7 + padding: 0rpx 30rpx;
  8 +}
  9 +
  10 +.alend {
  11 + align-items: flex-end;
  12 +}
  13 +
  14 +.goods-price {
  15 + font-size: 18rpx;
  16 +}
  17 +
  18 +.baseline {
  19 + display: flex;
  20 + align-items: baseline;
  21 +}
  22 +
  23 +.picture {
  24 + width: 100%;
  25 + height: 220rpx;
3 } 26 }
4 27
5 .container { 28 .container {
6 - display: flex;  
7 - height: 100%;  
8 - align-items: center;  
9 - justify-content: center;  
10 - background-color: #fff;  
11 - padding-bottom: 100rpx; 29 + display: flex;
  30 + height: 100%;
  31 + align-items: center;
  32 + justify-content: center;
  33 + background-color: #fff;
  34 + padding-bottom: 100rpx;
  35 +}
  36 +
  37 +radio {
  38 + transform: scale(0.8);
  39 + margin-right: 30rpx;
12 } 40 }
13 41
14 .login-in { 42 .login-in {
15 - width: 100%;  
16 - box-sizing: border-box; 43 + width: 100%;
  44 + box-sizing: border-box;
17 } 45 }
18 46
19 .order-item { 47 .order-item {
20 - display: flex;  
21 - justify-content: space-around;  
22 - height: 200rpx;  
23 - padding: 10rpx 0;  
24 - border-bottom: 1px solid #ddd; 48 + display: flex;
  49 + height: 246rpx;
  50 + border-top: 3rpx solid rgb(245, 245, 245);
  51 + align-items: center;
25 } 52 }
26 53
27 .goods-ico { 54 .goods-ico {
28 - display: flex;  
29 - align-items: center; 55 + display: flex;
  56 + align-items: center;
30 } 57 }
31 58
32 .goods-img { 59 .goods-img {
33 - width: 180rpx;  
34 - height: 180rpx;  
35 - font-size: 0;  
36 - margin-top: 10rpx; 60 + width: 180rpx;
  61 + height: 180rpx;
  62 + font-size: 0;
  63 + overflow: hidden;
37 } 64 }
38 65
39 .goods-cont { 66 .goods-cont {
40 - position: relative;  
41 - width: 430rpx;  
42 - height: 200rpx;  
43 - font-size: 28rpx; 67 + width: 400rpx;
  68 + height: 165rpx;
  69 + font-size: 28rpx;
  70 + margin-left: 35rpx;
  71 + padding-top: 10rpx;
  72 + padding-bottom: 5rpx;
44 } 73 }
45 74
46 .goods-name { 75 .goods-name {
47 - width: 370rpx;  
48 - height: 64rpx;  
49 - margin: 8rpx 0;  
50 - line-height: 32rpx;  
51 - color: #333;  
52 - 76 + line-height: 32rpx;
  77 + color: #333;
  78 + height: 130rpx;
53 } 79 }
54 80
55 .goods-attribute { 81 .goods-attribute {
56 - max-height: 52rpx;  
57 - line-height: 26rpx;  
58 - font-size: 24rpx;  
59 - color: #999; 82 + max-height: 52rpx;
  83 + line-height: 26rpx;
  84 + font-size: 24rpx;
  85 + color: #999;
60 } 86 }
61 87
62 -.goods-price {  
63 - height: 40rpx;  
64 - line-height: 40rpx;  
65 - margin-top: 10rpx;  
66 -} 88 +/* .goods-price {
  89 + height: 40rpx;
  90 + line-height: 40rpx;
  91 + margin-top: 10rpx;
  92 +} */
67 93
68 .btn-del { 94 .btn-del {
69 - position: absolute;  
70 - right: 0;  
71 - top: 8rpx;  
72 - width: 34rpx;  
73 - height: 34rpx; 95 + position: absolute;
  96 + right: 0;
  97 + top: 8rpx;
  98 + width: 34rpx;
  99 + height: 34rpx;
74 } 100 }
75 101
76 .count { 102 .count {
77 - position: absolute;  
78 - right: 0;  
79 - bottom: 5rpx;  
80 - width: 156rpx;  
81 - height: 50rpx;  
82 - border: 1px solid #ddd; 103 + display: flex;
  104 + bottom: 5rpx;
  105 + border: 2rpx solid rgb(236, 236, 236);
  106 + margin-bottom: 3rpx;
  107 +}
  108 +
  109 +.count>view, .count>input {
  110 + width: 40rpx;
  111 + height: 35rpx;
  112 + line-height: 34rpx;
  113 + text-align: center;
  114 + display: flex;
  115 + font-size: 18rpx;
  116 + justify-content: center;
  117 + min-height: 35rpx;
83 } 118 }
84 119
85 -.count>view,.count>input {  
86 - float: left;  
87 - width: 50rpx;  
88 - height: 50rpx;  
89 - line-height: 50rpx;  
90 - text-align: center; 120 +.count>.goodadd {
  121 + width: 64rpx;
  122 + font-size: 24rpx;
  123 +}
  124 +
  125 +.count>.add {
  126 + font-size: 32rpx;
91 } 127 }
92 128
93 .sub { 129 .sub {
94 - border-right: 1px solid #ddd; 130 + border-right: 2rpx solid rgb(236, 236, 236);
95 } 131 }
96 132
97 .add { 133 .add {
98 - border-left: 1px solid #ddd; 134 + border-left: 2rpx solid rgb(236, 236, 236);
99 } 135 }
100 136
101 .pay-for { 137 .pay-for {
102 - width: 100%;  
103 - height: 100rpx;  
104 - position: fixed;  
105 - left: 0;  
106 - bottom: 0;  
107 - font-size: 28rpx;  
108 - color: #666;  
109 - background-color: #f0f2f5; 138 + width: 100%;
  139 + height: 100rpx;
  140 + position: fixed;
  141 + left: 0;
  142 + bottom: 0;
  143 + font-size: 28rpx;
  144 + color: #666;
  145 + background-color: rgb(255, 255, 255);
  146 + z-index: 2;
  147 + border-top: 1rpx solid rgb(236, 236, 236);
  148 + border-bottom: 1rpx solid rgb(236, 236, 236);
110 } 149 }
111 150
112 .pay-for .pay-btn { 151 .pay-for .pay-btn {
113 - float: right;  
114 - width: 200rpx;  
115 - height: 100rpx;  
116 - line-height: 100rpx;  
117 - text-align: center;  
118 - background-color: #f23030;  
119 - color: #fff;  
120 - border-radius: 0; 152 + width: 220rpx;
  153 + height: 100rpx;
  154 + line-height: 100rpx;
  155 + background-color: rgb(219, 27, 52);
  156 + color: #fff;
  157 + border-radius: 0;
  158 + font-size: 31rpx;
121 } 159 }
122 160
123 .pay-for .consumer { 161 .pay-for .consumer {
124 - float: right;  
125 - margin-right: 20rpx;  
126 - line-height: 50rpx; 162 + margin-right: 23rpx;
  163 + color: rgb(0, 0, 0);
  164 + letter-spacing: 1rpx;
  165 +}
  166 +
  167 +.pay-for .consumer .total {
  168 + color: rgb(0, 0, 0);
  169 +}
  170 +
  171 +.pay-for .consumer .tips {
  172 + color: rgb(153, 153, 153);
127 } 173 }
128 174
129 .pay-for .checkbox { 175 .pay-for .checkbox {
130 - float: left;  
131 - padding-left: 40rpx;  
132 - line-height: 100rpx;  
133 - display: flex;  
134 - align-items: center; 176 + float: left;
  177 + padding-left: 40rpx;
  178 + line-height: 100rpx;
  179 + display: flex;
  180 + align-items: center;
135 } 181 }
136 182
137 .pay-for .ico-check { 183 .pay-for .ico-check {
138 - display: flex;  
139 - align-items: center;  
140 - margin-right: 20rpx; 184 + display: flex;
  185 + align-items: center;
  186 + margin-right: 20rpx;
  187 +}
  188 +
  189 +.shmd_m {
  190 + height: 80rpx;
  191 + line-height: 80rpx;
  192 + display: flex;
  193 +}
  194 +
  195 +.shmd_m image {
  196 + height: 50rpx;
  197 + width: 55rpx;
  198 + margin-left: -10rpx;
  199 +}
  200 +
  201 +.shmd_m .goods-ico icon {
  202 + margin-top: 26rpx;
  203 +}
  204 +
  205 +.shmd {
  206 + margin-left: 5rpx;
  207 +}
  208 +
  209 +.store {
  210 + border-top: 7rpx solid rgb(245, 245, 245);
  211 +}
  212 +
  213 +.login-in .Storenum {
  214 + height: 80rpx;
  215 + color: rgb(51, 51, 51);
  216 +}
  217 +
  218 +.login-in .goods_num {
  219 + margin-left: 13rpx;
  220 +}
  221 +
  222 +.allradio {
  223 + padding-left: 30rpx;
  224 + width: 600rpx;
  225 +}
  226 +
  227 +.allradio .all {
  228 + color: rgb(0, 0, 0);
  229 +}
  230 +
  231 +.Specifications {
  232 + padding: 3rpx 5rpx;
  233 + margin-top: 8rpx;
  234 + font-size: 20rpx;
  235 + max-width: 105rpx;
  236 + height: 30rpx;
  237 + line-height: 29rpx;
  238 + background-color: rgb(236, 236, 236);
  239 + border-radius: 8rpx;
  240 + white-space: nowrap;
  241 + overflow: hidden;
  242 + color: rgb(63, 63, 63);
  243 +}
  244 +
  245 +.abs {
  246 + top: 15rpx;
  247 + left: -39rpx;
  248 + width: 154rpx;
  249 + height: 40rpx;
  250 + background-color: rgb(16, 202, 220);
  251 + transform: rotate(320deg);
  252 + color: rgb(255, 255, 255);
  253 + line-height: 40rpx;
141 } 254 }
142 -.shmd_m{margin-left: 5rpx; height: 80rpx; line-height: 80rpx; display: flex;border-bottom: 1rpx solid #ddd}  
143 -.shmd_m .goods-ico icon{margin-top: 26rpx;}  
144 -.shmd{margin-left: 20rpx;}  
145 \ No newline at end of file 255 \ No newline at end of file