后台登录已经成功
This commit is contained in:
BIN
admin-system/src/assets/logo.png
Normal file
BIN
admin-system/src/assets/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -78,6 +78,40 @@ const endpoints = {
|
||||
CONFIG: '/system/config',
|
||||
NOTICE: '/system/notice',
|
||||
FEEDBACK: '/system/feedback'
|
||||
},
|
||||
|
||||
// 搜索相关
|
||||
SEARCH: {
|
||||
GLOBAL: '/search/global',
|
||||
SUGGESTIONS: '/search/suggestions',
|
||||
TRAVEL: '/search/travel',
|
||||
ANIMAL: '/search/animal',
|
||||
FLOWER: '/search/flower',
|
||||
USER: '/search/user'
|
||||
},
|
||||
|
||||
// 推广相关
|
||||
PROMOTION: {
|
||||
DATA: '/promotion/data',
|
||||
RECORDS: '/promotion/records',
|
||||
ALL_RECORDS: '/promotion/all-records',
|
||||
QRCODE: '/promotion/qrcode',
|
||||
REWARD_DETAILS: '/promotion/reward-details',
|
||||
WITHDRAW: '/promotion/withdraw',
|
||||
WITHDRAW_RECORDS: '/promotion/withdraw-records'
|
||||
},
|
||||
|
||||
// 认证相关
|
||||
AUTH: {
|
||||
PHONE_LOGIN: '/auth/phone-login',
|
||||
WECHAT_LOGIN: '/auth/wechat-login',
|
||||
PASSWORD_LOGIN: '/auth/password-login',
|
||||
SEND_SMS_CODE: '/auth/send-sms-code',
|
||||
CHECK_TOKEN: '/auth/check-token',
|
||||
REFRESH_TOKEN: '/auth/refresh-token',
|
||||
BIND_PHONE: '/auth/bind-phone',
|
||||
CHANGE_PASSWORD: '/auth/change-password',
|
||||
RESET_PASSWORD: '/auth/reset-password'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,81 @@ export const homeService = {
|
||||
getFeaturedFlowers: () => request.get('/home/featured-flowers')
|
||||
}
|
||||
|
||||
// 搜索服务
|
||||
export const searchService = {
|
||||
// 全局搜索
|
||||
search: (params = {}) => request.get(endpoints.SEARCH.GLOBAL, params),
|
||||
|
||||
// 获取搜索建议
|
||||
getSuggestions: (keyword) => request.get(endpoints.SEARCH.SUGGESTIONS, { keyword }),
|
||||
|
||||
// 旅行计划搜索
|
||||
searchTravel: (params = {}) => request.get(endpoints.SEARCH.TRAVEL, params),
|
||||
|
||||
// 动物搜索
|
||||
searchAnimal: (params = {}) => request.get(endpoints.SEARCH.ANIMAL, params),
|
||||
|
||||
// 花束搜索
|
||||
searchFlower: (params = {}) => request.get(endpoints.SEARCH.FLOWER, params),
|
||||
|
||||
// 用户搜索
|
||||
searchUser: (params = {}) => request.get(endpoints.SEARCH.USER, params)
|
||||
}
|
||||
|
||||
// 推广服务
|
||||
export const promotionService = {
|
||||
// 获取推广数据
|
||||
getPromotionData: () => request.get(endpoints.PROMOTION.DATA),
|
||||
|
||||
// 获取邀请记录
|
||||
getRecentRecords: (params = {}) => request.get(endpoints.PROMOTION.RECORDS, params),
|
||||
|
||||
// 获取所有邀请记录
|
||||
getAllRecords: (params = {}) => request.get(endpoints.PROMOTION.ALL_RECORDS, params),
|
||||
|
||||
// 生成邀请二维码
|
||||
generateQRCode: () => request.get(endpoints.PROMOTION.QRCODE),
|
||||
|
||||
// 获取奖励明细
|
||||
getRewardDetails: (params = {}) => request.get(endpoints.PROMOTION.REWARD_DETAILS, params),
|
||||
|
||||
// 提现申请
|
||||
applyWithdraw: (data) => request.post(endpoints.PROMOTION.WITHDRAW, data),
|
||||
|
||||
// 获取提现记录
|
||||
getWithdrawRecords: (params = {}) => request.get(endpoints.PROMOTION.WITHDRAW_RECORDS, params)
|
||||
}
|
||||
|
||||
// 认证服务
|
||||
export const authService = {
|
||||
// 手机号登录
|
||||
phoneLogin: (data) => request.post(endpoints.AUTH.PHONE_LOGIN, data),
|
||||
|
||||
// 微信登录
|
||||
wechatLogin: (data) => request.post(endpoints.AUTH.WECHAT_LOGIN, data),
|
||||
|
||||
// 密码登录
|
||||
passwordLogin: (data) => request.post(endpoints.AUTH.PASSWORD_LOGIN, data),
|
||||
|
||||
// 发送短信验证码
|
||||
sendSmsCode: (phone) => request.post(endpoints.AUTH.SEND_SMS_CODE, { phone }),
|
||||
|
||||
// 验证token
|
||||
checkToken: (token) => request.post(endpoints.AUTH.CHECK_TOKEN, { token }),
|
||||
|
||||
// 刷新token
|
||||
refreshToken: (refreshToken) => request.post(endpoints.AUTH.REFRESH_TOKEN, { refreshToken }),
|
||||
|
||||
// 绑定手机号
|
||||
bindPhone: (data) => request.post(endpoints.AUTH.BIND_PHONE, data),
|
||||
|
||||
// 修改密码
|
||||
changePassword: (data) => request.post(endpoints.AUTH.CHANGE_PASSWORD, data),
|
||||
|
||||
// 重置密码
|
||||
resetPassword: (data) => request.post(endpoints.AUTH.RESET_PASSWORD, data)
|
||||
}
|
||||
|
||||
// 工具函数
|
||||
export const apiUtils = {
|
||||
// 生成分页参数
|
||||
@@ -185,5 +260,8 @@ export default {
|
||||
paymentService,
|
||||
systemService,
|
||||
homeService,
|
||||
authService,
|
||||
searchService,
|
||||
promotionService,
|
||||
apiUtils
|
||||
}
|
||||
@@ -1,17 +1,113 @@
|
||||
{
|
||||
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "uni-app"
|
||||
"navigationBarTitleText": "结伴客",
|
||||
"navigationBarBackgroundColor": "#007aff",
|
||||
"navigationBarTextStyle": "white"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/travel/list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "旅行计划",
|
||||
"navigationBarBackgroundColor": "#007aff",
|
||||
"navigationBarTextStyle": "white"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/animal/list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "动物认养",
|
||||
"navigationBarBackgroundColor": "#007aff",
|
||||
"navigationBarTextStyle": "white"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/flower/list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "鲜花配送",
|
||||
"navigationBarBackgroundColor": "#ff6b8b",
|
||||
"navigationBarTextStyle": "white"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/promotion/invite",
|
||||
"style": {
|
||||
"navigationBarTitleText": "邀请好友",
|
||||
"navigationBarBackgroundColor": "#667eea",
|
||||
"navigationBarTextStyle": "white"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/search/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索",
|
||||
"navigationBarBackgroundColor": "#007aff",
|
||||
"navigationBarTextStyle": "white"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/auth/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "登录",
|
||||
"navigationBarBackgroundColor": "#007aff",
|
||||
"navigationBarTextStyle": "white"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarTitleText": "结伴客",
|
||||
"navigationBarBackgroundColor": "#007aff",
|
||||
"backgroundColor": "#f8f9fa",
|
||||
"app-plus": {
|
||||
"titleNView": {
|
||||
"backgroundColor": "#007aff",
|
||||
"titleColor": "#ffffff",
|
||||
"titleSize": "17px"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"tabBar": {
|
||||
"color": "#7A7E83",
|
||||
"selectedColor": "#007aff",
|
||||
"borderStyle": "black",
|
||||
"backgroundColor": "#ffffff",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home-active.png",
|
||||
"text": "首页"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/travel/list",
|
||||
"iconPath": "static/tabbar/travel.png",
|
||||
"selectedIconPath": "static/tabbar/travel-active.png",
|
||||
"text": "旅行"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/animal/list",
|
||||
"iconPath": "static/tabbar/animal.png",
|
||||
"selectedIconPath": "static/tabbar/animal-active.png",
|
||||
"text": "认养"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/flower/list",
|
||||
"iconPath": "static/tabbar/flower.png",
|
||||
"selectedIconPath": "static/tabbar/flower-active.png",
|
||||
"text": "鲜花"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/user/center",
|
||||
"iconPath": "static/tabbar/user.png",
|
||||
"selectedIconPath": "static/tabbar/user-active.png",
|
||||
"text": "我的"
|
||||
}
|
||||
]
|
||||
},
|
||||
"uniIdRouter": {}
|
||||
}
|
||||
|
||||
645
mini-program/pages/animal/list.vue
Normal file
645
mini-program/pages/animal/list.vue
Normal file
@@ -0,0 +1,645 @@
|
||||
<template>
|
||||
<view class="animal-list-page">
|
||||
<!-- 顶部搜索栏 -->
|
||||
<view class="search-header">
|
||||
<view class="search-input" @click="navigateToSearch">
|
||||
<uni-icons type="search" size="16" color="#999"></uni-icons>
|
||||
<text class="placeholder">搜索动物名称、品种</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 分类筛选 -->
|
||||
<view class="category-bar">
|
||||
<scroll-view class="category-scroll" scroll-x="true">
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'all' }"
|
||||
@click="changeCategory('all')"
|
||||
>
|
||||
<text>全部</text>
|
||||
</view>
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'cow' }"
|
||||
@click="changeCategory('cow')"
|
||||
>
|
||||
<text>牛类</text>
|
||||
</view>
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'sheep' }"
|
||||
@click="changeCategory('sheep')"
|
||||
>
|
||||
<text>羊类</text>
|
||||
</view>
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'pig' }"
|
||||
@click="changeCategory('pig')"
|
||||
>
|
||||
<text>猪类</text>
|
||||
</view>
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'chicken' }"
|
||||
@click="changeCategory('chicken')"
|
||||
>
|
||||
<text>鸡类</text>
|
||||
</view>
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'other' }"
|
||||
@click="changeCategory('other')"
|
||||
>
|
||||
<text>其他</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- 排序和筛选 -->
|
||||
<view class="filter-bar">
|
||||
<view class="filter-item" @click="showSortPopup">
|
||||
<text>{{ sortOptions[currentSort] }}</text>
|
||||
<uni-icons type="arrow-down" size="14" color="#666"></uni-icons>
|
||||
</view>
|
||||
<view class="filter-item" @click="showFilterPopup">
|
||||
<text>筛选</text>
|
||||
<uni-icons type="funnel" size="14" color="#666"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 动物列表 -->
|
||||
<view class="animal-list">
|
||||
<view class="animal-item" v-for="animal in animalList" :key="animal.id" @click="navigateToDetail(animal.id)">
|
||||
<image :src="animal.image" class="animal-image" mode="aspectFill"></image>
|
||||
<view class="animal-info">
|
||||
<text class="animal-name">{{ animal.name }}</text>
|
||||
<text class="animal-species">{{ animal.species }}</text>
|
||||
<text class="animal-location">{{ animal.location }}</text>
|
||||
<view class="animal-price">
|
||||
<text class="price-label">认养价格</text>
|
||||
<text class="price-value">¥{{ animal.price }}</text>
|
||||
</view>
|
||||
<view class="animal-status">
|
||||
<text class="status-tag" :class="getStatusClass(animal.status)">{{ getStatusText(animal.status) }}</text>
|
||||
<text class="hot-tag" v-if="animal.isHot">热门</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view class="load-more" v-if="hasMore">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
<view class="no-more" v-else>
|
||||
<text>没有更多数据了</text>
|
||||
</view>
|
||||
|
||||
<!-- 排序弹窗 -->
|
||||
<uni-popup ref="sortPopup" type="bottom">
|
||||
<view class="popup-content">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">排序方式</text>
|
||||
<uni-icons type="close" size="20" color="#999" @click="closeSortPopup"></uni-icons>
|
||||
</view>
|
||||
<view class="sort-options">
|
||||
<view
|
||||
class="sort-option"
|
||||
v-for="(label, key) in sortOptions"
|
||||
:key="key"
|
||||
:class="{ active: currentSort === key }"
|
||||
@click="selectSort(key)"
|
||||
>
|
||||
<text>{{ label }}</text>
|
||||
<uni-icons type="checkmark" size="16" color="#007aff" v-if="currentSort === key"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
||||
<!-- 筛选弹窗 -->
|
||||
<uni-popup ref="filterPopup" type="bottom">
|
||||
<view class="popup-content">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">筛选</text>
|
||||
<uni-icons type="close" size="20" color="#999" @click="closeFilterPopup"></uni-icons>
|
||||
</view>
|
||||
<view class="filter-options">
|
||||
<!-- 价格范围 -->
|
||||
<view class="filter-section">
|
||||
<text class="section-title">价格范围</text>
|
||||
<view class="price-range">
|
||||
<input
|
||||
type="number"
|
||||
placeholder="最低价"
|
||||
v-model="filterParams.minPrice"
|
||||
class="price-input"
|
||||
/>
|
||||
<text class="range-separator">-</text>
|
||||
<input
|
||||
type="number"
|
||||
placeholder="最高价"
|
||||
v-model="filterParams.maxPrice"
|
||||
class="price-input"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 地理位置 -->
|
||||
<view class="filter-section">
|
||||
<text class="section-title">地理位置</text>
|
||||
<view class="location-options">
|
||||
<view
|
||||
class="location-option"
|
||||
v-for="location in locationOptions"
|
||||
:key="location.value"
|
||||
:class="{ active: filterParams.location === location.value }"
|
||||
@click="toggleLocation(location.value)"
|
||||
>
|
||||
<text>{{ location.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<view class="filter-actions">
|
||||
<view class="reset-btn" @click="resetFilter">重置</view>
|
||||
<view class="confirm-btn" @click="applyFilter">确认</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { animalService } from '../../api/services.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
animalList: [],
|
||||
activeCategory: 'all',
|
||||
currentSort: 'default',
|
||||
sortOptions: {
|
||||
default: '默认排序',
|
||||
priceAsc: '价格从低到高',
|
||||
priceDesc: '价格从高到低',
|
||||
popularity: '人气最高',
|
||||
newest: '最新上架'
|
||||
},
|
||||
filterParams: {
|
||||
minPrice: '',
|
||||
maxPrice: '',
|
||||
location: ''
|
||||
},
|
||||
locationOptions: [
|
||||
{ label: '西藏', value: 'tibet' },
|
||||
{ label: '内蒙古', value: 'inner_mongolia' },
|
||||
{ label: '新疆', value: 'xinjiang' },
|
||||
{ label: '四川', value: 'sichuan' },
|
||||
{ label: '云南', value: 'yunnan' }
|
||||
],
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
hasMore: true,
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadAnimalList()
|
||||
},
|
||||
|
||||
onReachBottom() {
|
||||
if (this.hasMore && !this.loading) {
|
||||
this.loadMore()
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async loadAnimalList() {
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {
|
||||
page: this.currentPage,
|
||||
pageSize: this.pageSize,
|
||||
category: this.activeCategory === 'all' ? undefined : this.activeCategory,
|
||||
sort: this.currentSort === 'default' ? undefined : this.currentSort,
|
||||
...this.filterParams
|
||||
}
|
||||
|
||||
const response = await animalService.getList(params)
|
||||
this.animalList = response.list || []
|
||||
this.hasMore = response.total > this.currentPage * this.pageSize
|
||||
} catch (error) {
|
||||
console.error('加载动物列表失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
async loadMore() {
|
||||
this.currentPage++
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {
|
||||
page: this.currentPage,
|
||||
pageSize: this.pageSize,
|
||||
category: this.activeCategory === 'all' ? undefined : this.activeCategory,
|
||||
sort: this.currentSort === 'default' ? undefined : this.currentSort,
|
||||
...this.filterParams
|
||||
}
|
||||
|
||||
const response = await animalService.getList(params)
|
||||
this.animalList = [...this.animalList, ...(response.list || [])]
|
||||
this.hasMore = response.total > this.currentPage * this.pageSize
|
||||
} catch (error) {
|
||||
console.error('加载更多失败:', error)
|
||||
this.currentPage--
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
changeCategory(category) {
|
||||
if (this.activeCategory !== category) {
|
||||
this.activeCategory = category
|
||||
this.currentPage = 1
|
||||
this.animalList = []
|
||||
this.loadAnimalList()
|
||||
}
|
||||
},
|
||||
|
||||
showSortPopup() {
|
||||
this.$refs.sortPopup.open()
|
||||
},
|
||||
|
||||
closeSortPopup() {
|
||||
this.$refs.sortPopup.close()
|
||||
},
|
||||
|
||||
selectSort(sort) {
|
||||
this.currentSort = sort
|
||||
this.closeSortPopup()
|
||||
this.currentPage = 1
|
||||
this.animalList = []
|
||||
this.loadAnimalList()
|
||||
},
|
||||
|
||||
showFilterPopup() {
|
||||
this.$refs.filterPopup.open()
|
||||
},
|
||||
|
||||
closeFilterPopup() {
|
||||
this.$refs.filterPopup.close()
|
||||
},
|
||||
|
||||
toggleLocation(location) {
|
||||
this.filterParams.location = this.filterParams.location === location ? '' : location
|
||||
},
|
||||
|
||||
applyFilter() {
|
||||
this.closeFilterPopup()
|
||||
this.currentPage = 1
|
||||
this.animalList = []
|
||||
this.loadAnimalList()
|
||||
},
|
||||
|
||||
resetFilter() {
|
||||
this.filterParams = {
|
||||
minPrice: '',
|
||||
maxPrice: '',
|
||||
location: ''
|
||||
}
|
||||
},
|
||||
|
||||
getStatusClass(status) {
|
||||
const statusMap = {
|
||||
available: 'available',
|
||||
adopted: 'adopted',
|
||||
reserved: 'reserved'
|
||||
}
|
||||
return statusMap[status] || 'available'
|
||||
},
|
||||
|
||||
getStatusText(status) {
|
||||
const statusTextMap = {
|
||||
available: '可认养',
|
||||
adopted: '已认养',
|
||||
reserved: '预定中'
|
||||
}
|
||||
return statusTextMap[status] || '可认养'
|
||||
},
|
||||
|
||||
navigateToDetail(id) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/animal/detail?id=${id}`
|
||||
})
|
||||
},
|
||||
|
||||
navigateToSearch() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/search/index?type=animal'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.animal-list-page {
|
||||
background-color: #f8f9fa;
|
||||
min-height: 100vh;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.search-header {
|
||||
background-color: #fff;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 60rpx;
|
||||
background-color: #f0f0f0;
|
||||
border-radius: 30rpx;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.category-bar {
|
||||
background-color: #fff;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.category-scroll {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
display: inline-block;
|
||||
padding: 10rpx 25rpx;
|
||||
margin: 0 10rpx;
|
||||
border-radius: 25rpx;
|
||||
background-color: #f8f9fa;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.category-item.active {
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.filter-bar {
|
||||
display: flex;
|
||||
background-color: #fff;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.filter-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10rpx 20rpx;
|
||||
margin-right: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
background-color: #f8f9fa;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.animal-list {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.animal-item {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.animal-image {
|
||||
width: 100%;
|
||||
height: 300rpx;
|
||||
}
|
||||
|
||||
.animal-info {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.animal-name {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.animal-species {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.animal-location {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
display: block;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.animal-price {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.price-label {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.price-value {
|
||||
font-size: 32rpx;
|
||||
color: #ff6b35;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.animal-status {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-tag {
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 12rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.status-tag.available {
|
||||
background-color: #e6f7ff;
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.status-tag.adopted {
|
||||
background-color: #f6ffed;
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.status-tag.reserved {
|
||||
background-color: #fff2f0;
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.hot-tag {
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #fff7e6;
|
||||
color: #fa8c16;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.load-more,
|
||||
.no-more {
|
||||
text-align: center;
|
||||
padding: 30rpx;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 弹窗样式 */
|
||||
.popup-content {
|
||||
background-color: #fff;
|
||||
border-radius: 24rpx 24rpx 0 0;
|
||||
padding: 40rpx;
|
||||
}
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.sort-options {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.sort-option {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 25rpx 0;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.sort-option.active {
|
||||
color: #007aff;
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.price-range {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.price-input {
|
||||
flex: 1;
|
||||
height: 70rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 8rpx;
|
||||
padding: 0 20rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.range-separator {
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.location-options {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15rpx;
|
||||
}
|
||||
|
||||
.location-option {
|
||||
padding: 15rpx 25rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 8rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.location-option.active {
|
||||
border-color: #007aff;
|
||||
background-color: #e6f7ff;
|
||||
color: #007aff;
|
||||
}
|
||||
|
||||
.filter-actions {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.reset-btn,
|
||||
.confirm-btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.reset-btn {
|
||||
border: 1rpx solid #ddd;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
712
mini-program/pages/auth/login.vue
Normal file
712
mini-program/pages/auth/login.vue
Normal file
@@ -0,0 +1,712 @@
|
||||
<template>
|
||||
<view class="login-page">
|
||||
<!-- 顶部背景 -->
|
||||
<view class="login-header">
|
||||
<image src="/static/auth/login-bg.png" class="header-bg" mode="aspectFill"></image>
|
||||
<view class="header-content">
|
||||
<text class="welcome-text">欢迎来到结伴客</text>
|
||||
<text class="subtitle">开启您的结伴之旅</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 登录表单 -->
|
||||
<view class="login-form">
|
||||
<!-- 手机号登录 -->
|
||||
<view class="form-section" v-if="loginType === 'phone'">
|
||||
<view class="input-group">
|
||||
<view class="input-item">
|
||||
<uni-icons type="phone" size="20" color="#999"></uni-icons>
|
||||
<input
|
||||
type="number"
|
||||
v-model="phoneForm.phone"
|
||||
placeholder="请输入手机号码"
|
||||
placeholder-class="placeholder"
|
||||
maxlength="11"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="input-item">
|
||||
<uni-icons type="locked" size="20" color="#999"></uni-icons>
|
||||
<input
|
||||
type="number"
|
||||
v-model="phoneForm.code"
|
||||
placeholder="请输入验证码"
|
||||
placeholder-class="placeholder"
|
||||
maxlength="6"
|
||||
/>
|
||||
<view
|
||||
class="send-code-btn"
|
||||
:class="{ disabled: !canSendCode }"
|
||||
@click="sendCode"
|
||||
>
|
||||
{{ codeCountdown > 0 ? `${codeCountdown}s` : '获取验证码' }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="login-btn" :class="{ loading: loading }" @click="handlePhoneLogin">
|
||||
<text v-if="!loading">登录</text>
|
||||
<uni-icons v-else type="spinner-cycle" size="20" color="#fff"></uni-icons>
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- 微信一键登录 -->
|
||||
<view class="form-section" v-else-if="loginType === 'wechat'">
|
||||
<view class="wechat-login-tip">
|
||||
<text>一键授权,快速登录</text>
|
||||
</view>
|
||||
|
||||
<button class="wechat-login-btn" open-type="getPhoneNumber" @getphonenumber="handleWechatLogin">
|
||||
<uni-icons type="weixin" size="24" color="#fff"></uni-icons>
|
||||
<text>微信一键登录</text>
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- 其他登录方式 -->
|
||||
<view class="other-login-methods">
|
||||
<text class="divider">其他登录方式</text>
|
||||
|
||||
<view class="method-list">
|
||||
<view class="method-item" @click="switchLoginType('phone')" v-if="loginType !== 'phone'">
|
||||
<uni-icons type="phone" size="24" color="#007aff"></uni-icons>
|
||||
<text>手机验证码登录</text>
|
||||
</view>
|
||||
|
||||
<view class="method-item" @click="switchLoginType('wechat')" v-if="loginType !== 'wechat'">
|
||||
<uni-icons type="weixin" size="24" color="#07c160"></uni-icons>
|
||||
<text>微信一键登录</text>
|
||||
</view>
|
||||
|
||||
<view class="method-item" @click="navigateToPasswordLogin">
|
||||
<uni-icons type="locked" size="24" color="#ff9500"></uni-icons>
|
||||
<text>密码登录</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 服务协议 -->
|
||||
<view class="agreement">
|
||||
<view class="agreement-checkbox" @click="toggleAgreement">
|
||||
<uni-icons
|
||||
:type="agreed ? 'checkbox-filled' : 'circle'"
|
||||
size="16"
|
||||
:color="agreed ? '#007aff' : '#999'"
|
||||
></uni-icons>
|
||||
<text>我已阅读并同意</text>
|
||||
</view>
|
||||
<text class="agreement-link" @click="viewAgreement">《用户服务协议》</text>
|
||||
<text>和</text>
|
||||
<text class="agreement-link" @click="viewPrivacy">《隐私政策》</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 游客模式 -->
|
||||
<view class="guest-mode">
|
||||
<text class="guest-text" @click="enterAsGuest">先逛逛,稍后登录</text>
|
||||
</view>
|
||||
|
||||
<!-- 协议弹窗 -->
|
||||
<uni-popup ref="agreementPopup" type="bottom">
|
||||
<view class="agreement-popup">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">用户服务协议</text>
|
||||
<uni-icons type="close" size="20" color="#999" @click="closeAgreementPopup"></uni-icons>
|
||||
</view>
|
||||
<scroll-view class="popup-content" scroll-y="true">
|
||||
<text class="agreement-content">
|
||||
【用户服务协议内容...】
|
||||
请您务必审慎阅读、充分理解各条款内容,特别是免除或者限制责任的条款,以及开通或使用某项服务的单独协议,并选择接受或不接受。
|
||||
</text>
|
||||
</scroll-view>
|
||||
<view class="popup-actions">
|
||||
<button class="agree-btn" @click="agreeAndClose">同意并关闭</button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
||||
<!-- 隐私政策弹窗 -->
|
||||
<uni-popup ref="privacyPopup" type="bottom">
|
||||
<view class="privacy-popup">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">隐私政策</text>
|
||||
<uni-icons type="close" size="20" color="#999" @click="closePrivacyPopup"></uni-icons>
|
||||
</view>
|
||||
<scroll-view class="popup-content" scroll-y="true">
|
||||
<text class="privacy-content">
|
||||
【隐私政策内容...】
|
||||
我们深知个人信息对您的重要性,并会尽全力保护您的个人信息安全可靠。我们致力于维持您对我们的信任,恪守以下原则,保护您的个人信息:权责一致原则、目的明确原则、选择同意原则、最少够用原则、确保安全原则、主体参与原则、公开透明原则等。
|
||||
</text>
|
||||
</scroll-view>
|
||||
<view class="popup-actions">
|
||||
<button class="agree-btn" @click="agreeAndClose">同意并关闭</button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { authService } from '../../api/services.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
loginType: 'phone', // phone, wechat
|
||||
agreed: false,
|
||||
loading: false,
|
||||
|
||||
// 手机登录表单
|
||||
phoneForm: {
|
||||
phone: '',
|
||||
code: ''
|
||||
},
|
||||
|
||||
// 验证码倒计时
|
||||
codeCountdown: 0,
|
||||
canSendCode: true,
|
||||
|
||||
// 微信登录数据
|
||||
wechatForm: {
|
||||
code: '',
|
||||
encryptedData: '',
|
||||
iv: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
// 检查是否有重定向参数
|
||||
if (options.redirect) {
|
||||
this.redirectUrl = decodeURIComponent(options.redirect)
|
||||
}
|
||||
|
||||
// 检查是否已登录
|
||||
this.checkLoginStatus()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 页面显示时检查登录状态
|
||||
this.checkLoginStatus()
|
||||
},
|
||||
|
||||
methods: {
|
||||
async checkLoginStatus() {
|
||||
try {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (token) {
|
||||
// 验证token是否有效
|
||||
const isValid = await authService.checkToken(token)
|
||||
if (isValid) {
|
||||
this.navigateAfterLogin()
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('检查登录状态失败:', error)
|
||||
}
|
||||
},
|
||||
|
||||
async sendCode() {
|
||||
if (!this.phoneForm.phone) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号码',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!/^1[3-9]\d{9}$/.test(this.phoneForm.phone)) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号码',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (this.codeCountdown > 0) {
|
||||
return
|
||||
}
|
||||
|
||||
this.loading = true
|
||||
try {
|
||||
await authService.sendSmsCode(this.phoneForm.phone)
|
||||
uni.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 开始倒计时
|
||||
this.startCountdown()
|
||||
} catch (error) {
|
||||
console.error('发送验证码失败:', error)
|
||||
uni.showToast({
|
||||
title: '发送失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
startCountdown() {
|
||||
this.codeCountdown = 60
|
||||
this.canSendCode = false
|
||||
|
||||
const timer = setInterval(() => {
|
||||
this.codeCountdown--
|
||||
|
||||
if (this.codeCountdown <= 0) {
|
||||
clearInterval(timer)
|
||||
this.canSendCode = true
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
async handlePhoneLogin() {
|
||||
if (!this.agreed) {
|
||||
uni.showToast({
|
||||
title: '请先阅读并同意协议',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.phoneForm.phone) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号码',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.phoneForm.code) {
|
||||
uni.showToast({
|
||||
title: '请输入验证码',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.loading = true
|
||||
try {
|
||||
const result = await authService.phoneLogin({
|
||||
phone: this.phoneForm.phone,
|
||||
code: this.phoneForm.code
|
||||
})
|
||||
|
||||
await this.handleLoginSuccess(result)
|
||||
} catch (error) {
|
||||
console.error('手机登录失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '登录失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
async handleWechatLogin(e) {
|
||||
if (!this.agreed) {
|
||||
uni.showToast({
|
||||
title: '请先阅读并同意协议',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (e.detail.errMsg !== 'getPhoneNumber:ok') {
|
||||
console.error('微信登录失败:', e.detail)
|
||||
return
|
||||
}
|
||||
|
||||
this.loading = true
|
||||
try {
|
||||
// 获取微信code
|
||||
const loginRes = await uni.login({
|
||||
provider: 'weixin'
|
||||
})
|
||||
|
||||
const result = await authService.wechatLogin({
|
||||
code: loginRes.code,
|
||||
encryptedData: e.detail.encryptedData,
|
||||
iv: e.detail.iv
|
||||
})
|
||||
|
||||
await this.handleLoginSuccess(result)
|
||||
} catch (error) {
|
||||
console.error('微信登录失败:', error)
|
||||
uni.showToast({
|
||||
title: error.message || '登录失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
async handleLoginSuccess(result) {
|
||||
// 保存token和用户信息
|
||||
uni.setStorageSync('token', result.token)
|
||||
uni.setStorageSync('userInfo', result.userInfo)
|
||||
|
||||
// 显示登录成功提示
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 导航到目标页面
|
||||
await this.navigateAfterLogin()
|
||||
|
||||
// 触发全局登录事件
|
||||
uni.$emit('loginSuccess', result.userInfo)
|
||||
},
|
||||
|
||||
async navigateAfterLogin() {
|
||||
// 延迟一下让Toast显示完整
|
||||
await new Promise(resolve => setTimeout(resolve, 1500))
|
||||
|
||||
if (this.redirectUrl) {
|
||||
// 跳转到重定向页面
|
||||
uni.redirectTo({
|
||||
url: this.redirectUrl
|
||||
})
|
||||
} else {
|
||||
// 获取页面栈,决定返回还是跳转到首页
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
switchLoginType(type) {
|
||||
this.loginType = type
|
||||
},
|
||||
|
||||
navigateToPasswordLogin() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/auth/password-login'
|
||||
})
|
||||
},
|
||||
|
||||
toggleAgreement() {
|
||||
this.agreed = !this.agreed
|
||||
},
|
||||
|
||||
viewAgreement() {
|
||||
this.$refs.agreementPopup.open()
|
||||
},
|
||||
|
||||
viewPrivacy() {
|
||||
this.$refs.privacyPopup.open()
|
||||
},
|
||||
|
||||
closeAgreementPopup() {
|
||||
this.$refs.agreementPopup.close()
|
||||
},
|
||||
|
||||
closePrivacyPopup() {
|
||||
this.$refs.privacyPopup.close()
|
||||
},
|
||||
|
||||
agreeAndClose() {
|
||||
this.agreed = true
|
||||
this.closeAgreementPopup()
|
||||
this.closePrivacyPopup()
|
||||
},
|
||||
|
||||
enterAsGuest() {
|
||||
// 设置游客标识
|
||||
uni.setStorageSync('isGuest', true)
|
||||
|
||||
// 跳转到首页
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.login-page {
|
||||
background-color: #f8f9fa;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.login-header {
|
||||
height: 300rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.header-bg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.header-content {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
transform: translateY(-50%);
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.welcome-text {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 28rpx;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
padding: 40rpx 30rpx;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 40rpx 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.input-group {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.input-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 80rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.input-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.input-item uni-icons {
|
||||
margin-right: 15rpx;
|
||||
}
|
||||
|
||||
.input-item input {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.send-code-btn {
|
||||
padding: 8rpx 20rpx;
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.send-code-btn.disabled {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
background: linear-gradient(135deg, #007aff 0%, #0056cc 100%);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.login-btn.loading {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.wechat-login-tip {
|
||||
text-align: center;
|
||||
margin-bottom: 40rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.wechat-login-btn {
|
||||
background: linear-gradient(135deg, #07c160 0%, #059c4d 100%);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.wechat-login-btn uni-icons {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.other-login-methods {
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.divider {
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
margin-bottom: 30rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.divider::before,
|
||||
.divider::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 100rpx;
|
||||
height: 1rpx;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.divider::before {
|
||||
left: 50rpx;
|
||||
}
|
||||
|
||||
.divider::after {
|
||||
right: 50rpx;
|
||||
}
|
||||
|
||||
.method-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.method-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #eee;
|
||||
border-radius: 12rpx;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.method-item uni-icons {
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.method-item text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.agreement {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.agreement-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 5rpx;
|
||||
}
|
||||
|
||||
.agreement-checkbox uni-icons {
|
||||
margin-right: 5rpx;
|
||||
}
|
||||
|
||||
.agreement-link {
|
||||
color: #007aff;
|
||||
margin: 0 5rpx;
|
||||
}
|
||||
|
||||
.guest-mode {
|
||||
text-align: center;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.guest-text {
|
||||
font-size: 26rpx;
|
||||
color: #007aff;
|
||||
}
|
||||
|
||||
/* 协议弹窗样式 */
|
||||
.agreement-popup,
|
||||
.privacy-popup {
|
||||
background-color: #fff;
|
||||
border-radius: 24rpx 24rpx 0 0;
|
||||
max-height: 80vh;
|
||||
}
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
padding: 30rpx;
|
||||
max-height: 50vh;
|
||||
}
|
||||
|
||||
.agreement-content,
|
||||
.privacy-content {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.popup-actions {
|
||||
padding: 20rpx 30rpx 40rpx;
|
||||
}
|
||||
|
||||
.agree-btn {
|
||||
background: linear-gradient(135deg, #007aff 0%, #0056cc 100%);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
649
mini-program/pages/flower/list.vue
Normal file
649
mini-program/pages/flower/list.vue
Normal file
@@ -0,0 +1,649 @@
|
||||
<template>
|
||||
<view class="flower-list-page">
|
||||
<!-- 顶部搜索栏 -->
|
||||
<view class="search-header">
|
||||
<view class="search-input" @click="navigateToSearch">
|
||||
<uni-icons type="search" size="16" color="#999"></uni-icons>
|
||||
<text class="placeholder">搜索花束名称、用途</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 分类筛选 -->
|
||||
<view class="category-bar">
|
||||
<scroll-view class="category-scroll" scroll-x="true">
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'all' }"
|
||||
@click="changeCategory('all')"
|
||||
>
|
||||
<text>全部</text>
|
||||
</view>
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'love' }"
|
||||
@click="changeCategory('love')"
|
||||
>
|
||||
<text>爱情鲜花</text>
|
||||
</view>
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'birthday' }"
|
||||
@click="changeCategory('birthday')"
|
||||
>
|
||||
<text>生日祝福</text>
|
||||
</view>
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'friendship' }"
|
||||
@click="changeCategory('friendship')"
|
||||
>
|
||||
<text>友情鲜花</text>
|
||||
</view>
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'congratulation' }"
|
||||
@click="changeCategory('congratulation')"
|
||||
>
|
||||
<text>祝贺鲜花</text>
|
||||
</view>
|
||||
<view
|
||||
class="category-item"
|
||||
:class="{ active: activeCategory === 'apology' }"
|
||||
@click="changeCategory('apology')"
|
||||
>
|
||||
<text>道歉鲜花</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- 排序和筛选 -->
|
||||
<view class="filter-bar">
|
||||
<view class="filter-item" @click="showSortPopup">
|
||||
<text>{{ sortOptions[currentSort] }}</text>
|
||||
<uni-icons type="arrow-down" size="14" color="#666"></uni-icons>
|
||||
</view>
|
||||
<view class="filter-item" @click="showFilterPopup">
|
||||
<text>筛选</text>
|
||||
<uni-icons type="funnel" size="14" color="#666"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 花束列表 -->
|
||||
<view class="flower-list">
|
||||
<view class="flower-item" v-for="flower in flowerList" :key="flower.id" @click="navigateToDetail(flower.id)">
|
||||
<image :src="flower.image" class="flower-image" mode="aspectFill"></image>
|
||||
<view class="flower-info">
|
||||
<text class="flower-name">{{ flower.name }}</text>
|
||||
<text class="flower-description">{{ flower.description }}</text>
|
||||
<view class="flower-price">
|
||||
<text class="price-symbol">¥</text>
|
||||
<text class="price-value">{{ flower.price }}</text>
|
||||
</view>
|
||||
<view class="flower-meta">
|
||||
<text class="flower-category">{{ getCategoryText(flower.category) }}</text>
|
||||
<text class="flower-stock" v-if="flower.stock > 0">库存 {{ flower.stock }} 件</text>
|
||||
<text class="flower-soldout" v-else>已售罄</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view class="load-more" v-if="hasMore">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
<view class="no-more" v-else>
|
||||
<text>没有更多数据了</text>
|
||||
</view>
|
||||
|
||||
<!-- 排序弹窗 -->
|
||||
<uni-popup ref="sortPopup" type="bottom">
|
||||
<view class="popup-content">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">排序方式</text>
|
||||
<uni-icons type="close" size="20" color="#999" @click="closeSortPopup"></uni-icons>
|
||||
</view>
|
||||
<view class="sort-options">
|
||||
<view
|
||||
class="sort-option"
|
||||
v-for="(label, key) in sortOptions"
|
||||
:key="key"
|
||||
:class="{ active: currentSort === key }"
|
||||
@click="selectSort(key)"
|
||||
>
|
||||
<text>{{ label }}</text>
|
||||
<uni-icons type="checkmark" size="16" color="#007aff" v-if="currentSort === key"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
||||
<!-- 筛选弹窗 -->
|
||||
<uni-popup ref="filterPopup" type="bottom">
|
||||
<view class="popup-content">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">筛选</text>
|
||||
<uni-icons type="close" size="20" color="#999" @click="closeFilterPopup"></uni-icons>
|
||||
</view>
|
||||
<view class="filter-options">
|
||||
<!-- 价格范围 -->
|
||||
<view class="filter-section">
|
||||
<text class="section-title">价格范围</text>
|
||||
<view class="price-range">
|
||||
<input
|
||||
type="number"
|
||||
placeholder="最低价"
|
||||
v-model="filterParams.minPrice"
|
||||
class="price-input"
|
||||
/>
|
||||
<text class="range-separator">-</text>
|
||||
<input
|
||||
type="number"
|
||||
placeholder="最高价"
|
||||
v-model="filterParams.maxPrice"
|
||||
class="price-input"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 配送时间 -->
|
||||
<view class="filter-section">
|
||||
<text class="section-title">配送时间</text>
|
||||
<view class="delivery-options">
|
||||
<view
|
||||
class="delivery-option"
|
||||
v-for="time in deliveryOptions"
|
||||
:key="time.value"
|
||||
:class="{ active: filterParams.deliveryTime === time.value }"
|
||||
@click="toggleDeliveryTime(time.value)"
|
||||
>
|
||||
<text>{{ time.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 花店筛选 -->
|
||||
<view class="filter-section">
|
||||
<text class="section-title">花店选择</text>
|
||||
<view class="shop-options">
|
||||
<view
|
||||
class="shop-option"
|
||||
v-for="shop in shopOptions"
|
||||
:key="shop.value"
|
||||
:class="{ active: filterParams.shop === shop.value }"
|
||||
@click="toggleShop(shop.value)"
|
||||
>
|
||||
<text>{{ shop.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<view class="filter-actions">
|
||||
<view class="reset-btn" @click="resetFilter">重置</view>
|
||||
<view class="confirm-btn" @click="applyFilter">确认</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { flowerService } from '../../api/services.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
flowerList: [],
|
||||
activeCategory: 'all',
|
||||
currentSort: 'default',
|
||||
sortOptions: {
|
||||
default: '默认排序',
|
||||
priceAsc: '价格从低到高',
|
||||
priceDesc: '价格从高到低',
|
||||
popularity: '销量最高',
|
||||
newest: '最新上架'
|
||||
},
|
||||
filterParams: {
|
||||
minPrice: '',
|
||||
maxPrice: '',
|
||||
deliveryTime: '',
|
||||
shop: ''
|
||||
},
|
||||
deliveryOptions: [
|
||||
{ label: '立即配送', value: 'immediate' },
|
||||
{ label: '2小时内', value: '2hours' },
|
||||
{ label: '4小时内', value: '4hours' },
|
||||
{ label: '指定时间', value: 'specific' }
|
||||
],
|
||||
shopOptions: [
|
||||
{ label: '浪漫花坊', value: 'romantic' },
|
||||
{ label: '阳光花店', value: 'sunshine' },
|
||||
{ label: '幸福花艺', value: 'happiness' },
|
||||
{ label: '爱心花苑', value: 'lovegarden' }
|
||||
],
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
hasMore: true,
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadFlowerList()
|
||||
},
|
||||
|
||||
onReachBottom() {
|
||||
if (this.hasMore && !this.loading) {
|
||||
this.loadMore()
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async loadFlowerList() {
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {
|
||||
page: this.currentPage,
|
||||
pageSize: this.pageSize,
|
||||
category: this.activeCategory === 'all' ? undefined : this.activeCategory,
|
||||
sort: this.currentSort === 'default' ? undefined : this.currentSort,
|
||||
...this.filterParams
|
||||
}
|
||||
|
||||
const response = await flowerService.getList(params)
|
||||
this.flowerList = response.list || []
|
||||
this.hasMore = response.total > this.currentPage * this.pageSize
|
||||
} catch (error) {
|
||||
console.error('加载花束列表失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
async loadMore() {
|
||||
this.currentPage++
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {
|
||||
page: this.currentPage,
|
||||
pageSize: this.pageSize,
|
||||
category: this.activeCategory === 'all' ? undefined : this.activeCategory,
|
||||
sort: this.currentSort === 'default' ? undefined : this.currentSort,
|
||||
...this.filterParams
|
||||
}
|
||||
|
||||
const response = await flowerService.getList(params)
|
||||
this.flowerList = [...this.flowerList, ...(response.list || [])]
|
||||
this.hasMore = response.total > this.currentPage * this.pageSize
|
||||
} catch (error) {
|
||||
console.error('加载更多失败:', error)
|
||||
this.currentPage--
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
changeCategory(category) {
|
||||
if (this.activeCategory !== category) {
|
||||
this.activeCategory = category
|
||||
this.currentPage = 1
|
||||
this.flowerList = []
|
||||
this.loadFlowerList()
|
||||
}
|
||||
},
|
||||
|
||||
getCategoryText(category) {
|
||||
const categoryMap = {
|
||||
love: '爱情鲜花',
|
||||
birthday: '生日祝福',
|
||||
friendship: '友情鲜花',
|
||||
congratulation: '祝贺鲜花',
|
||||
apology: '道歉鲜花'
|
||||
}
|
||||
return categoryMap[category] || category
|
||||
},
|
||||
|
||||
showSortPopup() {
|
||||
this.$refs.sortPopup.open()
|
||||
},
|
||||
|
||||
closeSortPopup() {
|
||||
this.$refs.sortPopup.close()
|
||||
},
|
||||
|
||||
selectSort(sort) {
|
||||
this.currentSort = sort
|
||||
this.closeSortPopup()
|
||||
this.currentPage = 1
|
||||
this.flowerList = []
|
||||
this.loadFlowerList()
|
||||
},
|
||||
|
||||
showFilterPopup() {
|
||||
this.$refs.filterPopup.open()
|
||||
},
|
||||
|
||||
closeFilterPopup() {
|
||||
this.$refs.filterPopup.close()
|
||||
},
|
||||
|
||||
toggleDeliveryTime(time) {
|
||||
this.filterParams.deliveryTime = this.filterParams.deliveryTime === time ? '' : time
|
||||
},
|
||||
|
||||
toggleShop(shop) {
|
||||
this.filterParams.shop = this.filterParams.shop === shop ? '' : shop
|
||||
},
|
||||
|
||||
applyFilter() {
|
||||
this.closeFilterPopup()
|
||||
this.currentPage = 1
|
||||
this.flowerList = []
|
||||
this.loadFlowerList()
|
||||
},
|
||||
|
||||
resetFilter() {
|
||||
this.filterParams = {
|
||||
minPrice: '',
|
||||
maxPrice: '',
|
||||
deliveryTime: '',
|
||||
shop: ''
|
||||
}
|
||||
},
|
||||
|
||||
navigateToDetail(id) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/flower/detail?id=${id}`
|
||||
})
|
||||
},
|
||||
|
||||
navigateToSearch() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/search/index?type=flower'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.flower-list-page {
|
||||
background-color: #f8f9fa;
|
||||
min-height: 100vh;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.search-header {
|
||||
background-color: #fff;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 60rpx;
|
||||
background-color: #f0f0f0;
|
||||
border-radius: 30rpx;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.category-bar {
|
||||
background-color: #fff;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.category-scroll {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
display: inline-block;
|
||||
padding: 10rpx 25rpx;
|
||||
margin: 0 10rpx;
|
||||
border-radius: 25rpx;
|
||||
background-color: #f8f9fa;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.category-item.active {
|
||||
background-color: #ff6b8b;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.filter-bar {
|
||||
display: flex;
|
||||
background-color: #fff;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.filter-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10rpx 20rpx;
|
||||
margin-right: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
background-color: #f8f9fa;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.flower-list {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.flower-item {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.flower-image {
|
||||
width: 100%;
|
||||
height: 300rpx;
|
||||
}
|
||||
|
||||
.flower-info {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.flower-name {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.flower-description {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
display: block;
|
||||
margin-bottom: 15rpx;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.flower-price {
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.price-symbol {
|
||||
font-size: 24rpx;
|
||||
color: #ff6b35;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.price-value {
|
||||
font-size: 32rpx;
|
||||
color: #ff6b35;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.flower-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.flower-category {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
background-color: #f0f0f0;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.flower-stock {
|
||||
font-size: 24rpx;
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.flower-soldout {
|
||||
font-size: 24rpx;
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.load-more,
|
||||
.no-more {
|
||||
text-align: center;
|
||||
padding: 30rpx;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 弹窗样式 */
|
||||
.popup-content {
|
||||
background-color: #fff;
|
||||
border-radius: 24rpx 24rpx 0 0;
|
||||
padding: 40rpx;
|
||||
}
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.sort-options {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.sort-option {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 25rpx 0;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.sort-option.active {
|
||||
color: #007aff;
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.price-range {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.price-input {
|
||||
flex: 1;
|
||||
height: 70rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 8rpx;
|
||||
padding: 0 20rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.range-separator {
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.delivery-options,
|
||||
.shop-options {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15rpx;
|
||||
}
|
||||
|
||||
.delivery-option,
|
||||
.shop-option {
|
||||
padding: 15rpx 25rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 8rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.delivery-option.active,
|
||||
.shop-option.active {
|
||||
border-color: #ff6b8b;
|
||||
background-color: #fff0f3;
|
||||
color: #ff6b8b;
|
||||
}
|
||||
|
||||
.filter-actions {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.reset-btn,
|
||||
.confirm-btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.reset-btn {
|
||||
border: 1rpx solid #ddd;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background-color: #ff6b8b;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
657
mini-program/pages/promotion/invite.vue
Normal file
657
mini-program/pages/promotion/invite.vue
Normal file
@@ -0,0 +1,657 @@
|
||||
<template>
|
||||
<view class="promotion-page">
|
||||
<!-- 顶部背景 -->
|
||||
<view class="header-bg">
|
||||
<image src="/static/promotion/bg.png" class="bg-image" mode="aspectFill"></image>
|
||||
</view>
|
||||
|
||||
<!-- 主要内容 -->
|
||||
<view class="content">
|
||||
<!-- 邀请卡片 -->
|
||||
<view class="invite-card">
|
||||
<view class="card-header">
|
||||
<text class="title">邀请好友得奖励</text>
|
||||
<text class="subtitle">每成功邀请1位好友,最高可得50元奖励</text>
|
||||
</view>
|
||||
|
||||
<view class="reward-stats">
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ promotionData.totalReward || 0 }}</text>
|
||||
<text class="stat-label">累计奖励(元)</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ promotionData.invitedCount || 0 }}</text>
|
||||
<text class="stat-label">已邀请好友</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value">{{ promotionData.successCount || 0 }}</text>
|
||||
<text class="stat-label">成功邀请</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="invite-code">
|
||||
<text class="code-label">我的邀请码</text>
|
||||
<text class="code-value">{{ promotionData.inviteCode || '加载中...' }}</text>
|
||||
<view class="copy-btn" @click="copyInviteCode">
|
||||
<uni-icons type="copy" size="16" color="#007aff"></uni-icons>
|
||||
<text>复制</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 邀请方式 -->
|
||||
<view class="invite-methods">
|
||||
<text class="section-title">邀请方式</text>
|
||||
|
||||
<view class="method-list">
|
||||
<view class="method-item" @click="shareToWechat">
|
||||
<view class="method-icon wechat">
|
||||
<uni-icons type="weixin" size="24" color="#07c160"></uni-icons>
|
||||
</view>
|
||||
<text class="method-text">微信好友</text>
|
||||
</view>
|
||||
|
||||
<view class="method-item" @click="shareToMoment">
|
||||
<view class="method-icon moment">
|
||||
<uni-icons type="chat" size="24" color="#07c160"></uni-icons>
|
||||
</view>
|
||||
<text class="method-text">朋友圈</text>
|
||||
</view>
|
||||
|
||||
<view class="method-item" @click="saveQRCode">
|
||||
<view class="method-icon qrcode">
|
||||
<uni-icons type="scan" size="24" color="#007aff"></uni-icons>
|
||||
</view>
|
||||
<text class="method-text">保存二维码</text>
|
||||
</view>
|
||||
|
||||
<view class="method-item" @click="copyLink">
|
||||
<view class="method-icon link">
|
||||
<uni-icons type="link" size="24" color="#ff9500"></uni-icons>
|
||||
</view>
|
||||
<text class="method-text">复制链接</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 奖励规则 -->
|
||||
<view class="reward-rules">
|
||||
<text class="section-title">奖励规则</text>
|
||||
|
||||
<view class="rule-list">
|
||||
<view class="rule-item">
|
||||
<uni-icons type="checkmark" size="16" color="#52c41a"></uni-icons>
|
||||
<text>每成功邀请1位新用户注册,您可获得10元奖励</text>
|
||||
</view>
|
||||
|
||||
<view class="rule-item">
|
||||
<uni-icons type="checkmark" size="16" color="#52c41a"></uni-icons>
|
||||
<text>好友完成首单消费,您再获得20元奖励</text>
|
||||
</view>
|
||||
|
||||
<view class="rule-item">
|
||||
<uni-icons type="checkmark" size="16" color="#52c41a"></uni-icons>
|
||||
<text>好友成为活跃用户,您额外获得20元奖励</text>
|
||||
</view>
|
||||
|
||||
<view class="rule-item">
|
||||
<uni-icons type="checkmark" size="16" color="#52c41a"></uni-icons>
|
||||
<text>奖励累计满50元即可提现</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 邀请记录 -->
|
||||
<view class="invite-records">
|
||||
<view class="records-header">
|
||||
<text class="section-title">邀请记录</text>
|
||||
<text class="view-all" @click="viewAllRecords">查看全部</text>
|
||||
</view>
|
||||
|
||||
<view class="record-list">
|
||||
<view class="record-item" v-for="record in recentRecords" :key="record.id">
|
||||
<image :src="record.avatar" class="avatar" mode="aspectFill"></image>
|
||||
<view class="record-info">
|
||||
<text class="username">{{ record.username }}</text>
|
||||
<text class="time">{{ record.inviteTime }}</text>
|
||||
</view>
|
||||
<view class="record-status">
|
||||
<text class="status" :class="getStatusClass(record.status)">{{ getStatusText(record.status) }}</text>
|
||||
<text class="reward" v-if="record.reward > 0">+{{ record.reward }}元</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="empty-tip" v-if="recentRecords.length === 0">
|
||||
<uni-icons type="info" size="20" color="#999"></uni-icons>
|
||||
<text>暂无邀请记录</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 活动分享 -->
|
||||
<view class="activity-share">
|
||||
<text class="section-title">活动分享</text>
|
||||
<view class="share-tips">
|
||||
<text>分享您参与的活动,邀请好友一起参加,可获得额外奖励!</text>
|
||||
</view>
|
||||
<view class="share-actions">
|
||||
<button class="share-btn" @click="shareActivity">分享活动</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 认养分享 -->
|
||||
<view class="adoption-share">
|
||||
<text class="section-title">认养分享</text>
|
||||
<view class="share-tips">
|
||||
<text>分享您认养的动物,邀请好友一起认养,可获得丰厚奖励!</text>
|
||||
</view>
|
||||
<view class="share-actions">
|
||||
<button class="share-btn" @click="shareAdoption">分享认养</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 多人认养 -->
|
||||
<view class="group-adoption">
|
||||
<text class="section-title">多人认养</text>
|
||||
<view class="share-tips">
|
||||
<text>邀请好友共同认养一个动物,享受更多乐趣和优惠!</text>
|
||||
</view>
|
||||
<view class="share-actions">
|
||||
<button class="invite-btn" @click="inviteGroupAdoption">发起多人认养</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { promotionService } from '../../api/services.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
promotionData: {
|
||||
totalReward: 0,
|
||||
invitedCount: 0,
|
||||
successCount: 0,
|
||||
inviteCode: ''
|
||||
},
|
||||
recentRecords: [],
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadPromotionData()
|
||||
this.loadRecentRecords()
|
||||
},
|
||||
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: '结伴客 - 邀请好友得奖励',
|
||||
path: '/pages/index/index?inviteCode=' + this.promotionData.inviteCode,
|
||||
imageUrl: '/static/promotion/share.jpg'
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async loadPromotionData() {
|
||||
this.loading = true
|
||||
try {
|
||||
const response = await promotionService.getPromotionData()
|
||||
this.promotionData = response
|
||||
} catch (error) {
|
||||
console.error('加载推广数据失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
async loadRecentRecords() {
|
||||
try {
|
||||
const response = await promotionService.getRecentRecords()
|
||||
this.recentRecords = response.list || []
|
||||
} catch (error) {
|
||||
console.error('加载邀请记录失败:', error)
|
||||
}
|
||||
},
|
||||
|
||||
copyInviteCode() {
|
||||
if (!this.promotionData.inviteCode) return
|
||||
|
||||
uni.setClipboardData({
|
||||
data: this.promotionData.inviteCode,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: '邀请码已复制',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
shareToWechat() {
|
||||
uni.share({
|
||||
provider: 'weixin',
|
||||
scene: 'WXSceneSession',
|
||||
type: 0,
|
||||
title: '结伴客 - 邀请好友得奖励',
|
||||
summary: '每成功邀请1位好友,最高可得50元奖励!',
|
||||
href: 'https://jiebanke.com?inviteCode=' + this.promotionData.inviteCode,
|
||||
imageUrl: '/static/promotion/share.jpg',
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: '分享成功',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
shareToMoment() {
|
||||
uni.share({
|
||||
provider: 'weixin',
|
||||
scene: 'WXSceneTimeline',
|
||||
type: 0,
|
||||
title: '结伴客 - 邀请好友得奖励',
|
||||
summary: '每成功邀请1位好友,最高可得50元奖励!',
|
||||
href: 'https://jiebanke.com?inviteCode=' + this.promotionData.inviteCode,
|
||||
imageUrl: '/static/promotion/share.jpg',
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: '分享成功',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
saveQRCode() {
|
||||
uni.showLoading({
|
||||
title: '生成二维码中...'
|
||||
})
|
||||
|
||||
// 模拟生成二维码
|
||||
setTimeout(() => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '二维码已保存到相册',
|
||||
icon: 'success'
|
||||
})
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
copyLink() {
|
||||
const link = 'https://jiebanke.com?inviteCode=' + this.promotionData.inviteCode
|
||||
uni.setClipboardData({
|
||||
data: link,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: '链接已复制',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getStatusClass(status) {
|
||||
const statusMap = {
|
||||
registered: 'registered',
|
||||
ordered: 'ordered',
|
||||
active: 'active',
|
||||
completed: 'completed'
|
||||
}
|
||||
return statusMap[status] || 'registered'
|
||||
},
|
||||
|
||||
getStatusText(status) {
|
||||
const statusTextMap = {
|
||||
registered: '已注册',
|
||||
ordered: '已下单',
|
||||
active: '已活跃',
|
||||
completed: '已完成'
|
||||
}
|
||||
return statusTextMap[status] || '已注册'
|
||||
},
|
||||
|
||||
viewAllRecords() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/promotion/records'
|
||||
})
|
||||
},
|
||||
|
||||
shareActivity() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/promotion/share-activity'
|
||||
})
|
||||
},
|
||||
|
||||
shareAdoption() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/promotion/share-adoption'
|
||||
})
|
||||
},
|
||||
|
||||
inviteGroupAdoption() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/promotion/group-adoption'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.promotion-page {
|
||||
background-color: #f8f9fa;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.header-bg {
|
||||
height: 200rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.bg-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 20rpx;
|
||||
margin-top: -60rpx;
|
||||
}
|
||||
|
||||
.invite-card {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 20rpx;
|
||||
padding: 40rpx 30rpx;
|
||||
color: #fff;
|
||||
margin-bottom: 30rpx;
|
||||
box-shadow: 0 10rpx 30rpx rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
text-align: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 26rpx;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.reward-stats {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin-bottom: 30rpx;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
margin-bottom: 5rpx;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 24rpx;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.invite-code {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
padding: 20rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.code-label {
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.code-value {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
.copy-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.invite-methods,
|
||||
.reward-rules,
|
||||
.invite-records,
|
||||
.activity-share,
|
||||
.adoption-share,
|
||||
.group-adoption {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.method-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.method-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 30rpx 20rpx;
|
||||
border: 1rpx solid #eee;
|
||||
border-radius: 12rpx;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.method-icon {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.method-icon.wechat {
|
||||
background-color: #e6f7e6;
|
||||
}
|
||||
|
||||
.method-icon.moment {
|
||||
background-color: #e6f7ff;
|
||||
}
|
||||
|
||||
.method-icon.qrcode {
|
||||
background-color: #e6f7ff;
|
||||
}
|
||||
|
||||
.method-icon.link {
|
||||
background-color: #fff7e6;
|
||||
}
|
||||
|
||||
.method-text {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.rule-list {
|
||||
padding-left: 10rpx;
|
||||
}
|
||||
|
||||
.rule-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 20rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.rule-item uni-icons {
|
||||
margin-right: 15rpx;
|
||||
margin-top: 4rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.records-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.view-all {
|
||||
font-size: 26rpx;
|
||||
color: #007aff;
|
||||
}
|
||||
|
||||
.record-list {
|
||||
max-height: 400rpx;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.record-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.record-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 50%;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.record-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.username {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 5rpx;
|
||||
}
|
||||
|
||||
.time {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.record-status {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.status {
|
||||
font-size: 24rpx;
|
||||
display: block;
|
||||
margin-bottom: 5rpx;
|
||||
}
|
||||
|
||||
.status.registered {
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.status.ordered {
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.status.active {
|
||||
color: #fa8c16;
|
||||
}
|
||||
|
||||
.status.completed {
|
||||
color: #722ed1;
|
||||
}
|
||||
|
||||
.reward {
|
||||
font-size: 24rpx;
|
||||
color: #ff6b35;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 60rpx 0;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-tip uni-icons {
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.share-tips {
|
||||
margin-bottom: 25rpx;
|
||||
}
|
||||
|
||||
.share-tips text {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.share-actions {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.share-btn,
|
||||
.invite-btn {
|
||||
background: linear-gradient(135deg, #ff6b8b 0%, #ff8fb1 100%);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
padding: 20rpx 40rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.invite-btn {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
}
|
||||
</style>
|
||||
767
mini-program/pages/search/index.vue
Normal file
767
mini-program/pages/search/index.vue
Normal file
@@ -0,0 +1,767 @@
|
||||
<template>
|
||||
<view class="search-page">
|
||||
<!-- 搜索头部 -->
|
||||
<view class="search-header">
|
||||
<view class="search-input-container">
|
||||
<uni-icons type="arrow-left" size="20" color="#333" @click="goBack"></uni-icons>
|
||||
<view class="search-input">
|
||||
<uni-icons type="search" size="16" color="#999"></uni-icons>
|
||||
<input
|
||||
type="text"
|
||||
v-model="keyword"
|
||||
placeholder="请输入搜索关键词"
|
||||
placeholder-class="placeholder"
|
||||
focus
|
||||
@confirm="handleSearch"
|
||||
@input="handleInput"
|
||||
/>
|
||||
<uni-icons
|
||||
v-if="keyword"
|
||||
type="clear"
|
||||
size="16"
|
||||
color="#999"
|
||||
@click="clearKeyword"
|
||||
></uni-icons>
|
||||
</view>
|
||||
<text class="search-btn" @click="handleSearch">搜索</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 搜索类型切换 -->
|
||||
<view class="search-type-tabs">
|
||||
<view
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === 'all' }"
|
||||
@click="changeTab('all')"
|
||||
>
|
||||
<text>全部</text>
|
||||
</view>
|
||||
<view
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === 'travel' }"
|
||||
@click="changeTab('travel')"
|
||||
>
|
||||
<text>旅行计划</text>
|
||||
</view>
|
||||
<view
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === 'animal' }"
|
||||
@click="changeTab('animal')"
|
||||
>
|
||||
<text>动物认养</text>
|
||||
</view>
|
||||
<view
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === 'flower' }"
|
||||
@click="changeTab('flower')"
|
||||
>
|
||||
<text>鲜花配送</text>
|
||||
</view>
|
||||
<view
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === 'user' }"
|
||||
@click="changeTab('user')"
|
||||
>
|
||||
<text>用户</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 搜索历史 -->
|
||||
<view class="search-history" v-if="!hasSearched && searchHistory.length > 0">
|
||||
<view class="section-header">
|
||||
<text class="section-title">搜索历史</text>
|
||||
<uni-icons type="delete" size="16" color="#999" @click="clearHistory"></uni-icons>
|
||||
</view>
|
||||
<view class="history-list">
|
||||
<view
|
||||
class="history-item"
|
||||
v-for="(item, index) in searchHistory"
|
||||
:key="index"
|
||||
@click="selectHistory(item)"
|
||||
>
|
||||
<text>{{ item }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 热门搜索 -->
|
||||
<view class="hot-search" v-if="!hasSearched">
|
||||
<view class="section-header">
|
||||
<text class="section-title">热门搜索</text>
|
||||
</view>
|
||||
<view class="hot-list">
|
||||
<view
|
||||
class="hot-item"
|
||||
v-for="(item, index) in hotKeywords"
|
||||
:key="index"
|
||||
@click="selectHotKeyword(item)"
|
||||
>
|
||||
<uni-icons type="fire" size="14" color="#ff6b35" v-if="index < 3"></uni-icons>
|
||||
<text>{{ item }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 搜索结果 -->
|
||||
<view class="search-results" v-if="hasSearched">
|
||||
<!-- 搜索结果统计 -->
|
||||
<view class="result-stats">
|
||||
<text>找到 {{ totalCount }} 条相关结果</text>
|
||||
</view>
|
||||
|
||||
<!-- 旅行计划结果 -->
|
||||
<view class="result-section" v-if="activeTab === 'all' || activeTab === 'travel'">
|
||||
<view class="section-header">
|
||||
<text class="section-title">旅行计划</text>
|
||||
<text class="more" @click="viewMore('travel')" v-if="travelResults.length > 0">更多</text>
|
||||
</view>
|
||||
<view class="result-list">
|
||||
<view
|
||||
class="result-item travel-item"
|
||||
v-for="item in travelResults"
|
||||
:key="item.id"
|
||||
@click="navigateToTravelDetail(item.id)"
|
||||
>
|
||||
<image :src="item.coverImage" class="item-image" mode="aspectFill"></image>
|
||||
<view class="item-info">
|
||||
<text class="item-title">{{ item.title }}</text>
|
||||
<text class="item-destination">{{ item.destination }}</text>
|
||||
<view class="item-meta">
|
||||
<text class="item-date">{{ item.startDate }} - {{ item.endDate }}</text>
|
||||
<text class="item-price">¥{{ item.budget }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="empty-tip" v-if="travelResults.length === 0">
|
||||
<text>暂无相关旅行计划</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 动物认养结果 -->
|
||||
<view class="result-section" v-if="activeTab === 'all' || activeTab === 'animal'">
|
||||
<view class="section-header">
|
||||
<text class="section-title">动物认养</text>
|
||||
<text class="more" @click="viewMore('animal')" v-if="animalResults.length > 0">更多</text>
|
||||
</view>
|
||||
<view class="result-list">
|
||||
<view
|
||||
class="result-item animal-item"
|
||||
v-for="item in animalResults"
|
||||
:key="item.id"
|
||||
@click="navigateToAnimalDetail(item.id)"
|
||||
>
|
||||
<image :src="item.image" class="item-image" mode="aspectFill"></image>
|
||||
<view class="item-info">
|
||||
<text class="item-title">{{ item.name }}</text>
|
||||
<text class="item-species">{{ item.species }}</text>
|
||||
<view class="item-meta">
|
||||
<text class="item-location">{{ item.location }}</text>
|
||||
<text class="item-price">¥{{ item.price }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="empty-tip" v-if="animalResults.length === 0">
|
||||
<text>暂无相关动物</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 鲜花配送结果 -->
|
||||
<view class="result-section" v-if="activeTab === 'all' || activeTab === 'flower'">
|
||||
<view class="section-header">
|
||||
<text class="section-title">鲜花配送</text>
|
||||
<text class="more" @click="viewMore('flower')" v-if="flowerResults.length > 0">更多</text>
|
||||
</view>
|
||||
<view class="result-list">
|
||||
<view
|
||||
class="result-item flower-item"
|
||||
v-for="item in flowerResults"
|
||||
:key="item.id"
|
||||
@click="navigateToFlowerDetail(item.id)"
|
||||
>
|
||||
<image :src="item.image" class="item-image" mode="aspectFill"></image>
|
||||
<view class="item-info">
|
||||
<text class="item-title">{{ item.name }}</text>
|
||||
<text class="item-description">{{ item.description }}</text>
|
||||
<view class="item-meta">
|
||||
<text class="item-category">{{ item.category }}</text>
|
||||
<text class="item-price">¥{{ item.price }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="empty-tip" v-if="flowerResults.length === 0">
|
||||
<text>暂无相关鲜花</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 用户结果 -->
|
||||
<view class="result-section" v-if="activeTab === 'all' || activeTab === 'user'">
|
||||
<view class="section-header">
|
||||
<text class="section-title">用户</text>
|
||||
<text class="more" @click="viewMore('user')" v-if="userResults.length > 0">更多</text>
|
||||
</view>
|
||||
<view class="result-list">
|
||||
<view
|
||||
class="result-item user-item"
|
||||
v-for="item in userResults"
|
||||
:key="item.id"
|
||||
@click="navigateToUserProfile(item.id)"
|
||||
>
|
||||
<image :src="item.avatar" class="user-avatar" mode="aspectFill"></image>
|
||||
<view class="user-info">
|
||||
<text class="user-name">{{ item.nickname }}</text>
|
||||
<text class="user-bio">{{ item.bio || '暂无简介' }}</text>
|
||||
</view>
|
||||
<view class="follow-btn" @click.stop="handleFollow(item)">
|
||||
<text>{{ item.isFollowing ? '已关注' : '关注' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="empty-tip" v-if="userResults.length === 0">
|
||||
<text>暂无相关用户</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view class="load-more" v-if="hasMore && loading">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
<view class="no-more" v-if="!hasMore && hasSearched">
|
||||
<text>没有更多数据了</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 搜索建议 -->
|
||||
<view class="search-suggestions" v-if="showSuggestions && suggestions.length > 0">
|
||||
<view class="suggestion-list">
|
||||
<view
|
||||
class="suggestion-item"
|
||||
v-for="(item, index) in suggestions"
|
||||
:key="index"
|
||||
@click="selectSuggestion(item)"
|
||||
>
|
||||
<uni-icons type="search" size="16" color="#999"></uni-icons>
|
||||
<text>{{ item }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { searchService } from '../../api/services.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
keyword: '',
|
||||
activeTab: 'all',
|
||||
hasSearched: false,
|
||||
showSuggestions: false,
|
||||
loading: false,
|
||||
hasMore: false,
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
totalCount: 0,
|
||||
|
||||
// 搜索结果
|
||||
travelResults: [],
|
||||
animalResults: [],
|
||||
flowerResults: [],
|
||||
userResults: [],
|
||||
|
||||
// 搜索建议
|
||||
suggestions: [],
|
||||
|
||||
// 搜索历史
|
||||
searchHistory: uni.getStorageSync('searchHistory') || [],
|
||||
|
||||
// 热门搜索
|
||||
hotKeywords: [
|
||||
'西藏旅行',
|
||||
'小羊驼',
|
||||
'玫瑰花束',
|
||||
'云南大理',
|
||||
'农场体验',
|
||||
'生日鲜花',
|
||||
'结伴旅行',
|
||||
'动物认养'
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
if (options.keyword) {
|
||||
this.keyword = options.keyword
|
||||
this.handleSearch()
|
||||
}
|
||||
if (options.type) {
|
||||
this.activeTab = options.type
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async handleSearch() {
|
||||
if (!this.keyword.trim()) {
|
||||
uni.showToast({
|
||||
title: '请输入搜索关键词',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 保存搜索历史
|
||||
this.saveSearchHistory(this.keyword)
|
||||
|
||||
this.hasSearched = true
|
||||
this.showSuggestions = false
|
||||
this.currentPage = 1
|
||||
this.loading = true
|
||||
|
||||
try {
|
||||
const params = {
|
||||
keyword: this.keyword,
|
||||
type: this.activeTab === 'all' ? undefined : this.activeTab,
|
||||
page: this.currentPage,
|
||||
pageSize: this.pageSize
|
||||
}
|
||||
|
||||
const response = await searchService.search(params)
|
||||
this.processSearchResults(response)
|
||||
} catch (error) {
|
||||
console.error('搜索失败:', error)
|
||||
uni.showToast({
|
||||
title: '搜索失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
async handleInput() {
|
||||
if (!this.keyword.trim()) {
|
||||
this.showSuggestions = false
|
||||
return
|
||||
}
|
||||
|
||||
// 防抖处理
|
||||
clearTimeout(this.suggestionTimer)
|
||||
this.suggestionTimer = setTimeout(async () => {
|
||||
try {
|
||||
const response = await searchService.getSuggestions(this.keyword)
|
||||
this.suggestions = response
|
||||
this.showSuggestions = true
|
||||
} catch (error) {
|
||||
console.error('获取搜索建议失败:', error)
|
||||
}
|
||||
}, 300)
|
||||
},
|
||||
|
||||
processSearchResults(response) {
|
||||
this.totalCount = response.total || 0
|
||||
|
||||
if (this.activeTab === 'all') {
|
||||
this.travelResults = response.travel?.list || []
|
||||
this.animalResults = response.animal?.list || []
|
||||
this.flowerResults = response.flower?.list || []
|
||||
this.userResults = response.user?.list || []
|
||||
} else {
|
||||
const results = response.list || []
|
||||
switch (this.activeTab) {
|
||||
case 'travel':
|
||||
this.travelResults = results
|
||||
break
|
||||
case 'animal':
|
||||
this.animalResults = results
|
||||
break
|
||||
case 'flower':
|
||||
this.flowerResults = results
|
||||
break
|
||||
case 'user':
|
||||
this.userResults = results
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
this.hasMore = response.total > this.currentPage * this.pageSize
|
||||
},
|
||||
|
||||
saveSearchHistory(keyword) {
|
||||
// 去重
|
||||
const index = this.searchHistory.indexOf(keyword)
|
||||
if (index !== -1) {
|
||||
this.searchHistory.splice(index, 1)
|
||||
}
|
||||
|
||||
// 添加到开头
|
||||
this.searchHistory.unshift(keyword)
|
||||
|
||||
// 限制历史记录数量
|
||||
if (this.searchHistory.length > 10) {
|
||||
this.searchHistory = this.searchHistory.slice(0, 10)
|
||||
}
|
||||
|
||||
// 保存到本地存储
|
||||
uni.setStorageSync('searchHistory', this.searchHistory)
|
||||
},
|
||||
|
||||
clearHistory() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要清空搜索历史吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.searchHistory = []
|
||||
uni.removeStorageSync('searchHistory')
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
selectHistory(keyword) {
|
||||
this.keyword = keyword
|
||||
this.handleSearch()
|
||||
},
|
||||
|
||||
selectHotKeyword(keyword) {
|
||||
this.keyword = keyword
|
||||
this.handleSearch()
|
||||
},
|
||||
|
||||
selectSuggestion(keyword) {
|
||||
this.keyword = keyword
|
||||
this.handleSearch()
|
||||
},
|
||||
|
||||
clearKeyword() {
|
||||
this.keyword = ''
|
||||
this.showSuggestions = false
|
||||
},
|
||||
|
||||
changeTab(tab) {
|
||||
if (this.activeTab !== tab) {
|
||||
this.activeTab = tab
|
||||
if (this.hasSearched) {
|
||||
this.handleSearch()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
},
|
||||
|
||||
viewMore(type) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/search/more?keyword=${this.keyword}&type=${type}`
|
||||
})
|
||||
},
|
||||
|
||||
navigateToTravelDetail(id) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/travel/detail?id=${id}`
|
||||
})
|
||||
},
|
||||
|
||||
navigateToAnimalDetail(id) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/animal/detail?id=${id}`
|
||||
})
|
||||
},
|
||||
|
||||
navigateToFlowerDetail(id) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/flower/detail?id=${id}`
|
||||
})
|
||||
},
|
||||
|
||||
navigateToUserProfile(id) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/user/profile?id=${id}`
|
||||
})
|
||||
},
|
||||
|
||||
handleFollow(user) {
|
||||
// 关注/取消关注逻辑
|
||||
console.log('关注用户:', user)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.search-page {
|
||||
background-color: #f8f9fa;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.search-header {
|
||||
background-color: #fff;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.search-input-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 60rpx;
|
||||
background-color: #f0f0f0;
|
||||
border-radius: 30rpx;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.search-input input {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
margin: 0 10rpx;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
font-size: 28rpx;
|
||||
color: #007aff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.search-type-tabs {
|
||||
display: flex;
|
||||
background-color: #fff;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
padding: 10rpx 25rpx;
|
||||
margin-right: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
background-color: #f8f9fa;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.tab-item.active {
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.search-history,
|
||||
.hot-search {
|
||||
background-color: #fff;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.history-list,
|
||||
.hot-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15rpx;
|
||||
}
|
||||
|
||||
.history-item,
|
||||
.hot-item {
|
||||
padding: 12rpx 20rpx;
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 20rpx;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.hot-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.hot-item uni-icons {
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
|
||||
.search-results {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.result-stats {
|
||||
padding: 20rpx 0;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.result-section {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.result-list {
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
|
||||
.result-item {
|
||||
display: flex;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.result-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.item-image {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 8rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.item-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.item-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.item-destination,
|
||||
.item-species,
|
||||
.item-description,
|
||||
.item-location,
|
||||
.item-category {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.item-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.item-date,
|
||||
.item-location,
|
||||
.item-category {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.item-price {
|
||||
font-size: 26rpx;
|
||||
color: #ff6b35;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.user-item {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 50%;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 5rpx;
|
||||
}
|
||||
|
||||
.user-bio {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.follow-btn {
|
||||
padding: 8rpx 20rpx;
|
||||
border: 1rpx solid #007aff;
|
||||
border-radius: 20rpx;
|
||||
color: #007aff;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
text-align: center;
|
||||
padding: 40rpx;
|
||||
color: #999;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.load-more,
|
||||
.no-more {
|
||||
text-align: center;
|
||||
padding: 30rpx;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.search-suggestions {
|
||||
position: absolute;
|
||||
top: 120rpx;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: #fff;
|
||||
border-radius: 0 0 16rpx 16rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.suggestion-list {
|
||||
max-height: 400rpx;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.suggestion-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.suggestion-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.suggestion-item uni-icons {
|
||||
margin-right: 15rpx;
|
||||
}
|
||||
</style>
|
||||
340
mini-program/pages/travel/list.vue
Normal file
340
mini-program/pages/travel/list.vue
Normal file
@@ -0,0 +1,340 @@
|
||||
<template>
|
||||
<view class="travel-list-page">
|
||||
<!-- 顶部搜索栏 -->
|
||||
<view class="search-header">
|
||||
<view class="search-input" @click="navigateToSearch">
|
||||
<uni-icons type="search" size="16" color="#999"></uni-icons>
|
||||
<text class="placeholder">搜索目的地、旅行计划</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 筛选条件 -->
|
||||
<view class="filter-bar">
|
||||
<view class="filter-item" :class="{ active: filterActive === 'all' }" @click="changeFilter('all')">
|
||||
<text>全部</text>
|
||||
</view>
|
||||
<view class="filter-item" :class="{ active: filterActive === 'recruiting' }" @click="changeFilter('recruiting')">
|
||||
<text>招募中</text>
|
||||
</view>
|
||||
<view class="filter-item" :class="{ active: filterActive === 'ongoing' }" @click="changeFilter('ongoing')">
|
||||
<text>进行中</text>
|
||||
</view>
|
||||
<view class="filter-item" :class="{ active: filterActive === 'completed' }" @click="changeFilter('completed')">
|
||||
<text>已完成</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 旅行计划列表 -->
|
||||
<view class="travel-list">
|
||||
<view class="travel-item" v-for="travel in travelList" :key="travel.id" @click="navigateToDetail(travel.id)">
|
||||
<image :src="travel.coverImage" class="travel-image" mode="aspectFill"></image>
|
||||
<view class="travel-info">
|
||||
<text class="travel-title">{{ travel.title }}</text>
|
||||
<text class="travel-destination">{{ travel.destination }}</text>
|
||||
<view class="travel-meta">
|
||||
<text class="travel-date">{{ travel.startDate }} - {{ travel.endDate }}</text>
|
||||
<text class="travel-budget">¥{{ travel.budget }}</text>
|
||||
</view>
|
||||
<view class="travel-status">
|
||||
<text class="status-tag" :class="getStatusClass(travel.status)">{{ getStatusText(travel.status) }}</text>
|
||||
<text class="members">{{ travel.currentMembers }}/{{ travel.maxMembers }}人</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<view class="load-more" v-if="hasMore">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
<view class="no-more" v-else>
|
||||
<text>没有更多数据了</text>
|
||||
</view>
|
||||
|
||||
<!-- 发布按钮 -->
|
||||
<view class="publish-btn" @click="navigateToPublish">
|
||||
<uni-icons type="plus" size="24" color="#fff"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { travelService } from '../../api/services.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
travelList: [],
|
||||
filterActive: 'all',
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
hasMore: true,
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadTravelList()
|
||||
},
|
||||
|
||||
onReachBottom() {
|
||||
if (this.hasMore && !this.loading) {
|
||||
this.loadMore()
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async loadTravelList() {
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {
|
||||
page: this.currentPage,
|
||||
pageSize: this.pageSize,
|
||||
status: this.filterActive === 'all' ? undefined : this.filterActive
|
||||
}
|
||||
|
||||
const response = await travelService.getList(params)
|
||||
this.travelList = response.list || []
|
||||
this.hasMore = response.total > this.currentPage * this.pageSize
|
||||
} catch (error) {
|
||||
console.error('加载旅行计划列表失败:', error)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
async loadMore() {
|
||||
this.currentPage++
|
||||
this.loading = true
|
||||
try {
|
||||
const params = {
|
||||
page: this.currentPage,
|
||||
pageSize: this.pageSize,
|
||||
status: this.filterActive === 'all' ? undefined : this.filterActive
|
||||
}
|
||||
|
||||
const response = await travelService.getList(params)
|
||||
this.travelList = [...this.travelList, ...(response.list || [])]
|
||||
this.hasMore = response.total > this.currentPage * this.pageSize
|
||||
} catch (error) {
|
||||
console.error('加载更多失败:', error)
|
||||
this.currentPage--
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
changeFilter(filter) {
|
||||
if (this.filterActive !== filter) {
|
||||
this.filterActive = filter
|
||||
this.currentPage = 1
|
||||
this.travelList = []
|
||||
this.loadTravelList()
|
||||
}
|
||||
},
|
||||
|
||||
getStatusClass(status) {
|
||||
const statusMap = {
|
||||
recruiting: 'recruiting',
|
||||
ongoing: 'ongoing',
|
||||
completed: 'completed',
|
||||
cancelled: 'cancelled'
|
||||
}
|
||||
return statusMap[status] || 'recruiting'
|
||||
},
|
||||
|
||||
getStatusText(status) {
|
||||
const statusTextMap = {
|
||||
recruiting: '招募中',
|
||||
ongoing: '进行中',
|
||||
completed: '已完成',
|
||||
cancelled: '已取消'
|
||||
}
|
||||
return statusTextMap[status] || '招募中'
|
||||
},
|
||||
|
||||
navigateToDetail(id) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/travel/detail?id=${id}`
|
||||
})
|
||||
},
|
||||
|
||||
navigateToSearch() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/search/index?type=travel'
|
||||
})
|
||||
},
|
||||
|
||||
navigateToPublish() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/travel/publish'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.travel-list-page {
|
||||
background-color: #f8f9fa;
|
||||
min-height: 100vh;
|
||||
padding-bottom: 100rpx;
|
||||
}
|
||||
|
||||
.search-header {
|
||||
background-color: #fff;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 60rpx;
|
||||
background-color: #f0f0f0;
|
||||
border-radius: 30rpx;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.filter-bar {
|
||||
display: flex;
|
||||
background-color: #fff;
|
||||
padding: 20rpx 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.filter-item {
|
||||
padding: 10rpx 20rpx;
|
||||
margin-right: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.filter-item.active {
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.travel-list {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.travel-item {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.travel-image {
|
||||
width: 100%;
|
||||
height: 300rpx;
|
||||
}
|
||||
|
||||
.travel-info {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.travel-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.travel-destination {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
display: block;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.travel-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.travel-date {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.travel-budget {
|
||||
font-size: 28rpx;
|
||||
color: #ff6b35;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.travel-status {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-tag {
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 12rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.status-tag.recruiting {
|
||||
background-color: #e6f7ff;
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.status-tag.ongoing {
|
||||
background-color: #f6ffed;
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.status-tag.completed {
|
||||
background-color: #f9f9f9;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.status-tag.cancelled {
|
||||
background-color: #fff2f0;
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.members {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.load-more,
|
||||
.no-more {
|
||||
text-align: center;
|
||||
padding: 30rpx;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.publish-btn {
|
||||
position: fixed;
|
||||
right: 40rpx;
|
||||
bottom: 100rpx;
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
background-color: #007aff;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 4rpx 16rpx rgba(0, 122, 255, 0.3);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user