From 87d2fac9c381de99f75ce6c6c39b7d638b980d7e Mon Sep 17 00:00:00 2001 From: 杨磊 <505174330@qq.com> Date: 星期四, 21 八月 2025 17:52:14 +0800 Subject: [PATCH] 1111 --- src/assets/js/middleGround/api/store.js | 879 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 879 insertions(+), 0 deletions(-) diff --git a/src/assets/js/middleGround/api/store.js b/src/assets/js/middleGround/api/store.js new file mode 100644 index 0000000..bbe8f32 --- /dev/null +++ b/src/assets/js/middleGround/api/store.js @@ -0,0 +1,879 @@ +import request from '@/plugin/axios/index.ts' +import { tokenKey, goodsStore } from '@/assets/js/config' +import { handleQueryResourceListData, handleDetailQueryRequestData } from '../tool' +const storeApi = { + /* + **鑾峰彇鍟嗗搧鍒楄〃** + path: 鏁版嵁璺緞 + storeInfo: 浠撳偍 + channelInfo: 棰戦亾 + subAccess: + queryType: 妫�绱㈢被鍨� + paging: 鍒嗛〉 + sort: 鎺掑簭 + fields: 鑷畾涔夊瓧娈� + */ + getProductList: ({ + path = '', + storeInfo = goodsStore, + storeEventIdOrRefCode = '', + favoriteTypes = '', + queryType, + linkType, + subAccess = [], + paging = {}, + sort, + fields, + filterList, + coverSize, + mainProductId, + handelEBooK + }) => { + const query = { + AccessControl: { + Path: path, + StoreRefCode: storeInfo + '', + Type: queryType || '\\', + LinkType: linkType || '' + }, + FavoriteTypes: favoriteTypes ? [favoriteTypes] : [], + SubAccess: subAccess.length > 0 ? subAccess : [], + PageQuery: { + Start: paging.start || '0', + Size: paging.size || '10' + }, + SortQuery: + sort?.length == 0 + ? [] + : sort + ? [sort] + : [ + { + LinkOrder: 'Desc' + } + ], + CreateDate: [], + Description: [], + Name: [], + Icon: [], + RefCode: [], + TypeId: [], + SysType: [], + State: [], + Tag: [], + BeginDate: [], + EndDate: [], + ProductLinkInfo: [], + AllowDonate: [], + // DonatePriceList: [], + StoreEvent: [], + SubProductCount: [], + SaleMethod: [], + SaleMethodValid: [], + StoreEventIdOrRefCode: storeEventIdOrRefCode, + ...fields, + ...filterList + } + if (mainProductId) { + query.AccessControl.MainProductId = mainProductId + } + if (handelEBooK) { + query.ProductCmsQuery = [ + { + QueryCms: { + Path: '*', + Type: '\\', + Name: [], + Icon: [], + TypeId: [], + RefCode: [], + ChildrenCount: [], + ChildrenFolderCount: [], + CreateDate: [], + SysType: [], + SaleMethod: [], + PageQuery: { + Start: 0, + Size: 9999 + }, + ProductLinkInfo: [] + } + } + ] + } + const body = { + query: JSON.stringify({ + Query: [ + { + Q1: query + } + ] + }) + } + let token = localStorage.getItem(tokenKey) + let url = token ? '/store/api/ApiQueryProductByAppUser' : '/store/api/ApiQueryProduct' + return request({ + url: url, + method: 'post', + data: body + }).then((resp) => { + if (resp.length > 0) { + const data = resp[0] + const datas = handleQueryResourceListData({ + datas: data.datas, + fields, + path, + storeInfo, + coverSize, + handelEBooK + }) + return { + datas, + total: data.totalCount, + extraInfos: data.extraInfos?.StoreEvent + } + } + return { + datas: [], + total: 0 + } + }) + }, + /* + **鑾峰彇鍟嗗搧璇︽儏** + path: 鏁版嵁璺緞 + storeInfo: 浠撳偍 + channelInfo: 棰戦亾 + subAccess: + fields: 鑷畾涔夊瓧娈� + productId: 鍟嗗搧ID + cmsPath锛歝msPath + */ + getProductDetail: ({ + path = '', + storeInfo = goodsStore, + channelInfo = '', + favoriteTypes = '', + queryType, + subAccess = [], + fields, + productId, + cmsPath, + cmsType, + coverSize, + itemId, + itemIds, + itemFields, + linkTypes, + filterList, + handelEBooK, + sort, + cmsSort, + source + }) => { + const subQuery = {} + if (cmsPath) { + subQuery['QueryCms'] = { + Path: cmsPath + '', + Type: cmsType || '\\', + Name: [], + Icon: [], + TypeId: [], + RefCode: [], + Description:[], + ChildrenCount: [], + ChildrenFolderCount: [], + CreateDate: [], + SysType: [], + SaleMethod: [], + PageQuery: { + Start: 0, + Size: 9999 + }, + SortQuery: cmsSort + ? [cmsSort] + : [ + { + ProductLinkOrder: 'Asc' + } + ], + ProductLinkInfo: [], + ...itemFields + } + if (itemId) subQuery['QueryCms']['Id='] = [`${itemId}`] + if (itemIds) subQuery['QueryCms']['Id='] = itemIds + } else { + subQuery['QueryCms'] = { + Path: '*', + Type: '\\', + Name: [], + Icon: [], + TypeId: [], + RefCode: [], + Description:[], + ChildrenCount: [], + ChildrenFolderCount: [], + CreateDate: [], + SysType: [], + SaleMethod: [], + PageQuery: { + Start: 0, + Size: 9999 + }, + ProductLinkInfo: [] + } + } + // 鑾峰彇鍏宠仈璧勬簮 + let linkFields = {} + if (linkTypes && linkTypes.length) { + for (let i = 0; i < linkTypes.length; i++) { + const linkType = linkTypes[i] + subQuery['QueryLink_' + linkType.linkType] = { + Path: cmsPath + '', + Type: '\\', + Name: [], + Icon: [], + TypeId: [], + RefCode: [], + Description:[], + LinkTypes: [linkType.linkType], + PageQuery: { + Start: 0, + Size: 100 + }, + ProductLinkInfo: [], + ...linkType.fields + } + linkFields = { + ...linkFields, + ...linkType.fields + } + } + } + const query = { + AccessControl: { + Path: path, + StoreRefCode: storeInfo + '', + ChannelRefCode: channelInfo + '', + Type: queryType || '\\' + }, + FavoriteTypes: favoriteTypes ? [favoriteTypes] : [], + SubAccess: subAccess.length > 0 ? subAccess : [], + PageQuery: { + Start: '0', + Size: '1' + }, + 'Id=': [`${productId}`], + SortQuery: sort + ? [sort] + : [ + { + LinkOrder: 'Desc' + } + ], + CreateDate: [], + Description: [], + Name: [], + Icon: [], + RefCode: [], + Description:[], + TypeId: [], + SysType: [], + State: [], + Tag: [], + BeginDate: [], + EndDate: [], + ProductLinkInfo: [], + AllowDonate: [], + DonatePriceList: [], + StoreEvent: [], + SaleMethod: [], + SaleMethodValid: [], + CmsItemValid: [], + ProductCmsQuery: [subQuery], + ...fields, + ...filterList + } + if (productId) query['Id='] = [`${productId}`] + + const body = { + query: JSON.stringify({ + Query: [ + { + Q1: query + } + ] + }) + } + let token = localStorage.getItem(tokenKey) + let url = token ? '/store/api/ApiQueryProductByAppUser' : '/store/api/ApiQueryProduct' + return request({ + url: url, + method: 'post', + data: body, + cancelToken: source?.token + }) + .then((resp) => { + if (resp.length > 0) { + const data = resp[0] + if (data.datas.length) { + data.datas[0].subDatas = data.datas[0].cmsDatas + const datas = handleDetailQueryRequestData({ + item: data.datas[0], + fields, + itemFields: { + ...itemFields, + ...linkFields + }, + path, + coverSize, + handelEBooK, + + }) + return { + datas, + total: data.totalCount + } + } else { + return { + datas: [], + total: 0 + } + } + } + return { + datas: [], + total: 0 + } + }) + }, + // 鑾峰彇鍟嗗搧璇︽儏锛屼笉杩斿洖 ChildrenCount,ChildrenFolderCount + // (姝ゆ帴鍙d负浜嗘弧瓒充笉杩斿洖 ChildrenCount,ChildrenFolderCount鑰屽悗缁坊鍔犵殑) 涓嶆槸涓彴鍘熸湁鐨� + getProductDetailNoChildren:({ + path = '', + storeInfo = goodsStore, + channelInfo = '', + favoriteTypes = '', + queryType, + subAccess = [], + fields, + productId, + cmsPath, + cmsType, + coverSize, + itemId, + itemIds, + itemFields, + linkTypes, + filterList, + handelEBooK, + sort, + cmsSort, + source + }) => { + const subQuery = {} + if (cmsPath) { + subQuery['QueryCms'] = { + Path: cmsPath + '', + Type: cmsType || '\\', + Name: [], + Icon: [], + TypeId: [], + RefCode: [], + Description:[], + // ChildrenCount: [], + // ChildrenFolderCount: [], + CreateDate: [], + SysType: [], + SaleMethod: [], + PageQuery: { + Start: 0, + Size: 9999 + }, + SortQuery: cmsSort + ? [cmsSort] + : [ + { + ProductLinkOrder: 'Asc' + } + ], + ProductLinkInfo: [], + ...itemFields + } + if (itemId) subQuery['QueryCms']['Id='] = [`${itemId}`] + if (itemIds) subQuery['QueryCms']['Id='] = itemIds + } else { + subQuery['QueryCms'] = { + Path: '*', + Type: '\\', + Name: [], + Icon: [], + TypeId: [], + RefCode: [], + Description:[], + ChildrenCount: [], + ChildrenFolderCount: [], + CreateDate: [], + SysType: [], + SaleMethod: [], + PageQuery: { + Start: 0, + Size: 9999 + }, + ProductLinkInfo: [] + } + } + // 鑾峰彇鍏宠仈璧勬簮 + let linkFields = {} + if (linkTypes && linkTypes.length) { + for (let i = 0; i < linkTypes.length; i++) { + const linkType = linkTypes[i] + subQuery['QueryLink_' + linkType.linkType] = { + Path: cmsPath + '', + Type: '\\', + Name: [], + Icon: [], + TypeId: [], + RefCode: [], + Description:[], + LinkTypes: [linkType.linkType], + PageQuery: { + Start: 0, + Size: 100 + }, + ProductLinkInfo: [], + ...linkType.fields + } + linkFields = { + ...linkFields, + ...linkType.fields + } + } + } + const query = { + AccessControl: { + Path: path, + StoreRefCode: storeInfo + '', + ChannelRefCode: channelInfo + '', + Type: queryType || '\\' + }, + FavoriteTypes: favoriteTypes ? [favoriteTypes] : [], + SubAccess: subAccess.length > 0 ? subAccess : [], + PageQuery: { + Start: '0', + Size: '1' + }, + 'Id=': [`${productId}`], + SortQuery: sort + ? [sort] + : [ + { + LinkOrder: 'Desc' + } + ], + CreateDate: [], + Description: [], + Name: [], + Icon: [], + RefCode: [], + Description:[], + TypeId: [], + SysType: [], + State: [], + Tag: [], + BeginDate: [], + EndDate: [], + ProductLinkInfo: [], + AllowDonate: [], + DonatePriceList: [], + StoreEvent: [], + SaleMethod: [], + SaleMethodValid: [], + CmsItemValid: [], + ProductCmsQuery: [subQuery], + ...fields, + ...filterList + } + if (productId) query['Id='] = [`${productId}`] + + const body = { + query: JSON.stringify({ + Query: [ + { + Q1: query + } + ] + }) + } + let token = localStorage.getItem(tokenKey) + let url = token ? '/store/api/ApiQueryProductByAppUser' : '/store/api/ApiQueryProduct' + return request({ + url: url, + method: 'post', + data: body, + cancelToken: source?.token + }) + .then((resp) => { + if (resp.length > 0) { + const data = resp[0] + if (data.datas.length) { + data.datas[0].subDatas = data.datas[0].cmsDatas + const datas = handleDetailQueryRequestData({ + item: data.datas[0], + fields, + itemFields: { + ...itemFields, + ...linkFields + }, + path, + coverSize, + handelEBooK, + + }) + return { + datas, + total: data.totalCount + } + } else { + return { + datas: [], + total: 0 + } + } + } + return { + datas: [], + total: 0 + } + }) + }, + // 鑾峰彇浼樻儬鍒稿垪琛� + getChannelPromoteCodeList(data) { + return request({ + url: '/store/api/ApiGetChannelPromoteCodeList', + method: 'post', + data + }) + }, + + // 鑾峰彇鐢ㄦ埛宸查鍙栫殑浼樻儬鍒稿垪琛� + getPromoteCodeList(data) { + return request({ + url: '/store/api/ApiGetPromoteCodeList', + method: 'post', + data + }) + }, + + // 鑾峰彇鐢ㄦ埛娴忚鎺掕 + getProductViewRank(data) { + return request({ + url: '/store/api/ApiGetProductViewRank', + method: 'post', + data + }) + }, + + // 鑾峰彇鐢ㄦ埛閿�鍞帓琛� + getProductSaleRank(data) { + return request({ + url: '/store/api/ApiGetProductSaleRank', + method: 'post', + data + }) + }, + + // 鑾峰彇鍟嗗搧鍙敤浼樻儬鍒� + getProductPromoteCodeList(data) { + return request({ + url: '/store/api/ApiGetProductPromoteCodeList', + method: 'post', + data + }) + }, + + // 鑾峰彇璁㈠崟鍙敤浼樻儬鍒� + getOrderPromoteCodeList(data) { + return request({ + url: '/store/api/GetOrderPromoteCodeList', + method: 'post', + data + }) + }, + + // 鑾峰彇閿�鍞柟寮忓彲鐢ㄤ紭鎯犲埜 + getSaleMethodPromoteCodeList(data) { + return request({ + url: '/store/api/GetSaleMethodPromoteCodeList', + method: 'post', + data + }) + }, + + // 棰嗗彇浼樻儬鍗� + getPromoteCode(data) { + return request({ + url: '/store/api/ApiGetPromoteCode', + method: 'post', + data + }) + }, + + // 涓鸿鍗曚娇鐢ㄤ紭鎯犲埜 + updateOrderPromoteCode(data) { + return request({ + url: '/store/api/UpdateOrderPromoteCode', + method: 'post', + data + }) + }, + + // 涓洪攢鍞柟寮忎娇鐢ㄤ紭鎯犲埜 + updateSaleMethodPromoteCode(data) { + return request({ + url: '/store/api/UpdateSaleMethodPromoteCode', + method: 'post', + data + }) + }, + + // 閫氳繃璁㈠崟鍙疯幏鍙栬鍗� + getOrderByOrderNum(data) { + return request({ + url: '/store/api/GetOrderByOrderNum', + method: 'post', + data + }) + }, + + // 鍒涘缓璁㈠崟 + initOrder(data) { + return request({ + url: '/store/api/InitOrder', + method: 'post', + data + }) + }, + + // 纭璁㈠崟 + confirmOrder(data) { + return request({ + url: '/store/api/ConfirmOrder', + method: 'post', + data + }) + }, + + // 鍙栨秷璁㈠崟 + cancelOrder(data) { + return request({ + url: '/store/api/CancelOrder', + method: 'post', + data + }) + }, + + // 璧炶祻 + CreateDonateOrder(data) { + return request({ + url: '/store/api/CreateDonateOrder', + method: 'post', + data + }) + }, + + //鑾峰彇鐢ㄦ埛璁㈠崟鍒楄〃 + getUserOrderList(data) { + return request({ + url: '/store/api/GetUserOrderList', + method: 'post', + data + }) + }, + + //鑾峰彇棰戦亾涓嬬殑鍒楄〃 + getStoreChannelList(data) { + return request({ + url: '/store/api/ApiGetStoreChannelList', + method: 'post', + data + }) + }, + + //鑾峰彇璐墿杞� + getShoppingCartProductList(data) { + return request({ + url: '/store/api/ApiGetShoppingCartProductList', + method: 'post', + data + }) + }, + + //娣诲姞鍒拌喘鐗╄溅 + addShoppingCart(data) { + return request({ + url: '/store/api/ApiAddShoppingCart', + method: 'post', + data + }) + }, + + //璐墿杞﹀垹闄ゅ晢鍝� + delShoppingCart(data) { + return request({ + url: '/store/api/ApiDelShoppingCart', + method: 'post', + data + }) + }, + + //浠庤喘鐗╄溅鍒涘缓璁㈠崟 + shoppingCartCreateOrder(data) { + return request({ + url: '/store/api/ApiShoppingCartCreateOrder', + method: 'post', + data + }) + }, + + //鑾峰彇宸茶喘涔扮殑鍟嗗搧鍒楄〃 + getPurchasedProductList(data) { + return request({ + url: '/store/api/ApiGetPurchasedProductList', + method: 'post', + data + }) + }, + + //璋冨彇寰俊鏀粯 + makeWeChatPay(data) { + return request({ + url: '/store/api/MakeWeChatPay', + method: 'post', + data + }) + }, + + //璋冨彇寰俊浜岀淮鐮佹敮浠� + makeWeChatQrPay(data) { + return request({ + url: '/store/api/MakeWeChatQrPay', + method: 'post', + data + }) + }, + + // 鑾峰彇婵�娲荤爜璇︽儏 + getActiveCode(data) { + return request({ + url: '/store/api/ApiGetActiveCode', + method: 'post', + data + }) + }, + + // 浣跨敤婵�娲荤爜 + userActiveCode(data) { + return request({ + url: '/store/api/ApiUseActiveCode', + method: 'post', + data + }) + }, + // 浣跨敤婵�娲荤爜浣跨敤璁板綍 + userActiveCodeList(data) { + return request({ + url: '/store/api/ApiGetUsedActiveCodeList', + method: 'post', + data + }) + }, + + // 鍟嗗搧鏌ヨ绫诲瀷瀛楁鎺ュ彛 + getProductTypeField(data) { + return request({ + url: '/store/api/ApiGetProductTypeField', + method: 'post', + data + }) + }, + + // 鏀惰棌鎴栧姞鍏ヤ功鏋� + addProductLink(data) { + return request({ + url: '/store/api/ApiAddProductLink', + method: 'post', + data + }) + }, + + // 鍙栨秷鏀惰棌鎴栫Щ闄や功鏋� + delProductLink(data) { + return request({ + url: '/store/api/ApiDelProductLink', + method: 'post', + data + }) + }, + + //璐拱鍏嶈垂鍟嗗搧 + MakeFreeOrderPay(data) { + return request({ + url: '/store/api/MakeFreeOrderPay', + method: 'post', + data + }) + }, + + // 鐢宠璁㈠崟寮�绁� + requestOrderInvoice(data) { + return request({ + url: '/store/api/RequestOrderInvoice', + method: 'post', + data + }) + }, + + // 鑾峰彇鐢ㄦ埛閽卞寘 + getUserWallet(data) { + return request({ + url: '/store/api/GetWallet', + method: 'post', + data + }) + }, + // 鑾峰彇鐢ㄦ埛閽卞寘璁板綍 + getWalletHistory(data) { + return request({ + url: '/store/api/GetWalletHistory', + method: 'post', + data + }) + }, + // 閫氳繃閽卞寘鑷姩璐拱 + autoPayWithWallet(data) { + return request({ + url: '/store/api/AutoPayWithWallet', + method: 'post', + data + }) + }, + // 鏌ヨ鍟嗗搧鎵�鍦⊿tore + getProductStore(data) { + return request({ + url: '/store/api/ApiGetProductStore', + method: 'post', + data + }) + }, + //鏍规嵁閿�鍞柟寮忔煡璇㈠晢鍝佷俊鎭� + getProductBySaleMethod(data) { + return request({ + url: '/store/api/ApiGetProductBySaleMethod', + method: 'post', + data + }) + } +} + +export default storeApi -- Gitblit v1.9.1