| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- import { imgServerUrl } from '../../config/config.js'
- import { showToast } from '../../utils/tips.js'
- import Poster from '../../components/wxa-plugin-canvas/poster/poster'
- import { shareQrCodeA } from '../../services/index.js'
- import { updataStorageData } from '../../utils/storage.js'
- var app = getApp()
- Page({
- data: {
- imgServerUrl: imgServerUrl,
- qrCode:'',
- hasAuth:'',
- posterConfig: {
- width: 750,
- height: 1200,
- backgroundColor: '#1d449a',
- debug: false,
- blocks: [
- {
- x: 0,
- y: 330,
- width: 750,
- height: 8,
- backgroundColor: '#3f6dd3',
- zIndex: 2,
- },
- {
- x: 15,
- y: 370,
- width: 720,
- height: 800,
- backgroundColor: '#fffcf7',
- borderRadius: 10,
- paddingLeft: 50,
- paddingRight: 50,
- zIndex: 2,
- },
- {
- x: 207,
- y: 825,
- width: 338,
- height: 175,
- borderColor: '#1d449a',
- borderWidth: 1,
- zIndex: 4,
- }
- ],
- texts: [
- // {
- // x: 220,
- // y: 240,
- // baseLine: 'middle',
- // text: '每邀请1位新用户注册',
- // fontSize: 33,
- // color: '#ffffff',
- // lineHeight: 40,
- // zIndex: 2,
- // },
- // {
- // x: 220,
- // y: 290,
- // baseLine: 'middle',
- // text: '即可得5元现金红包',
- // fontSize: 33,
- // lineHeight: 40,
- // color: '#ffffff',
- // zIndex: 4,
- // },
- {
- x: 230,
- y: 880,
- baseLine: 'middle',
- text: '我在【开心工作】',
- fontSize: 18,
- lineHeight: 40,
- color: '#2a2a2a',
- zIndex: 4,
- },
- {
- x: 230,
- y: 912,
- baseLine: 'middle',
- text: '赚了5块钱',
- fontSize: 18,
- lineHeight: 40,
- color: '#2a2a2a',
- zIndex: 4,
- },
- {
- x: 230,
- y: 940,
- baseLine: 'middle',
- text: '扫码分享给你',
- fontSize: 18,
- lineHeight: 40,
- color: '#2a2a2a',
- zIndex: 4,
- },
- ],
- images: [
- {
- width: 750,
- height: 325,
- x: 0,
- y: 0,
- url: `${imgServerUrl}/images/recommend/awardBg.png`,
- zIndex: 1,
- },
- // {
- // width: 750,
- // height: 330,
- // x: 0,
- // y: 0,
- // url: `${imgServerUrl}/images/recommend/tuijian-bg.png`,
- // zIndex: 1,
- // },
- // {
- // x: 80,
- // y: 30,
- // width: 593,
- // height: 172,
- // url: `${imgServerUrl}/images/recommend/title.png`,
- // zIndex: 2,
- // },
- {
- x: 65,
- y: 400,
- width: 623,
- height: 372,
- url: `${imgServerUrl}/images/recommend/step.png`,
- zIndex: 4,
- },
- {
- x: 374,
- y: 835,
- width: 155,
- height: 155,
- url: '',
- zIndex: 4,
- }
- ],
- }
- },
- onLoad: function (options) {
- this.getCode()
- },
- onShow(){
- this.setData({
- hasAuth:true
- })
- },
- getCode(){
- let targetUrl = 'pages/recommend-iphone/index?shareToken=' + updataStorageData('shareToken')
- shareQrCodeA(targetUrl).then(data=>{
- this.setData({
- qrCode:data.data.imgUrl
- })
- })
- },
- onPosterSuccess(e) {
- const { detail } = e;
- var that = this
- wx.saveImageToPhotosAlbum({
- filePath: detail,
- success(res) {
- wx.hideLoading();
- showToast('已保存到相册!','success',3000)
- },
- fail(err){
- wx.hideLoading();
- showToast('请授权保存到相册')
- that.setData({
- hasAuth: false
- })
- }
- })
- },
- onPosterFail(err) {
- console.error(err);
- },
- /**
- * 异步生成海报
- */
- onCreatePoster() {
- // `/images/recommend/qrcode.jpg`
- wx.showLoading({ title: 'loading', mask: true });
- this.data.posterConfig.images[this.data.posterConfig.images.length - 1].url = this.data.qrCode
- this.setData({
- posterConfig:this.data.posterConfig
- }, () => {
- Poster.create();
- });
- },
- onError(err) {
- app.aldstat.sendEvent('报错',{
- 'err': err
- });
- },
- })
|