other.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. // pages/other/other.js
  2. var app = getApp();
  3. const utils = require("../../utils/http");
  4. const util = require("../../utils/util");
  5. var time = 0;
  6. var timer = null;
  7. let title='',imgurl='';
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. webUrl: '',
  14. clientype: app.globalData.clientype,
  15. type:'1',//1是小红屋,2是酷家乐,3是建额全景,剩下的是其他
  16. companyobj:{},
  17. personobj:{},
  18. canIUseGetUserProfile:false,
  19. loginFlag:false,
  20. vrType: '',
  21. aid: '',
  22. imgUrl: app.globalData.imgUrl,
  23. platform:'windows'
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad: function (options) {
  29. time = 0;
  30. if (wx.getUserProfile) {
  31. this.setData({
  32. canIUseGetUserProfile: true
  33. })
  34. }
  35. if(options.type=='vr'){
  36. app.globalData.clientype=options.ctp;
  37. app.globalData.shareuserid = options.uid;
  38. this.login();
  39. }
  40. if (!!options.aid) {
  41. this.setData({
  42. aid: options.aid
  43. })
  44. }
  45. if (!!options.cty) {
  46. this.setData({
  47. vrType: options.cty
  48. })
  49. }
  50. if (options.type == '21' || options.type == '23') {//新客户
  51. this.setData({
  52. webUrl: app.globalData.webUrl + 'applet.html#/customerMsg?token=' + app.globalData.token + '&cid=' + options.vid + '&client_type=' + app.globalData.clientype+"&platform="+app.globalData.platform,
  53. })
  54. } else if (options.type == '22') {//共有客户
  55. this.setData({
  56. webUrl: app.globalData.webUrl + 'applet.html#/client?token=' + app.globalData.token + '&orgid=' + app.globalData.personMsg.binded.org_id + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  57. })
  58. } else if (options.type == '3') {//共有客户
  59. this.setData({
  60. webUrl: app.globalData.webUrl + 'applet.html#/workReport?token=' + app.globalData.token + '&type=' + (options.state ? options.state : '') + '&orgid=' + app.globalData.personMsg.binded.org_id + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id+"&platform="+app.globalData.platform,
  61. })
  62. } else if (options.type == '2') {
  63. this.setData({
  64. webUrl: options.content,
  65. clientype: app.globalData.clientype,
  66. })
  67. } else if (options.type == '4') {
  68. // 日报详情
  69. this.setData({
  70. webUrl: app.globalData.webUrl + 'applet.html#/dailyDetail?token=' + app.globalData.token + '&id=' + options.did + '&type=' + 'sendout' + '&orgid=' + app.globalData.personMsg.binded.org_id + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  71. })
  72. }
  73. else if (options.type == '88') {
  74. this.setData({
  75. webUrl: app.globalData.webUrl + 'applet.html#/customermsg?token=' + app.globalData.token + "&aid=" + options.aid + "&cid=" + options.cid + '&client_type=' + app.globalData.clientype+"&platform="+app.globalData.platform
  76. })
  77. } else if (options.type == '11') {
  78. this.setData({
  79. webUrl: app.globalData.webUrl + 'applet.html#/trainmsg?token=' + app.globalData.token + '&tid=' + options.tid + '&client_type=' + app.globalData.clientype
  80. })
  81. } else if (options.type == '48') {//共有客户
  82. wx.setNavigationBarColor({
  83. frontColor: '#ffffff',
  84. backgroundColor: '#2376FF',
  85. })
  86. this.setData({
  87. webUrl: app.globalData.webUrl + 'applet.html#/custmanage?token=' + app.globalData.token + '&orgid=' + app.globalData.personMsg.binded.org_id + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  88. })
  89. } else if (options.type == '32') {
  90. this.setData({
  91. webUrl: app.globalData.webUrl + 'applet.html#/trainCamp?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id
  92. })
  93. } else if (options.type == '77') {
  94. this.setData({
  95. webUrl: app.globalData.webUrl + 'applet.html#/recycle?token=' + app.globalData.token + '&orgid=' + app.globalData.personMsg.binded.org_id + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  96. })
  97. wx.setNavigationBarColor({
  98. backgroundColor: '#249efb',
  99. frontColor: '#ffffff',
  100. })
  101. } else if (options.type == '29') {
  102. this.setData({
  103. webUrl: app.globalData.webUrl + 'applet.html#/joinCustomer?token=' + app.globalData.token + '&actid=' + options.actid + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  104. })
  105. } else if (options.type == '63') {
  106. this.setData({
  107. webUrl: app.globalData.webUrl + 'applet.html#/winPrize?token=' + app.globalData.token + '&actid=' + options.actid + '&client_type=' + app.globalData.clientype,
  108. })
  109. } else if (options.type == '9') {
  110. this.setData({
  111. webUrl: app.globalData.webUrl + 'applet.html#/designerlist?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype,
  112. })
  113. } else if (options.type == '111') {
  114. // vr
  115. this.setData({
  116. webUrl: app.globalData.vraddress,
  117. })
  118. } else if (options.type == '121') {
  119. this.setData({
  120. webUrl: app.globalData.webUrl + 'applet.html#/collage?token=' + app.globalData.token + '&orgid=' + app.globalData.personMsg.binded.org_id + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  121. })
  122. } else if (options.type == 'vr') {
  123. // vr
  124. wx.hideHomeButton()
  125. let str = unescape(options.vrurl);
  126. this.setData({
  127. webUrl: str,
  128. })
  129. } else if (options.type == '818') {
  130. this.setData({
  131. webUrl: app.globalData.webUrl + 'applet.html#/fiveDimensions?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype + '&empid=' + options.empid,
  132. })
  133. } else if (options.type == '919') {
  134. this.setData({
  135. webUrl: app.globalData.webUrl + 'applet.html#/overdue?token=' + app.globalData.token + '&orgid=' + app.globalData.personMsg.binded.org_id + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  136. })
  137. } else if (options.type == 'screen') {
  138. wx.setNavigationBarColor({
  139. backgroundColor: '#C40909',
  140. frontColor: '#ffffff',
  141. })
  142. this.setData({
  143. webUrl: app.globalData.webUrl + 'applet.html#/wbmanage?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  144. })
  145. } else if (options.type == "565") {
  146. // vr
  147. wx.hideHomeButton()
  148. let vrlink = decodeURIComponent(options.vrlink)
  149. this.setData({
  150. webUrl: vrlink,
  151. })
  152. } else if (options.type == '999') {
  153. wx.setNavigationBarColor({
  154. frontColor: '#ffffff',
  155. backgroundColor: '#191c23',
  156. })
  157. this.setData({
  158. webUrl: app.globalData.webUrl + 'applet.html#/medal?token=' + app.globalData.token + '&orgid=' + app.globalData.personMsg.binded.org_id + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  159. })
  160. } else if (options.type == '525') {
  161. this.setData({
  162. webUrl: app.globalData.webUrl + 'applet.html#/addReport?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype,
  163. })
  164. } else if (options.type == '656') {
  165. wx.setNavigationBarColor({
  166. frontColor: '#ffffff',
  167. backgroundColor: '#249efb',
  168. })
  169. this.setData({
  170. webUrl: app.globalData.webUrl + 'applet.html#/brokerModule?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  171. })
  172. } else if (options.type == '2277') {
  173. wx.setNavigationBarColor({
  174. frontColor: '#ffffff',
  175. backgroundColor: '#249efb',
  176. })
  177. this.setData({
  178. webUrl: app.globalData.webUrl + 'applet.html#/integral?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype + '&brokerId=' + app.globalData.brokeruserId,
  179. })
  180. } else if (options.type == '5566') {
  181. wx.setNavigationBarColor({
  182. frontColor: '#ffffff',
  183. backgroundColor: '#249efb',
  184. })
  185. this.setData({
  186. webUrl: app.globalData.webUrl + 'applet.html#/brokerDetail?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id + '&brokerId=' + options.cid,
  187. })
  188. } else if (options.type == '13') {
  189. wx.setNavigationBarColor({
  190. frontColor: '#ffffff',
  191. backgroundColor: '#249efb',
  192. })
  193. this.setData({
  194. webUrl: app.globalData.webUrl + 'applet.html#/sharestatistics?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype,
  195. })
  196. } else if (options.type == '987') {
  197. this.setData({
  198. webUrl: app.globalData.webUrl + 'applet.html#/buildinglist?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype +"&platform="+app.globalData.platform,
  199. })
  200. } else if (options.type == '090') {
  201. this.setData({
  202. webUrl: app.globalData.webUrl + 'applet.html#/publicQr?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype +"&platform="+app.globalData.platform,
  203. })
  204. }else if (options.type == '-87') {//未到访
  205. wx.setNavigationBarColor({
  206. frontColor: '#ffffff',
  207. backgroundColor: '#249efb',
  208. })
  209. this.setData({
  210. webUrl: app.globalData.webUrl + 'applet.html#/crmnotice?token=' + app.globalData.token + '&orgid=' + app.globalData.personMsg.binded.org_id + '&client_type=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id+'&time='+options.time,
  211. })
  212. }
  213. this.setype();
  214. },
  215. sharecompany: function () {
  216. const that = this;
  217. utils.$post({
  218. url: app.globalData.webUrl + 'client/index/content_belong_company',
  219. header: {
  220. 'Authorization': 'bearer ' + app.globalData.token
  221. },
  222. data: {
  223. client_type: app.globalData.clientype,
  224. uid: app.globalData.shareuserid
  225. },
  226. success: function (res) {
  227. if (res.data.code == '0') {
  228. app.globalData.currentUserId = res.data.data.employee_id || '';
  229. app.globalData.companyobj=res.data.data;
  230. that.setData({
  231. companyobj: res.data.data
  232. })
  233. that.geTitle();
  234. }
  235. },
  236. complete(res) {
  237. wx.hideLoading()
  238. }
  239. })
  240. },
  241. login: function () {
  242. var that = this;
  243. wx.login({
  244. success: function (data) {
  245. if (data.errMsg == 'login:ok') {
  246. utils.$post({
  247. url: app.globalData.webUrl + 'api/users/code2session',
  248. data: {
  249. code: data.code,
  250. share: app.globalData.shareuserid,
  251. client_type:app.globalData.clientype
  252. },
  253. success: function (r) {
  254. if (r.data.code == '0') {
  255. app.globalData.sharepersonobj = r.data.share;
  256. app.globalData.companyobj = r.data.company_data;
  257. that.setData({
  258. companyobj: r.data.company_data,
  259. personobj:r.data.share
  260. })
  261. that.sharecompany();
  262. that.vrFooterRecord();
  263. 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!='游客')) {
  264. that.setData({
  265. loginFlag: false,
  266. })
  267. app.globalData.personMsg = r.data.user;
  268. app.globalData.userflag = false; //有个人信息
  269. wx.hideLoading();
  270. }
  271. }
  272. }
  273. })
  274. }
  275. }
  276. })
  277. },
  278. /**
  279. * vr获取足迹
  280. */
  281. vrFooterRecord() {
  282. var that = this;
  283. utils.$post({
  284. url: app.globalData.webUrl + 'client/material/vrfootprints',
  285. data: {
  286. type: that.data.vrType,
  287. id: that.data.aid
  288. },
  289. header: {
  290. 'Authorization':'bearer '+app.globalData.token
  291. },
  292. success: function (r) {
  293. console.log(r,'<<<<<dsf')
  294. if(r.data.code=='0'){
  295. }
  296. }
  297. })
  298. },
  299. setype(){
  300. let webUrl=this.data.webUrl;
  301. let redurltest='https://hnweizhihui.xiaohongwu.com';
  302. let kjlurltest="https://pano337.p.kujiale.com";
  303. let jeajurltest="https://vr-17.justeasy.cn";
  304. let jeajurltest1="https://vr.justeasy.cn";
  305. if(webUrl.substr(0, 34)==redurltest){
  306. this.setData({
  307. type:1,
  308. platform:app.globalData.platform,
  309. })
  310. this.geTitle();
  311. }
  312. if(webUrl.substr(0, 29)==kjlurltest){
  313. this.setData({
  314. type:2,
  315. platform:app.globalData.platform,
  316. })
  317. this.geTitle();
  318. }
  319. if(webUrl.substr(0, 25)==jeajurltest||webUrl.substr(0, 22)==jeajurltest1){
  320. this.setData({
  321. type:3,
  322. platform:app.globalData.platform,
  323. })
  324. this.geTitle();
  325. }
  326. if (webUrl.substr(0, 29)!=kjlurltest && webUrl.substr(0, 34)!=redurltest&& webUrl.substr(0, 25)!=jeajurltest&&webUrl.substr(0, 22)!=jeajurltest1) {
  327. this.setData({
  328. type:'',
  329. platform:''
  330. })
  331. wx.hideShareMenu({
  332. menus: ['shareAppMessage', 'shareTimeline']
  333. })
  334. }
  335. },
  336. /**
  337. * 生命周期函数--监听页面初次渲染完成
  338. */
  339. onReady: function () {
  340. },
  341. callphonetap(){
  342. wx.makePhoneCall({
  343. phoneNumber: this.data.personobj.phone
  344. })
  345. },
  346. toPageNameCard() {
  347. wx.navigateTo({
  348. url: '/share/pages/shareCard/shareCard?uid=' + (app.globalData.shareuserid?app.globalData.shareuserid:this.data.personobj.id)+ '&empid=' + (app.globalData.currentUserId?app.globalData.currentUserId:this.data.personobj.binded.id) + '&ctp=' + app.globalData.clientype + '&ftype=share',
  349. })
  350. },
  351. prelookimgtap() {
  352. let personobj=this.data.personobj;
  353. let qrcode='';
  354. if(!!personobj.qrcode){
  355. qrcode=personobj.qrcode;
  356. }else if(!!personobj.binded.qrcode){
  357. qrcode=personobj.binded.qrcode;
  358. }
  359. if (!qrcode) {
  360. wx.showToast({
  361. title: "当前装修顾问的二维码为空!",
  362. icon: 'none',
  363. duration: 2000
  364. })
  365. return false;
  366. }
  367. wx.previewImage({
  368. current: app.globalData.imgUrl + qrcode, // 当前显示图片的http链接
  369. urls: [app.globalData.imgUrl + qrcode]// 需要预览的图片http链接列表
  370. })
  371. },
  372. getPhoneNumberTap:function(res){
  373. var that=this;
  374. if(res.detail.errMsg=='getPhoneNumber:ok'){
  375. utils.$post({
  376. url: app.globalData.webUrl + 'api/users/setUserMobile',
  377. data: {
  378. encryptedData:res.detail.encryptedData,
  379. iv:res.detail.iv
  380. },
  381. header: {
  382. 'Authorization':'bearer '+app.globalData.token
  383. },
  384. success: function (r) {
  385. if(r.data.code=='0'){
  386. that.signup(r.data.mobile);
  387. }else{
  388. that.setData({
  389. errorText:r.data.msg,
  390. errorflag:true
  391. })
  392. }
  393. }
  394. })
  395. }
  396. },
  397. signup:function(mobile){
  398. const that=this;
  399. utils.$post({
  400. url: app.globalData.webUrl + 'client/index/signUp',
  401. data: {
  402. name:'',
  403. remark:'',
  404. mobile:mobile,
  405. type:that.data.vrType+'Vr',
  406. id: that.data.aid,
  407. },
  408. header: {
  409. 'Authorization':'bearer '+app.globalData.token
  410. },
  411. success: function (r) {
  412. if(r.data.code=='0'){
  413. wx.showToast({
  414. title: '恭喜您报名成功',
  415. icon:'none'
  416. })
  417. }
  418. }
  419. })
  420. },
  421. /**
  422. * 生命周期函数--监听页面显示
  423. */
  424. onShow: function () {
  425. timer = setInterval(function () {
  426. time = (time * 1) + 1;
  427. }, 1000)
  428. if(JSON.stringify(app.globalData.sharepersonobj) != "{}"&&!!app.globalData.sharepersonobj){
  429. this.setData({
  430. personobj:app.globalData.sharepersonobj
  431. })
  432. }else if(JSON.stringify(app.globalData.personMsg) != "{}"){
  433. var obj=app.globalData.personMsg;
  434. obj.name=app.globalData.personMsg.binded.name;
  435. this.setData({
  436. personobj:obj
  437. })
  438. }
  439. this.setData({
  440. companyobj:app.globalData.companyobj,
  441. imgUrl: app.globalData.imgUrl,
  442. })
  443. },
  444. /**
  445. * 生命周期函数--监听页面隐藏
  446. */
  447. onHide: function () {
  448. if (timer) {
  449. clearInterval(timer);
  450. }
  451. if (!!this.data.aid) {
  452. this.visitimefun();
  453. }
  454. },
  455. visitimefun() {
  456. const that = this;
  457. utils.$post({
  458. url: app.globalData.webUrl + 'client/index/visit_due_time',
  459. header: {
  460. 'Authorization': 'bearer ' + app.globalData.token
  461. },
  462. data: {
  463. id: that.data.aid,
  464. pipe_type: that.data.vrType+'Vr',
  465. time: time,
  466. },
  467. success: function (res) {
  468. console.log(res,'<<<<<');
  469. }
  470. })
  471. },
  472. /**
  473. * 生命周期函数--监听页面卸载
  474. */
  475. onUnload: function () {
  476. if (!!this.data.aid) {
  477. this.visitimefun();
  478. }
  479. },
  480. /**
  481. * 页面相关事件处理函数--监听用户下拉动作
  482. */
  483. onPullDownRefresh: function () {
  484. },
  485. /**
  486. * 页面上拉触底事件的处理函数
  487. */
  488. onReachBottom: function () {
  489. },
  490. geTitle(){
  491. if(this.data.vrType=='company'){
  492. title="在线逛展厅-"+app.globalData.companyobj.company_name;
  493. imgurl=app.globalData.imgUrl + 'xcx/aaa/vrcover.png';
  494. }else if(this.data.vrType=='employeeCard'){
  495. title=app.globalData.companyobj.company_name+'VR寻址';
  496. imgurl=app.globalData.imgUrl+"/xcx/sharenamecard.png";
  497. }else if(this.data.vrType=='materialCase'){
  498. utils.$get({
  499. url: app.globalData.webUrl + 'client/casedetail',
  500. header: {
  501. 'Authorization': 'bearer ' + app.globalData.token
  502. },
  503. data: {
  504. id: this.data.aid,
  505. share:'146'
  506. },
  507. success: function (res) {
  508. if (res.data.code == '0') {
  509. title=res.data.data.title+'的VR';
  510. imgurl=res.data.data.cover_img;
  511. }
  512. }
  513. })
  514. }else if(this.data.vrType=='building'){
  515. utils.$get({
  516. url: app.globalData.webUrl + 'client/building/view',
  517. header: {
  518. 'Authorization': 'bearer ' + app.globalData.token
  519. },
  520. data: {
  521. id: this.data.aid,
  522. share:'146'
  523. },
  524. success: function (res) {
  525. if (res.data.code == '0') {
  526. title=res.data.data.name+'的VR';
  527. imgurl=res.data.data.cover;
  528. }
  529. }
  530. })
  531. }else if(this.data.vrType=='construction'){
  532. utils.$post({
  533. url: app.globalData.webUrl + 'client/construction/view',
  534. header: {
  535. 'Authorization': 'bearer ' + app.globalData.token
  536. },
  537. data: {
  538. id: this.data.aid,
  539. share:'146'
  540. },
  541. success: function (res) {
  542. if (res.data.code == '0') {
  543. title=res.data.data.name+'的VR';
  544. imgurl=res.data.data.cover;
  545. }
  546. }
  547. })
  548. }
  549. },
  550. addsharetap: function (type) {
  551. let that = this;
  552. utils.$post({
  553. url: app.globalData.webUrl + 'api/share/addlog',
  554. header: {
  555. 'Authorization': 'bearer ' + app.globalData.token
  556. },
  557. data: {
  558. id: '0',
  559. type: type,
  560. },
  561. success: function (r) {}
  562. })
  563. },
  564. /**
  565. * 用户点击右上角分享
  566. */
  567. onShareAppMessage: function () {
  568. this.addsharetap('toolAll');
  569. let str = escape(this.data.webUrl);
  570. return {
  571. title: title,
  572. imageUrl:imgurl,
  573. path: '/pages/other/other?ctp=' + app.globalData.clientype+'&uid='+ (app.globalData.shareuserid?app.globalData.shareuserid:app.globalData.personMsg.id) + '&type=vr&vrurl=' + str + '&aid=' + this.data.aid+ '&cty='+this.data.vrType
  574. };
  575. }
  576. })