zs 2 rokov pred
rodič
commit
afaf70c427
1 zmenil súbory, kde vykonal 91 pridanie a 26 odobranie
  1. 91 26
      pagesMy/order/service.vue

+ 91 - 26
pagesMy/order/service.vue

@@ -8,7 +8,8 @@
 				<view class="one_2">
 					<view class="list" v-for="(item,index) in info.goods" :key="index">
 						<view class="list_1">
-							<image class="image" :src="item.goods.file&&item.goods.file.length>0?item.goods.file[0].url:''" mode="">
+							<image class="image"
+								:src="item.goods.file&&item.goods.file.length>0?item.goods.file[0].url:''" mode="">
 							</image>
 						</view>
 						<view class="list_2">
@@ -36,23 +37,27 @@
 				<view class="two_1" v-if="status=='3'">
 					<uni-forms ref="thrform" :rules="thrrules" :model="thrform" label-width="auto">
 						<uni-forms-item label="售后商品" name="goods_id">
-							<picker class="picker" mode="selector" :range="info.goods" @change="goodsChange" range-key="goods_name">
+							<picker class="picker" mode="selector" :range="info.goods" @change="goodsChange"
+								range-key="goods_name">
 								<view>{{thrform.goods_name||'请选择退款商品'}}</view>
 							</picker>
 						</uni-forms-item>
 						<uni-forms-item label="售后类型" name="type">
-							<picker class="picker" mode="selector" :range="typeList" @change="typeChange" range-key="label">
+							<picker class="picker" mode="selector" :range="typeList" @change="typeChange"
+								range-key="label">
 								<view>{{thrform.type_name||'请选择售后类型'}}</view>
 							</picker>
 						</uni-forms-item>
 						<uni-forms-item label="退款金额" name="money" v-if="thrform.type=='0'||thrform.type=='1'">
-							<uni-easyinput type="digit" v-model="thrform.money" @input="toMoney" placeholder="请输入退款金额" />
-							<view>
-								最大退款金额不能超过{{moneyInfo.payTotal||0}}
+							<uni-easyinput type="digit" v-model="thrform.money" @input="toMoney"
+								placeholder="请输入退款金额" />
+							<view class="money">
+								最大退款金额不能超过 <text>{{moneyInfo.payTotal||0}}</text>,<text @tap="toAll">全部提现</text>
 							</view>
 						</uni-forms-item>
 						<uni-forms-item label="申请理由" name="reason">
-							<picker class="picker" mode="selector" :range="reasonList" @change="reasonChange" range-key="label">
+							<picker class="picker" mode="selector" :range="reasonList" @change="reasonChange"
+								range-key="label">
 								<view>{{thrform.reason_name||'请选择申请理由'}}</view>
 							</picker>
 						</uni-forms-item>
@@ -108,7 +113,30 @@
 				},
 				// 已收到货
 				thrform: {},
-				thrrules: {},
+				// 附件
+				icon: [],
+				// 最大退款数
+				moneyInfo: {},
+				thrrules: {
+					type: {
+						rules: [{
+							required: true,
+							errorMessage: '请选择售后类型',
+						}]
+					},
+					goods_id: {
+						rules: [{
+							required: true,
+							errorMessage: '请选择退款商品',
+						}]
+					},
+					reason: {
+						rules: [{
+							required: true,
+							errorMessage: '请选择申请理由',
+						}]
+					},
+				},
 				// 售后类型
 				typeList: [],
 				// 申请理由
@@ -165,27 +193,36 @@
 				const that = this;
 				let data = that.info.goods[e.detail.value];
 				if (data) that.$set(that.info, `goods`, [data])
+				that.$set(that.thrform, `goods_id`, data._id);
 				that.$set(that.thrform, `goods_name`, data.goods_name);
 			},
 			// 选择售后类型
 			async typeChange(e) {
 				const that = this;
+				let thrform = that.thrform;
 				let data = that.typeList[e.detail.value];
 				if (data) {
-					that.$set(that.form, `type`, data.value);
-					that.$set(that.form, `type_name`, data.label);
+					that.$set(that.thrform, `type`, data.value);
+					that.$set(that.thrform, `type_name`, data.label);
 				}
 				if (data.value != '2') {
-					const arr = await that.$api(`/afterSale/cgfr`, 'POST', {
-						order_detail: that.id,
-						goods_id: that.info._id
-					});
-					if (arr.errcode == '0') {
-						that.$set(that, `moneyInfo`, arr.data);
+					if (thrform.goods_id) {
+						const arr = await that.$api(`/afterSale/cgfr`, 'POST', {
+							order_detail: that.id,
+							goods_id: thrform.goods_id
+						});
+						if (arr.errcode == '0') {
+							that.$set(that, `moneyInfo`, arr.data);
+						} else {
+							uni.showToast({
+								title: arr.errmsg,
+								icon: 'none',
+							})
+						}
 					} else {
 						uni.showToast({
-							title: arr.errmsg,
-							icon: 'none',
+							title: '缺少商品信息',
+							icon: 'none'
 						})
 					}
 				}
@@ -223,6 +260,11 @@
 				let arr = data.filter((i, index) => index != e.data.index);
 				that.$set(that, `${e.name}`, arr)
 			},
+			// 全部提现
+			toAll() {
+				const that = this;
+				that.$set(that.thrform, `money`, that.moneyInfo.payTotal)
+			},
 			// 提交保存
 			async onSubmit(ref) {
 				const that = this;
@@ -230,14 +272,24 @@
 				let money = that.moneyInfo.payTotal;
 				that.$refs[ref].validate().then(params => {
 					if (status == '3') {
-						if (parseFloat(params.money) > parseFloat(money)) {
-							uni.showToast({
-								title: '输入金额不能超过实际支付金额',
-								icon: 'none'
-							})
-						} else {
-							console.log(params);
-						}
+						if (params.type != '2')
+							if (params.money) {
+								if (parseFloat(params.money) > parseFloat(money)) {
+									uni.showToast({
+										title: '输入金额不能超过实际支付金额',
+										icon: 'none'
+									})
+								} else {
+									params.file = that.icon;
+									params.order_detail = that.id;
+									console.log(params);
+								}
+							} else {
+								uni.showToast({
+									title: `请输入退款金额`,
+									icon: 'none',
+								});
+							}
 					} else {
 						that.orderCancel(params)
 					}
@@ -371,6 +423,19 @@
 					padding: 2vw;
 				}
 
+				.money {
+					margin: 1vw 0 0 0;
+
+					text {
+						color: #ff0000;
+					}
+
+					text:last-child {
+						color: #6A5ACD;
+					}
+
+				}
+
 				.btn {
 					text-align: center;
 				}