index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. <template>
  2. <view>
  3. <view class='productList'>
  4. <view class='search bg-color acea-row row-between-wrapper'>
  5. <view class="back" @click='backjJump()'>
  6. <view class="iconfont icon-xiangzuo"></view>
  7. </view>
  8. <view class='input acea-row row-between-wrapper'><text class='iconfont icon-sousuo'></text>
  9. <input placeholder='搜索店铺名称' placeholder-class='placeholder' confirm-type='search' name="search" :value='sotreParam.keyword'
  10. @confirm="searchSubmit"></input>
  11. </view>
  12. <view v-if="mer_location == 1" style="text-align: right;" class='iconfont search-right' @click='showMaoLocation(latitude,longitude)'>
  13. <view class="iconfont icon-dingwei"></view>
  14. <view class="right-text" v-if="recommend_address">
  15. {{recommend_address}}
  16. </view>
  17. <view class="iconfont icon-xiangyou" v-if="recommend_address"></view>
  18. </view>
  19. </view>
  20. <view class="nav-wrapper">
  21. <view class='nav acea-row row-middle'>
  22. <view v-for="item in downMenus" :key="item.key" class='item' :class="{'font-colors':firstKey == item.key}" @click='set_where(item.key)'>
  23. <view class="">
  24. {{item.title}}
  25. </view>
  26. <view class="line" :class="{'font-line':firstKey == item.key}">
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 店铺 -->
  32. <block>
  33. <view class="mer-box">
  34. <view class="mer-item" v-for="(item,index) in storeList" :key='index'>
  35. <view class="mer-hd" @click="goStore(item.mer_id)">
  36. <image :src="item.mini_banner?item.mini_banner:item.mer_banner"></image>
  37. <view class="mer-name">
  38. <image :src="item.mer_avatar"></image>
  39. <view class="">
  40. <view class="mer-top">
  41. <view class="txt line1">{{item.mer_name}}</view>
  42. <text v-if="item.is_trader" class="font-bg-red ml8">自营</text>
  43. </view>
  44. <view class="mer-btn">
  45. <view class="">
  46. {{item.care_count}}人关注
  47. </view>
  48. <view class="line" v-if="item.distance"></view>
  49. <view class="distance" v-if="item.distance" @click.stop="showMaoLocation(item.lat,item.long)">
  50. <view class="">
  51. {{item.distance}}
  52. </view>
  53. <view class="iconfont icon-xiangyou"></view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="pro-box">
  60. <navigator :url="`/pages/goods_details/index?id=${itemn.product_id}`" hover-class="none" class="pro-item" v-for="(itemn,indexn) in item.recommend"
  61. :key='indexn' v-if="item.recommend.length<=3">
  62. <image :src="itemn.image" mode=""></image>
  63. <view class="price">
  64. <text>¥</text>{{itemn.price}}
  65. </view>
  66. </navigator>
  67. </view>
  68. </view>
  69. <view class='loadingicon acea-row row-center-wrapper' v-if="loading">
  70. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  71. </view>
  72. </view>
  73. <view class='no-shop' v-if="!storeList.length && !loading && !loadingIcon" v-cloak>
  74. <view class='pictrue' style="margin: 0 auto;">
  75. <image src='../static/images/no-shop.png'></image>
  76. <text>暂无店铺,快去搜索其他店铺吧</text>
  77. </view>
  78. </view>
  79. </block>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import {
  85. storeMerchantList,
  86. getGeocoder
  87. } from '@/api/store.js';
  88. import recommend from '@/components/recommend';
  89. import rightSlider from '@/components/rightSlider.vue'
  90. import {
  91. mapGetters
  92. } from "vuex";
  93. import {
  94. goShopDetail
  95. } from '@/libs/order.js'
  96. const app = getApp();
  97. export default {
  98. components: {
  99. recommend,
  100. },
  101. data() {
  102. return {
  103. price: 0,
  104. stock: 0,
  105. nows: false,
  106. loading: false,
  107. loadingIcon: true,
  108. loadTitle: '加载更多',
  109. title: '',
  110. hotPage: 1,
  111. hotLimit: 10,
  112. hotScroll: false,
  113. // 筛选框
  114. rightBox: false,
  115. //品牌列表
  116. brandList: [],
  117. downKey: 0,
  118. downStatus: false,
  119. // 下拉菜单
  120. downMenu: [{
  121. title: '默认',
  122. key: 0,
  123. order: ""
  124. },
  125. {
  126. title: '销量',
  127. key: 1,
  128. order: 'sales'
  129. },
  130. {
  131. title: '好评',
  132. key: 2,
  133. order: 'rate'
  134. },
  135. {
  136. title: '距离',
  137. key: 3,
  138. order: 'location'
  139. }
  140. ],
  141. // 是否第一个
  142. firstKey: 0,
  143. // 商铺列表
  144. storeList: [],
  145. sotreParam: {
  146. keyword: '',
  147. page: 1,
  148. limit: 10,
  149. order: ''
  150. },
  151. storeKey: 0,
  152. storeScroll: true,
  153. mer_id: '',
  154. sortId: '',
  155. hide_mer_status: "",
  156. price_on: '',
  157. price_off: '',
  158. detaile_address: "",
  159. recommend_address: "",
  160. latitude: "",
  161. longitude: "",
  162. count: 0,
  163. mer_location: ""
  164. };
  165. },
  166. created() {
  167. uni.getStorage({
  168. key: 'GLOBAL_DATA',
  169. success: (res) => {
  170. console.log(res);
  171. this.hide_mer_status = res.data.hide_mer_status
  172. if (res.data.mer_location == 1) {
  173. this.mer_location = res.data.mer_location
  174. this.selfLocation()
  175. } else {
  176. this.storeMerchantList();
  177. }
  178. }
  179. });
  180. },
  181. computed: {
  182. downMenus: function() {
  183. return this.downMenu.filter((item) => {
  184. if (this.mer_location) {
  185. return item
  186. } else {
  187. return item.key < 3
  188. }
  189. })
  190. }
  191. },
  192. methods: {
  193. /**
  194. * 打开地图
  195. *
  196. */
  197. showMaoLocation(lat, long) {
  198. console.log(lat, long)
  199. if (!lat || !long) return this.$util.Tips({
  200. title: '缺少经纬度信息无法查看地图!'
  201. });
  202. uni.openLocation({
  203. latitude: parseFloat(lat),
  204. longitude: parseFloat(long),
  205. scale: 8,
  206. // geocode: true,
  207. // address: this.detaile_address,
  208. success: function(res) {
  209. console.log(res)
  210. },
  211. });
  212. },
  213. selfLocation() {
  214. console.log('2222222')
  215. let self = this
  216. uni.getLocation({
  217. type: 'gcj02',
  218. success: (res) => {
  219. let latitude, longitude;
  220. latitude = res.latitude.toString();
  221. longitude = res.longitude.toString();
  222. this.latitude = res.latitude
  223. this.longitude = res.longitude
  224. getGeocoder({
  225. lat: latitude,
  226. long: longitude
  227. }).then(res => {
  228. console.log(res)
  229. this.detaile_address = res.data.address;
  230. this.recommend_address = res.data.address.length > 4 ? res.data.address
  231. .slice(
  232. 0,
  233. 4) + '...' : res.data.address
  234. })
  235. },
  236. fail: (res) => {
  237. uni.showToast({
  238. title: res,
  239. icon: 'none',
  240. duration: 1000
  241. });
  242. },
  243. complete: (res) => {
  244. this.storeMerchantList();
  245. }
  246. });
  247. },
  248. // 查找店铺
  249. storeMerchantList() {
  250. if (this.loading) return
  251. this.loading = true
  252. let rqData = {
  253. keyword: this.sotreParam.keyword,
  254. page: this.sotreParam.page,
  255. limit: 10,
  256. order: this.sotreParam.order
  257. }
  258. if (this.latitude) {
  259. rqData.location = this.latitude + ',' + this.longitude
  260. }
  261. storeMerchantList(rqData).then(res => {
  262. this.count = res.data.count
  263. this.storeList = this.storeList.concat(res.data.list)
  264. this.loading = false
  265. this.loadingIcon = false
  266. })
  267. },
  268. // 进店
  269. goStore(id) {
  270. if (this.hide_mer_status != 1) {
  271. uni.navigateTo({
  272. url: `/pages/store/home/index?id=${id}`
  273. })
  274. }
  275. },
  276. searchSubmit: function(e) {
  277. let that = this;
  278. that.$set(that.sotreParam, 'keyword', e.detail.value);
  279. this.set_where(this.firstKey)
  280. },
  281. //点击事件处理
  282. set_where: function(e) {
  283. if (this.loading) return
  284. console.log(this.downMenu, e)
  285. this.storeList = []
  286. this.firstKey = e
  287. this.sotreParam.page = 1
  288. this.sotreParam.order = this.downMenu[e].order
  289. this.storeMerchantList();
  290. },
  291. backjJump() {
  292. uni.navigateBack({
  293. delta: 1
  294. })
  295. },
  296. },
  297. //刷新
  298. onPullDownRefresh() {
  299. },
  300. //上划加载更多
  301. onReachBottom() {
  302. if (this.count === this.storeList.length) {
  303. if (this.count === 0) {
  304. return
  305. }
  306. uni.showToast({
  307. title: '已加载全部',
  308. icon: 'none',
  309. duration: 1000
  310. });
  311. } else {
  312. this.sotreParam.page += 1
  313. this.storeMerchantList()
  314. }
  315. }
  316. }
  317. </script>
  318. <style lang="scss">
  319. .productList .search {
  320. width: 100%;
  321. height: 86rpx;
  322. padding: 0 20rpx;
  323. box-sizing: border-box;
  324. position: fixed;
  325. left: 0;
  326. top: 0;
  327. z-index: 9;
  328. display: flex;
  329. flex-wrap: nowrap;
  330. .search-right {
  331. display: flex;
  332. align-items: center;
  333. justify-content: space-between;
  334. max-width: max-content;
  335. flex: 1;
  336. padding-left: 20rpx;
  337. }
  338. .right-text {
  339. overflow: hidden;
  340. text-overflow: ellipsis;
  341. white-space: nowrap;
  342. font-size: 28rpx;
  343. width: max-content;
  344. // max-width: 4.4rem;
  345. color: #fff;
  346. padding: 0 10rpx;
  347. }
  348. .icon-xiangyou,
  349. .icon-dingwei {
  350. font-size: 30rpx;
  351. color: #fff;
  352. }
  353. }
  354. .productList .search .back {
  355. display: flex;
  356. align-items: center;
  357. width: 40rpx;
  358. height: 60rpx;
  359. .iconfont {
  360. color: #fff;
  361. font-size: 36rpx;
  362. }
  363. }
  364. .productList .search .input {
  365. flex: 1;
  366. // width: 540rpx;
  367. height: 60rpx;
  368. background-color: #fff;
  369. border-radius: 50rpx;
  370. padding: 0 20rpx;
  371. box-sizing: border-box;
  372. }
  373. .productList .search .input input {
  374. flex: 1;
  375. height: 100%;
  376. font-size: 26rpx;
  377. margin-left: 10rpx;
  378. }
  379. .productList .search .input .placeholder {
  380. color: #999;
  381. }
  382. .productList .search .input .iconfont {
  383. font-size: 35rpx;
  384. color: #555;
  385. }
  386. .productList .search .icon-pailie,
  387. .productList .search .icon-tupianpailie {
  388. color: #fff;
  389. width: 62rpx;
  390. font-size: 40rpx;
  391. height: 86rpx;
  392. line-height: 86rpx;
  393. }
  394. .productList .nav-wrapper {
  395. z-index: 9;
  396. position: fixed;
  397. left: 0;
  398. top: 0;
  399. width: 100%;
  400. margin-top: 86rpx;
  401. background-color: $theme-color;
  402. .tab-bar {
  403. display: flex;
  404. align-items: center;
  405. .tab-item {
  406. position: relative;
  407. flex: 1;
  408. display: flex;
  409. justify-content: center;
  410. align-items: center;
  411. padding: 8rpx 0 20rpx;
  412. color: #fff;
  413. font-size: 28rpx;
  414. font-weight: bold;
  415. &::after {
  416. content: ' ';
  417. position: absolute;
  418. left: 50%;
  419. bottom: 18rpx;
  420. width: 30rpx;
  421. height: 3rpx;
  422. background: transparent;
  423. transform: translateX(-50%);
  424. }
  425. &.on {
  426. &::after {
  427. background: #fff;
  428. }
  429. }
  430. }
  431. }
  432. }
  433. .productList .nav {
  434. height: 86rpx;
  435. color: #454545;
  436. font-size: 28rpx;
  437. background-color: $theme-color;
  438. display: flex;
  439. justify-content: space-between;
  440. padding: 0 28rpx;
  441. }
  442. .productList .nav .item {
  443. display: flex;
  444. align-items: center;
  445. justify-content: center;
  446. flex-direction: column;
  447. color: #FFFFFF;
  448. flex: 1;
  449. }
  450. .productList .nav .item.font-colors {
  451. font-weight: 500;
  452. color: #FFFFFF;
  453. }
  454. .productList .nav .item .font-line {
  455. height: 4rpx;
  456. background-color: #fff;
  457. margin-top: 3rpx;
  458. width: 28rpx;
  459. animation: line 0.3s;
  460. -moz-animation: line 0.3s;
  461. /* Firefox */
  462. -webkit-animation: line 0.3s;
  463. /* Safari 和 Chrome */
  464. -o-animation: line 0.3s;
  465. /* Opera */
  466. }
  467. @keyframes line {
  468. from {
  469. width: 0rpx;
  470. }
  471. to {
  472. width: 28rpx;
  473. }
  474. }
  475. .productList .nav .item image {
  476. width: 15rpx;
  477. height: 19rpx;
  478. margin-left: 10rpx;
  479. }
  480. .mer-box {
  481. padding: 20rpx 20rpx;
  482. margin-top: 168rpx;
  483. .mer-item {
  484. margin-bottom: 20rpx;
  485. background-color: #fff;
  486. border-radius: 16rpx;
  487. .mer-hd {
  488. position: relative;
  489. width: 100%;
  490. // height: 134rpx;
  491. height: 200rpx;
  492. border-radius: 16rpx 16rpx 0 0;
  493. overflow: hidden;
  494. display: flex;
  495. image {
  496. width: 100%;
  497. height: 100%;
  498. }
  499. .mer-name {
  500. position: absolute;
  501. left: 20rpx;
  502. top: 30rpx;
  503. display: flex;
  504. align-items: center;
  505. padding: 0 10rpx;
  506. image {
  507. width: 79rpx;
  508. height: 79rpx;
  509. border: 1px solid #fff;
  510. border-radius: 50%;
  511. margin-right: 10rpx;
  512. }
  513. .mer-top {
  514. display: flex;
  515. align-items: center;
  516. color: #FFFFFF;
  517. font-size: 28rpx;
  518. font-weight: bold;
  519. margin-bottom: 6rpx;
  520. .txt {
  521. padding: 5rpx 10rpx;
  522. color: #000;
  523. background: #fff;
  524. border-radius: 20rpx;
  525. }
  526. .font-bg-red {
  527. margin-left: 20rpx;
  528. font-size: 18rpx;
  529. padding: 2rpx 10rpx;
  530. color: #E93323;
  531. background: #FFFFFF;
  532. border-radius: 30rpx;
  533. width: auto;
  534. }
  535. }
  536. .mer-btn {
  537. color: rgba($color: #fff, $alpha: 0.7);
  538. font-size: 24rpx;
  539. display: flex;
  540. align-items: center;
  541. .line {
  542. width: 2rpx;
  543. height: 18rpx;
  544. color: rgba($color: #fff, $alpha: 0.7);
  545. margin: 0 12rpx;
  546. }
  547. .distance {
  548. display: flex;
  549. align-items: center;
  550. font-size: 24rpx;
  551. color: rgba($color: #fff, $alpha: 0.7);
  552. .iconfont {
  553. font-size: 24rpx;
  554. line-height: 24rpx;
  555. }
  556. }
  557. }
  558. .txt {
  559. flex: 1;
  560. }
  561. }
  562. }
  563. .pro-box {
  564. display: flex;
  565. align-items: center;
  566. padding: 20rpx 20rpx 30rpx;
  567. .pro-item {
  568. width: 218rpx;
  569. margin-right: 14rpx;
  570. image {
  571. width: 100%;
  572. height: 214rpx;
  573. border-radius: 8rpx;
  574. }
  575. .price {
  576. margin-top: 5rpx;
  577. font-size: 28rpx;
  578. color: $theme-color;
  579. font-weight: bold;
  580. text {
  581. font-size: 28rpx;
  582. }
  583. }
  584. &:last-child {
  585. margin-right: 0;
  586. }
  587. }
  588. }
  589. }
  590. .more-shop {
  591. display: flex;
  592. align-items: center;
  593. justify-content: center;
  594. background-color: #FFFFFF;
  595. padding: 27rpx 0;
  596. color: #999999;
  597. font-size: 26rpx;
  598. .icon-xiangyou {
  599. font-size: 22rpx;
  600. }
  601. }
  602. }
  603. .no-shop {
  604. background-color: #fff;
  605. padding-bottom: calc(100% - 176rpx);
  606. .pictrue {
  607. display: flex;
  608. flex-direction: column;
  609. align-items: center;
  610. color: $uni-nothing-text;
  611. image {
  612. width: 414rpx;
  613. height: 380rpx;
  614. }
  615. }
  616. }
  617. </style>