Commit b8804951f81b88d003e45c339521dae05b202f42
1 parent
32e4e09c
fix修正细节
Showing
1 changed file
with
134 additions
and
136 deletions
packageA/pages/details_serviceCard/details_serviceCard.js
| @@ -262,163 +262,161 @@ Page({ | @@ -262,163 +262,161 @@ Page({ | ||
| 262 | } else { | 262 | } else { |
| 263 | 263 | ||
| 264 | var len = details.list.length; | 264 | var len = details.list.length; |
| 265 | - | 265 | + // 底导航购物车红点显示的数量 |
| 266 | + var c_num = 0; | ||
| 267 | + // 多商品 | ||
| 266 | for (let i = 0; i < len; i++) { | 268 | for (let i = 0; i < len; i++) { |
| 267 | - | ||
| 268 | - | ||
| 269 | - | ||
| 270 | 269 | ||
| 271 | - var newd = { | ||
| 272 | - // service_id: th.data.data.id, | ||
| 273 | - // service_sn:th.data.data.service_sn, | ||
| 274 | - // service_name:th.data.data.goods_name, | ||
| 275 | - // goods_num: th.data.goodsInputNum, | ||
| 276 | - // pick_id: th.data.sto_sele_id, | ||
| 277 | - // user_id:oo.user_id, | ||
| 278 | - // store_id:os.stoid, | ||
| 279 | - // money:th.data.data.shop_price, | ||
| 280 | - | ||
| 281 | - service_id: details.list[i].card_id, | ||
| 282 | - service_sn: details.list[i].service_sn, | ||
| 283 | - service_name: details.list[i].service_name, | ||
| 284 | - goods_num: details.list[i].qty, | ||
| 285 | - pick_id: details.list[i].pickup_id, | ||
| 286 | - user_id: user_id, | ||
| 287 | - store_id: app.globalData.setting.stoid, | ||
| 288 | - money: details.list[i].price, | ||
| 289 | - }; | ||
| 290 | - if (getApp().globalData.guide_id) { | ||
| 291 | - newd['guide_id'] = getApp().globalData.guide_id; | ||
| 292 | - newd['guide_type'] = 0; | ||
| 293 | - }; | ||
| 294 | - // 秒杀:单独购买的情况下,加入购物车显示的是零售价,否则显示秒杀活动价 | ||
| 295 | - if(details.list[0].prom_type == 1) { | ||
| 296 | - newd['prom_type'] = details.list[i].prom_type; | ||
| 297 | - newd['prom_id'] = details.list[i].prom_id; | ||
| 298 | - }; | ||
| 299 | - | ||
| 300 | - var prom_id = details.list[i].prom_id > 0 ? details.list[i].prom_id : 0; | ||
| 301 | - var card_id = details.list[i].card_id; | ||
| 302 | - var prom_type = details.list[i].prom_type > 0 ? details.list[i].prom_type : 0; | ||
| 303 | - var is_pd_normal = details.list[i].is_pd_normal; | ||
| 304 | - // 库存 | ||
| 305 | - var redisNums = 0; | ||
| 306 | - // 限购数 | ||
| 307 | - var limitNum = 0; | ||
| 308 | - // 已购买数量 | ||
| 309 | - var boughtNum = 0; | ||
| 310 | - | ||
| 311 | - // 秒杀活动中购买 | ||
| 312 | - if (prom_type == 1 && !is_pd_normal) { | ||
| 313 | - | ||
| 314 | - // 获取已购数量 | ||
| 315 | - await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id="+os.stoid+"&user_id="+getApp().globalData.user_id+"&card_id="+card_id+"&prom_type="+prom_type+"&prom_id="+prom_id, { | ||
| 316 | - }).then(res => { | ||
| 317 | - boughtNum = !res.data.data.promcardbuynum ? 0 : res.data.data.promcardbuynum; | ||
| 318 | - }); | ||
| 319 | - | ||
| 320 | - // 获取库存 | ||
| 321 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => { | ||
| 322 | - if (res.data.code == 0) { | ||
| 323 | - redisNums = !res.data.data ? 0 : res.data.data; | ||
| 324 | - }; | ||
| 325 | - }); | 270 | + var newd = { |
| 271 | + // service_id: th.data.data.id, | ||
| 272 | + // service_sn:th.data.data.service_sn, | ||
| 273 | + // service_name:th.data.data.goods_name, | ||
| 274 | + // goods_num: th.data.goodsInputNum, | ||
| 275 | + // pick_id: th.data.sto_sele_id, | ||
| 276 | + // user_id:oo.user_id, | ||
| 277 | + // store_id:os.stoid, | ||
| 278 | + // money:th.data.data.shop_price, | ||
| 279 | + | ||
| 280 | + service_id: details.list[i].card_id, | ||
| 281 | + service_sn: details.list[i].service_sn, | ||
| 282 | + service_name: details.list[i].service_name, | ||
| 283 | + goods_num: details.list[i].qty, | ||
| 284 | + pick_id: details.list[i].pickup_id, | ||
| 285 | + user_id: user_id, | ||
| 286 | + store_id: app.globalData.setting.stoid, | ||
| 287 | + money: details.list[i].price, | ||
| 288 | + }; | ||
| 289 | + if (getApp().globalData.guide_id) { | ||
| 290 | + newd['guide_id'] = getApp().globalData.guide_id; | ||
| 291 | + newd['guide_type'] = 0; | ||
| 292 | + }; | ||
| 293 | + // 秒杀:单独购买的情况下,加入购物车显示的是零售价,否则显示秒杀活动价 | ||
| 294 | + if(details.list[i].prom_type == 1) { | ||
| 295 | + newd['prom_type'] = details.list[i].prom_type; | ||
| 296 | + newd['prom_id'] = details.list[i].prom_id; | ||
| 297 | + }; | ||
| 326 | 298 | ||
| 327 | - // 获取限购数 | ||
| 328 | - | ||
| 329 | - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + prom_id, {}).then(res => { | ||
| 330 | - if (res.data.code == 0) { | ||
| 331 | - limitNum = res.data.data.buy_limit; | ||
| 332 | - } | ||
| 333 | - }); | 299 | + var prom_id = details.list[i].prom_id > 0 ? details.list[i].prom_id : 0; |
| 300 | + var card_id = details.list[i].card_id; | ||
| 301 | + var prom_type = details.list[i].prom_type > 0 ? details.list[i].prom_type : 0; | ||
| 302 | + var is_pd_normal = details.list[i].is_pd_normal; | ||
| 303 | + // 库存 | ||
| 304 | + var redisNums = 0; | ||
| 305 | + // 限购数 | ||
| 306 | + var limitNum = 0; | ||
| 307 | + // 已购买数量 | ||
| 308 | + var boughtNum = 0; | ||
| 309 | + | ||
| 310 | + // 秒杀活动中购买 | ||
| 311 | + if (prom_type == 1 && !is_pd_normal) { | ||
| 312 | + | ||
| 313 | + // 获取已购数量 | ||
| 314 | + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id="+os.stoid+"&user_id="+getApp().globalData.user_id+"&card_id="+card_id+"&prom_type="+prom_type+"&prom_id="+prom_id, { | ||
| 315 | + }).then(res => { | ||
| 316 | + boughtNum = !res.data.data.promcardbuynum ? 0 : res.data.data.promcardbuynum; | ||
| 317 | + }); | ||
| 318 | + | ||
| 319 | + // 获取库存 | ||
| 320 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => { | ||
| 321 | + if (res.data.code == 0) { | ||
| 322 | + redisNums = !res.data.data ? 0 : res.data.data; | ||
| 323 | + }; | ||
| 324 | + }); | ||
| 334 | 325 | ||
| 335 | - var snum = limitNum - boughtNum; | ||
| 336 | - if (snum <= 0) { | ||
| 337 | - wx.showModal({ | ||
| 338 | - title: '超出限购数量', | 326 | + // 获取限购数 |
| 327 | + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + prom_id, {}).then(res => { | ||
| 328 | + if (res.data.code == 0) { | ||
| 329 | + limitNum = res.data.data.buy_limit; | ||
| 330 | + } | ||
| 339 | }); | 331 | }); |
| 340 | - return false; | ||
| 341 | - } | ||
| 342 | 332 | ||
| 343 | - } | 333 | + var snum = limitNum - boughtNum; |
| 334 | + if (snum <= 0) { | ||
| 335 | + wx.showModal({ | ||
| 336 | + title: '超出限购数量', | ||
| 337 | + }); | ||
| 338 | + return false; | ||
| 339 | + } | ||
| 344 | 340 | ||
| 341 | + } | ||
| 345 | 342 | ||
| 346 | - //----先看会员在购物车中是否加入了该商品----- | ||
| 347 | - app.request.get("/api/weshop/cartService/page", { | ||
| 348 | - data: { | ||
| 349 | - store_id: app.globalData.setting.stoid, | ||
| 350 | - user_id: user_id, | ||
| 351 | - service_id: details.list[0].card_id, | ||
| 352 | - pick_id: details.list[0].pickup_id, | ||
| 353 | - }, | ||
| 354 | - success: function(re) { | ||
| 355 | - //-------如果购物车中有相关的数据--------- | ||
| 356 | - if (re.data.data.total > 0) { | ||
| 357 | - var item = re.data.data.pageData[0]; | ||
| 358 | - var totalNum = details.list[i].qty + item.goods_num; | ||
| 359 | - | ||
| 360 | - if (prom_type == 1 && !is_pd_normal) { | ||
| 361 | - // 秒杀购物车购买 修正数量 | ||
| 362 | - var snum = limitNum - boughtNum; | ||
| 363 | 343 | ||
| 364 | - if (totalNum >= redisNums){ | ||
| 365 | - if (redisNums > snum) { | ||
| 366 | - totalNum = snum; | ||
| 367 | - } else { | ||
| 368 | - totalNum = redisNums; | ||
| 369 | - } | ||
| 370 | - } else { | ||
| 371 | - if (totalNum > snum) | ||
| 372 | - totalNum = snum; | 344 | + //----先看会员在购物车中是否加入了该商品----- |
| 345 | + app.request.get("/api/weshop/cartService/page", { | ||
| 346 | + data: { | ||
| 347 | + store_id: app.globalData.setting.stoid, | ||
| 348 | + user_id: user_id, | ||
| 349 | + service_id: details.list[i].card_id, | ||
| 350 | + pick_id: details.list[i].pickup_id, | ||
| 351 | + }, | ||
| 352 | + success: function(re) { | ||
| 353 | + //-------如果购物车中有相关的数据--------- | ||
| 354 | + if (re.data.data.total > 0) { | ||
| 355 | + var item = re.data.data.pageData[0]; | ||
| 356 | + var totalNum = details.list[i].qty + item.goods_num; | ||
| 357 | + | ||
| 358 | + if (prom_type == 1 && !is_pd_normal) { | ||
| 359 | + // 秒杀购物车购买 修正数量 剩余购买数量 | ||
| 360 | + var snum = limitNum - boughtNum; | ||
| 361 | + | ||
| 362 | + if (totalNum >= redisNums){ | ||
| 363 | + if (redisNums > snum) { | ||
| 364 | + totalNum = snum; | ||
| 365 | + } else { | ||
| 366 | + totalNum = redisNums; | ||
| 367 | + } | ||
| 368 | + } else { | ||
| 369 | + if (totalNum > snum) | ||
| 370 | + totalNum = snum; | ||
| 371 | + } | ||
| 373 | } | 372 | } |
| 374 | - } | ||
| 375 | 373 | ||
| 376 | - var updata = { | ||
| 377 | - id: item.id, | ||
| 378 | - goods_num: totalNum, | ||
| 379 | - money: details.list[i].price, | ||
| 380 | - store_id: app.globalData.setting.stoid, | ||
| 381 | - }; | 374 | + var updata = { |
| 375 | + id: item.id, | ||
| 376 | + goods_num: totalNum, | ||
| 377 | + money: details.list[i].price, | ||
| 378 | + store_id: app.globalData.setting.stoid, | ||
| 379 | + }; | ||
| 382 | 380 | ||
| 383 | - if (getApp().globalData.guide_id) { | ||
| 384 | - updata['guide_id'] = getApp().globalData.guide_id; | ||
| 385 | - updata['guide_type'] = 1; | ||
| 386 | - } | 381 | + if (getApp().globalData.guide_id) { |
| 382 | + updata['guide_id'] = getApp().globalData.guide_id; | ||
| 383 | + updata['guide_type'] = 1; | ||
| 384 | + } | ||
| 387 | 385 | ||
| 388 | - getApp().request.put("/api/weshop/cartService/update", { | ||
| 389 | - data: updata, | ||
| 390 | - success: function(t) { | ||
| 391 | - // getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 392 | - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | ||
| 393 | - th.setData({ | ||
| 394 | - cartGoodsNum: c_num | 386 | + getApp().request.put("/api/weshop/cartService/update", { |
| 387 | + data: updata, | ||
| 388 | + success: function(t) { | ||
| 389 | + // getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 390 | + c_num += th.data.cartGoodsNum + th.data.goodsInputNum; | ||
| 391 | + th.setData({ | ||
| 392 | + cartGoodsNum: c_num | ||
| 393 | + }); | ||
| 394 | + | ||
| 395 | + // th.closeSpecModal(); | ||
| 396 | + } | ||
| 395 | }); | 397 | }); |
| 396 | - app.goto('/pages/cart/cart/cart'); | ||
| 397 | - // th.closeSpecModal(); | ||
| 398 | - } | ||
| 399 | - }); | ||
| 400 | 398 | ||
| 401 | 399 | ||
| 402 | - } else { | 400 | + } else { |
| 403 | 401 | ||
| 404 | - getApp().request.post("/api/weshop/cartService/save", { | ||
| 405 | - data: newd, | ||
| 406 | - success: function(t) { | ||
| 407 | - // getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 408 | - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | ||
| 409 | - th.setData({ | ||
| 410 | - cartGoodsNum: c_num | 402 | + getApp().request.post("/api/weshop/cartService/save", { |
| 403 | + data: newd, | ||
| 404 | + success: function(t) { | ||
| 405 | + // getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 406 | + c_num += th.data.cartGoodsNum + th.data.goodsInputNum; | ||
| 407 | + th.setData({ | ||
| 408 | + cartGoodsNum: c_num | ||
| 409 | + }); | ||
| 410 | + | ||
| 411 | + // th.closeSpecModal(); | ||
| 412 | + } | ||
| 411 | }); | 413 | }); |
| 412 | - app.goto('/pages/cart/cart/cart'); | ||
| 413 | - // th.closeSpecModal(); | ||
| 414 | } | 414 | } |
| 415 | - }); | ||
| 416 | - } | ||
| 417 | - } | ||
| 418 | - }); | 415 | + } |
| 416 | + }); | ||
| 419 | 417 | ||
| 420 | } | 418 | } |
| 421 | - | 419 | + app.goto('/pages/cart/cart/cart'); |
| 422 | 420 | ||
| 423 | } | 421 | } |
| 424 | }, | 422 | }, |