|
|
@@ -33,13 +33,8 @@
|
|
|
<image class="icon" src="/static/icons/usdt_min.png" mode=""></image>
|
|
|
</view>
|
|
|
<view class="item price">
|
|
|
- <template v-if="formData.price_type==1">
|
|
|
-
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- <u-number-box v-model="value" @change="valChange"></u-number-box>
|
|
|
- </template>
|
|
|
-
|
|
|
+ <u-input type="text" :value="v.price" :placeholder="lang.advert_price" disabled>
|
|
|
+ </u-input>
|
|
|
</view>
|
|
|
<view class="item pay">
|
|
|
<template v-if="v.pay_type" v-for="(vo, kk) in v.pay_type">
|
|
|
@@ -55,7 +50,7 @@
|
|
|
<text class="time" v-else>{{lang.unsaled}}</text>
|
|
|
</view>
|
|
|
<view class="item op">
|
|
|
- <text class="btn" @click="unsale(v, 1)">{{lang.unsale}}</text>
|
|
|
+ <text class="btn" @click="unsale(v, k)">{{lang.unsale}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
@@ -68,7 +63,7 @@
|
|
|
:mask-close-able="true" width="90%" :show-title="true" :z-index="96" :show-cancel-button="true"
|
|
|
:confirm-text="lang.confirm" :cancel-text="lang.cancel" confirm-color="#bb955e">
|
|
|
<view v-slot class="u-modal-content">
|
|
|
- <u-form labelPosition="left" :model="formData" ref="tradeForm" :labelWidth="'120rpx'">
|
|
|
+ <u-form labelPosition="left" :model="formData" ref="tradeForm" :labelWidth="'130rpx'">
|
|
|
<u-form-item :label="lang.publish_type">
|
|
|
<u-radio-group v-model="formData.type" placement="row" @change="radioGroupChange">
|
|
|
<u-radio activeColor="#bb955e" :label="lang.trade_buy" name="1">{{lang.trade_buy}}</u-radio>
|
|
|
@@ -79,10 +74,10 @@
|
|
|
<u-form-item :label="lang.publishname">
|
|
|
<u-input type="text" v-model="userInfo.username" disabled placeholder=""></u-input>
|
|
|
</u-form-item>
|
|
|
- <u-form-item :label="lang.limit">
|
|
|
- <u-input type="text" :placeholder="lang.limit_min+' USDT'">
|
|
|
+ <u-form-item :label="lang.advert_limit">
|
|
|
+ <u-input type="text" v-model="formData.limit_min" :placeholder="lang.limit_min+' CNY'">
|
|
|
</u-input>~
|
|
|
- <u-input type="text" :placeholder="lang.limit_max+' USDT'">
|
|
|
+ <u-input type="text" v-model="formData.limit_max" :placeholder="lang.limit_max+' CNY'">
|
|
|
</u-input>
|
|
|
</u-form-item>
|
|
|
<u-form-item :label="lang.price_type">
|
|
|
@@ -93,10 +88,28 @@
|
|
|
</u-radio-group>
|
|
|
</u-form-item>
|
|
|
<u-form-item :label="lang.price">
|
|
|
- <u-input type="text" :value="info.price+' CNY'" disabled placeholder=""></u-input>
|
|
|
- <view class="price">
|
|
|
+ <template v-if="formData.price_type==1">
|
|
|
+ <u-input type="text" v-model="formData.price" :placeholder="lang.advert_price">
|
|
|
+ </u-input>
|
|
|
+ <text class="unit">CNY</text>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <view class="price-box">
|
|
|
+ <view class="float-price">
|
|
|
+ <u-number-box v-model="formData.prioce" @change="changePrice" :input-width="100"
|
|
|
+ :positive-integer="false"
|
|
|
+ :min="-(formData.type==1? trade.buy_price:trade.sell_price)" :max="10"
|
|
|
+ :step="0.1">
|
|
|
+ </u-number-box>
|
|
|
+ </view>
|
|
|
+ <view class="price">
|
|
|
+ <text
|
|
|
+ class="text">{{lang.trade_price}}:{{(formData.type==1?trade.buy_price:trade.sell_price)}}</text>
|
|
|
+ <text class="text real">{{lang.real_price}}:{{formData.real_price}}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </template>
|
|
|
|
|
|
- </view>
|
|
|
</u-form-item>
|
|
|
<u-form-item :label="lang.pay_type">
|
|
|
<u-checkbox-group @change="checkboxGroupChange">
|
|
|
@@ -111,16 +124,9 @@
|
|
|
</u-checkbox>
|
|
|
</u-checkbox-group>
|
|
|
</u-form-item>
|
|
|
- <u-form-item :label="lang.advert_num" prop="formData.num">
|
|
|
- <u-input v-if="formData.type==1" type="text" v-model="formData.num"
|
|
|
- :placeholder="lang.input_buy_num" @input="countTotal">
|
|
|
- </u-input>
|
|
|
- <u-input v-else type="text" v-model="formData.num" :placeholder="lang.input_sell_num"
|
|
|
- @input="countTotal">
|
|
|
- </u-input>
|
|
|
- </u-form-item>
|
|
|
- <u-form-item :label="lang.trade_total">
|
|
|
- <u-input type="text" :value="formData.total+' CNY'" disabled>
|
|
|
+ <u-form-item :label="lang.advert_time" prop="formData.expired_at">
|
|
|
+ <u-input type="text" v-model="formData.expired_at" :placeholder="lang.select_date"
|
|
|
+ @click="showDate=true" readonly>
|
|
|
</u-input>
|
|
|
</u-form-item>
|
|
|
<u-form-item :label="lang.trade_password" prop="formData.trade_password">
|
|
|
@@ -132,6 +138,9 @@
|
|
|
</view>
|
|
|
</u-modal>
|
|
|
|
|
|
+ <u-calendar v-model="showDate" :mode="'date'" @change="changeDate" :min-date="minDate()" :max-date="maxDate()">
|
|
|
+ </u-calendar>
|
|
|
+
|
|
|
<!-- 与包裹页面所有内容的元素u-page同级,且在它的下方 -->
|
|
|
<tabbars :currentIndex="4"></tabbars>
|
|
|
</view>
|
|
|
@@ -147,6 +156,7 @@
|
|
|
return {
|
|
|
index: 0,
|
|
|
page: 1,
|
|
|
+ showDate: false,
|
|
|
loadMore: false,
|
|
|
loadStatus: 'loadmore',
|
|
|
loaded: false,
|
|
|
@@ -154,16 +164,18 @@
|
|
|
info: {},
|
|
|
// 表单数据
|
|
|
formData: {
|
|
|
- pay_type: '',
|
|
|
+ pay_type: [1],
|
|
|
price_type: 1,
|
|
|
- type: 2,
|
|
|
+ type: 1,
|
|
|
+ limit_min: '',
|
|
|
+ limit_max: '',
|
|
|
trade_password: '',
|
|
|
price: '',
|
|
|
real_price: '0.00',
|
|
|
- expried_at: '',
|
|
|
+ expired_at: '',
|
|
|
},
|
|
|
checkboxArr: {
|
|
|
- bank: false,
|
|
|
+ bank: true,
|
|
|
wxpay: false,
|
|
|
alipay: false,
|
|
|
},
|
|
|
@@ -178,11 +190,14 @@
|
|
|
// 用户收款方式
|
|
|
payment: [],
|
|
|
adverts: [],
|
|
|
+ // 交易参数
|
|
|
+ trade: {},
|
|
|
};
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
let type = typeof(options.type) != 'undefined' ? options.type : 1;
|
|
|
this.formData.type = type == 1 ? 1 : 2;
|
|
|
+ this.getTrade()
|
|
|
this.getData()
|
|
|
this.getUserInfo()
|
|
|
|
|
|
@@ -198,11 +213,24 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ minDate() {
|
|
|
+ let _date = new Date();
|
|
|
+ let day = _date.getFullYear() + '-' + (_date.getMonth() + 1) + '-' + _date.getDate();
|
|
|
+ return day;
|
|
|
+ },
|
|
|
+ maxDate() {
|
|
|
+ let _date = new Date();
|
|
|
+ let day = (_date.getFullYear() + 1) + '-' + (_date.getMonth() + 1) + '-' + _date.getDate();
|
|
|
+ console.log(day)
|
|
|
+ return day;
|
|
|
+ },
|
|
|
// 切换交易类型
|
|
|
changeType(type) {
|
|
|
let _this = this;
|
|
|
this.$nextTick(() => {
|
|
|
- this.formData.type = type;
|
|
|
+ _this.formData.type = type;
|
|
|
+ _this.page = 1;
|
|
|
+ _this.adverts = [];
|
|
|
_this.getData();
|
|
|
});
|
|
|
},
|
|
|
@@ -212,6 +240,26 @@
|
|
|
priceGroupChange(e) {
|
|
|
this.formData.price_type = e;
|
|
|
},
|
|
|
+ changePrice(e) {
|
|
|
+ console.log(e)
|
|
|
+ // 购买价格
|
|
|
+ this.formData.price = e.value
|
|
|
+ if (this.formData.type == 1) {
|
|
|
+ this.formData.real_price = (parseFloat(this.trade.buy_price) + parseFloat(e.value)).toFixed(2)
|
|
|
+ } else {
|
|
|
+ this.formData.real_price = (parseFloat(this.trade.sell_price) + parseFloat(e.value)).toFixed(2)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.formData.real_price <= 0) {
|
|
|
+ this.formData.price = ''
|
|
|
+ this.formData.real_price = '0.00'
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$forceUpdate()
|
|
|
+ },
|
|
|
+ changeDate(date) {
|
|
|
+ this.formData.expired_at = date.result ? date.result + ' 23:59:59' : '';
|
|
|
+ },
|
|
|
// 计算实际价格
|
|
|
countPrice() {
|
|
|
this.formData.price = parseFloat(this.formData.price)
|
|
|
@@ -224,7 +272,7 @@
|
|
|
this.showPopup = true
|
|
|
},
|
|
|
checkboxGroupChange(e) {
|
|
|
- console.log(e)
|
|
|
+ this.formData.pay_type = e
|
|
|
},
|
|
|
//获取用户数据
|
|
|
getUserInfo() {
|
|
|
@@ -244,13 +292,16 @@
|
|
|
// 购买
|
|
|
unsale(data, index) {
|
|
|
let _this = this;
|
|
|
+
|
|
|
this.$request.sendToken('/api/advert/status', {
|
|
|
id: data.id,
|
|
|
status: 2
|
|
|
}, 'POST').then(res => {
|
|
|
if (res.success == true) {
|
|
|
- _this.adverts[index].status = 2;
|
|
|
this.$u.toast(res.msg);
|
|
|
+ setTimeout(function() {
|
|
|
+ _this.getData()
|
|
|
+ }, 800)
|
|
|
} else {
|
|
|
this.$u.toast(res.msg);
|
|
|
}
|
|
|
@@ -259,13 +310,60 @@
|
|
|
// 添加
|
|
|
submit() {
|
|
|
let _this = this;
|
|
|
- this.$request.sendToken('/api/advert/add', _this.formData, 'POST').then(res => {
|
|
|
+ console.log(_this.formData)
|
|
|
+ if (this.formData.limit_min <= 0) {
|
|
|
+ this.$u.toast(this.lang.input_limit_min);
|
|
|
+ _this.$refs.uModal.clearLoading();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (this.formData.limit_max <= 0) {
|
|
|
+ this.$u.toast(this.lang.input_limit_max);
|
|
|
+ _this.$refs.uModal.clearLoading();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (parseFloat(this.formData.limit_min) >= parseFloat(this.formData.limit_max)) {
|
|
|
+ this.$u.toast(this.lang.limit_error);
|
|
|
+ _this.$refs.uModal.clearLoading();
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (this.formData.price <= 0 && this.formData.price_type == 1) {
|
|
|
+ this.$u.toast(this.lang.input_price);
|
|
|
+ _this.$refs.uModal.clearLoading();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (this.formData.expired_at == '') {
|
|
|
+ this.$u.toast(this.lang.select_date);
|
|
|
+ _this.$refs.uModal.clearLoading();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (this.formData.trade_password == '') {
|
|
|
+ this.$u.toast(this.lang.input_trade_password);
|
|
|
+ _this.$refs.uModal.clearLoading();
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+ this.$request.sendToken('/api/advert/edit', _this.formData, 'POST').then(res => {
|
|
|
if (res.success == true) {
|
|
|
- _this.showPopup = false;
|
|
|
- _this.getData()
|
|
|
+ this.$u.toast(res.msg);
|
|
|
+ setTimeout(function() {
|
|
|
+ _this.showPopup = false;
|
|
|
+ _this.formData = {
|
|
|
+ pay_type: [1],
|
|
|
+ price_type: 1,
|
|
|
+ type: 1,
|
|
|
+ limit_min: '',
|
|
|
+ limit_max: '',
|
|
|
+ trade_password: '',
|
|
|
+ price: '',
|
|
|
+ real_price: '0.00',
|
|
|
+ expired_at: '',
|
|
|
+ };
|
|
|
+ _this.getData()
|
|
|
+ }, 800)
|
|
|
} else {
|
|
|
this.$u.toast(res.msg);
|
|
|
- _this.$refs.payConfirmModal.clearLoading();
|
|
|
+ _this.$refs.uModal.clearLoading();
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
@@ -302,6 +400,15 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ // 获取交易参数
|
|
|
+ getTrade() {
|
|
|
+ let _this = this;
|
|
|
+ let locale = uni.getStorageSync('locale')
|
|
|
+ this.$request.sendToken('/api/trade', {}, 'POST').then(res => {
|
|
|
+ // 打印调用成功回调
|
|
|
+ this.trade = res.data.trade
|
|
|
+ })
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
@@ -484,6 +591,8 @@
|
|
|
text-align: left;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
.head {
|
|
|
@@ -532,6 +641,24 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ .unit {
|
|
|
+ color: #666;
|
|
|
+ }
|
|
|
+
|
|
|
+ .price-box {
|
|
|
+ width: 100%;
|
|
|
+
|
|
|
+ .price {
|
|
|
+ width: 100%;
|
|
|
+
|
|
|
+ .text {
|
|
|
+ display: inline-block;
|
|
|
+ }
|
|
|
+
|
|
|
+ .real {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
.info {
|
|
|
padding: 19rpx 0;
|
|
|
|