index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view>
  3. <image class="top-img" src="@/static/img/lbt1.jpg"></image>
  4. <view class="container">
  5. <!-- <view class="search-bar">
  6. <input type="text" placeholder="请输入关键词搜索" />
  7. </view> -->
  8. <view @click="to_ai()" class="large-button button-all" style="background-color: #d4f4c2;"><!-- blanchedalmond -->
  9. <view class="align-center flex justify-between">
  10. <image style="height: 22vw; width: 22vw; margin-left: -3vw;" src="@/static/img/ai-talk.png"></image>
  11. <p style="color: #5c6a7c; font-size: 30px; margin-left: 4vw;">AI 问诊</p>
  12. </view>
  13. </view>
  14. <view @click="$util.navigateTo('/pages/img_process/img_process')" class="large-button button-all" style="background-color: blanchedalmond;"><!-- blanchedalmond -->
  15. <view class="align-center flex justify-between">
  16. <image style="height: 20vw; width: 20vw; margin-left: 2vw;" src="@/static/img/识别.png"></image>
  17. <p style="color: #5c6a7c; font-size: 28px; margin-left: 4vw;">病例识别</p>
  18. </view>
  19. </view>
  20. <view @click="$util.navigateTo('/pages/health_tip/health_tip')" class="large-button button-all" style="background-color: aliceblue;">
  21. <view class="align-center flex justify-between">
  22. <image style="height: 22vw; width: 22vw; margin-left: 5vw;" src="@/static/img/health-tip.png"></image>
  23. <p style="color: #5c6a7c; font-size: 26px; margin-left: 4vw;">健康小知识</p>
  24. </view>
  25. </view>
  26. <view @click="$util.navigateTo('/pages/BMI/BMI')" class="large-button button-all" style="background-color: #fff1f1;"> <!-- #fffae8 #fff0ff-->
  27. <view class="align-center flex justify-between">
  28. <image style="height: 22vw; width: 22vw; margin-left: 0vw;" src="@/static/img/bmi.png"></image>
  29. <p style="color: #5c6a7c; font-size: 30px; margin-left: 10vw;">B M I</p>
  30. </view>
  31. </view>
  32. <uv-gap height="20vw"></uv-gap>
  33. <view v-if="windowHeight">
  34. <image @click="to_ai()" :style="{top:`calc(${windowHeight}px - 30vw)`}" class="doctor" :src="doctor_gender == 1 ? doctor_woman : doctor_man"></image>
  35. <view v-if="isTalking" :style="{ width: `${talkWidth}`, top:`calc(${windowHeight}px - 18vw)` }" class="talk">{{message}}</view>
  36. </view>
  37. <!-- <uv-button @click="$util.navigateTo('/pages/test/test')"></uv-button> -->
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. onShow() {
  44. let doctor_gender = uni.getStorageSync('doctor_gender');
  45. if(doctor_gender === 0) this.doctor_gender = 0;
  46. else this.doctor_gender = 1;
  47. console.log('doctor_gender: ',this.doctor_gender);
  48. },
  49. onReady() {
  50. const windowHeight = uni.getSystemInfoSync().windowHeight - getBottomBarHeight();
  51. this.windowHeight = windowHeight;
  52. console.log('windowHeight-init: ',windowHeight);
  53. function getBottomBarHeight() {
  54. let res = uni.getSystemInfoSync();
  55. const windowHeight = res.windowHeight; // 屏幕可用高度
  56. const screenHeight = res.screenHeight; // 屏幕总高度
  57. // 状态栏高度
  58. const statusBarHeight = res.statusBarHeight
  59. // #ifdef MP-WEIXIN
  60. // 获取微信胶囊的位置信息 width,height,top,right,left,bottom
  61. const custom = wx.getMenuButtonBoundingClientRect()
  62. // console.log(custom)
  63. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  64. const navigationBarHeight = custom.height + (custom.top - statusBarHeight) * 2
  65. // console.log("导航栏高度:"+navigationBarHeight)
  66. // 总体高度 = 状态栏高度 + 导航栏高度
  67. const navHeight = navigationBarHeight + statusBarHeight
  68. // #endif
  69. let bottomBarHeight = screenHeight - windowHeight - navHeight;
  70. bottomBarHeight = bottomBarHeight > 0 ? bottomBarHeight : 0;
  71. console.log('Bottom Bar Height:',bottomBarHeight);
  72. return bottomBarHeight;
  73. }
  74. },
  75. onLoad() {
  76. this.$user_api.check_login();
  77. },
  78. mounted(){
  79. this.talk();
  80. },
  81. onPullDownRefresh() {
  82. setTimeout(() => {uni.stopPullDownRefresh();}, 1000);
  83. },
  84. data() {
  85. return {
  86. windowHeight: null,
  87. doctor_woman: '/static/img/女医生.png',
  88. doctor_man: '/static/img/男医生.png',
  89. doctor_gender: 1,
  90. name: null,
  91. time: 1,
  92. message: '您好 !',
  93. message_num: 0,
  94. talkWidth: '30vw',
  95. isTalking: true
  96. // list: [
  97. // '../../static/img/lbt1.jpg',
  98. // '../../static/img/lbt2.jpg',
  99. // '../../static/img/lbt3.jpg'
  100. // ]
  101. };
  102. },
  103. methods: {
  104. to_ai(){
  105. uni.switchTab({
  106. url: '/pages/ai/ai'
  107. })
  108. },
  109. to_home(){
  110. uni.switchTab({
  111. url: '/pages/my/my'
  112. })
  113. },
  114. talk(){
  115. return new Promise((resolve, reject) => {
  116. if(this.message_num < 6){
  117. if(this.message_num == 1) {
  118. this.talkWidth = '30vw';
  119. const hour = new Date().getHours();
  120. console.log('hour: ',hour);
  121. if (hour >= 4 && hour < 8) {
  122. this.message = '早上好 !'; // 早上
  123. } else if (hour >= 8 && hour < 12) {
  124. this.message = '上午好 !'; // 上午
  125. } else if (hour >= 12 && hour < 18) {
  126. this.message = '下午好 !'; // 下午
  127. } else {
  128. this.message = '晚上好 !'; // 晚上
  129. }
  130. this.applyAnimation();
  131. }
  132. if(this.message_num == 2) {
  133. this.talkWidth = '60vw';
  134. this.message = '希望您今天过得愉快。';
  135. this.applyAnimation();
  136. }
  137. if(this.message_num == 3) {
  138. this.talkWidth = '65vw';
  139. this.message = '有什么我可以帮您的吗?';
  140. this.applyAnimation();
  141. }
  142. if(this.message_num == 4) {
  143. this.talkWidth = '60vw';
  144. this.message = '注意休息,保持健康。';
  145. this.applyAnimation();
  146. }
  147. this.message_num = this.message_num + 1;
  148. // console.log('this.message_num: ',this.message_num);
  149. setTimeout(() => this.talk(), 3000);
  150. }
  151. else{
  152. this.message_num = 0;
  153. setTimeout(() => this.talk(), 3000);
  154. }
  155. })
  156. },
  157. applyAnimation() {
  158. this.isTalking = false;
  159. setTimeout(() => this.isTalking = true, 100);
  160. },
  161. }
  162. };
  163. </script>
  164. <style>
  165. page {
  166. height: 100vh;
  167. background-color: #fff;
  168. }
  169. .container {
  170. margin: 0 20px;
  171. display: flex;
  172. flex-direction: column;
  173. height: 80vh;
  174. }
  175. .header-index {
  176. width: 100%;
  177. padding: 10px;
  178. display: flex;
  179. justify-content: space-between;
  180. align-items: center;
  181. color: #ee4863;
  182. font-weight: 1000;
  183. backdrop-filter: blur(10px); /* 高斯模糊效果 */
  184. background-color: #f8df72; /* 半透明背景 */
  185. border: none;
  186. }
  187. .header-title {
  188. font-size: 20px;
  189. }
  190. .header-login {
  191. color: white;
  192. text-decoration: none;
  193. font-size: 16px;
  194. }
  195. .search-bar {
  196. width: 100%;
  197. }
  198. .search-bar input {
  199. font-size: 16px;
  200. width: 100%;
  201. height: 5vh;
  202. padding: 10px;
  203. box-sizing: border-box;
  204. border-radius: 5px;
  205. }
  206. .button-group {
  207. font-weight: 1000;
  208. margin-top: 20px;
  209. width: 100%;
  210. display: flex;
  211. justify-content: space-between;
  212. gap: 20px;
  213. }
  214. .square-button {
  215. width: 100%;
  216. height: 18vh;
  217. line-height: 100px;
  218. text-align: center;
  219. color: #5bae23;
  220. border: none;
  221. border-radius: 5px;
  222. }
  223. .large-button {
  224. color: #fff;
  225. z-index: 0;
  226. display: flex;
  227. justify-content: center;
  228. align-items: center;
  229. width: 100%;
  230. height: 40vw;
  231. margin-top: 20px;
  232. width: 100%;
  233. font-weight: 1000;
  234. }
  235. .doctor{
  236. height: 30vw;
  237. width: 30vw;
  238. margin-top: auto;
  239. position: fixed;
  240. left: -2vw;
  241. }
  242. .talk {
  243. position: fixed;
  244. left: 30vw;
  245. width: 30vw;
  246. height: 40px;
  247. color: #5c6a7c;
  248. font-size: 20px;
  249. font-weight: 1000;
  250. border-radius: 8px;
  251. background-color: #ffece3;
  252. display: flex; /* 使用flex布局来实现居中 */
  253. justify-content: center; /* 水平居中 */
  254. align-items: center; /* 垂直居中 */
  255. }
  256. .talk::before {
  257. content: "";
  258. position: absolute;
  259. top: 50%; /* 三角形位于元素下方 */
  260. right: 100%; /* 水平居中 */
  261. width: 0;
  262. height: 0;
  263. border-top: 6px solid transparent;
  264. border-bottom: 6px solid transparent;
  265. border-right: 10px solid #ffece3; /* 使用变量 */
  266. transform: translateY(-50%); /* 确保三角形的中心点位于 .active 元素的中心 */
  267. }
  268. .talk {
  269. opacity: 0; /* 初始透明度 */
  270. animation: fadeInLeft 1s ease-in-out forwards;
  271. }
  272. /* 箭头淡入动画 */
  273. @keyframes fadeInLeft {
  274. 0% {
  275. opacity: 0;
  276. transform: translateX(100%);
  277. }
  278. 100% {
  279. opacity: 1;
  280. transform: translateX(0);
  281. }
  282. }
  283. </style>