Browse Source

统一展示时间

wangkaiyue 5 năm trước cách đây
mục cha
commit
f61e4a6ab4

+ 41 - 0
src/web/staticres/vipsubscribe/js/common.js

@@ -392,4 +392,45 @@ function getVipEndDate(flag, value, endtime) {
     } else {
         return new Date(yearNum, monthNum, lastDay, 23, 59, 59).getTime() / 1000;
     }
+}
+// 格式化金钱的函数
+// s: 金额(number) 必传
+// n: 保留小数的位数(int:0-100)
+function formatMoney(s, n) {
+    if (n === undefined) {
+        n = -1
+    } else {
+        n = n > 0 && n <= 20 ? n : 2;
+    }
+    var intS = parseInt(s)
+    var point = '.'
+    var left;
+    var right;
+    s = parseFloat((s + '').replace(/[^\d\.-]/g, ''))
+    // 没传n,默认(如果为整数,则不保留小数。如果为浮点数,则保留两位小数)
+    if (n === -1) {
+        if (s === intS) {
+            n = 0
+            right = ''
+            point = ''
+        } else {
+            n = 2
+            s = s.toFixed(n);
+            right = s.split('.')[1];
+        }
+        s = s + ''
+        left = s.split('.')[0].split("").reverse();
+    } else {
+        s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(n) + '';
+        left = s.split('.')[0].split('').reverse();
+        right = s.split('.')[1];
+    }
+
+    t = "";
+    for (i = 0; i < left.length; i++) {
+        t += left[i] + ((i + 1) % 3 == 0 && (i + 1) != left.length ? ',' : '');
+    }
+
+    var money = t.split('').reverse().join('') + point + right;
+    return money;
 }

+ 0 - 43
src/web/staticres/vipsubscribe/js/vip_index_new.js

@@ -1,47 +1,4 @@
 $(function () {
-    // 格式化金钱的函数
-    // s: 金额(number) 必传
-    // n: 保留小数的位数(int:0-100)
-    function formatMoney(s, n) {
-        if (n === undefined) {
-            n = -1
-        } else {
-            n = n > 0 && n <= 20 ? n : 2;
-        }
-        var intS = parseInt(s)
-        var point = '.'
-        var left;
-        var right;
-        s = parseFloat((s + '').replace(/[^\d\.-]/g, ''))
-        // 没传n,默认(如果为整数,则不保留小数。如果为浮点数,则保留两位小数)
-        if (n === -1) {
-            if (s === intS) {
-                n = 0
-                right = ''
-                point = ''
-            } else {
-                n = 2
-                s = s.toFixed(n);
-                right = s.split('.')[1];
-            }
-            s = s + ''
-            left = s.split('.')[0].split("").reverse();
-        } else {
-            s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(n) + '';
-            left = s.split('.')[0].split('').reverse();
-            right = s.split('.')[1];
-        }
-
-        t = "";
-        for (i = 0; i < left.length; i++) {
-            t += left[i] + ((i + 1) % 3 == 0 && (i + 1) != left.length ? ',' : '');
-        }
-
-        var money = t.split('').reverse().join('') + point + right;
-        return money;
-    }
-
-
     //项目匹配开关
     var checkedflag = true;
 

+ 5 - 4
src/web/templates/weixin/vipsubscribe/vip_purchase.html

@@ -510,13 +510,14 @@
                     $('.price strong').text('¥0.00');
                 } else {
                     var price = getsubVipOrderPrice(this.areaSelect, this.industrySelect, time, this.price);
+                    var showPrice = formatMoney(price);
                     if (flag === 1) {
-                        $('.price strong').text('¥' + price);
+                        $('.price strong').text('¥' + showPrice);
                     } else if (flag === 2) {
-                        $('.computed_price').html('¥' + price);
+                        $('.computed_price').html('¥' + showPrice);
                     } else {
-                        $('.price strong').text('¥' + price);
-                        $('.computed_price').html('¥' + price);
+                        $('.price strong').text('¥' + showPrice);
+                        $('.computed_price').html('¥' + showPrice);
                     }
 
                 }

+ 8 - 6
src/web/templates/weixin/vipsubscribe/vip_renew.html

@@ -90,7 +90,7 @@
                 <span class="clause-read">我已阅读,理解并接受<a href="/front/staticPage/wx-serviceterms.html">《剑鱼标讯线上购买与服务条款》</a></span>
             </div>
             <div class="price-preview">
-                <span class="preview-label">价格:</span>
+                <span class="preview-label"></span>
                 <span class="preview-content">
                         <span class="billing-list-btn"></span>
                         <span class="billing-price">¥366.50</span>
@@ -465,15 +465,17 @@
         },
         flushPrice: function (time, flag) {
             var price = getsubVipOrderPrice(this.areaSelect, this.industrySelect, time, this.price);
+            var showPrice = formatMoney(price);
             if (flag === 1) {
-                $('.billing-price').text('¥' + price);
+                $('.billing-price').text('¥' + showPrice);
             } else if (flag === 2) {
-                $('.computed_price').html('¥' + price);
+                $('.computed_price').html('¥' + showPrice);
             } else {
-                $('.billing-price').text('¥' + price);
-                $('.computed_price').html('¥' + price);
+                $('.billing-price').text('¥' + showPrice);
+                $('.computed_price').html('¥' + showPrice);
             }
-        }, flushSelectTime() {
+        },
+        flushSelectTime() {
             $(".select_cycle .month").text(this.timeValue);
             if (this.endTime) {
                 var time1 = new Date(this.endTime * 1000).pattern('yyyy年MM月dd日');