const app=getApp(); var utils=require("../../../utils/http"),page=1; const util = require("../../../utils/util"); let time = 0,timer = null; Page({ /** * 页面的初始数据 */ data: { canIUseGetUserProfile: false, shareobj:{}, employeeflag:false,//false是用户,true是员工 top:app.globalData.statusBarHeight, hgt:app.globalData.titleBarHeight, companyobj:{}, datashow:false, sourceflag:false, houseflag:false, likestyle:'', likehouse:'', stylearr:[], housearr:[], designlist:[], phoneFlag:false, orgarr: [], orgobj: {}, noworg: { id: '', name: '' }, orgName:'', orgId:'', orgshow: false, levelIds: ['1'], }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.showLoading({ title: '加载中...', }) time = 0; this.setData({ top:app.globalData.statusBarHeight, hgt:app.globalData.titleBarHeight, }) if (wx.getUserProfile) { this.setData({ canIUseGetUserProfile: true }) } if(!!options.scene){ options=unescape(options.scene); let arr=options.split('&'); let obj={}; for(let i=0;i { if (id == item.id) { if (!item.children || !item.children.length) { wx.showToast({ title: '没有下级部门了', icon: 'none', duration: 1000 }) } else { if (level) { this.setData({ orgarr: item.children, levelIds: this.data.levelIds, }) } else { this.data.levelIds.push(id); this.setData({ orgarr: item.children, levelIds: this.data.levelIds, }) } } return; } else { if (item.children && item.children.length) { this.setDepartData(item.children, id, level); } } }) }, lastLevel() { if (this.data.levelIds.length == 2) { this.setData({ orgarr: this.data.orgobj, levelIds: ['1'], }) } else { this.data.levelIds.splice(this.data.levelIds.length - 1, 1); this.setDepartData(this.data.orgobj, this.data.levelIds[this.data.levelIds.length - 1], 'lastlevel'); } }, radioChange(e) { let data = e.detail.value.split('~'); let obj = { name: data[1], id: data[0] }; this.setData({ noworg: obj }) }, showorgtap(){ this.setData({ orgshow:true }) }, closeMask() { this.setData({ orgshow: false, levelIds: ['1'], noworg: { id: '', name: '' }, orgarr:this.data.orgobj }) }, confirmDepart() { this.setData({ orgName: this.data.noworg.name, orgId: this.data.noworg.id, orgshow: false, levelIds: ['1'], noworg: { id: '', name: '' }, orgarr:this.data.orgobj }); this.designlistfun(); }, apointap:function(e){ const that=this; let item=this.data.designlist[e.currentTarget.dataset.idx]; utils.$post({ url: app.globalData.webUrl + 'client/designer/designer_make', header: { 'Authorization':'bearer '+app.globalData.token }, data:{ designer_id:item.designer_id, designer_name:item.name, share_uid:app.globalData.shareuserid }, success: function (res) { if (res.data.code == "0"){ wx.showToast({ title: res.data.msg, icon: 'none', duration: 2000 }) } } }) }, getPhoneNumberTap:function(res){ var that=this; console.log(res) if(res.detail.errMsg=='getPhoneNumber:ok'){ utils.$post({ url: app.globalData.webUrl + 'api/users/setUserMobile', data: { encryptedData:res.detail.encryptedData, iv:res.detail.iv }, header: { 'Authorization':'bearer '+app.globalData.token }, success: function (r) { if(r.data.code=='0'){ // wx.showLoading({ // title: '加载中', // }) app.globalData.phone=true; that.setData({ phoneFlag:false }) that.apointap(res); }else{ that.setData({ errorText:r.data.msg, errorflag:true }) } } }) } }, designertap:function(e){ let item=this.data.designlist[e.currentTarget.dataset.idx]; wx.navigateTo({ url: '/share/pages/designermsg/designermsg?did='+item.id+"&type=3" }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { timer = setInterval(function () { time = time * 1 + 1; }, 1000) }, prelooktap(){ if(!app.globalData.sharepersonobj.qrcode){ wx.showToast({ title: "当前专属客服的二维码为空!", icon: 'none', duration: 2000 }) return false; } wx.previewImage({ current: app.globalData.imgUrl+app.globalData.sharepersonobj.qrcode, // 当前显示图片的http链接 urls: [app.globalData.imgUrl+app.globalData.sharepersonobj.qrcode]// 需要预览的图片http链接列表 }) }, callphonetap:function(){ wx.makePhoneCall({ phoneNumber: app.globalData.sharepersonobj.phone }) }, golastap:function(){ wx.reLaunch({ url: '/pages/index/index?state=1', }) }, goindextap:function(){ wx.reLaunch({ url: '/pages/index/index?state=1', }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { if (timer) { clearInterval(timer) } this.setimetap(); }, setimetap(){ const that = this; utils.$post({ url: app.globalData.webUrl + 'client/index/visit_due_time', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: that.data.companyobj.employee_id, pipe_type: 'toolAll', time: time, }, success: function (res) { } }) }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { this.setimetap(); }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.designlistfun(); wx.stopPullDownRefresh(); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { const that=this; page=page*1+1; utils.$post({ url: app.globalData.webUrl + 'client/designer/index', header: { 'Authorization':'bearer '+app.globalData.token }, data:{ at: that.data.likestyle, house: that.data.likehouse, limit: 10, page: page, org_id:this.data.orgId }, success: function (res) { if (res.data.code == "0"){ let designlist=that.data.designlist; designlist=designlist.concat(res.data.data); that.setData({ designlist:designlist }) } } }) }, addsharetap: function (type) { let that = this; utils.$post({ url: app.globalData.webUrl + 'api/share/addlog', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: '0', type: type, }, success: function (r) {} }) }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { this.addsharetap('toolAll'); return { title: "设计师列表", imageUrl: app.globalData.imgUrl+"xcx/designerlisticon.jpg", path: '/share/pages/designerlist/designerlist?uid='+app.globalData.shareuserid+'&ctp='+app.globalData.clientype } } })