buildShare.js 11 KB

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