invitationUser.vue 25 KB

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