From 366de5b4636679392a1e3d2984fc23bd5eaa5ac3 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期二, 27 八月 2024 17:48:03 +0800 Subject: [PATCH] wenti --- assets/js/middleGround/api/store.js | 318 ++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 253 insertions(+), 65 deletions(-) diff --git a/assets/js/middleGround/api/store.js b/assets/js/middleGround/api/store.js index aecc4a2..d842309 100644 --- a/assets/js/middleGround/api/store.js +++ b/assets/js/middleGround/api/store.js @@ -1,6 +1,12 @@ import request from "../../../request/index"; -import { tokenKey, goodsStore } from '../../config' -import { handleQueryResourceListData, handleDetailQueryRequestData } from '../tool' +import { + tokenKey, + goodsStore +} from '../../config' +import { + handleQueryResourceListData, + handleDetailQueryRequestData +} from '../tool' const storeApi = { /* **鑾峰彇鍟嗗搧鍒楄〃** @@ -42,16 +48,9 @@ Start: paging.start || '0', Size: paging.size || '10' }, - SortQuery: - sort?.length == 0 - ? [] - : sort - ? [sort] - : [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: sort?.length == 0 ? [] : sort ? [sort] : [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], @@ -78,39 +77,35 @@ 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: [] - } + 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 - } - ] + Query: [{ + Q1: query + }] }) } - let token = localStorage.getItem(tokenKey) + let token = wx.getStorageSync(tokenKey) ? wx.getStorageSync(tokenKey) : ''; let url = token ? '/store/api/ApiQueryProductByAppUser' : '/store/api/ApiQueryProduct' return request({ url: url, @@ -180,6 +175,7 @@ Icon: [], TypeId: [], RefCode: [], + Description: [], ChildrenCount: [], ChildrenFolderCount: [], CreateDate: [], @@ -189,13 +185,9 @@ Start: 0, Size: 9999 }, - SortQuery: cmsSort - ? [cmsSort] - : [ - { - ProductLinkOrder: 'Asc' - } - ], + SortQuery: cmsSort ? [cmsSort] : [{ + ProductLinkOrder: 'Asc' + }], ProductLinkInfo: [], ...itemFields } @@ -209,6 +201,7 @@ Icon: [], TypeId: [], RefCode: [], + Description: [], ChildrenCount: [], ChildrenFolderCount: [], CreateDate: [], @@ -233,6 +226,7 @@ Icon: [], TypeId: [], RefCode: [], + Description: [], LinkTypes: [linkType.linkType], PageQuery: { Start: 0, @@ -261,18 +255,15 @@ Size: '1' }, 'Id=': [`${productId}`], - SortQuery: sort - ? [sort] - : [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: sort ? [sort] : [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], Icon: [], RefCode: [], + Description: [], TypeId: [], SysType: [], State: [], @@ -294,25 +285,25 @@ const body = { query: JSON.stringify({ - Query: [ - { - Q1: query - } - ] + Query: [{ + Q1: query + }] }) } - let token = localStorage.getItem(tokenKey) + + let token = wx.getStorageSync(tokenKey) ? wx.getStorageSync(tokenKey) : ''; let url = token ? '/store/api/ApiQueryProductByAppUser' : '/store/api/ApiQueryProduct' return request({ - url: url, - method: 'post', - data: body, - cancelToken: source?.token - }) + 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], @@ -342,7 +333,196 @@ } }) }, + // 鑾峰彇鍟嗗搧璇︽儏(鏃� ChildrenCount ChildrenFolderCount ) 姝ゆ帴鍙d负婊¤冻涓婅堪瑕佹眰娣诲姞锛屼笉鏄腑鍙板師鏈� + 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 = wx.getStorageSync(tokenKey) ? wx.getStorageSync(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({ @@ -661,7 +841,15 @@ method: 'post', data }) + }, + //鏍规嵁閿�鍞柟寮忔煡璇㈠晢鍝佷俊鎭� + getProductBySaleMethod(data) { + return request({ + url: '/store/api/ApiGetProductBySaleMethod', + method: 'post', + data + }) } } -export default storeApi +export default storeApi \ No newline at end of file -- Gitblit v1.9.1