1
0

setposter.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960
  1. const app = getApp();
  2. var utils = require("../../../utils/http");
  3. const util = require("../../../utils/util");
  4. let winwidth = 0, allquery = '';
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. imgUrl: app.globalData.imgUrl,
  11. personobj: app.globalData.personMsg,
  12. companyobj: app.globalData.companyobj,
  13. src: '',
  14. type: '',
  15. aid: '',
  16. cangth: 0,
  17. shareImg: '',
  18. posterimg: '',
  19. qrcodeimg: '',
  20. title: '',
  21. aType: '',
  22. listshare: false,
  23. openSet: false,
  24. vrtype: '',
  25. vrurl: '',
  26. employee_uid: "",
  27. agent_id: "",
  28. bType: "",
  29. fromType: "",
  30. qrCodelogo: ""
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad: function (options) {
  36. let that = this;
  37. this.setData({
  38. type: options.type,
  39. aid: options.aid,
  40. listshare: options.listshare ? true : false,
  41. vrtype: options.vrtype ? options.vrtype : '',
  42. vrurl: options.turl ? options.turl : ''
  43. })
  44. that.setData({
  45. personobj: app.globalData.personMsg,
  46. companyobj: app.globalData.companyobj
  47. })
  48. if (this.data.personobj.headimgurl) {
  49. this.setData({
  50. qrCodelogo: this.data.personobj.headimgurl
  51. })
  52. } else if (this.data.companyobj.logo) {
  53. this.setData({
  54. qrCodelogo: this.data.companyobj.logo
  55. })
  56. } else {
  57. this.setData({
  58. qrCodelogo: 'https://imgzqxg.yx-cdn.com/xcx/default.png'
  59. })
  60. }
  61. if (!!options.tp) {
  62. this.setData({
  63. aType: options.tp
  64. })
  65. }
  66. if (!!options.ty) {
  67. this.setData({
  68. bType: options.ty
  69. })
  70. }
  71. if (!!options.f) {
  72. this.setData({
  73. fromType: options.f
  74. })
  75. }
  76. wx.showLoading({
  77. title: '加载中...',
  78. })
  79. wx.getSystemInfo({
  80. success: (res) => {
  81. winwidth = res.windowWidth;
  82. }
  83. })
  84. if (that.data.listshare) {
  85. if (this.data.type == 'materialCase') {
  86. allquery = '&u=' + app.globalData.personMsg.id + '&c=' + options.c + '&s=' + options.s + '&st=' + options.st + '&e=' + options.e + '&h=' + options.h;
  87. }
  88. if (this.data.type == 'materialEvidence') {
  89. allquery = 'uid=' + app.globalData.personMsg.id + '&cate=' + options.cate;
  90. }
  91. if (this.data.type == 'video') {
  92. allquery = "uid=" + app.globalData.personMsg.id + "&ftext=" + options.ftext + "&nText=" + options.nText;
  93. }
  94. }
  95. if (this.data.type == 'shareArticle') {
  96. this.addsharetap();
  97. } else {
  98. this.sharelogtap();
  99. }
  100. },
  101. addsharetap: function () {
  102. let that = this;
  103. utils.$post({
  104. url: app.globalData.webUrl + 'api/agentsWork/agent_sharelog',
  105. header: {
  106. 'Authorization': 'bearer ' + app.globalData.token
  107. },
  108. data: {
  109. type: "AgentArticle",
  110. article_id: that.data.aid,
  111. },
  112. success: function (r) { }
  113. })
  114. },
  115. sharelogtap: function (e) {
  116. var that = this;
  117. utils.$post({
  118. url: app.globalData.webUrl + 'api/share/addlog',
  119. header: {
  120. 'Authorization': 'bearer ' + app.globalData.token
  121. },
  122. data: {
  123. id: that.data.aid,
  124. type: that.data.type == 'vr' ? (that.data.vrtype + '_vr') : that.data.type,
  125. other_data: that.data.type == 'vr' ? that.data.vrurl : ''
  126. },
  127. success: function (r) {
  128. }
  129. })
  130. },
  131. postermsg: function () {
  132. let that = this;
  133. if (that.data.listshare) {
  134. if (this.data.type == 'materialCase') {
  135. that.setData({
  136. posterimg: app.globalData.imgUrl + 'xcx/caseposter.jpg',
  137. title: "案例列表"
  138. })
  139. }
  140. if (this.data.type == 'materialEvidence') {
  141. that.setData({
  142. posterimg: app.globalData.imgUrl + 'xcx/praiseimg.jpg',
  143. title: "客户好评"
  144. })
  145. }
  146. if (this.data.type == 'video') {
  147. that.setData({
  148. posterimg: app.globalData.imgUrl + 'xcx/videoposter.png',
  149. title: "拓客视频"
  150. })
  151. }
  152. that.getcodeimg()
  153. return false;
  154. }
  155. if (that.data.type == 'activity') {
  156. if (that.data.aType && that.data.aType == 'broker') {
  157. utils.$post({
  158. url: app.globalData.webUrl + 'api/agents_work/activity_detail',
  159. header: {
  160. 'Authorization': 'bearer ' + app.globalData.token
  161. },
  162. data: {
  163. id: that.data.aid,
  164. uid: app.globalData.personMsg.id
  165. },
  166. success: function (res) {
  167. if (res.data.code == '0') {
  168. that.setData({
  169. posterimg: res.data.data.cover,
  170. title: res.data.data.title
  171. })
  172. }
  173. that.getcodeimg()
  174. }
  175. })
  176. } else {
  177. utils.$post({
  178. url: app.globalData.webUrl + 'api/activity/details',
  179. header: {
  180. 'Authorization': 'bearer ' + app.globalData.token
  181. },
  182. data: {
  183. id: that.data.aid,
  184. uid: app.globalData.personMsg.id
  185. },
  186. success: function (res) {
  187. if (res.data.code == '0') {
  188. that.setData({
  189. posterimg: res.data.data.poster,
  190. title: res.data.data.title
  191. })
  192. }
  193. that.getcodeimg()
  194. }
  195. })
  196. }
  197. }
  198. if (this.data.type == 'materialCase') {
  199. utils.$get({
  200. url: app.globalData.webUrl + 'api/casedetail',
  201. header: {
  202. 'Authorization': 'bearer ' + app.globalData.token
  203. },
  204. data: {
  205. id: this.data.aid,
  206. uid: app.globalData.personMsg.id,
  207. },
  208. success: function (res) {
  209. if (res.data.code == '0') {
  210. res.data.data.cover_img = res.data.data.cover_img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  211. that.setData({
  212. posterimg: res.data.data.cover_img,
  213. title: res.data.data.title
  214. })
  215. }
  216. that.getcodeimg()
  217. }
  218. })
  219. }
  220. if (this.data.type == 'materialEvidence') {
  221. utils.$get({
  222. url: app.globalData.webUrl + 'api/evidencedetail',
  223. header: {
  224. 'Authorization': 'bearer ' + app.globalData.token
  225. },
  226. data: {
  227. id: that.data.aid,
  228. uid: app.globalData.personMsg.id,
  229. },
  230. success: function (res) {
  231. if (res.data.code == '0') {
  232. let img = res.data.data.difference == 1 ? (res.data.data.cover ? res.data.data.cover : (res.data.data.pics[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast')) : res.data.data.pics[0];
  233. img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  234. that.setData({
  235. posterimg: img,
  236. title: res.data.data.title
  237. })
  238. }
  239. that.getcodeimg()
  240. }
  241. })
  242. }
  243. if (this.data.type == 'video') {
  244. utils.$post({
  245. url: app.globalData.webUrl + 'api/video/info',
  246. header: {
  247. 'Authorization': 'bearer ' + app.globalData.token
  248. },
  249. data: {
  250. video_id: that.data.aid
  251. },
  252. success: function (rs) {
  253. if (rs.data.code == '0') {
  254. that.setData({
  255. posterimg: rs.data.data.cover ? rs.data.data.cover : (rs.data.data.video_url + '?x-oss-process=video/snapshot,t_100,f_jpg,w_500,m_fast'),
  256. title: rs.data.data.title
  257. })
  258. }
  259. that.getcodeimg()
  260. }
  261. })
  262. }
  263. if (this.data.type == 'article') {
  264. utils.$post({
  265. url: app.globalData.webUrl + 'api/article/info',
  266. header: {
  267. 'Authorization': 'bearer ' + app.globalData.token
  268. },
  269. data: {
  270. article_id: that.data.aid
  271. },
  272. success: function (res) {
  273. if (res.data.code == '0') {
  274. that.setData({
  275. posterimg: res.data.data.cover_img,
  276. title: res.data.data.title
  277. })
  278. }
  279. that.getcodeimg()
  280. }
  281. })
  282. }
  283. if (this.data.type == 'Construction') {
  284. utils.$post({
  285. url: app.globalData.webUrl + 'api/construction/view',
  286. header: {
  287. 'Authorization': 'bearer ' + app.globalData.token
  288. },
  289. data: {
  290. id: that.data.aid
  291. },
  292. success: function (res) {
  293. if (res.data.code == '0') {
  294. that.setData({
  295. posterimg: res.data.data.cover,
  296. title: res.data.data.name
  297. })
  298. }
  299. that.getcodeimg()
  300. }
  301. })
  302. }
  303. if (this.data.type == 'shareArticle') {
  304. utils.$post({
  305. url: app.globalData.webUrl + 'api/agentsWork/share_article_details',
  306. header: {
  307. 'Authorization': 'bearer ' + app.globalData.token
  308. },
  309. data: {
  310. from: that.data.fromType,
  311. id: that.data.aid
  312. },
  313. success: function (res) {
  314. wx.hideLoading();
  315. if (res.data.code == '0') {
  316. let imgUrl = '';
  317. if (that.data.fromType == 2) {
  318. if (res.data.data.type == 1) {
  319. imgUrl = res.data.data.file[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_200,m_fast';
  320. } else if (res.data.data.type == 3 || res.data.data.type == 4) {
  321. imgUrl = res.data.data.file_img;
  322. } else {
  323. imgUrl = res.data.data.file[0];
  324. }
  325. } else {
  326. if (res.data.data.type == 1) {
  327. imgUrl = res.data.data.file[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_200,m_fast';
  328. } else if (res.data.data.type == 3 || res.data.data.type == 4) {
  329. imgUrl = res.data.data.file_img ? res.data.data.file_img : res.data.data.file[0];
  330. } else {
  331. imgUrl = res.data.data.file[0];
  332. }
  333. }
  334. that.setData({
  335. posterimg: imgUrl,
  336. title: res.data.data.title
  337. })
  338. that.getcodeimg()
  339. }
  340. }
  341. })
  342. }
  343. if (this.data.type == 'building') {
  344. utils.$post({
  345. url: app.globalData.webUrl + 'api/building/view',
  346. header: {
  347. 'Authorization': 'bearer ' + app.globalData.token
  348. },
  349. data: {
  350. id: that.data.aid
  351. },
  352. success: function (res) {
  353. if (res.data.code == '0') {
  354. that.setData({
  355. posterimg: res.data.data.cover[0],
  356. title: res.data.data.name
  357. })
  358. }
  359. that.getcodeimg()
  360. }
  361. })
  362. }
  363. if (this.data.type == 'buildingProgress') {
  364. utils.$post({
  365. url: app.globalData.webUrl + 'client/building/progress_detail',
  366. header: {
  367. 'Authorization': 'bearer ' + app.globalData.token
  368. },
  369. data: {
  370. id: that.data.aid
  371. },
  372. success: function (res) {
  373. if (res.data.code == '0') {
  374. let data = res.data.data;
  375. if (data.type == 'video') {
  376. if (data.img && data.img.length) {
  377. that.setData({
  378. posterimg: data.img[0],
  379. title: `${data.building_name}-${data.name}`
  380. })
  381. } else {
  382. that.setData({
  383. posterimg: `${data.video}?x-oss-process=video/snapshot,t_100,f_jpg,w_200,m_fast`,
  384. title: `${data.building_name}-${data.name}`
  385. })
  386. }
  387. } else if (data.type == 'img') {
  388. that.setData({
  389. posterimg: data.img[0],
  390. title: `${data.building_name}-${data.name}`
  391. })
  392. } else {
  393. that.setData({
  394. posterimg: data.vr[0]['vrfirstImg'],
  395. title: `${data.building_name}-${data.name}`
  396. })
  397. }
  398. }
  399. that.getcodeimg()
  400. }
  401. })
  402. }
  403. if (this.data.type == 'CompanyStrength') {
  404. utils.$post({
  405. url: app.globalData.webUrl + 'api/company_strength/read',
  406. header: {
  407. 'Authorization': 'bearer ' + app.globalData.token
  408. },
  409. data: {
  410. id: that.data.aid
  411. },
  412. success: function (res) {
  413. if (res.data.code == '0') {
  414. let img = res.data.data.difference == 1 ? (res.data.data.cover ? res.data.data.cover : (res.data.data.pics + '?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast')) : res.data.data.cover;
  415. img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  416. that.setData({
  417. posterimg: img,
  418. title: res.data.data.title
  419. })
  420. }
  421. that.getcodeimg()
  422. }
  423. })
  424. }
  425. if (this.data.type == 'vr') {
  426. let title, imgurl;
  427. if (this.data.vrtype == 'company') {
  428. title = "在线逛展厅-" + app.globalData.companyobj.company_name;
  429. imgurl = app.globalData.imgUrl + 'xcx/aaa/vrcover.png';
  430. that.setData({
  431. posterimg: imgurl,
  432. title: title
  433. })
  434. that.getcodeimg()
  435. } else if (this.data.vrtype == 'employeeCard') {
  436. title = app.globalData.companyobj.company_name + 'VR寻址';
  437. imgurl = app.globalData.imgUrl + "/xcx/sharenamecard.png";
  438. that.setData({
  439. posterimg: imgurl,
  440. title: title
  441. })
  442. that.getcodeimg()
  443. } else if (this.data.vrtype == 'materialCase') {
  444. utils.$get({
  445. url: app.globalData.webUrl + 'client/casedetail',
  446. header: {
  447. 'Authorization': 'bearer ' + app.globalData.token
  448. },
  449. data: {
  450. id: this.data.aid,
  451. share: '146'
  452. },
  453. success: function (res) {
  454. if (res.data.code == '0') {
  455. title = res.data.data.title + '的VR';
  456. imgurl = res.data.data.cover_img;
  457. that.setData({
  458. posterimg: imgurl,
  459. title: title
  460. })
  461. that.getcodeimg()
  462. }
  463. }
  464. })
  465. } else if (this.data.vrtype == 'building') {
  466. utils.$get({
  467. url: app.globalData.webUrl + 'client/building/view',
  468. header: {
  469. 'Authorization': 'bearer ' + app.globalData.token
  470. },
  471. data: {
  472. id: this.data.aid,
  473. share: '146'
  474. },
  475. success: function (res) {
  476. if (res.data.code == '0') {
  477. title = res.data.data.name + '的VR';
  478. imgurl = res.data.data.cover;
  479. that.setData({
  480. posterimg: Array.isArray(imgurl) && imgurl.length ? imgurl[0] : imgurl,
  481. title: title
  482. })
  483. that.getcodeimg()
  484. }
  485. }
  486. })
  487. } else if (this.data.vrtype == 'construction') {
  488. utils.$post({
  489. url: app.globalData.webUrl + 'client/construction/view',
  490. header: {
  491. 'Authorization': 'bearer ' + app.globalData.token
  492. },
  493. data: {
  494. id: this.data.aid,
  495. share: '146'
  496. },
  497. success: function (res) {
  498. if (res.data.code == '0') {
  499. title = res.data.data.name + '的VR';
  500. imgurl = res.data.data.cover;
  501. that.setData({
  502. posterimg: imgurl,
  503. title: title
  504. })
  505. that.getcodeimg()
  506. }
  507. }
  508. })
  509. } else if (this.data.vrtype == 'housetype') {
  510. utils.$post({
  511. url: app.globalData.webUrl + 'client/building/housetype_detail',
  512. header: {
  513. 'Authorization': 'bearer ' + app.globalData.token
  514. },
  515. data: {
  516. id: this.data.aid,
  517. share: '146'
  518. },
  519. success: function (res) {
  520. if (res.data.code == '0') {
  521. let dataObj = res.data.data;
  522. let imgCover = "";
  523. if (dataObj.room == 9) {
  524. dataObj.housetypename = "别墅";
  525. } else {
  526. dataObj.housetypename = `${dataObj.room}室${dataObj.hall}厅${dataObj.bathroom}卫`;
  527. }
  528. if (dataObj.house_img && dataObj.house_img.length) {
  529. imgCover = dataObj.house_img[0];
  530. }
  531. title = dataObj.housetypename + '的VR';
  532. imgurl = imgCover ? imgCover : dataObj.vr_link_img;
  533. that.setData({
  534. posterimg: imgurl,
  535. title: title
  536. })
  537. that.getcodeimg()
  538. }
  539. }
  540. })
  541. }
  542. }
  543. if (this.data.type == 'housetype') {
  544. utils.$post({
  545. url: app.globalData.webUrl + 'api/building/housetype_detail',
  546. header: {
  547. 'Authorization': 'bearer ' + app.globalData.token
  548. },
  549. data: {
  550. id: that.data.aid
  551. },
  552. success: function (res) {
  553. if (res.data.code == '0') {
  554. let data = res.data.data;
  555. let posterCover = "";
  556. if (data.house_img && Array.isArray(data.house_img) && data.house_img.length) {
  557. posterCover = data.house_img[0];
  558. } else {
  559. posterCover = data.vr_link_img;
  560. }
  561. if (data.room == 9) {
  562. data.shareTitle = "别墅";
  563. } else {
  564. data.shareTitle = `${data.room}室${data.hall}厅${data.bathroom}卫`;
  565. }
  566. that.setData({
  567. posterimg: posterCover,
  568. title: data.shareTitle
  569. })
  570. }
  571. that.getcodeimg()
  572. }
  573. })
  574. }
  575. },
  576. getcodeimg: function () {
  577. let that = this, query = '', path = '';
  578. if (that.data.listshare) {
  579. if (this.data.type == 'materialCase') {
  580. query = allquery + '&ctp=' + app.globalData.clientype;
  581. path = 'share/pages/caselist/caselist'
  582. }
  583. if (this.data.type == 'materialEvidence') {
  584. query = allquery + '&ctp=' + app.globalData.clientype;
  585. path = 'share/pages/praiselist/praiselist'
  586. }
  587. if (this.data.type == 'video') {
  588. query = allquery + '&ctp=' + app.globalData.clientype;
  589. path = 'share/pages/videolist/videolist'
  590. }
  591. } else {
  592. if (that.data.type == 'activity') {
  593. if (that.data.aType && that.data.aType == 'broker') {
  594. query = 'aid=' + this.data.aid + '&bid=' + app.globalData.brokeruserId + '&ctp=' + app.globalData.clientype + '&t=b';
  595. path = 'share/pages/activitymsg/activitymsg';
  596. } else {
  597. query = 'aid=' + this.data.aid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
  598. path = 'share/pages/activitymsg/activitymsg';
  599. }
  600. }
  601. if (this.data.type == 'materialCase') {
  602. if (this.data.bType == 'b') {
  603. query = 'a=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
  604. path = 'share/pages/materialcase/materialcase';
  605. } else {
  606. query = 'cid=' + that.data.aid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
  607. path = 'share/pages/materialcase/materialcase';
  608. }
  609. }
  610. if (this.data.type == 'materialEvidence') {
  611. if (this.data.bType == 'b') {
  612. query = 'e=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
  613. path = 'share/pages/publicpraisemsg/publicpraisemsg';
  614. } else {
  615. query = 'eid=' + that.data.aid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
  616. path = 'share/pages/publicpraisemsg/publicpraisemsg';
  617. }
  618. }
  619. if (this.data.type == 'CompanyStrength') {
  620. if (this.data.bType == 'b') {
  621. query = 'e=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
  622. path = 'share/pages/companystrengthmsg/companystrengthmsg';
  623. } else {
  624. query = 'eid=' + that.data.aid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
  625. path = 'share/pages/companystrengthmsg/companystrengthmsg';
  626. }
  627. }
  628. if (this.data.type == 'video') {
  629. if (this.data.bType == 'b') {
  630. query = 'v=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
  631. path = 'share/pages/videoshare/videoshare';
  632. } else {
  633. query = 'vid=' + that.data.aid + '&userid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
  634. path = 'share/pages/videoshare/videoshare';
  635. }
  636. }
  637. if (this.data.type == 'article') {
  638. if (this.data.bType == 'b') {
  639. query = 'a=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
  640. path = 'share/pages/articleshare/articleshare';
  641. } else {
  642. query = 'aid=' + that.data.aid + '&userid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
  643. path = 'share/pages/articleshare/articleshare';
  644. }
  645. }
  646. if (this.data.type == 'spellgroup') {
  647. query = 'a=' + that.data.aid + '&u=' + app.globalData.personMsg.id + '&t=' + '&e=' + app.globalData.personMsg.binded.id + '&p=' + app.globalData.clientype;
  648. path = 'share/pages/collagemsg/collagemsg';
  649. }
  650. if (this.data.type == 'Construction') {
  651. query = 'cid=' + that.data.aid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype;
  652. path = 'share/pages/constructsite/constructsite';
  653. }
  654. if (this.data.type == 'building') {
  655. if (this.data.bType == 'b') {
  656. query = 'u=' + app.globalData.agentEmployeEid + '&c=' + that.data.aid + '&t=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
  657. path = 'share/pages/buildprogress/buildprogress';
  658. } else {
  659. query = 'u=' + app.globalData.personMsg.id + '&c=' + that.data.aid + '&e=' + app.globalData.personMsg.binded.id + '&t=' + app.globalData.clientype;
  660. path = 'share/pages/buildprogress/buildprogress';
  661. }
  662. }
  663. if (this.data.type == 'buildingProgress') {
  664. query = 'u=' + app.globalData.personMsg.id + '&c=' + that.data.aid + '&e=' + app.globalData.personMsg.binded.id + '&t=' + app.globalData.clientype;
  665. path = 'share/pages/buildShare/buildShare';
  666. }
  667. if (this.data.type == 'vr') {
  668. query = 'c=' + app.globalData.clientype + '&u=' + app.globalData.personMsg.id + '&a=' + this.data.aid + '&y=' + this.data.vrtype + '&l=' + this.data.vrurl;
  669. path = 'pages/other/other';
  670. }
  671. if (this.data.type == 'shareArticle') {
  672. query = 'c=' + this.data.aid + '&u=' + app.globalData.agentEmployeEid + '&ct=' + app.globalData.clientype + '&ag=' + app.globalData.brokeruserId + '&f=' + this.data.fromType;
  673. path = 'share/pages/brokershareinfo/brokershareinfo';
  674. }
  675. if (this.data.type == 'housetype') {
  676. if (this.data.bType == 'b') {
  677. query = 'd=' + that.data.aid + '&u=' + app.globalData.agentEmployeEid + '&c=' + app.globalData.clientype + "&g=" + app.globalData.brokeruserId;
  678. path = 'share/pages/housetype/housetype';
  679. } else {
  680. query = 'd=' + that.data.aid + '&u=' + app.globalData.personMsg.id + '&c=' + app.globalData.clientype;
  681. path = 'share/pages/housetype/housetype';
  682. }
  683. }
  684. }
  685. utils.$post({
  686. url: app.globalData.webUrl + 'api/share/qrcode',
  687. header: {
  688. 'Authorization': 'bearer ' + app.globalData.token
  689. },
  690. data: {
  691. query: query,
  692. path: path
  693. },
  694. success: function (res) {
  695. if (res.data.code == "0") {
  696. that.setData({
  697. qrcodeimg: res.data.data
  698. })
  699. setTimeout(function () {
  700. that.createdCode();
  701. }, 300)
  702. }
  703. },
  704. fail() {
  705. }
  706. })
  707. },
  708. //开始绘图
  709. createdCode: function () {
  710. let that = this;
  711. if (that.data.title.length > 15) {
  712. that.setData({
  713. title: that.data.title.substring(0, 13) + '...'
  714. })
  715. }
  716. let topwidth = winwidth * 710 / 750, topheight = '';
  717. const ctx = wx.createCanvasContext('myCanvas'); //绘图上下文
  718. wx.getImageInfo({
  719. src: that.data.posterimg,
  720. success(res) {
  721. wx.getImageInfo({
  722. src: that.data.qrcodeimg,
  723. success(rs) {
  724. if (that.data.qrCodelogo) {
  725. wx.getImageInfo({
  726. src: that.data.qrCodelogo,
  727. success(fs) {
  728. console.log(fs, '图片信息');
  729. topheight = topwidth * res.height / res.width;
  730. that.setData({
  731. cangth: topheight + 110
  732. })
  733. ctx.save();
  734. ctx.drawImage(res.path, 0, 0, topwidth, topheight);
  735. ctx.rect(0, topheight, topwidth, 110);
  736. ctx.setFillStyle('#FFFFFF');
  737. ctx.fill();
  738. ctx.restore()
  739. ctx.setFontSize(14);
  740. ctx.fillText("@" + (app.globalData.personMsg.binded && app.globalData.personMsg.binded.name ? app.globalData.personMsg.binded.name : app.globalData.personMsg.nickname), 12, topheight + 44, topwidth - 70);
  741. ctx.fillText(that.data.title, 12, topheight + 66, topwidth - 70);
  742. ctx.drawImage(rs.path, topwidth - 100, topheight + 12, 88, 88);
  743. //-------------------
  744. ctx.save();
  745. // 绘制圆形头像
  746. const avatarSize = 40; // 头像尺寸
  747. const avatarX = topwidth - 100; // 头像左上角的 X 坐标
  748. const avatarY = topheight + 12; // 头像左上角的 Y 坐标
  749. const avatarRadius = avatarSize / 2; // 头像半径
  750. // 绘制圆形头像底色
  751. ctx.fillStyle = '#ffffff';
  752. ctx.beginPath();
  753. ctx.arc(avatarX + 43.8, avatarY + 43.8, avatarRadius, 0, 2 * Math.PI);
  754. ctx.closePath();
  755. ctx.fill();
  756. // 在圆形区域内绘制头像图片
  757. ctx.save(); // 保存当前绘图状态
  758. ctx.beginPath();
  759. ctx.arc(avatarX + 43.8, avatarY + 43.8, avatarRadius - 2, 0, 2 * Math.PI);
  760. ctx.closePath();
  761. ctx.clip();
  762. ctx.drawImage(fs.path, avatarX + 23, avatarY + 23, avatarSize, avatarSize);
  763. ctx.restore(); // 恢复之前的绘图状态
  764. // -----------------------
  765. ctx.draw();
  766. wx.hideLoading();
  767. setTimeout(() => {
  768. wx.canvasToTempFilePath({
  769. x: 0,
  770. y: 0,
  771. canvasId: 'myCanvas',
  772. success: function (res) {
  773. let shareImg = res.tempFilePath;
  774. that.setData({
  775. shareImg: shareImg,
  776. })
  777. },
  778. fail: function (res) { }
  779. })
  780. }, 500)
  781. },
  782. fail(err) {
  783. console.log(err)
  784. }
  785. })
  786. } else {
  787. topheight = topwidth * res.height / res.width;
  788. that.setData({
  789. cangth: topheight + 110
  790. })
  791. ctx.save();
  792. ctx.drawImage(res.path, 0, 0, topwidth, topheight);
  793. ctx.rect(0, topheight, topwidth, 110);
  794. ctx.setFillStyle('#FFFFFF');
  795. ctx.fill();
  796. ctx.restore()
  797. ctx.setFontSize(14);
  798. ctx.fillText("@" + (app.globalData.personMsg.binded && app.globalData.personMsg.binded.name ? app.globalData.personMsg.binded.name : app.globalData.personMsg.nickname), 12, topheight + 44, topwidth - 70);
  799. ctx.fillText(that.data.title, 12, topheight + 66, topwidth - 70);
  800. ctx.drawImage(rs.path, topwidth - 100, topheight + 12, 88, 88);
  801. ctx.draw();
  802. wx.hideLoading();
  803. setTimeout(() => {
  804. wx.canvasToTempFilePath({
  805. x: 0,
  806. y: 0,
  807. canvasId: 'myCanvas',
  808. success: function (res) {
  809. let shareImg = res.tempFilePath;
  810. that.setData({
  811. shareImg: shareImg,
  812. })
  813. },
  814. fail: function (res) { }
  815. })
  816. }, 500)
  817. }
  818. }, fail(res) {
  819. console.log(res)
  820. },
  821. })
  822. }, fail(res) {
  823. console.log(res)
  824. }
  825. })
  826. },
  827. saveimgtap: function () {
  828. let that = this;
  829. // 获取用户是否开启用户授权相册
  830. wx.getSetting({
  831. success(res) {
  832. // 如果没有则获取授权
  833. if (!res.authSetting['scope.writePhotosAlbum']) {
  834. wx.authorize({
  835. scope: 'scope.writePhotosAlbum',
  836. success() {
  837. wx.saveImageToPhotosAlbum({
  838. filePath: that.data.shareImg,
  839. success() {
  840. wx.showToast({
  841. title: '保存成功'
  842. })
  843. },
  844. fail() {
  845. wx.showToast({
  846. title: '保存失败',
  847. icon: 'none'
  848. })
  849. }
  850. })
  851. },
  852. fail() {
  853. // 如果用户拒绝过或没有授权,则再次打开授权窗口
  854. //(ps:微信api又改了现在只能通过button才能打开授权设置,以前通过openSet就可打开,下面有打开授权的button弹窗代码)
  855. that.setData({
  856. openSet: true
  857. })
  858. }
  859. })
  860. } else {
  861. // 有则直接保存
  862. wx.saveImageToPhotosAlbum({
  863. filePath: that.data.shareImg,
  864. success() {
  865. wx.showToast({
  866. title: '保存成功'
  867. })
  868. },
  869. fail() {
  870. wx.showToast({
  871. title: '保存失败',
  872. icon: 'none'
  873. })
  874. }
  875. })
  876. }
  877. }
  878. })
  879. },
  880. cancleSet() {
  881. this.setData({
  882. openSet: false
  883. })
  884. },
  885. /**
  886. * 生命周期函数--监听页面初次渲染完成
  887. */
  888. onReady: function () {
  889. },
  890. /**
  891. * 生命周期函数--监听页面显示
  892. */
  893. onShow: function () {
  894. let that = this;
  895. that.postermsg();
  896. },
  897. /**
  898. * 生命周期函数--监听页面隐藏
  899. */
  900. onHide: function () {
  901. },
  902. /**
  903. * 生命周期函数--监听页面卸载
  904. */
  905. onUnload: function () {
  906. },
  907. /**
  908. * 页面相关事件处理函数--监听用户下拉动作
  909. */
  910. onPullDownRefresh: function () {
  911. },
  912. /**
  913. * 页面上拉触底事件的处理函数
  914. */
  915. onReachBottom: function () {
  916. },
  917. /**
  918. * 用户点击右上角分享
  919. */
  920. // onShareAppMessage: function () {
  921. // }
  922. })