"pages/prizes/prizes", | "pages/prizes/prizes", | ||||
"pages/poster/poster", | "pages/poster/poster", | ||||
"pages/coupon/coupon", | "pages/coupon/coupon", | ||||
"pages/receiveRegister/receiveRegister" | |||||
"pages/receiveRegister/receiveRegister", | |||||
"pages/address/address" | |||||
], | ], | ||||
"window": { | "window": { | ||||
"backgroundTextStyle": "light", | "backgroundTextStyle": "light", |
// pages/address/address.js | |||||
const app = getApp() | |||||
Page({ | |||||
/** | |||||
* 页面的初始数据 | |||||
*/ | |||||
data: { | |||||
imgUrl: app.globalData.urlStatic,//图片路径 | |||||
submitData:{ | |||||
realName:"", | |||||
mobile: "",//电话 | |||||
province: "",//省份 | |||||
city: "",//城市 | |||||
district: "",//地区 | |||||
addressDetail:""//详细 | |||||
}, | |||||
isAddress: false,//是否有地址 | |||||
phoneInputShow: false,//是否显示电话输入框 | |||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面加载 | |||||
*/ | |||||
onLoad: function (options) { | |||||
app.globalData.nowPage = 4; | |||||
if (app.globalData.openid) { | |||||
this.loadFun(); | |||||
} else { | |||||
app.globalData.openidSuccessFuc = this.loadFun; | |||||
} | |||||
// if (app.globalData.userMobile) { | |||||
// this.data.submitData.mobile = app.globalData.userMobile; | |||||
// this.setData({ | |||||
// phoneInputShow: true, | |||||
// submitData: this.data.submitData | |||||
// }) | |||||
// } | |||||
}, | |||||
loadFun: function () { | |||||
this.getAddress(); | |||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面初次渲染完成 | |||||
*/ | |||||
onReady: function () { | |||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面显示 | |||||
*/ | |||||
onShow: function () { | |||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面隐藏 | |||||
*/ | |||||
onHide: function () { | |||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面卸载 | |||||
*/ | |||||
onUnload: function () { | |||||
}, | |||||
/** | |||||
* 页面相关事件处理函数--监听用户下拉动作 | |||||
*/ | |||||
onPullDownRefresh: function () { | |||||
}, | |||||
/** | |||||
* 页面上拉触底事件的处理函数 | |||||
*/ | |||||
onReachBottom: function () { | |||||
}, | |||||
/** | |||||
* 用户点击右上角分享 | |||||
*/ | |||||
onShareAppMessage: function () { | |||||
}, | |||||
addressChange:function(e){//所在地区发生改变 | |||||
this.data.submitData.province = e.detail.value[0]; | |||||
this.data.submitData.city = e.detail.value[1]; | |||||
this.data.submitData.district = e.detail.value[2]; | |||||
this.setData({ | |||||
submitData:this.data.submitData | |||||
}) | |||||
}, | |||||
getRealName: function (e) {//获取收货人 | |||||
this.data.submitData.realName = e.detail.value; | |||||
this.setData({ | |||||
submitData: this.data.submitData | |||||
}) | |||||
}, | |||||
getMobile: function (e) {//获取手机号码 | |||||
this.data.submitData.mobile = e.detail.value; | |||||
this.setData({ | |||||
submitData: this.data.submitData | |||||
}) | |||||
}, | |||||
getAddressDetail: function (e) {//获取详细地址 | |||||
this.data.submitData.addressDetail = e.detail.value; | |||||
this.setData({ | |||||
submitData: this.data.submitData | |||||
}) | |||||
}, | |||||
getAddress: function () {//获取地址 | |||||
app.wxRequest(app.globalData.urlRoot +"address/getAddress",{},res=>{ | |||||
if(res.code == 200){ | |||||
if(res.data){ | |||||
this.data.isAddress = true; | |||||
this.data.submitData.realName = res.data.realName; | |||||
this.data.submitData.mobile = res.data.mobile; | |||||
this.data.submitData.province = res.data.province; | |||||
this.data.submitData.city = res.data.city; | |||||
this.data.submitData.district = res.data.district; | |||||
this.data.submitData.addressDetail = res.data.addressDetail; | |||||
this.setData({ | |||||
submitData: this.data.submitData | |||||
}) | |||||
} | |||||
}else{ | |||||
wx.showToast({ | |||||
title: res.msg, | |||||
icon:"none" | |||||
}) | |||||
} | |||||
},this); | |||||
}, | |||||
addAddress:function(){//添加地址 | |||||
app.wxRequest(app.globalData.urlRoot + "address/addAddress", this.data.submitData,res => { | |||||
wx.showToast({ | |||||
title: res.msg, | |||||
}) | |||||
if (res.code == 200) { | |||||
wx.navigateBack({ | |||||
delta: 1 | |||||
}) | |||||
} | |||||
},this,"POST") | |||||
}, | |||||
updateAddress: function () {//更新地址 | |||||
app.wxRequest(app.globalData.urlRoot + "address/updateAddress", this.data.submitData, res => { | |||||
wx.showToast({ | |||||
title: res.msg, | |||||
}) | |||||
if (res.code == 200) { | |||||
wx.navigateBack({ | |||||
delta:1 | |||||
}) | |||||
} | |||||
}, this,"POST"); | |||||
}, | |||||
getUserPhone: function (e) {//获取用户手机号 | |||||
this.setData({ | |||||
phoneInputShow: true | |||||
}) | |||||
if (e.detail.errMsg == 'getPhoneNumber:ok') { | |||||
app.getMobile(e.detail.encryptedData, e.detail.iv, res => { | |||||
if (res.code == 200) { | |||||
this.data.submitData.mobile = res.data.decodeData.phoneNumber; | |||||
this.setData({ | |||||
submitData: this.data.submitData | |||||
}) | |||||
} else { | |||||
wx.showToast({ | |||||
title: res.msg, | |||||
icon: "none" | |||||
}) | |||||
} | |||||
}, this); | |||||
} | |||||
}, | |||||
submitAddress:function(){//保存地址 | |||||
if (!this.data.submitData.realName){ | |||||
wx.showToast({ | |||||
title: '请输入收货人', | |||||
icon:"none" | |||||
}) | |||||
return; | |||||
} | |||||
if (!app.mobileVerify(this.data.submitData.mobile)) { | |||||
if (this.data.submitData.mobile) { | |||||
wx.showToast({ | |||||
title: '请输入正确的电话', | |||||
icon: 'none' | |||||
}) | |||||
} else { | |||||
wx.showToast({ | |||||
title: '请输入电话', | |||||
icon: 'none' | |||||
}) | |||||
} | |||||
return; | |||||
} | |||||
if (!this.data.submitData.province) { | |||||
wx.showToast({ | |||||
title: '请选择所在地区', | |||||
icon: 'none' | |||||
}) | |||||
return; | |||||
} | |||||
if (!this.data.submitData.addressDetail) { | |||||
wx.showToast({ | |||||
title: '请输入详细地址', | |||||
icon: "none" | |||||
}) | |||||
return; | |||||
} | |||||
if(this.data.isAddress){ | |||||
this.updateAddress(); | |||||
} else { | |||||
this.addAddress(); | |||||
} | |||||
} | |||||
}) |
{ | |||||
"navigationBarTitleText": "地址管理", | |||||
"usingComponents": { | |||||
"tabBar": "../component/tabBar/index" | |||||
} | |||||
} |
<!--pages/address/address.wxml--> | |||||
<view> | |||||
<view class="main"> | |||||
<view class="addressTitle">编辑收货信息</view> | |||||
<view class="addressMsg"> | |||||
<view class="msgGroup"> | |||||
<view class="msgTitle">收货人:</view> | |||||
<input class="msgInput" bindinput="getRealName" value="{{submitData.realName}}"></input> | |||||
</view> | |||||
<view class="msgGroup"> | |||||
<view class="msgTitle">手机号码:</view> | |||||
<input class="msgInput" maxlength='11' type="number" bindinput="getMobile" value="{{submitData.mobile}}"></input> | |||||
<!-- <button wx:if="{{!phoneInputShow}}" class="msgInput buttonSty" style="width:530rpx;height: 62rpx;margin: 0;padding: 0;min-height: 0;opacity:0;" open-type="getPhoneNumber" bindgetphonenumber="getUserPhone"></button> --> | |||||
</view> | |||||
<view class="msgGroup"> | |||||
<view class="msgTitle">所在地区:</view> | |||||
<picker class="pickerSty" mode="region" bindchange="addressChange" value="{{[submitData.province,submitData.city,submitData.district]}}"> | |||||
<!-- <picker class="pickerSty" mode="region" bindchange="addressChange"> --> | |||||
<view class="msgInput">{{submitData.province+" "+submitData.city+" "+submitData.district}}</view> | |||||
</picker> | |||||
</view> | |||||
<view class="msgGroup addressDetail"> | |||||
<view class="msgTitle">详细地址:</view> | |||||
<textarea class="msgInput addressTextarea" bindinput="getAddressDetail" value="{{submitData.addressDetail}}"></textarea> | |||||
</view> | |||||
</view> | |||||
<view class="saveAddress" bindtap="submitAddress">保存</view> | |||||
</view> | |||||
<tabBar></tabBar> | |||||
</view> |
/* pages/address/address.wxss */ | |||||
image{ | |||||
display: block; | |||||
} | |||||
view{ | |||||
-webkit-overflow-scrolling: touch; | |||||
} | |||||
.main{ | |||||
height: calc(100vh - 150rpx); | |||||
overflow: auto; | |||||
position: relative; | |||||
} | |||||
.addressTitle{ | |||||
margin:72rpx 0; | |||||
font-size:35rpx; | |||||
line-height:35rpx; | |||||
font-family:PingFangSC; | |||||
font-weight:600; | |||||
color:rgba(0,0,0,1); | |||||
text-align: center; | |||||
} | |||||
.addressMsg{ | |||||
display: flex; | |||||
align-items: center; | |||||
flex-direction: column; | |||||
} | |||||
.msgGroup{ | |||||
position: relative; | |||||
width:697rpx; | |||||
min-height:62rpx; | |||||
border: 1rpx solid #B1B1B1; | |||||
border-radius: 15rpx; | |||||
display: flex; | |||||
align-items: center; | |||||
box-sizing: border-box; | |||||
padding: 0 27rpx; | |||||
margin-bottom: 40rpx; | |||||
} | |||||
.msgTitle,.msgInput{ | |||||
min-height: 23rpx; | |||||
line-height: 23rpx; | |||||
font-size:23rpx; | |||||
font-family:PingFangSC; | |||||
font-weight:600; | |||||
color:rgba(35,33,34,1); | |||||
} | |||||
.msgInput{ | |||||
width: 530rpx; | |||||
} | |||||
.addressDetail{ | |||||
padding: 21rpx 26rpx; | |||||
height:155rpx; | |||||
align-items: flex-start; | |||||
} | |||||
.addressTextarea{ | |||||
height: 100%; | |||||
} | |||||
.saveAddress{ | |||||
position: absolute; | |||||
left: 50%; | |||||
bottom: 45rpx; | |||||
text-align: center; | |||||
transform: translateX(-50%); | |||||
width:652rpx; | |||||
height:70rpx; | |||||
background-color: #01538E; | |||||
line-height: 70rpx; | |||||
font-size:30rpx; | |||||
font-family:PingFangSC; | |||||
font-weight:400; | |||||
color:rgba(255,255,255,1); | |||||
border-radius: 15rpx; | |||||
} | |||||
.pickerSty{ | |||||
height: 62rpx; | |||||
display: flex; | |||||
align-items: center; | |||||
} | |||||
.buttonSty{ | |||||
position: absolute; | |||||
left: 135rpx; | |||||
top: 0; | |||||
z-index: 2; | |||||
} |
}, | }, | ||||
getUserLocation:function(e){ | getUserLocation:function(e){ | ||||
wx.getLocation({ | wx.getLocation({ | ||||
type: 'wgs84', // | |||||
type: 'gcj02', // | |||||
success:(res)=>{ | success:(res)=>{ | ||||
// console.log(res); | // console.log(res); | ||||
this.getDistributorList(res.longitude, res.latitude); | this.getDistributorList(res.longitude, res.latitude); |
clawScale: 1,//爪子的scale值 | clawScale: 1,//爪子的scale值 | ||||
downNum:30,//倒计时时间 | downNum:30,//倒计时时间 | ||||
setInt:null,//倒计时元素 | setInt:null,//倒计时元素 | ||||
pizeTip:0,//抓奖提示框 | |||||
pizeTip:1,//抓奖提示框 | |||||
setGroup:{ | setGroup:{ | ||||
left:null, | left:null, | ||||
right: null, | right: null, | ||||
top: null, | top: null, | ||||
bottom: null, | bottom: null, | ||||
} | |||||
}, | |||||
gameSign: null, //游戏结束时需要 | |||||
startType:1,//开始类型:1通过游戏玩法里的开始按钮,2:通过抓取按钮 | |||||
gameState:false,//游戏状态 | |||||
}, | }, | ||||
/** | /** | ||||
}) | }) | ||||
}, | }, | ||||
openGameRule: function () {//打开游戏玩法 | openGameRule: function () {//打开游戏玩法 | ||||
this.setData({ | |||||
ruleShow: true | |||||
}) | |||||
if(!this.data.gameState){ | |||||
this.setData({ | |||||
ruleShow: true | |||||
}) | |||||
} | |||||
}, | }, | ||||
gameStart: function () {//开始游戏 | |||||
if (!this.data.ruleCloseShow) { | |||||
this.downTimeFun(); | |||||
gameStart: function () {//开始游戏按钮 | |||||
if(this.data.startType==1){ | |||||
this.data.startType = 2; | |||||
this.setData({ | |||||
ruleShow: false, | |||||
ruleCloseShow: true | |||||
}) | |||||
this.beginGame(); | |||||
} | } | ||||
this.setData({ | |||||
ruleShow: false, | |||||
ruleCloseShow: true | |||||
}) | |||||
}, | |||||
beginGame: function () {//开始游戏 | |||||
app.wxRequest(app.globalData.urlRoot + "dollGame/beginGame", {}, res => { | |||||
console.log(res); | |||||
if(res.code==200){ | |||||
this.data.gameSign = res.data.sign; | |||||
this.endGame(); | |||||
if (this.data.gameSign) { | |||||
this.downTimeFun(); | |||||
} | |||||
}else{ | |||||
wx.showToast({ | |||||
title: res.msg, | |||||
icon:"none" | |||||
}) | |||||
} | |||||
},this) | |||||
}, | |||||
endGame:function(){//结束游戏 | |||||
app.wxRequest(app.globalData.urlRoot + "dollGame/endGame", { sign:this.data.gameSign}, res => { | |||||
console.log(res); | |||||
if(res.code=200){ | |||||
}else{ | |||||
console.log(res); | |||||
} | |||||
}, this,"POST") | |||||
}, | }, | ||||
startClaw:function(e){//开始控制爪子方向 | startClaw:function(e){//开始控制爪子方向 | ||||
let direction = e.currentTarget.dataset.direction; | let direction = e.currentTarget.dataset.direction; | ||||
this.closeSetInt(); | this.closeSetInt(); | ||||
}, | }, | ||||
downTimeFun:function(){//游戏倒计时 | downTimeFun:function(){//游戏倒计时 | ||||
this.data.gameState = true; | |||||
this.data.setInt = setInterval(()=>{ | this.data.setInt = setInterval(()=>{ | ||||
this.data.downNum -= 1; | this.data.downNum -= 1; | ||||
if (this.data.downNum<10){ | if (this.data.downNum<10){ | ||||
} | } | ||||
},1000); | },1000); | ||||
}, | }, | ||||
closeSetInt:function(){//关闭倒计时 | |||||
closeSetInt: function () {//关闭倒计时 | |||||
this.data.gameState = false; | |||||
clearInterval(this.data.setInt); | clearInterval(this.data.setInt); | ||||
this.setData({ | this.setData({ | ||||
downNum: 30, | downNum: 30, | ||||
}, 1200); | }, 1200); | ||||
}, | }, | ||||
prizeLook:function(){//活动奖品 | prizeLook:function(){//活动奖品 | ||||
wx.navigateTo({ | |||||
url: '../prizes/prizes' | |||||
}) | |||||
if(!this.data.gameState){ | |||||
wx.navigateTo({ | |||||
url: '../prizes/prizes' | |||||
}) | |||||
} | |||||
} | } | ||||
}) | }) |
<view class="gameStrat" bindtap="gameStart">开始游戏</view> | <view class="gameStrat" bindtap="gameStart">开始游戏</view> | ||||
</view> | </view> | ||||
</view> | </view> | ||||
<view class="gameRuleDesc" style="background-color:rgba(000,000,000,0)" wx:if="{{false}}"> | |||||
</view> | |||||
<view class="successPop" wx:if="{{pizeTip}}"> | <view class="successPop" wx:if="{{pizeTip}}"> | ||||
<view class="successGroup" wx:if="{{pizeTip==1}}"> | <view class="successGroup" wx:if="{{pizeTip==1}}"> | ||||
<image class="gameRuleClose" style="top:-31rpx;right:-29rpx;" src="{{imgUrl+'/images/gameRuleClose.png'}}"></image> | <image class="gameRuleClose" style="top:-31rpx;right:-29rpx;" src="{{imgUrl+'/images/gameRuleClose.png'}}"></image> | ||||
<view class="successTip">幸运满格,大奖到手</view> | <view class="successTip">幸运满格,大奖到手</view> | ||||
<image class="prizePic" src="{{imgUrl+'/images/prizePic1.png'}}" mode="aspectFit"></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> | ||||
<view class="successGroup" wx:if="{{pizeTip==2 || pizeTip==3}}"> | <view class="successGroup" wx:if="{{pizeTip==2 || pizeTip==3}}"> | ||||
<image class="gameRuleClose" style="top:-31rpx;right:-29rpx;" src="{{imgUrl+'/images/gameRuleClose.png'}}"></image> | <image class="gameRuleClose" style="top:-31rpx;right:-29rpx;" src="{{imgUrl+'/images/gameRuleClose.png'}}"></image> |
this.data.subscribeData.realname = ""; | this.data.subscribeData.realname = ""; | ||||
this.data.subscribeData.captcha = ""; | this.data.subscribeData.captcha = ""; | ||||
this.setData({ | this.setData({ | ||||
subscribeData: this.data.subscribeData | |||||
subscribeData: this.data.subscribeData, | |||||
verificationCode: '获取验证码', | |||||
}) | }) | ||||
// this.setData({ | // this.setData({ | ||||
// isRegister: true | // isRegister: true | ||||
} | } | ||||
}, this); | }, this); | ||||
} | } | ||||
}, | |||||
addressControl:function(){//跳转到地址管理 | |||||
wx.navigateTo({ | |||||
url: '../address/address' | |||||
}) | |||||
} | } | ||||
}) | }) |
</view> | </view> | ||||
<view class="userNameGroup"> | <view class="userNameGroup"> | ||||
<view class="userName">{{userData.nickName}}</view> | <view class="userName">{{userData.nickName}}</view> | ||||
<!-- <image class="userNameEdit" src="{{imgUrl+'/images/userNameEdit.png'}}"></image> --> | |||||
<image bindtap="addressControl" class="userNameEdit" src="{{imgUrl+'/images/userNameEdit.png'}}"></image> | |||||
</view> | </view> | ||||
<view class="userLevel" wx:if="{{userData.userLevel}}"> | <view class="userLevel" wx:if="{{userData.userLevel}}"> | ||||
<image class="userLevelIcon" src="{{imgUrl+'/images/userLevelIcon'+userData.userLevel+'.png'}}"></image> | <image class="userLevelIcon" src="{{imgUrl+'/images/userLevelIcon'+userData.userLevel+'.png'}}"></image> |
"name": "领红包注册", | "name": "领红包注册", | ||||
"pathName": "pages/receiveRegister/receiveRegister", | "pathName": "pages/receiveRegister/receiveRegister", | ||||
"query": "" | "query": "" | ||||
} | |||||
}, | |||||
{ | |||||
"id": -1, | |||||
"name": "地址管理", | |||||
"pathName": "pages/address/address", | |||||
"query": "" | |||||
} | |||||
] | ] | ||||
} | } | ||||
} | } |