litian
2024-10-15 1a5e46e6955225675d21fe04962e82b37e7890ed
assets/js/middleGround/api/store.js
@@ -306,6 +306,7 @@
            data.datas[0].subDatas = data.datas[0].cmsDatas
            const datas = handleDetailQueryRequestData({
              productId,
              item: data.datas[0],
              fields,
              itemFields: {
@@ -333,7 +334,192 @@
        }
      })
  },
  // 获取商品详情(无 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: [],
        TypeId: [],
        RefCode: [],
        // Description: [],
        // ChildrenCount: [],
        // ChildrenFolderCount: [],
        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({
            productId,
            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({
@@ -660,7 +846,23 @@
      method: 'post',
      data
    })
  }
  },
  // 积分兑换
  newOrderPay(data) {
    return request({
      url: '/store/api/NewOrderPay',
      method: 'post',
      data
    })
  },
  // 删除积分订单
  delOrderPay(data) {
    return request({
      url: '/store/api/DelOrderPay',
      method: 'post',
      data
    })
  },
}
export default storeApi