xiaohaizhao vor 2 Jahren
Ursprung
Commit
3029afacc4
2 geänderte Dateien mit 12 neuen und 7 gelöschten Zeilen
  1. 11 6
      select/product/index.js
  2. 1 1
      select/product/index.wxml

+ 11 - 6
select/product/index.js

@@ -1,6 +1,6 @@
 const _Http = getApp().globalData.http,
 	file = require("../../utils/FormatTheAttachment");
-
+import currency from "../../utils/currency";
 Page({
 	data: {
 		loading: true,
@@ -44,17 +44,22 @@ Page({
 				title: res.msg,
 				icon: "none"
 			})
+			const CNY = num => currency(num, {
+				symbol: "¥",
+				precision: 2
+			}).format();
+			let newPrice = this.data.newPrice,
+				oldPrice = this.data.oldPrice;
 			res.data = res.data.map(value => {
 				if (value.attinfos.length != 0) {
 					value.attinfos = file.fileList(value.attinfos)
 					let image = value.attinfos.find(v => v.fileType == "image");
 					value.cover = image ? image.cover : "";
 				}
-				value.gradeprice && (value.gradeprice = (value.gradeprice - 0).toFixed(2));
-				value.marketprice && (value.marketprice = (value.marketprice - 0).toFixed(2));
-				value.price && (value.price = (value.price - 0).toFixed(2));
-				value.oldprice && (value.oldprice = (value.oldprice - 0).toFixed(2));
-				value.contractprice && (value.contractprice = (value.contractprice - 0).toFixed(2));
+				
+				if (newPrice) value.newPrice = CNY(value[newPrice] || 0);
+				if (oldPrice) value.oldPrice = CNY(value[oldPrice] || 0);
+
 				value.brandName = value.brand.map(name => name.brandname)
 				value.tradefields = value.tradefield.map(name => name.tradefield)
 				return value;

+ 1 - 1
select/product/index.wxml

@@ -24,7 +24,7 @@
                     领域:{{item.tradefields}}
                 </view>
                 <view class="price line-1">
-                    价格:<text class="num">¥{{item[newPrice]}}元</text><text wx:if="{{item[newPrice]<item[oldPrice]}}" style="text-decoration:line-through; color:#999;">/{{item[oldPrice]}}</text>
+                    价格:<text class="num">{{item.newPrice}}元</text><text wx:if="{{item.oldPrice}}" style="text-decoration:line-through; color:#999;">/{{item.oldPrice}}</text>
                 </view>
             </view>
         </view>