| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- /**
- * 交♂易相关API
- */
- import { http, Method } from "@/utils/request.js";
- /**
- * 获取购物车列表
- * @param show_type 要显示的类型 all:全部 checked:已选中的
- */
- export function getCarts() {
- return http.request({
- url: `/trade/carts/all`,
- method: Method.GET,
- needToken: true,
- loading: false,
- });
- }
- /**
- * 获取购物车总数
- * @param show_type 要显示的类型 all:全部 checked:已选中的
- */
- export function getCartNum() {
- return http.request({
- url: `/trade/carts/count`,
- method: Method.GET,
- needToken: true,
- loading: false,
- });
- }
- /**
- * 获取购物车可用优惠券数量
- * @param way 购物车购买:CART/立即购买:BUY_NOW/拼团购买:PINTUAN / 积分购买:POINT
- */
- export function getCartCouponNum(way) {
- return http.request({
- url: `/trade/carts/coupon/num?way=${way}`,
- method: Method.GET,
- needToken: true,
- loading: false,
- });
- }
- /**
- * 添加货品到购物车
- * @param skuId 产品ID
- * @param num 产品的购买数量
- * @param cartType 购物车类型,默认加入购物车
- */
- export function addToCart(data) {
- return http.request({
- url: "/trade/carts",
- method: Method.POST,
- needToken: true,
- header: { "content-type": "application/x-www-form-urlencoded" },
- data,
- });
- }
- /**
- * 更新购物车商品数量
- * @param skuId
- * @param num
- */
- export function updateSkuNum(skuId, num = 1) {
- return http.request({
- url: `/trade/carts/sku/num/${skuId}`,
- method: Method.POST,
- header: { "content-type": "application/x-www-form-urlencoded" },
- needToken: true,
- data: { num },
- });
- }
- /**
- * 更新购物车货品选中状态
- * @param skuId
- * @param checked
- */
- export function updateSkuChecked(skuId, checked) {
- return http.request({
- url: `/trade/carts/sku/checked/${skuId}`,
- method: Method.POST,
- needToken: true,
- header: { "content-type": "application/x-www-form-urlencoded" },
- data: { checked },
- });
- }
- /**
- * 删除多个货品项
- * @param skuIds
- */
- export function deleteSkuItem(skuIds) {
- return http.request({
- url: `/trade/carts/sku/remove?skuIds=${skuIds}`,
- method: Method.DELETE,
- needToken: true,
- });
- }
- /**
- * 设置全部货品为选中或不选中
- * @param checked
- */
- export function checkAll(checked) {
- return http.request({
- url: "/trade/carts/sku/checked",
- method: Method.POST,
- needToken: true,
- params: { checked },
- });
- }
- /**
- * 设置店铺内全部货品选中状态
- * @param storeId
- * @param checked
- */
- export function checkStore(storeId, checked) {
- return http.request({
- url: `/trade/carts/store/${storeId}`,
- method: Method.POST,
- needToken: true,
- header: { "content-type": "application/x-www-form-urlencoded" },
- data: { checked },
- });
- }
- /**
- * 获取结算参数
- */
- export function getCheckoutParams(way) {
- return http.request({
- url: "/trade/carts/checked?way=" + way,
- method: Method.GET,
- needToken: true,
- });
- }
- /**
- * 设置收货地址ID
- * @param addressId
- */
- export function setAddressId(addressId,way) {
- return http.request({
- url: `/trade/carts/shippingAddress?shippingAddressId=${addressId}&way=${way}`,
- method: Method.GET,
- needToken: true,
-
- });
- }
- /**
- * 创建交易
- */
- export function createTrade(params) {
- return http.request({
- url: "/trade/carts/create/trade",
- method: Method.POST,
- needToken: true,
- message: false,
- data:params,
- });
- }
- /**
- * 根据交易编号或订单编号查询收银台数据
- * @param params
- */
- export function getCashierData(params) {
- return http.request({
- url: "cashier/tradeDetail",
- method: Method.GET,
- needToken: true,
- params,
- });
- }
- /**
- * 发起支付
- * @param paymentMethod
- * @param paymentClient
- * @param params
- * @returns {*|*}
- */
- export function initiatePay(paymentMethod, paymentClient, params) {
- return http.request({
- url: `cashier/pay/${paymentMethod}/${paymentClient}`,
- method: Method.GET,
- needToken: true,
- params,
- });
- }
-
- /**
- * 查询物流
- * @param orderSn
- */
- export function getExpress(orderSn) {
- return http.request({
- url: `/orders/getTraces/${orderSn}`,
- method: Method.POST,
- needToken: true,
-
- });
- }
- /**
- * 获取当前会员的对于当前商品可使用的优惠券列表
- */
- export function getMemberCanUse(data) {
- return http.request({
- url: `/promotion/coupon/canUse`,
- method: Method.GET,
- params: data,
- });
- }
- /**
- * 获取当前会员的优惠券列表
- */
- export function getMemberCouponList(data) {
- return http.request({
- url: `/promotion/coupon/getCoupons`,
- method: Method.GET,
- params: data,
- });
- }
- /**
- * 使用优惠券
- */
- export function useCoupon(params) {
- return http.request({
- url: `/trade/carts/select/coupon`,
- method: Method.GET,
- needToken: true,
- params: params,
- });
- }
- /**
- * 更换参与活动
- * @param params
- */
- export function changeActivity(params) {
- return http.request({
- url: "trade/promotion",
- method: Method.POST,
- needToken: true,
- data: params,
- header: { "content-type": "application/x-www-form-urlencoded" },
- });
- }
- /**
- * 根据交易单号查询订单列表
- * @param trade_sn
- */
- export function reBuy(sn) {
- return http.request({
- url: `trade/carts/rebuy/${sn}`,
- method: Method.POST,
- needToken: true,
- });
- }
|