Browse Source

mingsu page

邹能昇 4 months ago
parent
commit
b3d113021e

+ 3 - 1
app.json

@@ -11,7 +11,9 @@
                 "pages/homestay/homestay-detail/index",
                 "pages/homestay/homestay-detail/index",
                 "pages/my/my-card/index",
                 "pages/my/my-card/index",
                 "pages/my/my-wallet/index",
                 "pages/my/my-wallet/index",
-                "pages/homestay/homestay-order/index"
+                "pages/homestay/homestay-order/index",
+                "pages/homestay/customer/select-customer/index",
+                "pages/homestay/customer/customer-info/index"
             ]
             ]
         },
         },
         {
         {

+ 249 - 0
nova-tourism/pages/homestay/customer/customer-info/index.js

@@ -0,0 +1,249 @@
+var company = getApp().globalData.company;
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        realname: '',
+        cardtype: '身份证',
+        idcard: '',
+        mobile: '',
+        formctrl:{
+            realname: '姓名',
+            cardtype: '身份证',
+            idcard: '证件号码',
+            mobile: '手机号码' 
+        },
+        showTypePicker: false,
+        columns: ['身份证','护照','港澳通行证','台胞证'],
+    },
+    selectCardtype(){
+        this.setData({
+            showTypePicker:true
+        })
+    },
+    typePickerEnter(event){
+        const { picker, value, index } = event.detail;
+        console.log(picker, value, index);
+        console.log(`当前值:${value}, 当前索引:${index}`);
+        this.setData({
+            cardtype:value,
+            showTypePicker:false
+        })
+    },
+    typePickerCancel(){
+        console.log('取消');
+        this.setData({
+            showTypePicker:false
+        })
+    },
+    onChange(){
+        console.log(this.data.realname);
+    },
+    checkform(){
+        let formctrl = this.data.formctrl;
+        let keys = Object.keys(formctrl);
+        for (let index = 0; index < keys.length; index++) {
+            let key = keys[index];
+            if(this.data[key].trim() == ''){
+                console.log(key,this.data[key]);
+                wx.showToast({
+                  title: `请输入${formctrl[key]}`,
+                  icon: 'error'
+                })
+                return false;
+            }
+        }
+        // this.data.realname
+        // this.data.idcard
+        let checkName = /[\u4e00-\u9fa5]/.test(this.data.realname);
+        if (!checkName) {
+            wx.showToast({
+                title: '请输入您的真实姓名',
+                icon: 'none',
+                duration: 2000
+            })
+            return false
+        }
+        let checkMobile = /^1[34578]\d{9}$/.test(this.data.mobile);
+        if (!checkMobile) {
+            wx.showToast({
+                title: '手机号码格式有误',
+                icon: 'none',
+                duration: 2000
+            })
+            return false
+        }
+        let checkIdcard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/gi.test(this.data.idcard)
+        if (!checkIdcard) {
+            wx.showToast({
+                title: '请输入正确的身份证号',
+                icon: 'none',
+                duration: 2000
+            })
+            return false
+        }
+
+        return true;
+    },
+    verifyIdcardName(){
+        return new Promise((resolve,reject)=>{
+            wx.request({
+                url: "https://server.fmode.cn/api/apig/idcard", //请求接口的url
+                method: "POST", //请求方式
+                data: {
+                    company: company,
+                    cardNo: this.data.idcard,
+                    realName: this.data.realname
+                }, //请求参数
+                header: {
+                    "content-type": "application/json", // 默认值
+                },
+                success: (res) => {
+                    if(res.statusCode != '200'){
+                        console.log(res);
+                        resolve(false)
+                    }
+                    console.log(res.data.data.result);
+                    if (res.data.data.result.isok) {
+                        resolve(true)
+                    } else {
+                        resolve(false)
+                    }
+                },
+                fail:(err)=>{
+                    console.log(err);
+                    wx.showToast({
+                        title: err,
+                        icon: 'none',
+                        duration: 2000
+                    })
+                }
+            })
+        })
+
+    },
+    async save(){
+        let checked = this.checkform()
+        console.log(checked);
+        if(!checked){
+            return false
+        }
+        let verifyIdcardName = await this.verifyIdcardName()
+        console.log(verifyIdcardName);
+        if(!verifyIdcardName){
+            wx.showToast({
+              title: '身份校验失败,请输入真实姓名和身份证号',
+              icon: 'none'
+            })
+            return false
+        }
+        wx.showToast({
+            title: '添加成功',
+            icon: 'none',
+            duration: 1000
+          })
+
+        let formdata = {
+            realname:this.data.realname,
+            cardtype:this.data.cardtype,
+            idcard:this.data.idcard,
+            mobile:this.data.mobile
+        };
+        let customers = wx.getStorageSync("customers")
+        if(customers){
+            console.log(customers);
+            customers.forEach((customer,index) =>{
+                if(customer.realname == this.data.realname){
+                    customers[index] = formdata
+                }
+            })
+        }else {
+            customers = []
+            customers.push(formdata)
+        }
+        wx.setStorageSync("customers",customers)
+        setTimeout(()=>{
+            wx.navigateBack({
+                delta: 1,
+              }) 
+        },1000)
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        console.log(options);
+        let {type,name}=options;
+        if(type== 'edit' && name){
+            this.initCustomerInfo(name)
+        }
+    },
+    initCustomerInfo(name){
+        let customers = wx.getStorageSync("customers")
+        if(customers){
+            console.log(customers);
+            customers.forEach((customer,index) =>{
+                if(customer.realname == name){
+                    this.setData({
+                        realname: customer.realname,
+                        cardtype: customer.cardtype,
+                        idcard: customer.idcard,
+                        mobile: customer.mobile,
+                    })
+                }
+            })
+        }
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 8 - 0
nova-tourism/pages/homestay/customer/customer-info/index.json

@@ -0,0 +1,8 @@
+{
+  "usingComponents": {
+    "van-icon": "@vant/weapp/icon/index",
+    "list-item": "../../../../components/list-item/index",
+    "van-divider": "@vant/weapp/divider/index",
+    "van-picker": "@vant/weapp/picker/index"
+  }
+}

+ 20 - 0
nova-tourism/pages/homestay/customer/customer-info/index.less

@@ -0,0 +1,20 @@
+@import '../../../../styles/base.less';
+
+.warning {
+    padding: 10rpx;
+    color:@red;
+}
+.tips{
+    line-height: 2;
+}
+.type-picker {
+    position: fixed;
+    bottom: 128rpx;
+    left:0;
+    right: 0;
+  }
+
+  .save-btn {
+    color: #ffffff;
+    background-color:#46a9a4;
+  }

+ 40 - 0
nova-tourism/pages/homestay/customer/customer-info/index.wxml

@@ -0,0 +1,40 @@
+<nav type="back"  title="添加入住人"  />
+<view class="page-section">
+    <list-item label="姓名" >
+        <view slot="content">
+            <input type="text" placeholder="请填写入住人姓名" model:value="{{realname}}" bind:input="onChange" />
+        </view>
+    </list-item>
+    <van-divider customStyle="margin:8rpx 0;"/>
+    <list-item label="证件类型" arrow="arrow" bind:arrowtap="selectCardtype">
+        <view slot="content" bind:tap="selectCardtype">
+            <text class="text text-left">{{cardtype}}</text>
+        </view>
+    </list-item>
+    <van-divider customStyle="margin:8rpx 0;"/>
+    <list-item label="证件号码" >
+        <view slot="content">
+            <input type="idcard" placeholder="请填写真实证件号码"  model:value="{{idcard}}"/>
+        </view>
+    </list-item>
+    <van-divider customStyle="margin:8rpx 0;"/>
+    <list-item label="手机号码" >
+        <view slot="content">
+            <input type="text" placeholder="请填写手机号码" model:value="{{mobile}}"/>
+        </view>
+    </list-item>
+    <van-divider customStyle="margin:8rpx 0;"/>
+</view>
+<view class="page-section">
+    <view class="text-small spacing-small grey">
+        <van-icon name="warning" class="warning"></van-icon>
+        <text class="tips">根据国家相关法律法规,入住经营性质的酒店、民宿,必须提供入住者的身份信息。\n 您的身份信息会严格保密,仅用于必要的身份核实。\n上述手机号码将用于房东在提供入住和相关服务时联系房客,请您知悉。
+        </text>
+    </view>
+</view>
+<view class="page-section">
+    <button  class="save-btn" size="large" bind:tap="save">保存</button>
+</view>
+<!-- 证件类型选择 -->
+<van-picker wx:if="{{ showTypePicker }}" show-toolbar title="证件类型" columns="{{columns}}" bind:cancel="typePickerCancel"
+bind:confirm="typePickerEnter" class="type-picker" default-index="{{ 0 }}"/>

+ 1 - 0
nova-tourism/pages/homestay/customer/customer-info/index.wxss

@@ -0,0 +1 @@
+.red{color:#F01740}.grey{color:#666666}.black{color:#000000}.title{font-weight:Medium;font-size:36rpx;color:#222222}.text-large{font-size:36rpx}.text{font-size:30rpx}.text-left{text-align:left}.text-center{text-align:center}.text-small{font-size:24rpx}.flex{display:flex}.justify-between{justify-content:space-between}.flex-aligin-center{display:flex;align-items:center}.flex-justify-between{display:flex;justify-content:space-between}.flex-1{flex:1}.flex-grow-1{flex-grow:1}.fixed-bottom{position:fixed;bottom:0;left:0;right:0}.w-100{width:100%}.h-100{height:100%}.page-section{margin:20rpx;border-radius:20rpx;background-color:#ffffff}.page-section-spacing{padding:20rpx}.spacing-small{padding:10rpx}.border-trans{border:1px solid transparent}.ellipsis{width:100%;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical}.ellipsis-2{width:100%;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.warning{padding:10rpx;color:#F01740}.tips{line-height:2}.type-picker{position:fixed;bottom:128rpx;left:0;right:0}.save-btn{color:#ffffff;background-color:#46a9a4}

+ 124 - 0
nova-tourism/pages/homestay/customer/select-customer/index.js

@@ -0,0 +1,124 @@
+// nova-tourism/pages/homestay/customer/select-customer/index.js
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        customers: []
+    },
+    navigate(){
+        wx.navigateTo({
+            url: `/nova-tourism/pages/homestay/customer/customer-info/index`
+        })  
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+        
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+        let customers = wx.getStorageSync('customers');
+        if(customers.length){
+            customers = customers.map(customer =>  {
+                 customer['idcard'] = this.hiddenMiddleText(customer['idcard'])
+                 customer['checked'] = false
+                 return customer;
+            })
+        }
+        this.setData({
+            customers
+        })
+        console.log(this.data.customers);
+    },
+    radioChange(event){
+        console.log(111,event);
+        let index = event.currentTarget.dataset.index;
+        this.setData({
+            [`customers[${index}].checked`] : !this.data.customers[index].checked
+        })
+        console.log(this.data.customers[index].checked);
+    },
+    toEdit(event){
+        console.log(111,event);
+        let name = event.currentTarget.dataset.name;
+        wx.navigateTo({
+            url: `/nova-tourism/pages/homestay/customer/customer-info/index?type=edit&name=${name}`
+        })  
+    },
+    hiddenMiddleText(text){
+        return text.replace(/(.{5}).*(.{3})/, "$1********$2")
+    },
+    save(){
+        let customers = this.checkedCustomer();
+        if(!customers.length || customers.length == 0) return;
+        // 入住人数据保存到上一页面,再进行跳转
+        var pages = getCurrentPages();var prevPage = pages[pages.length - 2];
+        console.log(pages,prevPage,customers);
+        prevPage.setData({
+            customers
+        })
+          wx.navigateBack({
+          delta: 1,
+        })
+        
+        
+    },
+    checkedCustomer(){
+        let customers = []
+        for (let index = 0; index < this.data.customers.length; index++) {
+            let customer = this.data.customers[index];
+            if(customer.checked == true){
+                customers.push(customer)
+            }
+        }
+        return customers
+    },
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 6 - 0
nova-tourism/pages/homestay/customer/select-customer/index.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "van-icon": "@vant/weapp/icon/index",
+    "list-item": "../../../../components/list-item/index"
+  }
+}

+ 20 - 0
nova-tourism/pages/homestay/customer/select-customer/index.less

@@ -0,0 +1,20 @@
+@import '../../../../styles/base.less';
+
+
+page {
+    background: #ffffff;
+}
+.add-customer {
+    padding: 20rpx 0;
+    text-align: center;
+    color: blue;
+    background-color: #eee;
+    border-radius: 40rpx;
+}
+.add-icon {
+    margin-right: 10rpx; 
+}
+.save-btn {
+    color: #ffffff;
+    background-color:#46a9a4;
+  }

+ 33 - 0
nova-tourism/pages/homestay/customer/select-customer/index.wxml

@@ -0,0 +1,33 @@
+<nav type="back"  title="选择入住人" />
+
+<view class="page-section">
+    <view class="add-customer" bind:tap="navigate">
+        <van-icon class="add-icon" name="https://file-cloud.fmode.cn/sHNeVwSaAg/20220418/qn1d5i021341.png?imageView2/1/w/200/h/200" color="#3d88ff" />
+        <text class="text" style="color:#3d88ff;">添加入住人信息</text>
+    </view>
+</view>
+
+<view class="page-section">
+    <radio-group >
+        <list-item class="list-item" wx:for="{{customers}}" wx:key="index" wx:for-item="customer">
+            <view class="text-small grey" slot="start" data-index="{{index}}" bind:tap="radioChange">
+                <radio value="{{index}}" color="#46a9a4" checked="{{customer.checked}}"></radio>
+            </view>
+            <view class="" slot="content">
+                <view class="text">{{customer['realname']}}</view>
+                <view class="text-small">
+                    <text class=" grey">{{customer['cardtype']}}</text>
+                    <text >{{customer['idcard']}}</text>
+                </view>
+            </view>
+            <view class="text-small grey" slot="end" data-name='{{customer.realname}}' bind:tap="toEdit">
+                <van-icon name="edit" size="26"></van-icon>
+            </view>
+        </list-item>
+    </radio-group>
+    
+</view>
+
+<view class="page-section fixed-bottom">
+    <button  class="save-btn" size="large" bind:tap="save">保存</button>
+</view>

+ 1 - 0
nova-tourism/pages/homestay/customer/select-customer/index.wxss

@@ -0,0 +1 @@
+.red{color:#F01740}.grey{color:#666666}.black{color:#000000}.title{font-weight:Medium;font-size:36rpx;color:#222222}.text-large{font-size:36rpx}.text{font-size:30rpx}.text-left{text-align:left}.text-center{text-align:center}.text-small{font-size:24rpx}.flex{display:flex}.justify-between{justify-content:space-between}.flex-aligin-center{display:flex;align-items:center}.flex-justify-between{display:flex;justify-content:space-between}.flex-1{flex:1}.flex-grow-1{flex-grow:1}.fixed-bottom{position:fixed;bottom:0;left:0;right:0}.w-100{width:100%}.h-100{height:100%}.page-section{margin:20rpx;border-radius:20rpx;background-color:#ffffff}.page-section-spacing{padding:20rpx}.spacing-small{padding:10rpx}.border-trans{border:1px solid transparent}.ellipsis{width:100%;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical}.ellipsis-2{width:100%;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}page{background:#ffffff}.add-customer{padding:20rpx 0;text-align:center;color:blue;background-color:#eee;border-radius:40rpx}.add-icon{margin-right:10rpx}.save-btn{color:#ffffff;background-color:#46a9a4}

+ 1 - 1
nova-tourism/pages/homestay/homestay-detail/index.less

@@ -4,6 +4,7 @@
     height: 100vh;
     height: 100vh;
     background-color: #ECECEC;
     background-color: #ECECEC;
     position: relative;
     position: relative;
+    overflow-y: scroll;
     .picturebox{
     .picturebox{
         width: 100%;
         width: 100%;
         height: 480rpx;
         height: 480rpx;
@@ -39,7 +40,6 @@
         height: auto;
         height: auto;
         position: absolute;
         position: absolute;
         top: 450rpx;
         top: 450rpx;
-        padding-bottom: 40rpx;
         .Legendary-Information{
         .Legendary-Information{
             width: 100%;
             width: 100%;
             height: auto;
             height: auto;

File diff suppressed because it is too large
+ 0 - 0
nova-tourism/pages/homestay/homestay-detail/index.wxss


+ 56 - 19
nova-tourism/pages/homestay/homestay-order/index.js

@@ -42,6 +42,9 @@ Page({
         // checkedFormatter: null,// 日历相关数据处理
         // checkedFormatter: null,// 日历相关数据处理
         CountArray: [], // 房型可选日期及已订数量数组 [{date: '',count: 0}]
         CountArray: [], // 房型可选日期及已订数量数组 [{date: '',count: 0}]
         CountObj: [], // 房型可选日期及已订数量对象 {date: count}
         CountObj: [], // 房型可选日期及已订数量对象 {date: count}
+        start:'',
+        end:'',
+        objectId:'',
     },
     },
 
 
     /**
     /**
@@ -55,8 +58,39 @@ Page({
         } = options;
         } = options;
         const date_start1 = decodeURIComponent(date_start);
         const date_start1 = decodeURIComponent(date_start);
         const date_end1 = decodeURIComponent(date_end);
         const date_end1 = decodeURIComponent(date_end);
-        console.log('123',date_start1,date_end1 );
+        this.setData({
+            start:date_start1,
+            end:date_end1,
+            objectId
+
+        })
+        console.log('123', date_start1, date_end1);
+        this.getdate()
         this.initData(objectId)
         this.initData(objectId)
+
+    },
+    getdate() {
+        let {
+            startTime,
+            endTime
+        } = this.formatTimeArea(this.data.start, this.data.end)
+        console.log('开始时间', startTime, '结束时间', endTime);
+        var dataAll = dateServ.getDayAll(startTime, endTime);
+        dataAll.pop(); // 最后一天为退房,不算在内
+        console.log(dataAll);
+        console.log(this.formatDate(startTime), this.formatDate(endTime))
+        let dateStr = this.formatDate(startTime) + '-' + this.formatDate(endTime)
+        console.log(dateStr)
+        this.setData({
+            showDate: false,
+            date: `${this.formatDate(startTime)} - ${this.formatDate(endTime)}`,
+            startTime: new Date(startTime),
+            endTime: new Date(endTime),
+            priceInfoArr: dataAll,
+            count: dataAll.length
+        })
+
+        console.log(this.data.priceInfoArr);
     },
     },
     /**
     /**
      * 生命周期函数--监听页面显示
      * 生命周期函数--监听页面显示
@@ -126,25 +160,28 @@ Page({
         console.log(obj);
         console.log(obj);
         return obj
         return obj
     },
     },
-    // navigate(event){
-    //     console.log(event);
-    //     let type = event.currentTarget.dataset.type;
-    //     switch (type) {
-    //         case 'room':
-    //             wx.navigateTo({
-    //                 url: `/nova-tourism/pages/homestay/room-detail/index?id=${this.data.roomId}`
-    //             })  
-    //             break;
-    //             case 'customer':
-    //                 wx.navigateTo({
-    //                     url: `/nova-tourism/pages/homestay/customer/select-customer/index`
-    //                 })  
-    //                 break;
-    //         default:
-    //             break;
-    //     }
+    navigate(event){
+        console.log(event);
+        let type = event.currentTarget.dataset.type;
+        switch (type) {
+            case 'room':
+                console.log('暂时无详细页面');
+                //暂时无详细页面
+                // wx.navigateTo({
+                //     url: `/nova-tourism/pages/homestay/room-detail/index?id=${this.data.roomId}`
+                // })  
+                break;
+                case 'customer':
+                    //跳转到信息页面
+                    wx.navigateTo({
+                        url: `../customer/select-customer/index`
+                    })  
+                    break;
+            default:
+                break;
+        }
 
 
-    // },
+    },
     // 显示订房必读
     // 显示订房必读
     showNotePop() {
     showNotePop() {
         this.setData({
         this.setData({

Some files were not shown because too many files changed in this diff