1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
<template>
<!-- 商户列表首页 -->
<view class="wrap">
<view class="banner">
<u-swiper :list="list" @change="e => currentNum = e.current" indicatorStyle="right: 20px;bottom:25px" height="350">
<view slot="indicator" class="indicator-num">
<text class="indicator-num__text">{{ currentNum + 1 }}/{{ list.length }}</text>
</view>
</u-swiper>
</view>
<view class="search">
<view class="search-wrap">
<view class="search-left">
重庆
<view class="line"></view>
</view>
<view class="search-right">
<input class="search-input" placeholder="景区关键词搜索" v-model="searchData" />
<text class="search-btn" @click="initList('','',true)">搜索</text>
</view>
</view>
</view>
<view class="merchant-wrap">
<view>
<!-- <u-tabs-swiper ref="uTabs" :list="tabList" :current="current" @change="tabsChange" :is-scroll="false" swiperWidth="750"></u-tabs-swiper> -->
</view>
<swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" class="swiper-box">
<swiper-item class="swiper-item">
<scroll-view scroll-y style="height:100%;width: 100%;">
<view class="merchant-list" v-for="(item,index) in scenicList" :key='index' @click="goProduct(item.id)" >
<view class="list-left">
<image :src="item.imgUrl"></image>
</view>
<view class="list-right">
<view class="right1">
{{item.name}}
</view>
<view class="right2">
<view class="right2-left">
<text v-for="(items, index) of item.tag.slice(0, 3)" :key="index" v-if="items">{{items}}</text>
</view>
<view class="right2-right" v-if="showDistance">
距您{{item.distance?parseFloat((item.distance/1000).toFixed(2)):0}}km
</view>
</view>
<view class="right3">
<text class="right3-text" v-for="(items, index) of item.tag.slice(0, 3)" :key="index" v-if="items">
{{items}}
</text>
<text @click.stop="clikDetail(item.id)">
详情
</text>
<u-icon name="arrow-right"></u-icon>
</view>
<view class="right4">
<view class="right4-left">
<!-- <text>已售10W+</text> -->
{{item.couponName||'优惠'}}
</view>
<view class="right4-right">
<text class="right4-price1">¥{{parseFloat(item.originalPrice)}}</text>
<text class="right4-price2">
¥<text style="font-size: 40rpx;font-weight: bold;">{{parseFloat(item.sellingPrice)}}</text>
</text>
<text style="color: #ccc;">起</text>
</view>
</view>
</view>
</view>
<u-empty text="空空如也..." mode="list" v-if="scenicList.length==0"></u-empty>
</scroll-view>
</swiper-item>
<swiper-item class="swiper-item">
<u-empty text="空空如也..." mode="list"></u-empty>
</swiper-item>
<swiper-item class="swiper-item">
<u-empty text="空空如也..." mode="list"></u-empty>
</swiper-item>
</swiper>
</view>
<merchantDetail :detailData='detailData' ref='merchantDetail'></merchantDetail>
<!-- 券1(抵用券) -->
<view class="coupon-wrap" v-if="showCoupon1" style="z-index: 101;">
<view @click="showCoupon1=false">
<view style="position: relative;">
<image src="@/static/img/coupon/coupon1.png" mode="widthFix"></image>
<view class="coupon1-content">
<image src="@/static/img/coupon/coupon-new.png" mode="widthFix" style="width: 356rpx;">
</image>
<view style="display: flex;justify-content: center;margin: 30rpx 0 70rpx 0;">
<view class="coupon1-price">
<view>
<text style="font-size: 52rpx;font-weight: bold;">{{couponPrice1}}</text>元
<text style="margin-left: 20rpx;font-weight: bold;">购买自动抵</text>
</view>
<view style="margin-top: 10rpx;">
<text>使用景区:两江夜游、云端之眼</text>
</view>
</view>
</view>
<view class="coupon1-btn">
<text class="btn">开心收下</text>
</view>
</view>
</view>
<view style="text-align: center;">
<u-icon name='close-circle' size='48' color="#ffffff"></u-icon>
</view>
</view>
</view>
<!-- 券2(代金券) -->
<view class="coupon-wrap" v-if="showCoupon2">
<view @click="showCoupon2=false">
<view style="text-align: right;">
<u-icon name='close-circle' size='48' color="#ffffff"></u-icon>
</view>
<image src="@/static/img/coupon/coupon2.png" mode="widthFix"></image>
</view>
</view>
</view>
</template>
<script>
import merchantDetail from '@/components/merchantDetail' //详情弹窗
export default {
components: {
merchantDetail
},
data() {
return {
showCoupon1:false,//是否显示券1
couponPrice1:0,//券价格
showCoupon2:false,//是否显示券2
detailData:'',//详情数据
scenicList:[],//景区数据
currentNum:0,//轮播图下标
list: [//轮播图图片
{
url: 'http://lx.pangdly.com/img/home1.69efcf8.jpg'
},
{
url: 'http://lx.pangdly.com/img/home2.2ec1a04.jpg'
},
{
url: 'http://lx.pangdly.com/img/home3.df60ec3.jpg'
}
],
tabList: [{
name: '热门景点'
}, {
name: '本地必吃'
}, {
name: '特价酒店'
}],
// 因为内部的滑动机制限制,请将tabs组件和swiper组件的current用不同变量赋值
current: 0, // tabs组件的current值,表示当前活动的tab选项
swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
searchData:'',//搜索框的值
showDistance:false,//定位成功显示距离
}
},
onLoad(option) {
//获取公司Id,保存到本地,支付等逻辑需要入口companyId
this.$commonjs.getCompanyId(option)
let token = uni.getStorageSync('token')||''
if(token){
uni.getLocation({
type: 'wgs84',
success:res=> {
let latitude = res.latitude//纬度
let longitude = res.longitude //经度
this.showDistance=true
this.initList(latitude,longitude,false)
},
fail:res=>{
let latitude=''
let longitude=''
this.initList(latitude,longitude,false)
}
})
this.giveCoupon()
}
},
methods: {
//---tabs通知swiper切换
tabsChange(index) {
this.swiperCurrent = index
},
//---swiper-item左右移动,通知tabs的滑块跟随移动
transition(e) {
let dx = e.detail.dx
this.$refs.uTabs.setDx(dx)
},
//---由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
// swiper滑动结束,分别设置tabs和swiper的状态
animationfinish(e) {
let current = e.detail.current
this.$refs.uTabs.setFinishCurrent(current)
this.swiperCurrent = current
this.current = current
},
//---跳转产品页面
goProduct(merchantId){
uni.navigateTo({
url:'/pages/combination/distributionCombiChoose/distributionCombiChoose?merchantId='+merchantId
})
},
//---加载数据
initList(latitude,longitude,click){
let data = {
userlongitude:longitude, //经度
userlatitude:latitude, //纬度
type: 1, //类型:1景区、2酒店、餐饮
pageIndex:1,//第几页
pageSize:20, //每页有多少条
}
if(click){
//如果是点击进行搜索
data.search=this.searchData
}
this.$request('scenic/user/merchant/findMerchantList', data).then(res => {
uni.hideLoading()
if (res.code == '00') {
this.scenicList=res.data.list||[]
this.scenicList.forEach((item, index) => {
item.tag = item.tag.split(',')
})
}else{
uni.showToast({
title: res.message,
icon: 'none'
})
}
}).catch(err=>{
uni.hideLoading()
})
},
//---送券
giveCoupon(){
let data={
pageCode:'merchantListIndex',//常量,写死
marketingStatus:1,
userId:uni.getStorageSync('userId')||'',
openid:uni.getStorageSync('openid')||''
}
this.$request('scenic/market/findPageMarket',data).then((res)=>{
let list=res.data||[]
if(list.length>0){
list.forEach(item=>{
if(item.couponType==1){
//抵用券
this.showCoupon1=true
this.couponPrice1=item.couponPrice
}
if(item.couponType==3){
//代金券
this.showCoupon2=true
}
})
}
})
},
//---点击详情
clikDetail(merchantId){
this.$refs.merchantDetail.showPop=true
this.initDetail(merchantId)
},
//---初始化详情
initDetail(merchantId){
let data={
userId:uni.getStorageSync('userId')||'',
openid:uni.getStorageSync('openid')||'',
id:merchantId,//商户id
isDetail:1,//商户详情
}
this.detailData=''
this.$request('scenic/user/merchant/findDetailInfo',data).then((res)=>{
if(res.code=='00'){
this.detailData=res.data
}else{
uni.showToast({
title: res.message,
icon: 'none'
})
}
})
},
}
}
</script>
<style scoped lang="scss">
.wrap{
height: 100%;
display: flex;
flex-direction: column;
background: #fff;
}
.search {
padding: 0 24rpx;
position: relative;
top: -40rpx;
}
.search-wrap {
background: #fff;
border-radius: 44rpx;
box-shadow: 0px 0px 8px 2px rgba(0, 0, 0, 0.08);
display: flex;
align-items: center;
height: 80rpx;
padding: 0 20rpx;
}
.search-left {
display: flex;
}
.line {
width: 2rpx;
background: #ccc;
margin: 0 20rpx;
}
.search-right {
display: flex;
flex: 1;
align-items: center;
}
.search-input {
flex: 1;
padding-right: 40rpx;
}
.search-btn {
background: $theme;
color: #fff;
border-radius: 32rpx;
padding: 12rpx 24rpx;
}
.merchant-wrap{
display: flex;
flex: 1;
flex-direction: column;
}
.swiper-box{
flex: 1;
}
.merchant-list{
padding: 0 24rpx;
margin-top: 32rpx;
display: flex;
font-size: 24rpx;
}
.list-left image{
width: 200rpx;
height: 200rpx;
border-radius: 16rpx;
margin-right: 20rpx;
}
.list-right{
flex: 1;
width: 0;
}
.right1{
width: 100%;
color: #191919;
font-weight: bold;
font-size: 32rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.right2{
margin-top: 20rpx;
display: flex;
justify-content: space-between;
}
.right2-left text{
color: $theme;
border: 1px solid $theme;
font-size: 20rpx;
padding: 2rpx 4rpx;
border-radius: 2rpx;
}
.right2 text:not(:last-child){
margin-right: 10rpx;
}
.right2-right{
color: #999999;
}
.right3{
margin-top: 16rpx;
display: flex;
}
.right3-text::after{
display: inline-block;
content: "";
height: 20rpx;
width: 2rpx;
background: #ccc;
margin: 0 10rpx;
}
.right4{
display: flex;
margin-top: 10rpx;
justify-content: space-between;
align-items: center;
}
.right4-left{
color: $red;
}
.right4-right{
flex-shrink: 0;
}
.right4-price1{
color: #999;
text-decoration:line-through;
font-size: 28rpx;
}
.right4-price2{
color: $red;
margin: 0 10rpx;
}
// 券
.coupon-wrap{
background: rgba(0, 0, 0, 0.5);
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100;
display: flex;
justify-content:center;
align-items: center;
}
.coupon1-content{
position: absolute;
top: 16vh;
color: #ffffff;
left: 80rpx;
width: 100%;
left: 0;
text-align: center;
}
.coupon1-price{
width: 465rpx;
height:155rpx;
padding: 10rpx 20rpx;
background: url('/static/img/coupon/redEnvelope.png') no-repeat;
background-size: 100% 100%;
text-align: left;
}
.coupon1-btn{
width: 100%;
}
.btn{
padding: 16rpx 60rpx;
border-radius:30rpx;
background: linear-gradient(#F19D38,#EB4926);
font-weight: bold;
font-size: 30rpx;
}
</style>