list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. <template>
  2. <view>
  3. <navbar :config="config" backColor="#666"></navbar>
  4. <view class="top-box" :style="{'top': sticky + 'px'}">
  5. <view class="top-nav">
  6. <view class="city-text" @click="addressShow=true">
  7. <image mode="aspectFit" src="/static/shop/location-icon.png"></image>
  8. <view>{{cityName}}</view>
  9. </view>
  10. <view class="searchBox">
  11. <image src="/static/shop/search-icon.png" mode="widthFix"></image>
  12. <input v-model="param.shop_name" type="text" @confirm="getShopList()" placeholder-style="color:#B3B3B3"
  13. placeholder="请输入关键字" @input="search()" />
  14. </view>
  15. </view>
  16. <view class="tabsBox">
  17. <view class="type-box">
  18. <view class="item" @click="show = true">
  19. <view>{{selectIndex === null ? '全部分类' : selector[selectIndex].name}}</view>
  20. <image mode="aspectFit" src="/static/convenienceService/drop-arrow.png"></image>
  21. </view>
  22. <view class="item" v-for="(v,i) in typeList" :key="i" :class="{activeCls:tabCurrent==i}"
  23. @click="tabsChange2(i)">
  24. <view>{{v.name}}</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view :style="{'height': placeholderH + 'px'}"></view>
  30. <!-- selector -->
  31. <!-- <view :style="{height: (statusBarHeight) + 'px'}"></view> -->
  32. <view class="shopListBox" v-if="list.length>0">
  33. <!-- 附近门店 -->
  34. <view class="item" v-for="(v, index) in list" :key="index" @click="goShopDetails(v)">
  35. <view class="shop-img">
  36. <image :src="v.logo" mode="aspectFill"></image>
  37. </view>
  38. <view class="right">
  39. <view class="title">{{v.shop_name}}</view>
  40. <view class="score-box">
  41. <view class="score">
  42. <rate :value="Math.round(v.average)"></rate>
  43. </view>
  44. <text class="score-text">{{v.average.toFixed(2)}}分</text>
  45. <text class="ju">距离:{{Math.round(v.distance/1000*100)/100}}KM</text>
  46. </view>
  47. <view class="address-box">
  48. <view class="left">
  49. <image class="location1" src="/static/shop/location-icon.png">
  50. </image>
  51. <view class="district">{{v.map_punctuation || '商户暂无地理位置'}}</view>
  52. </view>
  53. <view class="goShopping">
  54. <text class="iconfont3">&#xe787;</text>
  55. <text class="text">去逛逛</text>
  56. </view>
  57. </view>
  58. <!-- <view class="location2-box">
  59. <image class="location2" src="/static/convenienceService/location2.png">
  60. </image>
  61. <view>{{v.map_punctuation}}&gt;</view>
  62. </view> -->
  63. </view>
  64. </view>
  65. </view>
  66. <view>
  67. <noData v-if="list.length<=0"></noData>
  68. </view>
  69. <!-- 选择地区 -->
  70. <u-select v-model="addressShow" mode="mutil-column-auto" :list="cityTree" @confirm="addressConfirm">
  71. </u-select>
  72. <u-picker mode="selector" v-model="show" :range="selector" range-key="name" :default-selector="[sIndex]"
  73. @confirm="confirmSelect"></u-picker>
  74. </view>
  75. </template>
  76. <script>
  77. import rate from "@/components/rate.vue"
  78. import noData from "@/components/noData/nodata.vue"
  79. export default {
  80. components: {
  81. rate,
  82. noData
  83. },
  84. data() {
  85. return {
  86. //手机状态栏高度
  87. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  88. sticky: uni.getSystemInfoSync().statusBarHeight + 44,
  89. placeholderH: 0,
  90. config: {
  91. back: true,
  92. title: '同城商家',
  93. color: '#1a1a1a',
  94. backgroundColor: [1, "#fff"],
  95. statusBarFontColor: '#1A1A1A',
  96. leftSlot: true
  97. },
  98. cityName: '武汉市',
  99. sIndex: 0,
  100. param: {
  101. shop_name: '',
  102. order: 'distance',
  103. union_business: true
  104. },
  105. setTime: null,
  106. addressShow: false,
  107. tabCurrent: 0,
  108. cityTree: [],
  109. typeList: [{
  110. name: '距离优先',
  111. order: 'distance'
  112. },
  113. {
  114. name: '评分优先',
  115. order: 'average'
  116. }
  117. ],
  118. show: false,
  119. selector: [],
  120. selectIndex: null,
  121. list: [],
  122. }
  123. },
  124. onLoad(options) {
  125. if (options && options.id) {
  126. this.param.classify_id = options.id
  127. }
  128. if (options.cityName) {
  129. this.cityName = options.cityName
  130. }
  131. if (options.address) {
  132. this.param.address = options.address
  133. }
  134. if (options.area_code) {
  135. this.param.area_code = options.area_code
  136. }
  137. this.getCitys();
  138. this.getTppe(this.param.classify_id)
  139. },
  140. onShow() {
  141. this.$nextTick(() => {
  142. this.$u.getRect('.top-box').then(res => {
  143. console.log(res)
  144. this.placeholderH = res.height
  145. })
  146. })
  147. },
  148. onReady() {},
  149. onPullDownRefresh() {
  150. // this.getTppe()
  151. },
  152. methods: {
  153. tabsChange2(index) {
  154. this.tabCurrent = index;
  155. this.param.order = this.typeList[index].order
  156. this.getShopList()
  157. },
  158. confirmSelect(e) {
  159. this.selectIndex = e[0]
  160. this.sIndex = e[0]
  161. this.getShopList()
  162. },
  163. // 跳转 门店详情
  164. goShopDetails(item) {
  165. uni.navigateTo({
  166. url: "/pages/nearbyShop/shopDetail?shopId=" + item.shop_id
  167. })
  168. },
  169. // 跳转商品详情
  170. goDetails(v) {
  171. uni.navigateTo({
  172. url: "/pages/convenienceService/shopDetails?shopId=" + v.shop_id
  173. })
  174. },
  175. // 获取城市
  176. getCitys() {
  177. this.$http.get('/cnarea/tree-lbs').then(res => {
  178. if (res && res.code == 200) {
  179. this.cityTree = res.tree.children
  180. this.cityTree.forEach(v => {
  181. if (v.children.length <= 0) {
  182. v.children = [{}]
  183. }
  184. })
  185. }
  186. })
  187. },
  188. // 选择地区
  189. addressConfirm(e) {
  190. // this.param.city_code = e[2].value ? e[2].value : e[1].value ? e[1].value : e[0].value;
  191. this.cityName = e[2].label ? e[2].label : e[1].label ? e[1].label : e[0].label;
  192. this.param.area_code = e[2].value ? e[2].value : e[1].value ? e[1].value : e[0].value;
  193. this.getShopList()
  194. },
  195. // 便民服务分类
  196. getTppe(id) {
  197. let that = this
  198. this.$http.get('/union/business/classify/list')
  199. .then(res => {
  200. if (res.code == 200) {
  201. this.selector = [{
  202. name: "全部分类",
  203. id: ""
  204. }, ...res.list];
  205. if (id) {
  206. this.selector.forEach((v, i) => {
  207. if (v.id == id) {
  208. this.selectIndex = i
  209. }
  210. })
  211. }
  212. // #ifdef H5
  213. this.getShopList()
  214. // #endif
  215. console.log('666666666666')
  216. uni.getLocation({
  217. type: 'gcj02',
  218. geocode: true,
  219. success: function(res) {
  220. // that.cityName = res.address ? res.address.district : '';
  221. that.param.lon = res.longitude;
  222. that.param.lat = res.latitude;
  223. that.getShopList()
  224. if (!that.cityName) {
  225. uni.request({
  226. url: `https://restapi.amap.com/v3/geocode/regeo?key=47798318a0d39673a1fb9729aa6a468a&location=${res.longitude+','+res.latitude}`, //仅为示例,并非真实接口地址。
  227. method: "GET",
  228. header: {
  229. "content-type": "application/x-www-form-urlencoded"
  230. },
  231. success: (re) => {
  232. console.log(re);
  233. that.cityName = re.data.regeocode
  234. .addressComponent.city;
  235. }
  236. });
  237. }
  238. },
  239. complete(e) {
  240. console.log(e)
  241. }
  242. });
  243. }
  244. })
  245. .finally(() => {
  246. })
  247. },
  248. // 门店列表
  249. getShopList() {
  250. let that = this
  251. if (this.selectIndex === null) {
  252. // this.param.category_id = null
  253. } else {
  254. this.param.classify_id = this.selector[this.selectIndex].id
  255. }
  256. console.log(this.param, 1111)
  257. this.$http.get('/service/goods/nearby', this.param).then(res => {
  258. uni.stopPullDownRefresh()
  259. if (res && res.code == 200) {
  260. this.list = res.list;
  261. }
  262. })
  263. },
  264. // 搜索防抖
  265. search() {
  266. clearTimeout(this.setTime)
  267. this.setTime = setTimeout(() => {
  268. this.getShopList()
  269. }, 1000)
  270. },
  271. }
  272. }
  273. </script>
  274. <style lang="scss" scoped>
  275. .top-box {
  276. position: fixed;
  277. background-color: #fff;
  278. z-index: 3;
  279. }
  280. .top-nav {
  281. height: 120rpx;
  282. display: flex;
  283. justify-content: space-between;
  284. align-items: center;
  285. padding: 0 30rpx;
  286. background-color: #fff;
  287. }
  288. .city-text {
  289. margin-right: 20rpx;
  290. font-size: 30rpx;
  291. font-family: PingFang SC, PingFang SC-Regular;
  292. font-weight: 400;
  293. text-align: center;
  294. color: #666666;
  295. display: flex;
  296. align-items: center;
  297. view {
  298. max-width: 100rpx;
  299. white-space: nowrap;
  300. text-overflow: ellipsis;
  301. overflow: hidden;
  302. }
  303. image {
  304. width: 26rpx;
  305. height: 36rpx;
  306. margin-right: 10rpx;
  307. vertical-align: middle;
  308. }
  309. }
  310. .searchBox {
  311. width: 560rpx;
  312. display: flex;
  313. padding: 10rpx 27rpx;
  314. border: 1rpx solid #CCCCCC;
  315. border-radius: 10rpx;
  316. display: flex;
  317. align-items: center;
  318. image {
  319. width: 35rpx;
  320. height: 35rpx;
  321. margin-right: 15rpx;
  322. flex-shrink: 0;
  323. }
  324. input {
  325. text-align: left;
  326. }
  327. }
  328. .tabsBox {
  329. width: 100%;
  330. background-color: #fff;
  331. .tabsBox_tabs {
  332. padding: 0 10rpx;
  333. /deep/ .u-tab-item {
  334. font-weight: 700;
  335. }
  336. }
  337. }
  338. .type-box {
  339. display: flex;
  340. align-items: center;
  341. padding: 0 40rpx 20rpx;
  342. justify-content: space-between;
  343. .item {
  344. display: flex;
  345. font-size: 28rpx;
  346. font-family: PingFang SC, PingFang SC-Regular;
  347. font-weight: 400;
  348. color: #4d4d4d;
  349. align-items: center;
  350. color: #4D4D4D;
  351. &:first-child {
  352. min-width: 142rpx;
  353. }
  354. image {
  355. width: 14rpx;
  356. height: 10rpx;
  357. margin-left: 10rpx;
  358. vertical-align: middle;
  359. }
  360. }
  361. .activeCls {
  362. color: #FA6138;
  363. }
  364. .item2 {
  365. margin-left: 100rpx;
  366. padding-top: 20rpx;
  367. }
  368. }
  369. .content-box {
  370. padding: 0 30rpx;
  371. }
  372. .shopListBox {
  373. padding: 0 30rpx;
  374. .shopListBox_item {
  375. margin-top: 30rpx;
  376. }
  377. .shopItem {
  378. // border-bottom: 1rpx solid #E6E6E6;
  379. padding-bottom: 40rpx;
  380. margin-bottom: 40rpx;
  381. .shopItem_title {
  382. font-size: 34rpx;
  383. color: #1A1A1A;
  384. font-weight: 700;
  385. margin-bottom: 20rpx;
  386. }
  387. .shopItem_data {
  388. display: flex;
  389. align-items: center;
  390. justify-content: space-between;
  391. font-size: 26rpx;
  392. image {
  393. width: 22rpx;
  394. height: 30rpx;
  395. }
  396. >view {
  397. display: flex;
  398. align-items: center;
  399. image {
  400. margin-right: 10rpx;
  401. }
  402. }
  403. .shopItem_data_distance {
  404. color: #666666;
  405. }
  406. }
  407. .gooodsBox {
  408. .gooods_item {
  409. display: flex;
  410. margin-top: 20rpx;
  411. image {
  412. width: 136rpx;
  413. height: 136rpx;
  414. margin-right: 35rpx;
  415. border-radius: 10rpx;
  416. flex-shrink: 0;
  417. }
  418. .gooods_item_r {
  419. display: flex;
  420. flex-direction: column;
  421. justify-content: space-around;
  422. >view {
  423. display: flex;
  424. align-items: center;
  425. }
  426. .gooods_item_r_title {
  427. font-size: 26rpx;
  428. color: #1A1A1A;
  429. overflow: hidden;
  430. text-overflow: ellipsis;
  431. display: -webkit-box;
  432. -webkit-line-clamp: 2;
  433. -webkit-box-orient: vertical;
  434. }
  435. .gooods_item_r_price {
  436. font-size: 36rpx;
  437. color: #00BF5A;
  438. font-weight: 600;
  439. text {
  440. font-size: 20rpx;
  441. display: inline-block;
  442. margin-right: 10rpx;
  443. }
  444. }
  445. .gooods_item_r_expense {
  446. font-size: 26rpx;
  447. color: #666666;
  448. margin-left: 52rpx;
  449. }
  450. }
  451. }
  452. }
  453. .lookOther {
  454. font-size: 24rpx;
  455. color: #333333;
  456. width: 288rpx;
  457. height: 59rpx;
  458. border-radius: 8rpx;
  459. background: #F2F2F2;
  460. display: flex;
  461. align-items: center;
  462. justify-content: center;
  463. margin: 20rpx auto 0;
  464. }
  465. }
  466. .item {
  467. display: flex;
  468. align-items: center;
  469. padding: 30rpx 0;
  470. // border-bottom: 1rpx solid #e6e6e6;
  471. .shop-img {
  472. width: 162rpx;
  473. height: 158rpx;
  474. margin-right: 40rpx;
  475. border-radius: 10rpx;
  476. overflow: hidden;
  477. flex-shrink: 0;
  478. image {
  479. width: 100%;
  480. height: 100%;
  481. }
  482. }
  483. .right {
  484. flex: 1;
  485. width: 0;
  486. .score-box,
  487. .address-box,
  488. .location2-box {
  489. display: flex;
  490. align-items: center;
  491. font-size: 24rpx;
  492. font-family: PingFang SC, PingFang SC-Regular;
  493. font-weight: 400;
  494. }
  495. .location1,
  496. .location2 {
  497. width: 20rpx;
  498. height: 27rpx;
  499. flex-shrink: 0;
  500. margin-right: 9rpx;
  501. }
  502. .location2 {
  503. width: 23rpx;
  504. height: 27rpx;
  505. }
  506. .light-start,
  507. .startt {
  508. width: 30rpx;
  509. height: 30rpx;
  510. margin-right: 12rpx;
  511. }
  512. .title {
  513. margin-bottom: 18rpx;
  514. font-size: 28rpx;
  515. font-family: PingFang SC, PingFang SC-Regular;
  516. color: #1a1a1a;
  517. }
  518. .score-box {
  519. align-items: normal;
  520. margin-bottom: 10rpx;
  521. font-family: PingFang SC, PingFang SC-Semibold;
  522. color: #333333;
  523. .score {
  524. flex-shrink: 0;
  525. }
  526. .score-text {
  527. font-size: 24rpx;
  528. font-family: PingFang SC, PingFang SC-Medium;
  529. font-weight: 500;
  530. text-align: left;
  531. color: #333333;
  532. flex-shrink: 0;
  533. }
  534. .ju {
  535. margin-left: 23rpx;
  536. font-size: 24rpx;
  537. color: #808080;
  538. text-align: left;
  539. overflow: hidden;
  540. text-overflow: ellipsis;
  541. white-space: nowrap;
  542. }
  543. }
  544. .address-box {
  545. // margin-bottom: 10rpx;
  546. font-family: PingFang SC;
  547. color: #666666;
  548. justify-content: space-between;
  549. .left {
  550. flex: 1;
  551. width: 0;
  552. display: flex;
  553. align-items: center;
  554. font-size: 24rpx;
  555. font-family: PingFang SC, PingFang SC-Regular;
  556. font-weight: 400;
  557. text-align: left;
  558. color: #333333;
  559. }
  560. .district {
  561. color: #1a1a1a;
  562. margin-right: 40rpx;
  563. overflow: hidden;
  564. text-overflow: ellipsis;
  565. white-space: nowrap;
  566. }
  567. .goShopping {
  568. display: flex;
  569. align-items: center;
  570. font-size: 40rpx;
  571. color: #FA6138;
  572. flex-shrink: 0;
  573. .text {
  574. font-size: 24rpx;
  575. font-family: PingFang SC, PingFang SC-Medium;
  576. font-weight: 500;
  577. text-align: left;
  578. color: #666666;
  579. }
  580. }
  581. }
  582. .location2-box {
  583. color: #333333;
  584. view {
  585. overflow: hidden;
  586. text-overflow: ellipsis;
  587. white-space: nowrap;
  588. }
  589. }
  590. }
  591. }
  592. }
  593. </style>