const app = getApp(), utils = require("../../utils/http"); const util = require("../../utils/util"); let casepage = 1, articlepage = 1, videopage = 1, evidencepage = 1, page = 1, time = 0, timer = null, showflag = true; Page({ /** * 页面的初始数据 */ data: { top: app.globalData.statusBarHeight, hgt: app.globalData.titleBarHeight, loginFlag: true, phoneflag: false, share_user_id: '0', topname: '', toparea: '', imgUrl: app.globalData.imgUrl, personobj: {}, casetype: [], nowcasebtn: '', caselist: [], guidetext: '', videolist: [], mobilephone: '', alertflag: false, loginform: false, canIUseGetUserProfile: false, weboffer: [], articlelist: [], type: '1', leftcaselist: [], rightcaselist: [], leftarticlelist: [], rightarticlelist: [], leftvideolist: [], rightvideolist: [], evidencelist: [], leftevidencelist: [], rightevidencelist: [], shareobj: {}, passflag: false, indextitle: '微官网', type: 'updatetime',//hot 最热, updatetime最新 indexlist: [], unfutureflag: false, companyobj: {}, nowstate: 0, datashow: false, linkType: '', paramsId: '', firstload: false, officeType: '', curId: '', prelook: '', timeline: app.globalData.timeline, jumpType: '', jumpId: "", jumpPage: "", buildingId: "", apptype: '', isCollected: "", isAgree: false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; if (options.timeline == 'share') { this.setData({ prelook: '125', timeline: app.globalData.timeline }) } if (!!options.state) { this.setData({ nowstate: options.state }) } if (!!options.type) { this.setData({ apptype: options.type }) } time = 0; if (wx.getUserProfile) { this.setData({ canIUseGetUserProfile: true }) } that.setData({ top: app.globalData.statusBarHeight, hgt: app.globalData.titleBarHeight, }) if (!!options.clientype) { app.globalData.clientype = options.clientype; if (!!options.share_user_id) { that.setData({ share_user_id: options.share_user_id }) app.globalData.shareuserid = options.share_user_id; } if (options.office_type) { that.setData({ officeType: options.office_type }) } if (options.clg) { that.setData({ isCollected: options.clg }) } if (!!options.cid) { that.setData({ curId: options.cid }) } if (!!options.jump) { this.setData({ jumpType: options.jump, jumpPage: options.page, jumpId: options.cid }) } if (!!options.bid) { this.setData({ buildingId: options.bid }) } that.login(); } else { if (!!options.scene) { let params = this.handleParams(decodeURIComponent(options.scene)); if (!!params.cli) { app.globalData.clientype = params.cli; } if (!!params.t) { that.setData({ linkType: params.t }) } if (!!params.id) { that.setData({ paramsId: params.id }) } } if (!!options.share_user_id) { that.setData({ share_user_id: options.share_user_id }) app.globalData.shareuserid = options.share_user_id; } that.login(); } }, agreePrivacy() { this.setData({ isAgree: true }); }, handleParams: function (params) { let data = {}; let p = params.split('&'); for (var i = 0; i < p.length; i++) { let p1 = p[i].split('='); data[p1[0]] = p1[1]; } return data; }, videodecoratetap: function (e) { // '/customer/pages/videodecorate/videodecorate' wx.navigateTo({ url: '/customer/pages/designerlist/designerlist' }) }, toViewBuilding() { wx.navigateTo({ url: '/share/pages/buildinglist/buildinglist?ctp=' + app.globalData.clientype + '&uid=' + app.globalData.shareuserid + '&type=3&index=1', }) }, 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链接列表 }) }, 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; } }, complete(res) { wx.hideLoading() } }) }, login: function () { var that = this; wx.showLoading({ title: '加载中...' }); 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.companyobj = r.data.company_data; app.globalData.companyname = r.data.company_data.company_name; app.globalData.token = r.data.token; app.globalData.official_openid = r.data.official_openid; app.globalData.agentEmployeEid = r.data.agent_employee_id; app.globalData.vrString = r.data.str || ""; that.setData({ companyobj: r.data.company_data }) if (!!r.data.company_data && r.data.company_data.client_type) { app.globalData.clientype = r.data.company_data.client_type; } if (!!r.data.share) { app.globalData.shareperson = r.data.share; app.globalData.sharename = r.data.share.name; app.globalData.sharepersonobj = r.data.share; that.setData({ mobilephone: r.data.share.phone, shareobj: r.data.share, indextitle: r.data.share.name ? r.data.share.name : r.data.share.nickname + '的微官网', share_user_id: r.data.share.id, }) that.sharecompany(); util.toolfun(6); } else { that.setData({ indextitle: r.data.company + '微官网', }) } that.getCurAgentName(); that.indexfun(); // phone有没有,有的话,不用授权, if (!!r.data.user.phone) { if (that.data.share_user_id) { that.setData({ share_user_id: r.data.user.id, }) } if (!r.data.share) { that.setData({ indextitle: (!!r.data.user.binded ? !r.data.user.binded.name ? r.data.user.nickname + '的' : r.data.user.binded.name + '的' : '') + '微官网' }) } if (!!r.data.user.binded && r.data.user.binded.state == '待审核') { that.setData({ passflag: true }) } else { that.setData({ passflag: false }) } app.globalData.personMsg = r.data.user; app.globalData.use_id = r.data.user.id; that.setData({ personobj: r.data.user }) that.setData({ phoneflag: false }) app.globalData.phone = true;//有手机号 that.setData({ firstload: true }) if (!!r.data.user.binded && r.data.user.binded.state == '在职' && that.data.nowstate != 1) { app.globalData.currentUserId = r.data.user.binded.id; if (that.data.apptype == 1) { wx.reLaunch({ url: '/index/pages/building/building' }) } else if (that.data.apptype == 2) { wx.reLaunch({ url: '/index/pages/morecontent/morecontent' }) } else if (that.data.apptype == 3) { wx.reLaunch({ url: '/index/pages/caselist/caselist' }) } else if (that.data.apptype == 4) { wx.reLaunch({ url: '/index/pages/friendcircle/friendcircle' }) } else if (that.data.apptype == 5) {//谈单工具 wx.reLaunch({ url: '/pages/findcustomertool/findcustomertool?type=1' }) } else if (that.data.apptype == 6) {//老客转介 wx.reLaunch({ url: '/pages/findcustomertool/findcustomertool?type=2' }) } else if (that.data.apptype == 7) { wx.reLaunch({ url: '/index/pages/school/school?type=121' }) } else if (that.data.apptype == 8) { wx.reLaunch({ url: '/index/pages/school/school?type=212' }) } else if (that.data.apptype == 9) { wx.reLaunch({ url: '/index/pages/school/school?type=313' }) } else if (that.data.apptype == 10) {//客户报备 wx.reLaunch({ url: '/mycustomer/pages/addcustomerData/addcustomerData' }) } else if (that.data.apptype == 11) {//工作汇报 wx.reLaunch({ url: "/pages/other/other?type=3" }) } else if (that.data.apptype == 12) { wx.reLaunch({ url: "/index/pages/activity/activity" }) } else if (that.data.apptype == 13) {//每日学练 wx.reLaunch({ url: "/index/pages/school/school?type=11" }) } else if (that.data.apptype == 14) {//活动扫码 wx.reLaunch({ url: "/mycustomer/pages/activitylist/activitylist" }) } else if (that.data.apptype == 15) { wx.reLaunch({ url: '/pages/other/other?type=9009' }) } else if (that.data.apptype == 16) {//楼盘上传 wx.reLaunch({ url: "/pages/other/other?type=987&bType=" }) } else if (that.data.apptype == 17) {//在施工地 wx.reLaunch({ url: '/pages/other/other?type=8992' }) } else if (that.data.apptype == 18) { wx.reLaunch({ url: '/mycustomer/pages/dragontigerrank/dragontigerrank' }) } else if (that.data.apptype == 19) {//团队管理 wx.reLaunch({ url: "/mycustomer/pages/managerdata/managerdata?type=1" }) } else if (that.data.apptype == 20) {//员工邀请 wx.reLaunch({ url: "/mycustomer/pages/managerdata/managerdata?type=5" }) } else if (that.data.apptype == 21) {//员工审核 wx.reLaunch({ url: "/mycustomer/pages/managerdata/managerdata?type=6" }) } else if (that.data.apptype == 22) {//员工画像 wx.reLaunch({ url: "/mycustomer/pages/managerdata/managerdata?type=7" }) } else if (that.data.apptype == 23) {//话术管理 wx.reLaunch({ url: "/mycustomer/pages/managerdata/managerdata?type=2" }) } else if (that.data.apptype == 24) {//资源库管理 wx.reLaunch({ url: "/mycustomer/pages/managerdata/managerdata?type=3" }) } else if (that.data.apptype == 25) {//汇报管理 wx.reLaunch({ url: "/pages/other/other?type=3&state=2" }) } else if (that.data.apptype == 26) {//考核管理 wx.reLaunch({ url: "/index/pages/testapprove/testapprove" }) } else if (that.data.apptype == 27) {//团队客户 wx.reLaunch({ url: "/pages/other/other?type=48" }) } else if (that.data.apptype == 28) {//客户回收库 wx.reLaunch({ url: "/pages/other/other?type=77" }) } else if (that.data.apptype == 29) {//内容触达 wx.reLaunch({ url: "/pages/other/other?type=13" }) } else if (that.data.apptype == 30) {//楼盘管理 wx.reLaunch({ url: "/pages/other/other?type=987&bType=1" }) } else if (that.data.apptype == 31) {//死单审核 wx.reLaunch({ url: "/pages/other/other?type=6060" }) } else if (that.data.apptype == 32) {//数据统计 wx.reLaunch({ url: "/pages/other/other?type=6886" }) } else if (that.data.jumpType == 'app') { if (that.data.jumpPage == 'building') { wx.reLaunch({ url: '/index/pages/progressdetail/progressdetail?cid=' + that.data.jumpId, }) } else if (that.data.jumpPage == 'housetype') { wx.reLaunch({ url: '/index/pages/housetype/housetype?cid=' + that.data.jumpId + '&buildId=' + that.data.buildingId, }) } else if (that.data.jumpPage == 'materialcase') { wx.reLaunch({ url: '/index/pages/casemsg/casemsg?cid=' + that.data.jumpId, }) } else if (that.data.jumpPage == 'construct') { wx.reLaunch({ url: '/customer/pages/sitemsg/sitemsg?cid=' + that.data.jumpId + '&type=2', }) } } else if (that.data.officeType) { if (that.data.officeType == 'allocation') { wx.reLaunch({ url: '/pages/customer/customer?type=1', }) } else if (that.data.officeType == 'cread') { wx.reLaunch({ url: '/mycustomer/pages/customermsg/customermsg?cid=' + that.data.curId, }) } else if (that.data.officeType == 'clue_radar') { wx.reLaunch({ url: '/mycustomer/pages/guestclues/guestclues', }) } else if (that.data.officeType == 'share_c') { wx.reLaunch({ url: '/pages/other/other?type=22', }) } } else if (r.data.camp == 1) { wx.reLaunch({ url: '/pages/other/other?type=32', }) } else if (!!that.data.linkType && !!that.data.paramsId) { setTimeout(() => { wx.navigateTo({ url: '/pages/other/other?type=11' + '&tid=' + that.data.paramsId }) }, 1000) } else if (that.data.isCollected) { that.collectJumpFun(that.data.isCollected); } else { wx.switchTab({ url: '/pages/consoledesk/consoledesk', }) } } else { if (r.data.isagent && !r.data.user.binded && that.data.nowstate != 1) { app.globalData.brokeruserId = r.data.isagent; wx.reLaunch({ url: '/customer/pages/brokerindex/brokerindex', }) } } wx.hideLoading(); } else { wx.hideLoading(); that.setData({ loginFlag: false, phoneflag: true }) app.globalData.phone = false;//没有手机号 } } } }) } } }) }, collectJumpFun(type) { switch(type) { case '1': wx.navigateTo({ url: '/index/pages/casemsg/casemsg?cid=' + this.data.curId, }) break; case '2': wx.navigateTo({ url: "/index/pages/videoshare/videoshare?vid=" + this.data.curId, }); break; case '3': wx.navigateTo({ url: "/index/pages/articleshare/articleshare?aid=" + this.data.curId, }); break; case '4': wx.navigateTo({ url: '/index/pages/companystrengthmsg/companystrengthmsg?eid=' + this.data.curId, }) break; case '5': wx.navigateTo({ url: '/index/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.curId, }) break; case '6': wx.navigateTo({ url: '/index/pages/progressdetail/progressdetail?cid=' + this.data.curId, }) break; case '7': wx.navigateTo({ url: '/customer/pages/sitemsg/sitemsg?cid=' + this.data.curId + '&type=2&ty=', }) break; case '8': wx.navigateTo({ url: '/pages/decorateguidemsg/decorateguidemsg?cid=' + this.data.curId +"&type=1" }) break; } }, callcompanytap() { if (!app.globalData.companyobj.tel) { wx.showToast({ title: '公司电话没有填写!', icon: 'none', duration: 2000 }) return false; } wx.makePhoneCall({ phoneNumber: app.globalData.companyobj.tel }) }, closetap: function () { this.setData({ passflag: false, unfutureflag: false }) }, setitletap: function (e) { this.setData({ type: e.currentTarget.dataset.type }) if (e.currentTarget.dataset.type == 1) { this.caselistfun(); } else if (e.currentTarget.dataset.type == 2) { this.articlelist(); } else if (e.currentTarget.dataset.type == 3) { // this.videofun(); } else if (e.currentTarget.dataset.type == 4) { this.evidencefun(); } }, evidencefun: function () { const that = this; evidencepage = 1; utils.$get({ url: app.globalData.webUrl + 'client/evidencelist', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { uid: '', page: 1, cate: '', keyword: '' }, success: function (res) { wx.stopPullDownRefresh(); if (res.data.code == '0') { that.setData({ evidencelist: res.data.data, leftevidencelist: [], rightevidencelist: [], }) that.imgload(); } } }) }, imgload: function () { var that = this; var leftlist = that.data.leftevidencelist; var rightlist = that.data.rightevidencelist; var indexlist = that.data.evidencelist; if (indexlist.length == 0) { return false; } if (leftlist.length == 0) { leftlist.push(indexlist[0]); indexlist.shift(); that.setData({ evidencelist: indexlist, leftevidencelist: leftlist, rightevidencelist: rightlist }) } else { var leftheight, rightheight; const query = wx.createSelectorQuery() query.select('.leftcaselistbox').boundingClientRect(); query.exec(function (res) { leftheight = res[0].height; const queryright = wx.createSelectorQuery() queryright.select('.rightcaselistbox').boundingClientRect(); queryright.exec(function (rs) { leftlist = that.data.leftevidencelist; rightlist = that.data.rightevidencelist; indexlist = that.data.evidencelist; rightheight = rs[0].height; if (leftheight <= rightheight) { leftlist.push(indexlist[0]); indexlist.shift(); } else { rightlist.push(indexlist[0]); indexlist.shift(); } that.setData({ evidencelist: indexlist, leftevidencelist: leftlist, rightevidencelist: rightlist }) }) }) } }, indextap: function () { wx.switchTab({ url: '/pages/consoledesk/consoledesk', }) }, appointap: function () { wx.navigateTo({ url: '/pages/appoint/appoint', }) }, housestyleBtn: function () { this.setData({ unfutureflag: true }) // wx.navigateTo({ // url: "/pages/beforetest/beforetest?type=housestyle&share_user_id="+this.data.share_user_id // }); }, casetotap: function () { // '/customer/pages/decoratecase/decoratecase?share_user_id='+this.data.share_user_id, wx.navigateTo({ url: '/customer/pages/site/site' }) }, findcustomertoolTap: function (e) { wx.navigateTo({ url: '/pages/networktool/networktool?share_user_id=' + this.data.share_user_id, }) }, callphonetap: function () { wx.makePhoneCall({ phoneNumber: this.data.shareobj.phone }) }, guidetotap: function () { wx.navigateTo({ url: '/pages/decorateguide/decorateguide?share_user_id=' + this.data.share_user_id, }) }, casetap: function (e) { wx.navigateTo({ url: '/pages/decorateguidemsg/decorateguidemsg?cid=' + e.currentTarget.dataset.cid, }) }, articletap: function (e) { wx.navigateTo({ url: '/customer/pages/decoratecasemsg/decoratecasemsg?aid=' + e.currentTarget.dataset.cid }) }, figurepricetap: function () { wx.navigateTo({ url: '/customer/pages/figureprice/figureprice?share_user_id=' + this.data.share_user_id, }) }, signtap: function () { wx.navigateTo({ url: '/customer/pages/findesign/findesign?share_user_id=' + this.data.share_user_id, }) }, oldreform: function () { wx.navigateTo({ url: '/customer/pages/reform/reform?share_user_id=' + this.data.share_user_id, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function (options) { }, onPlay: function () { }, onPlayNav: function () { }, onShow: function () { this.setData({ top: app.globalData.statusBarHeight, hgt: app.globalData.titleBarHeight, timeline: app.globalData.timeline }) if (app.globalData.shareuserid) { timer = setInterval(function () { time = time * 1 + 1; }, 1000) } if (app.globalData.timeline == 2) { wx.hideLoading() } if (!showflag) { this.caseimgload(); } showflag = true; }, hotap: function () { this.setData({ type: "updatetime" }) wx.showLoading({ title: '加载中...', }) this.indexfun(); }, newtap: function () { this.setData({ type: "hot" }) wx.showLoading({ title: '加载中...', }) this.indexfun(); }, indexfun: function () { const that = this; page = 1; that.setData({ firstload: true }) utils.$get({ url: app.globalData.webUrl + 'client/index/recommend', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { page: 1, limit: 10, type: that.data.type,//hot 最热, updatetime最新 }, success: function (res) { that.setData({ datashow: true }) if (res.data.code == '0') { that.setData({ indexlist: res.data.data, leftcaselist: [], rightcaselist: [], }) } that.caseimgload(); wx.hideLoading() }, fail() { wx.hideLoading() } }) }, getCurAgentName: function () { const that = this; utils.$get({ url: app.globalData.webUrl + 'api/agents/get_agent_name', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: {}, success: function (res) { if (res.data.code == '0') { app.globalData.agentName = res.data.name; } } }) }, caseimgload: function () { var that = this; var leftcaselist = that.data.leftcaselist; var rightcaselist = that.data.rightcaselist; var indexlist = that.data.indexlist; if (indexlist.length == 0) { return false; } let casemsg = indexlist[0]; if (!casemsg) { that.setData({ indexlist: [], }) return false; } if (leftcaselist.length == 0) { leftcaselist.push(casemsg); indexlist.shift(); that.setData({ indexlist: indexlist, leftcaselist: leftcaselist, rightcaselist: rightcaselist }) } else { var leftheight, rightheight; const query = wx.createSelectorQuery() query.select('.leftcaselistbox').boundingClientRect(); query.exec(function (res) { if (!res[0]) { return false; } leftheight = res[0].height; const queryright = wx.createSelectorQuery() queryright.select('.rightcaselistbox').boundingClientRect(); queryright.exec(function (rs) { leftcaselist = that.data.leftcaselist; rightcaselist = that.data.rightcaselist; rightheight = rs[0].height; if (leftheight <= rightheight) { leftcaselist.push(casemsg); indexlist.shift(); } else { rightcaselist.push(casemsg); indexlist.shift(); } that.setData({ indexlist: indexlist, leftcaselist: leftcaselist, rightcaselist: rightcaselist }) }) }) } }, videofun: function () { var that = this; videopage = 1; utils.$post({ url: app.globalData.webUrl + 'client/video/list', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { type: '', page: 1, limit: "10", user_id: '' }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { that.setData({ videolist: res.data.data, leftvideolist: [], rightvideolist: [] }) that.videoimgload(); } } }) }, videoimgload: function () { var that = this; var leftvideolist = that.data.leftvideolist; var rightvideolist = that.data.rightvideolist; var videolist = that.data.videolist; if (videolist.length == 0) { return false; } let articlemsg = videolist[0]; if (!articlemsg) { that.setData({ videolist: [], }) return false; } if (leftvideolist.length == 0) { leftvideolist.push(articlemsg); videolist.shift(); that.setData({ videolist: videolist, leftvideolist: leftvideolist, rightvideolist: rightvideolist }) } else { var leftheight, rightheight; const query = wx.createSelectorQuery() query.select('.leftcaselistbox').boundingClientRect(); query.exec(function (res) { leftheight = res[0].height; const queryright = wx.createSelectorQuery() queryright.select('.rightcaselistbox').boundingClientRect(); queryright.exec(function (rs) { leftvideolist = that.data.leftvideolist; rightvideolist = that.data.rightvideolist; rightheight = rs[0].height; if (leftheight <= rightheight) { leftvideolist.push(articlemsg); videolist.shift(); } else { rightvideolist.push(articlemsg); videolist.shift(); } that.setData({ videolist: videolist, leftvideolist: leftvideolist, rightvideolist: rightvideolist }) }) }) } }, guidetap: function (e) { this.setData({ guidetext: e.currentTarget.dataset.type }) this.caselistfun(); }, caselistfun: function () { var that = this; casepage = 1; utils.$get({ url: app.globalData.webUrl + 'client/caselist', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { uid: '', page: 1, commu_id: '',// 小区id style_id: '',//风格id square_start: '',//面积开始值 square_end: '',//面积结束值 keyword: '' }, success: function (res) { that.setData({ datashow: true }) if (res.data.code == '0') { that.setData({ caselist: res.data.data, leftcaselist: [], rightcaselist: [], }) } that.caseimgload(); wx.hideLoading() }, fail() { wx.hideLoading() } }) }, articlelist: function () { var that = this; articlepage = 1; utils.$post({ url: app.globalData.webUrl + 'client/article/list', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { type: "", label: '', page: 1, limit: "10", keyword: '' }, success: function (res) { if (res.data.code == '0') { that.setData({ articlelist: res.data.data, leftarticlelist: [], rightarticlelist: [], }) that.articleimgload(); } } }) }, articleimgload: function () { var that = this; var leftarticlelist = that.data.leftarticlelist; var rightarticlelist = that.data.rightarticlelist; var articlelist = that.data.articlelist; if (articlelist.length == 0) { return false; } let articlemsg = articlelist[0]; if (!articlemsg) { that.setData({ articlelist: [], }) return false; } if (leftarticlelist.length == 0) { leftarticlelist.push(articlemsg); articlelist.shift(); that.setData({ articlelist: articlelist, leftarticlelist: leftarticlelist, rightarticlelist: rightarticlelist }) } else { var leftheight, rightheight; const query = wx.createSelectorQuery() query.select('.leftcaselistbox').boundingClientRect(); query.exec(function (res) { leftheight = res[0].height; const queryright = wx.createSelectorQuery() queryright.select('.rightcaselistbox').boundingClientRect(); queryright.exec(function (rs) { leftarticlelist = that.data.leftarticlelist; rightarticlelist = that.data.rightarticlelist; rightheight = rs[0].height; if (leftheight <= rightheight) { leftarticlelist.push(articlemsg); articlelist.shift(); } else { rightarticlelist.push(articlemsg); articlelist.shift(); } that.setData({ articlelist: articlelist, leftarticlelist: leftarticlelist, rightarticlelist: rightarticlelist }) }) }) } }, videomsgtap: function (e) { wx.navigateTo({ url: '/pages/networkvideo/networkvideo?vid=' + e.currentTarget.dataset.vid }) }, evitap: function (e) { wx.navigateTo({ url: '/customer/pages/publicpraisemsg/publicpraisemsg?eid=' + e.currentTarget.dataset.cid }) }, publicpraisetap: function (e) { wx.navigateTo({ url: '/customer/pages/publicpraise/publicpraise' }) }, submittap: function () { var that = this; if (that.data.loginform) { wx.showToast({ title: '不能重复报名!', icon: 'none', duration: 2000 }) return false; } if (!that.data.topname) { wx.showToast({ title: '姓名不能为空!', icon: 'none', duration: 2000 }) return false; } if (!that.data.toparea) { wx.showToast({ title: '面积不能为空!', icon: 'none', duration: 2000 }) return false; } this.applyinput(); }, getUserProfile: function () { var that = this; if (!that.data.topname) { wx.showToast({ title: '姓名不能为空!', icon: 'none', duration: 2000 }) return false; } if (!that.data.toparea) { wx.showToast({ title: '面积不能为空!', icon: 'none', duration: 2000 }) return false; } wx.getUserProfile({ lang: 'zh_CN', desc: '为了更好的体验申请获取以下信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 success: (res) => { if (res.errMsg == 'getUserProfile:ok') { utils.$post({ url: app.globalData.webUrl + 'api/users/setUserInfo', data: { encryptedData: res.encryptedData, iv: res.iv, rawData: res.rawData, signature: res.signature, }, header: { 'Authorization': 'bearer ' + app.globalData.token }, success: function (r) { if (r.data.code == '0') { that.setData({ loginFlag: false }) app.globalData.userflag = false;//有个人信息 wx.showToast({ title: '点击立即计算获取报价', icon: 'none', duration: 2000 }) } else { that.setData({ loginFlag: true }) } } }) } else { that.setData({ loginFlag: true }) } } }) }, getUserInfoTap: function (res) { var that = this; if (!that.data.topname) { wx.showToast({ title: '姓名不能为空!', icon: 'none', duration: 2000 }) return false; } if (!that.data.toparea) { wx.showToast({ title: '面积不能为空!', icon: 'none', duration: 2000 }) return false; } if (res.detail.errMsg == 'getUserInfo:ok') { utils.$post({ url: app.globalData.webUrl + 'api/users/setUserInfo', data: { encryptedData: res.detail.encryptedData, iv: res.detail.iv, rawData: res.detail.rawData, signature: res.detail.signature, }, header: { 'Authorization': 'bearer ' + app.globalData.token }, success: function (r) { if (r.data.code == '0') { that.setData({ loginFlag: false, }) app.globalData.userflag = false;//有个人信息 wx.showToast({ title: '点击立即计算获取报价', icon: 'none', duration: 2000 }) } else { that.setData({ loginFlag: true }) } } }) } else { that.setData({ loginFlag: true }) } }, getPhoneNumberTap: function (res) { var that = this; 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') { that.login(); app.globalData.phone = true; app.globalData.personMsg.phone = r.data.mobile; that.applyinput(); } } }) } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { showflag = false; if (app.globalData.shareuserid) { if (timer) { clearInterval(timer) } this.setimetap(); } }, openVRLink(e) { let vrlink = e.currentTarget.dataset.vrlink; let id = e.currentTarget.dataset.id; wx.navigateTo({ url: '/pages/other/other?type=vr&vrurl=' + escape(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&aid=' + id, }) }, setimetap() { if (!this.data.isAgree) { return false; } const that = this; utils.$post({ url: app.globalData.webUrl + 'client/index/visit_due_time', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: app.globalData.currentUserId, pipe_type: 'toolAll', time: time, }, success: function (res) { } }) }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { if (app.globalData.shareuserid) { this.setimetap(); } }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { const that = this; if (app.globalData.timeline == 2) { return false; } page = 1; this.login(); let time = setTimeout(function () { wx.stopPullDownRefresh() clearTimeout(time) }, 1000) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { const that = this; page = page + 1; wx.showLoading({ title: '加载中...', }) utils.$get({ url: app.globalData.webUrl + 'client/index/recommend', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { page: page, limit: 10, type: that.data.type,//hot 最热, updatetime最新 }, success: function (res) { if (res.data.code == '0') { let arrflag = false, indexlist = that.data.indexlist; if (indexlist.length != 0) { arrflag = true; } indexlist = indexlist.concat(res.data.data) that.setData({ indexlist: indexlist, }) if (!arrflag) { that.caseimgload(); } } wx.hideLoading() }, fail() { wx.hideLoading() } }) }, 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 () { let real = ''; wx.showShareMenu({ withShareTicket: true, menus: ['shareAppMessage', 'shareTimeline'] }) if (!!app.globalData.personMsg.binded && !!app.globalData.personMsg.binded.name) { real = app.globalData.personMsg.binded.name + '的微官网' } else { real = this.data.indextitle; } this.addsharetap('weiwang'); return { title: real, imageUrl: 'https://o.nczyzs.com/xcx/xcxweiw.jpg', path: '/pages/index/index?type=share&share_user_id=' + (this.data.share_user_id ? this.data.share_user_id : app.globalData.personMsg.id) + '&clientype=' + app.globalData.clientype + "&state=1" } }, onShareTimeline: function () { let real = ''; if (!!app.globalData.personMsg.binded && !!app.globalData.personMsg.binded.name) { real = app.globalData.personMsg.binded.name + '的微官网' } else { real = this.data.indextitle; } this.addsharetap('weiwang'); return { title: real, imageUrl: app.globalData.imgUrl + 'xcx/xcxweiw.jpg', query: 'type=share&share_user_id=' + (this.data.share_user_id ? this.data.share_user_id : app.globalData.personMsg.id) + '&clientype=' + app.globalData.clientype + "&state=1&timeline=share" } } })