remind.js 11.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555
// pages/remind/remind.js
const app = getApp()
const pickerFile = require('../../picker/picker_datetime.js');
var util = require('../../../utils/time.js')

var cellId;
var date = new Date();
var years = [];
var months = [];
var days = [];
var hours = [];
var minutes = [];
var seconds = [];

var nowYear;
var nowMonth;
var nowDay;
var nowHour;
var nowMinute;
var nowSecond;

var t = 0;
var show = false;
var moveY = 200;

for (let i = new Date().getFullYear(); i < new Date().getFullYear() + 100; i++) {
  years.push(i)
}

for (let i = 1; i <= 12; i++) {
  i = zeroPadding(i);
  months.push(i)
}

for (let i = 1; i <= 31; i++) {
  i = zeroPadding(i);
  days.push(i)
}

for (let i = 0; i <= 23; i++) {
  i = zeroPadding(i);
  hours.push(i)
}
for (let i = 0; i <= 59; i++) {
  i = zeroPadding(i);
  minutes.push(i)
}
for (let i = 0; i <= 59; i++) {
  i = zeroPadding(i);
  seconds.push(i)
}

Page({
  /**
   * 页面的初始数据
   */
  data: {
    user_type: [],
    type_index: -1,
    currentTab: 1,
    edit_state: true,
    follow_time: '',
    place: '',
    mainid: '',
    def: [],
    warn: [],
    remind_times: ['当天 08:00','提前一天 08:00', '提前两天 08:00', '提前三天 08:00', '提前四天 08:00', '提前五天 08:00'],
    remind_time: '',
    index: -1,
    years: years,
    months: months,
    days: days,
    hours: hours,
    minutes: minutes,
    seconds: seconds,
    appointment_time: '',
    level_state: false,
    time_state: false,
    interval: false,
  },

  showInfo() {

    // wx.navigateTo({
    //   url: '/pages/index/VipRecharge/VipRecharge',
    // })
    // wx.showModal({
    //   title: '提示',
    //   content: '请充值会员',
    //   cancelText: '暂不充值',
    //   confirmText: '立即充值',
    //   success(res) {
    //     console.log(res)
    //     if (res.confirm) {
    //       wx.navigateTo({
    //         url: '/pages/index/VipRecharge/VipRecharge',
    //       })
    //     }
    //   },
    // })
  },

  // 打电话
  makePhoneCall() {
    let that = this;
    var def = that.data.def
    console.log(def)
    var phoneNumber = def.mobile
    wx.makePhoneCall({
      phoneNumber: phoneNumber
    })
  },

  //用户等级
  userType(e) {
    this.setData({
      type_index: e.detail.value
    })
  },

  showLevel: function() {
    this.setData({
      level_state: true
    })
  },

  cancleMask: function() {
    this.setData({
      level_state: false
    })
  },

  //修改客户级别接口
  setlevel(e) {
    let that = this;
    let defid = parseInt(e.currentTarget.dataset.defid);
    let LevelId = parseInt(e.currentTarget.id)
    let level = e.currentTarget.dataset.level;
    let def = that.data.def;
    let url = 'counselor/levelupdate';
    app.post(url, {
      DefId: defid,
      LevelId: LevelId
    }).then((res) => {
      if (res.data.code == 200) {
        def.leveltext = level;
        that.setData({
          def: def
        })
      }
    }).catch((errMsg) => {
      console.log(errMsg)
    })
  },


  //点击切换
  tabCharge(e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  },

  //修改信息
  editInfo(e) {
    this.setData({
      edit_state: true
    })
  },

  //提醒时间
  remindTime(e) {
    var remind_times = this.data.remind_times
    var remind_time = this.data.remind_times[e.detail.value]
    this.setData({
      index: e.detail.value,
      remind_time: remind_time
    })
  },

  //跟踪时间
  followTime(e) {
    this.setData({
      follow_time: e.detail.value,
    })
  },

  //地点
  place(e) {
    this.setData({
      place: e.detail.value,
    })
  },

  //清空
  nullValue() {
    this.setData({
      remind_time: '',
      follow_time: '',
      place: '',
      index: -1
    })
  },

  //完成
  finish(e) {
    var family_id = e.currentTarget.dataset.family_id
    var url = 'counselor/alerttwo';
    var params = {
      UserId: app.globalData.UserId,
      family_id: family_id,
      warn_time: parseInt(this.data.index) ,
      text_time: this.data.follow_time,
      text: this.data.place,
    }
    app.post(url, params).then((res) => {
      if (res.data.code == 200) {
        wx.showToast({
          title: '修改成功',
          icon: 'success',
          duration: 2000
        })
        this.getData()
        this.setData({
          edit_state: true
        })
      }
    })
  },


  //添加日志
  addLogs(e) {
    let that = this;
    let DefId = parseInt(e.currentTarget.dataset.defid); //客户id
    let cid = that.data.cid;
    wx.navigateTo({
      url: '../addLog/addLog?DefId=' + DefId + '&cid=' + cid,
    })
  },

  //删除日志
  delLog(e) {
    let that = this;
    wx.showModal({
      title: '提示',
      content: '确认删除?',
      showCancel: true,
      cancelText: '取消',
      cancelColor: '',
      confirmText: '确认',
      confirmColor: '',
      success: function(res) {
        console.log(res)
        if (res.confirm) {
          let id = e.currentTarget.dataset.id; //客户id
          let url = 'counselor/logDelete'
          let params = {
            log_id: id
          }
          app.post(url, params).then((res) => {
            if (res.data.code == 200) {
              wx.showToast({
                title: '删除成功',
              })
              that.getData()
            }
          })
        } else {
          wx.showToast({
            title: '删除失败',
            icon: 'none'
          })
        }
      },
      fail: function(res) {
        console.log(res)
      },
      complete: function(res) {},
    })
  },

  //获取数据
  getData() {
    let url = 'counselor/deflook';
    var that = this;
    // wx.showLoading({
    //   title: '加载中',
    //   success: function() {
    //     setTimeout(function() {
    app.post(url, {
      UserId: app.globalData.UserId,
      DefId: that.data.mainid
    }).then((res) => {
      console.log(res)
      if (res.data.code == 200) {
        var time = res.data.data.warn.warn_time
        var index = parseInt(time)
        that.setData({
          def: res.data.data.def,
          label: res.data.data.label,
          level: res.data.data.level,
          log: res.data.data.log,
          warn: res.data.data.warn,
          follow_time: res.data.data.warn.text_time,
          place: res.data.data.warn.text,
          index: index
        })
        // that.warnBox()
        // that.trackBox()
      }
    }).catch((errMsg) => {
      console.log(errMsg)
    })
    // },2000)
    // },
    // })
  },

  // 滑动事件
  bindChange: function(e) {
    const val = e.detail.value
    var temp_year = new Date().getFullYear()
    // 获取天数
    days = getDays(val[0] + temp_year, val[1] + 1);
    var follow_time = this.data.years[val[0]] + '-' + this.data.months[val[1]] + '-' + this.data.days[val[2]] + ' ' + this.data.hours[val[3]] + ':' + this.data.minutes[val[4]]
    this.setData({
      days: days,
      year: this.data.years[val[0]],
      month: this.data.months[val[1]],
      day: this.data.days[val[2]],
      hour: this.data.hours[val[3]],
      minute: this.data.minutes[val[4]],
      second: this.data.seconds[val[5]],
      follow_time: follow_time
    })
  },


  //移动按钮点击事件
  translate: function(e) {
    if (t == 0) {
      moveY = 0;
      show = false;
      t = 1;
    } else {
      moveY = 200;
      show = true;
      t = 0;
    }
    this.setData({
      time_state: false
    })
    // this.animation.translate(arr[0], arr[1]).step();
    animationEvents(this, moveY, show);
  },


  //隐藏弹窗浮层
  hiddenFloatView() {
    moveY = 200;
    show = true;
    t = 0;
    this.setData({
      time_state: true
    })
    animationEvents(this, moveY, show);
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    options.cid ? (this.setData({
      cid: options.cid,
    })) : ''
    options.mainid ? this.setData({
      mainid: options.mainid
    }) : ''
    this.setData({
      vip_state: options.vip_state ? options.vip_state:false
    })
    this.getData()
    cellId = options.cellId;
    var that = this;
    //获取时间
    getNowDate(new Date());
    // 初始化
    days = getDays(nowYear, nowMonth);
    var temp_year = new Date().getFullYear()
    that.setData({
      year: nowYear,
      month: zeroPadding(nowMonth),
      days: days,
      day: zeroPadding(nowDay),
      hour: zeroPadding(nowHour),
      minute: zeroPadding(nowMinute),
      second: zeroPadding(nowSecond),
      value: [nowYear - temp_year, nowMonth - 1, nowDay - 1, nowHour, nowMinute, nowSecond]
    })
    var follow_time = that.data.year + '-' + that.data.month + '-' + that.data.day + ' ' + that.data.hour + ':' + that.data.minute
    setTimeout(function() {
      that.setData({
        time_state: true
      })
    }, 300)


    var phone = wx.getSystemInfoSync();  //调用方法获取机型 
    var that = this;  
    if (phone.platform == 'ios') {   
      that.setData({    
        interval: true   
      });  
    } else if (phone.platform == 'android') {   
      that.setData({    
        interval: false   
      });  
    }




  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {
    this.animation = wx.createAnimation({
      transformOrigin: "50% 50%",
      duration: 0,
      timingFunction: "ease",
      delay: 0
    })
    this.animation.translateY(200 + 'vh').step();
    this.setData({
      animation: this.animation.export(),
      show: show
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.getData()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})
//动画事件
function animationEvents(that, moveY, show) {
  // console.log("moveY:" + moveY + "\nshow:" + show);
  that.animation = wx.createAnimation({
    transformOrigin: "50% 50%",
    duration: 400,
    timingFunction: "ease",
    delay: 0
  })
  that.animation.translateY(moveY + 'vh').step()

  that.setData({
    animation: that.animation.export(),
    show: show
  })

}


//输入年、月计算当月天数
var getDays = function(year, month) {
  var dayCount = new Date(year, month, 0).getDate();
  var tempDays = [];
  for (let i = 1; i <= dayCount; i++) {
    i = zeroPadding(i);
    tempDays.push(i)
  }
  return tempDays;
}

// 自动补零
function zeroPadding(i) {
  return ('0' + i).slice(-2);
}

//获取当前年月日时分秒
function getNowDate(date) {
  nowYear = date.getFullYear();
  nowMonth = date.getMonth() + 1;
  nowDay = date.getDate();
  nowHour = date.getHours();
  nowMinute = date.getMinutes();
  nowSecond = date.getSeconds();
}

// 反向传值
function nav_back(that) {
  var rewriteTime = that.data.year + "-" + that.data.month + "-" + that.data.day + " " + that.data.hour + ":" + that.data.minute + ":" + that.data.second;

  var pages = getCurrentPages();
  var currPage = pages[pages.length - 1]; //当前页面
  var prevPage = pages[pages.length - 2]; //上一个页面

  //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  if (cellId == "21") {
    prevPage.setData({
      starTime: rewriteTime
    })
  } else if (cellId == "22") {
    prevPage.setData({
      endTime: rewriteTime
    })
  }
  console.log(prevPage.data);
  var a = ''
}