266 lines
12 KiB
Vue
266 lines
12 KiB
Vue
<template>
|
|
<view class="waper">
|
|
<u-navbar :autoBack="true" bgColor="#fff">
|
|
<view slot='center' class="navbar_title">游客信息</view>
|
|
</u-navbar>
|
|
<mescroll-body @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption" :top="paddingTop + 'px'">
|
|
<view class="list_waper">
|
|
<view class="list" v-for="(i, index) in list" :key="index">
|
|
<cowain-slide-action :slide-width="132">
|
|
<template v-slot:card>
|
|
<view class="list_card">
|
|
<view class="text">
|
|
<view>姓名</view>
|
|
<view>{{i.name}}
|
|
<text v-if="i.status == '1'">默认</text>
|
|
</view>
|
|
</view>
|
|
<view class="text">
|
|
<view>手机号</view>
|
|
<view>{{i.mobile}}</view>
|
|
</view>
|
|
<view class="text">
|
|
<view>身份证</view>
|
|
<view>{{i.idCard}}</view>
|
|
</view>
|
|
<view class="edit" @click="editTourist(i)">
|
|
<u-icon name="edit-pen" color="#333" size="46rpx"></u-icon>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<template v-slot:delete>
|
|
<view class="delete-wrap">
|
|
<view class="delete_list" v-if="i.status != '1'" @click="setDefault(i)">
|
|
<view class="icon">
|
|
<u-icon name="setting" color="#fff" size="32rpx"></u-icon>
|
|
</view>
|
|
<view class="text">设为默认</view>
|
|
</view>
|
|
<view class="delete_list" @click="touristDelete(i)">
|
|
<view class="icon">
|
|
<u-icon name="trash" color="#fff" size="32rpx"></u-icon>
|
|
</view>
|
|
<view class="text">删除</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</cowain-slide-action>
|
|
</view>
|
|
</view>
|
|
</mescroll-body>
|
|
<view class="btn_box">
|
|
<view class="btn" @click="addTourist">
|
|
<view class="icon">
|
|
<u-icon name="plus" size="28rpx" color="#03AE80"></u-icon>
|
|
</view>
|
|
<view class="text">添加游客信息</view>
|
|
</view>
|
|
</view>
|
|
<!-- 添加修改游客 -->
|
|
<view class="tourist_waper" v-if="showTourist">
|
|
<view class="tourist_box" :style="'padding-bottom: ' + keyboardHeight + 'px;'">
|
|
<view class="popup-tourist">
|
|
<view class="title">
|
|
{{popupTitle}}
|
|
<view class="close" @click="closeTourist">
|
|
<u-icon name="close" color="#000" size="30rpx"></u-icon>
|
|
</view>
|
|
</view>
|
|
<view class="form">
|
|
<view class="name-box">
|
|
<view class="list">
|
|
<view class="label">姓名</view>
|
|
<input type="text" :adjust-position="false" @keyboardheightchange="handleKeyboardChange" v-model="touristForm.name" placeholder="请输入联系人姓名" />
|
|
</view>
|
|
</view>
|
|
<view class="num-box">
|
|
<view class="list">
|
|
<view class="label">联系电话</view>
|
|
<input type="number" :adjust-position="false" @keyboardheightchange="handleKeyboardChange" v-model="touristForm.mobile" placeholder="请输入联系号码" @blur="keyboardHeight = 0;" />
|
|
</view>
|
|
<view class="list">
|
|
<view class="label">身份证号码</view>
|
|
<input type="idcard" :adjust-position="false" @keyboardheightchange="handleKeyboardChange" v-model="touristForm.idCard" placeholder="请输入证件号码" @blur="keyboardHeight = 0;" />
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="btn" @click="saveTourist">保存</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!-- 确认删除弹框 -->
|
|
<u-popup :show="show" bgColor="transparent" mode="center">
|
|
<view class="popup_waper">
|
|
<image src="https://common/refundPopup.png" mode=""></image>
|
|
<div class="refund_box">
|
|
<view class="title">温馨提示</view>
|
|
<view class="content">确认删除该游客吗?</view>
|
|
<view class="btns">
|
|
<view @click="closePopup">取消</view>
|
|
<view @click="submitPopup">确认</view>
|
|
</view>
|
|
</div>
|
|
</view>
|
|
</u-popup>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
|
|
export default {
|
|
mixins: [MescrollMixin],
|
|
data () {
|
|
return {
|
|
paddingTop: 0,
|
|
list: [],
|
|
showTourist: false,
|
|
popupTitle: '',
|
|
keyboardHeight: 0,
|
|
popupInfo: null,
|
|
touristForm: { name: '', mobile: '', idCard: '' },
|
|
show: false
|
|
}
|
|
},
|
|
onLoad () {
|
|
this.paddingTop = this.$paddingTop;
|
|
},
|
|
methods: {
|
|
touristDelete (info) {
|
|
this.popupInfo = info;
|
|
this.show = true;
|
|
},
|
|
closePopup () {
|
|
this.popupInfo = null;
|
|
this.show = false;
|
|
},
|
|
async submitPopup () {
|
|
if (this.popupInfo.status == '1') {
|
|
uni.showToast({ mask: true, title: '默认游客不可删除', icon: 'none' })
|
|
this.closePopup()
|
|
return false;
|
|
}
|
|
const params = { id: this.popupInfo.id }
|
|
let info = await this.$http.delTourist(params)
|
|
uni.showToast({ title: '删除成功', mask: true, icon: 'success' })
|
|
this.closePopup()
|
|
this.mescroll && this.mescroll.resetUpScroll();
|
|
},
|
|
async setDefault (date) {
|
|
let info = await this.$http.updateTourStatus({ id: date.id });
|
|
uni.showToast({ mask: true, title: '操作成功', icon: 'none' });
|
|
this.mescroll && this.mescroll.resetUpScroll();
|
|
},
|
|
addTourist () {
|
|
this.touristForm = { name: '', mobile: '', idCard: '' };
|
|
this.popupTitle = '新增游客'
|
|
this.showTourist = true;
|
|
},
|
|
editTourist (info) {
|
|
this.touristForm = { name: info.name, mobile: info.mobile, idCard: info.idCard, id: info.id };
|
|
this.popupTitle = '修改游客'
|
|
this.showTourist = true;
|
|
},
|
|
async upCallback (page) {
|
|
let info = await this.$http.touristList({ pageNum: page.num, pageSize: page.size });
|
|
if(page.num == 1) this.list = [];
|
|
this.list = this.list.concat(info.rows)
|
|
this.mescroll.endBySize(info.rows.length, info.total);
|
|
},
|
|
handleKeyboardChange (e) {
|
|
this.$nextTick(() => {
|
|
this.keyboardHeight = e.detail.height
|
|
})
|
|
},
|
|
closeTourist () {
|
|
this.touristForm = { name: '', mobile: '', idCard: '' };
|
|
this.popupTitle = ''
|
|
this.showTourist = false;
|
|
},
|
|
async saveTourist () {
|
|
if (!this.touristForm.name) {
|
|
uni.showToast({ mask: true, title: '请输入姓名', icon: 'none' })
|
|
return false;
|
|
}
|
|
if (!this.$utils.checkStr(this.touristForm.idCard, 'card')) {
|
|
uni.showToast({ mask: true, title: '请输入正确的证件号', icon: 'none' })
|
|
return false;
|
|
}
|
|
if (!this.$utils.checkStr(this.touristForm.mobile, 'mobile')) {
|
|
uni.showToast({ mask: true, title: '请输入正确的手机号', icon: 'none' })
|
|
return false;
|
|
}
|
|
let info = null;
|
|
if (this.touristForm.id) {
|
|
info = await this.$http.updateTourist(this.touristForm);
|
|
} else {
|
|
info = await this.$http.addTourist(this.touristForm);
|
|
}
|
|
if (info.code == 200) {
|
|
uni.showToast({ mask: true, title: '操作成功', icon: 'success' });
|
|
this.closeTourist();
|
|
this.mescroll && this.mescroll.resetUpScroll();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
page{ background: #fff; }
|
|
.list_waper{
|
|
width: 100%; box-sizing: border-box; padding: 32rpx 32rpx 162rpx;
|
|
.list{
|
|
width: 100%; background: #FBFBFB; border-radius: 10rpx; box-sizing: border-box; margin-bottom: 32rpx; overflow: hidden;
|
|
&:last-child{ margin-bottom: 0; }
|
|
.list_card{
|
|
position: relative; width: 686rpx; padding: 28rpx 24rpx; box-sizing: border-box;
|
|
.text{
|
|
width: 100%; margin-top: 16rpx; height: 40rpx; box-sizing: border-box; padding-left: 128rpx; position: relative;
|
|
&:first-child{ margin-top: 0; }
|
|
view{
|
|
font-size: 28rpx; line-height: 40rpx; color: #333; display: flex; align-items: center;
|
|
&:first-child{ color: #999; position: absolute; left: 0; top: 0; }
|
|
text{ background: #03AE80; border-radius: 4rpx; color :#fff; line-height: 40rpx; font-size: 24rpx; color: #fff; padding: 0 12rpx; margin-left: 20rpx; }
|
|
}
|
|
}
|
|
.edit{ position: absolute; right: 32rpx; top: 50%; transform: translateY(-50%); }
|
|
}
|
|
.delete-wrap{
|
|
width: 108rpx; height: 208rpx; background: #FF5833; display: flex; flex-direction: column; justify-content: center; align-items: center;
|
|
.delete_list{
|
|
display: flex; flex-direction: column; flex: 1; justify-content: center; align-items: center;
|
|
.text{ color: #fff; margin-top: 12rpx; font-size: 24rpx; }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.btn_box{
|
|
width: 100%; background: #fff; position: fixed; left: 0; bottom: 0; z-index: 5; box-sizing: border-box; padding: 20rpx 32rpx; box-shadow: 0rpx -1rpx 6rpx 0rpx rgba(0, 0, 0, 0.05);
|
|
.btn{
|
|
width: 100%; height: 90rpx; display: flex; justify-content: center; align-items: center; background: rgba(3,174,128,0.1); border-radius: 10rpx;
|
|
.text{ color: #03AE80; font-size: 28rpx; font-weight: 500; margin-left: 10rpx; }
|
|
}
|
|
}
|
|
.tourist_waper{
|
|
width: 100%; height: 100%; background: rgba(0, 0, 0, 0.4); position: fixed; left: 0; bottom: 0; z-index: 100; display: flex; align-items: flex-end;
|
|
.tourist_box{
|
|
width: 100%;
|
|
.popup-tourist{ width: 100%; }
|
|
}
|
|
}
|
|
.popup_waper{
|
|
width: 596rpx; height: 398rpx; position: relative;
|
|
.refund_box{
|
|
width: 100%; box-sizing: border-box; padding: 64rpx 46rpx 0; position: absolute; left: 0; top: 0;
|
|
.title{ line-height: 56rpx; text-align: center; color: #000; font-size: 40rpx; font-weight: 500; }
|
|
.content{ margin-top: 28rpx; color: #333; font-size: 30rpx; font-weight: 500; line-height: 42rpx; text-align: center; }
|
|
.btns{
|
|
margin-top: 62rpx; display: flex; justify-content: space-between; align-items: center;
|
|
view{
|
|
width: 240rpx; height: 80rpx; border-radius: 10rpx; text-align: center; box-sizing: border-box; line-height: 76rpx; color: #666; font-size: 30rpx; border: 2rpx solid #EBECEE;
|
|
&:last-child{ background: #01BE69; border-color: #01BE69; color: #fff; }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style> |