// index/pages/viewcase/viewcase.js const app = getApp(); var utils = require("../../../utils/http"); var designTimer = null; var time = 0; Page({ /** * 页面的初始数据 */ data: { cid: '', dscDataMsg: '', detail: {}, companyobj: {}, loginFlag: false, canIUseGetUserProfile: false, designPlan: false, phoneFlag:false, type:'',//1就是分享进来的 top: app.globalData.statusBarHeight, hgt: app.globalData.titleBarHeight, employeeflag: false,//false是用户,true是员工 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { if (wx.getUserProfile) { this.setData({ canIUseGetUserProfile: true }) } this.setData({ type:'' }) wx.showLoading({ title: '加载中...', }) if (!!options.cid) { this.setData({ cid: options.cid }) if (options.type == 1) { this.devCaseDetail(); } else { this.setData({ type:1 }) if (!!options.ctp) { app.globalData.clientype = options.ctp; } if (!!options.uid) { app.globalData.shareuserid = options.uid; } this.login(); } } wx.hideHomeButton(); }, login: function () { var that = this; wx.login({ success: function (data) { if (data.errMsg == 'login:ok') { utils.$post({ url: app.globalData.webUrl + 'api/users/code2session', data: { code: data.code, share: app.globalData.shareuserid, client_type:app.globalData.clientype }, success: function (r) { if (r.data.code == '0') { app.globalData.sharepersonobj = r.data.share; app.globalData.token = r.data.token; app.globalData.companyobj=r.data.company_data; that.sharecompany(); that.setData({ sharepersonMsg: app.globalData.sharepersonobj, }) app.globalData.personMsg = r.data.user; app.globalData.companyname=r.data.company; app.globalData.official_openid = r.data.official_openid; app.globalData.agentEmployeEid = r.data.agent_employee_id; if (!!r.data.user.phone) { that.setData({ employeeflag: (!!r.data.user.binded && r.data.user.binded.state == '在职') ? true : false }) app.globalData.personMsg = r.data.user; app.globalData.use_id = r.data.user.id; if (!!r.data.user.binded && r.data.user.binded.state == '在职'){ app.globalData.currentUserId = r.data.user.binded.id; } app.globalData.phone = true;//有手机号 that.setData({ phoneFlag: false, }) var obj = { detail: 1 } that.devClientCaseDetail(obj); } else { wx.hideLoading(); that.setData({ loginFlag: false, phoneFlag: true }) } } else { setTimeout(function () { wx.hideLoading() }, 500) } } }) } } }) }, sharecompany:function (){ const that=this; utils.$post({ url: app.globalData.webUrl + 'client/index/content_belong_company', header: { 'Authorization':'bearer '+app.globalData.token }, data:{ client_type:app.globalData.clientype, uid: app.globalData.shareuserid }, success: function (res) { if(res.data.code=='0'){ app.globalData.currentUserId = res.data.data.employee_id; that.setData({ companyobj:res.data.data }) } }, complete(res) { wx.hideLoading() } }) }, golastap(){ wx.navigateBack() }, devCaseDetail() { var that = this; utils.$get({ url: app.globalData.webUrl + 'api/building/dev_case_detail', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: that.data.cid, }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { wx.setNavigationBarTitle({ title: res.data.data.name, }) that.setData({ dscDataMsg: res.data.data.content, detail: res.data.data }) } else { wx.showToast({ title: res.data.msg, icon: 'none', duration: 1500 }) } } }) }, devClientCaseDetail() { var that = this; utils.$get({ url: app.globalData.webUrl + 'client/building/dev_case_detail', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: that.data.cid, }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { wx.setNavigationBarTitle({ title: res.data.data.name, }) that.setData({ dscDataMsg: res.data.data.content, detail: res.data.data }) } else { wx.showToast({ title: res.data.msg, icon: 'none', duration: 1500 }) } } }) }, closeDesigntap(e) { if (designTimer) { clearTimeout(designTimer); } if (e.detail.type == 'success') { this.setData({ designPlan: false }) } else { this.setData({ designPlan: false }) } }, visitimefun() { const that = this; utils.$post({ url: app.globalData.webUrl + 'client/index/visit_due_time', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: that.data.cid, pipe_type: 'devcase', time: time, }, success: function (res) {} }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { time = 0; setInterval(() => { time++; },1000) }, gotoindextap(){ wx.reLaunch({ url: '/pages/consoledesk/consoledesk', }) }, /** * 生命周期函数--监听页面隐藏 */ onHide() { this.visitimefun(); }, /** * 生命周期函数--监听页面卸载 */ onUnload() { this.visitimefun(); }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { var that = this; return { title: that.data.detail.name, path: '/index/pages/viewcase/viewcase?cid=' + that.data.cid + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&type=2' } } })