Parcourir la source

第二轮竞猜部分(未完成)

guessPrice
suizhijia il y a 5 ans
Parent
révision
834a10746e
13 fichiers modifiés avec 326 ajouts et 38 suppressions
  1. +47
    -8
      496_dongfengqichen/pages/guess/guess.js
  2. +5
    -1
      496_dongfengqichen/pages/guess/guess.wxml
  3. +151
    -6
      496_dongfengqichen/pages/guessPoster/guessPoster.js
  4. +25
    -5
      496_dongfengqichen/pages/guessPoster/guessPoster.wxml
  5. +64
    -4
      496_dongfengqichen/pages/guessPoster/guessPoster.wxss
  6. +1
    -1
      496_dongfengqichen/pages/guessSecond/guessSecond.js
  7. +23
    -3
      496_dongfengqichen/pages/guessSecondPrize/guessSecondPrize.js
  8. +2
    -2
      496_dongfengqichen/pages/guessSecondPrize/guessSecondPrize.wxml
  9. +2
    -2
      496_dongfengqichen/pages/guessSecondPrize/guessSecondPrize.wxss
  10. +2
    -2
      496_dongfengqichen/pages/myCenter/myCenter.wxml
  11. +1
    -1
      496_dongfengqichen/pages/myCenter/myCenter.wxss
  12. +1
    -1
      496_dongfengqichen/pages/placingOrder/placingOrder.wxml
  13. +2
    -2
      496_dongfengqichen/pages/placingOrder/placingOrder.wxss

+ 47
- 8
496_dongfengqichen/pages/guess/guess.js Voir le fichier

imgUrl: app.globalData.urlStatic,//图片路径 imgUrl: app.globalData.urlStatic,//图片路径
yuyueShow:false, yuyueShow:false,
userType:1, userType:1,
isShowFun:false
}, },


/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { 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
})
} }
}, },


}) })
}, },
enterGuessPrize:function(){//开始竞猜 enterGuessPrize:function(){//开始竞猜
if(this.data.userType == 1){
if(this.data.userType == 1 || this.data.userType == 2){
wx.navigateTo({ wx.navigateTo({
url: '/pages/guessSecondPrize/guessSecondPrize' url: '/pages/guessSecondPrize/guessSecondPrize'
}) })
}else if(this.data.userType == 2){
}else if(this.data.userType == 3){
wx.navigateTo({ wx.navigateTo({
url: '/pages/guessSecond/guessSecond?type=1' url: '/pages/guessSecond/guessSecond?type=1'
}) })
app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondGuessInfo", {}, res => { app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondGuessInfo", {}, res => {
if (res.code == 200) { if (res.code == 200) {
app.globalData.getSecondGuessInfo = res.data; 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){ }else if(res.data.firstData.lucky_result==-1){
this.data.userType = 2;
userType = 3;
// console.log("调整价格");
}else{ }else{
this.data.userType = 3;
userType = 4;
// console.log("去抽大奖");
} }
this.setData({
userType:userType,
isShowFun:true
})
} }
}, this); }, this);
} }

+ 5
- 1
496_dongfengqichen/pages/guess/guess.wxml Voir le fichier

<view class="main"> <view class="main">
<image class="pageBg" src="{{imgUrl+'/newImages4/20.png'}}"></image> <image class="pageBg" src="{{imgUrl+'/newImages4/20.png'}}"></image>
<image class="gameRule" src="{{imgUrl+'/newImages4/17.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="drawBtn" bindtap="enterLucky" src="{{imgUrl+'/versions/1.png'}}"></image>
<image class="yuyue" bindtap="yuyueControl" src="{{imgUrl+'/newIcon/4.png'}}"></image> <image class="yuyue" bindtap="yuyueControl" src="{{imgUrl+'/newIcon/4.png'}}"></image>
</view> </view>

+ 151
- 6
496_dongfengqichen/pages/guessPoster/guessPoster.js Voir le fichier

// pages/guessPoster/guessPoster.js // pages/guessPoster/guessPoster.js
const app = getApp() const app = getApp()
let _savePostBg = "";//用于绘制海报的背景
let _totalDownloadTask = 2;//绘制需要下载的图片总数
let _currentSuccessDownloadTask = 0;//已完成下载的图片数
let windowScale = 0;//屏幕缩放比
let canvasContron = null;//canvas
let posterUrl = "";//合成后的海报路径
let _saveImg = false;
Page({ Page({


/** /**
*/ */
data: { data: {
imgUrl: app.globalData.urlStatic,//图片路径 imgUrl: app.globalData.urlStatic,//图片路径
selectType:2,//选中的分享类型
selectType:1,//选中的分享类型
userPrice:0,//用户竞猜价格
userName:"",//用户昵称
qrCodeUrl:"",//用户二维码
}, },


/** /**
*/ */
onLoad: function (options) { onLoad: function (options) {
app.globalData.nowPage = 3; app.globalData.nowPage = 3;
this.setData({
userName:app.globalData.userInfoData.nickName,
userPrice:app.globalData.getSecondGuessInfo.secondData.guess_price
})
},
loadFun:function(){
this.getGuessPriceQrCode();
}, },


/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function () { onReady: function () {
canvasContron = wx.createCanvasContext('myCanvas');
if (app.globalData.openid) {
this.loadFun();
} else {
app.globalData.openidSuccessFuc = this.loadFun;
}
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {

_totalDownloadTask = 2;
_currentSuccessDownloadTask = 0;
_saveImg = false;
}, },


/** /**
*/ */
onShareAppMessage: function () { onShareAppMessage: function () {
return { 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(){//切换分享类型 changeType:function(){//切换分享类型
this.setData({ this.setData({
selectType:this.data.selectType==1?2:1 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"
})
}
}
})
}
}
})
}
}
})
}
})
} }
}) })

+ 25
- 5
496_dongfengqichen/pages/guessPoster/guessPoster.wxml Voir le fichier

</view> </view>
<view wx:if="{{selectType==1}}"> <view wx:if="{{selectType==1}}">
<view class="posterGroup"> <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>
<view class="bottomGroup"> <view class="bottomGroup">
<image class="bottomImg" src="{{imgUrl+'/newImages5/25.png'}}"></image>
<image class="bottomImg" src="{{imgUrl+'/newImages5/64.png'}}"></image>
<view class="saveGroup"> <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>
</view> </view>
<view wx:if="{{selectType==2}}"> <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>
</view> </view>
<canvas class="canvasDraw" canvas-id="myCanvas"></canvas>
<tabBar></tabBar> <tabBar></tabBar>
</view> </view>

+ 64
- 4
496_dongfengqichen/pages/guessPoster/guessPoster.wxss Voir le fichier

opacity: 0; opacity: 0;
} }
.posterGroup{ .posterGroup{
position: relative;
width: 395rpx; width: 395rpx;
height: 749rpx;
height: 750rpx;
margin: 0 auto; margin: 0 auto;
} }
.posterImg{ .posterImg{
position: relative; position: relative;
margin-top: 35rpx; margin-top: 35rpx;
width: 750rpx; width: 750rpx;
height: 217rpx;
height: 200rpx;
} }
.bottomImg{ .bottomImg{
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
width: 100%;
height: 100%;
width: 750rpx;
height: 370rpx;
} }
.saveGroup{ .saveGroup{
position: absolute; position: absolute;
.saveBtn{ .saveBtn{
width: 267rpx; width: 267rpx;
height: 54rpx; 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;
} }

+ 1
- 1
496_dongfengqichen/pages/guessSecond/guessSecond.js Voir le fichier

this.data.httpState = false; this.data.httpState = false;
if(res.code==200){ if(res.code==200){
app.globalData.getSecondGuessInfo.firstData.lucky_result = 1; app.globalData.getSecondGuessInfo.firstData.lucky_result = 1;
res.data.lucky_result = 1;
// res.data.lucky_result = 1;
if(res.data.lucky_result==1){ if(res.data.lucky_result==1){
this.setData({ this.setData({
drawResult:2 drawResult:2

+ 23
- 3
496_dongfengqichen/pages/guessSecondPrize/guessSecondPrize.js Voir le fichier

stringValue:"",//输入的竞猜价格 stringValue:"",//输入的竞猜价格
focusState:false,//输入框聚焦状态 focusState:false,//输入框聚焦状态
tipImgShow:true,//是否显示输入框提示 tipImgShow:true,//是否显示输入框提示
isGuess:false,//是否竞猜过价格
isGuess:true,//是否竞猜过价格
guessPrice:"", guessPrice:"",
guessPriceArr:[1,2,3,4,5,6], guessPriceArr:[1,2,3,4,5,6],
slideDay:['0','0'],//距离上市时间 slideDay:['0','0'],//距离上市时间
cartogramShow:false,//是否显示统计图 cartogramShow:false,//是否显示统计图
getSecondGuessInfo:null, getSecondGuessInfo:null,
httpState:false,//是否正在进行http请求 httpState:false,//是否正在进行http请求
isUserInfo:false,//是否有个人信息
}, },


/** /**
guessPriceArr:this.data.guessPriceArr guessPriceArr:this.data.guessPriceArr
}) })
} }
if(app.globalData.userInfoData && app.globalData.userInfoData.nickName){
this.setData({
isUserInfo:true
})
}
}, },
loadFun:function(){ loadFun:function(){
} }
}, },
cartogramControl:function(){ cartogramControl:function(){
var randomNum = Math.floor(Math.random()*4+44);
// var randomNum = Math.floor(Math.random()*4+44);
this.setData({ this.setData({
randomNum:randomNum,
randomNum:56,
cartogramShow:!this.data.cartogramShow cartogramShow:!this.data.cartogramShow
}) })
}, },
this.setData({ this.setData({
shareShow:!this.data.shareShow 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',
})
} }
}) })

+ 2
- 2
496_dongfengqichen/pages/guessSecondPrize/guessSecondPrize.wxml Voir le fichier

<view class="slideMask"></view> <view class="slideMask"></view>
</view> </view>
<view class="shareGroup"> <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>
<view class="dayGroup"> <view class="dayGroup">
<image class="newImages5-43" src="{{imgUrl+'/newImages5/43.png'}}"></image> <image class="newImages5-43" src="{{imgUrl+'/newImages5/43.png'}}"></image>

+ 2
- 2
496_dongfengqichen/pages/guessSecondPrize/guessSecondPrize.wxss Voir le fichier

} }
.cartogramGroup{ .cartogramGroup{
position: relative; position: relative;
width: 501rpx;
height: 620rpx;
width: 500rpx;
height: 619rpx;
} }
.cartogramImg{ .cartogramImg{
width: 100%; width: 100%;

+ 2
- 2
496_dongfengqichen/pages/myCenter/myCenter.wxml Voir le fichier

<image style="width:100%;height:100%;" src="{{imgUrl+'/btns/myCenterBtn2.png'}}"></image></view> <image style="width:100%;height:100%;" src="{{imgUrl+'/btns/myCenterBtn2.png'}}"></image></view>
</view> --> </view> -->
<view class="orderDescGroup" wx:if="{{selectNow==4 && !buyState}}"> <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> <image class="indexOrderIcon" bindtap="placingControl" src="{{imgUrl+'/images/indexOrderIcon.png'}}"></image>
</view> </view>
<view class="placingOrder" wx:if="{{selectNow==4 && buyState}}"> <view class="placingOrder" wx:if="{{selectNow==4 && buyState}}">
<view class="lineSty"></view> <view class="lineSty"></view>
<image class="closeXieyi" bindtap="vipDetailControl" src="{{imgUrl+'/images/closeXieyi.png'}}"></image> <image class="closeXieyi" bindtap="vipDetailControl" src="{{imgUrl+'/images/closeXieyi.png'}}"></image>
<view style="position:relative;"> <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> <image class="newImages3-45" bindtap="vipDetailControl" src="{{imgUrl+'/newImages3/45.png'}}"></image>
</view> </view>
<view class="cardCode">{{buyStateCouponCode}}<view bindtap="cardCodeCopy" class="cardCodeCopy">复制</view></view> <view class="cardCode">{{buyStateCouponCode}}<view bindtap="cardCodeCopy" class="cardCodeCopy">复制</view></view>

+ 1
- 1
496_dongfengqichen/pages/myCenter/myCenter.wxss Voir le fichier

} }
.orderDesc{ .orderDesc{
width: 634rpx; width: 634rpx;
height: 1145rpx;
height: 1193rpx;
margin-bottom: 81rpx; margin-bottom: 81rpx;
} }
/* .ranksList{ /* .ranksList{

+ 1
- 1
496_dongfengqichen/pages/placingOrder/placingOrder.wxml Voir le fichier

<image class="closeTip" bindtap="tipShowControl" src="{{imgUrl+'/newImages4/15.png'}}"></image> <image class="closeTip" bindtap="tipShowControl" src="{{imgUrl+'/newImages4/15.png'}}"></image>
<image class="tipGroupBg" src="{{imgUrl+'/newImages4/12.png'}}"></image> <image class="tipGroupBg" src="{{imgUrl+'/newImages4/12.png'}}"></image>
<view class="tipGroupContent"> <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> <image class="tipGroupContentBtn" bindtap="tipShowControl2" src="{{imgUrl+'/newImages4/14.png'}}"></image>
</view> </view>
</view> </view>

+ 2
- 2
496_dongfengqichen/pages/placingOrder/placingOrder.wxss Voir le fichier

overflow: auto; overflow: auto;
} }
.tipGroupContentImg{ .tipGroupContentImg{
width: 634rpx;
height: 1862rpx;
width: 633rpx;
height: 1910rpx;
} }
.tipGroupContentBtn{ .tipGroupContentBtn{
width: 429rpx; width: 429rpx;

Chargement…
Annuler
Enregistrer