index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <template>
  2. <view class="content">
  3. <!-- #ifdef MP-WEIXIN -->
  4. <uv-sticky>
  5. <view class="top-box" :class="showTopSearch?'':'hide'">
  6. <view :style="[{height: `${statusBarHeight}px`}]"></view>
  7. <view class="title" :style="[{height: `${statusBarHeight}px`}]">
  8. <text class="titlt-txt">门店列表</text>
  9. </view>
  10. </view>
  11. </uv-sticky>
  12. <!-- #endif -->
  13. <!-- #ifndef MP-WEIXIN -->
  14. <uv-navbar title="门店列表" placeholder leftIcon="" titleStyle="font-size:36rpx;color:#fff"></uv-navbar>
  15. <!-- #endif -->
  16. <!-- <uv-swiper :list="swiperList"></uv-swiper> -->
  17. <view class="shopListBox" v-if="list.length>0">
  18. <!-- 附近门店 -->
  19. <view class="item" v-for="(v, index) in list" :key="index" @click="goDetails(v)">
  20. <view class="shop-img">
  21. <image :src="v.logo" mode="aspectFill"></image>
  22. </view>
  23. <view class="right">
  24. <view class="title">{{v.businessName}}</view>
  25. <view class="score-box">
  26. <view class="score">
  27. <rate :value="Math.round(v.average)"></rate>
  28. </view>
  29. <text class="score-text">{{v.average}}分</text>
  30. <text class="ju">距离:{{Math.round(v.distance/1000*100)/100}}KM</text>
  31. </view>
  32. <view class="address-box">
  33. <view class="left">
  34. <image class="location1" :src="$handleImageUrl('/common/location-icon.png')">
  35. </image>
  36. <view class="district">{{v.address || '商户暂无地理位置'}}</view>
  37. </view>
  38. <view class="goShopping" @click.stop="openMap(v)">
  39. <text class="iconfont3">&#xe787;</text>
  40. <text class="text">去逛逛</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script setup>
  49. import { getBusinessList } from '@/api/shop'
  50. import { ref, getCurrentInstance } from 'vue'
  51. import { onShow, onLoad, onPageScroll } from '@dcloudio/uni-app'
  52. const showTopSearch = ref(true);
  53. const statusBarHeight = ref(0);
  54. statusBarHeight.value = uni.getSystemInfoSync().statusBarHeight;
  55. // const menuButtonHeight = ref(0);
  56. // menuButtonHeight.value = uni.getMenuButtonBoundingClientRect().height + 10;
  57. const list = ref([]);
  58. const param = ref({
  59. lon: "",
  60. lat: ""
  61. });
  62. onPageScroll((e) => {
  63. if (e.scrollTop > uni.upx2px(49 + 30)) {
  64. showTopSearch.value = false;
  65. } else {
  66. showTopSearch.value = true;
  67. }
  68. })
  69. const getList = () => {
  70. getBusinessList(param.value).then(res => {
  71. if (res.data && res.data.length > 0) {
  72. res.data.map(v => {
  73. v.average = v.average || 0
  74. })
  75. }
  76. list.value = res.data
  77. })
  78. }
  79. const openMap = (item) => {
  80. uni.openLocation({
  81. latitude: Number(item.latitude),
  82. longitude: Number(item.longitude),
  83. success: function () {
  84. console.log('success');
  85. },
  86. complete: (e) => {
  87. console.log(e);
  88. }
  89. });
  90. }
  91. const goDetails = (item) => {
  92. uni.setStorageSync('businessId', item.businessId);
  93. uni.switchTab({
  94. url: '/pages/tabtar/home'
  95. })
  96. }
  97. onLoad(() => {
  98. uni.getLocation({
  99. type: 'gcj02',
  100. geocode: true,
  101. success: (res) => {
  102. param.value.userLongitude = res.longitude;
  103. param.value.userLatitude = res.latitude;
  104. getList()
  105. },
  106. complete: (e) => {
  107. console.log(e);
  108. },
  109. });
  110. getList()
  111. })
  112. </script>
  113. <style lang="scss" scoped>
  114. ::v-deep .uv-navbar__content {
  115. background: linear-gradient(
  116. 132deg,
  117. #fd995d 1%,
  118. #feb771 45%,
  119. #ed9f61 95%
  120. ) !important;
  121. }
  122. .top-box {
  123. width: 100%;
  124. background: linear-gradient(132deg, #fd995d 1%, #feb771 45%, #ed9f61 95%);
  125. &.hide {
  126. .seat {
  127. display: block;
  128. }
  129. }
  130. .seat {
  131. display: none;
  132. height: 130rpx;
  133. }
  134. .title {
  135. display: flex;
  136. justify-content: center;
  137. align-items: center;
  138. position: relative;
  139. margin: 0 auto;
  140. padding: 0 30rpx;
  141. font-size: 36rpx;
  142. font-family: PingFang SC, PingFang SC-Bold;
  143. font-weight: 700;
  144. color: #ffffff;
  145. text-align: center;
  146. .back-icon {
  147. position: absolute;
  148. left: 30rpx;
  149. top: 50%;
  150. transform: translateY(-50%);
  151. float: left;
  152. }
  153. image {
  154. width: 41rpx;
  155. height: 31rpx;
  156. margin-right: 4rpx;
  157. }
  158. .titlt-txt {
  159. font-size: 36rpx;
  160. }
  161. }
  162. .input-box {
  163. display: flex;
  164. justify-content: space-between;
  165. align-items: center;
  166. position: sticky;
  167. top: 0;
  168. z-index: 100;
  169. width: 100%;
  170. padding: 23rpx 30rpx 20rpx;
  171. .text {
  172. margin-right: 20rpx;
  173. margin-left: 0rpx;
  174. font-weight: 500;
  175. font-size: 28rpx;
  176. color: #fff;
  177. }
  178. .input-placeholder {
  179. // flex: 1;
  180. box-sizing: border-box;
  181. display: inline-block;
  182. vertical-align: middle;
  183. width: 690rpx;
  184. height: 70rpx;
  185. line-height: 66rpx;
  186. // background: rgba(2,81,43,0.3);
  187. background: #fff;
  188. padding-left: 80rpx;
  189. // color: #666666;
  190. background: rgba(255, 255, 255, 0.3);
  191. // background-image: url("/static/czd/search.png");
  192. background-size: 40rpx 40rpx;
  193. background-position: 24rpx 50%;
  194. background-repeat: no-repeat;
  195. border: 1rpx solid rgba(255, 255, 255, 0.36);
  196. border-radius: 36rpx;
  197. }
  198. text {
  199. margin-left: 10rpx;
  200. display: inline-block;
  201. vertical-align: middle;
  202. font-size: 42rpx;
  203. font-weight: 400;
  204. text-align: right;
  205. color: #ffffff;
  206. line-height: 42rpx;
  207. &.iconfont2 {
  208. font-size: 55rpx;
  209. }
  210. }
  211. .status-bar {
  212. display: none;
  213. }
  214. .msgCenter {
  215. position: relative;
  216. text {
  217. min-width: 50rpx;
  218. font-size: 20rpx;
  219. color: #ffffff;
  220. font-weight: 400;
  221. padding: 0 4rpx;
  222. background-color: #ff0000;
  223. border-radius: 13rpx;
  224. border: 2rpx solid #fff;
  225. text-align: center;
  226. position: absolute;
  227. left: 10rpx;
  228. top: -30rpx;
  229. line-height: normal;
  230. }
  231. }
  232. }
  233. .input-placeholder {
  234. color: #fee3cf;
  235. opacity: 0.74;
  236. font-size: 28rpx;
  237. font-family: PingFang SC, PingFang SC-Regular;
  238. font-weight: 400;
  239. text-align: left;
  240. line-height: 70rpx;
  241. }
  242. }
  243. .shopListBox {
  244. padding: 0 30rpx;
  245. .shopListBox_item {
  246. margin-top: 30rpx;
  247. }
  248. .shopItem {
  249. // border-bottom: 1rpx solid #E6E6E6;
  250. padding-bottom: 40rpx;
  251. margin-bottom: 40rpx;
  252. .shopItem_title {
  253. font-size: 34rpx;
  254. color: #1a1a1a;
  255. font-weight: 700;
  256. margin-bottom: 20rpx;
  257. }
  258. .shopItem_data {
  259. display: flex;
  260. align-items: center;
  261. justify-content: space-between;
  262. font-size: 26rpx;
  263. image {
  264. width: 22rpx;
  265. height: 30rpx;
  266. }
  267. > view {
  268. display: flex;
  269. align-items: center;
  270. image {
  271. margin-right: 10rpx;
  272. }
  273. }
  274. .shopItem_data_distance {
  275. color: #666666;
  276. }
  277. }
  278. .gooodsBox {
  279. .gooods_item {
  280. display: flex;
  281. margin-top: 20rpx;
  282. image {
  283. width: 136rpx;
  284. height: 136rpx;
  285. margin-right: 35rpx;
  286. border-radius: 10rpx;
  287. flex-shrink: 0;
  288. }
  289. .gooods_item_r {
  290. display: flex;
  291. flex-direction: column;
  292. justify-content: space-around;
  293. > view {
  294. display: flex;
  295. align-items: center;
  296. }
  297. .gooods_item_r_title {
  298. font-size: 26rpx;
  299. color: #1a1a1a;
  300. overflow: hidden;
  301. text-overflow: ellipsis;
  302. display: -webkit-box;
  303. -webkit-line-clamp: 2;
  304. -webkit-box-orient: vertical;
  305. }
  306. .gooods_item_r_price {
  307. font-size: 36rpx;
  308. color: #fa6138;
  309. font-weight: 600;
  310. text {
  311. font-size: 20rpx;
  312. display: inline-block;
  313. margin-right: 10rpx;
  314. }
  315. }
  316. .gooods_item_r_expense {
  317. font-size: 26rpx;
  318. color: #666666;
  319. margin-left: 52rpx;
  320. }
  321. }
  322. }
  323. }
  324. .lookOther {
  325. font-size: 24rpx;
  326. color: #333333;
  327. width: 288rpx;
  328. height: 59rpx;
  329. border-radius: 8rpx;
  330. background: #f2f2f2;
  331. display: flex;
  332. align-items: center;
  333. justify-content: center;
  334. margin: 20rpx auto 0;
  335. }
  336. }
  337. .item {
  338. display: flex;
  339. align-items: center;
  340. padding: 30rpx 0;
  341. // border-bottom: 1rpx solid #e6e6e6;
  342. .shop-img {
  343. width: 162rpx;
  344. height: 158rpx;
  345. margin-right: 40rpx;
  346. border-radius: 10rpx;
  347. overflow: hidden;
  348. flex-shrink: 0;
  349. image {
  350. width: 100%;
  351. height: 100%;
  352. }
  353. }
  354. .right {
  355. flex: 1;
  356. width: 0;
  357. .score-box,
  358. .address-box,
  359. .location2-box {
  360. display: flex;
  361. align-items: center;
  362. font-size: 24rpx;
  363. font-family: PingFang SC, PingFang SC-Regular;
  364. font-weight: 400;
  365. }
  366. .location1,
  367. .location2 {
  368. width: 20rpx;
  369. height: 27rpx;
  370. flex-shrink: 0;
  371. margin-right: 9rpx;
  372. }
  373. .location2 {
  374. width: 23rpx;
  375. height: 27rpx;
  376. }
  377. .light-start,
  378. .startt {
  379. width: 30rpx;
  380. height: 30rpx;
  381. margin-right: 12rpx;
  382. }
  383. .title {
  384. margin-bottom: 18rpx;
  385. font-size: 28rpx;
  386. font-family: PingFang SC, PingFang SC-Regular;
  387. color: #1a1a1a;
  388. }
  389. .score-box {
  390. align-items: normal;
  391. margin-bottom: 10rpx;
  392. font-family: PingFang SC, PingFang SC-Semibold;
  393. color: #333333;
  394. .score {
  395. flex-shrink: 0;
  396. }
  397. .score-text {
  398. font-size: 24rpx;
  399. font-family: PingFang SC, PingFang SC-Medium;
  400. font-weight: 500;
  401. text-align: left;
  402. color: #333333;
  403. flex-shrink: 0;
  404. }
  405. .ju {
  406. margin-left: 23rpx;
  407. font-size: 24rpx;
  408. color: #808080;
  409. text-align: left;
  410. overflow: hidden;
  411. text-overflow: ellipsis;
  412. white-space: nowrap;
  413. }
  414. }
  415. .address-box {
  416. // margin-bottom: 10rpx;
  417. font-family: PingFang SC;
  418. color: #666666;
  419. justify-content: space-between;
  420. .left {
  421. flex: 1;
  422. width: 0;
  423. display: flex;
  424. align-items: center;
  425. font-size: 24rpx;
  426. font-family: PingFang SC, PingFang SC-Regular;
  427. font-weight: 400;
  428. text-align: left;
  429. color: #333333;
  430. }
  431. .district {
  432. color: #1a1a1a;
  433. margin-right: 40rpx;
  434. overflow: hidden;
  435. text-overflow: ellipsis;
  436. white-space: nowrap;
  437. }
  438. .goShopping {
  439. display: flex;
  440. align-items: center;
  441. font-size: 40rpx;
  442. color: #fa6138;
  443. flex-shrink: 0;
  444. .text {
  445. font-size: 24rpx;
  446. font-family: PingFang SC, PingFang SC-Medium;
  447. font-weight: 500;
  448. text-align: left;
  449. color: #666666;
  450. }
  451. }
  452. }
  453. .location2-box {
  454. color: #333333;
  455. view {
  456. overflow: hidden;
  457. text-overflow: ellipsis;
  458. white-space: nowrap;
  459. }
  460. }
  461. }
  462. }
  463. }
  464. </style>