@ -0,0 +1,86 @@ | |||
const app = getApp(); | |||
Page({ | |||
data: { | |||
item:null, | |||
percentage:0 | |||
}, | |||
onLoad:function(options){ | |||
this.setData({ | |||
item:JSON.parse(options.item), | |||
percentage:JSON.parse(options.item).percentage | |||
}) | |||
}, | |||
back(){ | |||
wx.navigateBack({ | |||
delta: 0, | |||
}) | |||
}, | |||
change_stock(){ | |||
var text | |||
var that = this | |||
var res_text | |||
if(this.data.percentage){ | |||
text = "确定从"+this.data.item.percentage+"%修改至"+this.data.percentage+"%?" | |||
res_text="修改成功" | |||
} | |||
else{ | |||
text = "确定删除?" | |||
res_text="删除成功" | |||
} | |||
wx.showModal({ | |||
title: "提示", | |||
content:text, | |||
showCancel : true, | |||
confirmText:"确定", | |||
cancelText:"取消", | |||
success:(res)=>{ | |||
if(res.confirm){ | |||
wx.cloud.callContainer({ | |||
"config": { | |||
"env": "prod-2g058voqbea31ecb" | |||
}, | |||
"path": "fridge/food-stock/change/", | |||
"header": { | |||
"X-WX-SERVICE": "django-5198", | |||
'content-type': 'application/x-www-form-urlencoded' | |||
}, | |||
"method": "POST", | |||
data: {id:that.data.item.id,percentage:that.data.percentage}, | |||
success(res){ | |||
wx.showToast({ | |||
title: res_text, | |||
duration:800, | |||
mask:true, | |||
icon:'success', | |||
success(res){ | |||
setTimeout(function() { | |||
wx.navigateBack({ | |||
delta: 0, | |||
}) | |||
}, 800); | |||
} | |||
}) | |||
} | |||
}) | |||
} | |||
} | |||
}) | |||
}, | |||
sliderchanging(e){ | |||
wx.showToast({ | |||
title: e.detail.value.toString()+'%', | |||
icon:'none' | |||
}), | |||
this.setData({ | |||
percentage:e.detail.value | |||
}) | |||
} | |||
}) |
@ -0,0 +1,3 @@ | |||
{ | |||
"usingComponents": {} | |||
} |
@ -0,0 +1,20 @@ | |||
<text class="title1">库存</text> | |||
<view style="position: fixed;left:4%;top:8%" bindtap="back" hover-class="back"> | |||
<text style="font-size: 60rpx;padding-left: 10rpx;padding-right:20rpx;background-color: rgba(255, 255, 255, 0.5);border-radius: 20%;box-shadow: 0px 0px 20px 0 rgba(133, 100, 100, 0.37);" decode="true"><</text> | |||
</view> | |||
<view class="title2" style="position: relative;left:5%;margin-top: 36%;">选中的食材:{{item.amount}}{{item.unit}}{{item.name}}</view> | |||
<view class="title2" style="position: relative;left:5%;margin-top: 10%;">添加时间:{{item.date}}</view> | |||
<view class="title2" style="position: relative;left:5%;margin-top: 10%;">距今:{{item.days}}天</view> | |||
<view class="title2" style="position: relative;left:5%;margin-top: 10%;">剩余:{{item.percentage}}%</view> | |||
<view class="title2" style="position: relative;left:5%;margin-top: 10%;"> | |||
<view wx:if="{{item.percentage!=percentage}}">修改后剩余:{{percentage}}%</view> | |||
<view wx:else>拖动滑动条以修改</view> | |||
</view> | |||
<slider style="position: relative;margin-top: 20%;" min="0" max="100" step="10" bindchanging="sliderchanging" value="{{percentage}}" activeColor='#ba7a75'></slider> | |||
<button wx:if="{{item.percentage!=percentage&& percentage!=0}}" class="title2" style="position: relative;margin-top: 10%;box-shadow: 0px 0px 10px 0 rgba(100, 133, 106, 0.37);background-color: #ba7a75;" type="primary" bindtap="change_stock" >提交修改</button> | |||
<button wx:if="{{item.percentage!=percentage&& percentage==0}}" class="title3" style="position: relative;margin-top: 10%;" bindtap="change_stock">删除库存</button> | |||
<view class="deco1"></view> | |||
<view class="deco2"></view> | |||
@ -0,0 +1,63 @@ | |||
Page{ | |||
background: white | |||
} | |||
.deco1{ | |||
/* Rectangle 2 */ | |||
position: absolute; | |||
width: 49.37px; | |||
height: 321.5px; | |||
top: -30rpx; | |||
right:20rpx; | |||
background: linear-gradient(rgba(245, 186, 173, 0.068)5%,rgba(231, 153, 139, 0.075) 50%); | |||
transform: rotate(135deg); | |||
border-radius: 20rpx; | |||
z-index: -10; | |||
} | |||
.deco2{ | |||
/* Rectangle 2 */ | |||
position: absolute; | |||
width: 49.37px; | |||
height: 321.5px; | |||
top: -30rpx; | |||
right:250rpx; | |||
background: linear-gradient(rgba(245, 186, 173, 0.075)5%,rgba(231, 153, 139, 0.075) 20%); | |||
transform: rotate(135deg); | |||
border-radius: 20rpx; | |||
z-index: -10; | |||
} | |||
.title1{ | |||
width:75%; | |||
position: absolute; | |||
left:17%; | |||
top:8%; | |||
font-weight:bold; | |||
font-size: 30px; | |||
} | |||
.title2{ | |||
width:100%; | |||
font-weight:bold; | |||
font-size: 20px; | |||
line-height: 21px; | |||
letter-spacing: 0px; | |||
} | |||
.title3{ | |||
width:100%; | |||
font-weight:bold; | |||
font-size: 20px; | |||
line-height: 21px; | |||
letter-spacing: 0px; | |||
background-color: rgb(255, 255, 255); | |||
color:#fa5151; | |||
box-shadow: 0px 0px 10px 0 rgba(133, 100, 100, 0.37); | |||
} | |||
.back{ | |||
background-color: rgb(255, 255, 255); | |||
border-radius: 20%; | |||
} |