123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- // share/pages/buildShare/buildShare.js
- const app = getApp();
- var utils = require("../../../utils/http");
- var designTimer = null;
- var time = 0;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- canIUseGetUserProfile: false,
- cid: '',
- loginFlag: false,
- designPlan: false,
- employeeflag: false,
- sharepersonMsg: {},
- companyobj: {},
- detail: {}
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- if (wx.getUserProfile) {
- this.setData({
- canIUseGetUserProfile: true
- })
- }
- if (!!options.cid) {
- this.setData({
- cid: options.cid
- })
- }
- 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;
- that.sharecompany();
- that.setData({
- sharepersonMsg: app.globalData.sharepersonobj,
- })
- 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({
- loginFlag: 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;
- 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.setData({
- phoneFlag: true,
- })
- designTimer = setTimeout(() => {
- that.setData({
- designPlan: true
- })
- }, 3000)
- that.buildProgress();
- } else {
- app.globalData.phone = true;//有手机号
- that.setData({
- phoneFlag: false,
- })
- var obj = {
- detail: 1
- }
- that.buildProgress(obj);
- }
- } else {
- wx.hideLoading();
- that.setData({
- loginFlag: true,
- 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.companyobj=res.data.data;
- app.globalData.currentUserId = res.data.data.employee_id;
- that.setData({
- companyobj: res.data.data
- })
- }
- },
- complete(res) {
- wx.hideLoading()
- }
- })
- },
- buildProgress() {
- var that = this;
- utils.$get({
- url: app.globalData.webUrl + 'client/building/progress_detail',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.cid,
- },
- success: function (res) {
- if (res.data.code == '0') {
- wx.setNavigationBarTitle({
- title: res.data.data.building_name,
- })
- that.setData({
- detail: res.data.data
- })
- } else {
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 1500
- })
- }
- }
- })
- },
- previewImage(e) {
- wx.previewImage({
- current: e.currentTarget.dataset.img,
- urls: this.data.detail.img,
- })
- },
- openVRLink(e) {
- let vrlink = e.currentTarget.dataset.vr;
- wx.navigateTo({
- url: '/pages/other/other?type=vr&vrurl=' + escape(vrlink) + '&uid=' + app.globalData.shareuserid + '&cty=building' + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.detail.id,
- })
- },
- 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: 'progressDetail',
- time: time,
- },
- success: function (res) {
- console.log(res, time, '<<<')
- }
- })
- },
- closeDesigntap(e) {
- if (designTimer) {
- clearTimeout(designTimer);
- }
- if (e.detail.type == 'success') {
- this.setData({
- designPlan: false
- })
- } else {
- this.setData({
- designPlan: false
- })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- time = 0;
- setInterval(() => {
- time++;
- }, 1000)
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- this.visitimefun();
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- this.visitimefun();
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage() {
- // }
- })
|