联系人

This commit is contained in:
itgaojian163 2025-04-07 11:04:08 +08:00
parent cfed11108d
commit 2dc51c6b1e
12 changed files with 690 additions and 21 deletions

View File

@ -13,7 +13,8 @@
"pages/copyright/common/payState",
"pages/readTxt/readTxt",
"pages/mine/mineAccount/mineInfo/mineInfo",
"pages/mine/mineAccount/mineOrder/mineOrder"
"pages/mine/mineAccount/mineOrder/mineOrder",
"pages/mine/mineAccount/mineContact/mineContact"
],
"window": {
"navigationBarTextStyle": "black",

View File

@ -13,6 +13,9 @@ const apiPath = {
uploadImg: '/api/file/v2/upload-image', //上传图片
userInfo: '/api/user-info/get-self', //获取我的个人信息
mineOrder: '/api/order/listpage/self', //我的订单
mineContact: '/api/proj-contact/listpage/self', //联系人列表
updateContact: '/api/proj-contact/update/{projContactId}', //更新联系人
delContact: '/api/proj-contact/remove/{ids}', //删除联系人
}
class UserService {
static doLogin(data) {
@ -50,6 +53,20 @@ class UserService {
static doGetMineOrder(data) {
return request(apiPath.mineOrder, "GET", data)
}
//获取项目联系人列表
static doGetMineContactList(data) {
return request(apiPath.mineContact, "GET", data)
}
//更新联系人
static doUpdateContactList(id, data) {
const path = apiPath.updateContact.replace('{projContactId}', id)
return request(path, "PUT", data)
}
//删除联系人
static doDelContact(id) {
const path = apiPath.delContact.replace('{ids}', id)
return request(path, "DELETE")
}
}
export default UserService;

View File

@ -45,7 +45,8 @@ Page({
langList: [], //项目语言
showLang: false, //显示选择语言
tempLang: '', //临时选中的语言
selectLang: ''
selectLang: '',
contactCompany: '', //联系人公司
},
onLoad(options) {
wx.setNavigationBarTitle({
@ -121,6 +122,11 @@ Page({
contactPhone: e.detail.value
})
},
inputContactCompany(e) {
this.setData({
contactCompany: e.detail.value
})
},
inputContactEmail(e) {
this.setData({
contactEmail: e.detail.value
@ -424,7 +430,7 @@ Page({
title: '创建中...',
})
const data = {
"company": "",
"company": _self.data.contactCompany,
"csaNo": _self.data.csaNo,
"name": _self.data.contactName,
"phone": _self.data.contactPhone
@ -438,7 +444,8 @@ Page({
isShowContact: false,
contactEmail: '',
contactPhone: '',
contactName: ''
contactName: '',
contactCompany:'',
})
//获取一遍联系人
_self.doGetContactList()

View File

@ -82,7 +82,7 @@
<view class="form-box">
<view class="form-item">
<view class="form-item-title">姓名</view>
<input vlaue="{{contactName}}" placeholder="请输入联系人姓名" class="form-item-content" bindinput="inputContactName" />
<input value="{{contactName}}" placeholder="请输入联系人姓名" class="form-item-content" bindinput="inputContactName" />
</view>
<view class="form-item">
<view class="form-item-title">联系电话</view>
@ -92,6 +92,10 @@
<view class="form-item-title no-after">联系邮箱</view>
<input value="{{contactEmail}}" placeholder="请输入邮箱" class="form-item-content" bindinput="inputContactEmail" />
</view>
<view class="form-item">
<view class="form-item-title no-after">公司</view>
<input value="{{contactCompany}}" placeholder="请输入公司名称" class="form-item-content" bindinput="inputContactCompany" />
</view>
</view>
</view>
<view slot="footer">

View File

@ -0,0 +1,360 @@
// pages/mine/mineAccount/mineOrder/mineOrder.js
import UserApi from '../../../../net/api/userApi'
const {
isValidPhone,
isValidEmail
} = require('../../../../utils/validator')
Page({
/**
* 页面的初始数据
*/
data: {
contactList: [], //联系人列表
pageData: {
page: 1,
rows: 10,
keywords: ''
}, //检索参数
loadingState: 'loading', //加载状态
listRefreshTrig: false, //list刷新状态
isLoadMore: false, //加载更多的状态
hasMore: true, //是否有更多数据
keywords: '', //搜索关键字
showCreateContact: false, //创建联系人
contactCompany: '', //公司名称
contactEmail: '', //联系邮箱
contactName: '', //名字
contactPhone: '', //联系电话
showError: false,
errorHint: '',
showSuccess: false,
successHint: '',
csaNo: '', //客服号
title: '创建联系人',
btnTxt: '保存',
isCreate: true, //创建还是编辑
tempContact: null, //修改的联系人
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
wx.setNavigationBarTitle({
title: '产权联系人',
})
wx.setNavigationBarColor({
frontColor: '#000000', // 必写项,字体颜色仅支持#ffffff和#000000
backgroundColor: '#F0F0F0', // 传递的颜色值,仅支持十六进制颜色
animation: { // 可选项
duration: 500,
timingFunc: 'easeIn'
}
})
this.doGetCsaNo()
this.doGetMineContactList()
},
inputKeywords(e) {
this.setData({
keywords: e.detail.value
})
},
inputContactName(e) {
console.log(e)
this.setData({
contactName: e.detail.value
})
},
inputContactPhone(e) {
this.setData({
contactPhone: e.detail.value
})
},
inputContactEmail(e) {
this.setData({
contactEmail: e.detail.value
})
},
inputContactCompany(e) {
this.setData({
contactCompany: e.detail.value
})
},
//显示创建联系人弹窗
showCreateDialog() {
this.setData({
title: '创建',
showCreateContact: true,
contactName: '',
contactCompany: '',
contactEmail: '',
contactPhone: '',
isCreate: true
})
},
//显示编辑弹窗
showEditDialog(e) {
const _self = this
const item = e.currentTarget.dataset.value
_self.setData({
title: '编辑',
showCreateContact: true,
contactName: item.name,
contactPhone: item.phone,
contactEmail: item.email,
contactCompany: item.company,
isCreate: false,
tempContact: item
})
},
//获取客服NO
doGetCsaNo(isShow) {
const _self = this
UserApi.doGetCsaNo()
.then(res => {
console.log(res)
_self.setData({
csaNo: res.csaNo
})
if (isShow) {
_self.setData({
isShowContact: true
})
}
}, err => {
console.log(err)
})
},
showDelDialog(e) {
const _self = this
const item = e.currentTarget.dataset.value
wx.showModal({
title: '警告',
content: '一旦删除,该联系人信息将无法恢复,你仍要删除吗?',
complete: (res) => {
if (res.cancel) {
}
if (res.confirm) {
_self.doDelContact(item.projContactId)
}
}
})
},
//删除联系人
doDelContact(id) {
const _self = this
wx.showLoading({
title: '删除中...',
})
UserApi.doDelContact(id)
.then(res => {
wx.hideLoading()
_self.setData({
showSuccess: true,
successHint: '删除成功'
})
_self.doRefreshList()
}, err => {
wx.hideLoading()
_self.setData({
showError: true,
errorHint: err.msg ? err.msg : '删除失败,请稍后重试'
})
})
},
//保存修改联系人
doEditContact() {
//校验参数
const _self = this
if (_self.data.contactName == '') {
_self.setData({
showError: true,
errorHint: '请输入联系人姓名'
})
return
}
if (_self.data.contactPhone == '' || !isValidPhone(_self.data.contactPhone)) {
_self.setData({
showError: true,
errorHint: '请输入合法的联系电话'
})
return
}
if (_self.data.contactEmail != '') {
if (!isValidEmail(_self.data.contactEmail)) {
_self.setData({
showError: true,
errorHint: '请输入合法的邮箱'
})
return
}
}
wx.showLoading({
title: '保存中...',
})
const data = {
"company": _self.data.contactCompany,
"csaNo": _self.data.tempContact.csaNo,
"name": _self.data.contactName,
"phone": _self.data.contactPhone,
"email": _self.data.contactEmail,
}
UserApi.doUpdateContactList(_self.data.tempContact.projContactId, data)
.then(res => {
wx.hideLoading()
_self.setData({
showSuccess: true,
successHint: '修改成功',
showCreateContact: false,
contactEmail: '',
contactPhone: '',
contactName: '',
contactCompany: '',
tempContact: null,
})
//获取一遍联系人
_self.doRefreshList()
}, err => {
wx.hideLoading()
_self.setData({
showError: true,
errorHint: err.msg ? err.msg : '新建失败,请稍后重试',
showCreateContact: false
})
})
},
//创建联系人
doSaveContact() {
//校验参数
const _self = this
if (_self.data.contactName == '') {
_self.setData({
showError: true,
errorHint: '请输入联系人姓名'
})
return
}
if (_self.data.contactPhone == '' || !isValidPhone(_self.data.contactPhone)) {
_self.setData({
showError: true,
errorHint: '请输入合法的联系电话'
})
return
}
if (_self.data.contactEmail != '') {
if (!isValidEmail(_self.data.contactEmail)) {
_self.setData({
showError: true,
errorHint: '请输入合法的邮箱'
})
return
}
}
wx.showLoading({
title: '创建中...',
})
const data = {
"company": _self.data.contactCompany,
"csaNo": _self.data.csaNo,
"name": _self.data.contactName,
"phone": _self.data.contactPhone,
"email": _self.data.contactEmail,
}
UserApi.doCreateContact(data)
.then(res => {
wx.hideLoading()
_self.setData({
showSuccess: true,
successHint: '新建成功',
showCreateContact: false,
contactEmail: '',
contactPhone: '',
contactName: '',
contactCompany: '',
})
//获取一遍联系人
_self.doRefreshList()
}, err => {
wx.hideLoading()
_self.setData({
showError: true,
errorHint: err.msg ? err.msg : '新建失败,请稍后重试',
showCreateContact: false
})
})
},
//刷新列表
doRefreshList() {
console.log('正在刷新...')
const _self = this
_self.setData({
listRefreshTrig: true,
loadingState: 'loading',
hasMore: true,
'pageData.page': 1,
'pageData.keywords': _self.data.keywords,
isLoadMore: false
})
_self.doGetMineContactList(true)
},
//加载更多
doLoadMore() {
//判断是否正在加载中 与是否存在更多数据
const _self = this
if (_self.data.isLoadMore || !_self.data.hasMore) {
return
}
_self.setData({
isLoadMore: true,
'pageData.page': ++_self.data.pageData.page,
keywords: _self.data.keywords
})
_self.doGetMineContactList(false)
},
//获取我的联系人列表 isRefresh false 加载更多 true 刷新
doGetMineContactList(isRefresh) {
const _self = this
_self.setData({
contactList: isRefresh ? [] : _self.data.contactList,
loadingState: isRefresh ? 'loading' : ''
})
UserApi.doGetMineContactList(_self.data.pageData)
.then(res => {
console.log(res)
var status = 'success'
status = res.rows && res.rows.length > 0 ? 'success' : 'empty'
_self.setData({
loadingState: isRefresh ? status : '',
contactList: _self.data.contactList.concat(res.rows),
listRefreshTrig: false,
isLoadMore: false
})
_self.setData({
hasMore: _self.data.contactList.length < res.total
})
}, err => {
_self.setData({
loadingState: 'error',
listRefreshTrig: false,
isLoadMore: false,
hasMore: true
})
})
},
//清除搜索内容
clearSearch() {
const _self = this
_self.setData({
keywords: ''
})
_self.doRefreshList()
},
//发起搜索
doSearchKeyWord() {
const _self = this
_self.doRefreshList()
}
})

View File

@ -0,0 +1,8 @@
{
"usingComponents": {
"mp-half-screen-dialog": "weui-miniprogram/half-screen-dialog/half-screen-dialog",
"mp-loading": "weui-miniprogram/loading/loading",
"container-loading": "/components/container-loading/container-loading",
"mp-toptips": "weui-miniprogram/toptips/toptips"
}
}

View File

@ -0,0 +1,67 @@
<view class="page-container">
<view class="search-box">
<view class="search-container">
<input class="search-input" value="{{keywords}}" bindinput="inputKeywords" bindconfirm="doSearchKeyWord" type="text" confirm-type="search" placeholder="搜索" />
<view wx:if="{{keywords !=''}}" bind:tap="clearSearch" class="icon-clear" style="width: 20px;height: 20px;"></view>
</view>
<view class="add-btn" bind:tap="showCreateDialog">创建联系人</view>
</view>
<view class="content-container">
<container-loading loadingState="{{loadingState}}" style="height: 85vh;" bindrefresh="doRefreshList">
<scroll-view scroll-y="{{true}}" style="height: 85vh;" bindrefresherrefresh="doRefreshList" refresher-enabled refresher-triggered="{{listRefreshTrig}}" bindscrolltolower="doLoadMore" lower-threshold='30'>
<view class="order-box">
<block wx:for="{{contactList}}" wx:key="index">
<view class="order-item">
<view class="contact-desc">
<view class="contact-icon">
<view class="ic-user" style="width: 24px;height: 24px;"></view>
<view class="ml-10">{{item.name}}</view>
</view>
<view>{{item.phone}}</view>
<view class="options-box">
<view class="edit" bind:tap="showEditDialog" data-value="{{item}}">编辑</view>
<view class="del" bind:tap="showDelDialog" data-value="{{item}}">删除</view>
</view>
</view>
<view class="service-desc ml-10">{{item.company}}</view>
<view class="service-desc ml-10">专属客服 : {{item.csaNo}}</view>
</view>
</block>
<mp-loading show="{{isLoadMore}}" type="circle"></mp-loading>
</view>
</scroll-view>
</container-loading>
</view>
</view>
<!-- 新增 -->
<mp-half-screen-dialog show="{{showCreateContact}}">
<view slot="title">{{title}}</view>
<view slot="desc">
<view class="form-box">
<view class="form-item">
<view class="form-item-title">姓名</view>
<input value="{{contactName}}" placeholder="请输入联系人姓名" class="form-item-content" bindinput="inputContactName" />
</view>
<view class="form-item">
<view class="form-item-title">联系电话</view>
<input value="{{contactPhone}}" placeholder="请输入联系电话" class="form-item-content" bindinput="inputContactPhone" />
</view>
<view class="form-item">
<view class="form-item-title no-after">联系邮箱</view>
<input value="{{contactEmail}}" placeholder="请输入邮箱" class="form-item-content" bindinput="inputContactEmail" />
</view>
<view class="form-item">
<view class="form-item-title no-after">公司</view>
<input value="{{contactCompany}}" placeholder="请输入公司名称" class="form-item-content" bindinput="inputContactCompany" />
</view>
</view>
</view>
<view slot="footer">
<button wx:if="{{isCreate}}" type="primary" bind:tap="doSaveContact">{{btnTxt}}</button>
<button wx:if="{{!isCreate}}" type="primary" bind:tap="doEditContact">{{btnTxt}}</button>
</view>
</mp-half-screen-dialog>
<mp-toptips msg="{{errorHint}}" type="error" show="{{showError}}"></mp-toptips>
<mp-toptips msg="{{successHint}}" delay="2000" type="success" show="{{showSuccess}}"></mp-toptips>

View File

@ -0,0 +1,199 @@
page {
background: linear-gradient(to bottom, #F0F0F0, #FFFFFF);
}
.ic-user {
background-image: url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB0PSIxNzQzOTg4MzkwNjkwIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjM0MDkiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTUxMiAxMDI0QzIyOS4yMDUzMzMgMTAyNCAwIDc5NC43OTQ2NjcgMCA1MTJTMjI5LjIwNTMzMyAwIDUxMiAwczUxMiAyMjkuMjA1MzMzIDUxMiA1MTItMjI5LjIwNTMzMyA1MTItNTEyIDUxMnogbTAtNDk2LjQ2OTMzM2ExNzAuNjY2NjY3IDE3MC42NjY2NjcgMCAxIDAgMC0zNDEuMzMzMzM0IDE3MC42NjY2NjcgMTcwLjY2NjY2NyAwIDAgMCAwIDM0MS4zMzMzMzR6IG0yNjMuNzY1MzMzIDI2My43MjI2NjZhMjYzLjc2NTMzMyAyNjMuNzY1MzMzIDAgMSAwLTUyNy41MzA2NjYgMGg1MjcuNTMwNjY2eiIgcC1pZD0iMzQxMCIgZmlsbD0iIzEyOTZkYiI+PC9wYXRoPjwvc3ZnPg==');
background-size: cover;
background-repeat: no-repeat;
}
.search-box {
position: fixed;
top: 0;
left: 0;
width: 97vw;
display: flex;
flex-direction: row;
align-items: center;
}
.search-container {
position: relative;
align-self: center;
border-radius: 5px;
background-color: rgba(255, 255, 255, 1);
font-family: -regular;
margin: 10px;
padding: 5px;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
flex: 1;
}
.search-input {
box-sizing: border-box;
color: rgba(16, 16, 16, 1);
font-size: 14px;
text-align: center;
flex: 1;
}
.search-input::after {
content: '';
position: absolute;
left: 10px;
top: 50%;
transform: translateY(-50%);
width: 20px;
height: 20px;
margin-top: -1px;
background-size: cover;
background-image: url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSI2NCA2NCA4OTYgODk2IiB3aWR0aD0iMTQiIGhlaWdodD0iMTkiIHN0eWxlPSIiIGZpbHRlcj0ibm9uZSI+CiAgICAKICAgIDxnPgogICAgPHBhdGggZD0iTTkwOS42IDg1NC41TDY0OS45IDU5NC44QzY5MC4yIDU0Mi43IDcxMiA0NzkgNzEyIDQxMmMwLTgwLjItMzEuMy0xNTUuNC04Ny45LTIxMi4xLTU2LjYtNTYuNy0xMzItODcuOS0yMTIuMS04Ny45cy0xNTUuNSAzMS4zLTIxMi4xIDg3LjlDMTQzLjIgMjU2LjUgMTEyIDMzMS44IDExMiA0MTJjMCA4MC4xIDMxLjMgMTU1LjUgODcuOSAyMTIuMUMyNTYuNSA2ODAuOCAzMzEuOCA3MTIgNDEyIDcxMmM2NyAwIDEzMC42LTIxLjggMTgyLjctNjJsMjU5LjcgMjU5LjZhOC4yIDguMiAwIDAgMCAxMS42IDBsNDMuNi00My41YTguMiA4LjIgMCAwIDAgMC0xMS42ek01NzAuNCA1NzAuNEM1MjggNjEyLjcgNDcxLjggNjM2IDQxMiA2MzZzLTExNi0yMy4zLTE1OC40LTY1LjZDMjExLjMgNTI4IDE4OCA0NzEuOCAxODggNDEyczIzLjMtMTE2LjEgNjUuNi0xNTguNEMyOTYgMjExLjMgMzUyLjIgMTg4IDQxMiAxODhzMTE2LjEgMjMuMiAxNTguNCA2NS42UzYzNiAzNTIuMiA2MzYgNDEycy0yMy4zIDExNi4xLTY1LjYgMTU4LjR6IiBmaWxsPSJyZ2JhKDIwNCwyMDQsMjA0LDEpIj48L3BhdGg+CiAgICA8L2c+CiAgPC9zdmc+');
}
.add-btn {
border-radius: 4px;
background-color: rgba(50, 112, 255, 1);
color: rgba(255, 255, 255, 1);
font-size: 14px;
text-align: center;
text-align: center;
font-family: PingFangSC-regular;
padding: 5px 10px;
}
.add-btn:active {
background-color: rgba(50, 112, 255, .7);
}
.content-container {
height: 86vh;
margin-top: 50px;
}
.order-box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.order-item {
display: flex;
flex-direction: column;
background-color: white;
border-radius: 10px;
width: 94vw;
}
.order-item:nth-of-type(n+2) {
margin-top: 15px;
}
.contact-desc {
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 15px;
align-items: center;
}
.contact-icon {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.service-desc {
padding: 0px 15px 15px 15px;
line-height: 20px;
color: rgba(0, 0, 0, 1);
font-size: 14px;
text-align: left;
font-family: SourceHanSansSC-regular;
}
.edit {
line-height: 20px;
border-radius: 4px;
background-color: rgba(122, 196, 131, 0.42);
color: rgba(255, 255, 255, 1);
font-size: 14px;
text-align: center;
font-family: PingFangSC-regular;
padding: 5px 15px;
}
.del {
line-height: 20px;
border-radius: 4px;
background-color: rgba(247, 49, 42, 0.42);
color: rgba(255, 255, 255, 1);
font-size: 14px;
text-align: center;
font-family: PingFangSC-regular;
padding: 5px 15px;
margin-left: 5px;
}
.del:active {
background-color: rgba(247, 49, 42, 0.7);
}
.options-box {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.edit:active {
background-color: rgba(122, 196, 131, 0.6);
}
.form-box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
font-size: 14px;
width: 100vw;
}
.form-item {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
width: 80vw;
padding: 10px;
}
.form-item-title {
flex: .3;
font-size: 14px;
color: black;
font-weight: 500;
text-align: left;
}
.form-item-title:not(.no-after)::after {
content: "*";
color: red;
font-size: 14px;
margin-left: 1px;
text-align: center;
}
.form-item-content {
flex: 1;
}

View File

@ -38,8 +38,13 @@ Page({
}, {
"icon": "ic-contact",
"title": "产权联系人",
"path": "/pages/mine/mineAccount/mineInfo/mineInfo"
}]
"path": "/pages/mine/mineAccount/mineContact/mineContact"
}],
buttons: [{
text: '知道了'
}],
hintTxt: '',
showHint: false
},
/**
@ -102,23 +107,20 @@ Page({
itemClick(e) {
const path = e.currentTarget.dataset.path
if (path == '') {
wx.showModal({
title: '提示',
content: `鉴于功能特性,需在电脑端完成操作。请打开浏览器,输入网址${copyrightUrl},进行后续操作。`,
complete: (res) => {
if (res.cancel) {
}
if (res.confirm) {
}
}
this.setData({
showHint: true,
hintTxt: `鉴于功能特性,需在电脑端完成操作。请打开浏览器,登录网址${copyrightUrl},进行后续操作。`
})
} else {
wx.navigateTo({
url: path,
})
}
},
closeHint(e) {
this.setData({
showHint: false,
hintTxt: ''
})
}
})

View File

@ -1,4 +1,4 @@
{
"usingComponents": {},
"usingComponents": {"mp-dialog": "weui-miniprogram/dialog/dialog"},
"navigationStyle": "custom"
}

View File

@ -49,4 +49,7 @@
</view>
</view>
</view>
</view>
</view>
<mp-dialog title="提示" show="{{showHint}}" buttons="{{buttons}}" bindbuttontap="closeHint">
<view style="color: black;">{{hintTxt}}</view>
</mp-dialog>

View File

@ -40,6 +40,7 @@ var orderStatus = function (value) {
statusStr = '补正2次退款'
break
}
return statusStr
};
var proType = function (value) {
// PROJ:项目、AGENT:代理、FULL_REFUND:全额退款、CORRECTION1_REFUND:补正1次退款、CORRECTION2_REFUND:补正2次退款