Browse Source

生成订单和订单列表

LXT-NJ\Admin 2 years ago
parent
commit
8ed73a393a

+ 66 - 5
pages/dingdan/index.vue

@@ -2,7 +2,7 @@
 	<view :style="{ minHeight: sys.windowHeight + 'px' }"
 		:class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
 		<tm-menubars title="我的订单" :shadow="0" :showback="true"></tm-menubars>
-		<tm-tabs align="center" class="qiehuan1" v-model="activeIndex" :list="list2" range-key="title"></tm-tabs>
+		<tm-tabs align="center" class="qiehuan1" v-model="activeIndex" :list="list2" range-key="title" @change="changeTab"></tm-tabs>
 		<div class="zhuti shangpin">
 			<tm-sheet class="jiaoxi" style="" v-for="item in test">
 				<tm-cartCellListFood class="shuliang" :typeclick="typeclick" :mdata="item" :cart-num.sync="item.buy"></tm-cartCellListFood>
@@ -17,9 +17,10 @@ import{myRequest} from '@/api/request.js'
 export default {
 	data() {
 		return {
-			list2:[ '全部','待付款','待收货','已完成','售后'],
+			list2:[ '全部','待付款','已付款','已完成','待收货'],
 			activeIndex:0,
-			test: [{
+			test: [
+				{
 				img: '../../static/img/83.png',
 				title: '丝缎质感纹理风衣',
 				label: '黑色 - 6518/320',
@@ -29,6 +30,7 @@ export default {
 				buy: 0,
 				itemId: 0,
 				checked:false,
+				status:0
 			},{
 				img: '../../static/img/84.png',
 				title: '产品3(任选)',
@@ -38,7 +40,8 @@ export default {
 				id: 3,
 				buy: 0,
 				itemId: 0,
-				checked:false
+				checked:false,
+				status:0
 			}],
 			typeclick:4,//1加入购物车,2购物车
 		};
@@ -47,10 +50,68 @@ export default {
 		
 	},
 	created() {
+		if(!uni.getStorageSync("token")){
+			uni.navigateTo({
+				url: "/pages/login/index",
+			})
+		}
 		this.sys = uni.getSystemInfoSync();
+		this.getOrderList(-1);
 	},
 	methods: {
-		
+		// 切换tab
+		changeTab(e){
+			this.activeIndex=e;
+			let sel=0;
+			if(e==0){
+				sel=-1;
+			}else if(e==1){
+				sel=0;
+			}else if(e==2){
+				sel=1;
+			}else if(e==3){
+				sel=2;
+			}else if(e==4){
+				sel=-2;
+			}
+			this.getOrderList(sel)	
+		},
+		// 获取订单列表
+		getOrderList(index){
+			let that=this;
+			myRequest({
+				url:'/api/Order/orderList',
+				method:'post',
+				data:{type:index}
+			}).then(res=>{
+				if(res.data.code==200){
+					if (res.data.code == 200) {
+						if (res.data.data.length != 0) {
+							that.test = [];
+							for (let i = 0; i < res.data.data.length; i++) {
+								var obj = {
+									img: res.data.data[i].goods_image,
+									title: res.data.data[i].goods_name,
+									// label: '黑色 - 6518/320',
+									// size:'S',
+									price: res.data.data[i].pay_money,
+									id: res.data.data[i].id,
+									buy: res.data.data[i].goods_num,
+									itemId: res.data.data[i].id,
+									checked: false,
+									goods_id:res.data.data[i].goods_id,
+									orderStatus:res.data.data[i].order_status
+								};
+								that.test.push(obj)
+							}
+						}else {
+						that.test = [];
+						}
+					} 
+					console.log(res.data.data,'33');
+				}
+			})
+		}
 	},
 }
 </script>

+ 229 - 109
pages/gouwuche/index.vue

@@ -1,140 +1,260 @@
 <template>
-	<view :style="{ minHeight: sys.windowHeight + 'px' }"
-		:class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
+	<view :style="{ minHeight: sys.windowHeight + 'px' }" :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
 		<tm-menubars title="消息列表" :shadow="0" :showback="true"></tm-menubars>
 		<view class="zhuti shangpin">
 			<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" :mdata="item" :cart-num.sync="item.buy"></tm-cartCellListFood>
+					<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"
+						:mdata="item" :cart-num.sync="item.buy"></tm-cartCellListFood>
 				</view>
 			</tm-sheet>
 		</view>
 		<view class="dibu">
-			
-			<tm-listitem class="liebiao" value="免费" :round="24" :shadow="12" title="邮费" :show-right-icon="false"></tm-listitem>
-			<tm-listitem class="liebiao jiageList" :value="'¥'+zongjia" :round="24" :shadow="12" title="价格" :show-right-icon="false"></tm-listitem>
+
+			<tm-listitem class="liebiao" value="免费" :round="24" :shadow="12" title="邮费" :show-right-icon="false">
+			</tm-listitem>
+			<tm-listitem class="liebiao jiageList" :value="'¥'+zongjia" :round="24" :shadow="12" title="价格"
+				:show-right-icon="false"></tm-listitem>
 			<view class="text-align-center">
 				<tm-button theme="red" @click="shanchu" :round="24" class="mt-50 logincla">删除</tm-button>
-				<tm-button theme="primary" :round="24" class="mt-50 logincla">立即付款</tm-button>
+				<tm-button theme="primary" :round="24" class="mt-50 logincla" @click="goPay">立即付款</tm-button>
 			</view>
 		</view>
 		<!-- 弹出层消息 -->
 		<tm-message ref="toast"></tm-message>
 	</view>
-</template>	
+</template>
 <script>
-import{myRequest} from '@/api/request.js'
-export default {
-	data() {
-		return {
-			zongjia:0,
-			test: [],
-			typeclick:2,//1加入购物车,2购物车
-		};
-	},
-	onLoad() {
-		
-	},
-	created() {
-		this.sys = uni.getSystemInfoSync();
-		this.getList()
-	},
-	methods: {
-		shanchu(){
-			var that=this,data=this.test,ids=[];
-			for(let i=0;i<data.length;i++){
-				if(data[i].checked){
-					ids.push(data[i].id)
-				}
-			}
-			if(ids.length==0){
-				that.$refs.toast.show({model:'success',label:'请选择商品'})
-				return
-			}
-			myRequest({
-				url: "/api/ShopCart/deleteOneGoods",
-				method:'post',
-				data:{id:ids}
-			}).then(res => {
-				if (res.data.code == 200) {
-					this.getList()
-					that.$refs.toast.show({model:'success',label:res.data.msg})
-				}else{
-					that.$refs.toast.show({model:'error',label:res.data.msg})
-				}
-			})
+	import {
+		myRequest
+	} from '@/api/request.js'
+	export default {
+		data() {
+			return {
+				zongjia: 0,
+				test: [],
+				typeclick: 2, //1加入购物车,2购物车
+			};
 		},
-		shuliangjia(num){
-			this.jiage();
+		onLoad() {
+
 		},
-		choose(){
-			this.jiage()
+		created() {
+			this.sys = uni.getSystemInfoSync();
+			this.getList()
 		},
-		jiage(){
-			var data=this.test,jiage=0;
-			for(let i=0;i<data.length;i++){
-				if(data[i].checked){
-					var danjia=JSON.parse(data[i].price);
-					var shuliang=data[i].buy;
-					jiage=jiage+(danjia*shuliang);
+		methods: {
+			goPay() {
+				var that = this,
+					data = this.test,
+					goods = [];
+				for (let i = 0; i < data.length; i++) {
+					if (data[i].checked) {
+						goods.push(data[i])
+						console.log(data, goods, '数据');
+					}
 				}
-			}
-			this.zongjia=jiage;
-		},
-		getList(){
-			var that=this;
-			myRequest({
-				url: "/api/ShopCart/shopCartList",
-				method:'post',
-				data:{}
-			}).then(res => {
-				if (res.data.code == 200) {
-					if(res.data.data.length != 0){
-						that.test=[];
-						for(let i=0;i<res.data.data.length;i++){
-							var obj={
-								img: res.data.data[i].goods_image,
-								title: res.data.data[i].goods_name,
-								// label: '黑色 - 6518/320',
-								// size:'S',
-								price: res.data.data[i].goods_price,
-								id: res.data.data[i].id,
-								buy: res.data.data[i].goods_num,
-								itemId: res.data.data[i].id,
-								checked:false,
-							};
-							that.test.push(obj)
+				if (goods.length == 0) {
+					that.$refs.toast.show({
+						model: 'success',
+						label: '请选择商品'
+					})
+					return
+				} else if (goods.length == 1) {
+					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
 						}
-						that.jiage()
+					}).then(res => {
+						if (res.data.code == 200) {
+							that.$refs.toast.show({
+								model: 'success',
+								label: res.data.msg
+							})
+						} else {
+							that.$refs.toast.show({
+								model: 'error',
+								label: res.data.msg
+							})
+						}
+					})
+				} else {
+					console.log('不止一个');
+				}
+			},
+			shanchu() {
+				var that = this,
+					data = this.test,
+					ids = [];
+				for (let i = 0; i < data.length; i++) {
+					if (data[i].checked) {
+						ids.push(data[i].id)
+						console.log(ids);
+					}
+				}
+				console.log(data, '数据');
+				if (ids.length == 0) {
+					that.$refs.toast.show({
+						model: 'success',
+						label: '请选择商品'
+					})
+					return
+				}
+				myRequest({
+					url: "/api/ShopCart/deleteOneGoods",
+					method: 'post',
+					data: {
+						id: ids
+					}
+				}).then(res => {
+					if (res.data.code == 200) {
+						this.getList()
+						that.$refs.toast.show({
+							model: 'success',
+							label: res.data.msg
+						})
+					} else {
+						that.$refs.toast.show({
+							model: 'error',
+							label: res.data.msg
+						})
+					}
+				})
+			},
+			shuliangjia(num) {
+				this.jiage();
+			},
+			choose() {
+				this.jiage()
+			},
+			jiage() {
+				var data = this.test,
+					jiage = 0;
+				for (let i = 0; i < data.length; i++) {
+					if (data[i].checked) {
+						var danjia = JSON.parse(data[i].price);
+						var shuliang = data[i].buy;
+						jiage = jiage + (danjia * shuliang);
 					}
-				}else{
-					that.test=[];
 				}
-			})
+				this.zongjia = jiage;
+			},
+			getList() {
+				var that = this;
+				myRequest({
+					url: "/api/ShopCart/shopCartList",
+					method: 'post',
+					data: {}
+				}).then(res => {
+					if (res.data.code == 200) {
+						if (res.data.data.length != 0) {
+							that.test = [];
+							for (let i = 0; i < res.data.data.length; i++) {
+								var obj = {
+									img: res.data.data[i].goods_image,
+									title: res.data.data[i].goods_name,
+									// label: '黑色 - 6518/320',
+									// size:'S',
+									price: res.data.data[i].goods_price,
+									id: res.data.data[i].id,
+									buy: res.data.data[i].goods_num,
+									itemId: res.data.data[i].id,
+									checked: false,
+									goods_id:res.data.data[i].goods_id
+								};
+								that.test.push(obj)
+							}
+							that.jiage()
+						}
+					} else {
+						that.test = [];
+					}
+				})
+			},
 		},
-	},
-}
+	}
 </script>
 
 <style lang="scss">
-	/deep/ .tm-menubars .body{
+	/deep/ .tm-menubars .body {
 		background-color: #1b1b1b !important;
 	}
-	/deep/ .jiaoxi{margin:0 !important;padding: 8px !important;margin-bottom: 200px !important;}
-	/deep/ .shangpin .white.bk{background-color:#1b1b1b!important;}
-	/deep/ .shangpin .tm-cartCellListFood{    padding: 0px 0px 15px 0px !important;
-	margin-top: 5px !important;margin-bottom: 20px !important;
-	border-bottom: 1px solid #303030;}
-	/deep/ .shangpin .border-t-1.bk{border-top:1px solid #1b1b1b!important;}
-	/deep/ .shangpin .title{color: white !important;}
-	/deep/ .shangpin .text-red{color: white !important;}
-	/deep/ .shangpin .round-3{width:90px !important;height:90px !important;}
-	/deep/ .shangpin .tm-cartCellListFood-img{width:90px !important;height:90px !important;}
-	/deep/ .shuliang .text-size-n{color: white !important;}
-	.dibu{background: #0D0D0D;position: fixed;bottom:0px;width: 100%;}
-	/deep/ .liebiao .grey-darken-4.bk{background: #0D0D0D !important;padding: 0px;margin: 0px;
-	width: 100%;border-radius: 0px !important;}
-	.logincla{width: 40%;margin:0 auto;margin-top:20px;margin-bottom:30px;}
-	/deep/ .jiageList .d-inline-block{font-size: 18px !important;color: white !important;}
+
+	/deep/ .jiaoxi {
+		margin: 0 !important;
+		padding: 8px !important;
+		margin-bottom: 200px !important;
+	}
+
+	/deep/ .shangpin .white.bk {
+		background-color: #1b1b1b !important;
+	}
+
+	/deep/ .shangpin .tm-cartCellListFood {
+		padding: 0px 0px 15px 0px !important;
+		margin-top: 5px !important;
+		margin-bottom: 20px !important;
+		border-bottom: 1px solid #303030;
+	}
+
+	/deep/ .shangpin .border-t-1.bk {
+		border-top: 1px solid #1b1b1b !important;
+	}
+
+	/deep/ .shangpin .title {
+		color: white !important;
+	}
+
+	/deep/ .shangpin .text-red {
+		color: white !important;
+	}
+
+	/deep/ .shangpin .round-3 {
+		width: 90px !important;
+		height: 90px !important;
+	}
+
+	/deep/ .shangpin .tm-cartCellListFood-img {
+		width: 90px !important;
+		height: 90px !important;
+	}
+
+	/deep/ .shuliang .text-size-n {
+		color: white !important;
+	}
+
+	.dibu {
+		background: #0D0D0D;
+		position: fixed;
+		bottom: 0px;
+		width: 100%;
+	}
+
+	/deep/ .liebiao .grey-darken-4.bk {
+		background: #0D0D0D !important;
+		padding: 0px;
+		margin: 0px;
+		width: 100%;
+		border-radius: 0px !important;
+	}
+
+	.logincla {
+		width: 40%;
+		margin: 0 auto;
+		margin-top: 20px;
+		margin-bottom: 30px;
+	}
+
+	/deep/ .jiageList .d-inline-block {
+		font-size: 18px !important;
+		color: white !important;
+	}
 </style>

+ 22 - 1
pages/pingjia/index.vue

@@ -25,7 +25,7 @@
 					<view class="mt-30">
 						<tm-upload :tips="false" :filelist.sync="filelist"></tm-upload>
 					</view>
-					<tm-button :round="24" class="sao" block>提交</tm-button>
+					<tm-button :round="24" class="sao" block @click="submit">提交</tm-button>
 				</view>
 			</tm-sheet>
 			
@@ -60,6 +60,7 @@ export default {
 	},
 	onLoad() {
 		
+		
 	},
 	created() {
 		this.sys = uni.getSystemInfoSync();
@@ -80,6 +81,26 @@ export default {
 				this.checked3=true;
 			}
 		},
+		// 提交评价
+		submit(){
+			console.log('11');
+			myRequest({
+				url:'/api/Order/orderEvaluate',
+				method:'post',
+				data:{
+				experience_value:''	,
+				delivery_value:'',
+				service_value:'',
+				atlas:'',
+				content:''
+				}
+			}).then(res=>{
+				if(res.data.code==200){
+					console.log(res.data.data,'pingjia1!!');
+				}
+			})
+			
+		}
 	},
 }
 </script>

+ 13 - 3
tm-vuetify/components/tm-cartCellListFood/tm-cartCellListFood.vue

@@ -58,8 +58,17 @@
 						<view class="qiangwang">前往商城购买</view>
 					</view>
 					<view class="flex" v-if="typeclick==4">
-						<view class="fukuan mr-10">去付款</view>
-						<view class="fukuan">去付款</view>
+						<view class="" v-if="mdata[keyMap['orderStatus']]==0">
+							<view class="fukuan">去付款</view>
+						</view>
+						<view class="flex" v-if="mdata[keyMap['orderStatus']]==1 ||mdata[keyMap['orderStatus']]==2">
+							<view class="fukuan mr-10">再次购买</view>
+							<view class="fukuan" >{{mdata[keyMap['orderStatus']]==1?'确认收货':'去评价'}}</view>
+						</view>
+							<view class="flex" v-if="mdata[keyMap['orderStatus']]==-2">
+								<view class="fukuan mr-10">再次购买</view>
+								<view class="fukuan" >确认收货</view>
+							</view>
 					</view>
 					<view style="position: absolute;right: 20px;" v-if="typeclick==5">
 						<view class="genghuan mr-10">取出</view>
@@ -127,6 +136,7 @@
 						unit:'unit',
 						buy:'buy',
 						size:'size',
+						orderStatus:'orderStatus'
 					}
 				}
 			},
@@ -168,7 +178,7 @@
 			typeclick:{
 				type:Number,
 				default:0
-			},
+			}
 		},
 		watch:{
 			'mdata.buy':function(val){