index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <view class="container">
  3. <view class="banner-box">
  4. <u-swiper :list="swiperList" @change="change" @click="toLinkPage" radius="0" height="340rpx"></u-swiper>
  5. </view>
  6. <view class="hospital-box">
  7. <view class="hospital-list">
  8. <view class="hospital-item" v-for="item,index in hospitalList" :key="index">
  9. <image :src="item.logoUrl" mode="aspectFill" />
  10. <view class="hospital-info">
  11. <view class="info-top">
  12. <view class="hospital-name">{{item.name || '-'}}</view>
  13. <view class="hospital-distance">{{item.relativeDistance || 0}}{{item.distanceUnit}}</view>
  14. </view>
  15. <view class="info-bottom">
  16. <view class="info-bottom-l">
  17. <span class="hospital-address">
  18. <u-icon name="map-fill" color="#999999" size="14"></u-icon>
  19. <span class="address">{{item.address || '-'}}</span>
  20. </span>
  21. <!-- <view class="hospital-area">所在区:{{item.areaName || '-'}}</view> -->
  22. </view>
  23. </view>
  24. <view class="btn-box">
  25. <view class="hospital-btn" @click="toPlaceOrder(item)">去下单</view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. linkList,
  36. getHospitalList
  37. } from "@/api/home.js"
  38. export default {
  39. data() {
  40. return {
  41. swiperList: [],
  42. userInfo: {},
  43. currents: 0,
  44. hospitalList: [],
  45. coordinates: '',
  46. pageSize: 10,
  47. pageNo: 1,
  48. botLoadingShow: 0, //0不显示 1显示 3.显示没有更多了
  49. loadingShow: false,
  50. status: 'loadmore',
  51. loadingText: '努力加载中',
  52. loadmoreText: '上拉或点击加载更多',
  53. nomoreText: '实在没有了',
  54. total: 0,
  55. };
  56. },
  57. onLoad() {
  58. //获取当前定位信息
  59. uni.getLocation({
  60. type: 'gcj02',
  61. success: (res) => {
  62. console.log('当前位置的经度:' + res.longitude);
  63. console.log('当前位置的纬度:' + res.latitude);
  64. this.coordinates = res.longitude + ',' + res.latitude;
  65. this.getList();
  66. }
  67. });
  68. },
  69. onShow() {
  70. this.getBannerList();
  71. },
  72. methods: {
  73. getList() {
  74. let that = this;
  75. uni.showLoading({
  76. title: '加载中',
  77. mask: true,
  78. });
  79. let param = {
  80. // pageNo: that.pageNo,
  81. // pageSize: that.pageSize,
  82. coordinates: that.coordinates
  83. };
  84. getHospitalList(param).then(res => {
  85. let data = res.data;
  86. if (data) {
  87. this.hospitalList.push(...data); //在列表后面新增新获取的数据
  88. // this.total = data.total; //获取数据总页数
  89. if (this.hospitalList.length >= this.total) {
  90. this.status = 'nomore';
  91. return;
  92. }
  93. } else {
  94. that.status = 'nomore';
  95. }
  96. }).finally(() => {
  97. uni.hideLoading();
  98. })
  99. },
  100. toPlaceOrder(obj) {
  101. // let item = {
  102. // id: obj.id,
  103. // name: obj.name,
  104. // address: obj.address,
  105. // logoUrl: obj.logoUrl,
  106. // areaName: obj.areaName,
  107. // }
  108. uni.navigateTo({
  109. url: '/pages/order/placeAnOrder?id=' + obj.id
  110. })
  111. },
  112. getBannerList() {
  113. let that = this;
  114. linkList('home_top_banner').then(res => {
  115. res.data.forEach(item => {
  116. that.swiperList.push(item.image)
  117. })
  118. }).finally(() => {})
  119. },
  120. toLinkPage() {
  121. },
  122. //下拉刷新
  123. onPullDownRefresh() {
  124. this.pageNo = 1;
  125. this.hospitalList = [];
  126. this.getList();
  127. this.getBannerList();
  128. uni.stopPullDownRefresh();
  129. },
  130. //上拉加载
  131. // onReachBottom() {
  132. // this.pageNo++;
  133. // this.getList();
  134. // },
  135. change(index) {
  136. this.currents = index;
  137. },
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .container {
  143. .banner-box {
  144. width: 100%;
  145. height: 340rpx;
  146. image {
  147. width: 100%;
  148. height: 340rpx !important;
  149. }
  150. }
  151. .hospital-box {
  152. background-color: #fff;
  153. .hospital-list {
  154. padding: 0 30rpx;
  155. .hospital-item {
  156. display: flex;
  157. align-items: center;
  158. justify-content: center;
  159. padding: 30rpx 0;
  160. margin-bottom: 30rpx;
  161. border-bottom: 1rpx solid #E8E8E8;
  162. &:last-child {
  163. border-bottom: none;
  164. }
  165. image {
  166. width: 262rpx;
  167. height: 200rpx;
  168. border-radius: 20rpx;
  169. margin-right: 17rpx;
  170. }
  171. .hospital-info {
  172. flex: 1;
  173. .info-top {
  174. display: flex;
  175. justify-content: space-between;
  176. align-items: center;
  177. .hospital-name {
  178. width: 300rpx;
  179. font-size: 30rpx;
  180. font-weight: bold;
  181. // word-break: break-all;
  182. display: -webkit-box;
  183. -webkit-line-clamp: 1;
  184. /* 设置显示的行数 */
  185. -webkit-box-orient: vertical;
  186. overflow: hidden;
  187. text-overflow: ellipsis;
  188. max-width: 300px;
  189. /* 设置最大宽度,根据需要调整 */
  190. //超过一行使用省略号
  191. }
  192. .hospital-distance {
  193. text-align: right;
  194. margin: 15rpx 0;
  195. font-size: 28rpx;
  196. color: #999;
  197. }
  198. }
  199. .info-bottom {
  200. display: flex;
  201. flex-direction: column;
  202. // justify-content: space-between;
  203. // align-items: center;
  204. .info-bottom-l {
  205. flex: 1;
  206. .hospital-address {
  207. display: flex;
  208. justify-content: flex-start;
  209. align-items: flex-start;
  210. width: 100%;
  211. margin-top: 10rpx;
  212. font-weight: 500;
  213. line-height: 40rpx;
  214. overflow: hidden; //超出的文本隐藏
  215. text-overflow: ellipsis; //溢出用省略号显示
  216. white-space: normal; //处理元素中的 空白
  217. display: -webkit-box;
  218. -webkit-line-clamp: 2;
  219. -webkit-box-orient: vertical;
  220. display: -moz-box;
  221. -moz-line-clamp: 2;
  222. -moz-box-orient: vertical;
  223. overflow-wrap: break-word;
  224. word-break: break-all;
  225. ::v-deep .u-icon {
  226. display: inline-block;
  227. }
  228. // u-icon和span在同一行,换行时文字在icon下面
  229. .address {
  230. font-size: 28rpx;
  231. margin-left: 5rpx;
  232. color: #999999;
  233. }
  234. }
  235. .hospital-area {
  236. font-size: 28rpx;
  237. color: #999;
  238. }
  239. }
  240. }
  241. .btn-box {
  242. display: flex;
  243. justify-content: flex-end;
  244. align-items: center;
  245. margin-top: 20rpx;
  246. .hospital-btn {
  247. width: 165rpx;
  248. height: 60rpx;
  249. margin-left: 10rpx;
  250. line-height: 60rpx;
  251. text-align: center;
  252. background: #4B91D1;
  253. color: #fff;
  254. font-size: 24rpx;
  255. border-radius: 30rpx;
  256. justify-content: flex-end;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. </style>