소스 검색

修改零售使用红包的一些问题

wangning 5 년 전
부모
커밋
dfaa78c156

+ 33 - 11
hdApp/src/admin/billing/affirmGhs.vue

@@ -239,7 +239,7 @@
             <appTimer :placeholder="'默认30分钟内配送'" @confirm="onConfirm" :sendTime="sendTime"></appTimer>
 					<tui-list-cell class="line-cell" :hover="false" :arrow="false" v-show="form.sendType == 1">
 						<view class="tui-title ">运费</view>
-						<input type="number" placeholder="留空表示免运费" @input="countAllPrices" v-model="form.sendCost" placeholder-class="tui-placeholder">
+						<input type="number" placeholder="留空表示免运费" @input="countAllPrices" v-model="form.sendCost" placeholder-class="tui-placeholder" disabled>
 					</tui-list-cell>
           <tui-list-cell class="line-cell" :hover="false" :arrow="true" @click="pageTo({url: '/admin/coupon/selectCouponList'})">
 						<view class="tui-title ">红包/抵用券</view>
@@ -265,8 +265,12 @@
 				<text class="price-title">总金额</text>
 				<text class="price-number">
 					¥
-					<text class="large" v-if="form.sendType==1">{{ this.numberAdd(allPrice, Number(form.sendCost))  }}</text>
-					<text class="large" v-else>{{ allPrice}}</text>
+					<text class="large" v-if="form.sendType==1 && !couponSumText">{{ numberAdd(allPrice, Number(form.sendCost))  }}</text>
+					<text class="large" v-else-if="form.sendType==1 && couponSumText">{{ allPrice + Number(form.sendCost) - Number(couponSumText)  }}</text>
+					<text class="large" v-else-if="form.sendType==2 && !couponSumText">{{ allPrice}}</text>
+					<text class="large" v-else-if="form.sendType==2 && couponSumText">{{ NumberSub(allPrice, Number(couponSumText))}}</text>
+					<text class="large" v-else-if="!form.sendType && !couponSumText">{{ allPrice }}</text>
+					<text class="large" v-else-if="!form.sendType && couponSumText">{{ NumberSub(allPrice, Number(couponSumText)) }}</text>
 				</text>
 			</view>
 			<button class="admin-button-com blue middle" @click="affirmFormSubmit">提交</button>
@@ -337,7 +341,7 @@ export default {
 			// 详细地址
 			// showRegion: false,
 			showCustomer: false,
-      couponSumText: uni.getStorageSync('selectCouponInfo').couponSum ? uni.getStorageSync('selectCouponInfo').couponSum : '',
+      couponSumText: '',
       couponText: ''
 		};
 	},
@@ -353,19 +357,20 @@ export default {
 				title: this.getMerchantInfo.name
 			});
 		}
+    
+		this.getGhsData(e.id);
+	},
+  onShow() {
     if(uni.getStorageSync('selectCouponInfo').couponSum) {
-      this.couponText = '-¥' + uni.getStorageSync('selectCouponInfo').couponSum
+      this.couponSumText = uni.getStorageSync('selectCouponInfo').couponSum
+      this.couponText = '-¥' + this.couponSumText
     } else {
        this.hasCoupon()
     }
-		this.getGhsData(e.id);
-	},
+  },
 	computed: {
 		...mapGetters(["getMerchantInfo", "getLoginInfo"])
 	},
-  onUnload() {
-    uni.removeStorageSync('selectCouponInfo')
-  },
 	methods: {
 		...mapActions(["initMerchantInfo"]),
 		init() {
@@ -382,7 +387,7 @@ export default {
     // 是否有可用优惠券
     hasCoupon() {
       let amount = this.form.sendType == 1 ? this.allPrice+Number(this.form.sendCost) : this.allPrice
-      shopHouponHas(amount).then(res => {
+      shopHouponHas({amount}).then(res => {
         console.log(377, res)
         this.couponText = res.data.has ? '有可用优惠券' : ''
         console.log(this.couponText)
@@ -462,6 +467,7 @@ export default {
 				content: '确认提交?',
 				success: function (res) {
 					if (res.confirm) {
+            uni.removeStorageSync('selectCouponInfo')
 						createOrder(parameter).then(res => {
 							self.resetSelectInfoByType(self.pageType);
 							const {data: { orderSn,actPrice }} = res;
@@ -486,6 +492,22 @@ export default {
       m = Math.pow(10, Math.max(r1, r2))
       n = (r1 >= r2) ? r1 : r2;
       return ((arg1 * m + arg2 * m) / m).toFixed(n);
+  },
+  NumberSub(arg1, arg2) {
+    var re1, re2, m, n;
+    try {
+        re1 = arg1.toString().split(".")[1].length;
+    } catch (e) {
+    re1 = 0;
+    }
+    try {
+        re2 = arg2.toString().split(".")[1].length;
+    } catch (e) {
+        re2 = 0;
+    }
+    m = Math.pow(10, Math.max(re1, re2)); 
+    n = (re1 >= re2) ? re1 : re2;
+    return ((arg1 * m - arg2 * m) / m).toFixed(n);
   },
 		// 表单验证
 		async formSubmit(e) {

+ 5 - 5
hdApp/src/admin/coupon/components/selectCouponItem.vue

@@ -1,12 +1,7 @@
 <template>
   <div class="coupon-list">
     <div class="list-img">
-      <template v-if="couponSelInx && couponSelInx == (index + 1)">
-        <img :src="`${constant.imgUrl}/retail/coupon/is-check.png`" alt mode="widthFix" />
-      </template>
-      <template v-else>
         <img :src="`${constant.imgUrl}/retail/coupon/no-check.png`" alt mode="widthFix" />
-      </template>
     </div>
     <div class="list-det">
       <div class="list-det-left">
@@ -35,6 +30,11 @@ export default {
       type: Object,
       default: {}
     }
+  },
+  data() {
+    return {
+      constant: this.$constant,
+    }
   }
 };
 </script>

+ 21 - 1
hdApp/src/admin/coupon/selectCouponList.vue

@@ -72,6 +72,13 @@ export default {
     }
   },
   mounted() {},
+  onShow() {
+    if( uni.getStorageSync('selectCouponInfo').couponId != null) {
+      this.couponSelInx = uni.getStorageSync('selectCouponInfo').couponSelInx
+      this.couponId = uni.getStorageSync('selectCouponInfo').couponId
+      this.couponSum = uni.getStorageSync('selectCouponInfo').couponSum
+    }
+  },
   onPullDownRefresh() {
 			this._list().then(res => {
 				uni.stopPullDownRefresh()
@@ -89,14 +96,27 @@ export default {
 		},
     // 优惠券选择
     couponChange(item, index) {
+      
       this.couponSelInx = this.couponSelInx == index ? null : index;
       this.couponId = this.couponSelInx == index ? item.id : 0;
       this.couponSum = this.couponSelInx == index ? item.amount : '';
+      
       console.log(this.couponId, this.couponSelInx)
     },
     ConfirmReachFn() {
+      let obj = {}
       console.log({couponSum: this.couponSum, couponId: this.couponId})
-      uni.setStorageSync('selectCouponInfo', {couponSum: this.couponSum, couponId: this.couponId})
+      if(this.couponSum != '0') {
+        obj.couponSum = this.couponSum
+      }
+      if(this.couponId != '0') {
+        obj.couponId = this.couponId
+      }
+      if (this.couponSelInx != null) {
+        obj.couponSelInx = this.couponSelInx
+      }
+      console.log(obj, 116)
+      uni.setStorageSync('selectCouponInfo', obj)
       uni.navigateBack({})
     }
   }

+ 1 - 0
hdApp/src/pagesPurchase/ghsProduct.vue

@@ -311,6 +311,7 @@ export default {
 		},
 		confirmSelectEvent() {
 			if (this.selectList.length > 0) {
+        uni.removeStorageSync('selectCouponInfo')
 				uni.navigateTo({
 					url: `/admin/billing/affirmGhs?id=${this.options.id}`
 				});