shangjia1.1/pages/store/withdraw/credit.vue

176 lines
5.8 KiB
Vue

<template>
<view class="body">
<view class="header">
<view class="container">
<view class="icon">
<u-image v-if="false" height="60" width="60"
src="https://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/credit_card_icon.png"></u-image>
</view>
<view class="title " @click='showInfo = !showInfo'>
扫码付款 <text style="font-weight:bold;">[金豆抵扣]</text>设置<u-icon name="info-circle
" size="28"></u-icon>
</view>
</view>
</view>
<!-- <view class="payinfo" v-if="showInfo">
<view>开启金豆抵扣后,
<text style="font-weight:bold;">将同时开启随机立减功能;</text></view>
<view style="color:red;">请注意:提现时将扣除订单金豆赠送比例金额</view> -->
<!-- 0.0038平台手续费 -->
<!-- <view style="color:red;">例如:金豆赠送比例为0.01(百分之一),那消费者付款100元后,您将得到100*(1-0.0038)-(0.01*100)=98.62元</view>
<view style="color:#999999;">随机立减费用由余乐兑平台方承担,不会从商家提现中扣除</view>
</view> -->
<view class="content">
<u--form :model="form" ref="uForm">
<u-form-item label="是否开启金豆抵扣" label-width="280" prop="redirect">
<u-switch size='50' v-model="openCreditGive" @change="openCreditGiveChange" slot="right"></u-switch>
</u-form-item>
</u--form>
</view>
<view class="content" v-if="openCreditGive">
<u--form :model="form" ref="uForm">
<u-form-item label-width="300" :label-position="labelPosition" label="输入金豆抵扣比例:" prop="credit_give">
<u-input :border="border" @change="creditGiveInputChange" type="number" placeholder="请输入金豆抵扣比例"
v-model="form.credit_give"></u-input>
</u-form-item>
<u-form-item label-width="300" :label-position="labelPosition" label="确认金豆抵扣比例:" prop="credit_give2">
<u-input :border="border" type="number" placeholder="请再次输入金豆抵扣比例" v-model="form.credit_give2"></u-input>
</u-form-item>
</u--form>
</view>
<view style="padding:0.5rem 1rem;">
<view v-if="form.credit_give >= 1">
金豆抵扣比例不能大于1
</view>
<view v-else-if="form.credit_give > 0">
当前金豆抵扣百分比为:
<text style="font-weight:bold;">{{ (modifyCreditMoneyEg()) }}%; </text>
<text>即每收款100元,则抵扣消费者价值 <text>{{ modifyCreditMoneyEg() }}</text> 元的金豆</text>
</view>
<view v-else>
当前未开启金豆抵扣
</view>
<!-- <view style="margin-top:15rpx;">
<text>最大金豆赠送比例:{{ form.max_credit_give }} ; </text>
<text>最小金豆赠送比例:{{ form.min_credit_give }} ; </text>
</view> -->
</view>
<view style="margin-top: 60rpx;">
<u-button :disabled="false" class="button" @click="submit">保存设置</u-button>
</view>
</view>
</template>
<script>
let that = {}
export default {
data() {
return {
showInfo: false,
form: {
payType: '提现到银行',
payTypeValue: 2,
},
bankImgUp: 'http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/bank_card_setting/take_photo.png',// 银行卡照片OCR
openCreditGive: true,
border: 'none',
showPayType: false,
labelPosition: 'left',
modifyCreditMoneyEg: function () {
let resNum = parseFloat(parseFloat(that.form.credit_give) * 100).toFixed(2)
if (parseInt(resNum) == resNum) {
resNum = parseInt(resNum)
}
return resNum
},
};
},
onLoad: function () {
that = this
// that.init();
},
methods: {
init() {
getApp().globalData.util.request({
s: 'Merch.Mershop_Index.get',
}).then(res => {
console.log(res);
if (res.data.ret == 200) {
that.form = res.data.data
that.form.max_credit_give = parseFloat(that.form.max_credit_give).toFixed(2)
that.form.min_credit_give = parseFloat(that.form.min_credit_give).toFixed(3)
that.form.credit_give2 = res.data.data.credit_give
if (res.data.data.credit_give <= 0) {
that.openCreditGive = false
}
}
})
},
submit() {
if (!that.openCreditGive) {
that.form.credit_give = 0
}
if (that.form.credit_give >= 1) {
uni.showModal({
title: '提示',
content: '赠送比例必须小于1'
})
return
}
if (that.form.credit_give !== that.form.credit_give2) {
uni.showModal({
title: '提示',
content: '两次输入的赠送比例不一致'
})
return
}
// if (that.form.credit_give < that.form.min_credit_give || that.form.credit_give > that.form.max_credit_give) {
// uni.showModal({
// title: '提示',
// content: '金豆赠送率必须在'+that.form.min_credit_give+"到"+that.form.max_credit_give+"之间"
// })
// return
// }
getApp().globalData.util.request({
s: 'Merch.Mershop_Index.updateCreditGive',
credit_give: that.form.credit_give
}).then(res => {
uni.showModal({
title: '提示',
content: res.data.data.res_msg,
showCancel: false,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
}
}
})
})
},
openCreditGiveChange(selectValue) {
console.log(selectValue);
// if (!selectValue) {
// that.form.credit_give = 0
// that.form.credit_give2 = that.form.credit_give
// }else{
// that.form.credit_give = 0.001
// that.form.credit_give2 = that.form.credit_give
// }
},
creditGiveInputChange(inputValue) {
console.log(inputValue)
},
}
}
</script>
<style lang="scss" scoped>
@import "./creditadd.scss";
</style>