完成祈祷功能

main
Wkang921 3 years ago
parent 76bf5e1f65
commit d2391de3f9

@ -1,6 +1,7 @@
// pages/home/jl/index.js
const app = getApp();//新建页面时 默认引入
const req = app.xzjlReq();//初始化一个的request() 实例
import Toast from 'tdesign-miniprogram/toast/index';
Page({
/**
@ -12,7 +13,13 @@ Page({
xingxiangtu:{},
userInfo:{},
loverInfo:{},
hours:0,
minute:0,
minutes:0,
pickerValue: [0, 0],
prayerContent:'', //祈祷内容
showSexLogo:false,//不展示形象修改按钮
showPray:false //显示祈祷弹层
},
ShowOrNotLogoS(){
this.setData({singleShow:!this.data.singleShow})
@ -79,12 +86,53 @@ Page({
console.log(err);
})
},
getTextValue(e){
console.log(e.detail.value);
this.setData({
prayerContent:e.detail.value
})
console.log(this.data.prayerContent);
},
openPray(){
this.setData({
showPray:!this.data.showPray,
prayerContent:''
})
},
onPickerChange(e){
if(e.detail.value[0] === this.data.hours){
this.setData({
minutes:this.data.minute
})
}else{
this.setData({
minutes:59
})
}
this.setData({
pickerValue: e.detail.value
})
},
getUserInfo(){
req.getRequest('/api/user/curt',{}).then((res)=>{
if(res.data.code==200){
this.setData({userInfo:res.data.data})
console.log(res.data.data);
const pendantEnergy = res.data.data.pendantEnergy
const minute = pendantEnergy * 6
const hours = Math.floor(pendantEnergy / 60); // 计算小时数
if(hours>0){
this.setData({
minutes:59
})
}
this.setData({
userInfo:res.data.data,
hours:hours,
minute:minute,
pendantEnergy:pendantEnergy
})
console.log(this.data.userInfo);
}
console.log(this.userInfo);
}).catch((err)=>{
console.log(err);
})
@ -93,7 +141,39 @@ Page({
wx.navigateTo({
url: '/pages/home/jl/jlai/jlai'
})
},
btnOK(){
const prayerEnergy = (this.data.pickerValue[0]*60 + this.data.pickerValue[1])/6
if(prayerEnergy < 1){
return Toast({
context: this,
selector: '#t-toast',
message: '能量不足',
});
}
console.log(prayerEnergy);
req.patchRequest('/api/user/curt/prayer',{
prayerContent:this.data.prayerContent,
prayerEnergy:prayerEnergy
}).then((res) => {
console.log(res);
if(res.data.code === 200){
Toast({
context: this,
selector: '#t-toast',
message: '祈祷成功',
});
}else{
Toast({
context: this,
selector: '#t-toast',
message: res.data.msg,
});
}
this.openPray()
}).catch((err) => {
console.log('祈祷失败',err);
})
},
/**

@ -3,6 +3,8 @@
"t-progress": "tdesign-miniprogram/progress/progress",
"t-popup": "tdesign-miniprogram/popup/popup",
"t-rate": "tdesign-miniprogram/rate/rate",
"t-image": "tdesign-miniprogram/image/image"
"t-image": "tdesign-miniprogram/image/image",
"t-icon": "tdesign-miniprogram/icon/icon",
"t-toast": "tdesign-miniprogram/toast/toast"
}
}

@ -35,8 +35,6 @@
<view class="dcrighttxt">能量注入</view><!--下方左侧块-->
</swiper-item>
  <swiper-item class="call1"><!--情侣页面-->
<t-image class="txl" src="{{userInfo.avatar}}"></t-image>
<view class="txtextl">{{userInfo.nick}}</view><!--头像名字1-->
@ -76,7 +74,7 @@
</view><!--下方左侧块-->
<!--下方左侧块-->
<view class="lovepic"></view>
<view class="dchxtxtql">祈祷</view>
<view class="dchxtxtql" bindtap="openPray">祈祷</view>
<view class="dcrightql">
<t-progress class="dcleft1" theme="circle" percentage="70" color="#00A7FF" label="" t-class-bar="dcleft1" />
<view class="dcrbs"></view>
@ -122,6 +120,39 @@
</swiper>
<!-- 弹层 -->
<view class="pray" wx:if="{{showPray}}">
<view class="dialog">
<view class="dialog-item">
<text>祈祷内容</text>
<textarea model:value="{{prayerContent}}" placeholder="请写下你要祈祷的内容" bindblur="getTextValue"></textarea>
</view>
<view class="dialog-item">
<text>祈祷时长</text>
<view class="duration">选择祈祷时长<t-icon name="chevron-down" size="48rpx"/></view>
</view>
<view class="dialog-btn">
<button bindtap="openPray">取消</button>
<button bindtap="btnOK">发起祈祷</button>
</view>
</view>
<view class="timing">
<view class="timing-title">你还有{{pendantEnergy}}%水晶能量,可为对方祈祷{{hours}}小时{{minute}}分</view>
<t-toast id="t-toast" />
<view class="picker">
<picker-view value="{{pickerValue}}" bindchange="onPickerChange" indicator-class="active">
<picker-view-column>
<view wx:for="{{hours + 1}}" wx:key="item" class="picker-item"> {{ item }} </view>
</picker-view-column>
<picker-view-column>
<view wx:for="{{minutes + 1}}" wx:key="item" class="picker-item"> {{ item }} </view>
</picker-view-column>
</picker-view>
</view>
</view>
</view>
<div class="jltxt" bindtap="go2Jlai">精灵 AI</div>

@ -31,7 +31,6 @@
position:absolute;
}
.t-progress__canvas--circle{
width:125.67rpx!important;
height:125.67rpx !important;
@ -109,7 +108,6 @@
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/bs.png);
}
.gh{
position:absolute;
width:750rpx;
@ -120,7 +118,6 @@
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/gh.png);
}
.call{
margin: 0;
padding: 0;
@ -184,7 +181,6 @@
font-size: 27rpx;
}
.txl{
position:absolute;
width:72rpx;
@ -618,7 +614,7 @@ font-size: 16px;
.jltxt{
position: absolute;
left: 300px;
right: 0;
top: 504px;
width: 75px;
height: 35px;
@ -656,3 +652,128 @@ background-repeat: no-repeat;
background-size:100% 100%;
background-image: url(https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/jl/ysfgx.png);
}
/* 弹层 */
.pray {
display: flex;
justify-content: center;
}
.dialog {
position: absolute;
bottom: 500rpx;
width: 648rpx;
height: 484rpx;
padding: 50rpx;
z-index: 999;
box-sizing: border-box;
line-height: 20px;
border-radius: 15px;
background-color: rgba(255, 255, 255, 1);
text-align: center;
box-shadow: 1px 2px 6px 0px rgba(0, 0, 0, 0.4);
}
.dialog-item {
display: flex;
justify-content: space-between;
margin-bottom: 38rpx;
}
.dialog-item textarea {
width: 400rpx;
height: 142rpx;
padding: 20rpx;
line-height: 40rpx;
box-sizing: border-box;
border-radius: 10px;
background-color: rgba(255, 255, 255, 1);
color: #9A9A9A;
font-size: 14px;
text-align: right;
border: 1px solid rgba(236, 236, 236, 1);
}
.dialog-item text {
padding-top: 16rpx;
color: #6C6C6C;
font-size: 16px;
text-align: center;
}
.dialog-item .duration {
width: 400rpx;
height: 80rpx;
display: flex;
justify-content: flex-end;
align-items: center;
padding-right: 20rpx;
box-sizing: border-box;
border-radius: 10px;
color: rgba(154, 154, 154, 1);
font-size: 14px;
border: 1px solid rgba(236, 236, 236, 1);
}
.dialog-btn {
display: flex;
justify-content: center;
align-items: center;
}
.dialog-btn button {
width: 210rpx;
height: 70rpx;
border-radius: 10px;
background: linear-gradient(233.49deg, rgba(248,99,42,1) 10.48%,rgba(249,135,89,1) 89.2%);
text-align: center;
box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
border: 3px solid rgba(255, 255, 255, 1);
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: 14px;
}
.timing {
position: absolute;
bottom: 0;
width: 100%;
height: 434rpx;
padding: 0 28px;
z-index: 999;
line-height: 20px;
background-color: rgba(255, 255, 255, 1);
text-align: center;
}
.timing .picker{
padding: 0 28px;
box-sizing: border-box;
}
.timing .timing-title {
height: 70rpx;
display: flex;
justify-content: center;
align-items: center;
color: #9A9A9A;
font-size: 14px;
border: 1px solid #F1F1F1;
}
.active {
background-color: #F1F1F1;
z-index: 0;
}
.picker-item {
display: flex;
align-items: center;
justify-content: center;
}
picker-view-column {
height: 364rpx;
}

@ -21,6 +21,13 @@
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/home/jl/index",
"query": "",
"launchMode": "default",
"scene": null
}
]
}

Loading…
Cancel
Save