| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- import {
- imgServerUrl
- } from '../../config/config.js'
- import {
- showToast
- } from '../../utils/tips.js'
- import Poster from '../../components/wxa-plugin-canvas/poster/poster';
- import {
- shareQrCodeB,
- getGroupDetail
- } from '../../services/index.js'
- import {
- updataStorageData
- } from '../../utils/storage.js'
- var app = getApp()
- Page({
- data: {
- hasShare:true,
- imgServerUrl: imgServerUrl,
- qrCode: '',
- hasAuth: true,
- posterConfig: '',
- userInfo: '',
- canIUse: wx.canIUse('button.open-type.getUserInfo'),
- },
- onLoad: function(options) {
- this.setData({
- hpPositionGroupId: options.hpPositionGroupId,
- positionCategory: options.positionCategory,
- positionId: options.positionId
- })
- },
- onShow: function() {
- if (app.globalData.userInfo) {
- console.log('有info===', app.globalData)
- this.setData({
- userInfo: app.globalData.userInfo
- })
- this.start()
- }
- this.setData({
- hasAuth: true
- })
- },
- start() {
- Promise.all([this.fetchData()]).then(data => {
- let posterConfig = {
- width: 700,
- height: 950,
- debug: false,
- texts: [{
- x: 54,
- y: 260,
- baseLine: 'middle',
- text: this.data.userInfo.nickName,
- fontSize: 38,
- color: '#ffffff',
- lineHeight: 30,
- zIndex: 2,
- },
- {
- x: 54,
- y: 316,
- baseLine: 'middle',
- text: '“我在找好友一起上班!”',
- fontSize: 26,
- color: '#ffffff',
- zIndex: 2,
- },
- {
- x: 350,
- y: 446,
- baseLine: 'middle',
- textAlign: "center",
- width: 700,
- text: this.data.postitionDetail.position.positionName,
- fontSize: 38,
- color: '#ffffff',
- lineHeight: 38,
- zIndex: 2
- },
- {
- x: 350,
- y: 494,
- baseLine: 'middle',
- textAlign: "center",
- width: 700,
- text: this.data.postitionDetail.position.hpCompany.companyName,
- fontSize: 20,
- color: '#ffffff',
- zIndex: 2,
- },
- {
- x: 350,
- y: 542,
- baseLine: 'middle',
- textAlign: "center",
- width: 700,
- text: this.data.postitionDetail.position.totalSalary ? this.data.postitionDetail.position.totalSalary : this.data.postitionDetail.position.basicSalary,
- fontSize: 50,
- color: '#ffffff',
- zIndex: 2,
- },
- {
- x: 62,
- y: 828,
- baseLine: 'middle',
- text: '专属客服,全程服务',
- fontSize: 20,
- color: '#ffffff',
- zIndex: 2,
- },
- {
- x: 464,
- y: 786,
- baseLine: 'middle',
- text: '识别右侧二维码,',
- fontSize: 20,
- color: '#ffffff',
- zIndex: 2,
- },
- {
- x: 464,
- y: 812,
- baseLine: 'middle',
- text: '即可参与我发起的拼工!',
- fontSize: 20,
- color: '#ffffff',
- zIndex: 2,
- }
- ],
- images: [{
- width: 700,
- height: 950,
- x: 0,
- y: 0,
- url: '/images/happyjob/bg.png',
- zIndex: 1,
- },
- {
- width: 218,
- height: 218,
- x: 400,
- y: 160,
- url: app.globalData.userInfo.avatarUrl,
- borderRadius: 222,
- zIndex: 2,
- borderWidth: 12,
- borderColor: '#fff',
- },
- {
- width: 196,
- height: 40,
- x: 50,
- y: 772,
- url: '/images/happyjob/logo.png',
- zIndex: 2,
- },
- {
- width: 180,
- height: 180,
- x: 270,
- y: 700,
- url: this.data.qrcode, //二维码
- zIndex: 2,
- borderRadius: 6,
- borderWidth: 14,
- borderColor: '#fff',
- },
- ],
- }
- console.log("sd", posterConfig)
- this.setData({
- posterConfig
- })
- })
- },
- //获取历史记录
- fetchData() {
- wx.showLoading({
- title: 'loading',
- mask: true
- });
- var that = this
- return new Promise(function(resolve, reject) {
- try {
- var value = wx.getStorageSync('groupDetail')
- if (value) {
- // Do something with return value
- wx.hideLoading()
- that.setData({
- postitionDetail: value,
- qrcode: value.qrcodeUrl,
- })
- resolve(true)
- }
- } catch (e) {
- // Do something when catch error
- console.log(data)
- wx.hideLoading()
- reject(data)
- }
- })
- },
- onPosterSuccess(e) {
- console.log("dddf", e)
- var detail = e.detail;
- console.log("df", detail)
- var that = this
- wx.saveImageToPhotosAlbum({
- filePath: detail,
- success(res) {
- console.log(res)
- wx.hideLoading();
- showToast('已保存到相册,快去分享吧!')
- },
- fail(err) {
- wx.hideLoading();
- showToast('请授权保存到相册')
- that.setData({
- hasAuth: false
- })
- }
- })
- wx.hideLoading()
- },
- onPosterFail(err) {
- wx.hideLoading()
- console.error(err);
- },
- /**
- * 异步生成海报
- */
- onCreatePoster() {
- Poster.create();
- },
- qrcodeLoad(e) {
- wx.hideLoading()
- },
- onShareAppMessage: function() {
- return {
- title: '开心工作参团有奖',
- path: '/pages/pt-detail/index?gd=' + this.data.hpPositionGroupId + '&pc=' + this.data.positionCategory + '&pd=' + this.data.positionId,
- imageUrl: ''
- }
- },
- onError(err) {
- app.aldstat.sendEvent('报错', {
- 'err': err
- });
- },
- })
|