bonus-Certificate-app/pages/mine/proxyManage/index.vue

253 lines
6.9 KiB
Vue

<template>
<page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
<Navbar2 title="代办人管理"/>
<scroll-view style="width: 100%;height: 88vh;background: #FFF;margin-top: 20rpx;" @scrolltolower="onScrollTolower" scroll-y="true">
<view v-for="(item, index) in proxyList" :key="index" class="proxy-item">
<view class="proxy-info">
<view class="proxy-name-view">
<view class="proxy-name">{{item.name}}</view>
</view>
<view class="number-info">
{{ item.idNumber }}
</view>
</view>
<view class="proxy-box">
<view class="btn-text" style="color: #1F72EA;" @click="editProxy(item)">编辑</view>
<view class="btn-text" style="color: #E60044;" @click="delThrid(item)">删除</view>
</view>
</view>
<view style="margin: 20px 0" v-if="proxyList.length > 0">
<u-loadmore :status="status" nomoreText="没有更多数据了" />
</view>
<view v-else class="flex justify-center align-center" style="height: 50vh">
<u-empty icon="../../static/images/not_order.png" text="暂无数据" textColor="#000" />
</view>
</scroll-view>
<view style="width: 100%;height: 6vh;background: #fff;display: flex;align-items: center;justify-content: center;">
<view @click="addProxy" style="width: 90%;height: 62rpx;background: #1F72EA;color: #FFF;border-radius: 10rpx;line-height: 62rpx;text-align: center;">
新增
</view>
</view>
<u-popup :show="showPopup" :round="10" @close="close" @open="open">
<view style="width: 100%;height: 45vh;position: relative;">
<view style="width: 100%;height: 80rpx;font-weight: 600;text-align: center;line-height: 80rpx;">新增</view>
<view style="width: 100%;height: 80px;padding: 40rpx;background: #FFF;border-bottom: 1px solid rgba(209,211,215,0.5);font-size: 28rpx;">
<view style="margin-bottom: 10px;">姓名<span style="color: red;">*</span></view>
<view><uni-easyinput type="text" :inputBorder="false" v-model="popupForm.name" maxlength="30" placeholder="请输入" /></view>
</view>
<view style="width: 100%;height: 80px;padding: 40rpx;background: #FFF;border-bottom: 1px solid rgba(209,211,215,0.5);font-size: 28rpx;">
<view style="margin-bottom: 10px;">身份证号<span style="color: red;">*</span></view>
<view><uni-easyinput type="text" :inputBorder="false" v-model="popupForm.idNumber" maxlength="30" placeholder="请输入" /></view>
</view>
<!-- <view style="width: 100%;height: 80px;padding: 40rpx;background: #FFF;border-bottom: 1px solid rgba(209,211,215,0.5);font-size: 28rpx;">
<view style="margin-bottom: 10px;">设为默认<span style="color: red;">*</span> </view>
<view><uni-data-checkbox v-model="popupForm.ifDefault" :localdata="checkBoxLocalData" /></view>
</view> -->
<view style="width: 100%;height: 6vh;background: #fff;display: flex;align-items: center;justify-content: center;position: absolute;bottom: 0;">
<view @click="confirmAdd" style="width: 90%;height: 62rpx;background: #1F72EA;color: #FFF;border-radius: 10rpx;line-height: 62rpx;text-align: center;">
确认
</view>
</view>
</view>
</u-popup>
</template>
<script>
import { thridTableListListApi,addThridApi,updateThridApi,delThridApi } from "@/api/proxyManage/index.js"
export default {
data() {
return {
fontValue:uni.getStorageSync('fontSize') || 8,
pageNum: 1,
pageSize: 10,
total: 0,
proxyList: [
// {
// name: '张三',
// phone: '349989854906459860948569045',
// ifDefault:"1"
// },
// {
// name: '冯先生',
// phone: '349989854906459860948569045'
// },
// {
// name: '冯先生',
// phone: '349989854906459860948569045'
// }
],
status: 'loadmore',
checkBoxLocalData:[{text: '是',value: 1}, {text: '否',value: 2}],
showPopup:false,
popupForm:{},
isSumbit:false,
}
},
onLoad() {
},
onShow(){
this.getList()
},
methods: {
// 翻页
onScrollTolower(){
console.log(this.proxyList.length)
if(this.total>this.proxyList.length){
this.pageNum++
this.getList()
}
},
//获取列表
async getList() {
console.log('获取列表')
const params = {
pageNum: this.pageNum,
pageSize: this.pageSize
}
try {
const res = await thridTableListListApi(params)
console.log('?? ~ getList ~ res:', res)
this.total = res.total;
res.rows.forEach(item=>{
item.checked=[];
})
if(this.pageNum==1){
this.proxyList = res.rows
}else{
this.proxyList.push(...res.rows)
}
this.status = this.total == this.proxyList.length ? 'nomore' : 'loadmore'
} catch (error) {
console.log(error)
}
},
addProxy() {
this.popupForm={}
this.showPopup = true;
},
editProxy(item){
this.popupForm=item
this.showPopup = true;
},
open(){},
close() {
this.showPopup = false;
},
confirmAdd() {
const regex = /(^\d{15}$)|(^\d{17}([0-9]|X)$)/;
console.log(this.popupForm)
if(this.popupForm.name==""){
uni.$u.toast(`姓名不能为空`)
}else if(this.popupForm.idNumber==""){
uni.$u.toast(`身份证号不能为空`)
}else if(!regex.test(this.popupForm.idNumber)){
uni.$u.toast(`请输入正确身份证号`)
}else{
if(!this.isSumbit){
const Id=this.popupForm.id;
if(Id!=undefined&&Id!=""){
this.updateThrid();
}else{
this.addThrid();
}
}
}
},
async updateThrid(){
this.isSumbit=true
let param = this.popupForm;
const res = await updateThridApi(param);
if(res.code==200){
uni.$u.toast(`操作成功!`)
setTimeout(()=>{
this.showPopup=false
this.isSumbit=false;
this.getList()
},500)
}else{
this.isSumbit=false
uni.$u.toast(`操作失败!`)
}
},
async addThrid(){
this.isSumbit=true
let param = {
"name": this.popupForm.name,
"idNumber": this.popupForm.idNumber,
}
const res = await addThridApi(param);
if(res.code==200){
uni.$u.toast(`新增成功!`)
setTimeout(()=>{
this.showPopup=false
this.isSumbit=false;
this.getList()
},500)
}else{
this.isSumbit=false
uni.$u.toast(res.msg)
}
},
async delThrid(item){
let param = {
"id":item.id
}
const res = await delThridApi(param);
if(res.code==200){
uni.$u.toast(`删除成功!`)
setTimeout(()=>{
this.getList()
},500)
}else{
uni.$u.toast(res.msg)
}
}
}
}
</script>
<style lang="scss" scoped>
.proxy-item {
width: 100%;
padding: 40rpx;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid rgba(209,211,215,0.5);
}
.proxy-info {
width: 70%;
height: auto;
.proxy-name-view{
width: 100%;
display: flex;
align-items: center;
margin-bottom: 30rpx;
}
.proxy-name{
color: #2A2B2F;
font-size: 32rpx;
font-weight: 600;
}
.number-info{
color: #979B9F;
font-size: 28rpx;
}
}
.proxy-box{
width: 20%;
display: flex;
}
.btn-text{
width: 40%;
font-size: 28rpx;
margin-right: 20rpx;
}
</style>