2025-09-28

This commit is contained in:
2025-09-28 09:21:15 +08:00
parent d2a0584ee5
commit 5110537d73
24 changed files with 819 additions and 365 deletions

View File

@@ -47,7 +47,6 @@
</view>
</view>
</view>
</view>
<Tabbar id="tabbarId"></Tabbar>

View File

@@ -166,6 +166,7 @@
password: userLogin.userForm.password,
})
}
uni.setStorageSync("user", response.user)
uni.showToast({
title: '登录成功',
icon: 'success',
@@ -186,6 +187,7 @@
password: userLogin.userForm.password,
})
}
uni.setStorageSync("user", response.user)
uni.showToast({
title: '登录成功',
icon: 'success',

View File

@@ -29,7 +29,7 @@
<u-waterfall v-model="mallList" ref="mallListRef">
<template v-slot:left="{leftList}">
<view class="mall-item u-m-r-10" v-for="(item, index) in leftList" :key="index">
<u-lazy-load threshold="-450" border-radius="10" :image="item.image"
<u-lazy-load threshold="-450" border-radius="10" :image="getImageUrl(item.image_url)"
:index="index"></u-lazy-load>
<view class="mall-title u-m-l-5 u-m-r-5">
{{item.name}}

View File

@@ -1,37 +1,39 @@
<template>
<view class="message-container">
<!-- 固定背景的容器 -->
<view class="background-container"></view>
<!-- 可滚动的内容区域 -->
<view class="content-container" :style="'height:'+height+'px'">
<view class="message-title">
容讯聊天室
</view>
<u-row class="message-search">
<u-col span="9">
<u-search placeholder="点击查询项目" v-model="keyword" :show-action="false"></u-search>
</u-col>
<u-col class="collection" span="3">
<image class="collection-icon" src="/static/icon/Bookmark.png" mode=""></image>
<view class="collection-text">
我的收藏
<view class="content-container">
<view style="padding: 32rpx;">
<view id="fixedHeadId">
<view class="message-title">
容讯聊天室
</view>
</u-col>
</u-row>
<view class="menu-list">
<view class="menu-item" v-for="(item,index) in menuList" @click="handleMenuChange(index)">
<view class="menu-title">{{item.name + '(' + item.count +')'}}
<u-row class="message-search">
<u-col span="9">
<u-search placeholder="点击查询项目" v-model="keyword" :show-action="false"></u-search>
</u-col>
<u-col class="collection" span="3">
<image class="collection-icon" src="/static/icon/Bookmark.png" mode=""></image>
<view class="collection-text">
我的收藏
</view>
</u-col>
</u-row>
<view class="menu-list">
<view class="menu-item" v-for="(item,index) in menuList" @click="handleMenuChange(index)">
<view class="menu-title">{{item.name + '(' + item.count +')'}}
</view>
<image class="menu-icon"
:src="currentMenu==index?'/static/icon/Chevron down.png':'/static/icon/Chevron right Menu.png'"
mode=""></image>
</view>
</view>
<image class="menu-icon"
:src="currentMenu==index?'/static/icon/Chevron down.png':'/static/icon/Chevron right Menu.png'"
mode=""></image>
</view>
</view>
<view class="message-list">
<view class="message-item" v-for="item in messageList">
{{item.messageName}}
</view>
<scroll-view scroll-y="true" class="message-list" :style="'height:'+height+'px'">
<view class="message-item" v-for="item in messageList" @click="handleChat(item)">
{{item.program.name}}
</view>
</scroll-view>
</view>
</view>
@@ -45,6 +47,7 @@
onReady, onPullDownRefresh
} from '@dcloudio/uni-app';
import { onReady as onUniReady } from '@dcloudio/uni-app';
import { groupAPI } from '../../api/group';
const instance = getCurrentInstance();
const height = ref(0)
@@ -54,7 +57,10 @@
success(res) {
let screenHeight = res.screenHeight
uni.createSelectorQuery().in(instance.proxy).select("#tabbarId").boundingClientRect((data : any) => {
height.value = screenHeight - data.height
height.value = screenHeight - data.height - 50
}).exec()
uni.createSelectorQuery().in(instance.proxy).select("#fixedHeadId").boundingClientRect((data : any) => {
height.value = height.value - data.height
}).exec()
}
})
@@ -94,18 +100,28 @@
})
}
}
// 下拉刷新
onPullDownRefresh(() => {
const handleChat = (item) => {
uni.navigateTo({
url: '/pages/program/chat?groupId=' + item.groupId
})
}
const loadData = () => {
groupAPI.getList().then((res) => {
messageList.value = res.data.list
})
}
onPullDownRefresh(async () => {
await loadData()
uni.stopPullDownRefresh()
})
onUniReady(() => {
loadHeight()
// 模拟数据
mockData()
loadData()
})
</script>
@@ -117,29 +133,12 @@
left: 0;
height: 100%;
overflow: hidden;
/* 防止容器本身滚动 */
/* 固定背景 */
.background-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(180deg, #2F75F9 0%, #F0F3FF 34.13%);
z-index: 1;
/* 确保背景在内容下方 */
}
/* 内容滚动区域 */
.content-container {
position: relative;
z-index: 2;
/* 确保内容在背景上方 */
background: linear-gradient(180deg, #2F75F9 0%, #F0F3FF 34.13%);
width: 100%;
overflow-y: scroll;
height: 100%;
padding: 32rpx;
.message-title {
margin-top: 40rpx;

View File

@@ -1,26 +1,32 @@
<template>
<view class="my-container">
{{user.real_name}}
<u-button @click="loginOut">退出登录</u-button>
</view>
<Tabbar></Tabbar>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
const user = ref()
onMounted(() => {
user.value = uni.getStorageSync("user")
const loginOut = () => {
uni.removeStorageSync("token")
uni.redirectTo({
url: '/pages/login/login'
})
}
const loginOut = () => {
uni.removeStorageSync("token")
uni.redirectTo({
url: '/pages/login/login'
})
}
</script>
<style scoped lang="scss">
.my-container {
}
.my-container {}
</style>

171
pages/program/chat.vue Normal file
View File

@@ -0,0 +1,171 @@
<template>
<view class="chat-container">
<u-navbar title="聊天" id="navBarId" :background="{background: 'transparent' }" :border-bottom="false"
back-icon-color="#000" title-color="#000">
<template v-slot:right>
<image class="collection" src="/static/icon/Bookmark.png" mode=""></image>
</template>
</u-navbar>
<view class="bottom-view" id="bottomId">
<view class="icon u-m-r-10">
<image src="/static/icon/Mic.png" mode="" style="width: 100%;height: 100%;"></image>
</view>
<textarea name="" v-model="text" class="text" maxlength="3000"></textarea>
<view v-if="text==null || text==''" class="icon u-m-r-10 u-m-l-10">
<image src="/static/icon/expression.png" mode="" style="width: 100%;height: 100%;"></image>
</view>
<view v-else class="icon u-m-r-10 u-m-l-10">
<image src="/static/icon/big.png" mode="" style="width: 100%;height: 100%;"></image>
</view>
<view v-if="text==null || text==''" class="icon">
<image src="/static/icon/Camera.png" mode="" style="width: 100%;height: 100%;"></image>
</view>
<view v-else class="icon u-m-r-10 u-m-l-10" @click="handleSend">
<image src="/static/icon/send.png" mode="" style="width: 100%;height: 100%;"></image>
</view>
</view>
<scroll-view :style="'height:'+scrollHeight+'px'" scroll-y="true" class="scroll-main">
<view v-for="(item, index) in dataList">
<view v-if="item.createId==userId" class="my-message">
{{item.content}}
</view>
<view v-else class="other-message">
{{item.content}}
</view>
</view>
</scroll-view>
</view>
</template>
<script setup lang="ts">
import { onMounted, ref, getCurrentInstance, onBeforeMount } from 'vue';
import {
onLoad,
} from "@dcloudio/uni-app";
import io from '@hyoga/uni-socket.io';
const text = ref('')
const socket = ref()
const navBarRef = ref()
const dataList = ref([])
const mockData = () => {
for (var i = 0; i < 40; i++) {
dataList.value.push("测试" + (i + 1))
}
}
const handleSend = () => {
socket.value.emit('clientMsg', {
createId: userId.value,
groupId: groupId.value,
content: text.value,
type: "text"
})
}
const groupId = ref()
const userId = ref()
onLoad((val) => {
groupId.value = val.groupId
});
const instance = getCurrentInstance();
const scrollHeight = ref(0)
const loadHeight = () => {
uni.getSystemInfo({
success(res) {
let screenHeight = res.screenHeight
uni.createSelectorQuery().in(instance.proxy).select("#navBarId").boundingClientRect((data : any) => {
scrollHeight.value = screenHeight - data.height
}).exec()
uni.createSelectorQuery().in(instance.proxy).select("#bottomId").boundingClientRect((data : any) => {
scrollHeight.value = scrollHeight.value - data.height
}).exec()
}
})
}
const connection = () => {
socket.value = io('http://192.168.0.15:3007', {
query: {},
transports: ['websocket', 'polling'],
timeout: 5000,
});
socket.value.on('connect', async () => {
console.log("连接成功");
})
socket.value.emit('addGroup', {
groupId: groupId.value,
})
socket.value.on('serverMsg', async (message) => {
console.log(message);
dataList.value.push(message)
})
}
const loadData = () => {
userId.value = uni.getStorageSync("user").id
}
onMounted(() => {
// mockData()
loadData()
loadHeight()
connection()
})
</script>
<style scoped lang="scss">
.chat-container {
width: 100%;
height: 100vh;
background: linear-gradient(180deg, #E3E8FF 0%, #FFFFFF 100%);
background-blend-mode: lighten;
.collection {
width: 48rpx;
height: 48rpx;
margin-right: 24rpx;
}
.bottom-view {
width: 100%;
height: 80rpx;
// background-color: #aaffff;
position: absolute;
bottom: 0;
display: flex;
align-items: center;
padding: 10rpx;
.icon {
width: 48rpx;
height: 48rpx;
}
.text {
width: 100%;
height: 100%;
border: 2rpx solid #DEEFFF;
}
}
.scroll-main {
.my-message {
text-align: right;
}
.other-message {}
}
}
</style>

View File

@@ -1,16 +1,13 @@
<template>
<view class="message-container">
<!-- 固定背景的容器 -->
<view class="background-container"></view>
<!-- 可滚动的内容区域 -->
<view class="content-container" :style="'height:'+height+'px'">
<view class="searchFilter">
<view class="searchFilter" id="searchFilterId">
<view class="search">
<u-search :show-action="false" placeholder="输入项目名称、企业名称" v-model="keyword"></u-search>
<u-search :show-action="false" placeholder="输入项目名称、企业名称" v-model="params.keyword" bgColor="#CADBFF"
@search="handleSearch"></u-search>
</view>
<u-dropdown :duration="0">
<u-dropdown :duration="0" class="dropdown">
<u-dropdown-item class="u-dropdown" v-model="areaFilter" title="区域筛选"
:options="areaOptions"></u-dropdown-item>
<u-dropdown-item class="u-dropdown" v-model="timeFilter" title="时间筛选"
@@ -20,33 +17,39 @@
</u-dropdown>
</view>
<view class="program-list">
<view class="program-item" v-for="item in programList" @click="handleDetail(item)">
<view class="program-avatar">
<image style="width: 100%;height: 100%;border-radius: 50%;" src="/static/ceshi_avatar.jpg"
mode=""></image>
</view>
<view class="program-info">
<view class="program-name">
{{item.programName}}
<view class="program-list" :style="'height:'+scrollHeight+'px'">
<scroll-view scroll-y="true" style="height: 100%;" v-if="programList.length!=0" @scrolltolower="loadData">
<view class="program-item" v-for="item in programList" @click="handleDetail(item)">
<view class="program-avatar">
<image style="width: 100%;height: 100%;border-radius: 50%;"
:src="getImageUrl(item.user.avatar)" mode=""></image>
</view>
<view class="company-name">
{{item.companyName}}
</view>
<view class="program-address">
项目地点{{item.programAddress}}
</view>
<view class="program-contact">
项目联系人{{item.contact}}
</view>
<view class="program-introduction">
项目简介{{item.introduction}}
<view class="program-info">
<view class="program-name">
{{item.name}}
</view>
<view class="company-name">
{{item.company}}
</view>
<view class="program-address">
项目地点{{item.address}}
</view>
<view class="program-contact">
项目联系人{{maskPhoneNumber(item.user.username)}}
</view>
<view class="program-introduction">
项目简介{{item.introduction}}
</view>
</view>
</view>
<u-loadmore :status="status" />
<view class="box-div"></view>
</scroll-view>
<view style="height: 100%;" v-else>
<u-empty></u-empty>
</view>
</view>
</view>
<Tabbar id="tabbarId"></Tabbar>
@@ -54,14 +57,17 @@
</template>
<script setup lang="ts">
import { ref, computed, getCurrentInstance } from 'vue';
import { ref, computed, getCurrentInstance, onMounted } from 'vue';
import {
onReady
} from '@dcloudio/uni-app';
import { onReady as onUniReady } from '@dcloudio/uni-app';
import { onReady as onUniReady, onPullDownRefresh } from '@dcloudio/uni-app';
import { programAPI } from '../../api/program';
import { getImageUrl, maskPhoneNumber } from '../../util/common';
const instance = getCurrentInstance();
const height = ref(0)
const scrollHeight = ref(0)
const loadHeight = () => {
uni.getSystemInfo({
@@ -70,6 +76,9 @@
uni.createSelectorQuery().in(instance.proxy).select("#tabbarId").boundingClientRect((data : any) => {
height.value = screenHeight - data.height
}).exec()
uni.createSelectorQuery().in(instance.proxy).select("#searchFilterId").boundingClientRect((data : any) => {
scrollHeight.value = height.value - data.height
}).exec()
}
})
}
@@ -122,74 +131,99 @@
// 列表
const programList = ref([])
const defaultSize = 5
const params = ref({
page: 1,
size: defaultSize,
keyword: ''
})
const status = ref('loadmore')
const maxPage = ref()
const mockData = () => {
for (var i = 0; i < 20; i++) {
programList.value.push({
programName: "项目名称" + (i + 1),
companyName: "公司名称" + (i + 1),
programAddress: "xx省xx市xxx区",
contact: "联系人" + (i + 1),
introduction: "在 Vue 3 + TypeScript 中使用 v-for=item in Range(1,20)报错,是因为 JavaScript/TypeScript 中没有内置 Range 函数(这是 Python 中的语法)。需要自己实现一个范围生成函数,并在模板中使用。"
})
}
}
const handleDetail = (item) => {
uni.navigateTo({
url: '/pages/program/programDetail'
// 加载数据
const loadData = () => {
if (status.value == 'nomore') return
programAPI.getList(params.value).then(res => {
programList.value = programList.value.concat(res.data.list)
maxPage.value = res.data.pages
params.value.page++
if (params.value.page > maxPage.value) {
status.value = 'nomore'
}
}).finally(() => {
uni.stopPullDownRefresh()
})
}
// 查看详情
const handleDetail = (item) => {
uni.navigateTo({
url: '/pages/program/programDetail?programId=' + item.id
})
}
// 查询
const handleSearch = () => {
params.value = {
page: 1,
size: defaultSize,
keyword: params.value.keyword
}
programList.value = []
loadData()
}
// 刷新
onPullDownRefresh(async () => {
// 全局刷新
params.value = {
page: 1,
size: defaultSize,
keyword: ''
}
programList.value = []
loadData()
})
onMounted(() => {
loadData()
})
onUniReady(() => {
loadHeight()
mockData()
})
</script>
<style lang="scss" scoped>
.message-container {
width: 100%;
position: fixed;
top: 0;
left: 0;
height: 100%;
overflow: hidden;
/* 防止容器本身滚动 */
/* 固定背景 */
.background-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #F0F3FF;
z-index: 1;
/* 确保背景在内容下方 */
}
height: 100vh;
background: linear-gradient(270deg, #65A7FF 0%, #458CF9 23.08%, #3F82FF 50%, #458CF9 71.15%, #65A7FF 100%);
/* 内容滚动区域 */
.content-container {
position: relative;
z-index: 2;
/* 确保内容在背景上方 */
width: 100%;
overflow-y: scroll;
height: 100%;
.searchFilter {
background-color: #fff;
background-color: transparent;
.search {
padding: 60rpx 42rpx 0;
}
}
::v-deep .dropdown {
.u-dropdown__menu__item__text {
color: #fff !important;
}
}
.program-list {
margin-top: 20rpx;
.program-item {
background-color: #fff;
background-color: #F0F3FF;
border-radius: 20rpx;
padding: 20rpx 42rpx;
margin-bottom: 20rpx;
@@ -270,6 +304,10 @@
}
}
}
.box-div {
padding: 30rpx 0rpx;
}
}
}
}

View File

@@ -1,7 +1,7 @@
<template>
<view class="detail-contrainer">
<u-navbar :is-fixed="false" title="项目详情" :background="{background: 'transparent' }" :border-bottom="false" back-icon-color="#fff"
title-color="#fff">
<u-navbar :is-fixed="false" title="项目详情" :background="{background: 'transparent' }" :border-bottom="false"
back-icon-color="#fff" title-color="#fff">
<template v-slot:right>
<image class="collection" src="/static/icon/Bookmark.png" mode=""></image>
</template>
@@ -9,10 +9,10 @@
<view class="head-text">
<view class="text-name">
xxxx工程
{{program.name}}
</view>
<view class="text-date">
起止时间2025/09/13-202512/12
起止时间{{program.startDate}}{{program.endDate}}
</view>
<view class="text-progress">
项目进度
@@ -29,19 +29,19 @@
</u-row>
<u-row class="u-m-b-20">
<u-col span="6" class="card-name">详细地址</u-col>
<u-col span="6" class="card-value">xx区xx路xxx号</u-col>
<u-col span="6" class="card-value">{{program.address}}</u-col>
</u-row>
<u-row class="u-m-b-20">
<u-col span="6" class="card-name">联系人</u-col>
<u-col span="6" class="card-value">xxx</u-col>
<u-col span="6" class="card-value">{{program.user.username}}</u-col>
</u-row>
<u-row class="u-m-b-20">
<u-col span="6" class="card-name">结算方式</u-col>
<u-col span="6" class="card-value">按月结算 次月支付60%</u-col>
<u-col span="6" class="card-value">{{program.paymentMethod}}</u-col>
</u-row>
<u-row>
<u-col span="6" class="card-name">项目企业</u-col>
<u-col span="6" class="card-value">xxxx公司</u-col>
<u-col span="6" class="card-value">{{program.company}}</u-col>
</u-row>
</view>
@@ -96,7 +96,7 @@
</view>
<u-row justify="flex-end" class="u-m-r-40 btn-group">
<u-col span="3"><u-button class="btn" type="primary">聊一聊</u-button></u-col>
<u-col span="3"><u-button class="btn" type="primary">{{isChat?"继续聊":"聊一聊"}}</u-button></u-col>
<u-col span="3"><u-button class="btn" type="success" @click="handleOpen">立刻融</u-button></u-col>
</u-row>
@@ -167,7 +167,52 @@
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { onMounted, ref } from 'vue';
import { getUserInfo } from '../../util/common';
import { programAPI } from '../../api/program';
import { onLoad } from '@dcloudio/uni-app'
const userId = ref()
const programId = ref()
const isChat = ref(false)
const program = ref({
name: '',
linkmanId: '',
company: '',
introduction: '',
address: '',
startDate: '',
endDate: '',
paymentMethod: '',
remark: '',
createDate: '',
user: {}
})
const loadData = () => {
programAPI.isChat({
userId: userId.value,
programId: programId.value
}).then(res => {
if (res.code == 200) {
isChat.value = res.data.isChat
}
})
programAPI.getProgram(programId.value).then(res => {
program.value = res.data
})
}
onLoad((val) => {
programId.value = val.programId
let user = getUserInfo()
userId.value = user.id
})
onMounted(() => {
loadData()
})
// 立刻融 弹窗
const showWarning = ref(false)