diff --git a/package.json b/package.json index 91d1141..7e496b1 100644 --- a/package.json +++ b/package.json @@ -16,14 +16,15 @@ "amfe-flexible": "^2.2.1", "axios": "^1.3.4", "core-js": "^3.23.3", + "date-fns": "^3.0.6", + "dayjs": "^1.11.7", + "echarts": "^5.4.1", + "js-base64": "^2.5.2", "regenerator-runtime": "^0.13.5", "vant": "^2.12.48", "vue": "^2.7.8", "vue-router": "^3.5.4", "vuex": "^3.6.2", - "dayjs": "^1.11.7", - "echarts": "^5.4.1", - "js-base64": "^2.5.2", "weixin-js-sdk": "^1.6.0" }, "devDependencies": { diff --git a/src/components/DateSwitch.vue b/src/components/DateSwitch.vue new file mode 100644 index 0000000..8d4ea11 --- /dev/null +++ b/src/components/DateSwitch.vue @@ -0,0 +1,337 @@ + + + + + diff --git a/src/filters/filter.js b/src/filters/filter.js index ec79560..f603ae4 100644 --- a/src/filters/filter.js +++ b/src/filters/filter.js @@ -35,3 +35,26 @@ function padLeftZero(str) { export function hidePhone(phone) { return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2'); } +/** + * + * @param {*} height + * @param {*} weight + * @returns + */ +export function calcBMI(height, weight) { + const realHeight = height > 100 ? height / 100 : height; + const bmiObj = {}; + // 计算 BMI 指数 + const bmi = weight / (realHeight * realHeight); + bmiObj.bmi = bmi; + if (bmi < 18.5) { + bmiObj.result = '体重过轻'; + } else if (bmi >= 18.5 && bmi < 24.9) { + bmiObj.result = '正常体重'; + } else if (bmi >= 25 && bmi < 29.9) { + bmiObj.result = '超重'; + } else { + bmiObj.result = '肥胖'; + } + return bmiObj; +} diff --git a/src/filters/index.js b/src/filters/index.js index 113d3c4..6f1f749 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -5,3 +5,4 @@ Object.keys(filter).forEach(k => Vue.filter(k, filter[k])); Vue.prototype.$formatDate = Vue.filter('formatDate'); Vue.prototype.$hidePhone = Vue.filter('hidePhone'); +Vue.prototype.$calcBMI = Vue.filter('calcBMI'); diff --git a/src/views/insight/index.vue b/src/views/insight/index.vue index 13e5c75..f124b9f 100644 --- a/src/views/insight/index.vue +++ b/src/views/insight/index.vue @@ -5,7 +5,8 @@
-
+ +
情绪感知
@@ -150,7 +151,11 @@