4.7提交
This commit is contained in:
@@ -14,18 +14,219 @@ Page({
|
||||
|
||||
},
|
||||
cycle_columns:['1个月', '3个月', '6个月', '12个月'],
|
||||
showCycle:false
|
||||
service_columns:['10次','不限次'],
|
||||
showCycle:false,
|
||||
showServiceNumber:false,
|
||||
monthly_frequency:'',
|
||||
isAdd:false,
|
||||
service_rounds:0,
|
||||
cur_id:'',
|
||||
items:[{
|
||||
service_period:'',
|
||||
service_price:''
|
||||
}]
|
||||
},
|
||||
confirmCycle(event){
|
||||
const { picker, value, index } = event.detail;
|
||||
console.log(value);
|
||||
openCycle(event){
|
||||
let {id} =event.currentTarget.dataset;
|
||||
console.log(id);
|
||||
this.setData({
|
||||
showCycle:true
|
||||
showCycle:true,
|
||||
cur_id:id,
|
||||
})
|
||||
},
|
||||
|
||||
confirmCycle(event){
|
||||
const { picker, value, index} = event.detail;
|
||||
let {items,cur_id}=this.data;
|
||||
|
||||
let obj='items['+cur_id+'].service_period';
|
||||
let day=null;
|
||||
if(index==0){
|
||||
day=30
|
||||
}else if(index==1){
|
||||
day=90
|
||||
}else if(index==2){
|
||||
day=180
|
||||
}else if(index==3){
|
||||
day=360
|
||||
}
|
||||
for (let index = 0; index < items.length; index++) {
|
||||
if(items[index].service_period==day){
|
||||
wx.showToast({
|
||||
title: '此服务周期不能重复设置',
|
||||
icon:'none'
|
||||
})
|
||||
return false
|
||||
};
|
||||
|
||||
}
|
||||
this.setData({
|
||||
showCycle:false,
|
||||
[obj]:day
|
||||
})
|
||||
|
||||
},
|
||||
changeIpt(event){
|
||||
let {value}=event.detail;
|
||||
let {id}=event.currentTarget.dataset;
|
||||
console.log(id);
|
||||
let obj='items['+id+'].service_price';
|
||||
this.setData({
|
||||
[obj]:value
|
||||
})
|
||||
|
||||
},
|
||||
delService(event){
|
||||
let {items}=this.data;
|
||||
let {id} =event.currentTarget.dataset;
|
||||
items.splice(1,id);
|
||||
this.setData({
|
||||
items
|
||||
})
|
||||
},
|
||||
handle(){
|
||||
this.data.isAdd?this.addService():this.editService();
|
||||
},
|
||||
addServiceArr(){
|
||||
let {items}=this.data;
|
||||
this.setData({
|
||||
items:items.concat({
|
||||
service_period:'' ,
|
||||
service_price:''
|
||||
})
|
||||
})
|
||||
},
|
||||
cancelCycle(){
|
||||
this.setData({
|
||||
showCycle:true
|
||||
showCycle:false
|
||||
})
|
||||
},
|
||||
getService(){
|
||||
api.getFollow().then(response=>{
|
||||
if(response.code==200){
|
||||
if(response.data){
|
||||
let {monthly_frequency,service_rounds,items}=response.data
|
||||
this.setData({
|
||||
monthly_frequency,
|
||||
service_rounds,
|
||||
items,
|
||||
isAdd:false
|
||||
})
|
||||
}else{
|
||||
this.setData({
|
||||
isAdd:true
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
addService(){
|
||||
let {monthly_frequency,service_rounds,items}=this.data;
|
||||
if(!monthly_frequency && monthly_frequency===''){
|
||||
wx.showToast({
|
||||
title: '请选择服务次数',
|
||||
icon:'none'
|
||||
})
|
||||
return false
|
||||
};
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if(!items[i].service_period){
|
||||
wx.showToast({
|
||||
title: '请选择第'+(i+1)+'个的服务周期',
|
||||
icon:'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
if(!items[i].service_price){
|
||||
wx.showToast({
|
||||
title: '请设置第'+(i+1)+'个的服务价格',
|
||||
icon:'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
api.postFollow({
|
||||
monthly_frequency,
|
||||
service_rounds,
|
||||
items
|
||||
}).then(response=>{
|
||||
if(response.code==200){
|
||||
wx.showToast({
|
||||
title: '保存成功',
|
||||
icon:'none'
|
||||
})
|
||||
wx.navigateBack()
|
||||
}
|
||||
})
|
||||
},
|
||||
editService(){
|
||||
let {monthly_frequency,service_rounds,items}=this.data;
|
||||
if(!monthly_frequency && monthly_frequency!=0){
|
||||
wx.showToast({
|
||||
title: '请选择服务次数',
|
||||
icon:'none'
|
||||
})
|
||||
return false
|
||||
};
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if(!items[i].service_period){
|
||||
wx.showToast({
|
||||
title: '请选择第'+(i+1)+'的服务周期',
|
||||
icon:'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
if(!items[i].service_price){
|
||||
wx.showToast({
|
||||
title: '请设置第'+(i+1)+'的服务价格',
|
||||
icon:'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
api.editFollow({
|
||||
monthly_frequency,
|
||||
service_rounds,
|
||||
items
|
||||
}).then(response=>{
|
||||
if(response.code==200){
|
||||
wx.showToast({
|
||||
title: '修改成功',
|
||||
});
|
||||
wx.navigateBack()
|
||||
}
|
||||
})
|
||||
},
|
||||
getFollowDetail(){
|
||||
api.getFollowDetail().then(response=>{
|
||||
if(response.code==200){
|
||||
if(response.data){
|
||||
let res=response.data.map((item)=>{
|
||||
return {service_period:item.service_period,service_price:item.service_price}
|
||||
})
|
||||
this.setData({
|
||||
items:res
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
openServiceNumber(){
|
||||
this.setData({
|
||||
showServiceNumber:true
|
||||
})
|
||||
},
|
||||
confirmServiceNumber(event){
|
||||
const { picker, value, index } = event.detail;
|
||||
|
||||
this.setData({
|
||||
showServiceNumber:false,
|
||||
monthly_frequency:index==0?10:0
|
||||
})
|
||||
},
|
||||
cancelServiceNumber(){
|
||||
this.setData({
|
||||
showServiceNumber:false
|
||||
})
|
||||
},
|
||||
/**
|
||||
@@ -46,7 +247,8 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
this.getService();
|
||||
this.getFollowDetail();
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,8 +4,11 @@
|
||||
<view class="price_steup_box">
|
||||
<view class="price_steup_box_top">
|
||||
<view class="price_steup_box_top_title">服务次数/月</view>
|
||||
<view class="price_steup_box_top_stepper">
|
||||
<van-icon name="arrow" color="#999" />
|
||||
<view class="price_steup_box_top_stepper" bind:tap="openServiceNumber">
|
||||
<text class="amount nodata" wx:if="{{monthly_frequency===''}}">请选择服务次数</text>
|
||||
<text class="amount" wx:else>{{monthly_frequency===0?'不限次数':'10次'}}</text>
|
||||
|
||||
<van-icon name="arrow" color="#999" style="margin-top: 2rpx;"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="price_steup_box_bottom">
|
||||
@@ -17,30 +20,35 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="checked_box">
|
||||
<view class="vontent">
|
||||
<view class="checked_box">
|
||||
<view class="title">服务内容</view>
|
||||
<view class="price_steup_box" style="height:240rpx">
|
||||
<view class="price_steup_box_top">
|
||||
<view class="price_steup_box" style="height:240rpx" wx:for="{{items}}" wx:key="index">
|
||||
<view class="price_steup_box_top" bind:tap="openCycle" data-id="{{index}}">
|
||||
<view class="price_steup_box_top_title">服务周期</view>
|
||||
<view class="price_steup_box_top_stepper">
|
||||
<van-icon name="arrow" color="#999" />
|
||||
<text class="amount " wx:if="{{item.service_period}}">{{item.service_period/30}}个月</text>
|
||||
<text class="amount nodata" wx:else>请选择周期</text>
|
||||
<van-icon name="arrow" color="#999" style="margin-top: 2rpx;"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="price_steup_box_bottom" style="border-bottom:0.5px solid #e7e7e7;padding-bottom: 25rpx;">
|
||||
<view class="price_steup_box_bottom_title">服务价格(元)</view>
|
||||
<view class="price_steup_box_bottom_num">
|
||||
<input type="number" class="ipt"/><text class="unit">元</text>
|
||||
<input type="number" class="ipt" value="{{item.service_price}}" placeholder="请设置价格" placeholder-style="font-size:28rpx;color: rgba(0,0,0,0.45);" bindinput="changeIpt" data-id="{{index}}" /><text class="unit" wx:if="{{item.service_price}}">元</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="tips">
|
||||
<view>建议服务价格设置为:单次图文*10次*5~8折</view>
|
||||
<view >建议服务价格设置为:{{(item.service_period/30)==1?'单次图文*10次*5~8折':(item.service_period/30)==3?'单次图文*30次*4~7折':(item.service_period/30)==6?'单次图文*60次*3~6折':(item.service_period/30)==12?'单次图文*120次*2~5折':'单次图文*10次*5'}}</view>
|
||||
<view wx:if="{{items.length>1}}" bind:tap="delService" data-id="{{index}}">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="continueadd">继续添加服务内容</view>
|
||||
<view class="btn">保存</view>
|
||||
<view class="continueadd" bind:tap="addServiceArr">继续添加服务内容</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn" bind:tap="handle">保存</view>
|
||||
<van-popup
|
||||
show="{{ showCycle }}"
|
||||
round
|
||||
@@ -48,4 +56,12 @@
|
||||
custom-style="height: 35%"
|
||||
>
|
||||
<van-picker columns="{{ cycle_columns }}" show-toolbar bind:confirm="confirmCycle" title="周期" bind:cancel="cancelCycle"/>
|
||||
</van-popup>
|
||||
<van-popup
|
||||
show="{{ showServiceNumber }}"
|
||||
round
|
||||
position="bottom"
|
||||
custom-style="height: 35%"
|
||||
>
|
||||
<van-picker columns="{{ service_columns }}" show-toolbar bind:confirm="confirmServiceNumber" title="服务次数" bind:cancel="cancelServiceNumber"/>
|
||||
</van-popup>
|
||||
@@ -1,6 +1,11 @@
|
||||
page{
|
||||
background-color: #F6F6F6;
|
||||
}
|
||||
.page{
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.title{
|
||||
width:90vw;
|
||||
margin: 0 auto 20rpx;
|
||||
@@ -23,7 +28,7 @@ page{
|
||||
display: flex;
|
||||
width: 90vw;
|
||||
height: 180rpx;
|
||||
margin: 0 auto;
|
||||
margin: 0 auto 20rpx;
|
||||
border-radius: 20rpx;
|
||||
flex-direction: column;
|
||||
background-color: rgb(255, 255, 255);
|
||||
@@ -48,8 +53,10 @@ page{
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.price{
|
||||
text-align: right!important;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.price_steup_box_bottom_num{
|
||||
flex: 1.5;
|
||||
@@ -77,7 +84,7 @@ page{
|
||||
transform: scaleY(0.5);
|
||||
}
|
||||
.price_steup_box_top_stepper{
|
||||
flex: 1;
|
||||
display: flex;
|
||||
text-align: right;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -125,7 +132,7 @@ color: #E34D59;
|
||||
justify-content: center;
|
||||
width:90vw;
|
||||
height: 80rpx;
|
||||
margin:160rpx auto 0;
|
||||
margin:80rpx auto 0;
|
||||
background: rgba(44,241,248,0.28);
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
@@ -158,4 +165,13 @@ color: rgba(0,0,0,0.6)!important;
|
||||
}
|
||||
.van-picker__toolbar{
|
||||
border-bottom:.5px solid #E7E7E7;
|
||||
}
|
||||
.amount.nodata{
|
||||
font-size: 28rpx;
|
||||
color: rgba(0,0,0,0.45);
|
||||
}
|
||||
.vontent{
|
||||
flex:1;
|
||||
margin-bottom: 150rpx;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
Reference in New Issue
Block a user