|
|
import request from '@/components/hzjc/utils/request.js'
|
|
|
|
|
|
let mall = {}
|
|
|
|
|
|
//------------------------设置-----------------------
|
|
|
/**
|
|
|
* 获取轮播图
|
|
|
* @date 2022-10-27
|
|
|
*/
|
|
|
mall.getCarousel = function() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Config/getCarousel', {}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取广告图
|
|
|
* @date 2022-10-27
|
|
|
*/
|
|
|
mall.getAdvertise = function() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Config/getAdvertise', {}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
//------------------------搜索-----------------------
|
|
|
/**
|
|
|
* 获取热门搜索
|
|
|
* @date 2022-11-17
|
|
|
*/
|
|
|
mall.listHotSearch = function() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Search/listHotSearch').then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取历史搜索
|
|
|
* @date 2022-11-17
|
|
|
*/
|
|
|
mall.listHistorySearch = function() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Search/listHistorySearch').then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加历史搜索
|
|
|
* @param {string} keyword 关键字
|
|
|
* @date 2022-11-17
|
|
|
*/
|
|
|
mall.insertHistorySearch = function(keyword) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Search/insertHistorySearch', {
|
|
|
keyword: keyword
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 清空历史搜索
|
|
|
* @date 2022-11-17
|
|
|
*/
|
|
|
mall.deleteAllHistorySearch = function(keyword) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Search/deleteAllHistorySearch', {
|
|
|
keyword: keyword
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取分类
|
|
|
* @date 2022-10-27
|
|
|
*/
|
|
|
mall.listCategory = function() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Product/listCategory', {}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取商品列表
|
|
|
* @param {object} that
|
|
|
* @param {int} isFirstPage 是否第一页 0--不是 1--是
|
|
|
* @param {int} firstCategoryId 一级分类ID
|
|
|
* @param {int} secondCategoryId 二级分类ID
|
|
|
* @param {int} keyword 关键词
|
|
|
* @param {int} isRecommend 是否推荐 0--不限制 1--是推荐
|
|
|
* @param {int} priceMin 最低价钱
|
|
|
* @param {int} priceMax 最高价钱
|
|
|
* @param {int} order 排序
|
|
|
* @date 2022-10-27
|
|
|
*/
|
|
|
mall.listProduct = function(that, isFirstPage, firstCategoryId, secondCategoryId, keyword, isRecommend, priceMin,
|
|
|
priceMax, order) {
|
|
|
let data = {}
|
|
|
|
|
|
data.first_category_id = firstCategoryId
|
|
|
data.second_category_id = secondCategoryId
|
|
|
data.keyword = keyword
|
|
|
data.is_recommend = isRecommend
|
|
|
data.price_min = priceMin
|
|
|
data.price_max = priceMax
|
|
|
data.order = order
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getList('mall/api/Product/listProduct', data, {
|
|
|
that: that,
|
|
|
first_page: isFirstPage
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取商品详情
|
|
|
* @param {int} productId 产品ID
|
|
|
* @date 2022-12-13
|
|
|
*/
|
|
|
mall.getProduct = function(productId) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Product/getProduct', {
|
|
|
product_id: productId
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取订单数量
|
|
|
* @date 2022-12-28
|
|
|
*/
|
|
|
mall.countOrderNumber = function() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Order/countOrderNumber').then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取下单数据
|
|
|
* @param {int} type 下单类型 1--商城 2--秒杀商城
|
|
|
* @param {int} buyType 购买类型 1--购物车 2--立即购买
|
|
|
* @param {int} myAddressId 我的地址ID
|
|
|
* @param {int} productId buyType=2时,产品ID
|
|
|
* @param {string} productSku buyType=2时,产品SKU
|
|
|
* @param {int} number buyType=2时,购买数量
|
|
|
* @param {int} isChooseDefaultCoupon 是否选择默认的最大可选优惠券
|
|
|
* @param {int} myCouponId 我的优惠券ID
|
|
|
* @param {int} spikeProductId type=2时,秒杀商品ID
|
|
|
* @date 2022-10-13
|
|
|
*/
|
|
|
mall.getOrderReady = function(type, buyType, myAddressId, productId, productSku, number, isChooseDefaultCoupon,
|
|
|
myCouponId, spikeProductId) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Order/getOrderReady', {
|
|
|
buy_type: buyType,
|
|
|
my_address_id: myAddressId,
|
|
|
product_id: productId,
|
|
|
product_sku: productSku,
|
|
|
number: number,
|
|
|
is_choose_default_coupon: isChooseDefaultCoupon,
|
|
|
my_coupon_id: myCouponId,
|
|
|
type: type,
|
|
|
spike_product_id: spikeProductId
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 提交订单并支付
|
|
|
* @param {int} type 下单类型 1--商城 2--秒杀商城
|
|
|
* @param {int} buyType 购买类型 1--购物车 2--立即购买
|
|
|
* @param {int} myAddressId 我的地址ID
|
|
|
* @param {int} productId buyType=2时,产品ID
|
|
|
* @param {string} productSku buyType=2时,产品SKU
|
|
|
* @param {int} number buyType=2时,购买数量
|
|
|
* @param {int} myCouponId 我的优惠券ID
|
|
|
* @param {int} payType 支付方式 1--微信支付 2--支付宝支付 3--余额支付
|
|
|
* @param {string} remark 备注
|
|
|
* @param {int} spikeProductId type=2时,秒杀商品ID
|
|
|
* @date 2022-10-31
|
|
|
*/
|
|
|
mall.insertOrder = function(type, buyType, myAddressId, productId, productSku, number,
|
|
|
myCouponId, payType, remark, spikeProductId) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Order/insertOrder', {
|
|
|
buy_type: buyType,
|
|
|
my_address_id: myAddressId,
|
|
|
product_id: productId,
|
|
|
product_sku: productSku,
|
|
|
number: number,
|
|
|
my_coupon_id: myCouponId,
|
|
|
pay_type: payType,
|
|
|
remark: remark,
|
|
|
type: type,
|
|
|
spike_product_id: spikeProductId
|
|
|
}, {
|
|
|
loading: true
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 再支付订单
|
|
|
* @param {int} orderId 订单ID
|
|
|
* @param {int} payType 支付方式 1--微信支付 2--支付宝支付 3--余额支付
|
|
|
* @date 2022-10-31
|
|
|
*/
|
|
|
mall.rePayOrder = function(orderId, payType) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Order/rePayOrder', {
|
|
|
order_id: orderId,
|
|
|
pay_type: payType
|
|
|
}, {
|
|
|
loading: true
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 取消订单
|
|
|
* @param {int} orderId 订单ID
|
|
|
* @date 2022-10-31
|
|
|
*/
|
|
|
mall.cancelOrder = function(orderId) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Order/cancelOrder', {
|
|
|
order_id: orderId
|
|
|
}, {
|
|
|
loading: true
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询物流
|
|
|
* @param {int} orderId 订单ID
|
|
|
* @date 2022-11-22
|
|
|
*/
|
|
|
mall.getLogistics = function(orderId) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Order/getLogistics', {
|
|
|
order_id: orderId
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取我的浏览记录
|
|
|
* @param {object} that
|
|
|
* @param {int} isFirstPage 是否第一页 0--不是 1--是
|
|
|
* @date 2022-11-30
|
|
|
*/
|
|
|
mall.listMyBrowse = function(that, isFirstPage) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getList('mall/api/Browse/listMyBrowse', {}, {
|
|
|
that: that,
|
|
|
first_page: isFirstPage
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除我的浏览记录
|
|
|
* @param {string} browseIds 需要删除的浏览记录ID
|
|
|
* @date 2022-12-01
|
|
|
*/
|
|
|
mall.deleteMyBrowse = function(browseIds) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Browse/deleteMyBrowse', {
|
|
|
browse_ids: browseIds
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除全部我的浏览记录
|
|
|
* @date 2022-12-01
|
|
|
*/
|
|
|
mall.deleteAllMyBrowse = function(browseIds) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Browse/deleteAllMyBrowse').then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取我的收藏记录
|
|
|
* @param {string} keyword 关键字
|
|
|
* @date 2022-12-01
|
|
|
*/
|
|
|
mall.listMyCollect = function(keyword) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Collect/listMyCollect', {
|
|
|
keyword: keyword
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取我的收藏记录
|
|
|
* @param {array} collectIds 需要删除的收藏记录ID
|
|
|
* @date 2022-12-01
|
|
|
*/
|
|
|
mall.deleteMyCollect = function(collectIds) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request.getData('mall/api/Collect/deleteMyCollect', {
|
|
|
collect_ids: collectIds
|
|
|
}).then(res => {
|
|
|
resolve(res)
|
|
|
}).catch(res => {
|
|
|
reject(res)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
export default mall
|