会员权益

This commit is contained in:
2026-04-29 15:33:58 +08:00
commit 54965243da
2787 changed files with 242809 additions and 0 deletions

469
pagesDemand/demand/add.vue Normal file
View File

@@ -0,0 +1,469 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 发布供需 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<page-meta :page-style="'overflow:' + (pageShow ? 'hidden' : 'visible')"></page-meta>
<view class="container" :style="{ '--theme-color': themeColor }">
<!-- 标题栏 -->
<title-bar :showBack="true" title="发布供需"></title-bar>
<!-- 内容区 -->
<view class="container-main">
<!-- 表单 -->
<view class="main-form">
<!-- 发布类型 -->
<view class="form-item">
<view class="item-title"><text style="color: #E60012;">*</text>发布类型</view>
<view class="item-input" @click="openSelectType()">
<view class="input text-ellipsis" v-if="formData.category_id">{{getTypeName()}}</view>
<view class="input placeholder text-ellipsis" v-else>请选择发布类型</view>
<image class="icon" src="/static/right.png" mode="aspectFit"></image>
</view>
</view>
<!-- 标题 -->
<view class="form-item">
<view class="item-title"><text style="color: #E60012;">*</text>标题</view>
<view class="item-input">
<input class="input" type="text" v-model="formData.title" placeholder="请输入标题" placeholder-class="placeholder" />
</view>
</view>
<!-- 介绍 -->
<view class="form-item">
<view class="item-title"><text style="color: #E60012;">*</text>介绍</view>
<view class="item-input">
<textarea class="textarea" type="text" maxlength="-1" v-model="formData.content" placeholder="请输入" placeholder-class="placeholder" />
</view>
</view>
<!-- 地址 -->
<view class="form-item">
<view class="item-title">地址</view>
<view class="item-input" @click="chooseLocation()">
<view class="input text-ellipsis" v-if="formData.address">{{formData.address}}</view>
<view class="input placeholder text-ellipsis" v-else>请选择地址(非必填项)</view>
<image class="icon" src="/static/right.png" mode="aspectFit"></image>
</view>
</view>
<!-- 详情图片 -->
<view class="form-item">
<view class="item-title">
<text>详情图片</text>
<text class="tips">图片建议尺寸1:1</text>
</view>
<view class="item-upload">
<view class="upload-image" v-for="(img, num) in selectImages" :key="num" @click="previewImage(num)">
<image class="image-select" :src="img" mode="aspectFill"></image>
<image class="image-delete" src="/static/delete.png" mode="aspectFit" @click.stop="deleteImage(num)"></image>
</view>
<view class="upload-image" v-if="selectImages.length < 9" @click="chooseImage()">
<view class="image-background"></view>
<view class="image-choose">
<view class="icon">
<image src="/static/camera.png" mode="aspectFit"></image>
</view>
<view class="text">上传图片</view>
</view>
</view>
</view>
</view>
</view>
<!-- 提交按钮 -->
<view class="main-footer">
<view class="footer-btn" @click="handleSubmit()">提交审核</view>
<view class="safe-padding"></view>
</view>
</view>
<!-- 单项选择框 -->
<select-picker ref="selectPicker" title="发布类型" @onChange="pageChange" @confirm="changeSelectType"></select-picker>
</view>
</template>
<script>
import { mapState } from "vuex"
import selectPicker from "@/pages/component/picker/select.vue"
export default {
components: {
selectPicker
},
data() {
return {
// 页面是否阻止滚动
pageShow: false,
// 发布类型列表
typeList: [],
// 表单数据
formData: {
// 发布类型
category_id: null,
// 标题
title: "",
// 介绍
content: "",
// 地址
address: "",
// 经度
lng: "",
// 纬度
lat: "",
// 详情图片
images: "",
},
// 已选择图片
selectImages: [],
// 延时器
timeout: null,
};
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
})
},
onLoad() {
this.getDemandType()
},
onUnload() {
if (this.timeout) clearTimeout(this.timeout)
},
methods: {
// 改变页面滚动状态
pageChange(state) {
this.pageShow = state
},
// 字符串转数组格式图片
splitImages(images) {
try {
if (images) return images.split(',');
else return []
} catch (error) {
return [];
}
},
// 获取发布类型
getDemandType() {
this.$util.request("demand.businessCat", {}).then(res => {
if (res.code == 1) {
this.typeList = res.data
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
console.error('获取发布类型', error)
})
},
// 打开选择发布类型弹窗
openSelectType() {
this.$refs.selectPicker.open(this.typeList, this.formData.category_id)
},
// 改变发布类型
changeSelectType(value) {
this.formData.category_id = value.id
},
// 获取发布类型名称
getTypeName() {
for (var i in this.typeList) {
if (this.typeList[i].id == this.formData.category_id) {
return this.typeList[i].name
}
}
return ""
},
// 打开地图选择位置
chooseLocation() {
uni.chooseLocation({
success: (res) => {
this.formData.lat = res.latitude
this.formData.lng = res.longitude
this.formData.address = res.address || ""
}
});
},
// 选择图片
chooseImage() {
// #ifdef MP-WEIXIN
uni.chooseMedia({
count: 9 - this.selectImages.length,
mediaType: ['image'],
sourceType: ['album', 'camera'],
sizeType: ['compressed'],
success: (res) => {
this.selectImages = [...this.selectImages, ...res.tempFiles.map(item => item.tempFilePath)]
}
})
// #endif
// #ifndef MP-WEIXIN
uni.chooseImage({
count: 9 - this.selectImages.length,
sourceType: ['album', 'camera'],
sizeType: ['compressed'],
success: (res) => {
this.selectImages = [...this.selectImages, ...res.tempFilePaths]
}
});
// #endif
},
// 删除图片
deleteImage(index) {
this.$delete(this.selectImages, index)
},
// 预览图片
previewImage(index) {
uni.previewImage({
urls: this.selectImages,
current: index,
})
},
// 提交审核
handleSubmit() {
if (!this.formData.category_id) {
uni.showToast({
title: "请选择发布类型",
icon: 'none'
})
return
}
if (!this.formData.title) {
uni.showToast({
title: "请输入标题",
icon: 'none'
})
return
}
if (!this.formData.content) {
uni.showToast({
title: "请输入内容",
icon: 'none'
})
return
}
if (this.selectImages.length > 0) {
uni.showLoading({
title: "提交中",
mask: true
})
const oldImages = this.splitImages(this.formData.images)
this.$util.uploadFileMultiple(this.selectImages, oldImages).then(result => {
this.formData.images = result
this.submitEvent()
}).catch(error => {
uni.hideLoading()
console.error('上传图片 ', error)
})
} else {
uni.showLoading({
title: "提交中",
mask: true
})
this.submitEvent()
}
},
// 提交事件
submitEvent() {
this.$util.request("demand.businessAdd", this.formData).then(res => {
if (res.code == 1) {
uni.showToast({
title: "提交成功",
icon: "success",
duration: 1500,
mask: true
})
this.timeout = setTimeout(() => {
uni.navigateBack()
}, 1500)
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
console.error('提交审核', error)
})
},
}
}
</script>
<style lang="scss">
.container {
.container-main {
padding-bottom: 112rpx;
.main-form {
padding: 32rpx 48rpx;
.form-item {
margin-top: 32rpx;
&:first-child {
margin-top: 0;
}
.item-title {
color: #5A5B6E;
font-size: 32rpx;
font-weight: 600;
line-height: 44rpx;
.tips {
font-size: 24rpx;
font-weight: 400;
}
}
.item-input {
margin-top: 32rpx;
display: flex;
align-items: center;
border-radius: 16rpx;
background: #ffffff;
.input {
color: #5A5B6E;
font-size: 28rpx;
height: 112rpx;
line-height: 112rpx;
flex: 1;
padding: 0 32rpx;
}
.textarea {
color: #5A5B6E;
font-size: 28rpx;
line-height: 40rpx;
flex: 1;
padding: 36rpx 32rpx;
width: 100%;
height: 240rpx;
}
.placeholder {
color: #ACADB7;
}
.icon {
width: 32rpx;
height: 32rpx;
padding-right: 32rpx;
}
}
.item-upload {
display: flex;
flex-wrap: wrap;
margin-top: 32rpx;
column-gap: 3.5%;
row-gap: 24rpx;
.upload-image {
position: relative;
width: 31%;
height: 0;
padding-top: 31%;
.image-select {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 10rpx;
}
.image-video {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 10rpx;
background: var(--theme-color);
padding: 56rpx;
}
.image-delete {
position: absolute;
top: -16rpx;
right: -16rpx;
width: 48rpx;
height: 48rpx;
}
.image-choose {
position: absolute;
top: 20rpx;
left: 20rpx;
right: 20rpx;
bottom: 20rpx;
z-index: 6;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: #ffffff;
border-radius: 10rpx;
.icon {
width: 80rpx;
height: 80rpx;
padding: 18rpx;
background: var(--theme-color);
border-radius: 50%;
}
.text {
margin-top: 16rpx;
color: var(--theme-color);
font-size: 28rpx;
line-height: 40rpx;
}
}
.image-background {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1;
background: var(--theme-color);
opacity: 0.08;
}
}
}
}
}
.main-footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 99;
padding: 12rpx 32rpx;
background: #ffffff;
border-top: 1rpx solid #F6F7FB;
.footer-btn {
color: #ffffff;
font-size: 32rpx;
line-height: 44rpx;
padding: 22rpx 24rpx;
border-radius: 16rpx;
background: var(--theme-color);
text-align: center;
}
}
}
}
</style>

View File

@@ -0,0 +1,529 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 供需详情 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<view class="container" :style="{ '--theme-color': themeColor }">
<!-- 标题栏 -->
<title-bar title="供需详情"></title-bar>
<!-- 内容区 -->
<view class="container-main" v-if="loadEnd">
<view class="main-tips flex align-items-center" :style="{top: titleBarHeight + 'px'}">
<view class="tips-icon" :style="{'background-image': 'url('+ iconSecurity +')'}" v-if="iconSecurity"></view>
<view class="tips-text flex-item">信息真实该信息由本商会成员发布接受大家监督</view>
<view class="tips-bg"></view>
</view>
<view class="main-content">
<view class="content-item">
<view class="item-top flex align-items-center" @click="toMemberDetails()">
<image class="top-avatar" :src="demandDetails.member.avatar" mode="aspectFill"></image>
<view class="top-info flex-item">
<view class="title">{{ demandDetails.member.name }}</view>
<view class="subtitle">
{{ demandDetails.member.level_name }} | {{ demandDetails.business.time }} | 浏览 {{ demandDetails.business.page_view }}
</view>
</view>
<view class="top-btn">
<image class="icon" src="/static/more.png" mode="aspectFill"></image>
</view>
</view>
<view class="item-center" v-if="demandDetails.business">
<view class="center-title">{{ demandDetails.business.title }}</view>
<view class="center-content">
<text>{{ demandDetails.business.content }}</text>
</view>
<view class="center-image" :class="{'special-image': (demandDetails.business.images.length < 3 || demandDetails.business.images.length === 4)}" v-if="demandDetails.business.images.length">
<view class="image-box" v-for="(img, num) in demandDetails.business.images" :key="num" @click.stop="previewImage(num)">
<image class="image" :src="img" mode="aspectFill"></image>
</view>
</view>
</view>
<view class="item-bottom" v-if="demandDetails.business.address">
<view class="bottom-label inline-flex align-items-center">
<view class="label-icon" :style="{'background-image': 'url('+ iconAddress +')'}" v-if="iconAddress"></view>
<text class="label-text flex-item">{{demandDetails.business.address}}</text>
<view class="label-bg"></view>
</view>
</view>
</view>
</view>
<view class="main-footer">
<view class="flex">
<button open-type="share" class="footer-share clear flex-item flex flex-center">
<view class="share-icon" :style="{'background-image': 'url('+ iconShare +')'}" v-if="iconShare"></view>
<text class="share-text">分享给好友</text>
<view class="share-bg"></view>
</button>
<view class="footer-contact" @click="onContact()">联系TA</view>
</view>
<view class="safe-padding"></view>
</view>
</view>
<!-- 未登录状态 -->
<view class="container-login" v-else-if="showLogin">
<image class="login-image" :src="loginImg" mode="aspectFit"></image>
<view class="login-tips">小程序需要登录注册才能使用相关功能请登录后查看该页面</view>
<view class="login-btn" :style="{ background: themeColor }" @click="toLogin()">前往登录</view>
</view>
<!-- 底部导航 -->
<tab-bar></tab-bar>
</view>
</template>
<script>
import { mapState } from "vuex"
import svgData from "@/common/svg.js"
// #ifdef H5
import wx from 'weixin-js-sdk';
// #endif
export default {
data() {
return {
// 加载完成
loadEnd: false,
// 标题栏高度
titleBarHeight: 0,
// 供需id
demandId: 0,
// 详情数据
demandDetails: {},
// 是否显示登录提示
showLogin: false,
};
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
iconSecurity: state => {
return svgData.svgToUrl("security", state.app.themeColor)
},
iconAddress: state => {
return svgData.svgToUrl("address", state.app.themeColor)
},
iconShare: state => {
return svgData.svgToUrl("share", state.app.themeColor)
},
loginImg: state => state.app.loginImg,
}),
},
mounted() {
// #ifdef MP-WEIXIN
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.titleBarHeight = statusBarHeight + (menuButtonInfo.top - statusBarHeight) * 2 + menuButtonInfo.height
// #endif
},
onLoad(option) {
this.demandId = option.id
uni.showLoading({
title: "加载中"
})
this.getDemandDetails(() => {
uni.hideLoading()
this.loadEnd = true
// #ifdef H5
this.initConfig()
// #endif
})
},
onShow() {
if (this.loadEnd) this.getDemandDetails()
},
onShareAppMessage() {
return {
title: this.demandDetails.business.title,
imageUrl: this.demandDetails.business.images.length ? this.demandDetails.business.images[0] : this.demandDetails.member.avatar,
}
},
onShareTimeline() {
return {
title: this.demandDetails.business.title,
imageUrl: this.demandDetails.business.images.length ? this.demandDetails.business.images[0] : this.demandDetails.member.avatar,
}
},
methods: {
// #ifdef H5
// 微信公众号初始化方法
initConfig() {
this.$util.request("main.WeChatConfig", {
url: location.href.split('#')[0]
}).then(res => {
if (res.code == 1) {
wx.config({
debug: false,
appId: res.data.appId,
timestamp: Number(res.data.timestamp),
nonceStr: res.data.nonceStr,
signature: res.data.signature,
jsApiList: ["updateAppMessageShareData", "updateTimelineShareData"],
openTagList: ["updateAppMessageShareData", "updateTimelineShareData"],
})
wx.ready(() => {
wx.updateAppMessageShareData({
title: this.demandDetails.business.title,
desc: "",
link: window.location.href,
imgUrl: this.demandDetails.business.images[0],
});
wx.updateTimelineShareData({
title: this.demandDetails.business.title,
link: window.location.href,
imgUrl: this.demandDetails.business.images[0],
});
});
} else {
uni.hideLoading()
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
uni.hideLoading()
console.error('通过config接口注入权限验证配置 ', error)
})
},
// #endif
// 获取详情
getDemandDetails(fn) {
this.$util.request("demand.businessDetails", {
id: this.demandId
}).then(res => {
if (fn) fn()
if (res.code == 1) {
this.demandDetails = res.data
this.demandDetails.business.images = this.splitImages(res.data.business.images)
this.demandDetails.business.time = this.$util.getDateBeforeNow(this.demandDetails.business.createtime)
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (error == 401) {
this.showLogin = true
} else {
if (fn) fn()
console.error('获取详情 ', error)
}
})
},
// 字符串转数组格式图片
splitImages(images) {
try {
if (images) return images.split(',');
else return []
} catch (error) {
return [];
}
},
// 跳转会员详情
toMemberDetails() {
if (this.demandDetails?.member?.id) {
this.$util.toPage({
mode: 1,
path: "/pages/member/details?id=" + this.demandDetails.member.id
})
} else {
this.$util.toPage({
mode: 1,
path: "/pages/index/association"
})
}
},
// 联系
onContact() {
this.$util.toPage({
mode: 6,
phone: this.demandDetails.member.mobile,
})
},
// 预览图片
previewImage(index) {
uni.previewImage({
urls: this.demandDetails.business.images,
current: index,
});
},
// 前往登录
toLogin() {
uni.redirectTo({
url: `/pagesDemand/demand/details?id=${this.demandId}`,
})
},
}
}
</script>
<style lang="scss">
.container {
.container-main {
padding-bottom: 112rpx;
.main-tips {
position: sticky;
top: 0;
z-index: 99;
background: #FFF;
padding: 24rpx 32rpx;
.tips-icon {
width: 32rpx;
height: 32rpx;
background-size: 32rpx;
}
.tips-text {
color: var(--theme-color);
font-size: 24rpx;
line-height: 34rpx;
margin-left: 8rpx;
}
.tips-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: -1;
background: var(--theme-color);
opacity: 0.1;
}
}
.main-content {
padding: 32rpx;
.content-item {
padding: 32rpx 32rpx 24rpx;
border-radius: 16rpx;
background: #FFF;
.item-top {
padding-bottom: 32rpx;
border-bottom: 1px solid #E4E4E4;
.top-avatar {
width: 96rpx;
height: 96rpx;
border-radius: 50%;
}
.top-info {
margin-left: 24rpx;
.title {
color: #5A5B6E;
font-size: 32rpx;
font-weight: 600;
line-height: 44rpx;
}
.subtitle {
margin-top: 16rpx;
color: #666;
font-size: 24rpx;
line-height: 34rpx;
}
}
.top-btn {
background: var(--theme-color);
border-radius: 50%;
overflow: hidden;
width: 48rpx;
height: 48rpx;
.icon {
width: 100%;
height: 100%;
}
}
}
.item-center {
margin-top: 32rpx;
.center-title {
color: #5A5B6E;
font-size: 32rpx;
font-weight: 600;
line-height: 44rpx;
}
.center-content {
margin-top: 24rpx;
color: #5A5B6E;
font-size: 28rpx;
line-height: 40rpx;
}
.center-image {
display: flex;
flex-wrap: wrap;
margin-top: 16rpx;
column-gap: 2%;
row-gap: 14rpx;
.image-box {
width: 32%;
height: 0;
padding-top: 32%;
position: relative;
border-radius: 16rpx;
overflow: hidden;
.image {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
}
&.special-image {
justify-content: space-between;
column-gap: 0;
.image-box {
width: calc(50% - 8rpx);
padding-top: calc(50% - 8rpx);
}
}
}
}
.item-bottom {
margin-top: 24rpx;
.bottom-label {
padding: 6rpx 18rpx 6rpx 8rpx;
position: relative;
z-index: 1;
border-radius: 8rpx;
overflow: hidden;
.label-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--theme-color);
z-index: -1;
opacity: 0.1;
}
.label-icon {
width: 24rpx;
height: 24rpx;
background-size: 24rpx;
}
.label-text {
margin-left: 8rpx;
color: var(--theme-color);
font-size: 20rpx;
line-height: 28rpx;
}
}
}
}
}
.main-footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 99;
padding: 12rpx 24rpx;
background: #ffffff;
border-top: 1rpx solid #F6F7FB;
.footer-share {
padding: 22rpx 24rpx;
background: #FFF;
border-radius: 16rpx;
overflow: hidden;
position: relative;
z-index: 1;
.share-icon {
width: 32rpx;
height: 32rpx;
background-size: 32rpx;
}
.share-text {
margin-left: 16rpx;
color: var(--theme-color);
font-size: 24rpx;
line-height: 44rpx;
}
.share-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: -1;
background: var(--theme-color);
opacity: 0.1;
}
}
.footer-contact {
color: #ffffff;
font-size: 32rpx;
line-height: 44rpx;
padding: 22rpx 24rpx;
border-radius: 16rpx;
background: var(--theme-color);
text-align: center;
width: 240rpx;
margin-left: 16rpx;
}
}
}
.container-login {
padding: 96rpx 60rpx 0;
.login-image {
width: 100%;
height: 500rpx;
}
.login-tips {
color: #585858;
font-size: 36rpx;
line-height: 50rpx;
margin-top: 48rpx;
text-align: center;
}
.login-btn {
margin-top: 56rpx;
height: 88rpx;
line-height: 88rpx;
font-size: 28rpx;
border-radius: 16rpx;
text-align: center;
color: #ffffff;
}
}
}
</style>

517
pagesDemand/demand/edit.vue Normal file
View File

@@ -0,0 +1,517 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 发布/修改供需 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<page-meta :page-style="'overflow:' + (pageShow ? 'hidden' : 'visible')"></page-meta>
<view class="container" :style="{ '--theme-color': themeColor }">
<!-- 标题栏 -->
<title-bar :showBack="true" :title="demandId ? '修改供需' : '发布供需'"></title-bar>
<!-- 内容区 -->
<view class="container-main" v-if="loadEnd">
<!-- 表单 -->
<view class="main-form">
<!-- 发布类型 -->
<view class="form-item">
<view class="item-title"><text style="color: #E60012;">*</text>发布类型</view>
<view class="item-input" @click="openSelectType()">
<view class="input text-ellipsis" v-if="formData.category_id">{{getTypeName()}}</view>
<view class="input placeholder text-ellipsis" v-else>请选择发布类型</view>
<image class="icon" src="/static/right.png" mode="aspectFit"></image>
</view>
</view>
<!-- 标题 -->
<view class="form-item">
<view class="item-title"><text style="color: #E60012;">*</text>标题</view>
<view class="item-input">
<input class="input" type="text" v-model="formData.title" placeholder="请输入标题" placeholder-class="placeholder" />
</view>
</view>
<!-- 介绍 -->
<view class="form-item">
<view class="item-title"><text style="color: #E60012;">*</text>介绍</view>
<view class="item-input">
<textarea class="textarea" type="text" maxlength="-1" v-model="formData.content" placeholder="请输入" placeholder-class="placeholder" />
</view>
</view>
<!-- 地址 -->
<view class="form-item">
<view class="item-title">地址</view>
<view class="item-input" @click="chooseLocation()">
<view class="input text-ellipsis" v-if="formData.address">{{formData.address}}</view>
<view class="input placeholder text-ellipsis" v-else>请选择地址(非必填项)</view>
<image class="icon" src="/static/right.png" mode="aspectFit"></image>
</view>
</view>
<!-- 详情图片 -->
<view class="form-item">
<view class="item-title">
<text>详情图片</text>
<text class="tips">图片建议尺寸1:1</text>
</view>
<view class="item-upload">
<view class="upload-image" v-for="(img, num) in selectImages" :key="num" @click="previewImage(num)">
<image class="image-select" :src="img" mode="aspectFill"></image>
<image class="image-delete" src="/static/delete.png" mode="aspectFit" @click.stop="deleteImage(num)"></image>
</view>
<view class="upload-image" v-if="selectImages.length < 9" @click="chooseImage()">
<view class="image-background"></view>
<view class="image-choose">
<view class="icon">
<image src="/static/camera.png" mode="aspectFit"></image>
</view>
<view class="text">上传图片</view>
</view>
</view>
</view>
</view>
</view>
<!-- 提交按钮 -->
<view class="main-footer">
<view class="footer-btn" @click="handleSubmit()">提交审核</view>
<view class="safe-padding"></view>
</view>
</view>
<!-- 单项选择框 -->
<select-picker ref="selectPicker" title="发布类型" @onChange="pageChange" @confirm="changeSelectType"></select-picker>
</view>
</template>
<script>
import { mapState } from "vuex"
import selectPicker from "@/pages/component/picker/select.vue"
export default {
components: {
selectPicker
},
data() {
return {
// 加载完成
loadEnd: false,
// 页面是否阻止滚动
pageShow: false,
// 供需id
demandId: null,
// 发布类型列表
typeList: [],
// 表单数据
formData: {
// 发布类型
category_id: null,
// 标题
title: "",
// 介绍
content: "",
// 地址
address: "",
// 经度
lng: "",
// 纬度
lat: "",
// 详情图片
images: "",
},
// 已选择图片
selectImages: [],
// 延时器
timeout: null,
};
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
})
},
onLoad(option) {
this.getDemandType()
if (option.id) {
this.demandId = option.id
uni.showLoading({
title: "加载中"
})
this.getDemandDetails(() => {
uni.hideLoading()
this.loadEnd = true
})
} else {
this.loadEnd = true
}
},
onUnload() {
clearTimeout(this.timeout)
},
methods: {
// 改变页面滚动状态
pageChange(state) {
this.pageShow = state
},
// 获取详情
getDemandDetails(fn) {
this.$util.request("demand.businessUserDetails", {
id: this.demandId
}).then(res => {
if (fn) fn()
if (res.code == 1) {
this.formData = {
id: res.data.business.id,
category_id: res.data.business.category_id,
title: res.data.business.title,
content: res.data.business.content,
address: res.data.business.address,
lng: res.data.business.lng,
lat: res.data.business.lat,
images: res.data.business.images,
}
this.selectImages = this.splitImages(res.data.business.images)
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (fn) fn()
console.error('获取详情', error)
})
},
// 字符串转数组格式图片
splitImages(images) {
try {
if (images) return images.split(',');
else return []
} catch (error) {
return [];
}
},
// 获取发布类型
getDemandType() {
this.$util.request("demand.businessCat", {}).then(res => {
if (res.code == 1) {
this.typeList = res.data
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
console.error('获取发布类型', error)
})
},
// 打开选择发布类型弹窗
openSelectType() {
this.$refs.selectPicker.open(this.typeList, this.formData.category_id)
},
// 改变发布类型
changeSelectType(value) {
this.formData.category_id = value.id
},
// 获取发布类型名称
getTypeName() {
for (var i in this.typeList) {
if (this.typeList[i].id == this.formData.category_id) {
return this.typeList[i].name
}
}
return ""
},
// 打开地图选择位置
chooseLocation() {
uni.chooseLocation({
success: (res) => {
this.formData.lat = res.latitude
this.formData.lng = res.longitude
this.formData.address = res.address || ""
}
});
},
// 选择图片
chooseImage() {
// #ifdef MP-WEIXIN
uni.chooseMedia({
count: 9 - this.selectImages.length,
mediaType: ['image'],
sourceType: ['album', 'camera'],
sizeType: ['compressed'],
success: (res) => {
this.selectImages = [...this.selectImages, ...res.tempFiles.map(item => item.tempFilePath)]
}
})
// #endif
// #ifndef MP-WEIXIN
uni.chooseImage({
count: 9 - this.selectImages.length,
sourceType: ['album', 'camera'],
sizeType: ['compressed'],
success: (res) => {
this.selectImages = [...this.selectImages, ...res.tempFilePaths]
}
});
// #endif
},
// 删除图片
deleteImage(index) {
this.$delete(this.selectImages, index)
},
// 预览图片
previewImage(index) {
uni.previewImage({
urls: this.selectImages,
current: index,
})
},
// 提交审核
handleSubmit() {
if (!this.formData.category_id) {
uni.showToast({
title: "请选择发布类型",
icon: 'none'
})
return
}
if (!this.formData.title) {
uni.showToast({
title: "请输入标题",
icon: 'none'
})
return
}
if (!this.formData.content) {
uni.showToast({
title: "请输入内容",
icon: 'none'
})
return
}
if (this.selectImages.length > 0) {
uni.showLoading({
title: "提交中",
mask: true
})
const oldImages = this.splitImages(this.formData.images)
this.$util.uploadFileMultiple(this.selectImages, oldImages).then(result => {
this.formData.images = result
this.submitEvent()
}).catch(error => {
uni.hideLoading()
console.error('上传图片 ', error)
})
} else {
uni.showLoading({
title: "提交中",
mask: true
})
this.submitEvent()
}
},
// 提交事件
submitEvent() {
var url = ""
if (this.demandId) url = "demand.businessEdit"
else url = "demand.businessAdd"
this.$util.request(url, this.formData).then(res => {
if (res.code == 1) {
uni.showToast({
title: "提交成功",
icon: "success",
duration: 1500,
mask: true
})
this.timeout = setTimeout(() => {
uni.navigateBack()
}, 1500)
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
console.error('提交审核', error)
})
},
}
}
</script>
<style lang="scss">
.container {
.container-main {
padding-bottom: 112rpx;
.main-form {
padding: 32rpx 48rpx;
.form-item {
margin-top: 32rpx;
&:first-child {
margin-top: 0;
}
.item-title {
color: #5A5B6E;
font-size: 32rpx;
font-weight: 600;
line-height: 44rpx;
.tips {
font-size: 24rpx;
font-weight: 400;
}
}
.item-input {
margin-top: 32rpx;
display: flex;
align-items: center;
border-radius: 16rpx;
background: #ffffff;
.input {
color: #5A5B6E;
font-size: 28rpx;
height: 112rpx;
line-height: 112rpx;
flex: 1;
padding: 0 32rpx;
}
.textarea {
color: #5A5B6E;
font-size: 28rpx;
line-height: 40rpx;
flex: 1;
padding: 36rpx 32rpx;
width: 100%;
height: 240rpx;
}
.placeholder {
color: #ACADB7;
}
.icon {
width: 32rpx;
height: 32rpx;
padding-right: 32rpx;
}
}
.item-upload {
display: flex;
flex-wrap: wrap;
margin-top: 32rpx;
column-gap: 3.5%;
row-gap: 24rpx;
.upload-image {
position: relative;
width: 31%;
height: 0;
padding-top: 31%;
.image-select {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 10rpx;
}
.image-video {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 10rpx;
background: var(--theme-color);
padding: 56rpx;
}
.image-delete {
position: absolute;
top: -16rpx;
right: -16rpx;
width: 48rpx;
height: 48rpx;
}
.image-choose {
position: absolute;
top: 20rpx;
left: 20rpx;
right: 20rpx;
bottom: 20rpx;
z-index: 6;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: #ffffff;
border-radius: 10rpx;
.icon {
width: 80rpx;
height: 80rpx;
padding: 18rpx;
background: var(--theme-color);
border-radius: 50%;
}
.text {
margin-top: 16rpx;
color: var(--theme-color);
font-size: 28rpx;
line-height: 40rpx;
}
}
.image-background {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1;
background: var(--theme-color);
opacity: 0.08;
}
}
}
}
}
.main-footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 99;
padding: 12rpx 32rpx;
background: #ffffff;
border-top: 1rpx solid #F6F7FB;
.footer-btn {
color: #ffffff;
font-size: 32rpx;
line-height: 44rpx;
padding: 22rpx 24rpx;
border-radius: 16rpx;
background: var(--theme-color);
text-align: center;
}
}
}
}
</style>

241
pagesDemand/demand/list.vue Normal file
View File

@@ -0,0 +1,241 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 我的发布 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<view class="container" :style="{'--theme-color': themeColor}">
<!-- 标题栏 -->
<title-bar :showBack="true" title="我的发布"></title-bar>
<!-- 内容区 -->
<view class="container-main" v-if="loadEnd">
<view class="main-header flex align-items-center" :style="{top: titleBarHeight + 'px'}">
<scroll-view scroll-x class="header-screen flex-item">
<view class="screen-item" :class="{active: selectScreen == item.id}" v-for="item in demandScreen" :key="item.id" @click="screenChange(item.id)">
{{ item.name }}
</view>
</scroll-view>
<view class="header-btn flex align-items-center" @click="toPublish()">
<view class="icon" :style="{'background-image': 'url('+ iconRelease +')'}" v-if="iconRelease"></view>
<view class="text">发布</view>
</view>
</view>
<view class="main-content">
<demand-item :show-data="demandList" :show-type="2" @onReset="resetDemandList()" v-if="demandList.length"></demand-item>
<empty top="30%" title="暂无相关内容~" v-else></empty>
</view>
</view>
<!-- 底部导航 -->
<tab-bar></tab-bar>
</view>
</template>
<script>
import { mapState } from "vuex"
import demandItem from "@/pages/component/demand/index.vue"
import svgData from "@/common/svg.js"
export default {
components: {
demandItem,
},
data() {
return {
// 加载完成
loadEnd: false,
// 标题栏高度
titleBarHeight: 0,
// 已选状态
selectScreen: 0,
// 分类查询参数
page: 1,
limit: 20,
hasMore: false,
// 供需筛选
demandScreen: [{
id: 0,
name: "全部",
},
{
id: 1,
name: "审核中",
},
{
id: 2,
name: "发布中",
},
{
id: 3,
name: "已驳回",
}
],
// 供需列表
demandList: []
};
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
iconRelease: state => {
return svgData.svgToUrl("release", state.app.themeColor)
},
})
},
mounted() {
// #ifdef MP-WEIXIN
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.titleBarHeight = statusBarHeight + (menuButtonInfo.top - statusBarHeight) * 2 + menuButtonInfo.height
// #endif
},
onLoad() {
uni.showLoading({
title: "加载中"
})
this.getDemandList(() => {
uni.hideLoading()
this.loadEnd = true
})
},
onShow() {
if (this.loadEnd) {
uni.pageScrollTo({
scrollTop: 0,
duration: 0
});
this.page = 1
this.getDemandList()
}
},
onPullDownRefresh() {
this.page = 1
this.getDemandList(() => {
uni.stopPullDownRefresh();
})
},
onReachBottom() {
if (this.hasMore) {
this.page++
this.getDemandList();
}
},
methods: {
// 获取列表
getDemandList(fn) {
this.$util.request("demand.businessList", {
state: this.selectScreen,
page: this.page,
limit: this.limit
}).then(res => {
if (fn) fn()
if (res.code == 1) {
let list = res.data.data || []
list.forEach((el) => {
el.images = this.splitImages(el.images)
});
this.hasMore = this.page < res.data.total / this.limit ? true : false
this.demandList = this.page == 1 ? list : [...this.demandList, ...list];
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (fn) fn()
console.error('获取供需列表', error)
})
},
// 字符串转数组格式图片
splitImages(images) {
try {
if (images) return images.split(',');
else return []
} catch (error) {
return [];
}
},
// 重新获取列表
resetDemandList() {
this.page = 1
this.getDemandList()
},
// 发布供需
toPublish() {
this.$util.toPage({
mode: 1,
path: "/pagesDemand/demand/edit"
})
},
// 顶部导航筛选
screenChange(id) {
if (this.selectScreen == id) {
return
}
this.selectScreen = id
this.page = 1
this.getDemandList()
},
}
}
</script>
<style lang="scss">
.container {
.container-main {
.main-header {
position: sticky;
top: 0;
z-index: 99;
padding: 24rpx 0;
background: #FFF;
.header-screen {
.screen-item {
display: inline-block;
min-width: 25%;
color: #5A5B6E;
font-size: 28rpx;
line-height: 40rpx;
text-align: center;
padding: 12rpx 16rpx;
&.active {
color: var(--theme-color);
font-weight: 600;
}
}
}
.header-btn {
padding: 12rpx 32rpx;
border-left: 1px solid #E4E4E4;
.icon {
width: 40rpx;
height: 40rpx;
background-size: 40rpx;
}
.text {
margin-left: 8rpx;
color: var(--theme-color);
font-size: 28rpx;
line-height: 40rpx;
}
}
}
.main-content {
padding: 32rpx;
}
}
}
</style>

View File

@@ -0,0 +1,380 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 供需详情-我的 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<view class="container" :style="{ '--theme-color': themeColor }">
<!-- 标题栏 -->
<title-bar :showBack="true" title="供需详情"></title-bar>
<!-- 内容区 -->
<view class="container-main" v-if="loadEnd">
<view class="main-tips" :style="{top: titleBarHeight + 'px'}" v-if="demandDetails.business.reject">
<view class="tips-text">驳回原因:{{ demandDetails.business.reject }}</view>
</view>
<view class="main-content">
<view class="content-item">
<view class="item-top flex align-items-center">
<image class="top-avatar" :src="demandDetails.member.avatar" mode="aspectFill"></image>
<view class="top-info flex-item">
<view class="title text-ellipsis">{{ demandDetails.member.name }}</view>
<view class="subtitle">
{{ demandDetails.member.level_name }} | {{ demandDetails.business.time }} | 浏览 {{ demandDetails.business.page_view }}
</view>
</view>
</view>
<view class="item-center" v-if="demandDetails.business">
<view class="center-title">{{ demandDetails.business.title }}</view>
<view class="center-content">
<text>{{ demandDetails.business.content }}</text>
</view>
<view class="center-image" :class="{'special-image': (demandDetails.business.images.length < 3 || demandDetails.business.images.length === 4)}" v-if="demandDetails.business.images.length">
<view class="image-box" v-for="(img, num) in demandDetails.business.images" :key="num" @click.stop="previewImage(num)">
<image class="image" :src="img" mode="aspectFill"></image>
</view>
</view>
</view>
<view class="item-bottom" v-if="demandDetails.business.address">
<view class="bottom-label inline-flex align-items-center">
<view class="label-icon" :style="{'background-image': 'url('+ iconAddress +')'}" v-if="iconAddress"></view>
<text class="label-text flex-item">{{demandDetails.business.address}}</text>
<view class="label-bg"></view>
</view>
</view>
</view>
</view>
<view class="main-footer">
<view class="flex">
<view class="footer-btn" style="background: #FFB656;" @click="handleEdit()">修改</view>
<view class="footer-btn" style="background: #FF2525;" @click="handleDelete()">删除</view>
</view>
<view class="safe-padding"></view>
</view>
</view>
</view>
</template>
<script>
import { mapState } from "vuex"
import svgData from "@/common/svg.js"
export default {
data() {
return {
// 加载完成
loadEnd: false,
// 标题栏高度
titleBarHeight: 0,
// 供需id
demandId: 0,
// 详情数据
demandDetails: {},
// 延时器
timeout: null,
};
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
iconAddress: state => {
return svgData.svgToUrl("address", state.app.themeColor)
},
}),
},
mounted() {
// #ifdef MP-WEIXIN
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.titleBarHeight = statusBarHeight + (menuButtonInfo.top - statusBarHeight) * 2 + menuButtonInfo.height
// #endif
},
onLoad(option) {
this.demandId = option.id
uni.showLoading({
title: "加载中"
})
this.getDemandDetails(() => {
uni.hideLoading()
this.loadEnd = true
})
},
onShow() {
if (this.loadEnd) this.getDemandDetails()
},
onUnload() {
clearTimeout(this.timeout)
},
methods: {
// 获取详情
getDemandDetails(fn) {
this.$util.request("demand.businessUserDetails", {
id: this.demandId
}).then(res => {
if (fn) fn()
if (res.code == 1) {
this.demandDetails = res.data
this.demandDetails.business.images = this.splitImages(res.data.business.images)
this.demandDetails.business.time = this.$util.getDateBeforeNow(this.demandDetails.business.createtime)
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (fn) fn()
console.error('获取详情 ', error)
})
},
// 字符串转数组格式图片
splitImages(images) {
try {
if (images) return images.split(',');
else return []
} catch (error) {
return [];
}
},
// 修改供需
handleEdit() {
this.$util.toPage({
mode: 1,
path: "/pagesDemand/demand/edit?id=" + this.demandId
})
},
// 删除供需
handleDelete() {
uni.showModal({
title: '提示',
content: '确认删除此条吗?',
confirmText: '确认删除',
confirmColor: '#E50002',
cancelText: '我再想想',
cancelColor: '#999999',
success: (res) => {
if (res.confirm) {
uni.showLoading({
title: "加载中",
mask: true
})
this.$util.request("demand.businessDel", {
id: this.demandId,
}).then(res => {
uni.hideLoading()
if (res.code == 1) {
uni.showToast({
title: "删除成功",
icon: "success",
mask: true,
duration: 1500
})
this.timeout = setTimeout(() => {
uni.navigateBack()
}, 1500)
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
uni.hideLoading()
console.error('删除供需', error)
})
}
}
})
},
// 预览图片
previewImage(index) {
uni.previewImage({
urls: this.demandDetails.business.images,
current: index,
});
},
}
}
</script>
<style lang="scss">
.container {
.container-main {
padding-bottom: 112rpx;
.main-tips {
position: sticky;
top: 0;
z-index: 99;
background: #FFF1F2;
padding: 24rpx 32rpx;
.tips-text {
color: #FF626E;
font-size: 24rpx;
line-height: 34rpx;
}
}
.main-content {
padding: 32rpx;
.content-item {
padding: 32rpx 32rpx 24rpx;
border-radius: 16rpx;
background: #FFF;
.item-top {
padding-bottom: 32rpx;
border-bottom: 1px solid #E4E4E4;
.top-avatar {
width: 96rpx;
height: 96rpx;
border-radius: 50%;
}
.top-info {
margin-left: 24rpx;
.title {
color: #5A5B6E;
font-size: 32rpx;
font-weight: 600;
line-height: 44rpx;
}
.subtitle {
margin-top: 16rpx;
color: #666;
font-size: 24rpx;
line-height: 34rpx;
}
}
}
.item-center {
margin-top: 32rpx;
.center-title {
color: #5A5B6E;
font-size: 32rpx;
font-weight: 600;
line-height: 44rpx;
}
.center-content {
margin-top: 24rpx;
color: #5A5B6E;
font-size: 28rpx;
line-height: 40rpx;
}
.center-image {
display: flex;
flex-wrap: wrap;
margin-top: 16rpx;
column-gap: 2%;
row-gap: 14rpx;
.image-box {
width: 32%;
height: 0;
padding-top: 32%;
position: relative;
border-radius: 16rpx;
overflow: hidden;
.image {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
}
&.special-image {
justify-content: space-between;
column-gap: 0;
.image-box {
width: calc(50% - 8rpx);
padding-top: calc(50% - 8rpx);
}
}
}
}
.item-bottom {
margin-top: 24rpx;
.bottom-label {
padding: 6rpx 18rpx 6rpx 8rpx;
position: relative;
z-index: 1;
border-radius: 8rpx;
overflow: hidden;
.label-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--theme-color);
z-index: -1;
opacity: 0.1;
}
.label-icon {
width: 24rpx;
height: 24rpx;
background-size: 24rpx;
}
.label-text {
margin-left: 8rpx;
color: var(--theme-color);
font-size: 20rpx;
line-height: 28rpx;
}
}
}
}
}
.main-footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 99;
padding: 12rpx 24rpx;
background: #ffffff;
border-top: 1rpx solid #F6F7FB;
.footer-btn {
color: #ffffff;
font-size: 32rpx;
line-height: 44rpx;
padding: 22rpx 24rpx;
border-radius: 16rpx;
background: var(--theme-color);
text-align: center;
width: 100%;
margin-left: 24rpx;
&:first-child {
margin-left: 0;
}
}
}
}
}
</style>