// index/pages/casemsg/casemsg.js const app = getApp(); var utils = require("../../utils/http") Page({ /** * 页面的初始数据 */ data: { top: app.globalData.statusBarHeight, hgt: app.globalData.titleBarHeight, imgUrl: app.globalData.imgUrl, companyobj: app.globalData.companyobj, communityht: '', cid: '', casemsgobj: {}, page: 1, shareid: '', loginFlag: true, mobileflag: false, canIUseGetUserProfile: false, contentmsg: '', articlelogin: true, datashow: false, mobile: false, personMsg: app.globalData.personMsg, caselist: [], leftcaselist: [], rightcaselist: [], sharepersonMsg: app.globalData.sharepersonobj, employeeflag: false, //false是用户,true是员工 showAddress: false, imgarr: [], type: '',//为空就是从微官网进来的,否则就是从工具中进来 ctype: '', priceflag: false, swiperIndex:0, tab: [{ name: 'VR案例', type: 'vr', count: 0 }, { name: '视频案例', type: 'video', count: 0 }], activeType: '', }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; wx.showLoading({ title: '加载中...', }) if (!!options.scene && !that.data.cid) { 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]; } this.setData({ cid: obj.cid, }) app.globalData.clientype = obj.cli; that.logindata(); } else { this.setData({ cid: options.cid, companyobj: app.globalData.companyobj, employeeflag: (!!app.globalData.personMsg.binded && app.globalData.personMsg.binded.state == '在职') ? true : false }) that.casemsgfun('1'); } if (options.type) { this.setData({ type: options.type }) } this.setData({ personMsg: app.globalData.personMsg, sharepersonMsg: app.globalData.sharepersonobj, top: app.globalData.statusBarHeight, hgt: app.globalData.titleBarHeight, imgUrl: app.globalData.imgUrl, companyobj: app.globalData.companyobj, }) wx.showLoading({ title: '加载中...', }) }, logindata: function () { var that = this; wx.showLoading(); wx.login({ success: function (data) { if (data.errMsg == 'login:ok') { utils.$post({ url: app.globalData.webUrl + 'api/users/code2session', data: { client_type: that.data.clientype, code: data.code, }, success: function (r) { if (r.data.code == '0') { app.globalData.sharepersonobj = r.data.share; app.globalData.token = r.data.token; that.sharecompany(); that.casemsgfun('1'); if (r.data.user != null && (!!r.data.user.headimgurl && r.data.user.headimgurl != "" || !!r.data.user.nickname && r.data.user.nickname != "" && r.data.user.nickname != '游客')) { app.globalData.use_id = r.data.user.id; app.globalData.personMsg = r.data.user; app.globalData.userflag = false; //有个人信息 var nickname = r.data.user.nickname; var phone = r.data.user.phone; that.setData({ loginFlag: true, datashow: true, }) if (r.data.user.phone != '') { app.globalData.personMsg = r.data.user; that.setData({ mobileflag: false }) } else { that.setData({ phoneFlag: true }) } } else { wx.hideLoading(); that.setData({ articlelogin: false, loginFlag: false }) } } else { wx.hideLoading(); that.setData({ articlelogin: false, loginFlag: true }) } } }) } else { wx.hideLoading(); that.setData({ articlelogin: false, loginFlag: true }) } } }) }, designertap(){ if(!!this.data.casemsgobj.designer_id){ if(this.data.type){ wx.navigateTo({ url: '/customer/pages/designermsg/designermsg?did='+this.data.casemsgobj.designer_id+"&sid="+this.data.casemsgobj.designer_id+'&type=1' }) }else{ wx.navigateTo({ url: '/share/pages/designermsg/designermsg?did='+this.data.casemsgobj.designer_id+"&type=3" }) } } }, 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; app.globalData.companyobj=res.data.data; that.setData({ companyobj: res.data.data }) } }, complete(res) { wx.hideLoading() } }) }, phonrtap: function () { wx.makePhoneCall({ phoneNumber: app.globalData.sharepersonobj.phone //仅为示例,并非真实的电话号码 }) }, priceshowtap() { this.setData({ priceflag: true }) }, swiperChange (e) { let type = e.detail.currentItemId.split('-')[0]; this.setData({ activeType: type }) }, closepricetap() { this.setData({ priceflag: false }) }, setypetap(e) { this.setData({ ctype: e.currentTarget.dataset.type }) }, prelookimgtap() { 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链接列表 }) }, pricetap: function () { wx.navigateTo({ url: '/customer/pages/figureprice/figureprice', }) }, designTap: function () { wx.navigateTo({ url: '/customer/pages/findesign/findesign', }) }, 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=565&vrlink=' + encodeURIComponent(vrlink) + '&cty=materialCase' + '&uid=' + (app.globalData.shareuserid?app.globalData.shareuserid:app.globalData.personMsg.id) + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.casemsgobj.id, }) } else { let vrlink = e.currentTarget.dataset.vrlink; let aid = e.currentTarget.dataset.id; wx.navigateTo({ url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&cty=materialCase' + '&uid=' + (app.globalData.shareuserid?app.globalData.shareuserid:app.globalData.personMsg.id) + '&ctp=' + app.globalData.clientype + '&aid=' + aid, }) } }, casemsgfun: function (type) { var that = this; utils.$get({ url: app.globalData.webUrl + 'client/casedetail', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: that.data.cid }, success: function (res) { setTimeout(function () { wx.hideLoading() }, 500) let tab=that.data.tab; if (res.data.code == '0') { wx.setNavigationBarTitle({ title: res.data.data.title }) 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 != '