hosList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view>
  3. <view class="initial displayFlexRow">
  4. <view class="hosItem" v-for="(item, index) in hosList" :key="index" @click="selectHos(index)">
  5. <text :class="{ 'cur': item.check }">{{ item.name }}</text>
  6. <image v-if="item.check" :src="index == 0 ? iconUrl.icon_new_bg : index == 1 ? iconUrl.icon_old_bg : ''"></image>
  7. </view>
  8. </view>
  9. <template v-for="(item, index) in hosList" :key="index">
  10. <view class="hos_addr_box displayFlexRow" v-if="item.check">
  11. <image :src="iconUrl.icon_addr"></image>
  12. <text>{{ item.addr }}</text>
  13. </view>
  14. </template>
  15. </view>
  16. </template>
  17. <script lang="ts" setup>
  18. import { ref, onMounted, watch, nextTick } from 'vue';
  19. import { common } from '@/utils';
  20. import icon from '@/utils/icon';
  21. const props = defineProps({
  22. pageType: {
  23. type: String,
  24. default: ''
  25. },
  26. hosId: {
  27. type: String,
  28. default: ''
  29. }
  30. });
  31. const emit = defineEmits(['getHosId']);
  32. const app = getApp();
  33. const iconUrl = ref(icon);
  34. const hosList = ref<any[]>([]);
  35. const edition_slb = ref(false);
  36. const initData = (isObserver = false) => {
  37. let arr: any[] = [];
  38. // Ensure globalData.hosList exists before accessing
  39. if (app.globalData?.hosList?.options) {
  40. let list = JSON.parse(JSON.stringify(app.globalData.hosList.options));
  41. list.forEach((item: any, index: number) => {
  42. // Default reset
  43. item.check = false;
  44. if (props.hosId && props.hosId !== "") {
  45. if (item.value == props.hosId) {
  46. item.check = true;
  47. }
  48. } else if (index == 0) {
  49. // Unified to default to index 0 (consistent with observer logic in original code)
  50. item.check = true;
  51. }
  52. if (item.value !== "") {
  53. arr.push(item);
  54. }
  55. });
  56. }
  57. hosList.value = arr;
  58. if (!isObserver && props.pageType != "noFristAuto" && arr.length > 0) {
  59. console.log(123);
  60. emit('getHosId', arr[0].value);
  61. }
  62. };
  63. onMounted(() => {
  64. edition_slb.value = uni.getStorageSync('wx_Slb') || false;
  65. initData();
  66. });
  67. watch(() => props.hosId, () => {
  68. initData(true);
  69. });
  70. const selectHos = (index: number) => {
  71. common.throttle(async () => {
  72. // Reset all checks
  73. hosList.value.forEach((item) => {
  74. item.check = false;
  75. });
  76. // Set current check
  77. if (hosList.value[index]) {
  78. hosList.value[index].check = true;
  79. const selectedValue = hosList.value[index].value;
  80. if (props.pageType == "deptList") {
  81. if (selectedValue == '22677') {
  82. app.globalData.districtId = '22677';
  83. } else {
  84. app.globalData.districtId = '';
  85. }
  86. }
  87. emit('getHosId', selectedValue);
  88. }
  89. });
  90. };
  91. </script>
  92. <style lang="scss" scoped>
  93. .displayFlexRow {
  94. display: flex;
  95. flex-direction: row;
  96. justify-content: center;
  97. align-items: center;
  98. }
  99. .displayFlexCol {
  100. display: flex;
  101. flex-direction: column;
  102. justify-content: center;
  103. align-items: center;
  104. }
  105. .initial, .concise {
  106. width: 100%;
  107. justify-content: space-between;
  108. }
  109. .initial .line_height {
  110. width: 33.3%;
  111. height: 100upx;
  112. position: relative;
  113. }
  114. .initial .line_height image {
  115. height: 100% !important;
  116. }
  117. .bgf7f7fc {
  118. background: #f7f7fc;
  119. }
  120. .initial .hosItem {
  121. width: 33%;
  122. height: 76upx;
  123. line-height: 76upx;
  124. font-size: 32upx;
  125. color: #43434A;
  126. text-align: center;
  127. background: #f1f1f6;
  128. border-radius: 50px;
  129. margin-right: 5%;
  130. position: relative;
  131. z-index: 1;
  132. }
  133. .initial .hosItem:last-child {
  134. margin-right: 0;
  135. }
  136. .initial text {
  137. font-size: 32upx;
  138. font-weight: bold;
  139. color: #43434A;
  140. position: relative;
  141. z-index: 17;
  142. }
  143. .initial text.cur {
  144. color: #fff;
  145. }
  146. .initial image {
  147. width: 100%;
  148. height: 81upx;
  149. position: absolute;
  150. left: 0;
  151. top: 0;
  152. z-index: 16;
  153. }
  154. /* 适老版 */
  155. .concise .hosItem {
  156. width: 218upx;
  157. margin-right: 18upx;
  158. height: 88upx;
  159. line-height: 88upx;
  160. font-size: 40upx;
  161. font-family: PingFang SC;
  162. font-weight: bold;
  163. color: #62626D;
  164. background: #EDEEF5;
  165. text-align: center;
  166. border-radius: 44px;
  167. position: relative;
  168. z-index: 1;
  169. }
  170. .concise .hosItem:last-child {
  171. margin-right: 0;
  172. }
  173. .concise text {
  174. font-weight: bold;
  175. color: #62626D;
  176. position: relative;
  177. z-index: 17;
  178. }
  179. .concise text.cur {
  180. color: #fff;
  181. }
  182. .concise image {
  183. width: 100%;
  184. height: 88upx;
  185. position: absolute;
  186. left: 0;
  187. top: 2upx;
  188. z-index: 16;
  189. }
  190. .concise .line_height {
  191. width: 196upx;
  192. height: 104upx;
  193. position: relative;
  194. background: #F1F1F6;
  195. margin-right: 20upx;
  196. border-radius: 20upx;
  197. }
  198. .concise .line_height:nth-child(3n) {
  199. margin-right: 0;
  200. }
  201. .hos_addr_box_slb {
  202. width: 100%;
  203. justify-content: flex-start;
  204. padding: 36upx 30upx 0 30upx;
  205. }
  206. .hos_addr_box_slb image {
  207. width: 34upx;
  208. height: 38upx;
  209. margin-right: 16upx;
  210. }
  211. .hos_addr_box_slb text {
  212. font-size: 40upx;
  213. font-family: PingFang SC;
  214. font-weight: bold;
  215. color: #222326;
  216. }
  217. .hos_addr_box {
  218. width: 100%;
  219. justify-content: flex-start;
  220. padding: 36upx 30upx 0 30upx;
  221. }
  222. .hos_addr_box image {
  223. width: 29upx;
  224. height: 33upx;
  225. margin-right: 16upx;
  226. }
  227. .hos_addr_box text {
  228. font-size: 28upx;
  229. font-weight: bold;
  230. color: #222326;
  231. }
  232. </style>