index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <template>
  2. <view v-if="XCXIsSelect=='是'">
  3. <view style="position: fixed;top: 0;width: 100%;z-index: 999;">
  4. <view class="flex justify-between align-center bg-white padding-tb padding-lr-sm">
  5. <view class="flex-sub text-center" :class="current==1?'select':''" @click="confirm(1)">综合排序</view>
  6. <view class="flex-sub text-center" :class="current==3?'select':''" @click="confirm(3)">距离优先</view>
  7. <view class="flex-sub text-center" :class="current==4?'select':''" @click="confirm(4)">销量优先</view>
  8. <view class="flex-sub text-center flex" @click="isShow = !isShow">
  9. <view class="flex align-center" style="margin: 0 auto;">
  10. <view :class="isShow?'select':''">筛选</view>
  11. <u-icon v-if="!isShow" name="arrow-down" size="28"></u-icon>
  12. <u-icon v-if="isShow" name="arrow-up" color="#FCD202" size="28"></u-icon>
  13. </view>
  14. </view>
  15. </view>
  16. <view v-if="isShow"
  17. style="position: absolute;top: 90rpx;width: 100%;z-index: 1000;background: rgba(0,0,0,.5);height: 100vh;"
  18. @click="isShow =false">
  19. <view class="padding-lr bg-white">
  20. <view class="flex justify-between align-center padding-tb-sm u-border-bottom"
  21. v-for="(item,index) in options4" :key='index' @click.stop="getSelect(item)">
  22. <view class="text-df" :class="item.select?'select':''">{{item.shopTypeName}}</view>
  23. <u-icon v-if="item.select" name="checkmark" color="#FCD202" size="28"></u-icon>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- #ifdef H5 -->
  29. <view class="hd flex justify-center" style="position: fixed;top: 90rpx;" v-if="hdlist.length>0">
  30. <!-- #endif -->
  31. <!-- #ifndef H5 -->
  32. <view class="hd flex justify-center" style="position: fixed;top: 90rpx;" v-if="hdlist.length>0">
  33. <!-- #endif -->
  34. <view class="hd-box">
  35. <scroll-view scroll-x="true" class="scroll-view_H">
  36. <view class="hd-box-item" :style="currenthd==index?'background-color:#fcd202;font-weight:bold':''" @click="searchhd(index,item.activityId)" v-for="(item,index) in hdlist" :key="index">{{item.activityTitle}}</view>
  37. </scroll-view>
  38. </view>
  39. </view>
  40. <!-- #ifdef H5 -->
  41. <view class="padding-lr-sm" style="margin-top: 80rpx;">
  42. <!-- #endif -->
  43. <!-- #ifndef H5 -->
  44. <view class="padding-lr-sm" style="margin-top: 180rpx;">
  45. <!-- #endif -->
  46. <view class="" v-for="(item,index) in shopList" :key='index'>
  47. <view class="margin-tb-sm flex justify-between bg-white padding"
  48. @click="goNav('/pages/index/shop/index?shopId='+item.shopId)">
  49. <image :src="item.shopCover" class="radius" style="width: 160rpx;height: 160rpx;"></image>
  50. <view class=" margin-left-sm" style="width: 450rpx;">
  51. <view class=" flex flex-direction justify-between">
  52. <view class="text-lg text-bold text-black">{{item.shopName}}</view>
  53. <view class="flex align-center margin-top-xs" style="width: 100%;">
  54. <u-icon name="star-fill" color="#FD6416" size="28"></u-icon>
  55. <text class="text-lg" style=""> {{item.shopScore?item.shopScore:0}}</text>
  56. <text
  57. class="text-gray flex-sub margin-left-xs">销量{{item.shopSales?item.shopSales:0}}</text>
  58. <text class="text-gray margin-left-xs">{{item.errandTime}}分钟</text>
  59. <text class="text-gray margin-left-xs">{{item.distance}}</text>
  60. </view>
  61. <view class="text-gray margin-top-xs flex justify-between">
  62. <view>起送 ¥{{item.minimumDelivery}} 配送 ¥{{item.errandMoney?item.errandMoney:0}}
  63. </view>
  64. <view style="color: #FCD202;">{{item.autoSendOrder==1?'商家配送':'平台配送'}}</view>
  65. </view>
  66. <view class="text-gray margin-top-xs" v-if="item.businessHours&&item.lockHours">
  67. 营业时间:{{item.businessHours}}-{{item.lockHours}}</view>
  68. <view class="flex margin-top-xs justify-between align-start" style="width: 100%;">
  69. <view class="flex flex-wrap align-center" style="width: 100%;height: 100%;overflow: hidden;">
  70. <view class="lable flex justify-center align-center" v-if="item.exemptMinMoney">满{{item.exemptMinMoney}}免配送费</view>
  71. <view class="lable flex justify-center align-center" v-for="(ite,ind) in item.shopLable" :key='ind'
  72. v-if="item.shopLable">
  73. {{ite}}
  74. </view>
  75. <view class="lable flex justify-center align-center" v-if="item.couponList" style="border-radius: 4rpx;border: 1rpx solid red;background-color: #ffffff;color: red;box-sizing: border-box;" v-for="(it,ide) in item.couponList" :key="ide">满{{it.minMoney}}减{{it.money}}</view>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="flex margin-top-xs">
  80. <view v-for="(ite,ind) in item.goodsList" :key='ind'
  81. @click.stop="goDet(ite.goodsId,item.shopId)" style="width: 33%;">
  82. <image :src="ite.goodsCover" style="width: 120rpx;height: 120rpx;" class="radius"
  83. mode=""></image>
  84. <view class="u-line-1 text-df text-bold margin-top-xs">{{ite.goodsName}}</view>
  85. <view class="text-bold margin-top-xs" style="color: #FD6416;">
  86. <text class="text-sm">¥</text> {{ite.goodsMoney}}
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. <empty v-if="!shopList.length"></empty>
  95. </view>
  96. <view v-else>
  97. <view style="font-size: 28upx;" v-html="content"></view>
  98. </view>
  99. </template>
  100. <script>
  101. import empty from '@/components/empty.vue'
  102. export default {
  103. components: {
  104. empty
  105. },
  106. data() {
  107. return {
  108. currenthd:-1,
  109. hdlist:[],
  110. activityId:'',
  111. isShow: false,
  112. hintShow: false,
  113. shop: {},
  114. page: 1,
  115. limit: 10,
  116. shopList: [],
  117. current: 1,
  118. shopTypeId: '',
  119. userId: '',
  120. lng: '',
  121. lat: '',
  122. value1: 0,
  123. value2: 0,
  124. value3: 0,
  125. value4: 0,
  126. options1: [{
  127. label: '综合排序',
  128. value: 1,
  129. }],
  130. options2: [{
  131. value: '3',
  132. label: "距离优先"
  133. }],
  134. options3: [{
  135. value: '4',
  136. label: "销量优先"
  137. }],
  138. options4: [{
  139. id: '',
  140. select: true,
  141. shopTypeName: "全部"
  142. }],
  143. title: '综合排序',
  144. title1: '距离优先',
  145. title2: '销量优先',
  146. title3: '筛选',
  147. totalCount: 0,
  148. XCXIsSelect: '否',
  149. content:''
  150. }
  151. },
  152. onLoad(e) {
  153. console.log(e)
  154. this.XCXIsSelect = this.$queue.getData('XCXIsSelect');
  155. if (this.XCXIsSelect == '否') {
  156. this.getGuize()
  157. uni.setNavigationBarTitle({
  158. title: '隐私政策'
  159. });
  160. } else {
  161. uni.setNavigationBarTitle({
  162. title: '店铺列表'
  163. });
  164. }
  165. let that = this
  166. uni.showLoading({
  167. title: '加载中'
  168. })
  169. that.shopTypeId = e.value ? e.value : ''
  170. that.value2 = e.value ? e.value : 0
  171. that.userId = uni.getStorageSync('userId')
  172. that.getShopType()
  173. uni.getLocation({
  174. type: 'gcj02', //返回可以用于uni.openLocation的经纬度
  175. success: function(res) {
  176. that.lat = res.latitude;
  177. that.lng = res.longitude;
  178. }
  179. });
  180. that.getShopList()
  181. that.gethdlist();
  182. },
  183. methods: {
  184. //筛选活动
  185. searchhd(index,activityId){
  186. if(index==this.currenthd){
  187. this.currenthd = -1
  188. this.activityId = '';
  189. this.getShopList()
  190. }else{
  191. this.currenthd = index;
  192. this.activityId=activityId;
  193. this.getShopList()
  194. }
  195. },
  196. //获取所有活动
  197. gethdlist(){
  198. this.$Request.get("/app/activityManage/getActivityList").then(res => {
  199. if (res.code == 0) {
  200. res.data.records.map((item,index)=>{
  201. if(item.activityId==14){
  202. res.data.records.splice(index, 1)
  203. }
  204. })
  205. this.hdlist = res.data.records
  206. }
  207. });
  208. },
  209. // 跳转商品详情
  210. goDet(goodsId, shopId) {
  211. let userId = this.$queue.getData('userId');
  212. if (!userId) {
  213. uni.navigateTo({
  214. url: '/pages/public/login'
  215. })
  216. return
  217. }
  218. uni.navigateTo({
  219. url: '/pages/index/shop/goodsDet?goodsId=' + goodsId + '&shopId=' + shopId + '&orderType=2'
  220. })
  221. },
  222. getGuize() {
  223. this.$Request.getT('/app/common/type/237').then(res => {
  224. if (res.code == 0) {
  225. this.content = res.data.value;
  226. // this.tit = res.data.min
  227. }
  228. });
  229. },
  230. goBack() {
  231. uni.navigateBack({
  232. })
  233. },
  234. getSelect(e) {
  235. console.log(e)
  236. this.options4.forEach(res => {
  237. if (res.id == e.id) {
  238. res.select = true
  239. this.page = 1
  240. this.shopTypeId = e.id
  241. this.getShopList();
  242. this.isShow = false
  243. } else {
  244. res.select = false
  245. }
  246. })
  247. },
  248. confirm(e) {
  249. console.log(e)
  250. this.page = 1
  251. this.current = e;
  252. this.getShopList();
  253. },
  254. confirm2(e) {
  255. console.log(e)
  256. this.page = 1
  257. this.current = e;
  258. this.getShopList();
  259. },
  260. confirm3(e) {
  261. console.log(e)
  262. this.page = 1
  263. this.current = e;
  264. this.getShopList();
  265. },
  266. confirm4(e) {
  267. console.log(e)
  268. this.page = 1
  269. this.shopTypeId = e
  270. this.getShopList();
  271. },
  272. // 商户列表
  273. getShopList() {
  274. // this.lng = uni.getStorageSync('lng')
  275. // this.lat = uni.getStorageSync('lat')
  276. let data = {
  277. page: this.page,
  278. limit: this.limit,
  279. screen: this.current,
  280. shopTypeId: this.shopTypeId,
  281. lng: uni.getStorageSync('lng'),
  282. lat: uni.getStorageSync('lat'),
  283. activityId:this.activityId
  284. }
  285. this.$Request.getT('/app/goods/selectShop', data).then(res => {
  286. uni.hideLoading()
  287. if (res.code == 0) {
  288. console.log(res.data.list)
  289. this.totalCount = res.data.totalCount
  290. res.data.list.forEach(ret => {
  291. if (ret.distance > 1000) {
  292. ret.distance = Number((ret.distance / 1000)).toFixed(2) + "km"
  293. } else {
  294. if (ret.distance == 0) {
  295. ret.distance = "0m";
  296. } else {
  297. ret.distance = Number(ret.distance).toFixed(1) + "m";
  298. }
  299. }
  300. ret.shopLable = ret.shopLable ? ret.shopLable.split(',') : ''
  301. ret.shopCover = ret.shopCover ? ret.shopCover.split(',') :
  302. '../../static/logo.png'
  303. ret.errandTime = Math.round(ret.errandTime)
  304. ret.shopScore = ret.shopScore.toFixed(1)
  305. })
  306. if (this.page == 1) {
  307. this.shopList = res.data.list
  308. } else {
  309. this.shopList = [...this.shopList, ...res.data.list]
  310. }
  311. console.log(this.shopList)
  312. }
  313. })
  314. },
  315. // 商户类型
  316. getShopType() {
  317. this.$Request.getT('/app/shoptype/selectShopTypeList').then(res => {
  318. if (res.code == 0) {
  319. res.data.forEach(res => {
  320. res.select = false
  321. })
  322. this.options4 = [...this.options4, ...res.data]
  323. }
  324. })
  325. },
  326. goNav(url) {
  327. console.log(url)
  328. if (this.userId) {
  329. uni.navigateTo({
  330. url
  331. })
  332. } else {
  333. uni.navigateTo({
  334. url: '/pages/public/login'
  335. })
  336. }
  337. },
  338. goShopDet(url, e) {
  339. this.shop = e
  340. // console.log(e, '当前店铺')
  341. // let myDate = new Date();
  342. // let hours = myDate.getHours();
  343. // let minute = myDate.getMinutes();
  344. // let openTime = this.shop.businessHours.split(':')[0] //开始小时
  345. // let closeTime = this.shop.lockHours.split(':')[0] //结束小时
  346. // let openTime1 = this.shop.businessHours.split(':')[1] //开始分钟
  347. // let closeTime1 = this.shop.lockHours.split(':')[1] //结束分钟.
  348. // console.log(hours)
  349. // console.log(minute)
  350. // console.log(openTime)
  351. // console.log(openTime1)
  352. // console.log(closeTime)
  353. // console.log(closeTime1)
  354. // console.log(minute >= closeTime1)
  355. // if (hours < openTime) {
  356. // this.hintShow = true
  357. // return
  358. // } else if (hours == openTime && minute < openTime1) {
  359. // this.hintShow = true
  360. // return
  361. // } else if (hours >= closeTime) {
  362. // this.hintShow = true
  363. // return
  364. // } else if (hours == closeTime && minute >= closeTime1) {
  365. // this.hintShow = true
  366. // return
  367. // }
  368. console.log(url)
  369. if (this.userId) {
  370. uni.navigateTo({
  371. url
  372. })
  373. } else {
  374. uni.navigateTo({
  375. url: '/pages/public/login'
  376. })
  377. }
  378. },
  379. },
  380. onReachBottom: function() {
  381. if (this.shopList.length < this.totalCount) {
  382. this.page = this.page + 1;
  383. this.getShopList()
  384. } else {
  385. uni.showToast({
  386. title: '已经到底了',
  387. icon: 'none'
  388. })
  389. }
  390. },
  391. }
  392. </script>
  393. <style lang="scss">
  394. .hd{
  395. width: 100%;
  396. height: auto;
  397. background-color: rgb(248, 248, 248);
  398. padding: 20rpx 0 20rpx 0;
  399. z-index: 1;
  400. // margin-top: 20rpx;
  401. .hd-box{
  402. width: 686rpx;
  403. height: 100%;
  404. .scroll-view_H{
  405. width: 100%;
  406. white-space: nowrap;
  407. }
  408. .hd-box-item{
  409. display: inline-block;
  410. padding: 10rpx 20rpx 10rpx 20rpx;
  411. background-color: #ffffff;
  412. font-size: 24rpx;
  413. border-radius: 8rpx;
  414. margin-right: 10rpx;
  415. }
  416. }
  417. }
  418. .select {
  419. color: #FCD202;
  420. }
  421. .tabs {
  422. margin: 20rpx 0;
  423. display: flex;
  424. justify-content: space-between;
  425. align-items: center;
  426. }
  427. .tabs_name {
  428. flex: 1;
  429. /* display: inline-block; */
  430. text-align: center;
  431. margin-bottom: 30rpx 0;
  432. position: relative;
  433. display: flex;
  434. /* justify-content: space-between; */
  435. align-items: center;
  436. }
  437. .tabs_name view {
  438. margin: 0 auto;
  439. display: flex;
  440. align-items: center;
  441. }
  442. .tabs_2 {
  443. /* width: 30%; */
  444. }
  445. .actives {
  446. color: #007AFF;
  447. }
  448. .tabsicon {
  449. position: absolute;
  450. top: 0;
  451. right: 22rpx;
  452. width: 20rpx;
  453. height: 40rpx;
  454. z-index: 1;
  455. }
  456. .tabs_icon {
  457. width: 12rpx;
  458. height: 8rpx;
  459. z-index: 1;
  460. margin-left: 10rpx;
  461. }
  462. .icon1 {
  463. /* position: absolute; */
  464. /* top: 6rpx; */
  465. }
  466. .icon2 {
  467. position: absolute;
  468. bottom: 6rpx;
  469. }
  470. .hintPopul {
  471. width: 100%;
  472. height: 100vh;
  473. position: fixed;
  474. top: 0;
  475. background: rgba(0, 0, 0, .4);
  476. z-index: 999;
  477. }
  478. .content_ {
  479. position: absolute;
  480. left: 0;
  481. right: 0;
  482. top: 0;
  483. bottom: 0;
  484. margin: auto;
  485. text-align: center;
  486. width: 500rpx;
  487. height: 400rpx;
  488. border-radius: 20rpx;
  489. background-color: #fff;
  490. padding-top: 120rpx;
  491. }
  492. .content_ image {
  493. position: absolute;
  494. top: -50rpx;
  495. left: 0;
  496. right: 0;
  497. margin: auto;
  498. }
  499. .hintText {
  500. font-size: 30rpx;
  501. }
  502. .skuBtn {
  503. width: 460rpx;
  504. height: 60rpx;
  505. line-height: 60rpx;
  506. text-align: center;
  507. background: #FCD202;
  508. font-size: 28rpx;
  509. border: 2rpx solid #FCD202;
  510. color: #333333;
  511. border-radius: 50rpx;
  512. font-weight: 700;
  513. margin: auto;
  514. }
  515. .lable {
  516. border: 1rpx solid #FFE6D9;
  517. height: 40rpx;
  518. padding: 0 14rpx;
  519. background: #FFE6D9;
  520. border-radius: 4rpx;
  521. font-weight: 500;
  522. color: #FD6416;
  523. font-size: 20rpx;
  524. margin-right: 10rpx;
  525. margin-bottom: 10rpx;
  526. }
  527. </style>