| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <template>
- <view class="distribution-page">
- <scroll-view scroll-y class="scroll-content">
- <view class="title">新客立减设置</view>
- <view class="form-item">
- <view class="label">立减金额(元)</view>
- <view class="value">
- <u-input fontSize="14" v-model="newDiscounts"></u-input>
- <text class="desc">金额在0~10之间,设置0元无新客立减</text>
- </view>
- </view>
-
- </scroll-view>
- <view class="footer-btn">
- <view class="save" @click="updateNewDiscounts">保存</view>
- </view>
- </view>
- </template>
- <script>
- import { mapState } from 'vuex';
- export default {
- data () {
- return {
- newDiscountsUrl: '/storeInfoManageApi/getStoreNewDiscounts',
- updateUrl: '/storeInfoManageApi/updateNewDiscounts',
- newDiscounts: 0
- }
- },
- computed: {
- ...mapState(['storeInfo'])
- },
- methods: {
- loadData () {
- uni.showLoading({
- title: '加载中'
- });
- var dateStr = (new Date()).getTime();
- var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
- this.requst({
- url: this.newDiscountsUrl,
- data: {
- timestamp: dateStr,
- sign: sign,
- storeId: this.storeInfo.storeId
- },
- success: res => {
- let price = res.data.obj;
- if (price != null && price != '' && price != undefined){
- this.newDiscounts = this.moneyConverter(price);
- }
- uni.hideLoading();
- },
- fail: (e) => {
- console.log("接口调用失败:" + JSON.stringify(e));
- uni.hideLoading();
- },
- })
- },
- updateNewDiscounts () {
- let regPrice = (/^[0-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/);
- if (this.newDiscounts == '' || this.newDiscounts == null) {
- this.$api.msg("立减金额不能为空");
- return;
- }
- if (!regPrice.test(this.newDiscounts)) {
- this.$api.msg("价格只能是正整数或小数点后两位");
- return;
- }
- if (Number(this.newDiscounts) < 0 || Number(this.newDiscounts) > 10) {
- this.$api.msg("立减金额在0到10之间");
- return;
- }
- uni.showLoading({
- title: '保存中'
- });
- var dateStr = (new Date()).getTime();
- var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
- this.requst({
- url: this.updateUrl,
- data: {
- timestamp: dateStr,
- sign: sign,
- storeId: this.storeInfo.storeId,
- newDiscounts: this.newDiscounts * 100
- },
- success:res => {
- if (res.data.rtnBean.rtnCode == 0) {
- uni.hideLoading();
- uni.showToast({
- title: "保存成功",
- duration: 3000,
- icon: 'none',
- });
- this.loadData();
- } else {
- uni.hideLoading();
- if (res.data.rtnBean.rtnMsg != '') {
- this.$api.msg(res.data.rtnBean.rtnMsg);
- }
- }
-
- },
- fail: (e) => {
- console.log("接口调用失败:" + JSON.stringify(e));
- uni.hideLoading();
- },
- });
- }
- },
- onShow () {
- },
- onLoad () {
- this.loadData()
- }
- }
- </script>
- <style lang="scss" scoped>
- .distribution-page {
- height: 100vh;
- background-color: #f5f5f5;
- }
- .scroll-content {
- height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
- height: calc(100vh - 120rpx - constant(safe-area-inset-bottom));
- }
- .title {
- font-size: 36rpx;
- color: $title-color;
- margin: 24rpx 0 16rpx;
- padding: 0 20rpx;
- }
- .form-item {
- background-color: #fff;
- @include flexStart(flex-start);
- padding: 20rpx 60rpx;
- box-sizing: border-box;
- .label {
- margin-right: 20rpx;
- margin-top: 20rpx;
- font-size: $font-base;
- color: $text-color;
- width: 180rpx;
- }
- .label.flex-center {
- margin-top: 6rpx;
- }
- .desc {
- font-size: $font-sm;
- color: $uni-color-button;
- }
- .flex-start {
- @include flexStart;
- .desc {
- margin-left: 20rpx;
- color: $text-color;
- }
- }
- }
- .form-item.pb0 {
- padding-bottom: 0;
- }
- .form-item.flex-center {
- @include flexStart(center);
- .label {
- margin-top: 0;
- }
- .btn {
- font-size: $font-base;
- color: #fff;
- background-color: $theme-color;
- @include flexCenter;
- padding: 6rpx 20rpx;
- border-radius: 10rpx;
- }
- .deliveryman {
- height: 52rpx;
- @include flexStart;
- font-size: $font-base;
- color: $text-color;
- }
- .del {
- color: $uni-color-button;
- margin-left: 20rpx;
- }
- }
- /deep/ .u-radio {
- margin-right: 50rpx;
- }
- .footer-btn {
- width: 100vw;
- margin-top: 40rpx;
- .save {
- margin: 0 10vw;
- width: 80vw;
- height: 80rpx;
- border-radius: 40rpx;
- background-color: $theme-color;
- color: #fff;
- @include flexCenter;
- }
- }
- </style>
|