linyongLynn 4 months ago
parent 2779b72dce
commit 595cc408ed

@ -1,12 +1,27 @@
<template>
<view class="library-container">
<view class="search-bar">
<u-search placeholder="书名/作者" v-model="keyword" :show-action="false" bg-color="#f5f5f5"
border-color="#e0e0e0" @search="searchBooks"></u-search>
<u-search
placeholder="书名/作者"
v-model="keyword"
:show-action="true"
action-text="搜索"
bg-color="#f5f5f5"
border-color="#e0e0e0"
@search="searchBooks"
@clear="clearSearch">
</u-search>
</view>
<view class="tabs-container">
<u-tabs :list="tabsList" :is-scroll="true" :current="currentTab" @change="tabChange" active-color="#73685c"></u-tabs>
<u-tabs
:list="tabsList"
:is-scroll="true"
:current="currentTab"
@change="tabChange"
active-color="#73685c"
:loading="tabsList.length <= 1">
</u-tabs>
</view>
<view class="book-list">
@ -68,7 +83,9 @@
totalPages: 1,
hasMore: true,
tabsList: [{
name: '全部'
name: '全部',
value: 'all',
id: 'all'
}],
bookList: []
}
@ -85,28 +102,37 @@
//
loadCategories() {
this.$u.api.bookOther().then(res => {
console.log('分类接口返回数据:', res);
if (res && res.category) {
// ""
const categories = [{
name: '全部'
name: '全部',
value: 'all',
id: 'all'
}];
//
if (Array.isArray(res.category)) {
res.category.forEach(categoryName => {
// {id: name}
if (typeof res.category === 'object' && !Array.isArray(res.category)) {
Object.keys(res.category).forEach(categoryId => {
const categoryName = res.category[categoryId];
categories.push({
name: categoryName
name: categoryName,
value: categoryName,
id: categoryId
});
});
}
this.tabsList = categories;
console.log('设置分类列表:', this.tabsList);
}
}).catch(err => {
console.error('获取分类失败:', err);
// 使
this.tabsList = [{
name: '全部'
name: '全部',
value: 'all',
id: 'all'
}];
}).finally(() => {
//
@ -129,10 +155,12 @@
}
//
if (this.currentTab > 0) {
params.category = this.currentTab;
if (this.currentTab > 0 && this.tabsList[this.currentTab]) {
params.category = this.tabsList[this.currentTab].id;
console.log('使用分类筛选:', this.tabsList[this.currentTab]);
}
console.log('请求参数:', params);
this.$u.api.bookIndex(params).then(res => {
//
const bookData = res || {};
@ -181,12 +209,25 @@
//
searchBooks() {
console.log('搜索关键词:', this.keyword);
this.currentPage = 1;
//
this.currentTab = 0;
this.loadBookList();
},
//
clearSearch() {
console.log('清空搜索');
this.keyword = '';
this.currentPage = 1;
this.currentTab = 0;
this.loadBookList();
},
//
tabChange(index) {
console.log('切换到分类:', index, this.tabsList[index]);
this.currentTab = index;
this.currentPage = 1;
this.loadBookList();
@ -220,10 +261,12 @@
.search-bar {
padding: 20rpx 30rpx;
background-color: #fff;
border-bottom: 1rpx solid #f0f0f0;
}
.tabs-container {
border-top: 1rpx solid #eee;
background-color: #fff;
border-bottom: 1rpx solid #f0f0f0;
}
.book-list {

@ -61,14 +61,14 @@
<u-icon name="chat-fill" color="#07c160" size="24"></u-icon>
<text class="label-text">微信</text>
</view>
<text class="contact-value">{{ detail.wechat }}</text>
<text class="contact-value wechat-clickable" @click="openWechat(detail.wechat)">{{ detail.wechat }}</text>
</view>
<view class="contact-item" v-if="detail.mobile">
<view class="contact-label">
<u-icon name="phone-fill" color="#007aff" size="24"></u-icon>
<text class="label-text">电话</text>
</view>
<text class="contact-value">{{ detail.mobile }}</text>
<text class="contact-value phone-clickable" @click="makePhoneCall(detail.mobile)">{{ detail.mobile }}</text>
</view>
<view class="contact-item" v-if="detail.email">
<view class="contact-label">
@ -210,6 +210,142 @@
current: file.url,
index: index
});
},
//
makePhoneCall(phoneNumber) {
uni.showModal({
title: '拨打电话',
content: `是否拨打 ${phoneNumber}`,
success: (res) => {
if (res.confirm) {
uni.makePhoneCall({
phoneNumber: phoneNumber,
success: () => {
console.log('拨号成功');
},
fail: (err) => {
console.error('拨号失败:', err);
this.$u.toast('拨号失败,请重试');
}
});
}
}
});
},
//
openWechat(wechatId) {
console.log('点击微信,微信号:', wechatId);
// 使URL Scheme
const wechatUrl = `weixin://`;
// APPplus
if (typeof window !== 'undefined' && window.plus && plus.runtime) {
console.log('检测到plus环境尝试打开微信');
plus.runtime.openURL(wechatUrl, (err) => {
if (err) {
console.error('打开微信失败:', err);
this.showWechatCopyDialog(wechatId);
} else {
console.log('微信打开成功');
this.$u.toast('请在微信中搜索并添加好友');
}
});
} else {
console.log('非APP环境或plus不可用直接显示复制对话框');
// APP
this.showWechatCopyDialog(wechatId);
}
},
//
showWechatCopyDialog(wechatId) {
console.log('准备显示微信复制对话框,微信号:', wechatId);
// 使showModal
uni.showModal({
title: '添加微信好友',
content: `微信号:${wechatId}\n请复制微信号到微信中搜索添加`,
confirmText: '复制',
cancelText: '取消',
showCancel: true,
success: (res) => {
console.log('showModal success callback:', res);
if (res.confirm) {
console.log('用户点击确认,准备复制微信号');
//
this.tryCopyToClipboard(wechatId);
}
},
fail: (err) => {
console.error('showModal fail callback:', err);
// showModal使toast
uni.showToast({
title: `微信号:${wechatId}`,
icon: 'none',
duration: 3000
});
}
});
},
//
tryCopyToClipboard(text) {
//
if (typeof wx !== 'undefined' && wx.requirePrivacyAuthorize) {
//
wx.requirePrivacyAuthorize({
success: () => {
//
this.executeCopyToClipboard(text);
},
fail: () => {
//
this.showManualCopyTip(text);
}
});
} else {
//
this.executeCopyToClipboard(text);
}
},
//
executeCopyToClipboard(text) {
uni.setClipboardData({
data: text,
success: () => {
console.log('复制成功');
uni.showToast({
title: '微信号已复制到剪贴板',
icon: 'success',
duration: 2000
});
},
fail: (err) => {
console.error('复制失败:', err);
//
this.showManualCopyTip(text);
}
});
},
//
showManualCopyTip(text) {
uni.showModal({
title: '复制失败',
content: `微信号:${text}\n\n由于权限限制请手动复制微信号到微信中搜索添加`,
confirmText: '知道了',
showCancel: false,
success: () => {
// 使
uni.showToast({
title: '请手动复制微信号',
icon: 'none',
duration: 3000
});
}
});
}
}
}
@ -473,6 +609,28 @@
font-weight: 500;
}
.phone-clickable {
color: #007aff;
text-decoration: underline;
cursor: pointer;
transition: color 0.3s ease;
}
.phone-clickable:active {
color: #0056b3;
}
.wechat-clickable {
color: #07c160;
text-decoration: underline;
cursor: pointer;
transition: color 0.3s ease;
}
.wechat-clickable:active {
color: #06ad56;
}
.contact-placeholder {
display: flex;
flex-direction: column;

@ -71,11 +71,9 @@
currentStatusTab: 0, //
statusTabs: [
{ name: '全部' },
{ name: '待审核' },
{ name: '审核通过' },
{ name: '已拒绝' },
{ name: '已发布' },
{ name: '退回修改' },
{ name: '永久隐藏' }
{ name: '已拒绝' }
]
}
},
@ -100,19 +98,17 @@
};
//
// 4退
if (this.currentStatusTab === 0) {
// null
params.status = '-1'
// -1
params.status = '-1';
} else {
//
const statusMap = {
1: 0, //
2: 1, //
3: 2, //
4: 3, // 退
5: 4 //
1: 1, // 1
2: 3, // 退3
3: 2 // 2
};
params.status = statusMap[this.currentStatusTab] || 0;
params.status = statusMap[this.currentStatusTab] || 1;
}
this.$u.api.supplyDemandList(params).then(res => {

Loading…
Cancel
Save