sbd-npm 1.2.18 → 1.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constant.js +15 -1
- package/package.json +1 -1
- package/util.js +32 -2
package/constant.js
CHANGED
@@ -224,7 +224,7 @@ const MenuList = [
|
|
224
224
|
{'key': 'other_bond', 'name': '地方债数据', 'url': '/fbe79af9b125b8952d05801dcf1ea4c1'},
|
225
225
|
{'key': 'other_convertible_bond', 'name': '可转债数据', 'url': '/cf21d0fe6fe66c94488dab9cfef16c0a'},
|
226
226
|
{'key': 'other_fortune500', 'name': '财富500强', 'url': '/04d4033d33ea4c0cdd0d874dde23ef2c'},
|
227
|
-
{'key': 'other_material', 'name': '
|
227
|
+
{'key': 'other_material', 'name': 'WIKI', 'url': '/384dd1f2f7cbfc1739f78d047ef22350'},
|
228
228
|
]
|
229
229
|
},
|
230
230
|
];
|
@@ -244,3 +244,17 @@ const ClassifyList = [
|
|
244
244
|
'创业板指',
|
245
245
|
'新股',
|
246
246
|
];
|
247
|
+
|
248
|
+
const IndexList = [
|
249
|
+
{'code': 'SH000300', 'name': '沪深300', 'is_industry': 1},
|
250
|
+
{'code': 'SH000016', 'name': '上证50', 'is_industry': 0},
|
251
|
+
{'code': 'SH000688', 'name': '科创50', 'is_industry': 0},
|
252
|
+
{'code': 'SH000903', 'name': '中证100', 'is_industry': 0},
|
253
|
+
{'code': 'SH000905', 'name': '中证500', 'is_industry': 1},
|
254
|
+
{'code': 'SH000906', 'name': '中证800', 'is_industry': 1},
|
255
|
+
{'code': 'SH000852', 'name': '中证1000', 'is_industry': 1},
|
256
|
+
{'code': 'SZ399303', 'name': '国证2000', 'is_industry': 0},
|
257
|
+
{'code': 'hsci', 'name': '恒生综合指数', 'is_industry': 1},
|
258
|
+
{'code': 'hstech', 'name': '恒生科技指数', 'is_industry': 0},
|
259
|
+
{'code': 'sp500', 'name': '标普500指数', 'is_industry': 1},
|
260
|
+
];
|
package/package.json
CHANGED
package/util.js
CHANGED
@@ -354,7 +354,7 @@ const Util = {
|
|
354
354
|
if ($("#price_change_" + code).length) {
|
355
355
|
let price_cls = Util.text_color(item["price"], item["previous_price"]);
|
356
356
|
$(".price_" + code).each(function () {
|
357
|
-
$(this).html("<b class='" + price_cls + "'>" + item["price"] + "</b>");
|
357
|
+
$(this).html("<b class='" + price_cls + "'>" + Util.to_float(item["price"], 2) + "</b>");
|
358
358
|
});
|
359
359
|
$("#price_change_" + code).html(Util.year_price_rate(item["price"], item["previous_price"]));
|
360
360
|
} else {
|
@@ -1276,6 +1276,25 @@ const Util = {
|
|
1276
1276
|
$("#" + component_id).html(html.join(""));
|
1277
1277
|
},
|
1278
1278
|
|
1279
|
+
/**
|
1280
|
+
* 初始指数组件
|
1281
|
+
* @param component_id
|
1282
|
+
* @param is_industry
|
1283
|
+
*/
|
1284
|
+
init_index_code_component: function (component_id, is_industry = 0) {
|
1285
|
+
let element_id = component_id.replace("_div", "");
|
1286
|
+
let html = [];
|
1287
|
+
html.push('<label for="', element_id, '"></label>');
|
1288
|
+
html.push('<select id="', element_id, '" class="form-control">');
|
1289
|
+
IndexList.forEach(function (item) {
|
1290
|
+
if (is_industry === 0 || (is_industry === 1 && item["is_industry"] === 1)) {
|
1291
|
+
html.push('<option ', (item["code"] === "SH000906" ? "selected" : ""), ' value="', item["code"], '">', item["name"], '</option>');
|
1292
|
+
}
|
1293
|
+
});
|
1294
|
+
html.push('</select>');
|
1295
|
+
$("#" + component_id).html(html.join(""));
|
1296
|
+
},
|
1297
|
+
|
1279
1298
|
/**
|
1280
1299
|
* 当前时间戳
|
1281
1300
|
* @returns {number}
|
@@ -2645,7 +2664,18 @@ const Util = {
|
|
2645
2664
|
to_float: function (digit, fraction = 2) {
|
2646
2665
|
if (digit) {
|
2647
2666
|
fraction = Math.pow(10, fraction);
|
2648
|
-
|
2667
|
+
digit = Math.round(digit * fraction) / fraction;
|
2668
|
+
if (fraction === 100) {
|
2669
|
+
let digit_arr = digit.toString().split(".");
|
2670
|
+
if (digit_arr.length > 1) {
|
2671
|
+
if (digit_arr[1].length === 1) {
|
2672
|
+
return (digit + "0");
|
2673
|
+
}
|
2674
|
+
} else {
|
2675
|
+
return (digit + ".00");
|
2676
|
+
}
|
2677
|
+
}
|
2678
|
+
return digit;
|
2649
2679
|
}
|
2650
2680
|
return 0;
|
2651
2681
|
},
|