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