// pages/service/settle/settle.js import { ServiceModel } from '../../../models/service.js' let serviceModel = new ServiceModel() Page({ /** * 页面的初始数据 */ data: { info:'', code:'', tp:'', array: ['融创', '时代国际'], index:'', departIndex:'', department:[], departArray:[], hospitalIndex:'', hospitalArray:[], doctorIndex:'', doctorArray:[], demand:'', // 服务需求 start:'', calendar:false, holiday:[ '2021-8-1', '2021-8-7', '2021-8-8', '2021-8-14', '2021-8-15', '2021-8-21', '2021-8-22', ] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options.code) console.log(options.tp) // var date = new Date(); // console.log(nowTime) // var year = date.getFullYear(); // var month = date.getMonth() + 1; // var day = date.getDate(); // if(month < 10){ // month = '0'+ month.toString() // } // if(day < 10){ // day = '0'+ month.toString() // } // var start = year + '-' + month + '-' + day // this.setData({ // start:start // }) // console.log(start) this.setData({ code:options.code, tp:options.tp }) serviceModel.getUserInfo(res=>{ this.setData({ info:res.result }) }) if(this.data.code == 'zwfw' || this.data.code == 'whly' || this.data.code == 'tycg' || this.data.code == 'cjkf' || this.data.code == 'jgtc'){ serviceModel.getDepartList(this.data.code,res=>{ var departArray = [] for(let i = 0;i < res.result.length; i++){ departArray.push(res.result[i]['depart_name']) } this.setData({ department:res.result, departArray:departArray }) }) } if(this.data.code == 'ylbj'){ serviceModel.getHosptialList(res=>{ this.setData({ hospitalArray:res.result }) }) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, photo:function(){ var th = this; var img = th.data.img; var count = img.length; var num = 9 - count; if(num <= 0){ wx.showToast({ title: '最多能选9张图片', icon: 'none', duration: 2000 }) return; } wx.chooseImage({ count: num, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { // tempFilePath可以作为img标签的src属性显示图片 const tempFilePaths = res.tempFilePaths console.log(tempFilePaths); img = img.concat(tempFilePaths); th.setData({ text:false, img: img }) } }) }, del:function(e){ // console.log(e); var id = e.currentTarget.dataset.id; var th = this; var img = th.data.img; img.splice(id,1); th.setData({ img:img }) }, inputDemand:function(e){ console.log(e) this.setData({ demand:e.detail.value }) }, bindDepartChange:function(e){ // 办理部门 console.log(e) this.setData({ departIndex:e.detail.value }) }, bindHospitalChange:function(e){ if(e.detail.value != this.data.hospitalIndex){ this.setData({ hospitalIndex:e.detail.value, doctorIndex:'', doctorArray:[] }) this.getDoctorList() } }, bindDoctorChange:function(e){ this.setData({ doctorIndex:e.detail.value }) }, calendar:function(e){ this.setData({ calendar:true }) }, onClose:function(){ this.setData({ calendar:false }) }, onConfirm:function(e){ console.log(e) this.setData({ calendar:false }) }, getDoctorList:function(){ var hospital = this.data.hospitalArray[this.data.hospitalIndex] serviceModel.getDoctorList(hospital,res=>{ var doctorArray = [] for(var i = 0;i < res.result.length;i++){ doctorArray.push(res.result[i]['deptType'] + ' '+ res.result[i]['doctor_name']) } this.setData({ doctorArray:doctorArray }) }) } })