Browse Source

功能优化

guessPrice
sui 5 years ago
parent
commit
4217a1e6a3
9 changed files with 162 additions and 71 deletions
  1. +2
    -1
      496_dongfengqichen/app.js
  2. +6
    -2
      496_dongfengqichen/pages/coupon/coupon.js
  3. +35
    -16
      496_dongfengqichen/pages/index/index.js
  4. +1
    -1
      496_dongfengqichen/pages/luckyStar/luckyStar.wxml
  5. +23
    -14
      496_dongfengqichen/pages/myCenter/myCenter.js
  6. +10
    -9
      496_dongfengqichen/pages/myCenter/myCenter.wxml
  7. +4
    -0
      496_dongfengqichen/pages/myCenter/myCenter.wxss
  8. +77
    -24
      496_dongfengqichen/pages/poster/poster.js
  9. +4
    -4
      496_dongfengqichen/pages/poster/poster.wxss

+ 2
- 1
496_dongfengqichen/app.js View File

// urlRoot: "",//接口根目录 // urlRoot: "",//接口根目录
urlStatic:"https://www.jiyou-tech.com/2020/496_qichen/static",//静态资源根目录 urlStatic:"https://www.jiyou-tech.com/2020/496_qichen/static",//静态资源根目录
openid: "",//OPENID openid: "",//OPENID
friendOpenid:"",//推荐人的openid
session_key: "",//session_key session_key: "",//session_key
openidSuccessFuc: null,//方法回调 openidSuccessFuc: null,//方法回调
nowPage:'1',//当前tabBar
nowPage:'0',//当前tabBar
isRegister:false,//是否已注册 isRegister:false,//是否已注册
userMobile:null,//用户手机号 userMobile:null,//用户手机号
isFirstLogin:true,//是否为第一次登录 isFirstLogin:true,//是否为第一次登录

+ 6
- 2
496_dongfengqichen/pages/coupon/coupon.js View File

* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {

if (options.friendOpenid){
app.globalData.friendOpenid = options.friendOpenid;
app.globalData.nowPage = 0;
}
}, },


/** /**
onShareAppMessage: function () { onShareAppMessage: function () {


}, },
receive:function(){//立即领取
receive: function () {//立即领取
app.globalData.nowPage = 1;
wx.redirectTo({ wx.redirectTo({
url: '../index/index', url: '../index/index',
}) })

+ 35
- 16
496_dongfengqichen/pages/index/index.js View File

province:"",//省份 province:"",//省份
agent_code: "",//经销商编码 agent_code: "",//经销商编码
agentDetail: "",//经销商详细信息 agentDetail: "",//经销商详细信息
parentOpenid: "",//好友openid
parentOpenid: app.globalData.friendOpenid,//好友openid
}, },
startAdvertisingUrl:'',//开屏广告路径 startAdvertisingUrl:'',//开屏广告路径
isStartAdvertising: 1,//开屏广告透明度 isStartAdvertising: 1,//开屏广告透明度
this.getHomeVideo();//获取视频 this.getHomeVideo();//获取视频
this.getOrderInfo(); this.getOrderInfo();
} else { } else {
this.setData({
mainShow:true,
isStartAdvertisingShow:false,
bannerList: app.globalData.indexData.bannerList,
videoList: app.globalData.indexData.videoList,
provinceArr: app.globalData.indexData.provinceArr,
storeArr: app.globalData.indexData.storeArr,
provinceValue: app.globalData.indexData.provinceValue,
storeValue: app.globalData.indexData.storeValue,
isRegister: app.globalData.isRegister
})
this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
if (app.globalData.indexData.bannerList){
this.setData({
bannerList: app.globalData.indexData.bannerList
})
} else {
this.getHomeBanner();//获取banner
}
if (app.globalData.indexData.videoList) {
this.setData({
videoList: app.globalData.indexData.videoList
})
} else {
this.getHomeVideo();//获取视频
}
if (app.globalData.indexData.provinceArr){
this.setData({
provinceArr: app.globalData.indexData.provinceArr,
storeArr: app.globalData.indexData.storeArr,
provinceValue: app.globalData.indexData.provinceValue,
storeValue: app.globalData.indexData.storeValue
})
this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
}
} }
this.setData({
mainShow: true,
isStartAdvertisingShow: false,
isRegister: app.globalData.isRegister
})
console.log(app.globalData.isRegister);
}, },
provinceChane: function (e) {//选中省 provinceChane: function (e) {//选中省
this.setData({ this.setData({
this.setData({ this.setData({
phoneInputShow: true phoneInputShow: true
}) })
this.getUserLocation();//获取用户当前位置
if (!app.globalData.indexData.provinceArr) {
this.getUserLocation();//获取用户当前位置
}
if (e.detail.errMsg=='getPhoneNumber:ok'){ if (e.detail.errMsg=='getPhoneNumber:ok'){
app.wxRequest(app.globalData.urlRoot + "userInfo/getUserPhoneNumber", { encryptedData: e.detail.encryptedData, iv: e.detail.iv }, res => { app.wxRequest(app.globalData.urlRoot + "userInfo/getUserPhoneNumber", { encryptedData: e.detail.encryptedData, iv: e.detail.iv }, res => {
if (res.code == 200) { if (res.code == 200) {

+ 1
- 1
496_dongfengqichen/pages/luckyStar/luckyStar.wxml View File

<image class="successIcon" src="{{imgUrl+'/images/successIcon.png'}}"></image> <image class="successIcon" src="{{imgUrl+'/images/successIcon.png'}}"></image>
<view class="titleGroup"></view> <view class="titleGroup"></view>
<view class="successTip">幸运满格,大奖到手</view> <view class="successTip">幸运满格,大奖到手</view>
<image class="prizePic" src="{{imgUrl+'/images/prizePic1.png'}}"></image>
<image class="prizePic" src="{{imgUrl+'/images/prizePic1.png'}}" mode="aspectFit"></image>
<view class="prizeName">头等舱机票一张</view> <view class="prizeName">头等舱机票一张</view>
<view class="startRegister">立即领奖</view> <view class="startRegister">立即领奖</view>
</view> </view>

+ 23
- 14
496_dongfengqichen/pages/myCenter/myCenter.js View File

province: "",//省份 province: "",//省份
agent_code: "",//经销商编码 agent_code: "",//经销商编码
agentDetail: "",//经销商详细信息 agentDetail: "",//经销商详细信息
parentOpenid: "",//好友openid
parentOpenid: app.globalData.friendOpenid,//好友openid
}, },
userData:{ userData:{
avatarUrl: null, avatarUrl: null,
count:20 count:20
}, },
noData:false, noData:false,
optionsData:null
optionsData:null,
lookDescId:null,
}, },


/** /**
}, },
loadFun: function () { loadFun: function () {
this.getUserInfo(); this.getUserInfo();
this.getTaskProgress();
this.getShareList();
this.getMyAwardList();
if (app.globalData.myCenterData) { if (app.globalData.myCenterData) {
this.setData({ this.setData({
provinceArr: app.globalData.myCenterData.provinceArr, provinceArr: app.globalData.myCenterData.provinceArr,
this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail; this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code; this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
}else{ }else{
app.globalData.myCenterData = {};
this.getOrderInfo(); this.getOrderInfo();
} }
if (this.data.optionsData){ if (this.data.optionsData){
this.setData({ this.setData({
selectNow: e.currentTarget.dataset.value selectNow: e.currentTarget.dataset.value
}) })
if (e.currentTarget.dataset.value==3){
this.data.parames.page=0;
this.data.getShareList = [];
if (e.currentTarget.dataset.value == 1) {
this.getTaskProgress();
} else if (e.currentTarget.dataset.value == 2) {
this.getMyAwardList();
} else if (e.currentTarget.dataset.value == 3){
this.data.parames.page = 0;
this.setData({
parames: this.data.parames,
shareFriendList:[]
})
this.getShareList();
} }
}, },
selectTask: function (e) { selectTask: function (e) {
getDistributorList: function (longitude, latitude) {//获取经销商列表 getDistributorList: function (longitude, latitude) {//获取经销商列表
app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude }, res => { app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude }, res => {
if (res.code == 200) { if (res.code == 200) {
app.globalData.myCenterData = {};
this.setData({ this.setData({
provinceArr: res.data.list, provinceArr: res.data.list,
storeArr: res.data.list[res.data.nearData.provinceIndex].children, storeArr: res.data.list[res.data.nearData.provinceIndex].children,
app.wxRequest(app.globalData.urlRoot + 'userInfo/getUserInfo', {}, res => { app.wxRequest(app.globalData.urlRoot + 'userInfo/getUserInfo', {}, res => {
if(res.code==200){ if(res.code==200){
// res.data.userLevel = 3; // res.data.userLevel = 3;
if(res.data.avatarUrl){
if (res.data) {
this.data.userData.avatarUrl = res.data.avatarUrl; this.data.userData.avatarUrl = res.data.avatarUrl;
this.data.userData.nickName = res.data.nickName; this.data.userData.nickName = res.data.nickName;
this.data.userData.userLevel = res.data.userLevel; this.data.userData.userLevel = res.data.userLevel;
this.setData({ this.setData({
userData:this.data.userData,
isLogin:true
userData: this.data.userData,
isLogin: true
}) })
} }
} }
}, },
lookDesc:function(e){//查看奖品详情 lookDesc:function(e){//查看奖品详情
this.setData({ this.setData({
descFrameShow: e.currentTarget.dataset.value
descFrameShow: !this.data.descFrameShow,
lookDescId: e.currentTarget.dataset.value || e.currentTarget.dataset.value==0 ? e.currentTarget.dataset.value:null
}) })
}, },
lookRule: function (e) {//查看奖品详情 lookRule: function (e) {//查看奖品详情
this.setData({ this.setData({
phoneInputShow: true phoneInputShow: true
}) })
this.getUserLocation();//获取用户当前位置
if (!app.globalData.myCenterData) {
this.getUserLocation();//获取用户当前位置
}
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == 'getPhoneNumber:ok') {
app.wxRequest(app.globalData.urlRoot + "userInfo/getUserPhoneNumber", { encryptedData: e.detail.encryptedData, iv: e.detail.iv }, res => { app.wxRequest(app.globalData.urlRoot + "userInfo/getUserPhoneNumber", { encryptedData: e.detail.encryptedData, iv: e.detail.iv }, res => {
if (res.code == 200) { if (res.code == 200) {

+ 10
- 9
496_dongfengqichen/pages/myCenter/myCenter.wxml View File

</view> </view>
</view> </view>
<view class="recordPic"> <view class="recordPic">
<image class="recordTip" bindtap="lookDesc" data-value="{{true}}" src="{{imgUrl+'/images/recordTip.png'}}"></image>
<image wx:if="{{false}}" class="rewardIcon" src="{{imgUrl+'/images/jiangpin.png'}}"></image>
<view class="rewardCash">
<image class="recordTip" bindtap="lookDesc" data-value="{{index}}" src="{{imgUrl+'/images/recordTip.png'}}"></image>
<image wx:if="{{item.awardId!=1 && recordNow!=3}}" class="rewardIcon" mode="aspectFit" src="{{item.awardPicurl}}"></image>
<image wx:if="{{item.awardId!=1 && recordNow==3}}" class="luckyClaw" mode="aspectFit" src="{{item.awardPicurl}}"></image>
<view class="rewardCash" wx:if="{{item.awardId==1}}">
<view class="cashGroup"> <view class="cashGroup">
<view class="cashNum">500</view>
<view class="cashNum">{{item.awardMoney}}</view>
<view class="cashCompany">元</view> <view class="cashCompany">元</view>
</view> </view>
<view class="rewardCashText">购车红包</view> <view class="rewardCashText">购车红包</view>
</view> </view>
<service></service> <service></service>
<view class="prizeDesc" catchtouchmove="ture" wx:if="{{descFrameShow}}"> <view class="prizeDesc" catchtouchmove="ture" wx:if="{{descFrameShow}}">
<view class="prizeImgGroup" wx:if="{{false}}">
<image class="prizeImg" src="http://www.jiyou-tech.com/2020/496_qichen/static/images/indexBg.jpg"></image>
<view class="prizeImgGroup" wx:if="{{recordList[lookDescId].awardId!=1}}">
<image class="prizeImg" src="{{recordList[lookDescId].awardDetailPicurl}}" mode="widthFix"></image>
<image bindtap="lookDesc" data-value="{{false}}" class="closeDescIcon" src="{{imgUrl+'/images/closeDescIcon.png'}}"></image> <image bindtap="lookDesc" data-value="{{false}}" class="closeDescIcon" src="{{imgUrl+'/images/closeDescIcon.png'}}"></image>
</view> </view>
<view class="prizeCustomGroup">
<view class="prizeCustomGroup" wx:if="{{recordList[lookDescId].awardId==1}}">
<view class="prizeCustom"> <view class="prizeCustom">
<view class="prizeTitle">500元购车券</view>
<view class="prizeTitle">{{recordList[lookDescId].awardMoney}}元购车券</view>
<view class="prizeDescText">恭喜您!</view> <view class="prizeDescText">恭喜您!</view>
<view class="prizeDescText">500元购车券,已放入您个人中心</view>
<view class="prizeDescText">{{recordList[lookDescId].awardMoney}}元购车券,已放入您个人中心</view>
<view class="prizeDescText">此购车券仅限</view> <view class="prizeDescText">此购车券仅限</view>
<view class="prizeDescText">全国东风启辰专营店购买启辰星使用</view> <view class="prizeDescText">全国东风启辰专营店购买启辰星使用</view>
<view class="prizeDescText">同时,您也可以加入星探计划,</view> <view class="prizeDescText">同时,您也可以加入星探计划,</view>

+ 4
- 0
496_dongfengqichen/pages/myCenter/myCenter.wxss View File

} }
.getPhoneBtn{ .getPhoneBtn{
opacity: 0; opacity: 0;
}
.luckyClaw{
width: 198rpx;
height: 75rpx;
} }

+ 77
- 24
496_dongfengqichen/pages/poster/poster.js View File

data: { data: {
imgUrl: app.globalData.urlStatic,//图片路径 imgUrl: app.globalData.urlStatic,//图片路径
canvasContron:null,//canvas canvasContron:null,//canvas
qrCodeUrl:"https://www.jiyou-tech.com/2020/496_qichen/static/images/testQrCode.png",
posterBg:[],//海报背景
qrCodeUrl:"https://www.jiyou-tech.com/2020/496_qichen/static/images/testQrCode.png",//二维码图片
userHead: app.globalData.urlStatic + '/images/defaultHead.png',//用户头像
rankNum: '8908',//缓存数字
windowScale:0,//屏幕缩放比 windowScale:0,//屏幕缩放比
windowW: 0,//屏幕宽度 windowW: 0,//屏幕宽度
windowH: 0,//屏幕高度 windowH: 0,//屏幕高度
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.data.posterBg.push();
}, },


/** /**
onReady: function () { onReady: function () {
this.data.canvasContron = wx.createCanvasContext('myCanvas'); this.data.canvasContron = wx.createCanvasContext('myCanvas');
wx.getSystemInfo({ wx.getSystemInfo({
success: res => {
this.data.windowScale = res.windowWidth / 750;
this.data.windowW = res.windowWidth;
this.data.windowH = res.windowHeight;
this.posterDrawing(1);
success: option => {
this.data.windowScale = option.windowWidth / 750;
this.data.windowW = option.windowWidth;
this.data.windowH = option.windowHeight;
var countNum = 0;
wx.getImageInfo({//缓存海报背景
src: this.data.imgUrl + '/images/tempImg1.jpg',
success: res => {
this.data.posterBg.push(res.path);
countNum+=1;
}
})
wx.getImageInfo({//缓存二维码
src: this.data.qrCodeUrl,
success: res => {
this.data.qrCodeUrl = res.path;
countNum += 1;
}
})
wx.getImageInfo({//缓存头像
src: this.data.userHead,
success: res => {
this.data.userHead = res.path;
countNum += 1;
}
})
wx.getImageInfo({//缓存数字背景
src: this.data.imgUrl + '/images/posterNum.png',
success: res => {
this.data.numBg = res.path;
countNum += 1;
}
})
this.data.rankNum = this.data.rankNum.toString().split("");
for (let i = 0; i < this.data.rankNum.length; i++) {
wx.getImageInfo({//缓存数字
src: this.data.imgUrl + '/images/nums/' + this.data.rankNum[i]+'.png',
success: res => {
this.data.rankNum[i] = res.path;
countNum += 1;
}
})
}
let setInt = setInterval(() => {
if (countNum >= 8) {
this.posterDrawing(1);
clearInterval(setInt);
}
},50);
} }
}) })
}, },
return { return {
title: '500元购车券', title: '500元购车券',
imageUrl: "", imageUrl: "",
path: "/pages/coupon/coupon"
path: "/pages/coupon/coupon?friendOpenid=" + app.globalData.openid
} }
}, },
saveImg:function(){//保存到手机 saveImg:function(){//保存到手机
wx.saveFile({
tempFilePath: this.data.posterUrl[this.data.swiperCurrent],
wx.saveImageToPhotosAlbum({
filePath: this.data.posterUrl[this.data.swiperCurrent],
success(res) { success(res) {
if (res.errMsg== "saveFile:ok"){
wx.showToast({
title: '保存成功'
})
}
}
wx.showToast({
title: '保存成功'
})
}
}) })
}, },
posterDrawing: function (e) {//海报绘制 posterDrawing: function (e) {//海报绘制
var ctx = this.data.canvasContron;//canvas对象 var ctx = this.data.canvasContron;//canvas对象
var scale = this.data.windowScale;//屏幕缩放比 var scale = this.data.windowScale;//屏幕缩放比
//背景 //背景
ctx.drawImage(this.data.imgUrl + '/images/tempImg'+e+'.jpg', 0, 0, scale * 444, scale * 817);//defaultHead
ctx.drawImage(this.data.posterBg[e-1], 0, 0, scale * 444, scale * 817);//
ctx.setFillStyle("#FFFFFF"); ctx.setFillStyle("#FFFFFF");
ctx.save(); ctx.save();
ctx.beginPath(); //开始绘制 ctx.beginPath(); //开始绘制
//先画个圆 前两个参数确定了圆心 (x,y) 坐标 第三个参数是圆的半径 四参数是绘图方向 默认是false,即顺时针 //先画个圆 前两个参数确定了圆心 (x,y) 坐标 第三个参数是圆的半径 四参数是绘图方向 默认是false,即顺时针
ctx.arc(scale * 48 / 2 + scale * 49, scale * 48 / 2 + scale * 538, scale * 48 / 2, 0, Math.PI * 2, false); ctx.arc(scale * 48 / 2 + scale * 49, scale * 48 / 2 + scale * 538, scale * 48 / 2, 0, Math.PI * 2, false);
ctx.clip(); //剪切 ctx.clip(); //剪切
ctx.drawImage(this.data.imgUrl + '/images/coupon.png', scale * 49, scale * 538, scale * 48, scale * 48); //头像
ctx.drawImage(this.data.userHead, scale * 49, scale * 538, scale * 48, scale * 48); //头像
ctx.restore(); //恢复之前保存的绘图上下文 ctx.restore(); //恢复之前保存的绘图上下文
//名称 //名称
ctx.setFontSize(scale * 28); ctx.setFontSize(scale * 28);
ctx.setTextAlign('left'); ctx.setTextAlign('left');
ctx.fillText("啦啦啦", scale * 102, scale *572); ctx.fillText("啦啦啦", scale * 102, scale *572);
//我是第XXX星探 //我是第XXX星探
ctx.drawImage(this.data.imgUrl + '/images/posterNum.png', scale * 50, scale * 598, scale * 333, scale * 74);
ctx.drawImage(this.data.numBg, scale * 50, scale * 598, scale * 333, scale * 74);
//排名数字 //排名数字
ctx.drawImage(this.data.imgUrl + '/images/nums/8.png', scale * 168, scale * 602, scale * 32, scale * 40);
ctx.drawImage(this.data.imgUrl + '/images/nums/9.png', scale * 202, scale * 602, scale * 32, scale * 40);
ctx.drawImage(this.data.imgUrl + '/images/nums/0.png', scale * 236, scale * 602, scale * 32, scale * 40);
ctx.drawImage(this.data.imgUrl + '/images/nums/8.png', scale * 270, scale * 602, scale * 32, scale * 40);
ctx.drawImage(this.data.rankNum[0], scale * 168, scale * 602, scale * 32, scale * 40);
ctx.drawImage(this.data.rankNum[1], scale * 202, scale * 602, scale * 32, scale * 40);
ctx.drawImage(this.data.rankNum[2], scale * 236, scale * 602, scale * 32, scale * 40);
ctx.drawImage(this.data.rankNum[3], scale * 270, scale * 602, scale * 32, scale * 40);
//二维码 //二维码
ctx.drawImage(this.data.qrCodeUrl, scale * 282, scale * 672, scale * 105, scale* 106); ctx.drawImage(this.data.qrCodeUrl, scale * 282, scale * 672, scale * 105, scale* 106);
//绘制 //绘制
ctx.draw(false, setTimeout(() => { ctx.draw(false, setTimeout(() => {
wx.canvasToTempFilePath({ wx.canvasToTempFilePath({
width:scale*444,
height: scale * 817,
canvasId: 'myCanvas', canvasId: 'myCanvas',
success: res => { success: res => {
this.data.posterUrl.push(res.tempFilePath); this.data.posterUrl.push(res.tempFilePath);
posterUrl: this.data.posterUrl posterUrl: this.data.posterUrl
}) })
if (e < 3) { if (e < 3) {
this.posterDrawing(e+1);
wx.getImageInfo({
src: this.data.imgUrl + '/images/tempImg'+(e+1)+'.jpg',
success: res => {
this.data.posterBg.push(res.path);
this.posterDrawing(e + 1);
}
})
}else{ }else{
this.setData({ this.setData({
canvasShow:false canvasShow:false

+ 4
- 4
496_dongfengqichen/pages/poster/poster.wxss View File

margin: 0 auto; margin: 0 auto;
margin-top: 92rpx; margin-top: 92rpx;
box-sizing: border-box; box-sizing: border-box;
background-color: #00548C;
} }
.selectTempFrameBorder{ .selectTempFrameBorder{
border: 10rpx solid #00548C; border: 10rpx solid #00548C;
z-index: 2; z-index: 2;
} }
.canvasDraw{ .canvasDraw{
width:444rpx;
height:817rpx;
opacity: 0;
width:1776rpx;
height:3268rpx;
position: fixed; position: fixed;
top: 0; top: 0;
left: 0;
left: -1776rpx;
} }
.lookBigPic{ .lookBigPic{
display: flex; display: flex;

Loading…
Cancel
Save