123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- // 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 () {
- }
- })
|