index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <template>
  2. <view :style="viewColor">
  3. <view class='productList'>
  4. <view class='search 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>
  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"v-if="storeList.length > 0">
  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.type_name" class="font-bg-red ml8">{{item.type_name}}</text>
  43. <text v-else-if="item.is_trader" class="font-bg-red ml8">自营</text>
  44. </view>
  45. <view class="mer-btn">
  46. <view class="">
  47. {{item.care_count<10000 ? item.care_count : (item.care_count/10000).toFixed(2)+'万'}}人关注
  48. </view>
  49. <view class="line" v-if="item.distance"></view>
  50. <view class="distance" v-if="item.distance" @click.stop="showStoreLocation(item)">
  51. <view class="">
  52. {{item.distance}}
  53. </view>
  54. <view class="iconfont icon-xiangyou"></view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="pro-box">
  61. <navigator :url="`/pages/goods_details/index?id=${itemn.product_id}`" hover-class="none" class="pro-item" v-for="(itemn,indexn) in item.recommend"
  62. :key='indexn' v-if="item.recommend.length<=3">
  63. <image :src="itemn.image" mode=""></image>
  64. <view class="price">
  65. <text>¥</text>{{itemn.price}}
  66. </view>
  67. </navigator>
  68. </view>
  69. </view>
  70. <view class='loadingicon acea-row row-center-wrapper' v-if="loading">
  71. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  72. </view>
  73. </view>
  74. <view class='no-shop' v-if="!storeList.length && !loading && !loadingIcon" v-cloak>
  75. <view class='pictrue' style="margin: 0 auto;">
  76. <image src='http://ygs.hqgjsmc.com/baseimg/noCart.png'></image>
  77. <text>暂无店铺,快去搜索其他店铺吧</text>
  78. </view>
  79. </view>
  80. </block>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. // +----------------------------------------------------------------------
  86. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  87. // +----------------------------------------------------------------------
  88. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  89. // +----------------------------------------------------------------------
  90. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  91. // +----------------------------------------------------------------------
  92. // | Author: CRMEB Team <admin@crmeb.com>
  93. // +----------------------------------------------------------------------
  94. import {
  95. getGeocoder
  96. } from '@/api/store.js';
  97. import {
  98. getMerchantServiceLst,
  99. } from '@/api/activity.js';
  100. import {
  101. mapGetters
  102. } from "vuex";
  103. import {
  104. goShopDetail
  105. } from '@/libs/order.js'
  106. const app = getApp();
  107. export default {
  108. data() {
  109. return {
  110. price: 0,
  111. stock: 0,
  112. nows: false,
  113. loading: false,
  114. loadingIcon: true,
  115. loadTitle: '加载更多',
  116. title: '',
  117. hotPage: 1,
  118. hotLimit: 10,
  119. hotScroll: false,
  120. // 筛选框
  121. rightBox: false,
  122. //品牌列表
  123. brandList: [],
  124. downKey: 0,
  125. downStatus: false,
  126. // 下拉菜单
  127. downMenu: [{
  128. title: '默认',
  129. key: 0,
  130. order: ""
  131. },
  132. {
  133. title: '销量',
  134. key: 1,
  135. order: 'sales'
  136. },
  137. {
  138. title: '好评',
  139. key: 2,
  140. order: 'rate'
  141. },
  142. {
  143. title: '距离',
  144. key: 3,
  145. order: 'location'
  146. }
  147. ],
  148. // 是否第一个
  149. firstKey: 0,
  150. // 商铺列表
  151. storeList: [],
  152. sotreParam: {
  153. keyword: '',
  154. page: 1,
  155. limit: 10,
  156. order: '',
  157. },
  158. storeKey: 0,
  159. storeScroll: true,
  160. mer_id: '',
  161. sortId: '',
  162. hide_mer_status: "",
  163. price_on: '',
  164. price_off: '',
  165. detaile_address: "",
  166. recommend_address: "",
  167. latitude: "",
  168. longitude: "",
  169. count: 0,
  170. mer_location: "",
  171. };
  172. },
  173. created() {
  174. uni.getStorage({
  175. key: 'GLOBAL_DATA',
  176. success: (res) => {
  177. console.log(res);
  178. this.hide_mer_status = res.data.hide_mer_status
  179. this.storeList = []
  180. if (res.data.mer_location == 1) {
  181. this.mer_location = res.data.mer_location
  182. this.selfLocation()
  183. } else {
  184. this.getServiceList();
  185. }
  186. }
  187. });
  188. },
  189. computed: {
  190. downMenus: function() {
  191. return this.downMenu.filter((item) => {
  192. if (this.mer_location) {
  193. return item
  194. } else {
  195. return item.key < 3
  196. }
  197. })
  198. },
  199. ...mapGetters(['viewColor']),
  200. },
  201. onLoad: function(options) {
  202. this.mer_id = options.mer_id;
  203. },
  204. methods: {
  205. // 打开地图
  206. showMaoLocation(lat, long) {
  207. console.log(lat, long)
  208. if (!lat || !long) return this.$util.Tips({
  209. title: '请设置允许商城访问您的位置!'
  210. });
  211. //#ifdef H5
  212. if (this.$wechat.isWeixin() === true) {
  213. this.$wechat.seeLocation({
  214. latitude: Number(lat),
  215. longitude: Number(long)
  216. }).then(res=>{
  217. console.log('success');
  218. })
  219. }else{
  220. //#endif
  221. uni.openLocation({
  222. latitude: parseFloat(lat),
  223. longitude: parseFloat(long),
  224. scale: 8,
  225. success: function(res) {
  226. console.log(res)
  227. },
  228. });
  229. // #ifdef H5
  230. }
  231. //#endif
  232. },
  233. showStoreLocation(item) {
  234. console.log(lat, long)
  235. if (!item.lat || !item.long) return this.$util.Tips({
  236. title: '请设置允许商城访问您的位置!'
  237. });
  238. //#ifdef H5
  239. if (this.$wechat.isWeixin() === true) {
  240. this.$wechat.seeLocation({
  241. latitude: Number(item.lat),
  242. longitude: Number(item.long),
  243. name: item.mer_name,
  244. address: item.mer_address ? item.mer_address: '',
  245. }).then(res=>{
  246. console.log('success');
  247. })
  248. }else{
  249. //#endif
  250. uni.openLocation({
  251. latitude: parseFloat(item.lat),
  252. longitude: parseFloat(item.long),
  253. scale: 8,
  254. name: item.mer_name,
  255. address: item.mer_address ? item.mer_address: '',
  256. success: function(res) {
  257. console.log(res)
  258. },
  259. });
  260. // #ifdef H5
  261. }
  262. //#endif
  263. },
  264. selfLocation() {
  265. let self = this
  266. uni.getLocation({
  267. type: 'gcj02',
  268. success: (res) => {
  269. let latitude, longitude;
  270. latitude = res.latitude.toString();
  271. longitude = res.longitude.toString();
  272. this.latitude = res.latitude
  273. this.longitude = res.longitude
  274. getGeocoder({
  275. lat: latitude,
  276. long: longitude
  277. }).then(res => {
  278. console.log(res)
  279. this.detaile_address = res.data.address;
  280. this.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. this.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/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">
  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. color: var(--view-theme);
  572. border-color: var(--view-theme);
  573. background: #FFFFFF;
  574. border-radius: 30rpx;
  575. width: auto;
  576. }
  577. }
  578. .mer-btn {
  579. color: rgba($color: #fff, $alpha: 0.7);
  580. font-size: 24rpx;
  581. display: flex;
  582. align-items: center;
  583. .line {
  584. width: 2rpx;
  585. height: 18rpx;
  586. color: rgba($color: #fff, $alpha: 0.7);
  587. margin: 0 12rpx;
  588. }
  589. .distance {
  590. display: flex;
  591. align-items: center;
  592. font-size: 24rpx;
  593. color: rgba($color: #fff, $alpha: 0.7);
  594. .iconfont {
  595. font-size: 24rpx;
  596. line-height: 24rpx;
  597. }
  598. }
  599. }
  600. .txt {
  601. flex: 1;
  602. }
  603. }
  604. }
  605. .pro-box {
  606. display: flex;
  607. align-items: center;
  608. padding: 20rpx 20rpx 30rpx;
  609. .pro-item {
  610. width: 218rpx;
  611. margin-right: 14rpx;
  612. image {
  613. width: 100%;
  614. height: 214rpx;
  615. border-radius: 8rpx;
  616. }
  617. .price {
  618. margin-top: 5rpx;
  619. font-size: 28rpx;
  620. color: var(--view-priceColor);
  621. font-weight: bold;
  622. text {
  623. font-size: 28rpx;
  624. }
  625. }
  626. &:last-child {
  627. margin-right: 0;
  628. }
  629. }
  630. }
  631. }
  632. .more-shop {
  633. display: flex;
  634. align-items: center;
  635. justify-content: center;
  636. background-color: #FFFFFF;
  637. padding: 27rpx 0;
  638. color: #999999;
  639. font-size: 26rpx;
  640. .icon-xiangyou {
  641. font-size: 22rpx;
  642. }
  643. }
  644. }
  645. .no-shop {
  646. background-color: #fff;
  647. padding-bottom: calc(100% - 40rpx);
  648. padding-top: 200rpx;
  649. .pictrue {
  650. display: flex;
  651. flex-direction: column;
  652. align-items: center;
  653. color: $uni-nothing-text;
  654. image {
  655. width: 414rpx;
  656. height: 380rpx;
  657. }
  658. }
  659. }
  660. </style>