产品页开发
有了首页,开发一个包含各目录的产品页,也就是小程序里的分类。Moqui可以设置多级目录。网易严选的小程序是三层目录,我们仅安排两层。子目录可以归属于几个不同的你目录,比如婴儿衣服,即可以放在服装下,还可以放在母婴下。
<service verb="get" noun="StoreProducts">
<in-parameters>
<parameter name="productStoreId" required="true"/>
</in-parameters>
<out-parameters>
<parameter name="productCategories" type="List"/>
</out-parameters>
<actions>
<entity-find entity-name="mantle.product.store.ProductStoreCategory" list="productsCategoryList" cache="true">
<date-filter/>
<econdition field-name="productStoreId"/>
<econdition field-name="storeCategoryTypeEnumId" value="PsctBrowseRoot"/>
<order-by field-name="sequenceNum,-fromDate"/>
</entity-find>
<set field="productCategories" from="[]"/>
<iterate list="productsCategoryList" entry="productsCategory">
<entity-find-one entity-name="mantle.product.category.ProductCategory" value-field="productCategory" cache="true">
<field-map field-name="productCategoryId" from="productsCategory.productCategoryId"/>
</entity-find-one>
<if condition="productCategory != null">
<set field="CategoryImageUrl" from="null"/>
<entity-find-one entity-name="mantle.product.category.ProductCategoryContent" value-field="CategoryImageUrl" cache="true">
<date-filter/>
<field-map field-name="productCategoryId" from="productsCategory.productCategoryId"/>
<field-map field-name="categoryContentTypeEnumId" value="PcctImageUrl"/>
</entity-find-one>
<set field="rollupList" from="null"/>
<entity-find entity-name="mantle.product.category.ProductCategoryRollup" list="rollupList" cache="true">
<date-filter/><econdition field-name="parentProductCategoryId" from="productsCategory.productCategoryId"/>
<order-by field-name="sequenceNum,-fromDate"/>
</entity-find>
<set field="subCategoryList" from="[]"/>
<iterate list="rollupList" entry="rollup">
<entity-find-one entity-name="mantle.product.category.ProductCategory" value-field="subProductCategory" cache="true">
<field-map field-name="productCategoryId" from="rollup.productCategoryId"/></entity-find-one>
<set field="Image" from="null"/>
<entity-find-one entity-name="mantle.product.category.ProductCategoryContent" value-field="Image" cache="true">
<date-filter/>
<field-map field-name="productCategoryId" from="rollup.productCategoryId"/>
<field-map field-name="categoryContentTypeEnumId" value="PcctImageUrl"/>
</entity-find-one>
<script>subCategoryList.add([productCategoryId:subProductCategory.productCategoryId, pseudoId:subProductCategory.pseudoId,
categoryName:subProductCategory.categoryName, description:subProductCategory.description,
categoryImageUrl:Image?.contentLocation, sequenceNum:rollup.sequenceNum])
</script>
</iterate>
<script>
productCategories.add([productCategoryId:productCategory.productCategoryId, pseudoId:productCategory.pseudoId,
categoryName:productCategory.categoryName, description:productCategory.description,
categoryImageUrl:CategoryImageUrl?.contentLocation, sequenceNum:productsCategory.sequenceNum, subCategoryList:subCategoryList])
</script>
</if>
</iterate>
</actions>
</service>
代码很容易看懂,首先用storeCategoryTypeEnumId找出产品父目录,遍历父目录、子目录,找出每个子目录的缩略图。
最后小程序的展示,参考网易严选小程序的分类,要做成那样的三层目录,再嵌套一层就是了。
其它各目录下的产品,和点击产品后的产品详情页,参考PopRestStore的ProductServices里的实现就是了。
如果要分页,参照PopRestStore的ProductServices里search products 或get categoryProducts里的productListCount, productListPageIndex, productListPageSize, productListPageMaxIndex, productListPageRangeLow, productListPageRangeHigh就是。