invitationUserqy.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. <template>
  2. <view class="page-box">
  3. <navBar title="邀请好友" color="#000" />
  4. <view class="page-content">
  5. <view
  6. class="flex justify-between align-center margin-lr-sm padding"
  7. style="background: #ffffff; border-radius: 20upx"
  8. >
  9. <view class="flex">
  10. <view>
  11. <image
  12. :src="userImageUrl ? userImageUrl : '../../static/logo.png'"
  13. style="width: 72upx; height: 72upx; border-radius: 12upx"
  14. ></image>
  15. </view>
  16. <view class="margin-left-sm">
  17. <view class="text-sm"
  18. ><text class="text-bold" style="font-size: 48upx">{{ peopleNum }}</text
  19. >人</view
  20. >
  21. <view style="color: #82a9fe">已成功邀请人数</view>
  22. </view>
  23. </view>
  24. <view @click="goTeam()" v-if="zhiRate > 0">
  25. 我的团队
  26. <image
  27. src="../../static/images/my/right_icon.png"
  28. style="width: 10rpx; height: 20rpx; margin-left: 10rpx"
  29. ></image>
  30. </view>
  31. </view>
  32. <view
  33. class="view1"
  34. v-bind:style="{ backgroundImage: 'url(' + backgroundImage + ')' }"
  35. >
  36. <view style="padding-top: 820upx" @longpress="logoTime(userImageUrl)">
  37. <view
  38. style="
  39. width: 100%;
  40. height: 150upx;
  41. display: flex;
  42. background: #ffffff;
  43. padding: 20upx 10upx;
  44. "
  45. >
  46. <image
  47. :src="userImageUrl"
  48. style="
  49. border-radius: 100upx;
  50. width: 100upx;
  51. height: 100upx;
  52. margin-left: 30upx;
  53. "
  54. ></image>
  55. <view class="login-view-text1" style="margin-left: 30upx; width: 59%">
  56. <view style="font-size: 16px">{{ nickName }}</view>
  57. <view style="font-size: 12px; margin-top: 20upx"
  58. >邀请码:{{ invitationCode }}</view
  59. >
  60. </view>
  61. <canvas canvas-id="qrcode" style="width: 140upx; height: 130upx" />
  62. </view>
  63. </view>
  64. </view>
  65. <view
  66. style="
  67. display: flex;
  68. flex-direction: row;
  69. padding: 20upx 40upx;
  70. justify-content: center;
  71. "
  72. >
  73. <!-- #ifdef H5 -->
  74. <button
  75. @click="share()"
  76. type="default"
  77. style="
  78. background: #e4ecff;
  79. border: 2upx solid #82a9fe;
  80. font-size: 16px;
  81. font-weight: bold;
  82. color: #82a9fe;
  83. width: 50%;
  84. "
  85. >
  86. 文案推广
  87. </button>
  88. <button
  89. @tap="showModal()"
  90. type="default"
  91. style="
  92. background-color: #82a9fe;
  93. font-size: 16px;
  94. font-weight: bold;
  95. color: #ffffff;
  96. width: 50%;
  97. margin-left: 40upx;
  98. "
  99. >
  100. 生成海报
  101. </button>
  102. <!-- #endif -->
  103. <!-- #ifdef APP-PLUS -->
  104. <button
  105. v-if="isShowWxAPPShare == '是'"
  106. @click="shareWeiXin()"
  107. type="default"
  108. style="
  109. background: #e4ecff;
  110. border: 2upx solid #82a9fe;
  111. font-size: 16px;
  112. font-weight: bold;
  113. color: #82a9fe;
  114. width: 50%;
  115. "
  116. >
  117. 文案推广
  118. </button>
  119. <button
  120. v-if="isShowWxAPPShare == '否'"
  121. @click="sharAPPUrl()"
  122. type="default"
  123. style="
  124. background: #e4ecff;
  125. border: 2upx solid #82a9fe;
  126. font-size: 16px;
  127. font-weight: bold;
  128. color: #82a9fe;
  129. width: 50%;
  130. "
  131. >
  132. 文案推广
  133. </button>
  134. <button
  135. @tap="showModal()"
  136. type="default"
  137. style="
  138. background-color: #557efd;
  139. font-size: 16px;
  140. font-weight: bold;
  141. color: #ffffff;
  142. width: 50%;
  143. margin-left: 40upx;
  144. "
  145. >
  146. 生成海报
  147. </button>
  148. <!-- #endif -->
  149. <!-- #ifdef MP-WEIXIN -->
  150. <button
  151. open-type="share"
  152. style="
  153. background: #e4ecff;
  154. border: 2upx solid #82a9fe;
  155. font-size: 16px;
  156. font-weight: bold;
  157. color: #82a9fe;
  158. width: 48%;
  159. "
  160. >
  161. 一键分享
  162. </button>
  163. <!-- <button @click="share()" type="default" style="background-color: #FFCB49;font-size: 16px;font-weight: bold;color: #FFFFFF; width: 40%;">文案推广</button> -->
  164. <button
  165. @tap="onSaveImg()"
  166. type="default"
  167. style="
  168. background-color: #82a9fe;
  169. font-size: 16px;
  170. font-weight: bold;
  171. color: #ffffff;
  172. width: 48%;
  173. "
  174. >
  175. 生成海报
  176. </button>
  177. <!-- #endif -->
  178. <!-- 生成海报 -->
  179. <!-- 图片展示由自己实现 -->
  180. <view
  181. class="flex_row_c_c modalView"
  182. :class="qrShow ? 'show' : ''"
  183. @tap="hideQr()"
  184. >
  185. <view class="flex_column">
  186. <view class="backgroundColor-white padding1vh border_radius_10px">
  187. <image
  188. :src="poster.finalPath || ''"
  189. mode="widthFix"
  190. class="posterImage"
  191. ></image>
  192. </view>
  193. <view class="flex_row marginTop2vh">
  194. <!-- #ifdef H5 -->
  195. <button type="primary" size="mini">长按上方图片保存</button>
  196. <!-- #endif -->
  197. <!-- #ifndef H5 -->
  198. <button type="primary" size="mini" @tap.prevent.stop="saveImage()">
  199. 保存图片
  200. </button>
  201. <!-- #endif -->
  202. </view>
  203. </view>
  204. </view>
  205. <!-- 画布 -->
  206. <view class="hideCanvasView">
  207. <canvas
  208. class="hideCanvas"
  209. canvas-id="default_PosterCanvasId"
  210. :style="{
  211. width: (poster.width || 10) + 'px',
  212. height: (poster.height || 10) + 'px',
  213. }"
  214. ></canvas>
  215. </view>
  216. </view>
  217. <!-- #ifndef MP-WEIXIN -->
  218. <tki-qrcode
  219. ref="qrcode"
  220. :val="url"
  221. :size="200"
  222. background="#fff"
  223. foreground="#000"
  224. pdground="#000"
  225. :onval="true"
  226. :loadMake="true"
  227. @result="qrR"
  228. :show="false"
  229. ></tki-qrcode>
  230. <view class="cu-modal" :class="modalName == 'Image' ? 'show' : ''" @tap="hideModal">
  231. <view
  232. class="cu-dialog"
  233. v-if="backgroundImage && erweimapath && haibaoShow"
  234. @tap="hideModal"
  235. >
  236. <view class="bg-img">
  237. <wm-poster
  238. @success="posterSuccess"
  239. :imgSrc="backgroundImage"
  240. :Referrer="'我的邀请码:' + invitationCode"
  241. :QrSrc="erweimapath"
  242. :Title="tuiguang"
  243. :LineType="false"
  244. ></wm-poster>
  245. </view>
  246. </view>
  247. </view>
  248. <!-- #endif -->
  249. <!-- #ifdef MP-WEIXIN -->
  250. <view
  251. @tap="hideModal"
  252. :class="modalName == 'Image' ? 'show' : ''"
  253. class="modal"
  254. style="text-align: center; display: flex; justify-content: center"
  255. >
  256. <view style="width: 100%; margin: auto">
  257. <image :src="h5SaveImg" mode="widthFix" style="width: 90%"></image>
  258. </view>
  259. </view>
  260. <canvas canvas-id="poster" class="poster_canvas"></canvas>
  261. <!-- #endif -->
  262. </view>
  263. </view>
  264. </template>
  265. <script>
  266. let settingWritePhotosAlbum = false;
  267. import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue";
  268. import appShare from "@/utils/share.js";
  269. import wmPoster from "@/components/wm-poster/wm-posterorders.vue";
  270. import uQRCode from "../../js_sdk/Sansnn-uQRCode/uqrcode.js";
  271. import _app from "../../js_sdk/QuShe-SharerPoster/QS-SharePoster/app.js";
  272. import configdata from "../../common/config.js";
  273. import navBar from "@/components/nav-bar/index.vue";
  274. // import {
  275. // getSharePoster
  276. // } from '../../js_sdk/QuShe-SharerPoster/QS-SharePoster/QS-SharePoster.js';
  277. export default {
  278. components: {
  279. tkiQrcode,
  280. wmPoster,
  281. navBar,
  282. // getSharePoster
  283. },
  284. data() {
  285. return {
  286. erweimapath: "",
  287. poster: {},
  288. qrShow: false,
  289. haibaoImg: null,
  290. haibaoShow: false,
  291. modalName: "",
  292. canvasId: "default_PosterCanvasId",
  293. imageUrl: "",
  294. userImageUrl: "",
  295. isShowWxAPPShare: "否",
  296. nickName: "",
  297. invitationCode: "",
  298. backgroundImage: "",
  299. tuiguang: "",
  300. tuiguang1: "",
  301. url: "",
  302. peopleNum: 0,
  303. zhiRate: 0,
  304. };
  305. },
  306. onLoad() {
  307. //我邀请的人数
  308. this.getYaoNum();
  309. this.getBackImageList();
  310. let avatar = this.$queue.getData("avatar");
  311. if (avatar && avatar !== "undefined") {
  312. this.userImageUrl = avatar;
  313. } else {
  314. this.userImageUrl = "/static/logo.png";
  315. }
  316. this.$Request.getT("/app/common/type/255").then((res) => {
  317. if (res.code === 0) {
  318. if (res.data && res.data.value) {
  319. this.tuiguang = res.data.value;
  320. }
  321. }
  322. });
  323. //文案推广
  324. this.$Request.getT("/app/common/type/255").then((res) => {
  325. if (res.code === 0) {
  326. if (res.data && res.data.value) {
  327. this.tuiguang1 = res.data.value;
  328. }
  329. }
  330. });
  331. //检测书否开启APP微信分享
  332. this.$Request.getT("/app/common/type/136").then((res) => {
  333. if (res.code === 0) {
  334. if (res.data && res.data.value) {
  335. this.isShowWxAPPShare = res.data.value;
  336. }
  337. }
  338. });
  339. this.invitationCode = this.$queue.getData("invitationCode");
  340. // #ifndef H5
  341. this.$Request.getT("/app/common/type/25").then((res) => {
  342. if (res.code === 0) {
  343. if (res.data && res.data.value) {
  344. this.url = res.data.value;
  345. }
  346. }
  347. });
  348. //#endif
  349. // #ifdef H5
  350. this.$Request.getT("/app/common/type/141").then((res) => {
  351. if (res.code === 0) {
  352. if (res.data && res.data.value && res.data.value == "是") {
  353. this.$Request.getT("/app/common/type/25").then((ress) => {
  354. if (ress.code === 0) {
  355. if (ress.data && ress.data.value) {
  356. this.url = ress.data.value;
  357. }
  358. }
  359. });
  360. } else {
  361. this.url = this.$queue.publicYuMing() + "/?invitation=" + this.invitationCode;
  362. }
  363. }
  364. });
  365. //#endif
  366. let userName = this.$queue.getData("userName");
  367. if (userName && userName !== "undefined") {
  368. this.nickName = userName;
  369. } else {
  370. this.nickName = "游客";
  371. }
  372. },
  373. onShow() {
  374. this.zhiRate = this.$queue.getData("zhiRate");
  375. },
  376. onShareAppMessage(res) {
  377. return {
  378. path: "/pages/index/index?invitation=" + this.invitationCode, //这是为了传参 onload(data){let id=data.id;}
  379. title: this.tuiguang,
  380. imageUrl: this.backgroundImage,
  381. };
  382. },
  383. onShareTimeline(res) {
  384. return {
  385. path: "/pages/index/index?invitation=" + uni.getStorageSync("invitationCode"), //这是为了传参
  386. title: this.tuiguang,
  387. imageUrl: this.backgroundImage,
  388. };
  389. },
  390. methods: {
  391. goTeam() {
  392. uni.navigateTo({
  393. url: "/my/team/team",
  394. });
  395. },
  396. //获取我邀请的人数
  397. getYaoNum() {
  398. this.$Request.getT("/app/invite/selectInviteCount", {}).then((res) => {
  399. if (res.code === 0) {
  400. this.peopleNum = res.data;
  401. }
  402. });
  403. },
  404. posterSuccess(haibaoImg) {
  405. this.haibaoImg = haibaoImg;
  406. this.modalName = "Image";
  407. },
  408. showModal() {
  409. if (!this.haibaoImg) {
  410. this.haibaoShow = true;
  411. this.$queue.showLoading("海报生成中...");
  412. } else {
  413. this.modalName = "Image";
  414. }
  415. },
  416. hideModal() {
  417. this.modalName = null;
  418. },
  419. qrR(path) {
  420. this.erweimapath = path;
  421. },
  422. getBackImageList() {
  423. this.$Request
  424. .getT("/app/banner/selectBannerList?state=-1&classify=6")
  425. .then((res) => {
  426. if (res.code === 0) {
  427. this.backgroundImage = res.data[0].imageUrl;
  428. }
  429. });
  430. this.make();
  431. },
  432. make() {
  433. uQRCode.make({
  434. canvasId: "default_PosterCanvasId",
  435. componentInstance: this,
  436. text: this.url,
  437. size: 68,
  438. margin: 4,
  439. backgroundColor: "#ffffff",
  440. foregroundColor: "#000000",
  441. fileType: "jpg",
  442. correctLevel: uQRCode.errorCorrectLevel.H,
  443. success: (res) => {
  444. console.log(res);
  445. },
  446. });
  447. },
  448. shareWeiXin() {
  449. this.$Request.getT("/app/common/type/103").then((res) => {
  450. if (res.code === 0) {
  451. if (res.data && res.data.value) {
  452. let relationId = this.invitationCode;
  453. let shareData = {
  454. shareUrl: this.url,
  455. shareTitle: res.data.value,
  456. shareContent: "邀请码:" + relationId + "," + res.data.value,
  457. shareImg: this.$queue.publicYuMing() + "/logo.png",
  458. type: 0,
  459. };
  460. appShare(shareData, (res) => {
  461. console.log("分享成功回调", res);
  462. });
  463. }
  464. }
  465. });
  466. },
  467. share() {
  468. this.sharurl();
  469. },
  470. sharAPPUrl() {
  471. let that = this;
  472. let relationId = this.invitationCode;
  473. uni.showModal({
  474. title: "文案推广",
  475. content: this.tuiguang1 + relationId + "\n" + this.url,
  476. showCancel: true,
  477. cancelText: "关闭",
  478. confirmText: "一键复制",
  479. confirmColor: "#016BF6",
  480. success: (res) => {
  481. if (res.confirm) {
  482. uni.setClipboardData({
  483. data: this.tuiguang1 + relationId + "\n" + this.url,
  484. success: function () {
  485. console.log("success");
  486. that.$queue.showToast("文案复制成功");
  487. },
  488. });
  489. }
  490. },
  491. });
  492. },
  493. sharurl() {
  494. let that = this;
  495. // this.$queue.showLoading('加载中...');
  496. let relationId = this.invitationCode;
  497. uni.showModal({
  498. title: "文案推广",
  499. content: this.tuiguang1 + relationId + "\n" + this.url,
  500. showCancel: true,
  501. cancelText: "关闭",
  502. confirmText: "一键复制",
  503. confirmColor: "#016BF6",
  504. success: (res) => {
  505. if (res.confirm) {
  506. uni.setClipboardData({
  507. data: this.tuiguang1 + relationId + "\n" + this.url,
  508. success: function () {
  509. console.log("success");
  510. that.$queue.showToast("复制成功");
  511. },
  512. });
  513. }
  514. },
  515. });
  516. },
  517. logoTime(urlList) {
  518. uni.previewImage({
  519. current: 0,
  520. urls: urlList,
  521. loop: true,
  522. longPressActions: {
  523. itemList: ["收藏"],
  524. itemColor: "#007AFF",
  525. },
  526. });
  527. },
  528. goList() {
  529. let userId = this.$queue.getData("userId");
  530. this.$Request
  531. .getT("/app/invite/selectInviteAndPoster?userId=" + userId)
  532. .then((res) => {
  533. if (res.code === 0) {
  534. if (res.data.user.imageUrl) {
  535. this.userImageUrl = res.data.user.imageUrl;
  536. } else {
  537. this.userImageUrl = "/static/img/common/logo.jpg";
  538. }
  539. if (res.data.user.nickName) {
  540. this.nickName = res.data.user.nickName;
  541. } else {
  542. this.nickName = res.data.user.phone;
  543. }
  544. this.invitationCode = res.data.user.invitationCode;
  545. this.imageUrl = res.data.url;
  546. }
  547. });
  548. },
  549. async shareFc() {
  550. let _this = this;
  551. try {
  552. const d = await getSharePoster({
  553. type: "testShareType",
  554. backgroundImage: _this.backgroundImage,
  555. posterCanvasId: _this.canvasId, //canvasId
  556. delayTimeScale: 20, //延时系数
  557. drawArray: ({ bgObj, type, bgScale }) => {
  558. const dx = bgObj.width * 0.3;
  559. const fontSize = bgObj.width * 0.045;
  560. const lineHeight = bgObj.height * 0.04;
  561. //可直接return数组,也可以return一个promise对象, 但最终resolve一个数组, 这样就可以方便实现后台可控绘制海报
  562. return new Promise((rs, rj) => {
  563. rs([
  564. {
  565. type: "custom",
  566. setDraw(Context) {
  567. Context.setFillStyle("black");
  568. Context.setGlobalAlpha(0.3);
  569. Context.fillRect(
  570. 0,
  571. bgObj.height - bgObj.height * 0.2,
  572. bgObj.width,
  573. bgObj.height * 0.2
  574. );
  575. Context.setGlobalAlpha(1);
  576. },
  577. },
  578. {
  579. type: "text",
  580. fontStyle: "italic",
  581. text: "邀请码:" + _this.invitationCode,
  582. size: fontSize,
  583. color: "white",
  584. alpha: 1,
  585. textAlign: "left",
  586. textBaseline: "middle",
  587. infoCallBack(textLength) {
  588. return {
  589. dx: bgObj.width - textLength - fontSize,
  590. dy: bgObj.height - lineHeight * 3,
  591. };
  592. },
  593. serialNum: 0,
  594. id: "tag1", //自定义标识
  595. },
  596. {
  597. type: "qrcode",
  598. text: _this.url,
  599. size: bgObj.width * 0.2,
  600. dx: bgObj.width * 0.05,
  601. dy: bgObj.height - bgObj.width * 0.25,
  602. },
  603. ]);
  604. });
  605. },
  606. setCanvasWH: ({ bgObj, type, bgScale }) => {
  607. // 为动态设置画布宽高的方法,
  608. _this.poster = bgObj;
  609. },
  610. });
  611. //_app.log('海报生成成功, 时间:' + new Date() + ', 临时路径: ' + d.poster.tempFilePath)
  612. _this.poster.finalPath = d.poster.tempFilePath;
  613. _this.qrShow = true;
  614. } catch (e) {
  615. _app.hideLoading();
  616. }
  617. },
  618. saveImage() {
  619. uni.saveImageToPhotosAlbum({
  620. filePath: this.poster.finalPath,
  621. success(res) {
  622. _app.showToast("保存成功");
  623. },
  624. });
  625. },
  626. hideQr() {
  627. this.qrShow = false;
  628. },
  629. // 微信小程序保存图片
  630. async onSaveImg() {
  631. // #ifdef MP-WEIXIN
  632. let imgUrl = await this.createPoster();
  633. uni.showLoading({
  634. title: "海报下载中",
  635. });
  636. if (settingWritePhotosAlbum) {
  637. uni.getSetting({
  638. success: (res) => {
  639. if (res.authSetting["scope.writePhotosAlbum"]) {
  640. uni.saveImageToPhotosAlbum({
  641. filePath: imgUrl,
  642. success: () => {
  643. uni.hideLoading();
  644. uni.showToast({
  645. title: "保存成功",
  646. });
  647. },
  648. });
  649. } else {
  650. uni.showModal({
  651. title: "提示",
  652. content: "请先在设置页面打开“保存相册”使用权限",
  653. confirmText: "去设置",
  654. cancelText: "算了",
  655. confirmColor: "#016BF6",
  656. success: (data) => {
  657. if (data.confirm) {
  658. uni.hideLoading();
  659. uni.openSetting();
  660. }
  661. },
  662. });
  663. }
  664. },
  665. });
  666. } else {
  667. uni.hideLoading();
  668. settingWritePhotosAlbum = true;
  669. uni.authorize({
  670. scope: "scope.writePhotosAlbum",
  671. success: () => {
  672. uni.saveImageToPhotosAlbum({
  673. filePath: imgUrl,
  674. success: () => {
  675. uni.hideLoading();
  676. uni.showToast({
  677. title: "保存成功",
  678. });
  679. },
  680. });
  681. },
  682. });
  683. }
  684. // #endif
  685. },
  686. //生成海报
  687. createPoster() {
  688. let that = this;
  689. return new Promise((resolve, reject) => {
  690. uni.showLoading({
  691. title: "海报生成中",
  692. });
  693. const ctx = uni.createCanvasContext("poster");
  694. ctx.fillRect(0, 0, 375, 673);
  695. ctx.setFillStyle("#FFF");
  696. ctx.fillRect(0, 0, 375, 673);
  697. let imgUrl = that.backgroundImage;
  698. uni.downloadFile({
  699. url: imgUrl,
  700. success: (res) => {
  701. if (res.statusCode === 200) {
  702. console.log(
  703. that.config("APIHOST1") +
  704. "/app/invite/mpCreateQr?invitationCode=" +
  705. that.invitationCode
  706. );
  707. uni.downloadFile({
  708. url:
  709. that.config("APIHOST1") +
  710. "/app/invite/mpCreateQr?invitationCode=" +
  711. that.invitationCode,
  712. success: (res2) => {
  713. console.log(res2);
  714. uni.hideLoading();
  715. if (res.statusCode === 200) {
  716. ctx.drawImage(res.tempFilePath, 0, 0, 375, 500);
  717. // 长按识别二维码访问
  718. let textTop = 0;
  719. ctx.setFontSize(19);
  720. ctx.setFillStyle("#333");
  721. ctx.fillText("长按识别图中二维码", 17, textTop + 590);
  722. // 二维码
  723. ctx.drawImage(res2.tempFilePath, 238, textTop + 526, 120, 120);
  724. ctx.draw(true, () => {
  725. // canvas画布转成图片并返回图片地址
  726. uni.canvasToTempFilePath({
  727. canvasId: "poster",
  728. width: 375,
  729. height: 673,
  730. success: (res) => {
  731. console.log("海报制作成功!");
  732. resolve(res.tempFilePath);
  733. },
  734. fail: () => {
  735. uni.hideLoading();
  736. reject();
  737. },
  738. });
  739. });
  740. } else {
  741. uni.hideLoading();
  742. uni.showToast({
  743. title: "海报制作失败,图片下载失败",
  744. icon: "none",
  745. });
  746. }
  747. },
  748. fail: (err) => {
  749. console.log(err);
  750. uni.hideLoading();
  751. uni.showToast({
  752. title: "海报制作失败,图片下载失败",
  753. icon: "none",
  754. });
  755. },
  756. complete: (com) => {
  757. console.log(com);
  758. uni.showToast({
  759. title: com,
  760. icon: "none",
  761. });
  762. },
  763. });
  764. } else {
  765. uni.hideLoading();
  766. uni.showToast({
  767. title: "海报制作失败,图片下载失败",
  768. icon: "none",
  769. });
  770. }
  771. },
  772. fail: (err) => {
  773. // that.yu.toast(err)
  774. console.log(err);
  775. uni.hideLoading();
  776. uni.showToast({
  777. title: "海报制作失败,图片下载失败",
  778. icon: "none",
  779. });
  780. },
  781. });
  782. });
  783. },
  784. config: function (name) {
  785. var info = null;
  786. if (name) {
  787. var name2 = name.split("."); //字符分割
  788. if (name2.length > 1) {
  789. info = configdata[name2[0]][name2[1]] || null;
  790. } else {
  791. info = configdata[name] || null;
  792. }
  793. if (info == null) {
  794. let web_config = cache.get("web_config");
  795. if (web_config) {
  796. if (name2.length > 1) {
  797. info = web_config[name2[0]][name2[1]] || null;
  798. } else {
  799. info = web_config[name] || null;
  800. }
  801. }
  802. }
  803. }
  804. return info;
  805. },
  806. },
  807. };
  808. </script>
  809. <style lang="scss" scoped>
  810. .page-box {
  811. position: absolute;
  812. left: 0;
  813. bottom: 0;
  814. right: 0;
  815. top: 0;
  816. overflow: hidden;
  817. display: flex;
  818. flex-direction: column;
  819. .page-content {
  820. flex: 1;
  821. overflow: hidden;
  822. overflow-y: auto;
  823. }
  824. }
  825. .content {
  826. height: 50vh;
  827. background: linear-gradient(0deg, #ffffff 0%, #e5eeff 51%);
  828. }
  829. .modal {
  830. position: fixed;
  831. top: 0;
  832. right: 0;
  833. bottom: 0;
  834. left: 0;
  835. z-index: 1110;
  836. opacity: 0;
  837. outline: 0;
  838. text-align: center;
  839. -ms-transform: scale(1.185);
  840. transform: scale(1.185);
  841. backface-visibility: hidden;
  842. perspective: 2000upx;
  843. /* background: rgba(0, 0, 0, 0.6); */
  844. background: #ffffff;
  845. transition: all 0.3s ease-in-out 0s;
  846. pointer-events: none;
  847. }
  848. .modal.show {
  849. opacity: 1;
  850. transition-duration: 0.3s;
  851. -ms-transform: scale(1);
  852. transform: scale(1);
  853. overflow-x: hidden;
  854. overflow-y: auto;
  855. pointer-events: auto;
  856. }
  857. page {
  858. background: #ffffff;
  859. }
  860. .view1 {
  861. border-radius: 15upx;
  862. /* background-size: 100%; */
  863. background-size: cover;
  864. margin: 20upx 20upx 0 20upx;
  865. }
  866. .hideCanvasView {
  867. position: relative;
  868. }
  869. .hideCanvas {
  870. position: fixed;
  871. top: -99999upx;
  872. left: -99999upx;
  873. z-index: -99999;
  874. }
  875. .flex_row_c_c {
  876. display: flex;
  877. flex-direction: row;
  878. justify-content: center;
  879. align-items: center;
  880. }
  881. .modalView {
  882. width: 100%;
  883. height: 100%;
  884. position: fixed;
  885. top: 0;
  886. left: 0;
  887. right: 0;
  888. bottom: 0;
  889. opacity: 0;
  890. outline: 0;
  891. transform: scale(1.2);
  892. perspective: 2500upx;
  893. /* background: rgba(0, 0, 0, 0.6); */
  894. background: #ffffff;
  895. transition: all 0.3s ease-in-out;
  896. pointer-events: none;
  897. backface-visibility: hidden;
  898. z-index: 999;
  899. }
  900. .modalView.show {
  901. opacity: 1;
  902. transform: scale(1);
  903. pointer-events: auto;
  904. }
  905. .flex_column {
  906. display: flex;
  907. flex-direction: column;
  908. }
  909. .backgroundColor-white {
  910. background-color: white;
  911. }
  912. .border_radius_10px {
  913. border-radius: 10px;
  914. }
  915. .padding1vh {
  916. padding: 1vh;
  917. }
  918. .posterImage {
  919. width: 60vw;
  920. }
  921. .flex_row {
  922. display: flex;
  923. flex-direction: row;
  924. }
  925. .marginTop2vh {
  926. margin-top: 2vh;
  927. }
  928. .poster_canvas {
  929. width: 750upx;
  930. height: 1334upx;
  931. position: fixed;
  932. top: -10000upx;
  933. left: 0;
  934. }
  935. </style>