浏览代码

优惠券

zhengkaixin 3 年之前
父节点
当前提交
40e537e57f
共有 4 个文件被更改,包括 73 次插入38 次删除
  1. 1 1
      .env.prod.js
  2. 8 0
      apis/chargeProcess.js
  3. 5 3
      pages/index/index.vue
  4. 59 34
      pages/searchPile/chargeProcess/charge.vue

+ 1 - 1
.env.prod.js

@@ -1,6 +1,6 @@
 const UNI_APP = {  	
 		ProjectName :"51充电联盟",
-    BASE_URL: 'https://charging.xiaoxinda.com/charging-station-server/',
+    BASE_URL: 'https://51team.xiaoxinda.com/charging-station-server/',
 	NODE_ENV :"prod",
 	SIMPLE_RUN:false,
 	openId:"oHjCawigqi8SEAwutwkQ-VEgdp3k",//测试用openId

+ 8 - 0
apis/chargeProcess.js

@@ -50,3 +50,11 @@ export function stopCarCharging(data) {
 		url: '/mobile/command/stopCarCharging'
 	})
 }
+
+export function useCoupon(data) {
+	return request({
+		method: 'post',
+		data: data,
+		url: '/mobile/chargingCouponApi/useCoupon'
+	})
+}

+ 5 - 3
pages/index/index.vue

@@ -337,11 +337,13 @@
 		},
 		methods: {
 			getPointTimeOut() {
-				if(this.pointTimeOut){
+			
 					setTimeout(()=>{
-						this.getPoint();
+						if(this.pointTimeOut){
+							this.getPoint();
+						}
 					},1000)
-				}
+				
 			},
 			getFindChargeData() {
 				API.findChargeData().then((res) => {				

+ 59 - 34
pages/searchPile/chargeProcess/charge.vue

@@ -27,25 +27,28 @@
 			</view>
 
 			<!-- 优惠券 -->
-			<view class="discounts" v-if="false">
+			<view class="discounts" v-if="list.length" >
 				<view class="title">
-					<view class="title-1">
+					<span class="title-1">
 						优惠券
-					</view>
-					<view class="title-2">
+					</span>
+					<span class="title-2">
 						每次只能使用1张
-					</view>
-					<view class="title-3">
+					</span>
+					<span class="title-3">
 						-¥6.00
-					</view>
+					</span>
 				</view>
 				<view class="select">
-					<u-radio-group v-model="value" @change="radioGroupChange" wrap="true">
+					<u-radio-group v-model="value" @change="radioGroupChange" :wrap="true">
+						
 						<u-radio @change="radioChange" v-for="(item, index) in list" :key="index" :name="item.name"
+							:style="item.disabled?'	background-color: #e3e3e3 !important;':''"
 							:disabled="item.disabled">
 							{{item.name}}
 
-						</u-radio>
+						</u-radio>
+						 
 						<view class="explain">使用说明</view>
 					</u-radio-group>
 
@@ -113,7 +116,8 @@
 						name: '100'
 					},
 
-				],
+				],
+				value:"",
 				// 优惠券
 				list: [{
 						name: '满50元减6元',
@@ -124,8 +128,8 @@
 						disabled: false
 					},
 					{
-						name: '满100减15元 未满足使用条件',
-						disabled: false
+						name: '满100减15元',
+						disabled: true
 					}
 				],
 
@@ -141,7 +145,7 @@
 			if(op.isback){
 				this.isback=false;
 			}
-
+			this.useCoupon()
 		},
 		onShow() {
 			this.getHomePage()
@@ -173,7 +177,8 @@
 
 			},
 			moneyClick(index) {
-				this.moneyActiveClass = index;
+				this.moneyActiveClass = index;
+				this.useCoupon()
 
 			},
 			confirm() {
@@ -225,27 +230,47 @@
 					this.user = res.data
 					this.isReady = true;
 					uni.hideLoading()
-
+					//this.useCoupon()
 				}).catch(error => {
 					uni.showToast({
 						title: error
 					})
 				})
 			},
-
+			useCoupon(){
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				 	this.submitInit()
+				API.useCoupon({
+					amount:this.submitForm.amount
+				}).then((res) => {
+					this.list=res.userCouponList
+					uni.hideLoading()
+					
+				}).catch(error => {
+					uni.showToast({
+						title: error
+					})
+				})
+			},
+			submitInit(){
+				if (this.moneyActiveClass == -1 && !this.otherNum) {
+					this.submitForm.chargeStrategy = 0;
+					this.submitForm.amount = 0
+				} else {
+					this.submitForm.chargeStrategy = 2;
+					if (this.otherNum) {
+						this.submitForm.amount = this.otherNum
+					} else {
+						this.submitForm.amount = this.moneyActiveClass
+					}
+				}
+			},
 			submit() {
-
-				if (this.moneyActiveClass == -1 && !this.otherNum) {
-					this.submitForm.chargeStrategy = 0;
-					this.submitForm.amount = 0
-				} else {
-					this.submitForm.chargeStrategy = 2;
-					if (this.otherNum) {
-						this.submitForm.amount = this.otherNum
-					} else {
-						this.submitForm.amount = this.moneyActiveClass
-					}
-				}
+				this.submitInit()
+				
 
 				if (!this.submitForm.channelNo) {
 					uni.showToast({
@@ -405,10 +430,10 @@
 
 		.title {
 			width: 100%;
-			display: flex;
+			
 
 			.title-1 {
-				width: 48px;
+			
 				height: 22px;
 				color: rgba(16, 16, 16, 100);
 				font-size: 16px;
@@ -421,7 +446,7 @@
 			}
 
 			.title-3 {
-				margin-left: 126px;
+				float: right;
 				height: 19px;
 				font-size: 16px;
 			}
@@ -442,10 +467,10 @@
 				position: relative;
 			}
 
-			/deep/.u-radio:nth-child(3) {
-				background-color: #e3e3e3 !important;
+			// /deep/.u-radio:nth-child(3) {
+			// 
 
-			}
+			// }
 
 			/deep/.u-radio__icon-wrap {
 				left: 16px;