Browse Source

购物车页面下单功能优化

LXT-NJ\Admin 1 year ago
parent
commit
3e4370b4a6
1 changed files with 26 additions and 20 deletions
  1. 26 20
      pages/gouwuche/index.vue

+ 26 - 20
pages/gouwuche/index.vue

@@ -1,9 +1,9 @@
 <template>
 	<view :style="{ minHeight: sys.windowHeight + 'px' }" :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
-		<tm-menubars title="消息列表" :shadow="0" :showback="true"></tm-menubars>
+		<tm-menubars title="购物车列表" :shadow="0" :showback="true"></tm-menubars>
 		<view class="zhuti shangpin" v-if="test.length>0">
-			<tm-sheet :padding="[0, 0]" class="jiaoxi xiao" >
-				<view v-for="item in test" >
+			<tm-sheet :padding="[0, 0]" class="jiaoxi xiao">
+				<view v-for="item in test">
 					<tm-checkbox @change="choose" style="float: left;padding:2px !important;margin-top:9%;"
 						v-model="item.checked" label=""></tm-checkbox>
 					<tm-cartCellListFood @change="shuliangjia(item)" class="shuliang" :typeclick="typeclick"
@@ -60,12 +60,12 @@
 					data: {}
 				}).then(res => {
 					if (res.data.code == 200) {
-						console.log(res.data.data,'33');
+						console.log(res.data.data, '33');
 						that.$refs.toast.show({
 							model: 'success',
 							label: res.data.msg
 						})
-						// this.getList()
+						this.getList()
 					} else {
 						that.$refs.toast.show({
 							model: 'error',
@@ -77,29 +77,37 @@
 			goPay() {
 				var that = this,
 					data = this.test,
-					goods = [];
+					goods = [],
+					gw_id = [];
 				for (let i = 0; i < data.length; i++) {
 					if (data[i].checked) {
-						goods.push(data[i])
-						console.log(data, goods, '数据');
+						console.log(that.zongjia, 'ss');
+						goods.push(
+							{
+								order_remark: '',
+								order_money:data[i].buy*data[i].price,
+								pay_money:data[i].buy*data[i].price,
+								buy_num: data[i].buy,
+								goods_id: data[i].goods_id,
+							}
+						)
+						gw_id.push(data[i].id)
+						console.log(goods, gw_id, '下单数据');
 					}
 				}
 				if (goods.length == 0) {
 					that.$refs.toast.show({
-						model: 'success',
+						model: 'warn',
 						label: '请选择商品'
 					})
 					return
-				} else if (goods.length == 1) {
+				} else {
 					myRequest({
 						url: "/api/Order/addOrder",
 						method: 'post',
 						data: {
-							order_remark: '',
-							order_money: that.zongjia,
-							pay_money: that.zongjia,
-							buy_num: goods[0].buy,
-							goods_id: goods[0].goods_id
+							gw_id: gw_id,
+							good: goods
 						}
 					}).then(res => {
 						if (res.data.code == 200) {
@@ -107,7 +115,7 @@
 								model: 'success',
 								label: res.data.msg
 							})
-							this.shanchu()
+							this.getList()
 						} else {
 							that.$refs.toast.show({
 								model: 'error',
@@ -115,8 +123,6 @@
 							})
 						}
 					})
-				} else {
-					console.log('不止一个');
 				}
 			},
 			shanchu() {
@@ -132,7 +138,7 @@
 				console.log(data, '数据');
 				if (ids.length == 0) {
 					that.$refs.toast.show({
-						model: 'success',
+						model: 'warn',
 						label: '请选择商品'
 					})
 					return
@@ -196,7 +202,7 @@
 								buy: res.data.data[i].goods_num,
 								itemId: res.data.data[i].id,
 								checked: false,
-								goods_id:res.data.data[i].goods_id
+								goods_id: res.data.data[i].goods_id
 							};
 							that.test.push(obj)
 						}