litian
2024-04-10 0c8505fb7d8a3ba0a3ef6dbcf5a7aa8cdb36105d
子商品跳转
2个文件已修改
138 ■■■■ 已修改文件
assets/js/middleGround/api/store.js 119 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/cart/index.js 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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,36 +77,32 @@
      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 = wx.getStorageSync(tokenKey) ? wx.getStorageSync(tokenKey) : '';
@@ -189,13 +184,9 @@
          Start: 0,
          Size: 9999
        },
        SortQuery: cmsSort
          ? [cmsSort]
          : [
            {
              ProductLinkOrder: 'Asc'
            }
          ],
        SortQuery: cmsSort ? [cmsSort] : [{
          ProductLinkOrder: 'Asc'
        }],
        ProductLinkInfo: [],
        ...itemFields
      }
@@ -261,13 +252,9 @@
        Size: '1'
      },
      'Id=': [`${productId}`],
      SortQuery: sort
        ? [sort]
        : [
          {
            LinkOrder: 'Desc'
          }
        ],
      SortQuery: sort ? [sort] : [{
        LinkOrder: 'Desc'
      }],
      CreateDate: [],
      Description: [],
      Name: [],
@@ -294,11 +281,9 @@
    const body = {
      query: JSON.stringify({
        Query: [
          {
            Q1: query
          }
        ]
        Query: [{
          Q1: query
        }]
      })
    }
@@ -307,11 +292,11 @@
    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]
@@ -664,7 +649,15 @@
      method: 'post',
      data
    })
  },
  //根据销售方式查询商品信息
  getProductBySaleMethod(data) {
    return request({
      url: '/store/api/ApiGetProductBySaleMethod',
      method: 'post',
      data
    })
  }
}
export default storeApi
export default storeApi
pages/cart/index.js
@@ -86,8 +86,6 @@
        totalSize: res.totalSize
      })
      res.datas.forEach(item => {
        console.log(res);
        this.setData({
          bookId: res.id,
          bookName: res.name
@@ -105,13 +103,11 @@
      this.setData({
        shoppingCartData: res.datas
      });
      console.log(this.data.shoppingCartData, 'shoppingCartData');
      if (this.data.shoppingCartData.length === 0) {
        this.setData({
          onDisabled: true
        })
      } else {
        console.log(2222);
        this.setData({
          onDisabled: false
        })
@@ -281,13 +277,20 @@
    console.log(978);
    this.shoppingCartGet()
  },
  onBook(e) {
  async onBook(e) {
    const item = e.currentTarget.dataset.item
    console.log(item);
    console.log(item.productMonWithLinkDto.product.id);
    console.log(item.productMonWithLinkDto.product.name);
    let parentData = null;
    parentData = await app.MG.store.getProductBySaleMethod({
      'saleMethodId': item.saleMethod.id
    })
    console.log(parentData)
    let bookId = item.productMonWithLinkDto.product.id;
    if (parentData.parentProduct.length > 0) {
      bookId = parentData.parentProduct[parentData.parentProduct.length - 1].id;
    }
    wx.navigateTo({
      url: '/packageBookService/pages/bookServices/detail/index?id=' + item.productMonWithLinkDto.product.id + '&name=' + item.productMonWithLinkDto.product.name
      url: '/packageBookService/pages/bookServices/detail/index?id=' + bookId + '&name=' + item.productMonWithLinkDto.product.name
    })
  }
});