|
|
@@ -1,8 +1,17 @@
|
|
|
-import { imgServerUrl } from '../../config/config.js'
|
|
|
-import { showToast } from '../../utils/tips.js'
|
|
|
+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'
|
|
|
+import {
|
|
|
+ shareQrCodeB,
|
|
|
+ getGroupDetail
|
|
|
+} from '../../services/index.js'
|
|
|
+import {
|
|
|
+ updataStorageData
|
|
|
+} from '../../utils/storage.js'
|
|
|
var app = getApp()
|
|
|
|
|
|
Page({
|
|
|
@@ -10,213 +19,87 @@ Page({
|
|
|
imgServerUrl: imgServerUrl,
|
|
|
qrCode: '',
|
|
|
hasAuth: true,
|
|
|
- posterConfig:'',
|
|
|
+ posterConfig: '',
|
|
|
userInfo: '',
|
|
|
},
|
|
|
- onLoad: function (options) {
|
|
|
+ onLoad: function(options) {
|
|
|
this.setData({
|
|
|
hpPositionGroupId: options.hpPositionGroupId,
|
|
|
- userInfo: app.globalData.userInfo,
|
|
|
+ positionCategory: options.positionCategory,
|
|
|
+ positionId: options.positionId
|
|
|
})
|
|
|
- // this.fetchData()
|
|
|
- // this.getCode()
|
|
|
- Promise.all([this.fetchData(), this.getCode()]).then(data=>{
|
|
|
- let posterConfig = {
|
|
|
- width: 700,
|
|
|
- height: 950,
|
|
|
- debug: false,
|
|
|
- // blocks: [
|
|
|
- // {
|
|
|
- // x: 192,
|
|
|
- // y: 600,
|
|
|
- // height: 33,
|
|
|
- // baseLine: 'middle',
|
|
|
- // paddingLeft: 15,
|
|
|
- // paddingRight: 15,
|
|
|
- // zIndex: 2,
|
|
|
- // borderRadius: 4,
|
|
|
- // backgroundColor: '#fff',
|
|
|
- // text: {
|
|
|
- // text: [
|
|
|
- // {
|
|
|
- // text: '男女不限',
|
|
|
- // fontSize: 16,
|
|
|
- // color: '#0e79d0',
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // baseLine: 'middle',
|
|
|
- // }
|
|
|
-
|
|
|
- // },
|
|
|
- // ],
|
|
|
- texts: [
|
|
|
- {
|
|
|
- x: 90,
|
|
|
- y: 250,
|
|
|
- baseLine: 'middle',
|
|
|
- text: '推荐奖励',
|
|
|
- fontSize: 30,
|
|
|
- color: '#ffffff',
|
|
|
- lineHeight: 30,
|
|
|
- zIndex: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- x: 472,
|
|
|
- y: 250,
|
|
|
- baseLine: 'middle',
|
|
|
- text: '诚信企业',
|
|
|
- fontSize: 30,
|
|
|
- color: '#ffffff',
|
|
|
- lineHeight: 30,
|
|
|
- zIndex: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- x: 350,
|
|
|
- y: 390,
|
|
|
- baseLine: 'middle',
|
|
|
- // text: '王明',
|
|
|
- text: this.data.userInfo.nickName,
|
|
|
- textAlign: 'center',
|
|
|
- width: 700,
|
|
|
- fontSize: 64,
|
|
|
- color: '#ffffff',
|
|
|
- lineHeight: 30,
|
|
|
- zIndex: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- x: 350,
|
|
|
- y: 487,
|
|
|
- baseLine: 'middle',
|
|
|
- text: '我在找好友一起上班',
|
|
|
- textAlign: 'center',
|
|
|
- fontSize: 37,
|
|
|
- color: '#ffffff',
|
|
|
- zIndex: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- x: 192,
|
|
|
- y: 570,
|
|
|
- baseLine: 'middle',
|
|
|
- // text: '无锡先导自动化设备股份有限公司',
|
|
|
- text: this.data.comName,
|
|
|
- fontSize: 26,
|
|
|
- color: '#ffffff',
|
|
|
- zIndex: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- x: 70,
|
|
|
- y: 791,
|
|
|
- baseLine: 'middle',
|
|
|
- text: '立即扫码',
|
|
|
- fontSize: 30,
|
|
|
- color: '#ffffff',
|
|
|
- zIndex: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- x: 500,
|
|
|
- y: 791,
|
|
|
- baseLine: 'middle',
|
|
|
- text: '开心工作',
|
|
|
- fontSize: 30,
|
|
|
- color: '#ffffff',
|
|
|
- zIndex: 2,
|
|
|
- },
|
|
|
-
|
|
|
- ],
|
|
|
- images: [
|
|
|
- {
|
|
|
- width: 700,
|
|
|
- height: 950,
|
|
|
- x: 0,
|
|
|
- y: 0,
|
|
|
- url: `${imgServerUrl}/images/pt/bg.png`,
|
|
|
- zIndex: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- width: 222,
|
|
|
- height: 222,
|
|
|
- x: 230,
|
|
|
- y: 102,
|
|
|
- // url: `${imgServerUrl}/images/pt/bg.png`,
|
|
|
- url: app.globalData.userInfo.avatarUrl,
|
|
|
- borderRadius: 222,
|
|
|
- zIndex: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- width: 90,
|
|
|
- height: 90,
|
|
|
- x: 70,
|
|
|
- y: 562,
|
|
|
- borderRadius: 90,
|
|
|
- // url: `${imgServerUrl}/images/avatar/man.png`,
|
|
|
- url: this.data.comLogo,
|
|
|
- zIndex: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- width: 196,
|
|
|
- height: 196,
|
|
|
- x: 245,
|
|
|
- y: 712,
|
|
|
- // url: `${imgServerUrl}/images/temp/men.png`,
|
|
|
- url: this.data.qrCode,
|
|
|
- zIndex: 2,
|
|
|
- },
|
|
|
- ],
|
|
|
- }
|
|
|
- if (!this.data.comLogo){
|
|
|
- posterConfig.images.splice(2,1)
|
|
|
- }
|
|
|
- console.log(posterConfig)
|
|
|
+ },
|
|
|
+ onShow: function() {
|
|
|
+ if (app.globalData.userInfo) {
|
|
|
+ console.log('有info===', app.globalData)
|
|
|
this.setData({
|
|
|
- posterConfig
|
|
|
+ userInfo: app.globalData.userInfo
|
|
|
})
|
|
|
-
|
|
|
- })
|
|
|
- },
|
|
|
- onShow: function () {
|
|
|
- this.setData({
|
|
|
- hasAuth: true
|
|
|
- })
|
|
|
+ this.fetchData()
|
|
|
+ } else if (this.data.canIUse) {
|
|
|
+ // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
|
+ // 所以此处加入 callback 以防止这种情况
|
|
|
+ app.userInfoReadyCallback = res => {
|
|
|
+ console.log('userInfoReadyCallback===', app.globalData)
|
|
|
+ this.setData({
|
|
|
+ userInfo: app.globalData.userInfo
|
|
|
+ })
|
|
|
+ this.fetchData()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 在没有 open-type=getUserInfo 版本的兼容处理
|
|
|
+ wx.getUserInfo({
|
|
|
+ success: res => {
|
|
|
+ app.globalData.userInfo = res.userInfo
|
|
|
+ console.log('兼容处理===', app.globalData)
|
|
|
+ this.setData({
|
|
|
+ userInfo: app.globalData.userInfo
|
|
|
+ })
|
|
|
+ this.fetchData()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
//获取历史记录
|
|
|
fetchData() {
|
|
|
- var that = this
|
|
|
- return new Promise(function (resolve,reject){
|
|
|
- getGroupDetail({
|
|
|
- hpPositionGroupId: that.data.hpPositionGroupId
|
|
|
- }).then(data => {
|
|
|
- console.log(data)
|
|
|
- that.setData({
|
|
|
- comLogo: data.data.comLogo,
|
|
|
- comName: data.data.comName
|
|
|
- })
|
|
|
- resolve(true)
|
|
|
- }).catch(data=>{
|
|
|
- console.log(data)
|
|
|
- reject(data)
|
|
|
+ let paramsObj = {
|
|
|
+ positionCategory: this.data.positionCategory,
|
|
|
+ positionId: this.data.positionId,
|
|
|
+ groupId: this.data.hpPositionGroupId,
|
|
|
+ user_id: app.globalData.userId,
|
|
|
+ user_token: app.globalData.userToken
|
|
|
+ }
|
|
|
+ Object.assign(paramsObj);
|
|
|
+ getGroupDetail(paramsObj).then(data => {
|
|
|
+ console.log("groupDetail", data)
|
|
|
+ var leftTime = data.data.position.groupEndTime
|
|
|
+ this.setData({
|
|
|
+ postitionDetail: data.data
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
},
|
|
|
+
|
|
|
onPosterSuccess(e) {
|
|
|
console.log(e)
|
|
|
- const { detail } = e;
|
|
|
- var that =this
|
|
|
+ const {
|
|
|
+ detail
|
|
|
+ } = e;
|
|
|
+ var that = this
|
|
|
wx.saveImageToPhotosAlbum({
|
|
|
filePath: detail,
|
|
|
success(res) {
|
|
|
console.log(res)
|
|
|
wx.hideLoading();
|
|
|
- showToast('已保存到相册,快去分享吧!','success',3000)
|
|
|
+ showToast('已保存到相册,快去分享吧!', 'success', 3000)
|
|
|
},
|
|
|
- fail(err){
|
|
|
+ fail(err) {
|
|
|
wx.hideLoading();
|
|
|
showToast('请授权保存到相册')
|
|
|
that.setData({
|
|
|
hasAuth: false
|
|
|
})
|
|
|
}
|
|
|
- })
|
|
|
+ })
|
|
|
},
|
|
|
onPosterFail(err) {
|
|
|
console.error(err);
|
|
|
@@ -225,32 +108,35 @@ Page({
|
|
|
/**
|
|
|
* 异步生成海报
|
|
|
*/
|
|
|
- onCreatePoster() {
|
|
|
+ onCreatePoster() {
|
|
|
Poster.create();
|
|
|
},
|
|
|
getCode() {
|
|
|
- wx.showLoading({ title: 'loading', mask: true });
|
|
|
+ wx.showLoading({
|
|
|
+ title: 'loading',
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
var that = this
|
|
|
- return new Promise(function (resolve,reject){
|
|
|
+ return new Promise(function(resolve, reject) {
|
|
|
let targetUrl = 'pages/pt-detail/index?hpPositionGroupId=' + that.data.hpPositionGroupId + '&shareToken=' + updataStorageData('shareToken')
|
|
|
shareQrCodeB(targetUrl).then(data => {
|
|
|
that.setData({
|
|
|
qrCode: data.data.imgUrl
|
|
|
- })
|
|
|
+ })
|
|
|
resolve(true)
|
|
|
- }).catch(data=>{
|
|
|
+ }).catch(data => {
|
|
|
console.log(data)
|
|
|
reject(data)
|
|
|
})
|
|
|
- })
|
|
|
+ })
|
|
|
},
|
|
|
- qrcodeLoad(e){
|
|
|
+ qrcodeLoad(e) {
|
|
|
wx.hideLoading()
|
|
|
},
|
|
|
|
|
|
onError(err) {
|
|
|
- app.aldstat.sendEvent('报错',{
|
|
|
- 'err': err
|
|
|
+ app.aldstat.sendEvent('报错', {
|
|
|
+ 'err': err
|
|
|
});
|
|
|
},
|
|
|
})
|