分配客户群二维码

This commit is contained in:
Dev
2026-09-29 16:24:19 +08:00
parent a4b0aaa661
commit 34177dfe86
10 changed files with 445 additions and 84 deletions
+38 -19
View File
@@ -17,6 +17,7 @@ Page({
freshPage: false,
fromPreview: false, // 预览锁
hasMore: true, // 新增字段,标记是否还有更多数据
refreshing: false, // 刷新按钮是否处于加载中
tabList: [
{ text: '全部', key: -1 },
{ text: '招标中', key: 1 },
@@ -59,6 +60,13 @@ Page({
}
this.loadDemandList(true);
},
// 点击右侧刷新按钮
async onRefreshTap() {
if (this.data.refreshing) return;
this.setData({ refreshing: true });
await this.loadDemandList(true);
this.setData({ refreshing: false });
},
//图片预览
onImageView(e) {
const { images, index } = e.currentTarget.dataset;
@@ -77,7 +85,8 @@ Page({
},
// 加载需求列表数据
async loadDemandList(fresh = false) {
async loadDemandList(fresh = false, options = {}) {
const { silent = false } = options;
if (fresh) {
this.setData({
page: 1,
@@ -95,14 +104,19 @@ Page({
try {
const { page, status, keywords, opType } = this.data;
let params = { page, status, keywords, opType };
wx.showLoading({
title: '加载中',
});
// 下拉刷新自带 loading 指示,不再叠加 showLoading
if (!silent) {
wx.showLoading({
title: '加载中',
});
}
const res = await fetchDemandList(params);
const nextList = res.data.data;
console.log(res)
console.log(nextList)
wx.hideLoading();
if (!silent) {
wx.hideLoading();
}
// 判断是否还有更多数据
const { current_page, last_page } = res.data;
@@ -218,22 +232,26 @@ Page({
return;
}
const bidDemandId = wx.getStorageSync('bidDemandId');
console.log('bidDemandId:', bidDemandId);
if (bidDemandId) {
const index = this.data.demandList.findIndex(item => item.id === Number(bidDemandId));
console.log('bidDemandId-index:', index);
index >= 0 && this.setData({
[`demandList[${index}].is_bid`]: true,
[`demandList[${index}].btnName`]: '已投标',
[`demandList[${index}].demand_biddings_count`]: this.data.demandList[index].demand_biddings_count + 1
});
// 先清除标记,避免同一条被重复处理
wx.removeStorageSync('bidDemandId');
} else {
if (this.data.freshPage) {
this.setData({ freshPage: false });
console.log('freshing');
const index = this.data.demandList.findIndex(item => item.id === Number(bidDemandId));
if (index < 0) {
// 当前列表里没有这条(例如「我投标的需求」页),交给接口重新拉取
this.loadDemandList(true);
} else {
this.setData({
[`demandList[${index}].is_bid`]: true,
// 按钮渲染的是 item.button.name,只改 btnName 不会刷新文案
[`demandList[${index}].button`]: { name: '已投标', theme: 'light' },
[`demandList[${index}].demand_biddings_count`]: this.data.demandList[index].demand_biddings_count + 1,
});
}
return;
}
if (this.data.freshPage) {
this.setData({ freshPage: false });
this.loadDemandList(true);
}
},
@@ -254,8 +272,9 @@ Page({
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
this.loadDemandList(true);
async onPullDownRefresh() {
await this.loadDemandList(true, { silent: true });
wx.stopPullDownRefresh();
},
/**
@@ -1,4 +1,7 @@
{
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark",
"onReachBottomDistance": 20,
"usingComponents": {
"t-search": "tdesign-miniprogram/search/search",
"t-loading": "tdesign-miniprogram/loading/loading",
+18 -4
View File
@@ -1,11 +1,25 @@
<!--pages/demand/list/index.wxml-->
<!-- <t-divider /> -->
<view class="home-page-container">
<view class="search" style="margin-bottom: 5rpx;" bind:tap="navToSearchPage">
<t-search t-class-input="t-search__input" t-class-left="t-search__left-icon" placeholder="请输入关键词搜索" value="{{keywords}}" left-icon="{{null}}" bind:blur="onChangeInput" bind:change="onChangeInput" bind:submit="onChangeSearch">
<t-icon slot="left-icon" prefix="" name="search" size="40rpx" color="#bbb" />
<t-icon slot="action" bind:tap="onChangeSearch" prefix="" name="refresh" size="40rpx" color="#787878" />
<view class="search-bar">
<t-search
t-class="search-bar__search"
t-class-input-container="search-bar__box"
t-class-input="search-bar__input"
t-class-left="search-bar__left"
shape="round"
placeholder="搜索需求关键词"
value="{{keywords}}"
left-icon="{{null}}"
bind:change="onChangeInput"
bind:blur="onChangeInput"
bind:submit="onChangeSearch"
>
<t-icon slot="left-icon" prefix="" name="search" size="36rpx" color="#b9bcc4" />
</t-search>
<view class="refresh-btn {{refreshing ? 'refresh-btn--loading' : ''}}" hover-class="refresh-btn--hover" bind:tap="onRefreshTap">
<t-icon prefix="" name="refresh" size="38rpx" color="#787878" />
</view>
</view>
<!-- <t-divider /> -->
<view class="home-page-tabs">
+61 -6
View File
@@ -22,15 +22,70 @@ page {
padding: 0 24rpx;
}
.home-page-header .t-search__input-box {
border-radius: 32rpx !important;
height: 64rpx !important;
margin-bottom: 8rpx;
/* ===== 搜索区 ===== */
.search-bar {
display: flex;
align-items: center;
padding: 18rpx 0 12rpx;
gap: 16rpx;
}
.home-page-header .t-search__input {
.search-bar__search {
flex: 1;
min-width: 0;
padding: 0 !important;
background: transparent !important;
}
.search-bar__box {
height: 68rpx !important;
border-radius: 34rpx !important;
background: #fff !important;
box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.05);
}
.search-bar__input {
font-size: 28rpx !important;
color: rgb(116, 116, 116) !important;
color: var(--text-primary) !important;
}
.search-bar__left {
display: flex;
align-items: center;
margin-right: 4rpx;
}
/* ===== 刷新按钮 ===== */
.refresh-btn {
flex-shrink: 0;
width: 68rpx;
height: 68rpx;
border-radius: 50%;
background: #fff;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
display: flex;
align-items: center;
justify-content: center;
transition: transform 0.15s ease, opacity 0.15s ease;
}
.refresh-btn--hover {
transform: scale(0.92);
opacity: 0.85;
}
.refresh-btn--loading {
animation: refresh-spin 0.9s linear infinite;
}
@keyframes refresh-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.home-page-header .swiper-wrap {
+23 -14
View File
@@ -38,24 +38,14 @@ Page({
onShow() {
this.getTabBar().init();
setTimeout(() => {
fetchPerson().then((res) => {
if (res.code === 1) {
let { role } = res.data;
this.setData({
role,
});
}
});
}, 3000);
this.refreshRole();
},
onLoad() {
// 先用本地缓存渲染入口按钮,避免接口返回前闪烁;随后由 onShow 用接口数据校正
const role = (wx.getStorageSync('userInfo') || {}).role || '';
this.setData({ role });
this.init();
let role = wx.getStorageSync('userInfo')?.role;
if (role == 'dev') {
this.toDemandHall();
}
},
onReachBottom() {
@@ -65,12 +55,31 @@ Page({
onPullDownRefresh() {
this.init();
this.refreshRole();
},
init() {
this.loadHomePage();
},
/**
* 拉取最新角色并写回本地缓存
* 入驻审核通过后,用户回到小程序触发 onShow 即可看到「进入接单大厅」入口
*/
refreshRole() {
return fetchPerson().then((res) => {
if (res.code === 1 && res.data) {
const role = res.data.role || '';
this.setData({ role });
const userInfo = wx.getStorageSync('userInfo');
if (userInfo && userInfo.role !== role) {
userInfo.role = role;
wx.setStorageSync('userInfo', userInfo);
}
}
});
},
loadHomePage() {
wx.stopPullDownRefresh();
this.setData({