liujiaxin2000 2 tygodni temu
rodzic
commit
ec4703ceda
1 zmienionych plików z 27 dodań i 13 usunięć
  1. 27 13
      pages_shopping/live/confirmCreateOrder.vue

+ 27 - 13
pages_shopping/live/confirmCreateOrder.vue

@@ -38,7 +38,8 @@
 					</view>
 					<view class="right" style="align-items: baseline;">
 						<text class="price-info-unit">¥</text>
-						<text class="price-info-num">{{(orderData.totalPrice||0).toFixed(2)}}</text>
+						<text class="price-info-num">{{(safeOrderData.totalPrice||0).toFixed(2)}}</text>
+						<!-- <text class="price-info-num">{{(orderData.totalPrice||0).toFixed(2)}}</text> -->
 					</view>
 				</view>
 				<view class="points" @click="couponVisible = true;">
@@ -64,7 +65,8 @@
 
 				<!-- 备注 -->
 				<view class="remarks">
-					<input type="text" v-model="orderData.remark" placeholder="备注留言(选填)" placeholder-class="input" />
+					<input type="text" v-model="safeOrderData.remark" placeholder="备注留言(选填)"
+						placeholder-class="input" />
 				</view>
 
 
@@ -155,7 +157,8 @@
 		data() {
 			return {
 				orderData: {
-					totalPrice: null
+					totalPrice: null,
+					remark: ''
 				},
 				cityId: null,
 				address: null,
@@ -177,7 +180,7 @@
 				type: '',
 				isFirstLoad: true,
 				recordId: '',
-				productValueSelect:''
+				productValueSelect: ''
 			}
 		},
 
@@ -191,11 +194,21 @@
 			this.type = options.type;
 			this.isFirstLoad = true;
 			this.recordId = options.recordId || '';
-            this.productValueSelect=options.productValueSelect||''
+			this.productValueSelect = options.productValueSelect || ''
 			if (options.type == 'win') {
 				this.getKey()
 			}
 		},
+		computed: {
+			safeOrderData() {
+				return this.orderData || {
+					totalPrice: 0,
+					payPrice: 0,
+					payDelivery: 0,
+					remark: ''
+				};
+			}
+		},
 		onShow() {
 			this.openCoupon()
 			if (this.type == 'win') {
@@ -203,7 +216,7 @@
 			} else {
 				this.computedOrder()
 			}
-			if(!this.cityId){
+			if (!this.cityId) {
 				this.getUserAddr()
 			}
 			// this.getUserAddr()
@@ -287,7 +300,7 @@
 					productId: this.productId,
 					orderKey: this.orderKey,
 					couponUserId: this.couponUserId || '',
-					attrValueId:this.productValueSelect
+					attrValueId: this.productValueSelect
 				}
 
 				computed(data).then(res => {
@@ -311,7 +324,7 @@
 					productId: this.productId,
 					orderKey: this.orderKey,
 					totalNum: 1,
-					remark:this.orderData.remark
+					remark: this.orderData.remark || ''
 				}
 				computedReward(data).then(res => {
 						if (res.code == 200) {
@@ -337,14 +350,15 @@
 					liveId: this.liveId,
 					orderKey: this.orderKey,
 					userName: this.address.realName,
-					remark:this.orderData.remark||'',
+					 remark: (this.orderData && this.orderData.remark) || '', // 安全访问
 					userPhone: this.address.phone,
-					userAddress: this.address.province + ' ' + this.address.city + ' ' + this.address.district + ' ' +this.address.detail,
+					userAddress: this.address.province + ' ' + this.address.city + ' ' + this.address.district + ' ' +
+						this.address.detail,
 					cartId: "5",
 					productId: this.productId,
 					totalNum: this.totalNum,
 					couponUserId: this.couponUserId,
-					attrValueId:this.productValueSelect
+					attrValueId: this.productValueSelect
 
 				}
 
@@ -372,7 +386,7 @@
 					userAddress: this.address.province + ' ' + this.address.city + ' ' + this.address.district + ' ' +
 						this.address.detail,
 					cartId: "5",
-					remark:this.orderData.remark||'',
+					remark: this.orderData.remark || '',
 					productId: this.productId,
 					totalNum: 1,
 					couponUserId: this.couponUserId,
@@ -477,7 +491,7 @@
 					}
 					console.log("orderList>>", orderList)
 					const orderListStr = encodeURIComponent(JSON.stringify(orderList));
-					uni.navigateTo({
+					uni.redirectTo({
 						url: `/pages_shopping/live/paymentOrder?orderList=${orderListStr}&couponUserId=${this.couponUserId}&type=${this.type}`
 					});
 				} catch (error) {