Ver código fonte

对接 详情

chenxiong 3 anos atrás
pai
commit
8156b630ed
2 arquivos alterados com 207 adições e 60 exclusões
  1. 29 0
      common/httpList/goods.js
  2. 178 60
      pages2/bank/detail.vue

+ 29 - 0
common/httpList/goods.js

@@ -24,6 +24,35 @@ export default {
 			noToken: true
 		})
 	},
+	
+	goodsBankList(data) {
+		return myRequest({
+			url: '/app/common/bank/list',
+			method: 'get',
+			data:data,
+			noToken: true
+		})
+	},
+	
+	goodsChapterList(data) {
+		return myRequest({
+			url: '/app/common/bank/chapter/list',
+			method: 'get',
+			data:data,
+			noToken: true
+		})
+	},
+	goodsExamList(data) {
+		return myRequest({
+			url: '/app/common/bank/exam/list',
+			method: 'get',
+			data:data,
+			noToken: true
+		})
+	},
+	
+	
+
 	addCart(data) {
 		return myRequest({
 			url: '/base/cart',

+ 178 - 60
pages2/bank/detail.vue

@@ -31,44 +31,59 @@
 		</view>
 		<view class="title-list"  v-if="current == 1">
 			<view class="content">
-				<view class="list" v-for="(item1,index) in outline">
-					<view class="module">
-						.2Z106000 施工合同管理-模块标题
-					</view>
-					<view class="section" :data-index="index" @click="changeItem" :class="{up:!item1.showList}">
-						2Z106010 施工承发包的模式-2Z106020 施工合同...
-					</view>
-					<view class="article" v-if="item1.showList" :class="{active:index1 == 0}" v-for="(article,index1) in item1.list">
-						施工承发包模式-施工合同与物资采购合同二
-						<navigator url="/pages2/bank/questionBankTest">
-							<view v-if="index1 == 0" class="btn">试做</view>
-						</navigator>
+				<view class="list" v-for="(item1,index1) in bankList">
+					<template v-if="item1.type==3">
+						<view class="module" @click="clickModule" :data-id="item1.id" :data-index="index1">
+							{{item1.name}} {{item1.subjectName}}
+						</view>
 						
-					</view>
-				</view>
-				
-				<view class="list">
-					<view class="section" :data-index="index" @click="changeItem">
-						2Z106010 施工承发包的模式-2Z106020 施工合同...
-					</view>
-					<view class="article" :class="{active:index1 == 0}" v-for="(article,index1) in 3">
-						施工承发包模式-施工合同与物资采购合同二
-						<navigator url="/pages2/bank/questionBankTest">
-							<view v-if="index1 == 0" class="btn">试做</view>
-						</navigator>
+						<template v-if="item1.showList">
+							<view class="section" v-for="(item2,index2) in item1.list" @click="changeItem" :data-index1="index1" :data-index2="index2" :data-id="item2.id" :data-type="item1.type">
+								<u-icon name="arrow-down" v-if="item2.showList"></u-icon>
+								<u-icon name="arrow-up" v-if="!item2.showList"></u-icon>
+								{{item2.name}}
+							</view>
+							<view v-if="item2.showList" >
+								<view class="article" v-for="(article,index1) in item2.list">
+									<view class="flex">{{article.name}}</view>
+									<navigator url="/pages2/bank/questionBankTest?id="+article.id+"">
+										<view v-if="index1 == 0" class="btn">试做</view>
+									</navigator>
+								</view>
+							</view>
+						</template>
 						
-					</view>
-				</view>
-				
-				<view class="list">
-					<view class="article" :class="{active:index1 == 0}" v-for="(article,index1) in 3">
-						施工承发包模式-施工合同与物资采购合同二
-						<navigator url="/pages2/bank/questionBankTest">
-							<view v-if="index1 == 0" class="btn">试做</view>
-						</navigator>
 						
-					</view>
+					</template>
+					
+					<template v-if="item1.type ==2">
+						<view class="section" :data-index1="index1" @click="changeItem" :data-type="item1.type">
+							<u-icon name="arrow-down" v-if="item1.showList"></u-icon>
+							<u-icon name="arrow-up" v-if="!item1.showList"></u-icon>
+							2Z106010 施工承发包的模式-2Z106020 施工合同...
+						</view>
+						<view v-if="item1.showList" >
+							<view class="article" :class="{active:index1 == 0}" v-for="(article,index1) in item1.list">
+								施工承发包模式-施工合同与物资采购合同二
+								<navigator url="/pages2/bank/questionBankTest">
+									<view v-if="index1 == 0" class="btn">试做</view>
+								</navigator>
+								
+							</view>
+						</view>
+					</template>
+					
+					<template v-if="item1.type ==1">
+						<view class="article" :class="{active:index1 == 0}" v-for="(article,index1) in 3">
+							施工承发包模式-施工合同与物资采购合同二
+							<navigator url="/pages2/bank/questionBankTest">
+								<view v-if="index1 == 0" class="btn">试做</view>
+							</navigator>
+							
+						</view>
+					</template>
 				</view>
+				
 			</view>
 		</view>
 		<view class="bottomBox">
@@ -95,12 +110,9 @@ export default {
 				}
 			],
 			current:0,
-			outline:[{
-				list:[1,2,3,4],
-				showList:false,
-			}],
 			id:'',
-			goodsData:{}
+			goodsData:{},
+			bankList:[]
 		};
 	},
 	filters: {
@@ -119,6 +131,7 @@ export default {
 		console.log(option)
 		this.id = option.id
 		this.getDetail();
+		this.goodsBankList()
 	},
 	onShow() {
 		
@@ -131,8 +144,57 @@ export default {
 				 
 			})
 		},
-		getModule() {
+		goodsBankList() {
+			this.$api.goodsBankList({
+				goodsId:this.id
+			}).then(res => {
+				console.log(res)
+				this.bankList = res.data.data;
+				res.data.data.forEach(bank => {
+					// if(bank.type == 3) {
+					// 	this.goodsChapterList(bank,bank.id)
+					// }
+					
+				})
+				
+				
+			})
+		},
+		goodsChapterList(bank,id) {
+			this.$api.goodsChapterList({
+				moduleExamId:id
+			}).then(res => {
+				this.$set(bank,'list',[{
+					name:'章卷',
+					showList:false,
+					id:1
+				}])
+				 
+			})
+		},
+		clickModule(e) {
+			
+			let index = e.currentTarget.dataset.index;
+			let id = e.currentTarget.dataset.id;
 			
+			console.log(this.bankList)
+			
+			if(this.bankList[index].list) {
+				this.$set(this.bankList[index],'showList',!this.bankList[index].showList)
+				return;
+			}
+			
+			this.$api.goodsChapterList({
+				moduleExamId:id
+			}).then(res => {
+				this.$set(this.bankList[index],'showList',true)
+				this.$set(this.bankList[index],'list',[{
+					name:'章卷',
+					showList:false,
+					id:1
+				}])
+				 
+			})
 		},
 		buy(){
 			if(this.$method.isGoLogin()){
@@ -144,9 +206,17 @@ export default {
 			if(this.$method.isGoLogin()){
 				return
 			}
-			uni.showToast({
-			    title: '添加成功',
-			    duration: 1000
+			
+			let self = this
+			this.$api.addCart({goodsId:this.id}).then(res => {
+				if(res.data.code==200){
+					uni.setStorageSync('updateCart',1) //提醒刷新购物车
+					uni.showToast({
+					    title: '添加成功'
+					});
+				}else{
+					this.$u.toast(res.data.msg);
+				}
 			});
 			
 		},
@@ -157,12 +227,67 @@ export default {
 			this.current = index;
 		},
 		changeItem(e) {
-			let index = e.currentTarget.dataset.index
-			this.outline.forEach((arrItem,i) => {
-				if(i == index) {
-					arrItem.showList = !arrItem.showList
+			
+			
+			let index1 = e.currentTarget.dataset.index1
+			let index2 = e.currentTarget.dataset.index2
+			let id = e.currentTarget.dataset.id
+			let type = e.currentTarget.dataset.type
+			
+			if(type == 3) {
+				if(this.bankList[index1].list[index2].list) {
+					this.$set(this.bankList[index1].list[index2],'showList',!this.bankList[index1].list[index2].showList)
+					this.$set(this.bankList[index1].list[index2],'list',[{
+						name:'试卷',
+						id:2,
+					}])
+					return;
 				}
-			})
+				
+				this.$api.goodsExamList({
+					chapterExamId:id
+				}).then(res => {
+					
+					// res.data.data.forEach(item => {
+					// 	item.showList = false;
+					// })
+					// this.bankList = res.data.data;
+					
+					this.$set(this.bankList[index1].list[index2],'showList',true)
+					this.$set(this.bankList[index1].list[index2],'list',[{
+						name:'试卷',
+						id:2,
+					}])
+					
+					 
+				})
+				
+			} else if(type == 2) {
+				if(this.bankList[index1].list) {
+					this.$set(this.bankList[index1],'showList',!this.bankList[index1].showList)
+					return;
+				}
+				
+				this.$api.goodsExamList({
+					chapterExamId:id
+				}).then(res => {
+					
+					// res.data.data.forEach(item => {
+					// 	item.showList = false;
+					// })
+					// this.bankList = res.data.data;
+					
+					this.$set(this.bankList[index1],'showList',true)
+					this.$set(this.bankList[index1],'list',[{
+						name:'试卷',
+						id:2,
+					}])
+					
+					 
+				})
+			}
+			
+			
 			
 		}
 	}
@@ -218,18 +343,6 @@ export default {
 					font-size: 24rpx;
 					color: #666666;
 					
-					&::before {
-						content:'^';
-						display: inline-block;
-						margin-right:20rpx;
-					}
-					
-					&.up {
-						&::before {
-							transform: rotate(180deg);
-						}
-						
-					}
 				}
 				
 				.article {
@@ -240,6 +353,11 @@ export default {
 					font-size: 24rpx;
 					color: #666666;
 					border-bottom: 1rpx solid #EEEEEE;
+					display: flex;
+					
+					.flex_auto{
+						flex:1;
+					}
 					
 					&:nth-last-of-type(1) {
 						border:0;