bxs-tools-ui 3.2.0 → 3.3.0
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/README.md +20 -20
- package/es/add-and-take/index.css +1 -1
- package/es/add-and-take/index.js +283 -64
- package/es/adjust-baoe/index.css +1 -1
- package/es/adjust-baoe/index.js +444 -195
- package/es/business-card/index.css +1 -1
- package/es/business-card/index.js +1 -0
- package/es/canvas-poster/index.css +1 -1
- package/es/canvas-poster/index.js +1 -0
- package/es/index.css +1 -1
- package/es/index.js +936 -824
- package/es/insure-calculate/index.css +1 -1
- package/es/insure-calculate/index.js +438 -265
- package/es/person-info/index.css +1 -1
- package/es/person-info/index.js +296 -1370
- package/es/product-info/index.css +1 -1
- package/es/product-info/index.js +644 -548
- package/es/share-sheet/index.css +1 -1
- package/es/share-sheet/index.js +313 -21
- package/es/utils/index.js +530 -429
- package/lib/add-and-take/index.css +1 -1
- package/lib/add-and-take/index.js +283 -64
- package/lib/adjust-baoe/index.css +1 -1
- package/lib/adjust-baoe/index.js +441 -194
- package/lib/business-card/index.css +1 -1
- package/lib/business-card/index.js +1 -0
- package/lib/canvas-poster/index.css +1 -1
- package/lib/canvas-poster/index.js +1 -0
- package/lib/index.css +1 -1
- package/lib/index.js +939 -826
- package/lib/insure-calculate/index.css +1 -1
- package/lib/insure-calculate/index.js +438 -268
- package/lib/person-info/index.css +1 -1
- package/lib/person-info/index.js +295 -1372
- package/lib/product-info/index.css +1 -1
- package/lib/product-info/index.js +645 -550
- package/lib/share-sheet/index.css +1 -1
- package/lib/share-sheet/index.js +313 -25
- package/lib/utils/index.js +531 -433
- package/package.json +9 -7
- package/packages/add-and-take/components/interest-form.less +144 -0
- package/packages/add-and-take/components/interest-form.vue +179 -179
- package/packages/add-and-take/components/interest-items.less +87 -0
- package/packages/add-and-take/components/interest-items.vue +67 -80
- package/packages/add-and-take/components/interest-table.less +111 -0
- package/packages/add-and-take/components/interest-table.vue +31 -31
- package/packages/add-and-take/constant.ts +2 -2
- package/packages/add-and-take/demo/index.vue +89 -86
- package/packages/add-and-take/handler.ts +52 -57
- package/packages/add-and-take/index.less +69 -0
- package/packages/add-and-take/index.vue +156 -156
- package/packages/add-and-take/readme.md +87 -98
- package/packages/adjust-baoe/demo/index.vue +37 -47
- package/packages/adjust-baoe/index.less +125 -0
- package/packages/adjust-baoe/index.vue +134 -147
- package/packages/adjust-baoe/readme.md +35 -45
- package/packages/business-card/demo/index.vue +7 -7
- package/packages/business-card/index.less +100 -0
- package/packages/business-card/index.vue +18 -21
- package/packages/business-card/readme.md +46 -53
- package/packages/bxs-utils/demo/index.vue +2 -2
- package/packages/bxs-utils/index.ts +5 -5
- package/packages/bxs-utils/planbook/common.ts +56 -92
- package/packages/bxs-utils/planbook/index.ts +4 -4
- package/packages/bxs-utils/planbook/insurance.ts +137 -127
- package/packages/bxs-utils/planbook/person.ts +143 -147
- package/packages/bxs-utils/planbook/product.ts +473 -509
- package/packages/bxs-utils/readme.md +94 -84
- package/packages/bxs-utils/trade/index.js +1 -1
- package/packages/bxs-utils/trade/insureCalculate.js +91 -204
- package/packages/canvas-poster/demo/index.vue +9 -13
- package/packages/canvas-poster/index.less +5 -0
- package/packages/canvas-poster/index.vue +68 -79
- package/packages/canvas-poster/readme.md +106 -109
- package/packages/index.ts +1 -1
- package/packages/insure-calculate/demo/index.vue +20 -20
- package/packages/insure-calculate/index.less +366 -0
- package/packages/insure-calculate/index.vue +305 -329
- package/packages/insure-calculate/readme.md +99 -106
- package/packages/person-info/crm-popup.vue +81 -80
- package/packages/person-info/demo/index.vue +25 -37
- package/packages/person-info/index-inline.less +11 -0
- package/packages/person-info/index.vue +53 -83
- package/packages/person-info/readme.md +109 -115
- package/packages/planbook-input/components/footer.less +54 -0
- package/packages/planbook-input/components/footer.vue +8 -64
- package/packages/planbook-input/components/handler.js +33 -44
- package/packages/planbook-input/components/product-table.less +235 -0
- package/packages/planbook-input/components/product-table.vue +114 -108
- package/packages/planbook-input/demo/index.vue +3 -3
- package/packages/planbook-input/helper.js +852 -465
- package/packages/planbook-input/index.less +30 -0
- package/packages/planbook-input/index.vue +86 -103
- package/packages/planbook-input/readme.md +72 -90
- package/packages/product-info/demo/constant.js +1 -1
- package/packages/product-info/demo/index.vue +31 -43
- package/packages/product-info/index.less +271 -0
- package/packages/product-info/index.vue +198 -210
- package/packages/product-info/readme.md +72 -75
- package/packages/share-sheet/constant.js +4 -4
- package/packages/share-sheet/demo/index.vue +10 -10
- package/packages/share-sheet/handler.js +14 -14
- package/packages/share-sheet/index.less +201 -0
- package/packages/share-sheet/index.vue +39 -39
- package/packages/share-sheet/readme.md +121 -127
- package/src/api/add-and-take.js +45 -0
- package/src/api/adjust-baoe.js +16 -0
- package/src/api/index.js +6 -0
- package/src/api/planbook.js +93 -0
- package/src/api/request.js +211 -0
- package/src/api/trade.js +56 -0
- package/src/api/user.js +18 -0
- package/src/components/common/common-age-birthday.less +66 -0
- package/src/components/common/common-age-birthday.vue +27 -95
- package/src/components/common/common-popup.less +81 -0
- package/src/components/common/common-popup.vue +12 -96
- package/src/components/common/common-radio.less +75 -0
- package/src/components/common/common-radio.vue +13 -91
- package/src/components/common/common-select.less +13 -0
- package/src/components/common/common-select.vue +21 -38
- package/src/components/common/common-title.less +115 -0
- package/src/components/common/common-title.vue +24 -24
- package/src/js/loading.js +6 -6
- package/src/js/md5Token.js +38 -44
- package/src/js/utils.js +45 -53
- package/src/js/variables.js +47 -25
- package/src/style/base.less +18 -0
- package/src/style/color.less +40 -0
- package/src/style/variables.less +21 -42
- package/packages/add-and-take/api.ts +0 -70
- package/packages/add-and-take/components/interest-form.css +0 -146
- package/packages/add-and-take/components/interest-items.css +0 -87
- package/packages/add-and-take/components/interest-table.css +0 -113
- package/packages/add-and-take/index.css +0 -70
- package/packages/adjust-baoe/index.css +0 -123
- package/packages/business-card/index.css +0 -101
- package/packages/canvas-poster/index.css +0 -5
- package/packages/insure-calculate/index.css +0 -368
- package/packages/planbook-input/api.js +0 -29
- package/packages/planbook-input/components/product-table.css +0 -236
- package/packages/planbook-input/index.css +0 -31
- package/packages/product-info/index.css +0 -264
- package/packages/share-sheet/index.css +0 -203
- package/src/components/common/common-title.css +0 -116
- package/src/js/request.js +0 -64
- package/src/style/apply.css +0 -25
- package/src/style/base.css +0 -36
- package/src/style/color.css +0 -74
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { Dialog } from 'vant'
|
|
2
|
+
import { showLoading as showGlobalLoading, hideLoading as hideGlobalLoading } from '../js/loading.js'
|
|
3
|
+
import { PLANBOOK_API_HOSTNAME } from '../js/variables.js'
|
|
4
|
+
|
|
5
|
+
const options = {
|
|
6
|
+
baseURL: PLANBOOK_API_HOSTNAME,
|
|
7
|
+
withCredentials: true,
|
|
8
|
+
timeout: 10000,
|
|
9
|
+
headers: {
|
|
10
|
+
'X-Requested-With': 'XMLHttpRequest'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let loadingTimer = null
|
|
15
|
+
const showRequestLoading = () => {
|
|
16
|
+
if (loadingTimer) {
|
|
17
|
+
clearTimeout(loadingTimer)
|
|
18
|
+
}
|
|
19
|
+
loadingTimer = setTimeout(() => {
|
|
20
|
+
showGlobalLoading()
|
|
21
|
+
}, 300)
|
|
22
|
+
}
|
|
23
|
+
const hideRequestLoading = () => {
|
|
24
|
+
if (loadingTimer) {
|
|
25
|
+
hideGlobalLoading()
|
|
26
|
+
}
|
|
27
|
+
if (loadingTimer) {
|
|
28
|
+
clearTimeout(loadingTimer)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const normalizeMethod = method => (method || 'get').toUpperCase()
|
|
33
|
+
|
|
34
|
+
const serializeParams = params => {
|
|
35
|
+
if (!params) {
|
|
36
|
+
return ''
|
|
37
|
+
}
|
|
38
|
+
const queryParts = []
|
|
39
|
+
|
|
40
|
+
Object.keys(params).forEach(key => {
|
|
41
|
+
const value = params[key]
|
|
42
|
+
|
|
43
|
+
if (value === undefined || value === null) {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
value.forEach(item => {
|
|
49
|
+
queryParts.push(`${encodeURIComponent(key)}=${encodeURIComponent(item)}`)
|
|
50
|
+
})
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
queryParts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
return queryParts.join('&')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const isAbsoluteUrl = url => /^https?:\/\//.test(url)
|
|
61
|
+
|
|
62
|
+
const buildUrl = (baseURL, url, params) => {
|
|
63
|
+
const queryString = serializeParams(params)
|
|
64
|
+
const requestUrl = isAbsoluteUrl(url) ? url : `${baseURL}${url}`
|
|
65
|
+
|
|
66
|
+
if (!queryString) {
|
|
67
|
+
return requestUrl
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return `${requestUrl}${requestUrl.includes('?') ? '&' : '?'}${queryString}`
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const isPlainObject = value => Object.prototype.toString.call(value) === '[object Object]'
|
|
74
|
+
|
|
75
|
+
const buildBody = (data, headers) => {
|
|
76
|
+
if (data === undefined || data === null) {
|
|
77
|
+
return undefined
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (data instanceof FormData || data instanceof Blob || typeof data === 'string') {
|
|
81
|
+
return data
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (isPlainObject(data) || Array.isArray(data)) {
|
|
85
|
+
if (!headers['Content-Type']) {
|
|
86
|
+
headers['Content-Type'] = 'application/json'
|
|
87
|
+
}
|
|
88
|
+
return JSON.stringify(data)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return data
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const parseResponse = async response => {
|
|
95
|
+
const contentType = response.headers.get('content-type') || ''
|
|
96
|
+
|
|
97
|
+
if (contentType.includes('application/json')) {
|
|
98
|
+
return response.json()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const text = await response.text()
|
|
102
|
+
if (!text) {
|
|
103
|
+
return {}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
return JSON.parse(text)
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return { data: text }
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const createTimeoutError = timeout => {
|
|
114
|
+
const error = new Error(`timeout of ${timeout}ms exceeded`)
|
|
115
|
+
error.name = 'TimeoutError'
|
|
116
|
+
return error
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const request = async config => {
|
|
120
|
+
const {
|
|
121
|
+
url,
|
|
122
|
+
baseURL = options.baseURL,
|
|
123
|
+
method = 'get',
|
|
124
|
+
params,
|
|
125
|
+
data,
|
|
126
|
+
headers = {},
|
|
127
|
+
isIgnoreLoading,
|
|
128
|
+
timeout = options.timeout,
|
|
129
|
+
withCredentials = options.withCredentials,
|
|
130
|
+
returnFullResponse
|
|
131
|
+
} = config
|
|
132
|
+
|
|
133
|
+
if (!isIgnoreLoading) {
|
|
134
|
+
showRequestLoading()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const requestHeaders = {
|
|
138
|
+
...options.headers,
|
|
139
|
+
...headers
|
|
140
|
+
}
|
|
141
|
+
let timeoutId = null
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
const fetchPromise = fetch(buildUrl(baseURL, url, params), {
|
|
145
|
+
method: normalizeMethod(method),
|
|
146
|
+
headers: requestHeaders,
|
|
147
|
+
body: normalizeMethod(method) === 'GET' ? undefined : buildBody(data, requestHeaders),
|
|
148
|
+
credentials: withCredentials ? 'include' : 'same-origin'
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
const response = await Promise.race([
|
|
152
|
+
fetchPromise,
|
|
153
|
+
new Promise((resolve, reject) => {
|
|
154
|
+
timeoutId = setTimeout(() => {
|
|
155
|
+
reject(createTimeoutError(timeout))
|
|
156
|
+
}, timeout)
|
|
157
|
+
})
|
|
158
|
+
])
|
|
159
|
+
|
|
160
|
+
const res = await parseResponse(response)
|
|
161
|
+
|
|
162
|
+
if (!response.ok) {
|
|
163
|
+
const error = new Error(`Request failed with status code ${response.status}`)
|
|
164
|
+
error.response = {
|
|
165
|
+
status: response.status,
|
|
166
|
+
data: res
|
|
167
|
+
}
|
|
168
|
+
throw error
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const { code } = res
|
|
172
|
+
if (['002012', '002013', '002015'].includes(code)) {
|
|
173
|
+
const messageMap = {
|
|
174
|
+
m002012: '当前账号因操作频繁被限制,请明天再试。感谢理解',
|
|
175
|
+
m002013: '您的操作频率较高,已达到今日生成上限。请稍后再试或明天继续使用,感谢您的理解!',
|
|
176
|
+
m002015: '您今天做了太多计划书了,休息一下,明天再来吧'
|
|
177
|
+
}
|
|
178
|
+
const message = messageMap[`m${code}`]
|
|
179
|
+
if (message) {
|
|
180
|
+
Dialog.alert({
|
|
181
|
+
message,
|
|
182
|
+
confirmButtonText: '知道了',
|
|
183
|
+
confirmButtonColor: '#0A64FE'
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
return Promise.reject({ code, message })
|
|
187
|
+
}
|
|
188
|
+
if (code === 401 || res.status === 401) {
|
|
189
|
+
gotoLogin()
|
|
190
|
+
return Promise.reject('status: 401')
|
|
191
|
+
}
|
|
192
|
+
// 兼容老接口,-1表示未登录
|
|
193
|
+
if (res.success && res.data === -1) {
|
|
194
|
+
gotoLogin()
|
|
195
|
+
return Promise.reject('login: -1')
|
|
196
|
+
}
|
|
197
|
+
return returnFullResponse ? res : res.data
|
|
198
|
+
} catch (error) {
|
|
199
|
+
if (error.response && error.response.status == 401) {
|
|
200
|
+
gotoLogin()
|
|
201
|
+
}
|
|
202
|
+
return Promise.reject(error)
|
|
203
|
+
} finally {
|
|
204
|
+
if (timeoutId) {
|
|
205
|
+
clearTimeout(timeoutId)
|
|
206
|
+
}
|
|
207
|
+
hideRequestLoading()
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export default request
|
package/src/api/trade.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import request from './request'
|
|
2
|
+
import { INSURANCE2A_API_HOSTNAME } from '../js/variables.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* C 端地区码(POST `…/api/product/data/getAreaCode`)
|
|
6
|
+
* @param {object} data 如 `{ pageType, productId }`
|
|
7
|
+
* @param {string} [userUuid] 有则拼到 query(与原先 `getApiUrl(getAreaCodeApi)` 行为一致)
|
|
8
|
+
*/
|
|
9
|
+
export function getAddress(data, userUuid) {
|
|
10
|
+
let url = `${INSURANCE2A_API_HOSTNAME}/api/product/data/getAreaCode`
|
|
11
|
+
if (userUuid && url.indexOf('userUuid') === -1) {
|
|
12
|
+
if (url.indexOf('?') === -1) {
|
|
13
|
+
url += `?userUuid=${encodeURIComponent(userUuid)}`
|
|
14
|
+
} else {
|
|
15
|
+
url += `&userUuid=${encodeURIComponent(userUuid)}`
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return request({
|
|
19
|
+
url,
|
|
20
|
+
method: 'post',
|
|
21
|
+
data,
|
|
22
|
+
headers: {
|
|
23
|
+
Accept: 'application/json, text/plain, */*',
|
|
24
|
+
'Content-Type': 'application/json'
|
|
25
|
+
},
|
|
26
|
+
isIgnoreLoading: false,
|
|
27
|
+
returnFullResponse: true
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 险种保费试算 `/api/product/data/calculate`
|
|
33
|
+
*/
|
|
34
|
+
export function postProductDataCalculate(urlParams, postParams) {
|
|
35
|
+
let path = '/api/product/data/calculate'
|
|
36
|
+
if (urlParams && urlParams.uuid) {
|
|
37
|
+
path += `?userUuid=${encodeURIComponent(urlParams.uuid)}`
|
|
38
|
+
} else if (urlParams && urlParams.openId) {
|
|
39
|
+
path += `?userUuid=${encodeURIComponent(urlParams.openId)}`
|
|
40
|
+
}
|
|
41
|
+
if (urlParams && urlParams.appid) {
|
|
42
|
+
path += path.includes('?') ? `&appId=${encodeURIComponent(urlParams.appid)}` : `?appId=${encodeURIComponent(urlParams.appid)}`
|
|
43
|
+
}
|
|
44
|
+
return request({
|
|
45
|
+
baseURL: INSURANCE2A_API_HOSTNAME,
|
|
46
|
+
url: path,
|
|
47
|
+
method: 'post',
|
|
48
|
+
data: postParams,
|
|
49
|
+
headers: {
|
|
50
|
+
Accept: 'application/json, text/plain, */*',
|
|
51
|
+
'Content-Type': 'application/json'
|
|
52
|
+
},
|
|
53
|
+
isIgnoreLoading: false,
|
|
54
|
+
returnFullResponse: true
|
|
55
|
+
})
|
|
56
|
+
}
|
package/src/api/user.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import request from './request'
|
|
2
|
+
|
|
3
|
+
export function getCommonCurrentUser(params) {
|
|
4
|
+
return request({
|
|
5
|
+
url: '/planBook/common/currentUser',
|
|
6
|
+
method: 'get',
|
|
7
|
+
params,
|
|
8
|
+
isIgnoreLoading: false
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getCommonNewCard(params) {
|
|
13
|
+
return request({
|
|
14
|
+
url: '/planBook/common/newCard',
|
|
15
|
+
method: 'get',
|
|
16
|
+
params
|
|
17
|
+
})
|
|
18
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.bxt_common_form_age_birthday {
|
|
2
|
+
position: relative;
|
|
3
|
+
|
|
4
|
+
& .van-field__control {
|
|
5
|
+
padding-right: 28px;
|
|
6
|
+
line-height: 27px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
& .bxt_birthday_wrapper {
|
|
10
|
+
position: absolute;
|
|
11
|
+
right: 16px;
|
|
12
|
+
top: 10px;
|
|
13
|
+
width: 148px;
|
|
14
|
+
padding: 6px 16px;
|
|
15
|
+
font-size: 13px;
|
|
16
|
+
line-height: 13px;
|
|
17
|
+
border: 1px solid var(--bxt-line-split);
|
|
18
|
+
border-radius: 30px;
|
|
19
|
+
z-index: 1;
|
|
20
|
+
box-sizing: content-box;
|
|
21
|
+
|
|
22
|
+
& .bxt_birthday.empty {
|
|
23
|
+
color: var(--bxt-text-primary);
|
|
24
|
+
|
|
25
|
+
& em {
|
|
26
|
+
font-style: normal;
|
|
27
|
+
vertical-align: middle;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
& em.small {
|
|
31
|
+
font-style: normal;
|
|
32
|
+
color: var(--bxt-text-patch);
|
|
33
|
+
font-size: 12px;
|
|
34
|
+
transform: scale((10/12));
|
|
35
|
+
transform-origin: left center;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
& .bxt_age {
|
|
40
|
+
position: absolute;
|
|
41
|
+
top: 0;
|
|
42
|
+
right: 0;
|
|
43
|
+
display: inline-block;
|
|
44
|
+
height: 100%;
|
|
45
|
+
width: 88px;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
& .bxt_birthday_wrapper::after {
|
|
50
|
+
position: absolute;
|
|
51
|
+
top: 20%;
|
|
52
|
+
left: 7em;
|
|
53
|
+
width: 1px;
|
|
54
|
+
height: 60%;
|
|
55
|
+
content: '';
|
|
56
|
+
border-right: 1px solid var(--bxt-line-split);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.bxt_common_form_age_birthday.disabled {
|
|
61
|
+
& .bxt_birthday_wrapper {
|
|
62
|
+
& .birthday {
|
|
63
|
+
color: #c8c9cc;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -40,10 +40,11 @@
|
|
|
40
40
|
</template>
|
|
41
41
|
|
|
42
42
|
<script>
|
|
43
|
-
import { Toast } from 'vant'
|
|
44
|
-
import { parseTime } from '
|
|
45
|
-
import { getAgeFromBirth } from 'packages/bxs-utils/planbook/common'
|
|
46
|
-
import CommonSelect from './common-select.vue'
|
|
43
|
+
import { Toast } from 'vant'
|
|
44
|
+
import { parseTime } from '../../js/utils.js'
|
|
45
|
+
import { getAgeFromBirth } from 'packages/bxs-utils/planbook/common'
|
|
46
|
+
import CommonSelect from './common-select.vue'
|
|
47
|
+
import './common-age-birthday.less'
|
|
47
48
|
|
|
48
49
|
export default {
|
|
49
50
|
components: {
|
|
@@ -76,130 +77,61 @@ export default {
|
|
|
76
77
|
minDate: new Date(),
|
|
77
78
|
maxDate: new Date()
|
|
78
79
|
}
|
|
79
|
-
}
|
|
80
|
+
}
|
|
80
81
|
},
|
|
81
82
|
computed: {
|
|
82
83
|
valueProp: {
|
|
83
84
|
get() {
|
|
84
|
-
return this.value
|
|
85
|
+
return this.value
|
|
85
86
|
},
|
|
86
87
|
set(v) {
|
|
87
|
-
this.$emit('input', v)
|
|
88
|
+
this.$emit('input', v)
|
|
88
89
|
}
|
|
89
90
|
},
|
|
90
91
|
convertOptions() {
|
|
91
92
|
return (this.options || []).map(o => ({
|
|
92
93
|
value: [o.value, o.val].find(v => v !== undefined),
|
|
93
94
|
name: o.name || o.desc
|
|
94
|
-
}))
|
|
95
|
+
}))
|
|
95
96
|
}
|
|
96
97
|
},
|
|
97
98
|
methods: {
|
|
98
99
|
openAgePicker() {
|
|
99
|
-
this.$refs.CommonSelect.openPicker()
|
|
100
|
+
this.$refs.CommonSelect.openPicker()
|
|
100
101
|
},
|
|
101
102
|
openDatePicker() {
|
|
102
|
-
const { $attrs, value, convertOptions, birthday } = this
|
|
103
|
+
const { $attrs, value, convertOptions, birthday } = this
|
|
103
104
|
if ($attrs.disabled) {
|
|
104
105
|
if ($attrs.disabledMessage) {
|
|
105
|
-
Toast($attrs.disabledMessage)
|
|
106
|
+
Toast($attrs.disabledMessage)
|
|
106
107
|
}
|
|
107
|
-
return
|
|
108
|
+
return
|
|
108
109
|
}
|
|
109
|
-
const now = new Date()
|
|
110
|
-
const [year, month, date] = [now.getFullYear(), now.getMonth(), now.getDate()]
|
|
111
|
-
const firstOption = convertOptions[0]
|
|
112
|
-
const lastOption = convertOptions[convertOptions.length - 1]
|
|
110
|
+
const now = new Date()
|
|
111
|
+
const [year, month, date] = [now.getFullYear(), now.getMonth(), now.getDate()]
|
|
112
|
+
const firstOption = convertOptions[0]
|
|
113
|
+
const lastOption = convertOptions[convertOptions.length - 1]
|
|
113
114
|
this.datetimePickerConfig = {
|
|
114
115
|
visible: true,
|
|
115
116
|
value: birthday ? new Date(birthday) : new Date(year - Number(value), month, date),
|
|
116
117
|
minDate: new Date(year - lastOption.value - 1, month, date),
|
|
117
118
|
maxDate: new Date(year - firstOption.value, month, date)
|
|
118
|
-
}
|
|
119
|
+
}
|
|
119
120
|
},
|
|
120
121
|
onDatetimePickerConfirm(date) {
|
|
121
|
-
const birthday = parseTime(date, '{y}/{m}/{d}')
|
|
122
|
-
this.$emit('input', getAgeFromBirth(birthday))
|
|
123
|
-
this.$emit('change', getAgeFromBirth(birthday))
|
|
124
|
-
this.$emit('changeBirthday', birthday)
|
|
125
|
-
this.onDatetimePickerCancel()
|
|
122
|
+
const birthday = parseTime(date, '{y}/{m}/{d}')
|
|
123
|
+
this.$emit('input', getAgeFromBirth(birthday))
|
|
124
|
+
this.$emit('change', getAgeFromBirth(birthday))
|
|
125
|
+
this.$emit('changeBirthday', birthday)
|
|
126
|
+
this.onDatetimePickerCancel()
|
|
126
127
|
},
|
|
127
128
|
onDatetimePickerCancel() {
|
|
128
|
-
this.datetimePickerConfig.visible = false
|
|
129
|
+
this.datetimePickerConfig.visible = false
|
|
129
130
|
},
|
|
130
131
|
onChangeAge(age) {
|
|
131
|
-
this.$emit('input', age)
|
|
132
|
-
this.$emit('changeBirthday', null)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
</script>
|
|
137
|
-
|
|
138
|
-
<style lang="css">
|
|
139
|
-
@import 'color.css';
|
|
140
|
-
|
|
141
|
-
.bxt_common_form_age_birthday {
|
|
142
|
-
position: relative;
|
|
143
|
-
|
|
144
|
-
& .van-field__control {
|
|
145
|
-
padding-right: 28px;
|
|
146
|
-
line-height: 27px;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
& .bxt_birthday_wrapper {
|
|
150
|
-
position: absolute;
|
|
151
|
-
right: 16px;
|
|
152
|
-
top: 10px;
|
|
153
|
-
width: 148px;
|
|
154
|
-
padding: 6px 16px;
|
|
155
|
-
font-size: 13px;
|
|
156
|
-
line-height: 13px;
|
|
157
|
-
border: 1px solid var(--color-line-split);
|
|
158
|
-
border-radius: 30px;
|
|
159
|
-
z-index: 1;
|
|
160
|
-
box-sizing: content-box;
|
|
161
|
-
|
|
162
|
-
& .bxt_birthday.empty {
|
|
163
|
-
color: var(--color-text-primary);
|
|
164
|
-
|
|
165
|
-
& em {
|
|
166
|
-
vertical-align: middle;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
& em.small {
|
|
170
|
-
color: var(--color-text-patch);
|
|
171
|
-
font-size: 12px;
|
|
172
|
-
transform: scale(10/12);
|
|
173
|
-
transform-origin: left center;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
& .bxt_age {
|
|
178
|
-
position: absolute;
|
|
179
|
-
top: 0;
|
|
180
|
-
right: 0;
|
|
181
|
-
display: inline-block;
|
|
182
|
-
height: 100%;
|
|
183
|
-
width: 88px;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
& .bxt_birthday_wrapper::after {
|
|
188
|
-
position: absolute;
|
|
189
|
-
top: 20%;
|
|
190
|
-
left: 7em;
|
|
191
|
-
width: 1px;
|
|
192
|
-
height: 60%;
|
|
193
|
-
content: '';
|
|
194
|
-
border-right: 1px solid var(--color-line-split);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
.bxt_common_form_age_birthday.disabled {
|
|
199
|
-
& .bxt_birthday_wrapper {
|
|
200
|
-
& .birthday {
|
|
201
|
-
color: #c8c9cc;
|
|
132
|
+
this.$emit('input', age)
|
|
133
|
+
this.$emit('changeBirthday', null)
|
|
202
134
|
}
|
|
203
135
|
}
|
|
204
136
|
}
|
|
205
|
-
</
|
|
137
|
+
</script>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
@import (reference) 'variables.less';
|
|
2
|
+
|
|
3
|
+
.bxt_common_popup {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
|
|
7
|
+
& .van-popup__close-icon {
|
|
8
|
+
position: absolute;
|
|
9
|
+
font-size: 22px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
& .bxt_common_popup_title {
|
|
13
|
+
padding: 11px 16px;
|
|
14
|
+
font-size: 16px;
|
|
15
|
+
color: var(--bxt-text-primary);
|
|
16
|
+
line-height: 24px;
|
|
17
|
+
font-weight: bold;
|
|
18
|
+
font-weight: 500;
|
|
19
|
+
text-align: center;
|
|
20
|
+
|
|
21
|
+
& > span {
|
|
22
|
+
.bxt-nowrap();
|
|
23
|
+
|
|
24
|
+
width: 100%;
|
|
25
|
+
padding: 0 2em;
|
|
26
|
+
white-space: nowrap;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
vertical-align: middle;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
& .bxt_common_popup_main {
|
|
33
|
+
position: relative;
|
|
34
|
+
flex: 1;
|
|
35
|
+
overflow: auto;
|
|
36
|
+
min-height: 0;
|
|
37
|
+
background: var(--bxt-bg-primary);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
& .bxt_common_popup_footer {
|
|
41
|
+
.bxt-safe-area-inset-bottom();
|
|
42
|
+
|
|
43
|
+
font-size: 14px;
|
|
44
|
+
line-height: 1.2;
|
|
45
|
+
text-align: center;
|
|
46
|
+
border-top: 1px solid var(--bxt-line-split);
|
|
47
|
+
background: var(--bxt-bg-minor);
|
|
48
|
+
|
|
49
|
+
& .bxt_common_popup_footer_wrapper {
|
|
50
|
+
display: flex;
|
|
51
|
+
padding: 7px 15px;
|
|
52
|
+
|
|
53
|
+
& > span {
|
|
54
|
+
flex: 1;
|
|
55
|
+
display: inline;
|
|
56
|
+
line-height: 100%;
|
|
57
|
+
padding: 10px 16px;
|
|
58
|
+
color: var(--bxt-text-primary);
|
|
59
|
+
background: white;
|
|
60
|
+
border: 1px solid var(--bxt-text-assist);
|
|
61
|
+
border-radius: 6px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
& > span:not(:last-child) {
|
|
65
|
+
margin-right: 9px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
& > span.primary {
|
|
69
|
+
color: white;
|
|
70
|
+
background: var(--bxt-primary);
|
|
71
|
+
border-color: var(--bxt-primary);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
& > span.disabled {
|
|
75
|
+
color: white;
|
|
76
|
+
background: var(--bxt-text-patch);
|
|
77
|
+
border-color: var(--bxt-text-patch);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|