@@ -9,6 +9,7 @@ Page({ | |||
imgUrl: app.globalData.urlStatic,//图片路径 | |||
yuyueShow:false, | |||
userType:1, | |||
isShowFun:false | |||
}, | |||
/** | |||
@@ -41,8 +42,28 @@ Page({ | |||
* 生命周期函数--监听页面显示 | |||
*/ | |||
onShow: function () { | |||
if(app.globalData.getSecondGuessInfo.firstData){ | |||
this.data.userType = 1; | |||
// if(app.globalData.getSecondGuessInfo.firstData){ | |||
// this.data.userType = 1; | |||
// } | |||
if(this.data.isShowFun){ | |||
var getSecondGuessInfo = app.globalData.getSecondGuessInfo; | |||
var userType = 1; | |||
if(getSecondGuessInfo.secondData){ | |||
userType = 1; | |||
// console.log("查看第二轮价格") | |||
}else if(!getSecondGuessInfo.firstData && !getSecondGuessInfo.secondData){ | |||
userType = 2; | |||
// console.log("开始竞猜"); | |||
}else if(getSecondGuessInfo.firstData.lucky_result==-1){ | |||
userType = 3; | |||
// console.log("调整价格"); | |||
}else{ | |||
userType = 4; | |||
// console.log("去抽大奖"); | |||
} | |||
this.setData({ | |||
userType:userType | |||
}) | |||
} | |||
}, | |||
@@ -91,11 +112,11 @@ Page({ | |||
}) | |||
}, | |||
enterGuessPrize:function(){//开始竞猜 | |||
if(this.data.userType == 1){ | |||
if(this.data.userType == 1 || this.data.userType == 2){ | |||
wx.navigateTo({ | |||
url: '/pages/guessSecondPrize/guessSecondPrize' | |||
}) | |||
}else if(this.data.userType == 2){ | |||
}else if(this.data.userType == 3){ | |||
wx.navigateTo({ | |||
url: '/pages/guessSecond/guessSecond?type=1' | |||
}) | |||
@@ -109,13 +130,31 @@ Page({ | |||
app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondGuessInfo", {}, res => { | |||
if (res.code == 200) { | |||
app.globalData.getSecondGuessInfo = res.data; | |||
if(res.data.secondData || !res.data.firstData){ | |||
this.data.userType = 1; | |||
// if(res.data.secondData || !res.data.firstData){ | |||
// this.data.userType = 1; | |||
// }else if(res.data.firstData.lucky_result==-1){ | |||
// this.data.userType = 2; | |||
// }else{ | |||
// this.data.userType = 3; | |||
// } | |||
var userType = 1; | |||
if(res.data.secondData){ | |||
userType = 1; | |||
// console.log("查看第二轮价格") | |||
}else if(!res.data.firstData && !res.data.secondData){ | |||
userType = 2; | |||
// console.log("开始竞猜"); | |||
}else if(res.data.firstData.lucky_result==-1){ | |||
this.data.userType = 2; | |||
userType = 3; | |||
// console.log("调整价格"); | |||
}else{ | |||
this.data.userType = 3; | |||
userType = 4; | |||
// console.log("去抽大奖"); | |||
} | |||
this.setData({ | |||
userType:userType, | |||
isShowFun:true | |||
}) | |||
} | |||
}, this); | |||
} |
@@ -3,7 +3,11 @@ | |||
<view class="main"> | |||
<image class="pageBg" src="{{imgUrl+'/newImages4/20.png'}}"></image> | |||
<image class="gameRule" src="{{imgUrl+'/newImages4/17.png'}}"></image> | |||
<image class="startBtn" bindtap="enterGuessPrize" src="{{imgUrl+'/versions/2.png?v=002'}}"></image> | |||
<image class="startBtn" bindtap="enterGuessPrize" wx:if="{{userType==1}}" src="{{imgUrl+'/newImages5/60.png'}}"></image> | |||
<image class="startBtn" bindtap="enterGuessPrize" wx:if="{{userType==4}}" src="{{imgUrl+'/newImages5/61.png'}}"></image> | |||
<image class="startBtn" bindtap="enterGuessPrize" wx:if="{{userType==3}}" src="{{imgUrl+'/newImages5/62.png'}}"></image> | |||
<image class="startBtn" bindtap="enterGuessPrize" wx:if="{{userType==2}}" src="{{imgUrl+'/newImages5/63.png'}}"></image> | |||
<image class="drawBtn" bindtap="enterLucky" src="{{imgUrl+'/versions/1.png'}}"></image> | |||
<image class="yuyue" bindtap="yuyueControl" src="{{imgUrl+'/newIcon/4.png'}}"></image> | |||
</view> |
@@ -1,5 +1,12 @@ | |||
// pages/guessPoster/guessPoster.js | |||
const app = getApp() | |||
let _savePostBg = "";//用于绘制海报的背景 | |||
let _totalDownloadTask = 2;//绘制需要下载的图片总数 | |||
let _currentSuccessDownloadTask = 0;//已完成下载的图片数 | |||
let windowScale = 0;//屏幕缩放比 | |||
let canvasContron = null;//canvas | |||
let posterUrl = "";//合成后的海报路径 | |||
let _saveImg = false; | |||
Page({ | |||
/** | |||
@@ -7,7 +14,10 @@ Page({ | |||
*/ | |||
data: { | |||
imgUrl: app.globalData.urlStatic,//图片路径 | |||
selectType:2,//选中的分享类型 | |||
selectType:1,//选中的分享类型 | |||
userPrice:0,//用户竞猜价格 | |||
userName:"",//用户昵称 | |||
qrCodeUrl:"",//用户二维码 | |||
}, | |||
/** | |||
@@ -15,19 +25,33 @@ Page({ | |||
*/ | |||
onLoad: function (options) { | |||
app.globalData.nowPage = 3; | |||
this.setData({ | |||
userName:app.globalData.userInfoData.nickName, | |||
userPrice:app.globalData.getSecondGuessInfo.secondData.guess_price | |||
}) | |||
}, | |||
loadFun:function(){ | |||
this.getGuessPriceQrCode(); | |||
}, | |||
/** | |||
* 生命周期函数--监听页面初次渲染完成 | |||
*/ | |||
onReady: function () { | |||
canvasContron = wx.createCanvasContext('myCanvas'); | |||
if (app.globalData.openid) { | |||
this.loadFun(); | |||
} else { | |||
app.globalData.openidSuccessFuc = this.loadFun; | |||
} | |||
}, | |||
/** | |||
* 生命周期函数--监听页面显示 | |||
*/ | |||
onShow: function () { | |||
_totalDownloadTask = 2; | |||
_currentSuccessDownloadTask = 0; | |||
_saveImg = false; | |||
}, | |||
/** | |||
@@ -63,14 +87,135 @@ Page({ | |||
*/ | |||
onShareAppMessage: function () { | |||
return { | |||
title: '您有一份启辰星专属礼品待领取', | |||
imageUrl: this.data.imgUrl + "/newImages3/28_" + (this.data.swiperCurrent+1)+".png?v=004", | |||
path: "/pages/coupon/coupon?scene=" + app.globalData.openid | |||
title: '召唤预言帝!快来和我一起猜启辰星售价,赢升舱大奖!', | |||
imageUrl:this.data.imgUrl+'/newImages5/56.jpg', | |||
path: "/pages/guess/guess" | |||
} | |||
}, | |||
changeType:function(){//切换分享类型 | |||
this.setData({ | |||
selectType:this.data.selectType==1?2:1 | |||
}) | |||
}, | |||
getGuessPriceQrCode:function(){//获取竞猜分享小程序码 | |||
app.wxRequest(app.globalData.urlRoot + "guessPrice/getGuessPriceQrCode", {}, res => { | |||
if (res.code == 200) { | |||
this.setData({ | |||
qrCodeUrl:res.data.qrcodeUrl | |||
}) | |||
this.cacheFun(); | |||
} | |||
}, this); | |||
}, | |||
cacheFun:function(){ | |||
wx.getSystemInfo({ | |||
success: option => { | |||
windowScale = option.windowWidth / 750; | |||
wx.getImageInfo({//缓存海报背景 | |||
src: this.data.imgUrl + '/newImages5/66.png', | |||
success: res => { | |||
_savePostBg = res.path; | |||
_currentSuccessDownloadTask ++; | |||
this.posterDrawing(); | |||
} | |||
}) | |||
wx.getImageInfo({//缓存二维码 | |||
src: this.data.qrCodeUrl, | |||
success: res => { | |||
this.data.qrCodeUrl = res.path; | |||
_currentSuccessDownloadTask++; | |||
this.posterDrawing(); | |||
} | |||
}) | |||
} | |||
}) | |||
}, | |||
posterDrawing: function (e) {//海报绘制 | |||
//图片尚未下载完成,禁止绘制 | |||
if(_currentSuccessDownloadTask < _totalDownloadTask){ | |||
return; | |||
} | |||
var ctx = canvasContron;//canvas对象 | |||
var scale = windowScale;//屏幕缩放比 | |||
//背景 | |||
ctx.drawImage(_savePostBg, 0, 0, scale * 750, scale * 1380); | |||
//二维码 | |||
ctx.drawImage(this.data.qrCodeUrl, scale * 574, scale * 1223, scale * 130, scale * 130); | |||
//绘制 | |||
ctx.draw(false, setTimeout(() => { | |||
wx.canvasToTempFilePath({ | |||
width:scale*750, | |||
height: scale * 1380, | |||
canvasId: 'myCanvas', | |||
success: res => { | |||
posterUrl = res.tempFilePath; | |||
if(_saveImg){ | |||
this.savePic(); | |||
} | |||
} | |||
}) | |||
}, 300)); | |||
}, | |||
saveImg: function () {//保存到手机 | |||
if (!posterUrl){ | |||
wx.showLoading({ | |||
title: '海报合成中', | |||
mask:true | |||
}) | |||
_saveImg = true; | |||
}else{ | |||
this.savePic(); | |||
} | |||
}, | |||
savePic: function () { | |||
wx.hideLoading(); | |||
wx.saveImageToPhotosAlbum({ | |||
filePath: posterUrl, | |||
success(res) { | |||
wx.showToast({ | |||
title: '保存成功' | |||
}) | |||
}, | |||
fail: res => { | |||
wx.getSetting({ | |||
success: res => { | |||
if (res.authSetting['scope.writePhotosAlbum']) { | |||
wx.showToast({ | |||
title: '保存失败', | |||
icon: "none" | |||
}) | |||
} else { | |||
wx.showModal({ | |||
title: '授权设置', | |||
content: '请授权“保存到相册”', | |||
success: (opt) => { | |||
if (opt.confirm) { | |||
wx.openSetting({ | |||
success: e => { | |||
if (e.authSetting['scope.writePhotosAlbum']) { | |||
wx.saveImageToPhotosAlbum({ | |||
filePath: posterUrl, | |||
success(res) { | |||
wx.showToast({ | |||
title: '保存成功' | |||
}) | |||
} | |||
}) | |||
} else { | |||
wx.showToast({ | |||
title: '授权失败', | |||
icon: "none" | |||
}) | |||
} | |||
} | |||
}) | |||
} | |||
} | |||
}) | |||
} | |||
} | |||
}) | |||
} | |||
}) | |||
} | |||
}) |
@@ -8,19 +8,39 @@ | |||
</view> | |||
<view wx:if="{{selectType==1}}"> | |||
<view class="posterGroup"> | |||
<image class="posterImg" src="{{imgUrl+'/newImages5/24.png'}}"></image> | |||
<image class="posterImg" src="{{imgUrl+'/newImages5/52.png'}}"></image> | |||
<view class="posterText">@{{userName}}</view> | |||
<view class="posterText" style="display:flex;align-items:center;top:547rpx;"> | |||
<view>启辰星</view> | |||
<view style="font-weight:bold;"> 260T</view> | |||
<view style="font-weight:bold;"> 48V</view> | |||
<view>轻混增压星享版</view> | |||
</view> | |||
<view class="posterText" style="top:567rpx;">我的预测上市价为:</view> | |||
<view class="posterText" style="display:flex;align-items:center;top:587rpx;"> | |||
<view style="font-weight:bold;">{{userPrice}}</view> | |||
<view>元</view> | |||
</view> | |||
<view class="posterText" style="top:607rpx;">来和我一起竞猜吧!</view> | |||
<image class="posterCode" src="{{qrCodeUrl}}"></image> | |||
</view> | |||
<view class="bottomGroup"> | |||
<image class="bottomImg" src="{{imgUrl+'/newImages5/25.png'}}"></image> | |||
<image class="bottomImg" src="{{imgUrl+'/newImages5/64.png'}}"></image> | |||
<view class="saveGroup"> | |||
<image class="saveIcon" src="{{imgUrl+'/newImages5/26.png'}}"></image> | |||
<image class="saveBtn" src="{{imgUrl+'/newImages5/27.png'}}"></image> | |||
<image class="saveIcon" bindtap="saveImg" src="{{imgUrl+'/newImages5/26.png'}}"></image> | |||
<image class="saveBtn" bindtap="saveImg" src="{{imgUrl+'/newImages5/27.png'}}"></image> | |||
</view> | |||
</view> | |||
</view> | |||
<view wx:if="{{selectType==2}}"> | |||
<image class="linkShareImg" src="{{imgUrl+'/newImages5/53.png'}}"></image> | |||
<view class="linkShareGroup"> | |||
<image class="linkShareBg" src="{{imgUrl+'/newImages5/65.png'}}"></image> | |||
<image class="linkShareBtn" src="{{imgUrl+'/newImages5/55.png'}}"></image> | |||
<button open-type="share" style="width:268rpx;height:168rpx;min-height:0;" class="shareBtn"></button> | |||
</view> | |||
</view> | |||
</view> | |||
<canvas class="canvasDraw" canvas-id="myCanvas"></canvas> | |||
<tabBar></tabBar> | |||
</view> |
@@ -29,8 +29,9 @@ view{ | |||
opacity: 0; | |||
} | |||
.posterGroup{ | |||
position: relative; | |||
width: 395rpx; | |||
height: 749rpx; | |||
height: 750rpx; | |||
margin: 0 auto; | |||
} | |||
.posterImg{ | |||
@@ -41,14 +42,14 @@ view{ | |||
position: relative; | |||
margin-top: 35rpx; | |||
width: 750rpx; | |||
height: 217rpx; | |||
height: 200rpx; | |||
} | |||
.bottomImg{ | |||
position: absolute; | |||
left: 0; | |||
top: 0; | |||
width: 100%; | |||
height: 100%; | |||
width: 750rpx; | |||
height: 370rpx; | |||
} | |||
.saveGroup{ | |||
position: absolute; | |||
@@ -69,4 +70,63 @@ view{ | |||
.saveBtn{ | |||
width: 267rpx; | |||
height: 54rpx; | |||
} | |||
.linkShareImg{ | |||
width: 462rpx; | |||
height: 640rpx; | |||
margin: 0 auto; | |||
} | |||
.linkShareGroup{ | |||
position: relative; | |||
width: 750rpx; | |||
height: 464rpx; | |||
margin-top: 44rpx; | |||
} | |||
.linkShareBg{ | |||
width: 100%; | |||
height: 100%; | |||
} | |||
.linkShareBtn{ | |||
position: absolute; | |||
left: 50%; | |||
transform: translateX(-50%); | |||
top: 123rpx; | |||
width: 268rpx; | |||
height: 168rpx; | |||
} | |||
.shareBtn{ | |||
position: absolute; | |||
left: 50%; | |||
transform: translateX(-50%); | |||
top: 123rpx; | |||
margin: 0; | |||
padding: 0; | |||
opacity: 0; | |||
width: 268rpx; | |||
height: 168rpx; | |||
} | |||
.posterText{ | |||
position: absolute; | |||
left: 71rpx; | |||
top: 520rpx; | |||
line-height: 14rpx; | |||
font-size:14rpx; | |||
font-family:MHeiPRC; | |||
font-weight:500; | |||
color:rgba(255,255,255,1); | |||
} | |||
.posterCode{ | |||
position: absolute; | |||
right: 30rpx; | |||
bottom: 21rpx; | |||
width: 68rpx; | |||
height: 68rpx; | |||
} | |||
.canvasDraw{ | |||
width:1776rpx; | |||
height:3268rpx; | |||
position: fixed; | |||
top: 0; | |||
left: -1776rpx; | |||
background-color: black; | |||
} |
@@ -124,7 +124,7 @@ Page({ | |||
this.data.httpState = false; | |||
if(res.code==200){ | |||
app.globalData.getSecondGuessInfo.firstData.lucky_result = 1; | |||
res.data.lucky_result = 1; | |||
// res.data.lucky_result = 1; | |||
if(res.data.lucky_result==1){ | |||
this.setData({ | |||
drawResult:2 |
@@ -12,7 +12,7 @@ Page({ | |||
stringValue:"",//输入的竞猜价格 | |||
focusState:false,//输入框聚焦状态 | |||
tipImgShow:true,//是否显示输入框提示 | |||
isGuess:false,//是否竞猜过价格 | |||
isGuess:true,//是否竞猜过价格 | |||
guessPrice:"", | |||
guessPriceArr:[1,2,3,4,5,6], | |||
slideDay:['0','0'],//距离上市时间 | |||
@@ -20,6 +20,7 @@ Page({ | |||
cartogramShow:false,//是否显示统计图 | |||
getSecondGuessInfo:null, | |||
httpState:false,//是否正在进行http请求 | |||
isUserInfo:false,//是否有个人信息 | |||
}, | |||
/** | |||
@@ -47,6 +48,11 @@ Page({ | |||
guessPriceArr:this.data.guessPriceArr | |||
}) | |||
} | |||
if(app.globalData.userInfoData && app.globalData.userInfoData.nickName){ | |||
this.setData({ | |||
isUserInfo:true | |||
}) | |||
} | |||
}, | |||
loadFun:function(){ | |||
@@ -192,9 +198,9 @@ Page({ | |||
} | |||
}, | |||
cartogramControl:function(){ | |||
var randomNum = Math.floor(Math.random()*4+44); | |||
// var randomNum = Math.floor(Math.random()*4+44); | |||
this.setData({ | |||
randomNum:randomNum, | |||
randomNum:56, | |||
cartogramShow:!this.data.cartogramShow | |||
}) | |||
}, | |||
@@ -226,5 +232,19 @@ Page({ | |||
this.setData({ | |||
shareShow:!this.data.shareShow | |||
}) | |||
}, | |||
getUserWxMsg:function(e){//通过微信获取用户信息 | |||
if (e.detail.errMsg == "getUserInfo:ok") { | |||
this.setData({ | |||
isUserInfo:true | |||
}) | |||
app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName); | |||
this.enterPoster(); | |||
} | |||
}, | |||
enterPoster:function(){ | |||
wx.navigateTo({ | |||
url: '/pages/guessPoster/guessPoster', | |||
}) | |||
} | |||
}) |
@@ -30,8 +30,8 @@ | |||
<view class="slideMask"></view> | |||
</view> | |||
<view class="shareGroup"> | |||
<image class="newImages5-42" src="{{imgUrl+'/newImages5/42.png'}}"></image> | |||
<button open-type="share" style="min-height:0;width: 100%;" class="shareBtn"></button> | |||
<image class="newImages5-42" bindtap="enterPoster" src="{{imgUrl+'/newImages5/42.png'}}"></image> | |||
<button open-type="getUserInfo" wx:if="{{!isUserInfo}}" bindgetuserinfo="getUserWxMsg" style="min-height:0;width: 100%;" class="shareBtn"></button> | |||
</view> | |||
<view class="dayGroup"> | |||
<image class="newImages5-43" src="{{imgUrl+'/newImages5/43.png'}}"></image> |
@@ -278,8 +278,8 @@ view{ | |||
} | |||
.cartogramGroup{ | |||
position: relative; | |||
width: 501rpx; | |||
height: 620rpx; | |||
width: 500rpx; | |||
height: 619rpx; | |||
} | |||
.cartogramImg{ | |||
width: 100%; |
@@ -200,7 +200,7 @@ | |||
<image style="width:100%;height:100%;" src="{{imgUrl+'/btns/myCenterBtn2.png'}}"></image></view> | |||
</view> --> | |||
<view class="orderDescGroup" wx:if="{{selectNow==4 && !buyState}}"> | |||
<image class="orderDesc" src="{{imgUrl+'/newImages4/10.png'}}"></image> | |||
<image class="orderDesc" src="{{imgUrl+'/newImages5/59.png'}}"></image> | |||
<image class="indexOrderIcon" bindtap="placingControl" src="{{imgUrl+'/images/indexOrderIcon.png'}}"></image> | |||
</view> | |||
<view class="placingOrder" wx:if="{{selectNow==4 && buyState}}"> | |||
@@ -277,7 +277,7 @@ | |||
<view class="lineSty"></view> | |||
<image class="closeXieyi" bindtap="vipDetailControl" src="{{imgUrl+'/images/closeXieyi.png'}}"></image> | |||
<view style="position:relative;"> | |||
<image style="width:750rpx;height:1700rpx;" src="{{imgUrl+'/newImages4/11.png?v=002'}}"></image> | |||
<image style="width:750rpx;height:1810rpx;" src="{{imgUrl+'/newImages5/58.png?v=003'}}"></image> | |||
<image class="newImages3-45" bindtap="vipDetailControl" src="{{imgUrl+'/newImages3/45.png'}}"></image> | |||
</view> | |||
<view class="cardCode">{{buyStateCouponCode}}<view bindtap="cardCodeCopy" class="cardCodeCopy">复制</view></view> |
@@ -484,7 +484,7 @@ view{ | |||
} | |||
.orderDesc{ | |||
width: 634rpx; | |||
height: 1145rpx; | |||
height: 1193rpx; | |||
margin-bottom: 81rpx; | |||
} | |||
/* .ranksList{ |
@@ -83,7 +83,7 @@ | |||
<image class="closeTip" bindtap="tipShowControl" src="{{imgUrl+'/newImages4/15.png'}}"></image> | |||
<image class="tipGroupBg" src="{{imgUrl+'/newImages4/12.png'}}"></image> | |||
<view class="tipGroupContent"> | |||
<image class="tipGroupContentImg" src="{{imgUrl+'/newImages4/13.png'}}"></image> | |||
<image class="tipGroupContentImg" src="{{imgUrl+'/newImages5/57.png'}}"></image> | |||
<image class="tipGroupContentBtn" bindtap="tipShowControl2" src="{{imgUrl+'/newImages4/14.png'}}"></image> | |||
</view> | |||
</view> |
@@ -243,8 +243,8 @@ | |||
overflow: auto; | |||
} | |||
.tipGroupContentImg{ | |||
width: 634rpx; | |||
height: 1862rpx; | |||
width: 633rpx; | |||
height: 1910rpx; | |||
} | |||
.tipGroupContentBtn{ | |||
width: 429rpx; |