brokershareinfo.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. // customer/pages/brokershareinfo/brokershareinfo.js
  2. const app = getApp();
  3. var utils = require("../../../utils/http");
  4. var time = 0;
  5. var timer = null;
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. loginFlag: false,
  12. datashow: false,
  13. mobileflag: false,
  14. showAction: false,
  15. showdesc: false,
  16. priceflag: false,
  17. isAgree: false,
  18. imgUrl: app.globalData.imgUrl,
  19. cid: "",
  20. agid: "",
  21. shareid: "",
  22. clientype: "",
  23. fromType: "",
  24. platform: "",
  25. personMsg: {},
  26. sharepersonMsg: {},
  27. shareArticleInfo: {},
  28. companyobj: {},
  29. showMask: false,
  30. fPhone: "",
  31. type: "",
  32. xhwwidth: '',
  33. bottom: 26,
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad(options) {
  39. wx.hideHomeButton();
  40. let that = this;
  41. if (!!options.scene) {
  42. options = unescape(options.scene);
  43. let arr = options.split('&');
  44. let obj = {};
  45. for (let i = 0; i < arr.length; i++) {
  46. let arr1 = arr[i].split('=');
  47. obj[arr1[0]] = arr1[1];
  48. }
  49. that.setData({
  50. cid: obj.c,
  51. shareid: obj.u,
  52. agid: obj.ag,
  53. fromType: obj.f
  54. })
  55. app.globalData.clientype = obj.ct;
  56. app.globalData.shareuserid = obj.u;
  57. } else {
  58. if (!!options.ctp) {
  59. app.globalData.clientype = options.ctp;
  60. }
  61. if (!!options.uid) {
  62. app.globalData.shareuserid = options.uid;
  63. }
  64. if (!!options.cid) {
  65. that.setData({
  66. clientype: options.ctp,
  67. cid: options.cid,
  68. shareid: options.uid,
  69. agid: options.agid,
  70. fromType: options.f
  71. })
  72. }
  73. }
  74. },
  75. //用户同意隐私协议
  76. agreePrivacy() {
  77. this.setData({
  78. isAgree: true
  79. })
  80. this.logindata();
  81. },
  82. logindata: function () {
  83. var that = this;
  84. wx.showLoading();
  85. wx.login({
  86. success: function (data) {
  87. if (data.errMsg == 'login:ok') {
  88. utils.$post({
  89. url: app.globalData.webUrl + 'api/users/code2session',
  90. data: {
  91. client_type: that.data.clientype,
  92. code: data.code,
  93. share: app.globalData.shareuserid,
  94. share_agent_id: that.data.agid
  95. },
  96. success: function (r) {
  97. if (r.data.code == '0') {
  98. app.globalData.sharepersonobj = r.data.share;
  99. app.globalData.token = r.data.token;
  100. that.sharecompany();
  101. that.setData({
  102. sharepersonMsg: app.globalData.sharepersonobj,
  103. })
  104. if (!!r.data.user.phone) {
  105. app.globalData.use_id = r.data.user.id;
  106. app.globalData.personMsg = r.data.user;
  107. app.globalData.userflag = false; //有个人信息
  108. var nickname = r.data.user.nickname;
  109. var phone = r.data.user.phone;
  110. that.setData({
  111. fPhone: phone,
  112. loginFlag: false,
  113. datashow: true,
  114. personMsg:r.data.user,
  115. mobileflag: false,
  116. })
  117. that.getShareArticleInfo();
  118. } else {
  119. that.getShareArticleInfo();
  120. wx.hideLoading();
  121. that.setData({
  122. loginFlag: false,
  123. mobileflag: true
  124. })
  125. }
  126. }
  127. }
  128. })
  129. }
  130. wx.hideLoading();
  131. }
  132. })
  133. },
  134. presharelooktap() {
  135. if (!app.globalData.sharepersonobj.qrcode) {
  136. wx.showToast({
  137. title: "当前专属客服的二维码为空!",
  138. icon: 'none',
  139. duration: 2000
  140. })
  141. return false;
  142. }
  143. wx.previewImage({
  144. current: app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode, // 当前显示图片的http链接
  145. urls: [app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode]// 需要预览的图片http链接列表
  146. })
  147. },
  148. previewImage(e) {
  149. let index = e.currentTarget.dataset.index;
  150. wx.previewImage({
  151. urls: this.data.shareArticleInfo.file,
  152. current: this.data.shareArticleInfo.file[index]
  153. })
  154. },
  155. hiddenMaskFunc() {
  156. this.setData({
  157. showMask: false
  158. })
  159. },
  160. getPhoneNumberTap: function (res) {
  161. var that = this;
  162. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  163. utils.$post({
  164. url: app.globalData.webUrl + 'api/users/setUserMobile',
  165. data: {
  166. encryptedData: res.detail.encryptedData,
  167. iv: res.detail.iv
  168. },
  169. header: {
  170. 'Authorization': 'bearer ' + app.globalData.token
  171. },
  172. success: function (r) {
  173. if (r.data.code == '0') {
  174. that.setData({
  175. fPhone: r.data.mobile,
  176. })
  177. if (res.currentTarget.dataset.type == 'broker') {
  178. that.setData({
  179. showMask: true
  180. })
  181. if (that.data.shareArticleInfo.type == 4) {
  182. that.signUpCustomer(that.data.fPhone);
  183. }
  184. }
  185. }
  186. }
  187. })
  188. } else {
  189. this.setData({
  190. showMask: true
  191. })
  192. }
  193. },
  194. signUpCustomer(fPhone) {
  195. const that = this;
  196. utils.$post({
  197. url: app.globalData.webUrl + 'client/index/add_customer',
  198. data: {
  199. name: '',
  200. phone: fPhone,
  201. community_name: '',
  202. agent_id: that.data.agid
  203. },
  204. header: {
  205. 'Authorization': 'bearer ' + app.globalData.token
  206. },
  207. success: function (r) {
  208. if (r.data.code == '0') {
  209. wx.showToast({
  210. title: '报名成功',
  211. icon: "none",
  212. duration: 1000
  213. })
  214. }
  215. }
  216. })
  217. },
  218. viewdescFunc() {
  219. console.log(this.data.showdesc);
  220. this.data.showdesc = !this.data.showdesc;
  221. this.setData({
  222. showdesc: this.data.showdesc
  223. })
  224. },
  225. priceshowtap() {
  226. this.setData({
  227. priceflag: true
  228. })
  229. },
  230. closepricetap() {
  231. this.setData({
  232. priceflag: false
  233. })
  234. },
  235. setype(){
  236. let webUrl = "";
  237. if (this.data.shareArticleInfo.type == 4) {
  238. webUrl = this.data.shareArticleInfo.vr_group_url;
  239. } else {
  240. webUrl = this.data.shareArticleInfo.files;
  241. }
  242. let redurltest='https://hnweizhihui.xiaohongwu.nczyzs.com';//41
  243. let kjlurltest="https://pano337.p.kujiale.com";
  244. let jeajurltest="https://vr-17.justeasy.nczyzs.com";
  245. let jeajurltest1="https://vr.justeasy.nczyzs.com";
  246. let wlurltest1="https://panorama.m2m88.com";//26
  247. let wlurltest2="https://panorama.wlwno1.com";//27
  248. let nowurl="https://wzh.nczyzs.com";//22
  249. let wl360="https://vr.3d66.nczyzs.com"//26
  250. if(webUrl.substr(0, 41)==redurltest){
  251. wx.getSystemInfo({
  252. success (res) {
  253. let width=(res.windowWidth-16)*0.48;
  254. that.setData({
  255. xhwwidth:width,
  256. bottom:res.platform=='android'?'26':36
  257. })
  258. }
  259. })
  260. this.setData({
  261. type:1,
  262. platform:app.globalData.platform,
  263. })
  264. }else if(webUrl.substr(0, 29)==kjlurltest){
  265. this.setData({
  266. type:2,
  267. platform:app.globalData.platform,
  268. })
  269. }else if(webUrl.substr(0, 33)==jeajurltest||webUrl.substr(0, 30)==jeajurltest1){
  270. this.setData({
  271. type:3,
  272. platform:app.globalData.platform,
  273. })
  274. }else if(webUrl.substr(0, 26)==wlurltest1||webUrl.substr(0, 27)==wlurltest2||webUrl.substr(0, 26)==wl360){
  275. this.setData({
  276. type:4,
  277. platform:app.globalData.platform,
  278. })
  279. } else if (webUrl.substr(0, 22)==nowurl){
  280. this.setData({
  281. type:5,
  282. platform:app.globalData.platform,
  283. })
  284. }
  285. },
  286. /**
  287. * 前往个人名片
  288. */
  289. toPageNameCard() {
  290. wx.navigateTo({
  291. url: '/share/pages/shareCard/shareCard?uid='+ app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.sharempid + '&ftype=share',
  292. })
  293. },
  294. callphonetap: function () {
  295. console.log()
  296. wx.makePhoneCall({
  297. phoneNumber: app.globalData.sharepersonobj.phone //仅为示例,并非真实的电话号码
  298. })
  299. },
  300. sharecompany: function () {
  301. const that = this;
  302. utils.$post({
  303. url: app.globalData.webUrl + 'client/index/content_belong_company',
  304. header: {
  305. 'Authorization': 'bearer ' + app.globalData.token
  306. },
  307. data: {
  308. client_type: app.globalData.clientype,
  309. uid: app.globalData.shareuserid
  310. },
  311. success: function (res) {
  312. if (res.data.code == '0') {
  313. app.globalData.companyobj=res.data.data;
  314. app.globalData.sharempid = res.data.data.employee_id;
  315. that.setData({
  316. companyobj: res.data.data
  317. })
  318. }
  319. },
  320. complete(res) {
  321. wx.hideLoading()
  322. }
  323. })
  324. },
  325. cancelGetPhone() {},
  326. getShareArticleInfo() {
  327. let that = this;
  328. utils.$post({
  329. url: app.globalData.webUrl + 'client/agent/info',
  330. header: {
  331. 'Authorization': 'bearer ' + app.globalData.token
  332. },
  333. data: {
  334. article_id: that.data.cid
  335. },
  336. success: function (res) {
  337. wx.hideLoading();
  338. if (res.data.code == '0') {
  339. that.setData({
  340. shareArticleInfo: res.data.data
  341. })
  342. wx.setNavigationBarTitle({
  343. title: that.data.shareArticleInfo.title,
  344. })
  345. that.setype();
  346. }
  347. }
  348. })
  349. },
  350. dothis: function() {},
  351. visitimefun() {
  352. if (!this.data.isAgree) {
  353. return false;
  354. }
  355. const that = this;
  356. utils.$post({
  357. url: app.globalData.webUrl + 'client/index/visit_due_time',
  358. header: {
  359. 'Authorization': 'bearer ' + app.globalData.token
  360. },
  361. data: {
  362. id: that.data.cid,
  363. pipe_type: 'agentArticle',
  364. time: time,
  365. },
  366. success: function (res) {
  367. }
  368. })
  369. },
  370. /**
  371. * 生命周期函数--监听页面初次渲染完成
  372. */
  373. onReady() {
  374. },
  375. /**
  376. * 生命周期函数--监听页面显示
  377. */
  378. onShow() {
  379. time = 0;
  380. timer = setInterval(function () {
  381. time = time * 1 + 1;
  382. }, 1000)
  383. },
  384. /**
  385. * 生命周期函数--监听页面隐藏
  386. */
  387. onHide() {
  388. if (timer) {
  389. clearInterval(timer);
  390. }
  391. this.visitimefun();
  392. },
  393. /**
  394. * 生命周期函数--监听页面卸载
  395. */
  396. onUnload() {
  397. if (timer) {
  398. clearInterval(timer);
  399. }
  400. this.visitimefun();
  401. },
  402. /**
  403. * 页面相关事件处理函数--监听用户下拉动作
  404. */
  405. onPullDownRefresh() {
  406. },
  407. /**
  408. * 页面上拉触底事件的处理函数
  409. */
  410. onReachBottom() {
  411. },
  412. addsharetap: function () {
  413. let that = this;
  414. utils.$post({
  415. url: app.globalData.webUrl + 'api/agentsWork/agent_sharelog',
  416. header: {
  417. 'Authorization': 'bearer ' + app.globalData.token
  418. },
  419. data: {
  420. article_id: that.data.cid,
  421. },
  422. success: function (r) {}
  423. })
  424. },
  425. /**
  426. * 用户点击右上角分享
  427. */
  428. onShareAppMessage() {
  429. this.addsharetap();
  430. let imgUrl = '';
  431. if (this.data.shareArticleInfo.type == 1) {
  432. imgUrl = `${this.data.shareArticleInfo.file[0]}?x-oss-process=video/snapshot,t_100,f_jpg,w_200,m_fast`;
  433. } else if (this.data.shareArticleInfo.type == 3||this.data.shareArticleInfo.type == 4) {
  434. imgUrl = this.data.shareArticleInfo.file_img;
  435. } else {
  436. imgUrl = this.data.shareArticleInfo.file[0];
  437. }
  438. return {
  439. title: this.data.shareArticleInfo.title,
  440. img: imgUrl,
  441. path: "/share/pages/brokershareinfo/brokershareinfo?ctp=" + app.globalData.clientype + '&cid=' + this.data.shareArticleInfo.id + "&uid=" + app.globalData.shareuserid + '&agid=' + this.data.agid + '&f=' + this.data.fromType
  442. }
  443. }
  444. })