Merge branch 'hotfix/pinyin'
Showing
3 changed files
with
35 additions
and
6 deletions
@@ -6,10 +6,10 @@ | @@ -6,10 +6,10 @@ | ||
6 | 'use strict'; | 6 | 'use strict'; |
7 | 7 | ||
8 | const _ = require('lodash'); | 8 | const _ = require('lodash'); |
9 | -const pinyin = require('pinyin-converter'); | ||
10 | 9 | ||
11 | const crypto = global.yoho.crypto; | 10 | const crypto = global.yoho.crypto; |
12 | 11 | ||
12 | +const pinyin = require('../models/province-pinyin'); | ||
13 | const addressApi = require('../models/address-api'); | 13 | const addressApi = require('../models/address-api'); |
14 | 14 | ||
15 | const worldSort = 'abcdefghijklmnopqrstuvwxyz'; | 15 | const worldSort = 'abcdefghijklmnopqrstuvwxyz'; |
@@ -20,14 +20,11 @@ const getAreaListData = (id) => { | @@ -20,14 +20,11 @@ const getAreaListData = (id) => { | ||
20 | 20 | ||
21 | if (id * 1 === 0 && list.length) { | 21 | if (id * 1 === 0 && list.length) { |
22 | _.forEach(list, value => { | 22 | _.forEach(list, value => { |
23 | - value.initial = _.get(pinyin(value.caption, { | ||
24 | - style: pinyin.STYLE_FIRST_LETTER | ||
25 | - }), '[0][0]', 'w'); | 23 | + value.initial = pinyin[value.caption] || 'z'; |
26 | value.pySort = _.indexOf(worldSort, value.initial); | 24 | value.pySort = _.indexOf(worldSort, value.initial); |
27 | }); | 25 | }); |
28 | result.data = list; | 26 | result.data = list; |
29 | } | 27 | } |
30 | - | ||
31 | return result; | 28 | return result; |
32 | }); | 29 | }); |
33 | }; | 30 | }; |
apps/cart/models/province-pinyin.js
0 → 100644
1 | +module.exports = { | ||
2 | + '北京市': 'b', | ||
3 | + '天津市': 't', | ||
4 | + '河北省': 'h', | ||
5 | + '山西省': 's', | ||
6 | + '内蒙古自治区': 'n', | ||
7 | + '辽宁省': 'l', | ||
8 | + '吉林省': 'j', | ||
9 | + '黑龙江省': 'h', | ||
10 | + '上海市': 's', | ||
11 | + '江苏省': 'j', | ||
12 | + '浙江省': 'z', | ||
13 | + '安徽省': 'a', | ||
14 | + '福建省': 'f', | ||
15 | + '江西省': 'j', | ||
16 | + '山东省': 's', | ||
17 | + '河南省': 'h', | ||
18 | + '湖北省': 'h', | ||
19 | + '湖南省': 'h', | ||
20 | + '广东省': 'g', | ||
21 | + '广西壮族自治区': 'g', | ||
22 | + '海南省': 'h', | ||
23 | + '重庆市': 'c', | ||
24 | + '四川省': 's', | ||
25 | + '贵州省': 'g', | ||
26 | + '云南省': 'y', | ||
27 | + '西藏自治区': 'x', | ||
28 | + '陕西省': 's', | ||
29 | + '甘肃省': 'g', | ||
30 | + '青海省': 'q', | ||
31 | + '宁夏回族自治区': 'n', | ||
32 | + '新疆维吾尔自治区': 'x' | ||
33 | +}; |
@@ -56,7 +56,6 @@ | @@ -56,7 +56,6 @@ | ||
56 | "passport-sina": "^0.1.0", | 56 | "passport-sina": "^0.1.0", |
57 | "passport-strategy": "1.x.x", | 57 | "passport-strategy": "1.x.x", |
58 | "passport-weixin": "^0.1.0", | 58 | "passport-weixin": "^0.1.0", |
59 | - "pinyin-converter": "^2.8.1", | ||
60 | "request-ip": "^1.2.2", | 59 | "request-ip": "^1.2.2", |
61 | "request-promise": "^3.0.0", | 60 | "request-promise": "^3.0.0", |
62 | "serve-favicon": "^2.3.0", | 61 | "serve-favicon": "^2.3.0", |
-
Please register or login to post a comment