bill.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. const util = require("../../../utils/util.js");
  2. const app = getApp();
  3. Page({
  4. data: {
  5. shareImage: '',
  6. orderid: "",
  7. groupid: "",
  8. painting: {},
  9. info: {
  10. posters: [],
  11. },
  12. indicatorDots: true,
  13. current: 0,
  14. channel: 0,
  15. channelTimes: 0,
  16. sid: '',
  17. pid: '',
  18. groupbook: -1,
  19. status: 0,
  20. userInfo: app.globalData.userInfo,
  21. showConent: true,
  22. shareStatus: 1,
  23. makeTask: false //是否为宝贝币中心任务进入
  24. },
  25. onLoad(options) {
  26. console.log('options', options)
  27. if (options.channel != 0 && !util.isEmpty(options.channel)) {
  28. this.setData({ channel: options.channel, channelTimes: options.channelTimes });
  29. }
  30. let prePath = util.getPrePageRoute();
  31. this.setData({ id: options.id, orderid: options.orderid || '', groupid: options.groupid || '', userInfo: app.globalData.userInfo, sid: options.sid || '', pid: options.pid || '', groupbook: options.groupbook || -1, showConent: (prePath == 'pages/product/activity/index' || prePath == 'pages/account/monetaryCenter/posterTask') ? true : false, makeTask: options.makeTask });
  32. },
  33. onReady() {
  34. this.getActivity();
  35. },
  36. // 复制文案
  37. copyContent(e) {
  38. let val = e.currentTarget.dataset.data;
  39. wx.setClipboardData({
  40. data: val,
  41. success: function (res) {
  42. wx.showToast({
  43. title: '复制成功',
  44. icon: 'none'
  45. });
  46. }
  47. });
  48. },
  49. // 获取分享家是否停用
  50. stat() {
  51. let that = this;
  52. util.stat().then(res => {
  53. that.setData({ shareStatus: res.shareStatus })
  54. })
  55. },
  56. // 获取用户信息
  57. getActivity() {
  58. console.log(this.data.id);
  59. let that = this, data = { aid: that.data.id }, url = "article", params = {};//article ———— 二维码
  60. if (this.data.channel && this.data.channel != 0 && this.data.channelTimes == 1) {
  61. params.channelId = this.data.channel;
  62. params.channelCount = parseInt(this.data.channelTimes) + 1;
  63. }
  64. if (!util.isEmpty(that.data.orderid)) {
  65. url = "group";
  66. data.orderid = that.data.orderid;
  67. params.orderid = that.data.orderid;
  68. }
  69. if (!util.isEmpty(that.data.groupid)) {
  70. url = "group";
  71. data.groupid = that.data.groupid;
  72. params.groupid = that.data.groupid;
  73. }
  74. if (!util.isEmpty(that.data.id)) {
  75. params.aid = that.data.id;
  76. }
  77. if (!util.isEmpty(that.data.sid)) {
  78. params.sharesid = that.data.sid;
  79. }
  80. if (!util.isEmpty(that.data.pid)) {
  81. params.sharepid = that.data.pid;
  82. }
  83. params.code = this.data.userInfo.code;
  84. params.sharer = this.data.userInfo.nickname;
  85. data.params = JSON.stringify(params);
  86. console.log(data);
  87. console.log(url);
  88. util.ajax({
  89. func: "user/poster/" + url, // user/poster/article user/qrcode/group
  90. data: data // user/qrcode/article ——获取活动二维码
  91. }, function (res) {
  92. console.log(res);
  93. if (res.code == 0) {
  94. res.data.invitePrice = util.config.invitePrice;
  95. let tags = [];
  96. if (!util.isObjEmpty(res.data.tags)) {
  97. for (let i in res.data.tags) {
  98. tags.push(res.data.tags[i].tagValue);
  99. }
  100. }
  101. res.data.tags = tags.join("|");
  102. res.data.tags = res.data.tags.length > 37 ? res.data.tags.substring(0, 37) + ".." : res.data.tags;
  103. if (!util.isEmpty(res.data.avatar)) {
  104. wx.downloadFile({
  105. url: util.config.apiServer + "file.do?url=" + res.data.avatar,
  106. success(ret) {
  107. if (ret.statusCode === 200) {
  108. res.data.avatar = ret.tempFilePath;
  109. }
  110. that.setData({ info: res.data });
  111. that.cateQroce(data, url, res.data.qrcode, res.data.groupid);
  112. }
  113. });
  114. } else {
  115. res.data.avatar = "/images/default_logo.jpg";
  116. that.setData({ info: res.data });
  117. that.cateQroce(data, url, res.data.qrcode, res.data.groupid);
  118. }
  119. that.stat()
  120. } else
  121. util.showTips(res.reason);
  122. });
  123. },
  124. // 生成二维码
  125. cateQroce(data, url, qrcode, groupid) {
  126. console.log(url);
  127. let that = this;
  128. if (!util.isEmpty(that.data.orderid)) data.groupid = groupid;
  129. console.log(data);
  130. util.ajax({
  131. func: "user/qrcode/" + url,
  132. data: data
  133. }, function (res) {
  134. console.log(res);
  135. if (res.code == 0) {
  136. console.log(res);
  137. that.data.info.qrcode = res.data;
  138. that.setData({ info: that.data.info });
  139. } else
  140. util.showTips(res.reason);
  141. });
  142. },
  143. swiperChange(e) {
  144. let current = e.detail.current;
  145. this.setData({ current: e.detail.current });
  146. },
  147. // 记录分享次数
  148. shareRecord(aid) {
  149. if (!util.isEmpty(aid)) {
  150. util.ajax({
  151. func: 'article/share',
  152. data: { "aid": aid },
  153. load: false
  154. }), function (res) {
  155. console.log(res)
  156. }
  157. }
  158. },
  159. cetaInvite() {
  160. // this.shareRecord(this.data.id)
  161. wx.showLoading({
  162. title: '海报生成中'
  163. });
  164. let that = this, views = [];
  165. if (this.data.current < this.data.info.posters.length) {
  166. let poster = this.data.info.posters[this.data.current];
  167. console.log(poster.posterPic);
  168. views.push({
  169. type: 'image',
  170. url: poster.posterPic,
  171. top: 0,
  172. left: 0,
  173. width: poster.posterWidth,
  174. height: poster.posterHeight
  175. },
  176. // that.data.info.qrcode
  177. // https://img.bbztx.com/images/upload/thumbs/20221212/logo/1670811442549004585.png
  178. {
  179. type: 'image',
  180. url: that.data.info.qrcode,
  181. top: poster.posterHeight - poster.qrcodeY - poster.qrcodeHeight,
  182. left: poster.qrcodeX,
  183. width: poster.qrcodeWidth,
  184. height: poster.qrcodeHeight
  185. })
  186. this.setData({
  187. painting: {
  188. width: poster.posterWidth,
  189. height: poster.posterHeight,
  190. clear: true,
  191. views: views
  192. }
  193. });
  194. } else if (this.data.current === this.data.info.posters.length) {
  195. if (!util.isEmpty(that.data.orderid)) {
  196. views.push({
  197. type: 'image',
  198. url: "https://img.bbztx.com/images/upload/thumbs/20221212/logo/1670814536619084888.jpg",
  199. top: 0,
  200. left: 0,
  201. width: 750,
  202. height: 1332
  203. },
  204. // that.data.info.qrcode
  205. // https://img.bbztx.com/images/upload/thumbs/20221212/logo/1670811442549004585.png
  206. {
  207. type: 'image',
  208. url: that.data.info.qrcode,
  209. top: 1078,
  210. left: 488,
  211. width: 210,
  212. height: 210
  213. },
  214. {
  215. type: 'image',
  216. url: that.data.info.avatar,
  217. borderRadius: 65,
  218. top: 268,
  219. left: 310,
  220. width: 139,
  221. height: 139
  222. },
  223. {
  224. type: 'image',
  225. url: that.data.info.logo,
  226. top: 542,
  227. left: 18,
  228. width: 712,
  229. height: 370
  230. },
  231. {
  232. type: 'text',
  233. content: that.data.info.discountPrice,
  234. fontSize: 40,
  235. bolder: true,
  236. color: '#ee3a43',
  237. textAlign: 'left',
  238. top: 482,
  239. left: 460
  240. },
  241. {
  242. type: 'text',
  243. content: that.data.info.nickname + " 邀您拼团",
  244. fontSize: 32,
  245. color: '#3e3a39',
  246. textAlign: 'center',
  247. top: 420,
  248. left: 750 / 2
  249. },
  250. {
  251. type: 'text',
  252. content: that.data.info.tags,
  253. fontSize: 24,
  254. color: '#ee3a43',
  255. textAlign: 'left',
  256. MaxLineNumber: 1,
  257. breakWord: true,
  258. lineHeight: 30,
  259. top: 927,
  260. left: 50,
  261. width: 650
  262. },
  263. {
  264. type: 'text',
  265. content: "活动费",
  266. fontSize: 26,
  267. color: '#595757',
  268. textAlign: 'left',
  269. top: 990,
  270. left: 50
  271. },
  272. {
  273. type: 'text',
  274. content: "¥",
  275. fontSize: 18,
  276. color: '#ee3a43',
  277. textAlign: 'left',
  278. top: 995,
  279. left: 168
  280. },
  281. {
  282. type: 'text',
  283. content: that.data.info.price,
  284. fontSize: 26,
  285. bolder: true,
  286. color: '#ee3a43',
  287. textAlign: 'left',
  288. top: 990,
  289. left: 186
  290. });
  291. } else {
  292. views.push({
  293. type: 'image',
  294. url: 'https://img.bbztx.com/images/upload/thumbs/20221110/logo/1668071284848082519.jpg',
  295. top: 0,
  296. left: 0,
  297. width: 750,
  298. height: 1332
  299. },
  300. {
  301. type: 'image',
  302. url: that.data.info.logo,
  303. top: 235,
  304. left: 71,
  305. arcType: "arc",
  306. borderRadius: 12,
  307. width: 604,
  308. height: 311
  309. },
  310. {
  311. type: 'image',
  312. url: that.data.info.qrcode,
  313. top: 1036,
  314. left: 65,
  315. width: 210,
  316. height: 210
  317. },
  318. {
  319. type: 'image',
  320. url: that.data.info.avatar,
  321. borderRadius: 47,
  322. top: 105,
  323. left: 80,
  324. width: 100,
  325. height: 100
  326. },
  327. {
  328. type: 'text',
  329. content: that.data.info.tags,
  330. fontSize: 24,
  331. color: '#ee3a43',
  332. textAlign: 'left',
  333. top: 580,
  334. left: 70
  335. },
  336. {
  337. type: 'text',
  338. content: " " + that.data.info.commentContent,
  339. MaxLineNumber: 4,
  340. lineHeight: 50,
  341. breakWord: true,
  342. fontSize: 28,
  343. width: 580,
  344. color: '#333333',
  345. textAlign: 'justify',
  346. top: 745,
  347. left: 70
  348. },
  349. {
  350. type: 'text',
  351. content: "活动费",
  352. fontSize: 28,
  353. color: '#333333',
  354. textAlign: 'left',
  355. top: 630,
  356. left: 70
  357. },
  358. {
  359. type: 'text',
  360. content: "¥",
  361. fontSize: 18,
  362. color: '#ee3a43',
  363. textAlign: 'left',
  364. top: 640,
  365. left: 168
  366. },
  367. {
  368. type: 'text',
  369. content: that.data.info.price,
  370. fontSize: 32,
  371. color: '#ee3a43',
  372. textAlign: 'left',
  373. top: 630,
  374. left: 186
  375. },
  376. {
  377. type: 'text',
  378. content: that.data.info.nickname,
  379. fontSize: 32,
  380. color: '#231815',
  381. textAlign: 'left',
  382. top: 120,
  383. left: 200
  384. },
  385. {
  386. type: 'text',
  387. content: that.data.userInfo.roleType == 'normal' || that.data.userInfo.roleTypeDisable == 1 ? "让宝贝探索属于自己的世界" : "邀你参加活动,送你" + util.config.invitePrice + "元新人现金券",
  388. fontSize: 22,
  389. color: '#231815',
  390. textAlign: 'left',
  391. top: 160,
  392. left: 200
  393. });
  394. }
  395. if (that.data.info.psAttendCount > 10) {
  396. views.push({
  397. type: 'text',
  398. content: "已售" + that.data.info.psAttendCount + "人",
  399. fontSize: 24,
  400. color: '#898989',
  401. textAlign: 'right',
  402. top: !util.isEmpty(that.data.orderid) ? 992 : 630,
  403. left: !util.isEmpty(that.data.orderid) ? 700 : 675
  404. })
  405. }
  406. this.setData({
  407. painting: {
  408. width: 750,
  409. height: 1332,
  410. clear: true,
  411. views: views
  412. }
  413. });
  414. }
  415. },
  416. swiperGetImage(event) {
  417. const { tempFilePath, errMsg } = event.detail;
  418. const current = event.currentTarget.dataset.current;
  419. if (errMsg === 'canvasdrawer:ok') {
  420. this.data.img.push(tempFilePath)
  421. this.data.info.posters[current].canvasImage = tempFilePath;
  422. this.setData({
  423. info: this.data.info,
  424. img: this.data.img,
  425. });
  426. wx.hideLoading();
  427. }
  428. },
  429. eventGetImage(event) {
  430. const { tempFilePath, errMsg } = event.detail;
  431. if (errMsg === 'canvasdrawer:ok') {
  432. wx.saveImageToPhotosAlbum({
  433. filePath: tempFilePath,
  434. success(res) {
  435. console.log('saveImageToPhotosAlbum-res', res)
  436. wx.showToast({
  437. title: '保存图片成功',
  438. icon: 'success',
  439. duration: 2000,
  440. success: () => {
  441. if (this.data.makeTask) {
  442. wx.navigateBack()
  443. }
  444. }
  445. })
  446. },
  447. fail(err) {
  448. console.log('saveImageToPhotosAlbum-err', err)
  449. if (err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" || err.errMsg === "saveImageToPhotosAlbum:fail auth deny" || err.errMsg === "saveImageToPhotosAlbum:fail authorize no response") {
  450. wx.showModal({
  451. title: '提示',
  452. content: '需要您授权保存相册',
  453. showCancel: false,
  454. success: modalSuccess => {
  455. wx.openSetting({
  456. success(settingdata) {
  457. console.log("settingdata", settingdata)
  458. if (settingdata.authSetting['scope.writePhotosAlbum']) {
  459. wx.showModal({
  460. title: '提示',
  461. content: '获取权限成功,再次点击即可保存!',
  462. showCancel: false,
  463. })
  464. } else {
  465. wx.showModal({
  466. title: '提示',
  467. content: '获取权限失败,将无法保存到相册。',
  468. showCancel: false,
  469. })
  470. }
  471. }
  472. })
  473. }
  474. })
  475. }
  476. }
  477. });
  478. wx.hideLoading();
  479. }
  480. }
  481. })