banner
This commit is contained in:
parent
90ece932c9
commit
6b7fb86023
|
|
@ -2,6 +2,7 @@ const request = require('../../utils/request');
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
carList: [],
|
carList: [],
|
||||||
|
type:1,
|
||||||
selectedSort: 'default',
|
selectedSort: 'default',
|
||||||
selectedBrand: '',
|
selectedBrand: '',
|
||||||
selectedPrice: '',
|
selectedPrice: '',
|
||||||
|
|
@ -75,6 +76,7 @@ Page({
|
||||||
brand:this.data.selectedSeriesId,
|
brand:this.data.selectedSeriesId,
|
||||||
price:this.data.selectedPrice,
|
price:this.data.selectedPrice,
|
||||||
attr:this.data.filterParams,
|
attr:this.data.filterParams,
|
||||||
|
type:this.data.type,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const raw = await request({
|
const raw = await request({
|
||||||
|
|
@ -97,7 +99,12 @@ Page({
|
||||||
address
|
address
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onLoad(){
|
onLoad(options){
|
||||||
|
if (options.type) {
|
||||||
|
this.setData({
|
||||||
|
type: options.type
|
||||||
|
});
|
||||||
|
}
|
||||||
this.loadBrandData();
|
this.loadBrandData();
|
||||||
},
|
},
|
||||||
async loadBrandData() {
|
async loadBrandData() {
|
||||||
|
|
|
||||||
|
|
@ -14,24 +14,35 @@ Page({
|
||||||
phone: '021-88888888'
|
phone: '021-88888888'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onShow() {
|
||||||
|
// 页面显示时刷新数据
|
||||||
|
this.loadBanner();
|
||||||
|
},
|
||||||
// 跳转到新车页面
|
// 跳转到新车页面
|
||||||
goToNewCar: function() {
|
goToNewCar: function () {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/pages/car_new/car_new'
|
url: '/pages/car_new/car_new?type=' + 1
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 跳转到租车页面
|
// 跳转到租车页面
|
||||||
goToRental: function() {
|
goToRental: function () {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/pages/rental/rental'
|
url: '/pages/car_new/car_new?type=' + 2
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 跳转到二手车页面
|
// 跳转到二手车页面
|
||||||
goToUsedCar: function() {
|
goToUsedCar: function () {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/pages/usedcar/usedcar'
|
url: '/pages/car_new/car_new?type=' + 3
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async loadBanner() {
|
||||||
|
const data = await request({
|
||||||
|
url: '/admin/wechat/api/banners'
|
||||||
|
});
|
||||||
|
this.setData({ bannerList: data })
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,21 @@
|
||||||
const request = require('../../utils/request');
|
const request = require('../../utils/request');
|
||||||
Page({
|
Page({
|
||||||
data: null,
|
data: {
|
||||||
|
currentImageIndex: 0
|
||||||
|
},
|
||||||
|
onSwiperChange(e) {
|
||||||
|
this.setData({
|
||||||
|
currentImageIndex: e.detail.current
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
previewImage(e) {
|
||||||
|
const current = e.currentTarget.dataset.src;
|
||||||
|
wx.previewImage({
|
||||||
|
current,
|
||||||
|
urls: this.data.carDetail.cover_image
|
||||||
|
});
|
||||||
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
// 获取车辆ID
|
// 获取车辆ID
|
||||||
if (options.id) {
|
if (options.id) {
|
||||||
|
|
@ -275,58 +290,12 @@ Page({
|
||||||
url: `/pages/loan-calculator/loan-calculator?price=${this.data.carDetail.price}`
|
url: `/pages/loan-calculator/loan-calculator?price=${this.data.carDetail.price}`
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 预约看车
|
|
||||||
bookViewing() {
|
|
||||||
wx.navigateTo({
|
|
||||||
url: `/pages/book-viewing/book-viewing?id=${this.data.carId}`
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 举报车辆
|
|
||||||
reportVehicle() {
|
|
||||||
wx.showActionSheet({
|
|
||||||
itemList: ['价格有误', '车况描述不符', '联系方式错误', '其他问题'],
|
|
||||||
success: (res) => {
|
|
||||||
const reasons = ['价格有误', '车况描述不符', '联系方式错误', '其他问题'];
|
|
||||||
const reason = reasons[res.tapIndex];
|
|
||||||
|
|
||||||
wx.showModal({
|
|
||||||
title: '举报确认',
|
|
||||||
content: `您要举报的原因:${reason}`,
|
|
||||||
success: (modalRes) => {
|
|
||||||
if (modalRes.confirm) {
|
|
||||||
// 提交举报
|
|
||||||
this.submitReport(reason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 提交举报
|
|
||||||
submitReport(reason) {
|
|
||||||
// 这里应该调用举报API
|
|
||||||
wx.showToast({
|
|
||||||
title: '举报成功',
|
|
||||||
icon: 'success'
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 页面下拉刷新
|
// 页面下拉刷新
|
||||||
onPullDownRefresh() {
|
onPullDownRefresh() {
|
||||||
this.loadCarDetail().then(() => {
|
this.loadCarDetail().then(() => {
|
||||||
wx.stopPullDownRefresh();
|
wx.stopPullDownRefresh();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 页面触底加载
|
|
||||||
onReachBottom() {
|
|
||||||
// 如果有相关推荐车辆,可以在这里加载
|
|
||||||
console.log('触底加载更多');
|
|
||||||
},
|
|
||||||
|
|
||||||
// 用户点击右上角分享
|
// 用户点击右上角分享
|
||||||
onShareAppMessage() {
|
onShareAppMessage() {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -7,32 +7,30 @@
|
||||||
</view>
|
</view>
|
||||||
</van-overlay>
|
</van-overlay>
|
||||||
|
|
||||||
<!-- 头部图片区域 -->
|
<!-- 头部图片区域 -->
|
||||||
<view class="hero-section">
|
<view class="hero-section">
|
||||||
|
<swiper
|
||||||
|
class="car-swiper"
|
||||||
|
indicator-dots="true"
|
||||||
|
autoplay="false"
|
||||||
|
current="{{currentImageIndex}}"
|
||||||
|
bindchange="onSwiperChange"
|
||||||
|
>
|
||||||
|
<block wx:for="{{carDetail.cover_image}}" wx:key="index">
|
||||||
|
<swiper-item>
|
||||||
<image
|
<image
|
||||||
src="{{carDetail.cover_image[0]}}"
|
src="{{item}}"
|
||||||
class="car-image"
|
class="car-image"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
bindtap="previewImage"
|
bindtap="previewImage"
|
||||||
data-src="{{carDetail.cover_image[0]}}"
|
data-src="{{item}}"
|
||||||
/>
|
/>
|
||||||
|
</swiper-item>
|
||||||
|
</block>
|
||||||
|
</swiper>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
<view class="car-desc">{{carDetail.desc}}</view>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 图片指示器 -->
|
|
||||||
<view class="image-indicator" wx:if="{{carDetail.cover_image.length > 1}}">
|
|
||||||
<text>1/{{carDetail.cover_image.length}}</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 更多图片按钮 -->
|
|
||||||
<view class="more-images-btn" bindtap="viewMoreImages" wx:if="{{carDetail.cover_image.length > 1}}">
|
|
||||||
<van-icon name="photo" size="16px" />
|
|
||||||
<text>查看更多</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="car-info-card car-type-{{carDetail.car_type}}">
|
<view class="car-info-card car-type-{{carDetail.car_type}}">
|
||||||
<view class="car-header">
|
<view class="car-header">
|
||||||
<view class="car-title">{{carDetail.title}}</view>
|
<view class="car-title">{{carDetail.title}}</view>
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,10 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
|
||||||
}
|
}
|
||||||
|
.car-swiper{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
.car-image {
|
.car-image {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const BASE_URL = 'https://car.cherrybless.com'; // 👈 换成你的后端地址
|
const BASE_URL = 'http://car.cherrybless.com'; // 👈 换成你的后端地址
|
||||||
|
|
||||||
function request({ url, method = 'GET', data = {}, header = {} }) {
|
function request({ url, method = 'GET', data = {}, header = {} }) {
|
||||||
const token = '';
|
const token = '';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user