123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- const app = getApp();
- var utils = require("../../../utils/http");
- const util = require("../../../utils/util");
- let page = 1,time = 0,timer = null;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- orderBuildType: 'new',
- unlogin: false,//默认未登录状态,false未登录,true登录成功,并是公司成员
- imgUrl: app.globalData.imgUrl,
- mattertype: '热装楼盘',
- datashow: false,
- buildinglist: [],
- companyobj: {},
- shareobj: {},
- page: 1,
- nowtype: '',
- nowid: '',
- nowtitle: '',
- nowimg: '',
- loginFlag: false,
- canIUseGetUserProfile: false,
- otherarr: [
- { id: 1, name: '最新', type: 'time' },
- { id: 2, name: '最热', type: 'hot' }
- ],
- type:'',//3就是从首页跳转,不显示底部
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this;
- time = 0;
- wx.hideHomeButton();
- if(options.type){
- this.setData({
- type:options.type
- })
- }
- if (wx.getUserProfile) {
- this.setData({
- canIUseGetUserProfile: true
- })
- }
- wx.showLoading({
- title: '加载中...',
- })
- 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];
- }
- app.globalData.clientype = obj.ctp;
- app.globalData.shareuserid = obj.uid;
- app.globalData.currentUserId = obj.emid;
- } else {
- app.globalData.clientype = options.ctp;
- app.globalData.shareuserid = options.uid;
- app.globalData.currentUserId = options.emid;
- }
- this.login();
- },
- /**
- * 客户授权登录
- */
- login: function () {
- var that = this;
- wx.login({
- success: function (data) {
- if (data.errMsg == 'login:ok') {
- utils.$post({
- method: "POST", //TESTAPIURL APIURL/users/auth
- 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;
- that.sharecompany();
- that.setData({
- shareobj: app.globalData.sharepersonobj
- })
- util.toolfun(5);
- 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 != '游客')) {
- that.setData({
- datashow: true,
- loginFlag: false,
- employeeflag: (!!r.data.user.binded && r.data.user.binded.state == '在职') ? true : false
- })
- app.globalData.personMsg = r.data.user;
- app.globalData.userflag = false; //有个人信息
- var nickname = r.data.user.nickname;
- var phone = r.data.user.phone;
- app.globalData.phone = false; //没有手机号
- if (r.data.user.phone == '') {
- wx.hideLoading();
- app.globalData.phone = false; //没有手机号
- that.loginbox = that.selectComponent("#loginbox");
- that.loginbox.loginfun();
- } else {
- app.globalData.phone = true; //有手机号
- }
- that.unreadMsg();
- } else {
- wx.hideLoading();
- that.setData({
- loginFlag: 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') {
- that.setData({
- companyobj: res.data.data
- })
- if (res.data.data.employee_id) {
- app.globalData.currentUserId = res.data.data.employee_id
- }
- app.globalData.companyobj=res.data.data;
- }
- },
- complete(res) {
- wx.hideLoading()
- }
- })
- },
- /**
- * 登录成功回调
- */
- unreadMsg: function () {
- this.getBuildingProgress();
- },
- /**
- * 筛选-最新|最热
- * @param {*} e
- */
- setBuildFilter(e) {
- page = 1;
- this.setData({
- orderBuildType: e.currentTarget.dataset.type
- })
- this.getBuildingProgress();
- },
- dothis: function () { },
- /**
- * 获取热装楼盘列表
- */
- getBuildingProgress() {
- var that = this;
- utils.$post({
- url: app.globalData.webUrl + 'client/building/index',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- order: that.data.orderBuildType,
- page: page,
- limit: "10",
- },
- success: function (res) {
- wx.hideLoading()
- if (res.data.code == 0) {
- res.data.data.forEach(v => {
- v.areastr = v.area_list.map(v => `${v}㎡`).join('/');
- v.update_time = v.update_time ? v.update_time.split(' ')[0] : '';
- v.duetime = v.duetime ? v.duetime.split(' ')[0] : '';
- })
- that.setData({
- buildinglist: res.data.data
- })
- }
- }
- })
- },
- /**
- * 楼盘详情
- * @param {*} e
- */
- toPageDetail(e) {
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/share/pages/buildprogress/buildprogress?type=3&cid=' + id + '&ctp=' + app.globalData.clientype + '&uid=' + app.globalData.shareuserid + '&empid=' + app.globalData.currentUserId,
- })
- },
- arrfun: function (str) {
- var that = this;
- let arr = str.split(',');
- return arr;
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- page = 1;
- timer = setInterval(function () {
- time = time * 1 + 1;
- }, 1000)
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- page = 1;
- if (timer) {
- clearInterval(timer)
- }
- this.setimetap();
- },
- setimetap(){
- const that = this;
- if(!that.data.companyobj.employee_id){
- return false;
- }
- 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 () {
- page = 1;
- this.setimetap();
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- var that = this;
- if (that.data.mattertype == '热装楼盘') {
- page = 1;
- this.getBuildingProgress();
- wx.stopPullDownRefresh();
- }
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- var that = this;
- if (that.data.mattertype == '热装楼盘') {
- var that = this;
- page = page * 1 + 1;
- utils.$post({
- url: app.globalData.webUrl + 'client/building/index',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- order: that.data.orderBuildType,
- page: page,
- limit: "10",
- },
- success: function (res) {
- wx.hideLoading()
- if (res.data.code == 0) {
- let list = that.data.buildinglist;
- res.data.data.forEach(v => {
- v.areastr = v.area_list.map(v => `${v}㎡`).join('/');
- v.update_time = v.update_time ? v.update_time.split(' ')[0] : '';
- v.duetime = v.duetime ? v.duetime.split(' ')[0] : '';
- })
- list = list.concat(res.data.data);
- that.setData({
- buildinglist: list
- })
- }
- }
- })
- }
- },
- 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 that = this;
- that.addsharetap('toolAll');
- return {
- title: "热装楼盘-"+that.data.companyobj.company_name,
- imageUrl: "https://o.nczyzs.com/xcx/aaa/buildcover.png",
- path: '/share/pages/buildinglist/buildinglist?uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&emid=' + app.globalData.currentUserId
- }
- }
- })
|