index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <view class="container">
  3. <template v-if="swiperList.length == 0">
  4. <u-skeleton rows="1" class="skeleton-full" loading :rowsHeight="170" :title="false"></u-skeleton>
  5. <view style="margin: 30rpx 0">
  6. <u-skeleton rows="2" title loading avatar avatarSize="120" avatarShape="square" :rowsHeight="28"
  7. :titleHeight="32"></u-skeleton>
  8. </view>
  9. </template>
  10. <template v-else>
  11. <view class="banner-box">
  12. <u--image v-if="swiperList.length == 1" :src="swiperList[0]" mode="aspectFill" :fade="true"
  13. duration="450" :lazy-load="true" width="100%" height="340rpx"></u--image>
  14. <u-swiper v-else :list="swiperList" @change="change" @click="toLinkPage" :autoplay="false" radius="0"
  15. height="340rpx"></u-swiper>
  16. </view>
  17. <view class="hospital-box">
  18. <view class="hospital-list">
  19. <view class="hospital-item" v-for="item,index in hospitalList" :key="index">
  20. <u--image :src="item.logoUrl" mode="aspectFill" :fade="true" duration="450" :lazy-load="true"
  21. width="262rpx" height="200rpx"></u--image>
  22. <view class="hospital-info">
  23. <view class="info-top">
  24. <view class="hospital-name">{{item.name || '-'}}</view>
  25. <view class="hospital-distance">{{item.relativeDistance || 0}}{{item.distanceUnit}}
  26. </view>
  27. </view>
  28. <view class="info-bottom">
  29. <view class="info-bottom-l">
  30. <span class="hospital-address">
  31. <u-icon name="map-fill" color="#999999" size="14"></u-icon>
  32. <span class="address">{{item.address || '-'}}</span>
  33. </span>
  34. <!-- <view class="hospital-area">所在区:{{item.areaName || '-'}}</view> -->
  35. </view>
  36. </view>
  37. <view class="btn-box">
  38. <view class="hospital-btn" @click="toPlaceOrder(item)">去下单</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="footer-box">
  44. <image src="/static/icon-home.png" mode="aspectFill"></image>
  45. <span class="tip">润康优护为你提供服务</span>
  46. </view>
  47. </view>
  48. </template>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. linkList,
  54. getHospitalList
  55. } from "@/api/home.js"
  56. export default {
  57. data() {
  58. return {
  59. swiperList: [],
  60. userInfo: {},
  61. currents: 0,
  62. hospitalList: [],
  63. coordinates: '',
  64. pageSize: 10,
  65. pageNo: 1,
  66. botLoadingShow: 0, //0不显示 1显示 3.显示没有更多了
  67. loadingShow: false,
  68. status: 'loadmore',
  69. loadingText: '努力加载中',
  70. loadmoreText: '上拉或点击加载更多',
  71. nomoreText: '实在没有了',
  72. total: 0,
  73. };
  74. },
  75. async onLoad() {
  76. //获取当前定位信息
  77. // uni.getLocation({
  78. // type: 'gcj02',
  79. // success: (res) => {
  80. // console.log('当前位置的经度:' + res.longitude);
  81. // console.log('当前位置的纬度:' + res.latitude);
  82. // this.coordinates = res.longitude + ',' + res.latitude;
  83. // this.getList();
  84. // }
  85. // });
  86. this.realoadData();
  87. },
  88. onShow() {
  89. wx.showShareMenu({
  90. withShareTicket: true,
  91. menus: ['shareAppMessage', 'shareTimeline']
  92. });
  93. },
  94. methods: {
  95. async realoadData() {
  96. let data = await this.$utils.getLocation();
  97. if (data) {
  98. console.log('当前位置的经度:' + data.long);
  99. console.log('当前位置的纬度:' + data.lat);
  100. this.coordinates = data.long + ',' + data.lat;
  101. this.getList();
  102. } else {
  103. this.coordinates = undefined;
  104. this.getList();
  105. }
  106. this.getBannerList();
  107. },
  108. getList() {
  109. let that = this;
  110. uni.showLoading({
  111. title: '加载中',
  112. mask: true,
  113. });
  114. let param = {
  115. coordinates: that.coordinates
  116. };
  117. getHospitalList(param).then(res => {
  118. let data = res.data;
  119. if (data) {
  120. this.hospitalList = data; //在列表后面新增新获取的数据
  121. // if (this.hospitalList.length >= this.total) {
  122. // this.status = 'nomore';
  123. // return;
  124. // }
  125. } else {
  126. that.status = 'nomore';
  127. }
  128. }).finally(() => {
  129. uni.hideLoading();
  130. })
  131. },
  132. toPlaceOrder(obj) {
  133. // let item = {
  134. // id: obj.id,
  135. // name: obj.name,
  136. // address: obj.address,
  137. // logoUrl: obj.logoUrl,
  138. // areaName: obj.areaName,
  139. // }
  140. uni.navigateTo({
  141. url: '/pages/order/placeAnOrder?id=' + obj.id
  142. })
  143. },
  144. getBannerList() {
  145. let that = this;
  146. linkList('home_top_banner').then(res => {
  147. res.data.forEach(item => {
  148. that.swiperList.push(item.image)
  149. })
  150. }).finally(() => {})
  151. },
  152. toLinkPage() {
  153. },
  154. //下拉刷新
  155. onPullDownRefresh() {
  156. this.pageNo = 1;
  157. this.swiperList = [];
  158. this.hospitalList = [];
  159. this.realoadData();
  160. uni.stopPullDownRefresh();
  161. },
  162. //上拉加载
  163. // onReachBottom() {
  164. // this.pageNo++;
  165. // this.getList();
  166. // },
  167. change(index) {
  168. this.currents = index;
  169. },
  170. /**
  171. * 用户点击右上角分享
  172. */
  173. onShareAppMessage: function() {
  174. const nickName = '您的好友'
  175. const title = '润护通为您提供服务',
  176. path = `/pages/tabBar/index`
  177. // imageUrl = 'https://www.baidu.com.cn/img/20211108/activity.png'
  178. return {
  179. title,
  180. path
  181. // imageUrl
  182. };
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss" scoped>
  188. .container {
  189. background-color: #fff;
  190. min-height: 100vh;
  191. .banner-box {
  192. width: 100%;
  193. height: 340rpx;
  194. image {
  195. width: 100%;
  196. height: 340rpx !important;
  197. }
  198. .u--image {
  199. width: 100%;
  200. height: 340rpx !important;
  201. }
  202. }
  203. .hospital-box {
  204. display: flex;
  205. flex-direction: column;
  206. min-height: calc(100vh - 340rpx);
  207. background-color: #fff;
  208. .hospital-list {
  209. padding: 0 30rpx 40rpx;
  210. flex: 1;
  211. .hospital-item {
  212. display: flex;
  213. align-items: center;
  214. justify-content: center;
  215. padding: 30rpx 0;
  216. border-bottom: 1rpx solid #f0f0f0;
  217. // &:last-child {
  218. // border-bottom: none;
  219. // }
  220. // image {
  221. // width: 262rpx;
  222. // height: 200rpx;
  223. // border-radius: 20rpx;
  224. // margin-right: 17rpx;
  225. // }
  226. .hospital-info {
  227. flex: 1;
  228. margin-left: 17rpx;
  229. .info-top {
  230. display: flex;
  231. justify-content: space-between;
  232. align-items: center;
  233. .hospital-name {
  234. width: 300rpx;
  235. font-size: 30rpx;
  236. font-weight: bold;
  237. // word-break: break-all;
  238. display: -webkit-box;
  239. -webkit-line-clamp: 1;
  240. /* 设置显示的行数 */
  241. -webkit-box-orient: vertical;
  242. overflow: hidden;
  243. text-overflow: ellipsis;
  244. max-width: 300px;
  245. /* 设置最大宽度,根据需要调整 */
  246. //超过一行使用省略号
  247. }
  248. .hospital-distance {
  249. text-align: right;
  250. margin: 15rpx 0;
  251. font-size: 28rpx;
  252. color: #999;
  253. }
  254. }
  255. .info-bottom {
  256. display: flex;
  257. flex-direction: column;
  258. // justify-content: space-between;
  259. // align-items: center;
  260. .info-bottom-l {
  261. flex: 1;
  262. .hospital-address {
  263. display: flex;
  264. justify-content: flex-start;
  265. align-items: flex-start;
  266. width: 100%;
  267. margin-top: 10rpx;
  268. font-weight: 500;
  269. line-height: 40rpx;
  270. overflow: hidden; //超出的文本隐藏
  271. text-overflow: ellipsis; //溢出用省略号显示
  272. white-space: normal; //处理元素中的 空白
  273. display: -webkit-box;
  274. -webkit-line-clamp: 2;
  275. -webkit-box-orient: vertical;
  276. display: -moz-box;
  277. -moz-line-clamp: 2;
  278. -moz-box-orient: vertical;
  279. overflow-wrap: break-word;
  280. word-break: break-all;
  281. ::v-deep .u-icon {
  282. display: inline-block;
  283. }
  284. // u-icon和span在同一行,换行时文字在icon下面
  285. .address {
  286. font-size: 28rpx;
  287. margin-left: 5rpx;
  288. color: #999999;
  289. }
  290. }
  291. .hospital-area {
  292. font-size: 28rpx;
  293. color: #999;
  294. }
  295. }
  296. }
  297. .btn-box {
  298. display: flex;
  299. justify-content: flex-end;
  300. align-items: center;
  301. margin-top: 20rpx;
  302. .hospital-btn {
  303. width: 165rpx;
  304. height: 60rpx;
  305. margin-left: 10rpx;
  306. line-height: 60rpx;
  307. text-align: center;
  308. background: #4B91D1;
  309. color: #fff;
  310. font-size: 24rpx;
  311. border-radius: 30rpx;
  312. justify-content: flex-end;
  313. }
  314. }
  315. }
  316. }
  317. }
  318. }
  319. .footer-box {
  320. display: flex;
  321. justify-content: center;
  322. align-items: center;
  323. // position: fixed;
  324. // bottom: 0;
  325. // left: 0;
  326. width: 100%;
  327. padding: 32rpx 0;
  328. background-color: #fff;
  329. image {
  330. width: 25rpx;
  331. height: 25rpx;
  332. }
  333. .tip {
  334. margin-left: 7rpx;
  335. color: #B3B3B3;
  336. font-size: 26rpx;
  337. line-height: 26rpx;
  338. }
  339. }
  340. }
  341. /* 骨架屏容器样式 */
  342. .skeleton-full {
  343. width: 100%;
  344. height: 100%;
  345. }
  346. /* 关键:使用深度选择器修改骨架屏内部样式 */
  347. ::v-deep .u-skeleton__wrapper__content__rows {
  348. width: 100% !important;
  349. }
  350. </style>