// index/pages/casemsg/casemsg.js const app = getApp(); var utils = require("../../../utils/http") let time = 0; var timer = null; var designTimer = null; Page({ /** * 页面的初始数据 */ data: { top: app.globalData.statusBarHeight, hgt: app.globalData.titleBarHeight, imgUrl: app.globalData.imgUrl, communityht: '', cid: '', casemsgobj: {}, page: 1, shareid: '', loginFlag: false, phoneFlag:false, canIUseGetUserProfile: false, datashow: false, personMsg: {}, caselist: [], leftcaselist: [], rightcaselist: [], sharepersonMsg: app.globalData.sharepersonobj, employeeflag: false,//false是用户,true是员工 companyobj: {}, articlelogin: false, scrollTop: 0, showAction: false, showAddress: false, imgarr:[], type:'',//有值代表是从其他页面进来的 ctype:'', priceflag: false, swiperIndex:0, tab: [{ name: 'VR案例', type: 'vr', count: 0 }, { name: '视频案例', type: 'video', count: 0 }], activeType: '', designPlan: false, isBroker: false, showMask: false, fPhone: "", agid: "" }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; time = 0; wx.hideHomeButton(); that.setData({ top: app.globalData.statusBarHeight, hgt: app.globalData.titleBarHeight, imgUrl: app.globalData.imgUrl, }) if(options.type){ this.setData({ type:options.type }) } 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 < arr.length; i++) { let arr1 = arr[i].split('='); obj[arr1[0]] = arr1[1]; } if (obj.g) { that.setData({ cid: obj.a, shareid: obj.u, isBroker: true, agid: obj.g }) app.globalData.clientype = obj.c; app.globalData.shareuserid = obj.u; app.globalData.brokeruserId = obj.g; } else { that.setData({ cid: obj.cid, shareid: obj.uid }) app.globalData.clientype = obj.ctp; app.globalData.shareuserid = obj.uid; } } else { that.setData({ cid: options.cid, shareid: options.uid }) if (!!options.agid) { that.setData({ isBroker: true, agid: options.agid }) app.globalData.brokeruserId = options.agid; } app.globalData.clientype = options.ctp; app.globalData.shareuserid = options.uid; } this.login(); }, dothis(){}, 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.companyobj=res.data.data; app.globalData.sharempid = res.data.data.employee_id; that.setData({ companyobj: res.data.data }) } }, complete(res) { wx.hideLoading() } }) }, login: function () { var that = this; wx.login({ success: function (data) { if (data.errMsg == 'login:ok') { utils.$post({ url: app.globalData.webUrl + 'api/users/code2sessionmini', data: { code: data.code, share: app.globalData.shareuserid, client_type:app.globalData.clientype, share_agent_id: app.globalData.brokeruserId }, success: function (r) { if (r.data.code == '0') { app.globalData.sharepersonobj = r.data.share; app.globalData.token = r.data.token; that.sharecompany(); if (r.data.share) { app.globalData.vrString = r.data.share.str; } that.setData({ sharepersonMsg: app.globalData.sharepersonobj, }) 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({ fPhone: r.data.user.phone, articlelogin: true, loginFlag: false, phoneFlag: false, 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; } var obj = { detail: 1 } that.casemsgfun(obj); } else { that.casemsgfun(); wx.hideLoading(); that.setData({ loginFlag: false, articlelogin: false, phoneFlag: true }) } } else { setTimeout(function () { wx.hideLoading() }, 500) } } }) } } }) }, cancelGetPhone() { designTimer = setTimeout(() => { this.setData({ designPlan: true }) },4000) }, designertap(){ if(!!this.data.casemsgobj.designer_id){ wx.navigateTo({ url: '/share/pages/designermsg/designermsg?did='+this.data.casemsgobj.designer_id+"&type=3" }) } }, presharelooktap() { 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链接列表 }) }, setypetap(e) { this.setData({ ctype: e.currentTarget.dataset.type }) }, swiperChange (e) { let type = e.detail.currentItemId.split('-')[0]; this.setData({ activeType: type }) }, prelooktap(e){ let arr=[]; for(let i in this.data.imgarr){ arr.push(app.globalData.imgUrl+this.data.imgarr[i].img); } wx.previewImage({ current: e.currentTarget.dataset.img, // 当前显示图片的 http 链接 urls: arr // 需要预览的图片 http 链接列表 }) }, /** * 前往个人名片 */ toPageNameCard() { wx.navigateTo({ url: '/share/pages/shareCard/shareCard?uid='+ app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.sharempid + '&ftype=share', }) }, golastap: function () { wx.navigateBack({ delta: 1, success:function(r){ }, fail:function(r){ wx.reLaunch({ url: '/pages/index/index?state=1', }) }, }) }, goindextap:function(){ if(!this.data.employeeflag){ wx.reLaunch({ url: '/pages/index/index', }) }else{ wx.reLaunch({ url: '/pages/consoledesk/consoledesk', }) } }, callphonetap: function () { console.log() wx.makePhoneCall({ phoneNumber: app.globalData.sharepersonobj.phone //仅为示例,并非真实的电话号码 }) }, lookcasefun() { let casemsgobj = this.data.casemsgobj; casemsgobj.desccontentmsg = casemsgobj.desc; casemsgobj.realdesc = casemsgobj.real_case; this.setData({ casemsgobj: casemsgobj }) }, handleSwitch(e) { let type = e.currentTarget.dataset.type; let swiperIndex=0; if (type == 'vr') { swiperIndex = 0; } else if (type == 'video') { swiperIndex = !!this.data.casemsgobj.vr_case?1:0; } this.setData({ swiperIndex: swiperIndex, activeType: type, }) }, openVRLink(e) { let type = e.currentTarget.dataset.type; if (type == 1) { let vrlink = this.data.casemsgobj.vr_case; wx.navigateTo({ url: '/pages/other/other?type=vr&vrurl=' + escape(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.casemsgobj.id, }) } else { let aid = e.currentTarget.dataset.id; let vrlink = e.currentTarget.dataset.vrlink; wx.navigateTo({ url: '/pages/other/other?type=vr&vrurl=' + escape(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&aid=' + aid, }) } }, hiddenMaskFunc() { this.setData({ showMask: false }) }, getPhoneNumberTap: function (res) { var that = this; let type = res.currentTarget.dataset.type; if (type != 'broker') { that.lookcasefun(); } if (res.detail.errMsg == 'getPhoneNumber:ok') { if (designTimer) { clearTimeout(designTimer); } 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') { that.setData({ fPhone: r.data.mobile, }) if (type == 'broker') { that.setData({ showMask: true }) return false; } if (res.currentTarget.dataset.type == 'price') { that.setData({ phoneFlag: false, designPlan: false }) return; } if(res.currentTarget.dataset.type==1){ wx.showToast({ title: '预约成功!', icon: 'none', duration: 2000 }) } that.orderfun(); app.globalData.phone = true; that.setData({ phoneFlag: false, webUrl: app.globalData.webUrl, articlelogin: true, designPlan: false }) } else { that.setData({ errorText: r.data.msg, errorflag: true }) } } }) } else { this.setData({ showMask: true }) } }, orderfun() { const that = this; utils.$post({ url: app.globalData.webUrl + 'client/material/designer_reserve', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id:that.data.cid, designer_id:that.data.casemsgobj.designer_id?that.data.casemsgobj.designer_id:'', type:'materialCase', share_uid:app.globalData.shareuserid }, success: function (res) { if (res.data.code == '0') { wx.showToast({ title: res.data.msg, icon: "none", duration: 2000 }); } } }) }, casefun: function () { this.casemsgfun(); }, casemsgfun: function (type) { var that = this; if (!!type && type.detail == '1') { that.setData({ articlelogin: true, phoneFlag: false, }) } utils.$get({ url: app.globalData.webUrl + 'client/casedetail', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: this.data.cid }, success: function (res) { setTimeout(function () { wx.hideLoading() }, 500) let tab=that.data.tab; if (res.data.code == '0') { if(!!res.data.data.video_case){ tab[1].count=1; that.setData({ tab: tab, activeType:'video' }) } if(!!res.data.data.vr_case){ tab[0].count=1; that.setData({ tab: tab, activeType:'vr' }) } var article = res.data.data.desc,realdesc=res.data.data.real_case; if (!!type && type.detail == '1') { article = res.data.data.desc; realdesc=res.data.data.real_case; } else { let length = res.data.data.desc.length; article = res.data.data.desc.substring(0, length); let len = res.data.data.real_case.length; realdesc=res.data.data.real_case.substring(0, len); } res.data.data.desccontentmsg = article; res.data.data.realdesc=realdesc; if (!res.data.data.desc) { if (!res.data.data.real_case) { that.setData({ ctype: '' }) } else { that.setData({ ctype: 2 }) } } else { if (res.data.data.desc != '