| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <template>
- <view class="container">
- <view class="box">
- <view class="body">
- <!-- 姓名区域 -->
- <view class="body_box">
- <view class="body_box_key">姓名</view>
- <view class="body_box_value">
- <input class="input" type="text" placeholder="请输入姓名" v-model="name" />
- </view>
- </view>
- <!-- 身份证号区域 -->
- <view class="body_box">
- <view class="body_box_key">身份证号</view>
- <view class="body_box_value">
- <input class="input" type="text" placeholder="请输入身份证号" v-model="identity" />
- </view>
- </view>
- <!-- 联系电话区域 -->
- <view class="body_box">
- <view class="body_box_key">联系电话</view>
- <view class="body_box_value">
- <input class="input" type="text" placeholder="请输入联系电话" maxlength="11" v-model="phone" />
- </view>
- </view>
- </view>
- <view class="btn" @click="handleSub">确定</view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 姓名
- name: '',
- // 身份证号
- identity: '',
- // 电话
- phone: '',
- type: '',
- id: ''
- }
- },
- onLoad(options) {
- // console.log(options)
- this.type = options.type
- if (options.type === '2') {
- // 编辑状态
- const info = JSON.parse(options.info)
- this.name = info.user_name
- this.identity = info.card_number
- this.phone = info.user_phone
- this.id = info.id
- uni.setNavigationBarTitle({
- title: '编辑旅客'
- })
- }
- },
- methods: {
- // 确定按钮点击回调
- handleSub() {
- if (!this.name) {
- uni.showToast({
- title: '请输入姓名',
- icon: 'none',
- mask: true
- })
- return
- }
- if (!this.identity) {
- uni.showToast({
- title: '请输入身份证号',
- icon: 'none',
- mask: true
- })
- return
- }
- if (!this.phone) {
- uni.showToast({
- title: '请输入联系电话',
- icon: 'none',
- mask: true
- })
- return
- }
- if (this.type === '1') {
- // 添加
- this.add()
- } else {
- // 编辑
- this.edit()
- }
- },
- // 添加请求
- async add() {
- const res = await this.$myRequest({
- url: '/mhotel/ampAddContact.action',
- data: {
- userName: uni.getStorageSync('userInfo').user_name,
- contactUserName: this.name,
- contactUserPhone: this.phone,
- contactUserIdNum: this.identity,
- userId: uni.getStorageSync('userInfo').id
- }
- })
- // console.log(res)
- if (res.code === 200) {
- uni.showToast({
- title: '添加成功',
- icon: 'success',
- mask: true
- })
- setTimeout(() => {
- uni.navigateBack(1)
- }, 1500)
- }
- },
- // 编辑请求
- async edit() {
- const res = await this.$myRequest({
- url: '/mhotel/ampupdateContact.action',
- data: {
- contactUserName: this.name,
- contactUserPhone: this.phone,
- contactUserIdNum: this.identity,
- contactId: this.id
- }
- })
- console.log(res)
- if (res.code === 200) {
- uni.showToast({
- title: '编辑成功',
- icon: 'success',
- mask: true
- })
- setTimeout(() => {
- uni.navigateBack(1)
- }, 1500)
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- display: flex;
- flex-direction: column;
- height: 100vh;
- background-color: #f2f2f2;
- .box {
- margin-top: 20rpx;
- height: calc(100vh - 20rpx);
- background-color: #fff;
- .body {
- box-sizing: border-box;
- padding: 0 20rpx;
- height: calc(100vh - 236rpx);
- background-color: #fff;
- .body_box {
- display: flex;
- align-items: center;
- margin-top: 30rpx;
- height: 80rpx;
- .body_box_key {
- width: 152rpx;
- color: #808080;
- font-size: 28rpx;
- }
- .body_box_value {
- display: flex;
- align-items: center;
- box-sizing: border-box;
- padding: 0 28rpx;
- width: 559rpx;
- height: 80rpx;
- font-size: 28rpx;
- border-radius: 15rpx;
- background-color: #f2f2f2;
- .input {
- width: 100%;
- }
- }
- }
- }
- .btn {
- display: flex;
- justify-content: center;
- align-items: center;
- margin: 45rpx auto;
- width: 710rpx;
- height: 96rpx;
- font-size: 32rpx;
- border-radius: 64rpx;
- color: #fff;
- background-color: #096562;
- }
- }
- }
- </style>
|