buildShare.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. // share/pages/buildShare/buildShare.js
  2. const app = getApp();
  3. var utils = require("../../../utils/http");
  4. var designTimer = null;
  5. var time = 0;
  6. let videoContext = null;
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. canIUseGetUserProfile: false,
  13. cid: '',
  14. loginFlag: false,
  15. phoneFlag:false,
  16. designPlan: false,
  17. employeeflag: false,
  18. isAgree: false,
  19. sharepersonMsg: {},
  20. companyobj: {},
  21. detail: {},
  22. top:app.globalData.statusBarHeight,
  23. hgt:app.globalData.titleBarHeight,
  24. playflag: 2,//1是播放中,2是暂停
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad(options) {
  30. if (!!options.scene) {
  31. options = unescape(options.scene);
  32. let arr = options.split('&');
  33. let obj = {};
  34. for (let i = 0; i < arr.length; i++) {
  35. let arr1 = arr[i].split('=');
  36. obj[arr1[0]] = arr1[1];
  37. }
  38. this.setData({
  39. cid: obj.c,
  40. clientype: obj.t
  41. })
  42. app.globalData.clientype = obj.t;
  43. app.globalData.shareuserid = obj.u;
  44. app.globalData.sharempid = obj.e;
  45. } else {
  46. if (!!options.cid) {
  47. this.setData({
  48. cid: options.cid
  49. })
  50. }
  51. if (!!options.ctp) {
  52. app.globalData.clientype = options.ctp;
  53. }
  54. if (!!options.uid) {
  55. app.globalData.shareuserid = options.uid;
  56. }
  57. }
  58. wx.hideHomeButton()
  59. },
  60. //用户同意隐私协议
  61. agreePrivacy() {
  62. this.setData({
  63. isAgree: true
  64. })
  65. wx.showLoading({
  66. title: '加载中...',
  67. })
  68. this.login();
  69. },
  70. login: function () {
  71. var that = this;
  72. wx.login({
  73. success: function (data) {
  74. if (data.errMsg == 'login:ok') {
  75. utils.$post({
  76. url: app.globalData.webUrl + 'api/users/code2session',
  77. data: {
  78. code: data.code,
  79. share: app.globalData.shareuserid,
  80. client_type: app.globalData.clientype
  81. },
  82. success: function (r) {
  83. if (r.data.code == '0') {
  84. app.globalData.sharepersonobj = r.data.share;
  85. app.globalData.token = r.data.token;
  86. that.sharecompany();
  87. if (r.data.share) {
  88. app.globalData.vrString = r.data.share.str;
  89. }
  90. that.setData({
  91. sharepersonMsg: app.globalData.sharepersonobj,
  92. })
  93. app.globalData.personMsg = r.data.user;
  94. app.globalData.companyname=r.data.company;
  95. app.globalData.official_openid = r.data.official_openid;
  96. app.globalData.agentEmployeEid = r.data.agent_employee_id;
  97. if (!!r.data.user.phone) {
  98. that.setData({
  99. loginFlag: false,
  100. phoneFlag: false,
  101. employeeflag: (!!r.data.user.binded && r.data.user.binded.state == '在职') ? true : false
  102. })
  103. app.globalData.personMsg = r.data.user;
  104. app.globalData.use_id = r.data.user.id;
  105. if (!!r.data.user.binded && r.data.user.binded.state == '在职'){
  106. app.globalData.currentUserId = r.data.user.binded.id;
  107. }
  108. app.globalData.userflag = false;//有个人信息
  109. var nickname = r.data.user.nickname;
  110. var phone = r.data.user.phone;
  111. app.globalData.phone = true;//有手机号
  112. var obj = {
  113. detail: 1
  114. }
  115. that.buildProgress(obj);
  116. } else {
  117. that.buildProgress();
  118. that.setData({
  119. loginFlag: false,
  120. phoneFlag: true
  121. })
  122. }
  123. } else {
  124. setTimeout(function () {
  125. wx.hideLoading()
  126. }, 500)
  127. }
  128. }
  129. })
  130. }
  131. }
  132. })
  133. },
  134. sharecompany: function () {
  135. const that = this;
  136. utils.$post({
  137. url: app.globalData.webUrl + 'client/index/content_belong_company',
  138. header: {
  139. 'Authorization': 'bearer ' + app.globalData.token
  140. },
  141. data: {
  142. client_type: app.globalData.clientype,
  143. uid: app.globalData.shareuserid
  144. },
  145. success: function (res) {
  146. if (res.data.code == '0') {
  147. app.globalData.companyobj=res.data.data;
  148. app.globalData.currentUserId = res.data.data.employee_id;
  149. that.setData({
  150. companyobj: res.data.data
  151. })
  152. }
  153. },
  154. complete(res) {
  155. wx.hideLoading()
  156. }
  157. })
  158. },
  159. videotap() {
  160. videoContext = this.selectComponent('#myVideo');
  161. videoContext.play();
  162. wx.showLoading()
  163. },
  164. callphonetap: function () {
  165. if (app.globalData.sharepersonobj.phone) {
  166. wx.makePhoneCall({
  167. phoneNumber: app.globalData.sharepersonobj.phone //仅为示例,并非真实的电话号码
  168. })
  169. } else {
  170. wx.makePhoneCall({
  171. phoneNumber: app.globalData.personMsg.phone//仅为示例,并非真实的电话号码
  172. })
  173. }
  174. },
  175. prelooktap(e) {
  176. let type = e.currentTarget.dataset.type;
  177. if (!app.globalData.sharepersonobj.qrcode) {
  178. let tips = type == 'inquiry' ? '未上传二维码' : '当前专属客服的二维码为空!';
  179. wx.showToast({
  180. title: tips,
  181. icon: 'none',
  182. duration: 2000
  183. })
  184. return false;
  185. }
  186. wx.previewImage({
  187. current: app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode, // 当前显示图片的http链接
  188. urls: [app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode]// 需要预览的图片http链接列表
  189. })
  190. },
  191. jumpNameCard() {
  192. wx.navigateTo({
  193. url: '/share/pages/shareCard/shareCard?uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.currentUserId + '&ftype=share'
  194. })
  195. },
  196. bindprogress() {
  197. wx.hideLoading();
  198. this.setData({
  199. playflag: 1
  200. })
  201. },
  202. buildProgress() {
  203. var that = this;
  204. utils.$get({
  205. url: app.globalData.webUrl + 'client/building/progress_detail',
  206. header: {
  207. 'Authorization': 'bearer ' + app.globalData.token
  208. },
  209. data: {
  210. id: that.data.cid,
  211. },
  212. success: function (res) {
  213. wx.hideLoading();
  214. if (res.data.code == '0') {
  215. wx.setNavigationBarTitle({
  216. title: res.data.data.building_name,
  217. })
  218. that.setData({
  219. detail: res.data.data
  220. })
  221. } else {
  222. wx.showToast({
  223. title: res.data.msg,
  224. icon: 'none',
  225. duration: 1500
  226. })
  227. }
  228. }
  229. })
  230. },
  231. previewImage(e) {
  232. wx.previewImage({
  233. current: e.currentTarget.dataset.img,
  234. urls: this.data.detail.img,
  235. })
  236. },
  237. openVRLink(e) {
  238. if (this.data.detail.type == 'group') {
  239. let vrlink = this.data.detail.show_url;
  240. wx.navigateTo({
  241. url: '/pages/other/other?type=vr&vrurl=' + escape(vrlink) + '&uid=' + app.globalData.shareuserid + '&cty=building' + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.detail.id,
  242. })
  243. } else {
  244. let vrlink = e.currentTarget.dataset.vr;
  245. wx.navigateTo({
  246. url: '/pages/other/other?type=vr&vrurl=' + escape(vrlink) + '&uid=' + app.globalData.shareuserid + '&cty=building' + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.detail.building_id,
  247. })
  248. }
  249. },
  250. visitimefun() {
  251. if (!this.data.isAgree) {
  252. return false;
  253. }
  254. const that = this;
  255. utils.$post({
  256. url: app.globalData.webUrl + 'client/index/visit_due_time',
  257. header: {
  258. 'Authorization': 'bearer ' + app.globalData.token
  259. },
  260. data: {
  261. id: that.data.cid,
  262. pipe_type: 'progressDetail',
  263. time: time,
  264. },
  265. success: function (res) {
  266. console.log(res, time, '<<<')
  267. }
  268. })
  269. },
  270. golastap: function () {
  271. wx.navigateBack({
  272. delta: 1,
  273. success:function(r){
  274. },
  275. fail:function(r){
  276. wx.reLaunch({
  277. url: '/pages/index/index?state=1',
  278. })
  279. },
  280. })
  281. },
  282. goindextap:function(){
  283. if(!this.data.employeeflag){
  284. wx.reLaunch({
  285. url: '/pages/index/index',
  286. })
  287. }else{
  288. wx.reLaunch({
  289. url: '/pages/consoledesk/consoledesk',
  290. })
  291. }
  292. },
  293. closeDesigntap(e) {
  294. if (designTimer) {
  295. clearTimeout(designTimer);
  296. }
  297. if (e.detail.type == 'success') {
  298. this.setData({
  299. designPlan: false
  300. })
  301. } else {
  302. this.setData({
  303. designPlan: false
  304. })
  305. }
  306. },
  307. /**
  308. * 生命周期函数--监听页面初次渲染完成
  309. */
  310. onReady() {
  311. },
  312. /**
  313. * 生命周期函数--监听页面显示
  314. */
  315. onShow() {
  316. time = 0;
  317. setInterval(() => {
  318. time++;
  319. }, 1000)
  320. },
  321. /**
  322. * 生命周期函数--监听页面隐藏
  323. */
  324. onHide() {
  325. this.visitimefun();
  326. },
  327. /**
  328. * 生命周期函数--监听页面卸载
  329. */
  330. onUnload() {
  331. this.visitimefun();
  332. },
  333. /**
  334. * 页面相关事件处理函数--监听用户下拉动作
  335. */
  336. onPullDownRefresh() {
  337. },
  338. /**
  339. * 页面上拉触底事件的处理函数
  340. */
  341. onReachBottom() {
  342. },
  343. /**
  344. * 用户点击右上角分享
  345. */
  346. // onShareAppMessage() {
  347. // }
  348. })