1
0

setposter.js 33 KB

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