wxs 语法的应用
<template name="shoppingcart">
/**
*使用wxs导出指定模块
*module = 'name' 导出的包名称
*
*/
<wxs module="countPrice">
var condimentPrice = function(orderItem) {
var total = orderItem.itemNetSalesAmount;
if(orderItem.condiment.length > 0){
for (var i = 0; i < orderItem.condiment.length;i++) {
total += orderItem.condiment[i].itemNetSalesAmount; // += 单价
}
}
return total/100; //返回值
}
module.exports = {
condimentPrice:condimentPrice
}
</wxs>
<block>
<view>
{{shoppingcart.condimentPrice(orderItem)}}
</view>
</block>
</template>