index.vue 15 KB

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