浏览代码

商品详情格式化价格

xiaohaizhao 2 年之前
父节点
当前提交
9d687bdce4
共有 2 个文件被更改,包括 13 次插入3 次删除
  1. 11 1
      packageA/market/detail.js
  2. 2 2
      packageA/market/detail.wxml

+ 11 - 1
packageA/market/detail.js

@@ -3,6 +3,7 @@ let sa_brandid = null;
 import {
 	fileList
 } from "../../utils/FormatTheAttachment";
+import currency from "../../utils/currency";
 
 Page({
 	data: {
@@ -45,9 +46,18 @@ Page({
 				return;
 			}
 			this.handleFiles(res.data[0].attinfos)
+			const CNY = sum => currency(sum, {
+				symbol: "¥",
+				precision: 2
+			}).format();
+
 			this.setData({
 				detail: res.data[0],
-				rows: res.data,
+				rows: res.data.map(v => {
+					v.gradeprice = CNY(v.gradeprice);
+					v.marketprice = CNY(v.marketprice);
+					return v
+				}),
 				loading: false
 			})
 		})

+ 2 - 2
packageA/market/detail.wxml

@@ -21,8 +21,8 @@
   </view>
   <view class="offer">
     <view>
-      <text class="price">{{detail.gradeprice}}</text>
-      <text class="old-price">{{detail.marketprice}}</text>
+      <text class="price">{{detail.gradeprice}}</text>
+      <text class="old-price">{{detail.marketprice}}</text>
     </view>
     <text class="unit">单位/{{detail.unitname}}</text>
   </view>