Quellcode durchsuchen

余额支付功能

liyuan vor 1 Monat
Ursprung
Commit
f42979958e
2 geänderte Dateien mit 167 neuen und 74 gelöschten Zeilen
  1. 14 7
      pages/tabBar/center.vue
  2. 153 67
      pages/tabBar/shoppingCart.vue

+ 14 - 7
pages/tabBar/center.vue

@@ -13,7 +13,7 @@
 		</view>
 		</view>
 		<view class="card" style="height: 114rpx;">
 		<view class="card" style="height: 114rpx;">
 			<view style="display: flex;justify-content: space-around;align-items: center;height: 114rpx;">
 			<view style="display: flex;justify-content: space-around;align-items: center;height: 114rpx;">
-				<text style="color:#818181;font-size: 24rpx;">
+<!--				<text style="color:#818181;font-size: 24rpx;">
 					产生积分:
 					产生积分:
 					<text style="color:#FE8301;font-size: 26rpx;">
 					<text style="color:#FE8301;font-size: 26rpx;">
 						{{form.addPoints?form.addPoints:'0.00'}}
 						{{form.addPoints?form.addPoints:'0.00'}}
@@ -24,13 +24,19 @@
 					<text style="color:#FE8301;font-size: 26rpx;">
 					<text style="color:#FE8301;font-size: 26rpx;">
 						{{form.subPoints?form.subPoints:'0.00'}}
 						{{form.subPoints?form.subPoints:'0.00'}}
 					</text>
 					</text>
-				</text>
+				</text>-->
 				<text style="color:#818181;font-size: 24rpx;">
 				<text style="color:#818181;font-size: 24rpx;">
-					余额:
+					积分余额:
 					<text style="color:#FE8301;font-size: 26rpx;">
 					<text style="color:#FE8301;font-size: 26rpx;">
 						{{form.pointsBalance?form.pointsBalance:'0.00'}}
 						{{form.pointsBalance?form.pointsBalance:'0.00'}}
 					</text>
 					</text>
 				</text>
 				</text>
+        <text style="color:#818181;font-size: 24rpx;">
+          现金余额:
+          <text style="color:#FE8301;font-size: 26rpx;">
+            {{form.recoveredBalance?form.recoveredBalance:'0.00'}}
+          </text>
+        </text>
 			</view>
 			</view>
 		</view>
 		</view>
 		<view class="card" style="margin-top: 20rpx;height: 141rpx;">
 		<view class="card" style="margin-top: 20rpx;height: 141rpx;">
@@ -172,8 +178,9 @@
 				this.name = res.data.cname
 				this.name = res.data.cname
 				corpPointsDetail({
 				corpPointsDetail({
 					corpId: res.data.id
 					corpId: res.data.id
-				}).then(res => {
-					this.form = res.data
+				}).then(e => {
+					this.form = e.data
+          this.form.recoveredBalance = res.data.recoveredBalance
 				})
 				})
 			})
 			})
 		},
 		},
@@ -195,7 +202,7 @@
 								}
 								}
 							});
 							});
 						});
 						});
-			
+
 						updateManager.onUpdateFailed(function() {
 						updateManager.onUpdateFailed(function() {
 							// 新的版本下载失败
 							// 新的版本下载失败
 							uni.showModal({
 							uni.showModal({
@@ -318,4 +325,4 @@
 			color: #797979;
 			color: #797979;
 		}
 		}
 	}
 	}
-</style>
+</style>

+ 153 - 67
pages/tabBar/shoppingCart.vue

@@ -8,6 +8,7 @@
 						style="width: 25rpx;height: 30rpx;margin-left: 34rpx;margin-right: 2rpx;" mode="scaleToFill">
 						style="width: 25rpx;height: 30rpx;margin-left: 34rpx;margin-right: 2rpx;" mode="scaleToFill">
 						<text>{{addres.contacts}}</text>
 						<text>{{addres.contacts}}</text>
 						<text style="margin-left: 35rpx;">{{addres.tel}}</text>
 						<text style="margin-left: 35rpx;">{{addres.tel}}</text>
+          </image>
 				</view>
 				</view>
 				<view style="font-size: 26rpx;color:#989898;font-weight: 400;margin-top: 22rpx;margin-left: 61rpx;">
 				<view style="font-size: 26rpx;color:#989898;font-weight: 400;margin-top: 22rpx;margin-left: 61rpx;">
 					<text>{{addres.belongtoarea + addres.detailedAddress}}</text>
 					<text>{{addres.belongtoarea + addres.detailedAddress}}</text>
@@ -49,35 +50,55 @@
 				</view>
 				</view>
 			</u-checkbox-group>
 			</u-checkbox-group>
 		</scroll-view>
 		</scroll-view>
-		<view class="submitBar">
-			<view style="margin:20rpx 47rpx;">
-				<view v-if="!editDel"
-					style="display: flex;justify-content: space-between;align-items: flex-end;padding: 28rpx 0 28rpx 28rpx;">
-					<u-checkbox-group v-model="radiovalue" placement="column" @change="radioGroupChange" :size='15'>
-						<u-checkbox label="全选" name="全选" activeColor="#E75F37" shape="circle" labelSize="28rpx"
-							labelColor='#3B3B3B'></u-checkbox>
-					</u-checkbox-group>
-					<view style="font-size: 24rpx;">合计:<text style="color: #E75F37;">¥</text><text
-							style="font-size: 42rpx;color: #E75F37;">{{totalPrice}}</text></view>
-				</view>
-				<view style="height: 2rpx;width: 100%;background: #EEEEEE;">
-				</view>
-				<view
-					style="display: flex;justify-content:space-between;align-items: center;padding: 28rpx 0 28rpx 28rpx;">
-					<view v-if="!editDel" style="font-size: 24rpx;">
-						<view style="color:#A3A3A3">运费:<text style="color: #E75F37;">¥{{totalFreight}}</text></view>
-					</view>
-					<view style="display: flex;">
-						<view class="left-btn" v-if="!editDel" @click="submit('W01')">
-							他人代付</view>
-						<view class="right-btn" v-if="!editDel" @click="submit()">立即支付
-						</view>
-					</view>
-				</view>
-				<view style="height: 2rpx;width: 100%;background: #EEEEEE;">
-				</view>
-			</view>
-		</view>
+    <view class="submitBar">
+      <view style="margin:20rpx 47rpx;">
+        <!-- 第一行:余额支付 -->
+        <view v-if="!editDel" class="balance-row">
+          <u-checkbox-group v-model="checkRecoveredBalance" placement="row" :size='15' @change="checkRecovered">
+            <u-checkbox label="使用余额支付" name="余额支付" activeColor="#E75F37" shape="circle" :disabled="!recoveredBalance || recoveredBalance <= 0"
+                        labelSize="24rpx" labelColor='#3B3B3B'></u-checkbox>
+          </u-checkbox-group>
+          <view class="balance-info">
+            <view style="font-size: 24rpx;color: #A3A3A3">可用余额: <text style="color: #E75F37;">¥{{recoveredBalance}}</text></view>
+            <view v-if="checkRecoveredBalance.length > 0" style="font-size: 24rpx;color: #E75F37;margin-top: 5rpx;">
+              最多抵扣{{totalPrice / 2}}元
+            </view>
+          </view>
+        </view>
+
+        <!-- 第二行:全选和合计 -->
+        <view v-if="!editDel" class="top-row">
+          <view class="select-all">
+            <u-checkbox-group v-model="radiovalue" placement="column" @change="radioGroupChange" :size='15'>
+              <u-checkbox label="全选" name="全选" activeColor="#E75F37" shape="circle"
+                          labelSize="28rpx" labelColor='#3B3B3B'></u-checkbox>
+            </u-checkbox-group>
+          </view>
+          <view class="total-price">
+            <text style="font-size: 24rpx;">合计:</text>
+            <text style="color: #E75F37;">¥</text>
+            <text style="font-size: 42rpx;color: #E75F37;">{{totalPrice}}</text>
+          </view>
+        </view>
+
+        <!-- 分隔线 -->
+        <view style="height: 2rpx;width: 100%;background: #EEEEEE;"></view>
+
+        <!-- 第三行:运费和支付按钮 -->
+        <view style="display: flex;justify-content:space-between;align-items: center;padding: 28rpx 0 28rpx 28rpx;">
+          <view v-if="!editDel" style="font-size: 24rpx;">
+            <view style="color:#A3A3A3">运费:<text style="color: #E75F37;">¥{{totalFreight}}</text></view>
+          </view>
+          <view style="display: flex;">
+            <view class="left-btn" v-if="!editDel" @click="submit('W01')">他人代付</view>
+            <view class="right-btn" v-if="!editDel" @click="submit()">立即支付</view>
+          </view>
+        </view>
+
+        <!-- 分隔线 -->
+        <view style="height: 2rpx;width: 100%;background: #EEEEEE;"></view>
+      </view>
+    </view>
 	</view>
 	</view>
 </template>
 </template>
 <script>
 <script>
@@ -92,10 +113,7 @@
 		isProcurement,
 		isProcurement,
 		generateOrderShare
 		generateOrderShare
 	} from '@/api/tabBar/shoppingCart.js'
 	} from '@/api/tabBar/shoppingCart.js'
-	import {
-		registerRuntimeCompiler
-	} from "vue"
-	import {
+  import {
 		details
 		details
 	} from '@/api/views/personalInformation/index.js'
 	} from '@/api/views/personalInformation/index.js'
 	import {
 	import {
@@ -126,6 +144,8 @@
 				inventoryShow: false,
 				inventoryShow: false,
 				inventoryContent: '',
 				inventoryContent: '',
 				freight: 5,
 				freight: 5,
+        recoveredBalance: 0,
+        checkRecoveredBalance: []
 			}
 			}
 		},
 		},
 		watch: {
 		watch: {
@@ -138,7 +158,12 @@
 					}
 					}
 				}
 				}
 				this.statistics()
 				this.statistics()
-			}
+			},
+      getUserInfo(){
+        details().then(res => {
+          this.recoveredBalance = res.data.recoveredBalance
+        })
+      }
 		},
 		},
 		onShow() {
 		onShow() {
 			this.getUpdate()
 			this.getUpdate()
@@ -159,6 +184,7 @@
 			// 获取审核状态
 			// 获取审核状态
 			details().then(res => {
 			details().then(res => {
 				this.checkStatus = res.data.checkStatus
 				this.checkStatus = res.data.checkStatus
+        this.recoveredBalance = res.data.recoveredBalance
 				uni.setStorageSync('checkStatus', res.data.checkStatus);
 				uni.setStorageSync('checkStatus', res.data.checkStatus);
 				console.log(1111111)
 				console.log(1111111)
 				if (this.checkStatus != '通过') {
 				if (this.checkStatus != '通过') {
@@ -170,7 +196,7 @@
 					// uni.switchTab({
 					// uni.switchTab({
 					// 	url:'/pages/tabBar/home'
 					// 	url:'/pages/tabBar/home'
 					// })
 					// })
-					// return 
+					// return
 				}
 				}
 			})
 			})
 
 
@@ -253,7 +279,7 @@
 								}
 								}
 							});
 							});
 						});
 						});
-			
+
 						updateManager.onUpdateFailed(function() {
 						updateManager.onUpdateFailed(function() {
 							// 新的版本下载失败
 							// 新的版本下载失败
 							uni.showModal({
 							uni.showModal({
@@ -450,14 +476,13 @@
 				if (this.companyValue.length > 0) {
 				if (this.companyValue.length > 0) {
 					let data = []
 					let data = []
 					for (let item of this.companyValue) {
 					for (let item of this.companyValue) {
-						for (let ite of this.dataList) {
-							if (item == ite.name) {
-								data.push({
-									name: item,
-									list: ite.list
-								})
-							}
-						}
+            let ite = this.dataList.find(e => e.name === item)
+            if (ite) {
+              data.push({
+                name: item,
+                list: ite.list
+              })
+            }
 					}
 					}
 					uni.showLoading({
 					uni.showLoading({
 						title: '加载中',
 						title: '加载中',
@@ -465,7 +490,15 @@
 					});
 					});
 					// 判断是否用额度支付
 					// 判断是否用额度支付
 					const personRef = await details()
 					const personRef = await details()
-					const totalPrice = Number(this.totalPrice) + Number(this.totalFreight)
+          let latest = Number(personRef.data.recoveredBalance)
+          let realRecoveredBalanceAmount = 0.0
+          let useRecoveredBalance = false
+          if (this.checkRecoveredBalance.length > 0) {
+            let half = Number(this.totalPrice) / 2
+            realRecoveredBalanceAmount = latest > half ? half : latest
+            useRecoveredBalance = true
+          }
+					const totalPrice = Number(this.totalPrice) + Number(this.totalFreight) - Number(realRecoveredBalanceAmount)
 					// 是否开通额度
 					// 是否开通额度
 					getParamservice(1, 10, {
 					getParamservice(1, 10, {
 						paramKey: 'WeChat.shipping.notification'
 						paramKey: 'WeChat.shipping.notification'
@@ -694,15 +727,15 @@
 				if (this.companyValue.length > 0) {
 				if (this.companyValue.length > 0) {
 					let data = []
 					let data = []
 					for (let item of this.companyValue) {
 					for (let item of this.companyValue) {
-						for (let ite of this.dataList) {
-							if (item == ite.name) {
-								data = data.concat(ite.list)
-							}
-						}
+            let ite = this.dataList.find(e => e.name === item)
+            if (ite) {
+              data = data.concat(ite.list)
+            }
 					}
 					}
 					let obj = {
 					let obj = {
 						address: this.addres.belongtoarea + this.addres.detailedAddress,
 						address: this.addres.belongtoarea + this.addres.detailedAddress,
 						shoppingCartList: data,
 						shoppingCartList: data,
+            useRecoveredBalance: this.checkRecoveredBalance.length > 0
 					}
 					}
 					uni.showLoading({
 					uni.showLoading({
 						title: '加载中',
 						title: '加载中',
@@ -845,20 +878,10 @@
 				this.inventoryfun(this.dataList)
 				this.inventoryfun(this.dataList)
 				this.statistics()
 				this.statistics()
 			},
 			},
-			radioGroupChange(e) {
-				this.radiovalue = e
-				if (e.length == 0) {
-					this.companyValue = []
-				} else {
-					for (let li of this.dataList) {
-						if (!this.companyValue.includes(li.name)) {
-							this.companyValue.push(li.name)
-						}
-					}
-				}
-				this.inventoryfun(this.dataList)
-				this.statistics()
-			},
+      checkRecovered(e){
+        console.info('e---------', e)
+        this.checkRecoveredBalance = e
+      },
 			statistics(val, index, ind) {
 			statistics(val, index, ind) {
 				console.log(val, index, ind)
 				console.log(val, index, ind)
 				if (val) {
 				if (val) {
@@ -939,7 +962,70 @@
 		}
 		}
 	}
 	}
 
 
-	.submitBar {
+  .submitBar {
+    position: fixed;
+    bottom: 0;
+    background-color: #fff;
+    width: 100%;
+    z-index: 10;
+
+    .balance-row {
+      display: flex;
+      justify-content: space-between;
+      align-items: flex-start; /* 改为flex-start使内容顶部对齐 */
+      padding: 15rpx 0 20rpx 0;
+
+      .balance-info {
+        text-align: right;
+        display: flex;
+        flex-direction: column;
+      }
+    }
+
+    .top-row {
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+      padding: 10rpx 0;
+
+      .select-all {
+        flex: 1;
+      }
+
+      .total-price {
+        flex: 1;
+        text-align: right;
+      }
+    }
+
+    .left-btn {
+      background-color: #FFEEE9;
+      color: #E75F37;
+      font-size: 26rpx;
+      width: 160rpx;
+      height: 65rpx;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+      border-top-left-radius: 33rpx;
+      border-bottom-left-radius: 33rpx;
+    }
+
+    .right-btn {
+      background-color: #E75F37;
+      color: #fff;
+      font-size: 26rpx;
+      width: 160rpx;
+      height: 65rpx;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+      border-top-right-radius: 33rpx;
+      border-bottom-right-radius: 33rpx;
+    }
+  }
+
+/*	.submitBar {
 		position: fixed;
 		position: fixed;
 		bottom: 0;
 		bottom: 0;
 		background-color: #fff;
 		background-color: #fff;
@@ -975,5 +1061,5 @@
 			border-top-right-radius: 33rpx;
 			border-top-right-radius: 33rpx;
 			border-bottom-right-radius: 33rpx;
 			border-bottom-right-radius: 33rpx;
 		}
 		}
-	}
-</style>
+	}*/
+</style>