...
|
...
|
@@ -5,9 +5,8 @@ |
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const api = global.yoho.API;
|
|
|
const _ = require('lodash');
|
|
|
const cartProcess = require(global.utils + '/cart-process');
|
|
|
|
|
|
const indexData = (uid, shoppingKey, saleChannel, cartType) => {
|
|
|
return api.get('', {
|
...
|
...
|
@@ -16,185 +15,1030 @@ const indexData = (uid, shoppingKey, saleChannel, cartType) => { |
|
|
shopping_key: shoppingKey,
|
|
|
sale_channel: saleChannel
|
|
|
}).then((data) => {
|
|
|
let cart = data.data;
|
|
|
let result = {};
|
|
|
let ordinaryCount = _.get(cart, 'ordinary_cart_data.shopping_cart_data.goods_count', 0);
|
|
|
let advanceCount = _.get(cart, 'advance_cart_data.shopping_cart_data.goods_count', 0);
|
|
|
let ordinarySoldOut = _.get(cart, 'ordinary_cart_data.sold_out_goods_list', []);
|
|
|
let advanceSoldOut = _.get(cart, 'advance_cart_data.sold_out_goods_list', []);
|
|
|
|
|
|
// 普通购物车和预售购物车都为空
|
|
|
if (ordinaryCount === 0 && advanceCount === 0 && !ordinarySoldOut.length && !advanceSoldOut.length) {
|
|
|
result.isEmptyCart = true;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
// 普通购物车空,则显示预售购物车
|
|
|
if (ordinaryCount === 0 && !ordinarySoldOut.length) {
|
|
|
result.cartNav = false;
|
|
|
result.cartType = 'advance';
|
|
|
} // 预售购物车空,则显示普通购物车
|
|
|
else if (advanceCount === 0 && !advanceSoldOut.length) {
|
|
|
result.cartNav = false;
|
|
|
result.cartType = 'ordinary';
|
|
|
} // 以上两个购物车中都有数据, 默认显示普通购物车
|
|
|
else {
|
|
|
result.cartNav = true;
|
|
|
result.cartType = cartType || 'ordinary';
|
|
|
}
|
|
|
|
|
|
/* 普通购物车 */
|
|
|
result.commonGoodsCount = ordinaryCount;
|
|
|
result.commonCart = processData(cart.ordinary_cart_data, false);
|
|
|
/* 预售购物车 */
|
|
|
result.presellGoodsCount = advanceCount;
|
|
|
result.preSellCart = processData(cart.advance_cart_data);
|
|
|
console.log(result)
|
|
|
return result;
|
|
|
// return new Promise((resolve, reject) => {
|
|
|
// resolve(cartProcess.processData({
|
|
|
// "alg": "SALT_MD5",
|
|
|
// "code": 200,
|
|
|
// "data": {
|
|
|
// "advance_cart_data": {
|
|
|
// "gift_list": [],
|
|
|
// "goods_list": [],
|
|
|
// "goods_pool_list": [],
|
|
|
// "off_shelves_goods_list": [],
|
|
|
// "price_gift": [],
|
|
|
// "promotion_info": [],
|
|
|
// "shopping_cart_data": {
|
|
|
// "discount_amount": 0,
|
|
|
// "fast_shopping_cost": 15,
|
|
|
// "gain_yoho_coin": 0,
|
|
|
// "goods_count": 0,
|
|
|
// "has_invalid_goods": 0,
|
|
|
// "is_multi_package": "N",
|
|
|
// "last_order_amount": 0,
|
|
|
// "offline_goods_count": 0,
|
|
|
// "online_goods_count": 0,
|
|
|
// "order_amount": 0,
|
|
|
// "package_list": [],
|
|
|
// "promotion_formula": "总计¥0.00=商品金额¥0.00",
|
|
|
// "promotion_formula_list": [
|
|
|
// {
|
|
|
// "promotion": "商品金额",
|
|
|
// "promotion_amount": "¥0.00"
|
|
|
// }
|
|
|
// ],
|
|
|
// "remain_time": 0,
|
|
|
// "selected_goods_count": 0,
|
|
|
// "shipping_cost": 10,
|
|
|
// "str_discount_amount": "¥0.00",
|
|
|
// "str_order_amount": "¥0.00"
|
|
|
// },
|
|
|
// "sold_out_goods_list": []
|
|
|
// },
|
|
|
// "ordinary_cart_data": {
|
|
|
// "gift_list": [],
|
|
|
// "goods_list": [],
|
|
|
// "goods_pool_list": [
|
|
|
// {
|
|
|
// "goods_list": [
|
|
|
// {
|
|
|
// "attribute": "1",
|
|
|
// "brand_domain": "I LOVE CHOC",
|
|
|
// "brand_id": "524",
|
|
|
// "brand_name": "ilovechoc",
|
|
|
// "buy_limit": 0,
|
|
|
// "buy_number": "1",
|
|
|
// "buy_type": 2,
|
|
|
// "can_cod_pay": "Y",
|
|
|
// "cn_alphabet": "ILOVECHOC505432039TongZhuangXingXingPinJieLianMaoBangQiuShan",
|
|
|
// "color_id": "7",
|
|
|
// "color_name": "蓝色",
|
|
|
// "delay_notice": "",
|
|
|
// "discount_tag": "",
|
|
|
// "expect_arrival_time": "",
|
|
|
// "factory_goods_name": "蓝色",
|
|
|
// "fit_promotions": [],
|
|
|
// "get_yoho_coin": "0",
|
|
|
// "goods_id": "367065",
|
|
|
// "goods_images": "http://img10.static.yhbimg.com/goodsimg/2015/11/25/06/01d06aa4c18f6714a04573afeac2ae71d2.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80",
|
|
|
// "goods_type": "ordinary",
|
|
|
// "is_advance": "N",
|
|
|
// "is_deposit_advance": "N",
|
|
|
// "is_jit": "N",
|
|
|
// "is_limited": "N",
|
|
|
// "is_outlets": "N",
|
|
|
// "is_special": "N",
|
|
|
// "last_price": "280.0",
|
|
|
// "last_vip_price": 280,
|
|
|
// "local_buy_number": 0,
|
|
|
// "market_price": 281,
|
|
|
// "max_sort_id": "365",
|
|
|
// "middle_sort_id": "404",
|
|
|
// "min_buy_number": 1,
|
|
|
// "off_shelves": 0,
|
|
|
// "offline_goods_status": 1,
|
|
|
// "offline_storage_number": 0,
|
|
|
// "offline_storage_status": 1,
|
|
|
// "online_storage_number": 0,
|
|
|
// "product_id": 285265,
|
|
|
// "product_name": "I LOVE CHOC 童装星星拼接连帽棒球衫",
|
|
|
// "product_skc": "288132",
|
|
|
// "product_skn": "51160552",
|
|
|
// "product_sku": "912752",
|
|
|
// "promotion_flag": "101",
|
|
|
// "promotion_id": "0",
|
|
|
// "real_price": 280,
|
|
|
// "real_vip_price": 0,
|
|
|
// "sale_price": 0,
|
|
|
// "sales_price": 280,
|
|
|
// "selected": "Y",
|
|
|
// "shop_id": 0,
|
|
|
// "shopping_cart_goods_id": "60454",
|
|
|
// "shopping_cart_id": "118792348",
|
|
|
// "shopping_key": "2a7729e3e974cfe476e4472a89c13743",
|
|
|
// "size_id": "203",
|
|
|
// "size_name": "M",
|
|
|
// "small_sort_id": "405",
|
|
|
// "storage_number": "1",
|
|
|
// "store_id": 0,
|
|
|
// "str_subtotal": "¥280.00",
|
|
|
// "subtotal": 280,
|
|
|
// "supplier_id": 0,
|
|
|
// "tags": [],
|
|
|
// "uid": "8040155",
|
|
|
// "vip1_price": "0.00",
|
|
|
// "vip2_price": "0.00",
|
|
|
// "vip3_price": "0.00",
|
|
|
// "vip_discount": 1,
|
|
|
// "vip_discount_money": 0,
|
|
|
// "vip_discount_type": "3",
|
|
|
// "vip_price": 0,
|
|
|
// "wareHouseId": 0,
|
|
|
// "yoho_coin_num": "0"
|
|
|
// }
|
|
|
// ],
|
|
|
// "pool_title": "ilovechoc",
|
|
|
// "pool_type": 1
|
|
|
// },
|
|
|
// {
|
|
|
// "pool_type": 0,
|
|
|
// "promotion_list": [
|
|
|
// {
|
|
|
// "alreadyMatch": true,
|
|
|
// "condition_unit": 0,
|
|
|
// "condition_value": 0,
|
|
|
// "gift_goods_List": [],
|
|
|
// "gift_price": 0,
|
|
|
// "promotion_id": 9148,
|
|
|
// "promotion_title": "全场促销",
|
|
|
// "promotion_type": "Discount",
|
|
|
// "status": 10
|
|
|
// }
|
|
|
// ],
|
|
|
// "sub_pool": [
|
|
|
// {
|
|
|
// "goods_list": [
|
|
|
// {
|
|
|
// "attribute": "1",
|
|
|
// "brand_domain": "oasso",
|
|
|
// "brand_id": "210",
|
|
|
// "brand_name": "oasso",
|
|
|
// "buy_limit": 0,
|
|
|
// "buy_number": "2",
|
|
|
// "buy_type": 2,
|
|
|
// "can_cod_pay": "Y",
|
|
|
// "cn_alphabet": "OASSOShouJiChongDianZuo",
|
|
|
// "color_id": "6",
|
|
|
// "color_name": "绿色",
|
|
|
// "delay_notice": "",
|
|
|
// "discount_tag": "S",
|
|
|
// "expect_arrival_time": "",
|
|
|
// "factory_goods_name": "绿色",
|
|
|
// "fit_promotions": [
|
|
|
// "9148"
|
|
|
// ],
|
|
|
// "get_yoho_coin": "0",
|
|
|
// "goods_id": "254893",
|
|
|
// "goods_images": "http://img13.static.yhbimg.com/goodsimg/2016/01/12/05/02d78f2aec2e0206f34e6bed05e463c73d.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80",
|
|
|
// "goods_type": "ordinary",
|
|
|
// "is_advance": "N",
|
|
|
// "is_deposit_advance": "N",
|
|
|
// "is_jit": "N",
|
|
|
// "is_limited": "Y",
|
|
|
// "is_outlets": "N",
|
|
|
// "is_special": "N",
|
|
|
// "last_price": "7.92",
|
|
|
// "last_vip_price": 9.9,
|
|
|
// "local_buy_number": 0,
|
|
|
// "market_price": 12,
|
|
|
// "max_sort_id": "10",
|
|
|
// "middle_sort_id": "103",
|
|
|
// "min_buy_number": 1,
|
|
|
// "off_shelves": 0,
|
|
|
// "offline_goods_status": 1,
|
|
|
// "offline_storage_number": 0,
|
|
|
// "offline_storage_status": 1,
|
|
|
// "online_storage_number": 0,
|
|
|
// "product_id": 189413,
|
|
|
// "product_name": "oasso 手机充电座",
|
|
|
// "product_skc": "228608",
|
|
|
// "product_skn": "51109379",
|
|
|
// "product_sku": "746705",
|
|
|
// "promotion_flag": "110",
|
|
|
// "promotion_id": "0",
|
|
|
// "real_price": 7.92,
|
|
|
// "real_vip_price": 9.9,
|
|
|
// "sale_price": 0,
|
|
|
// "sales_price": 11,
|
|
|
// "selected": "Y",
|
|
|
// "shop_id": 0,
|
|
|
// "shopping_cart_goods_id": "60434",
|
|
|
// "shopping_cart_id": "118792348",
|
|
|
// "shopping_key": "2a7729e3e974cfe476e4472a89c13743",
|
|
|
// "size_id": "199",
|
|
|
// "size_name": "F",
|
|
|
// "small_sort_id": "212",
|
|
|
// "storage_number": "12331",
|
|
|
// "store_id": 0,
|
|
|
// "str_subtotal": "¥19.80",
|
|
|
// "subtotal": 19.8,
|
|
|
// "supplier_id": 0,
|
|
|
// "tags": [],
|
|
|
// "uid": "8040155",
|
|
|
// "vip1_price": "10.45",
|
|
|
// "vip2_price": "9.90",
|
|
|
// "vip3_price": "9.68",
|
|
|
// "vip_discount": 0.9,
|
|
|
// "vip_discount_money": 1.1,
|
|
|
// "vip_discount_type": "1",
|
|
|
// "vip_price": 11,
|
|
|
// "wareHouseId": 0,
|
|
|
// "yoho_coin_num": "0"
|
|
|
// }
|
|
|
// ],
|
|
|
// "pool_type": 1
|
|
|
// }
|
|
|
// ]
|
|
|
// },
|
|
|
// {
|
|
|
// "goods_list": [
|
|
|
// {
|
|
|
// "attribute": "1",
|
|
|
// "brand_domain": "EBLIS",
|
|
|
// "brand_id": "37",
|
|
|
// "brand_name": "eblishungi",
|
|
|
// "buy_limit": 0,
|
|
|
// "buy_number": "1",
|
|
|
// "buy_type": 2,
|
|
|
// "can_cod_pay": "Y",
|
|
|
// "cn_alphabet": "EBLISChenShanS223",
|
|
|
// "color_id": "7",
|
|
|
// "color_name": "蓝色",
|
|
|
// "delay_notice": "",
|
|
|
// "discount_tag": "S",
|
|
|
// "expect_arrival_time": "1月",
|
|
|
// "factory_goods_name": "测试数据,测试厂家颜色,蓝色,testtest,测试测试测试测试。。。。测试",
|
|
|
// "fit_promotions": [],
|
|
|
// "get_yoho_coin": "0",
|
|
|
// "goods_id": "443029",
|
|
|
// "goods_images": "http://img11.static.yhbimg.com/goodsimg/2016/01/12/02/01e1c78084e7ed6739b21a8bccbbf32f1b.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80",
|
|
|
// "goods_type": "ordinary",
|
|
|
// "is_advance": "N",
|
|
|
// "is_deposit_advance": "N",
|
|
|
// "is_jit": "N",
|
|
|
// "is_limited": "N",
|
|
|
// "is_outlets": "N",
|
|
|
// "is_special": "N",
|
|
|
// "last_price": "9.9",
|
|
|
// "last_vip_price": 9.9,
|
|
|
// "local_buy_number": 0,
|
|
|
// "market_price": 598,
|
|
|
// "max_sort_id": "1",
|
|
|
// "middle_sort_id": "12",
|
|
|
// "min_buy_number": 1,
|
|
|
// "off_shelves": 0,
|
|
|
// "offline_goods_status": 1,
|
|
|
// "offline_storage_number": 0,
|
|
|
// "offline_storage_status": 1,
|
|
|
// "online_storage_number": 0,
|
|
|
// "product_id": 345753,
|
|
|
// "product_name": "EBLIS 男款格子衬衫",
|
|
|
// "product_skc": "329633",
|
|
|
// "product_skn": "51192557",
|
|
|
// "product_sku": "1029828",
|
|
|
// "promotion_flag": "0",
|
|
|
// "promotion_id": "0",
|
|
|
// "real_price": 9.9,
|
|
|
// "real_vip_price": 9.9,
|
|
|
// "sale_price": 0,
|
|
|
// "sales_price": 11,
|
|
|
// "selected": "Y",
|
|
|
// "shop_id": 0,
|
|
|
// "shopping_cart_goods_id": "60430",
|
|
|
// "shopping_cart_id": "118792348",
|
|
|
// "shopping_key": "2a7729e3e974cfe476e4472a89c13743",
|
|
|
// "size_id": "207",
|
|
|
// "size_name": "S",
|
|
|
// "small_sort_id": "115",
|
|
|
// "storage_number": "499",
|
|
|
// "store_id": 0,
|
|
|
// "str_subtotal": "¥9.90",
|
|
|
// "subtotal": 9.9,
|
|
|
// "supplier_id": 0,
|
|
|
// "tags": [],
|
|
|
// "uid": "8040155",
|
|
|
// "vip1_price": "10.45",
|
|
|
// "vip2_price": "9.90",
|
|
|
// "vip3_price": "9.68",
|
|
|
// "vip_discount": 0.9,
|
|
|
// "vip_discount_money": 1.1,
|
|
|
// "vip_discount_type": "1",
|
|
|
// "vip_price": 11,
|
|
|
// "wareHouseId": 0,
|
|
|
// "yoho_coin_num": "0"
|
|
|
// }
|
|
|
// ],
|
|
|
// "pool_title": "eblishungi",
|
|
|
// "pool_type": 1
|
|
|
// },
|
|
|
// {
|
|
|
// "pool_type": 0,
|
|
|
// "promotion_list": [
|
|
|
// {
|
|
|
// "alreadyMatch": true,
|
|
|
// "condition_unit": 0,
|
|
|
// "condition_value": 0,
|
|
|
// "gift_goods_List": [],
|
|
|
// "gift_price": 0,
|
|
|
// "promotion_id": 9088,
|
|
|
// "promotion_title": "线下店满3免一勿动",
|
|
|
// "promotion_type": "Cheapestfree",
|
|
|
// "status": 10
|
|
|
// }
|
|
|
// ],
|
|
|
// "sub_pool": [
|
|
|
// {
|
|
|
// "goods_list": [
|
|
|
// {
|
|
|
// "attribute": "1",
|
|
|
// "brand_domain": "BLACKJACK",
|
|
|
// "brand_id": "256",
|
|
|
// "brand_name": "blackjack",
|
|
|
// "buy_limit": 0,
|
|
|
// "buy_number": "3",
|
|
|
// "buy_type": 2,
|
|
|
// "can_cod_pay": "Y",
|
|
|
// "cn_alphabet": "PANDAMADEHOTRODP12062",
|
|
|
// "color_id": "1",
|
|
|
// "color_name": "白",
|
|
|
// "delay_notice": "",
|
|
|
// "discount_tag": "S",
|
|
|
// "expect_arrival_time": "",
|
|
|
// "factory_goods_name": "白",
|
|
|
// "fit_promotions": [
|
|
|
// "9088"
|
|
|
// ],
|
|
|
// "get_yoho_coin": "0",
|
|
|
// "goods_id": "28492",
|
|
|
// "goods_images": "http://img10.static.yhbimg.com/goodsimg/2016/09/26/19/01a0040ac739eda88815760dc95017c406.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80",
|
|
|
// "goods_type": "ordinary",
|
|
|
// "is_advance": "N",
|
|
|
// "is_deposit_advance": "N",
|
|
|
// "is_jit": "N",
|
|
|
// "is_limited": "N",
|
|
|
// "is_outlets": "N",
|
|
|
// "is_special": "N",
|
|
|
// "last_price": "0.6",
|
|
|
// "last_vip_price": 0.9,
|
|
|
// "local_buy_number": 0,
|
|
|
// "market_price": 289,
|
|
|
// "max_sort_id": "1",
|
|
|
// "middle_sort_id": "11",
|
|
|
// "min_buy_number": 1,
|
|
|
// "off_shelves": 0,
|
|
|
// "offline_goods_status": 1,
|
|
|
// "offline_storage_number": 0,
|
|
|
// "offline_storage_status": 1,
|
|
|
// "online_storage_number": 0,
|
|
|
// "product_id": 19858,
|
|
|
// "product_name": "BLACKJACK民族风骷髅拉花毛衣",
|
|
|
// "product_skc": "28492",
|
|
|
// "product_skn": "50023801",
|
|
|
// "product_sku": "164165",
|
|
|
// "promotion_flag": "108",
|
|
|
// "promotion_id": "0",
|
|
|
// "real_price": 0.6,
|
|
|
// "real_vip_price": 0.9,
|
|
|
// "sale_price": 0,
|
|
|
// "sales_price": 1,
|
|
|
// "selected": "Y",
|
|
|
// "shop_id": 0,
|
|
|
// "shopping_cart_goods_id": "60428",
|
|
|
// "shopping_cart_id": "118792348",
|
|
|
// "shopping_key": "2a7729e3e974cfe476e4472a89c13743",
|
|
|
// "size_id": "201",
|
|
|
// "size_name": "L",
|
|
|
// "small_sort_id": "114",
|
|
|
// "storage_number": "100",
|
|
|
// "store_id": 0,
|
|
|
// "str_subtotal": "¥2.70",
|
|
|
// "subtotal": 2.7,
|
|
|
// "supplier_id": 0,
|
|
|
// "tags": [],
|
|
|
// "uid": "8040155",
|
|
|
// "vip1_price": "0.95",
|
|
|
// "vip2_price": "0.90",
|
|
|
// "vip3_price": "0.88",
|
|
|
// "vip_discount": 0.9,
|
|
|
// "vip_discount_money": 0.1,
|
|
|
// "vip_discount_type": "1",
|
|
|
// "vip_price": 11,
|
|
|
// "wareHouseId": 0,
|
|
|
// "yoho_coin_num": "0"
|
|
|
// }
|
|
|
// ],
|
|
|
// "pool_type": 1
|
|
|
// }
|
|
|
// ]
|
|
|
// },
|
|
|
// {
|
|
|
// "goods_list": [
|
|
|
// {
|
|
|
// "attribute": "1",
|
|
|
// "brand_domain": "VANS",
|
|
|
// "brand_id": "144",
|
|
|
// "brand_name": "vans",
|
|
|
// "buy_limit": 0,
|
|
|
// "buy_number": "1",
|
|
|
// "buy_type": 2,
|
|
|
// "can_cod_pay": "Y",
|
|
|
// "cn_alphabet": "VANSGGIRLFRIENDSKIRTVN01Z1BLK",
|
|
|
// "color_id": "2",
|
|
|
// "color_name": "黑色",
|
|
|
// "delay_notice": "",
|
|
|
// "discount_tag": "S",
|
|
|
// "expect_arrival_time": "",
|
|
|
// "factory_goods_name": "黑色",
|
|
|
// "fit_promotions": [],
|
|
|
// "get_yoho_coin": "0",
|
|
|
// "goods_id": "257295",
|
|
|
// "goods_images": "http://img11.static.yhbimg.com/goodsimg/2015/05/22/08/01bdaaa0753892690e06ff7ef9bfd39b2b.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80",
|
|
|
// "goods_type": "ordinary",
|
|
|
// "is_advance": "N",
|
|
|
// "is_deposit_advance": "N",
|
|
|
// "is_jit": "N",
|
|
|
// "is_limited": "N",
|
|
|
// "is_outlets": "N",
|
|
|
// "is_special": "N",
|
|
|
// "last_price": "9.9",
|
|
|
// "last_vip_price": 9.9,
|
|
|
// "local_buy_number": 0,
|
|
|
// "market_price": 260,
|
|
|
// "max_sort_id": "4",
|
|
|
// "middle_sort_id": "32",
|
|
|
// "min_buy_number": 1,
|
|
|
// "off_shelves": 0,
|
|
|
// "offline_goods_status": 1,
|
|
|
// "offline_storage_number": 0,
|
|
|
// "offline_storage_status": 1,
|
|
|
// "online_storage_number": 0,
|
|
|
// "product_id": 191193,
|
|
|
// "product_name": "VANS G GIRLFRIEND SKIRT",
|
|
|
// "product_skc": "230040",
|
|
|
// "product_skn": "51110511",
|
|
|
// "product_sku": "751215",
|
|
|
// "promotion_flag": "101",
|
|
|
// "promotion_id": "0",
|
|
|
// "real_price": 9.9,
|
|
|
// "real_vip_price": 9.9,
|
|
|
// "sale_price": 0,
|
|
|
// "sales_price": 11,
|
|
|
// "selected": "Y",
|
|
|
// "shop_id": 0,
|
|
|
// "shopping_cart_goods_id": "60424",
|
|
|
// "shopping_cart_id": "118792348",
|
|
|
// "shopping_key": "2a7729e3e974cfe476e4472a89c13743",
|
|
|
// "size_id": "201",
|
|
|
// "size_name": "L",
|
|
|
// "small_sort_id": "135",
|
|
|
// "storage_number": "11999",
|
|
|
// "store_id": 0,
|
|
|
// "str_subtotal": "¥9.90",
|
|
|
// "subtotal": 9.9,
|
|
|
// "supplier_id": 0,
|
|
|
// "tags": [],
|
|
|
// "uid": "8040155",
|
|
|
// "vip1_price": "10.45",
|
|
|
// "vip2_price": "9.90",
|
|
|
// "vip3_price": "9.68",
|
|
|
// "vip_discount": 0.9,
|
|
|
// "vip_discount_money": 1.1,
|
|
|
// "vip_discount_type": "1",
|
|
|
// "vip_price": 11,
|
|
|
// "wareHouseId": 0,
|
|
|
// "yoho_coin_num": "0"
|
|
|
// }
|
|
|
// ],
|
|
|
// "pool_title": "vans",
|
|
|
// "pool_type": 1
|
|
|
// },
|
|
|
// {
|
|
|
// "pool_type": 0,
|
|
|
// "promotion_list": [
|
|
|
// {
|
|
|
// "alreadyMatch": true,
|
|
|
// "condition_unit": 0,
|
|
|
// "condition_value": 0,
|
|
|
// "gift_goods_List": [],
|
|
|
// "gift_price": 0,
|
|
|
// "promotion_id": 9086,
|
|
|
// "promotion_title": "线下店分件折扣勿动",
|
|
|
// "promotion_type": "Degressdiscount",
|
|
|
// "status": 10
|
|
|
// }
|
|
|
// ],
|
|
|
// "sub_pool": [
|
|
|
// {
|
|
|
// "goods_list": [
|
|
|
// {
|
|
|
// "attribute": "1",
|
|
|
// "brand_domain": "ZERONE",
|
|
|
// "brand_id": "199",
|
|
|
// "brand_name": "zerone",
|
|
|
// "buy_limit": 0,
|
|
|
// "buy_number": "1",
|
|
|
// "buy_type": 2,
|
|
|
// "can_cod_pay": "Y",
|
|
|
// "cn_alphabet": "ZERONEDZ100105DZ100107UPC853A",
|
|
|
// "color_id": "2",
|
|
|
// "color_name": "黑",
|
|
|
// "delay_notice": "",
|
|
|
// "discount_tag": "S",
|
|
|
// "expect_arrival_time": "",
|
|
|
// "factory_goods_name": "黑",
|
|
|
// "fit_promotions": [
|
|
|
// "9086"
|
|
|
// ],
|
|
|
// "get_yoho_coin": "0",
|
|
|
// "goods_id": "20056",
|
|
|
// "goods_images": "http://img12.static.yhbimg.com/goodsimg/2012/02/29/11/02f5a2573d16e353b3c36a6404a9aabd7c.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80",
|
|
|
// "goods_type": "ordinary",
|
|
|
// "is_advance": "N",
|
|
|
// "is_deposit_advance": "N",
|
|
|
// "is_jit": "N",
|
|
|
// "is_limited": "N",
|
|
|
// "is_outlets": "N",
|
|
|
// "is_special": "N",
|
|
|
// "last_price": "195.93",
|
|
|
// "last_vip_price": 279.9,
|
|
|
// "local_buy_number": 0,
|
|
|
// "market_price": 629,
|
|
|
// "max_sort_id": "8",
|
|
|
// "middle_sort_id": "59",
|
|
|
// "min_buy_number": 1,
|
|
|
// "off_shelves": 0,
|
|
|
// "offline_goods_status": 1,
|
|
|
// "offline_storage_number": 0,
|
|
|
// "offline_storage_status": 1,
|
|
|
// "online_storage_number": 0,
|
|
|
// "product_id": 14293,
|
|
|
// "product_name": "ZERONE Lolita系列蕾丝手表",
|
|
|
// "product_skc": "20056",
|
|
|
// "product_skn": "50018093",
|
|
|
// "product_sku": "141155",
|
|
|
// "promotion_flag": "108",
|
|
|
// "promotion_id": "0",
|
|
|
// "real_price": 195.93,
|
|
|
// "real_vip_price": 279.9,
|
|
|
// "sale_price": 0,
|
|
|
// "sales_price": 311,
|
|
|
// "selected": "Y",
|
|
|
// "shop_id": 0,
|
|
|
// "shopping_cart_goods_id": "60422",
|
|
|
// "shopping_cart_id": "118792348",
|
|
|
// "shopping_key": "2a7729e3e974cfe476e4472a89c13743",
|
|
|
// "size_id": "199",
|
|
|
// "size_name": "F",
|
|
|
// "small_sort_id": "162",
|
|
|
// "storage_number": "100",
|
|
|
// "store_id": 0,
|
|
|
// "str_subtotal": "¥279.90",
|
|
|
// "subtotal": 279.9,
|
|
|
// "supplier_id": 0,
|
|
|
// "tags": [],
|
|
|
// "uid": "8040155",
|
|
|
// "vip1_price": "295.45",
|
|
|
// "vip2_price": "279.90",
|
|
|
// "vip3_price": "273.68",
|
|
|
// "vip_discount": 0.9,
|
|
|
// "vip_discount_money": 31.1,
|
|
|
// "vip_discount_type": "1",
|
|
|
// "vip_price": 11,
|
|
|
// "wareHouseId": 0,
|
|
|
// "yoho_coin_num": "0"
|
|
|
// },
|
|
|
// {
|
|
|
// "attribute": "1",
|
|
|
// "brand_domain": "ZERONE",
|
|
|
// "brand_id": "199",
|
|
|
// "brand_name": "zerone",
|
|
|
// "buy_limit": 0,
|
|
|
// "buy_number": "1",
|
|
|
// "buy_type": 2,
|
|
|
// "can_cod_pay": "Y",
|
|
|
// "cn_alphabet": "ZERONEDZ100105DZ100107UPC853A",
|
|
|
// "color_id": "2",
|
|
|
// "color_name": "黑",
|
|
|
// "delay_notice": "",
|
|
|
// "discount_tag": "S",
|
|
|
// "expect_arrival_time": "",
|
|
|
// "factory_goods_name": "黑",
|
|
|
// "fit_promotions": [
|
|
|
// "9086"
|
|
|
// ],
|
|
|
// "get_yoho_coin": "0",
|
|
|
// "goods_id": "20056",
|
|
|
// "goods_images": "http://img12.static.yhbimg.com/goodsimg/2012/02/29/11/02f5a2573d16e353b3c36a6404a9aabd7c.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80",
|
|
|
// "goods_type": "ordinary",
|
|
|
// "is_advance": "N",
|
|
|
// "is_deposit_advance": "N",
|
|
|
// "is_jit": "N",
|
|
|
// "is_limited": "N",
|
|
|
// "is_outlets": "N",
|
|
|
// "is_special": "N",
|
|
|
// "last_price": "195.93",
|
|
|
// "last_vip_price": 279.9,
|
|
|
// "local_buy_number": 0,
|
|
|
// "market_price": 629,
|
|
|
// "max_sort_id": "8",
|
|
|
// "middle_sort_id": "59",
|
|
|
// "min_buy_number": 1,
|
|
|
// "off_shelves": 0,
|
|
|
// "offline_goods_status": 1,
|
|
|
// "offline_storage_number": 0,
|
|
|
// "offline_storage_status": 1,
|
|
|
// "online_storage_number": 0,
|
|
|
// "product_id": 14293,
|
|
|
// "product_name": "ZERONE Lolita系列蕾丝手表",
|
|
|
// "product_skc": "20056",
|
|
|
// "product_skn": "50018093",
|
|
|
// "product_sku": "141155",
|
|
|
// "promotion_flag": "108",
|
|
|
// "promotion_id": "0",
|
|
|
// "real_price": 195.93,
|
|
|
// "real_vip_price": 279.9,
|
|
|
// "sale_price": 0,
|
|
|
// "sales_price": 311,
|
|
|
// "selected": "Y",
|
|
|
// "shop_id": 0,
|
|
|
// "shopping_cart_goods_id": "60422",
|
|
|
// "shopping_cart_id": "118792348",
|
|
|
// "shopping_key": "2a7729e3e974cfe476e4472a89c13743",
|
|
|
// "size_id": "199",
|
|
|
// "size_name": "F",
|
|
|
// "small_sort_id": "162",
|
|
|
// "storage_number": "100",
|
|
|
// "store_id": 0,
|
|
|
// "str_subtotal": "¥279.90",
|
|
|
// "subtotal": 279.9,
|
|
|
// "supplier_id": 0,
|
|
|
// "tags": [],
|
|
|
// "uid": "8040155",
|
|
|
// "vip1_price": "295.45",
|
|
|
// "vip2_price": "279.90",
|
|
|
// "vip3_price": "273.68",
|
|
|
// "vip_discount": 0.9,
|
|
|
// "vip_discount_money": 31.1,
|
|
|
// "vip_discount_type": "1",
|
|
|
// "vip_price": 11,
|
|
|
// "wareHouseId": 0,
|
|
|
// "yoho_coin_num": "0"
|
|
|
// }
|
|
|
// ],
|
|
|
// "pool_type": 1
|
|
|
// }
|
|
|
// ]
|
|
|
// },
|
|
|
// {
|
|
|
// "goods_list": [
|
|
|
// {
|
|
|
// "attribute": "1",
|
|
|
// "brand_domain": "reemoor",
|
|
|
// "brand_id": "949",
|
|
|
// "brand_name": "reemoor",
|
|
|
// "buy_limit": 0,
|
|
|
// "buy_number": "1",
|
|
|
// "buy_type": 2,
|
|
|
// "can_cod_pay": "Y",
|
|
|
// "cn_alphabet": "REEMOOR251205ShuangXianHangFengYaZhiFengGeShuJuanXie",
|
|
|
// "color_id": "7",
|
|
|
// "color_name": "蓝色",
|
|
|
// "delay_notice": "",
|
|
|
// "discount_tag": "S",
|
|
|
// "expect_arrival_time": "",
|
|
|
// "factory_goods_name": "蓝色",
|
|
|
// "fit_promotions": [],
|
|
|
// "get_yoho_coin": "0",
|
|
|
// "goods_id": "353397",
|
|
|
// "goods_images": "http://img10.static.yhbimg.com/goodsimg/2015/10/10/08/01218e9a756a74d2f15e8071fe43b601ab.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80",
|
|
|
// "goods_type": "ordinary",
|
|
|
// "is_advance": "N",
|
|
|
// "is_deposit_advance": "N",
|
|
|
// "is_jit": "N",
|
|
|
// "is_limited": "N",
|
|
|
// "is_outlets": "N",
|
|
|
// "is_special": "N",
|
|
|
// "last_price": "9.9",
|
|
|
// "last_vip_price": 9.9,
|
|
|
// "local_buy_number": 0,
|
|
|
// "market_price": 298,
|
|
|
// "max_sort_id": "6",
|
|
|
// "middle_sort_id": "48",
|
|
|
// "min_buy_number": 1,
|
|
|
// "off_shelves": 0,
|
|
|
// "offline_goods_status": 1,
|
|
|
// "offline_storage_number": 0,
|
|
|
// "offline_storage_status": 1,
|
|
|
// "online_storage_number": 0,
|
|
|
// "product_id": 273535,
|
|
|
// "product_name": "reemoor 双线绗缝雅致风格舒卷鞋",
|
|
|
// "product_skc": "278773",
|
|
|
// "product_skn": "51152203",
|
|
|
// "product_sku": "890538",
|
|
|
// "promotion_flag": "109",
|
|
|
// "promotion_id": "0",
|
|
|
// "real_price": 9.9,
|
|
|
// "real_vip_price": 9.9,
|
|
|
// "sale_price": 0,
|
|
|
// "sales_price": 11,
|
|
|
// "selected": "Y",
|
|
|
// "shop_id": 0,
|
|
|
// "shopping_cart_goods_id": "60416",
|
|
|
// "shopping_cart_id": "118792348",
|
|
|
// "shopping_key": "2a7729e3e974cfe476e4472a89c13743",
|
|
|
// "size_id": "116",
|
|
|
// "size_name": "40码",
|
|
|
// "small_sort_id": "151",
|
|
|
// "storage_number": "7",
|
|
|
// "store_id": 0,
|
|
|
// "str_subtotal": "¥9.90",
|
|
|
// "subtotal": 9.9,
|
|
|
// "supplier_id": 0,
|
|
|
// "tags": [],
|
|
|
// "uid": "8040155",
|
|
|
// "vip1_price": "10.45",
|
|
|
// "vip2_price": "9.90",
|
|
|
// "vip3_price": "9.68",
|
|
|
// "vip_discount": 0.9,
|
|
|
// "vip_discount_money": 1.1,
|
|
|
// "vip_discount_type": "1",
|
|
|
// "vip_price": 11,
|
|
|
// "wareHouseId": 0,
|
|
|
// "yoho_coin_num": "0"
|
|
|
// },
|
|
|
// {
|
|
|
// "attribute": "1",
|
|
|
// "brand_domain": "reemoor",
|
|
|
// "brand_id": "949",
|
|
|
// "brand_name": "reemoor",
|
|
|
// "buy_limit": 0,
|
|
|
// "buy_number": "1",
|
|
|
// "buy_type": 2,
|
|
|
// "can_cod_pay": "Y",
|
|
|
// "cn_alphabet": "REEMOOR251289LiangMianJianTouHuDieJieZhuangShiShuJuanXie",
|
|
|
// "color_id": "1",
|
|
|
// "color_name": "白色",
|
|
|
// "delay_notice": "",
|
|
|
// "discount_tag": "S",
|
|
|
// "expect_arrival_time": "",
|
|
|
// "factory_goods_name": "白色",
|
|
|
// "fit_promotions": [],
|
|
|
// "get_yoho_coin": "0",
|
|
|
// "goods_id": "353425",
|
|
|
// "goods_images": "http://img10.static.yhbimg.com/goodsimg/2015/10/10/08/01a9456ed9db84ea945d2163de7144a85f.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80",
|
|
|
// "goods_type": "ordinary",
|
|
|
// "is_advance": "N",
|
|
|
// "is_deposit_advance": "N",
|
|
|
// "is_jit": "N",
|
|
|
// "is_limited": "N",
|
|
|
// "is_outlets": "N",
|
|
|
// "is_special": "N",
|
|
|
// "last_price": "9.9",
|
|
|
// "last_vip_price": 9.9,
|
|
|
// "local_buy_number": 0,
|
|
|
// "market_price": 298,
|
|
|
// "max_sort_id": "6",
|
|
|
// "middle_sort_id": "48",
|
|
|
// "min_buy_number": 1,
|
|
|
// "off_shelves": 0,
|
|
|
// "offline_goods_status": 1,
|
|
|
// "offline_storage_number": 0,
|
|
|
// "offline_storage_status": 1,
|
|
|
// "online_storage_number": 0,
|
|
|
// "product_id": 273543,
|
|
|
// "product_name": "reemoor 亮面尖头蝴蝶结装饰舒卷鞋",
|
|
|
// "product_skc": "278787",
|
|
|
// "product_skn": "51152207",
|
|
|
// "product_sku": "890621",
|
|
|
// "promotion_flag": "109",
|
|
|
// "promotion_id": "0",
|
|
|
// "real_price": 9.9,
|
|
|
// "real_vip_price": 9.9,
|
|
|
// "sale_price": 0,
|
|
|
// "sales_price": 11,
|
|
|
// "selected": "Y",
|
|
|
// "shop_id": 0,
|
|
|
// "shopping_cart_goods_id": "60426",
|
|
|
// "shopping_cart_id": "118792348",
|
|
|
// "shopping_key": "2a7729e3e974cfe476e4472a89c13743",
|
|
|
// "size_id": "116",
|
|
|
// "size_name": "40码",
|
|
|
// "small_sort_id": "151",
|
|
|
// "storage_number": "6",
|
|
|
// "store_id": 0,
|
|
|
// "str_subtotal": "¥9.90",
|
|
|
// "subtotal": 9.9,
|
|
|
// "supplier_id": 0,
|
|
|
// "tags": [],
|
|
|
// "uid": "8040155",
|
|
|
// "vip1_price": "10.45",
|
|
|
// "vip2_price": "9.90",
|
|
|
// "vip3_price": "9.68",
|
|
|
// "vip_discount": 0.9,
|
|
|
// "vip_discount_money": 1.1,
|
|
|
// "vip_discount_type": "1",
|
|
|
// "vip_price": 11,
|
|
|
// "wareHouseId": 0,
|
|
|
// "yoho_coin_num": "0"
|
|
|
// }
|
|
|
// ],
|
|
|
// "pool_title": "reemoor",
|
|
|
// "pool_type": 1
|
|
|
// }
|
|
|
// ],
|
|
|
// "off_shelves_goods_list": [],
|
|
|
// "price_gift": [],
|
|
|
// "promotion_info": [
|
|
|
// {
|
|
|
// "cutdown_amount": 0.9,
|
|
|
// "promotion_id": 9088,
|
|
|
// "promotion_title": "线下店满3免一勿动",
|
|
|
// "promotion_type": "Cheapestfree"
|
|
|
// },
|
|
|
// {
|
|
|
// "cutdown_amount": 3.96,
|
|
|
// "promotion_id": 9148,
|
|
|
// "promotion_title": "全场促销",
|
|
|
// "promotion_type": "Discount"
|
|
|
// },
|
|
|
// {
|
|
|
// "cutdown_amount": 167.94,
|
|
|
// "promotion_id": 9086,
|
|
|
// "promotion_title": "线下店分件折扣勿动",
|
|
|
// "promotion_type": "Degressdiscount"
|
|
|
// },
|
|
|
// {
|
|
|
// "cutdown_amount": 10,
|
|
|
// "promotion_id": 0,
|
|
|
// "promotion_title": "满¥399免运费",
|
|
|
// "promotion_type": "FreeShippingCost"
|
|
|
// }
|
|
|
// ],
|
|
|
// "shopping_cart_data": {
|
|
|
// "discount_amount": 172.8,
|
|
|
// "fast_shopping_cost": 5,
|
|
|
// "gain_yoho_coin": 0,
|
|
|
// "goods_count": 12,
|
|
|
// "has_invalid_goods": 0,
|
|
|
// "is_multi_package": "N",
|
|
|
// "last_order_amount": 729.1,
|
|
|
// "offline_goods_count": 0,
|
|
|
// "online_goods_count": 0,
|
|
|
// "order_amount": 971,
|
|
|
// "package_list": [],
|
|
|
// "promotion_formula": "总计¥729.10=商品金额¥971.00-活动金额¥172.80-学生优惠¥69.10",
|
|
|
// "promotion_formula_list": [
|
|
|
// {
|
|
|
// "promotion": "商品金额",
|
|
|
// "promotion_amount": "¥971.00"
|
|
|
// },
|
|
|
// {
|
|
|
// "promotion": "活动金额",
|
|
|
// "promotion_amount": "-¥172.80"
|
|
|
// },
|
|
|
// {
|
|
|
// "promotion": "学生优惠",
|
|
|
// "promotion_amount": "-¥69.10"
|
|
|
// }
|
|
|
// ],
|
|
|
// "remain_time": 0,
|
|
|
// "selected_goods_count": 12,
|
|
|
// "shipping_cost": 0,
|
|
|
// "str_discount_amount": "¥172.80",
|
|
|
// "str_order_amount": "¥971.00"
|
|
|
// },
|
|
|
// "sold_out_goods_list": []
|
|
|
// }
|
|
|
// },
|
|
|
// "md5": "4fd4cbe259627fea6b1c68a0fb6c217a",
|
|
|
// "message": "cart goods list."
|
|
|
// }))
|
|
|
// })
|
|
|
return cartProcess.processData(data);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const processData = (data, isAdvanceCart) => {
|
|
|
let result = {};
|
|
|
|
|
|
// 购买的可用商品列表
|
|
|
result.goods = _.get(data, 'goods_list', []).map(good => { return formatCartGoods(good, isAdvanceCart); });
|
|
|
result.promotionPoolList = _.get(data, 'promotion_pool_list', []).map(promotion => {
|
|
|
return {
|
|
|
goods: _.get(promotion, 'goods_list', []).map(good => { return formatCartGoods(good, isAdvanceCart); }),
|
|
|
promotions: _.get(promotion, 'promotion_list', []).map(promo => {
|
|
|
return {
|
|
|
status: promo.status,
|
|
|
conditionUnit: promo.condition_unit,
|
|
|
conditionValue: promo.condition_value,
|
|
|
giftGoodsList: _.get(promo, 'gift_goods_List', []).map(gift => { return formatAdvanceGoods(gift); }),
|
|
|
giftPrice: promo.gift_price,
|
|
|
promotionId: promo.promotion_id,
|
|
|
promotionTitle: promo.promotion_title,
|
|
|
promotionType: promo.promotion_type,
|
|
|
alreadyMatch: promo.alreadyMatch
|
|
|
};
|
|
|
})
|
|
|
};
|
|
|
/**
|
|
|
* 购物车商品选择与取消接口
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $sku 商品sku列表
|
|
|
* @param string $shoppingKey 未登录用户唯一识别码
|
|
|
* @return array 购物车接口返回的数据
|
|
|
*/
|
|
|
const selectGood = (uid, sku, shoppingKey) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.Shopping.selectedAndQryCart',
|
|
|
product_sku_list: sku,
|
|
|
uid: uid,
|
|
|
shopping_key: shoppingKey
|
|
|
}).then((data) => {
|
|
|
return cartProcess.processData(data);
|
|
|
});
|
|
|
|
|
|
// 失效商品列表
|
|
|
result.notValidGoods = _.get(data, 'sold_out_goods_list', []).map(good => { return formatCartGoods(good, isAdvanceCart, false); });
|
|
|
|
|
|
// 下架的商品列表
|
|
|
result.offShelveGoods = _.get(data, 'off_shelves_goods_list', []).map(good => { return formatCartGoods(good, isAdvanceCart, false); });
|
|
|
|
|
|
// 赠品和加价购商品
|
|
|
if (data.gift_list.length || data.price_gift.length) {
|
|
|
result.freebieOrAdvanceBuy = true;
|
|
|
|
|
|
// 赠品
|
|
|
result.freebie = data.gift_list.map(good => { return formatAdvanceGoods(good); });
|
|
|
result.giftCount = result.freebie.length;
|
|
|
|
|
|
// 加价购
|
|
|
result.advanceBuy = data.price_gift.map(good => { return formatAdvanceGoods(good); });
|
|
|
result.advanceBuyCount = result.advanceBuy.length;
|
|
|
}
|
|
|
|
|
|
// 已参加的活动
|
|
|
if (data.promotion_info && data.promotion_info.length > 0) {
|
|
|
result.promotionInfo = data.promotion_info.map(promotion => {
|
|
|
return {id: promotion.promotion_id, name: promotion.promotion_title};
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 结算数据
|
|
|
result.formulaPrice = data.shopping_cart_data.promotion_formula;
|
|
|
result.count = data.shopping_cart_data.selected_goods_count;
|
|
|
result.isAllSelected = (data.shopping_cart_data.goods_count === data.shopping_cart_data.selected_goods_count) && (data.shopping_cart_data.selected_goods_count > 0);
|
|
|
result.sumPrice = transPrice(data.shopping_cart_data.last_order_amount);
|
|
|
|
|
|
|
|
|
return result;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 格式化加价购和赠品商品
|
|
|
* 移出购物车
|
|
|
*
|
|
|
* @param array $advanceGoods 加价购商品列表
|
|
|
* @param int $count 计商品件数
|
|
|
* @return array $arr 处理之后的加价购商品数据
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $sku 商品sku列表
|
|
|
* @param string $shoppingKey 未登录用户唯一识别码
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const formatAdvanceGoods = (advanceGood, isGift) => {
|
|
|
let result = {};
|
|
|
|
|
|
result.id = advanceGood.product_skn;
|
|
|
result.name = advanceGood.product_name;
|
|
|
result.thumb = advanceGood.goods_images ? helpers.image(advanceGood.goods_images, 120, 160) : '';
|
|
|
result.price = transPrice(advanceGood.last_price);
|
|
|
result.marketPrice = isGift ? '0.00' : transPrice(advanceGood.market_price);
|
|
|
result.count = advanceGood.storage_number;
|
|
|
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
const removeFromCart = (uid, sku, shoppingKey) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.Shopping.removeAndQryCart',
|
|
|
product_sku_list: sku,
|
|
|
uid: uid,
|
|
|
shopping_key: shoppingKey
|
|
|
}).then((data) => {
|
|
|
return cartProcess.processData(data);
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 格式化购物车商品
|
|
|
* 获取购物车商品数据
|
|
|
*
|
|
|
* @param array $cartGoods 购物车商品列表
|
|
|
* @param boolean $isValid 是否是可用商品(非失效商品),默认是
|
|
|
* @param bool $isAdvanceCart 是否是预售购物车(和上市期有关)
|
|
|
* @return array 处理之后的购物车商品数据
|
|
|
* @param int $uid 用户ID
|
|
|
* @param int $skn 商品skn
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const formatCartGoods = (goodData, isAdvanceCart, isValid) => {
|
|
|
let result = {};
|
|
|
result.id = goodData.product_sku;
|
|
|
result.skn = goodData.product_skn;
|
|
|
result.name = goodData.product_name;
|
|
|
result.thumb = goodData.goods_images ? helpers.image(goodData.goods_images, 120, 160) : '';
|
|
|
result.color = goodData.color_name;
|
|
|
result.size = goodData.size_name;
|
|
|
result.checked = goodData.selected === 'Y';
|
|
|
result.price = transPrice(goodData.last_vip_price);
|
|
|
result.isVipPrice = goodData.sales_price !== goodData.last_vip_price && goodData.discount_tag === 'V';
|
|
|
result.isStudents = goodData.sales_price !== goodData.last_vip_price && goodData.discount_tag === 'S';
|
|
|
result.count = goodData.buy_number;
|
|
|
result.promotion_id = goodData.promotion_id;
|
|
|
if (isValid) {
|
|
|
// 库存不足
|
|
|
result.lowStocks = (goodData.buy_number > goodData.storage_number);
|
|
|
} else { // 失效商品
|
|
|
result.inValid = true;
|
|
|
}
|
|
|
|
|
|
// gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
|
|
|
if (!goodData.goods_type) {
|
|
|
result.inValid = true;
|
|
|
}
|
|
|
else if (goodData.goods_type === 'gift' && !goodData.isAdvanceBuy) {
|
|
|
result.isGift = true;
|
|
|
result.salesPrice = transPrice(goodData.sales_price);
|
|
|
result.price = transPrice(goodData.last_price);
|
|
|
}
|
|
|
else if (goodData.goods_type === 'price_gift') {
|
|
|
result.showCheckbox = true;
|
|
|
result.isAdvanceBuy = true;
|
|
|
result.salesPrice = transPrice(goodData.sales_price);
|
|
|
result.price = transPrice(goodData.last_price);
|
|
|
}
|
|
|
else {
|
|
|
result.showCheckbox = true;
|
|
|
}
|
|
|
|
|
|
// 上市期
|
|
|
if (isAdvanceCart && goodData.expect_arrival_time) {
|
|
|
result.appearDate = goodData.expect_arrival_time;
|
|
|
}
|
|
|
const cartProductData = (uid, skn) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.product.data',
|
|
|
product_skn: skn,
|
|
|
uid: uid,
|
|
|
showcomment: 'N'
|
|
|
}).then((data) => {
|
|
|
return cartProcess.procGoodsDetail(data);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 商品链接
|
|
|
result.link = helpers.urlFormat(`/product/show_${goodData.product_skn}.html`);
|
|
|
};
|
|
|
/**
|
|
|
* 修改购物车商品数量-增加
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $sku 商品SKU
|
|
|
* @param int $increaseNum 增加的数目
|
|
|
* @param string $shoppingKey 未登录用户唯一识别码
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const increaseProductNum = (uid, sku, increaseNum, shoppingKey) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.Shopping.increase',
|
|
|
product_sku: sku,
|
|
|
increase_number: increaseNum,
|
|
|
uid: uid,
|
|
|
shopping_key: shoppingKey
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 修改购物车商品数量-减少
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $sku 商品SKU
|
|
|
* @param int $decreaseNum 减少的数目
|
|
|
* @param string $shoppingKey 未登录用户唯一识别码
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const decreaseProductNum = (uid, sku, decreaseNum, shoppingKey) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.Shopping.decrease',
|
|
|
product_sku: sku,
|
|
|
decrease_number: decreaseNum,
|
|
|
uid: uid,
|
|
|
shopping_key: shoppingKey
|
|
|
});
|
|
|
}
|
|
|
|
|
|
const transPrice = (price, isSepcialZero) => {
|
|
|
return (price || isSepcialZero) ? price.toFixed(2) : 0;
|
|
|
};
|
|
|
/**
|
|
|
* 修改购物车商品数据
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $param 要更改的数据
|
|
|
* @param string $shoppingKey 未登录用户唯一识别码
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const modifyCartProduct = (uid, param, shoppingKey) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.Shopping.swap',
|
|
|
swap_data: param,
|
|
|
uid: uid,
|
|
|
shopping_key: shoppingKey
|
|
|
});
|
|
|
}
|
|
|
/**
|
|
|
* 移入收藏夹
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $sku 商品sku列表
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const addToFav = (uid, sku) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.Shopping.addfavoriteAndQryCart',
|
|
|
product_sku_list: sku,
|
|
|
uid: uid,
|
|
|
shopping_key: shoppingKey
|
|
|
}).then((data) => {
|
|
|
return cartProcess.processData(data);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
module.exports = {
|
|
|
indexData
|
|
|
indexData,
|
|
|
selectGood,
|
|
|
removeFromCart,
|
|
|
cartProductData,
|
|
|
addToFav,
|
|
|
increaseProductNum,
|
|
|
decreaseProductNum
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|