he2802 3 vuotta sitten
vanhempi
commit
64cc77e131
4 muutettua tiedostoa jossa 226 lisäystä ja 154 poistoa
  1. 3 1
      common/api.js
  2. 14 0
      common/httpList/course.js
  3. 172 147
      pages/shopping/shoppingCart.vue
  4. 37 6
      pages2/course/detail.vue

+ 3 - 1
common/api.js

@@ -6,6 +6,7 @@ import wxpay from './httpList/wxpay.js'
 import system from './httpList/system.js'
 import goods from './httpList/goods.js'
 import business from './httpList/business.js'
+import course from './httpList/course.js'
 export default {
 	...login,
 	...polyvVideo,
@@ -14,5 +15,6 @@ export default {
 	...system,
 	...wxpay,
 	...goods,
-	...business
+	...business,
+	...course
 }

+ 14 - 0
common/httpList/course.js

@@ -0,0 +1,14 @@
+import {
+	myRequest
+} from '../request.js'
+export default {
+	menuList(data) {
+		return myRequest({
+			url: '/app/common/course/menuList',
+			method: 'get',
+			data: data,
+			noToken: true
+		})
+	},
+	
+}

+ 172 - 147
pages/shopping/shoppingCart.vue

@@ -5,148 +5,160 @@
 				<image  src="/static/logo2.png" style="width: 178rpx;height: 31rpx;margin-left: 30rpx;"></image>
 			</view>
 		</u-navbar>
-		<view style="padding: 30rpx;padding-bottom: 98rpx;">
-			<uni-swipe-action>
-			 <u-checkbox-group
-			            v-model="checkboxValue1"
-			            placement="column"
-			            @change="checkboxChange">
-			<uni-swipe-action-item :autoClose="false" @change="swipeChange($event, item)" :show="item.show" v-for="(item,index) in list" :key="index" >
-				<view class="item">
-					<view style="width: 100%;">
-						<view style="display: flex;padding-bottom: 15rpx;">
-							<view style="display: flex;align-items:center;">
-								<u-checkbox
-									v-model="item.checked" 
+		<view v-show="isLogin">
+			<view style="padding: 30rpx;padding-bottom: 98rpx;">
+				<uni-swipe-action>
+				 <u-checkbox-group
+				     placement="column">
+						  <view>
+				<uni-swipe-action-item :autoClose="false" @change="swipeChange($event, item)" :show="item.show" v-for="(item,index) in list" :key="index" >
+					<view class="item">
+						<view style="width: 100%;">
+							
+							<view style="display: flex;padding-bottom: 15rpx;">
+								<view style="display: flex;align-items:center;">
+									<u-checkbox
+									@change="checkboxChange" 
+									v-model="list[index].checked" 
 									shape="circle"
-									:name="item.name">
-								</u-checkbox>
-							</view>
-							<image :src="$method.splitImgHost(item.coverUrl, true)" style="height: 134rpx;width: 278rpx;border-radius: 16rpx;"></image>
-							<view style="margin-left: 20rpx;flex: 1;">
-								<view style="color: #333333;font-size: 30rpx;font-weight: bold;">
-									{{item.goodsName}}
+									:name="index">
+									</u-checkbox>
 								</view>
-								<view class="priceTag">
-									¥ {{item.standPrice}}
+								<view>
+									<image :src="$method.splitImgHost(item.coverUrl, true)" style="width: 278rpx;height: 134rpx;"></image>
 								</view>
+								<view style="margin-left: 20rpx;flex: 1;">
+									<view style="color: #333333;font-size: 30rpx;font-weight: bold;">
+										{{item.goodsName}}
+									</view>
+									<view class="priceTag">
+										¥ {{item.standPrice}}
+									</view>
+								</view>
+								
+							</view>
+							<u-line color="#D6D6DB" />
+							<view style="display: flex;justify-content: space-between;align-items: center;height: 50rpx;" @click="openPopup(index)">
+								<view style="color: #666666;font-size: 24rpx;margin-left: 60rpx;">选择班级</view>
+								<view><u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
 							</view>
-							
-						</view>
-						<u-line color="#D6D6DB" />
-						<view style="display: flex;justify-content: space-between;align-items: center;height: 50rpx;" @click="openPopup(index)">
-							<view style="color: #666666;font-size: 24rpx;margin-left: 60rpx;">选择班级</view>
-							<view><u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
 						</view>
 					</view>
+					<template v-slot:right>
+						<view class="operate" @click="delItem(item)">
+							<view ><text>删除</text></view>
+							
+						</view>
+					</template>
+				</uni-swipe-action-item>
 				</view>
-				<template v-slot:right>
-					<view class="operate" @click="delItem(item)">
-						<view ><text>删除</text></view>
-						
-					</view>
-				</template>
-			</uni-swipe-action-item>
-			</u-checkbox-group>
-			</uni-swipe-action>
-		</view>
-		<view class="bottomBox">
-			<view>
-				<u-checkbox
-					label="all"
-					name="all"
-					shape="circle"
-					@change="checkboxAllChange"
-					v-model="allChecked" 
-				>
-				</u-checkbox>
-				<text>全选</text>
+				 </u-checkbox-group>
+				</uni-swipe-action>
 			</view>
-			<view style="display: flex;align-items: center;">
-				<view style="color: #999999;margin-right: 8rpx;">合计</view>
-				<view class="priceTag">¥ 999.00</view>
-				<view style="display: flex;color: #FFFFFF;align-items: center;">
-					<view class="btn2" @click="goBuy()">结算</view>
+			<view class="bottomBox">
+				<view>
+					<u-checkbox
+						label="all"
+						name="all"
+						shape="circle"
+						@change="checkboxAllChange"
+						v-model="allChecked" 
+					>
+					</u-checkbox>
+					<text>全选</text>
 				</view>
-			</view>
-		</view>
-		
-		<u-popup v-model="show" mode="bottom"border-radius="40">
-			<view class="popup_box">
-				<view style="margin-bottom: 20rpx;">
-					<view class="line1"></view>
-					<view class="grade">选择班级</view>
+				<view style="display: flex;align-items: center;">
+					<view style="color: #999999;margin-right: 8rpx;">合计</view>
+					<view class="priceTag">¥ {{totalPrice}}</view>
+					<view style="display: flex;color: #FFFFFF;align-items: center;">
+						<view class="btn2" @click="goBuy()">结算</view>
+					</view>
 				</view>
-				<u-line color="#D6D6DB" />
-				<view>
-					<scroll-view scroll-y="true" style="height: 500rpx;">
-						<view>
-							<u-checkbox-group @change="checkboxGroupChange">
-								<view v-for="(item, index) in list" :key="index" >
-									<view style="display: flex;align-items: center;padding: 20rpx;">
-										<view>
-											<u-checkbox
-												shape="circle"
-												@change="checkboxChange" 
-												v-model="item.checked" 
-												:name="item.name"
-											></u-checkbox>
-										</view>
-										<view :class="item.checked?'white-box blue-box':'white-box'" >
+			</view>
+			
+			<u-popup v-model="show" mode="bottom"border-radius="40">
+				<view class="popup_box">
+					<view style="margin-bottom: 20rpx;">
+						<view class="line1"></view>
+						<view class="grade">选择班级</view>
+					</view>
+					<u-line color="#D6D6DB" />
+					<view>
+						<scroll-view scroll-y="true" style="height: 500rpx;">
+							<view>
+								<u-checkbox-group @change="checkboxGroupChange1">
+									<view v-for="(item, index) in list" :key="index" >
+										<view style="display: flex;align-items: center;padding: 20rpx;">
 											<view>
-												<view class="blackTxt">2021年第1期二级建造师继续教育选修课(市政)标题过长换行显示</view>
-												<view class="redTxt">有效期至:2021/11/30</view>
-												<view class="redTxt">本班还剩41天将结束学习</view>
+												<u-checkbox
+													shape="circle"
+													@change="checkboxChange1" 
+													v-model="item.checked" 
+													:name="item.name"
+												></u-checkbox>
+											</view>
+											<view :class="item.checked?'white-box blue-box':'white-box'" >
+												<view>
+													<view class="blackTxt">2021年第1期二级建造师继续教育选修课(市政)标题过长换行显示</view>
+													<view class="redTxt">有效期至:2021/11/30</view>
+													<view class="redTxt">本班还剩41天将结束学习</view>
+												</view>
 											</view>
 										</view>
 									</view>
-								</view>
-							</u-checkbox-group>
-						</view>
-					</scroll-view>
-				</view>
-				<view class="confrim-btn">
-					<view class="okBtn">确定</view>
-				</view>
-			</view>
-		</u-popup>
-		<u-popup v-model="show1" mode="bottom"border-radius="40">
-			<view class="popup_box">
-				<view style="margin-bottom: 20rpx;">
-					<view class="line1"></view>
-					<view class="grade">选择考期/地区</view>
+								</u-checkbox-group>
+							</view>
+						</scroll-view>
+					</view>
+					<view class="confrim-btn">
+						<view class="okBtn">确定</view>
+					</view>
 				</view>
-				<u-line color="#D6D6DB" />
-				<view style="display: flex;height: 500rpx;">
-					<view style="width: 50%;">
-						<view class="topTxt">考期</view>
-						<view>
-							<picker-view  :indicator-style="indicatorStyle" :value="value" @change="bindChange" class="picker-view">
-								<picker-view-column>
-									<view class="picker-item" v-for="(item,index) in list1" :key="index">{{item.label}}</view>
-								</picker-view-column>
-							</picker-view>
-						</view>
+			</u-popup>
+			<u-popup v-model="show1" mode="bottom"border-radius="40">
+				<view class="popup_box">
+					<view style="margin-bottom: 20rpx;">
+						<view class="line1"></view>
+						<view class="grade">选择考期/地区</view>
 					</view>
-					<view style="width: 50%;">
-						<view class="topTxt">地区</view>
-						<view>
-							<picker-view  :indicator-style="indicatorStyle" :value="value" @change="bindChange" class="picker-view">
-								<picker-view-column>
-									<view class="picker-item" v-for="(item,index) in list2" :key="index">{{item.label}}</view>
-								</picker-view-column>
-								<picker-view-column>
-									<view class="picker-item" v-for="(item,index) in list3" :key="index">{{item.label}}</view>
-								</picker-view-column>
-							</picker-view>
+					<u-line color="#D6D6DB" />
+					<view style="display: flex;height: 500rpx;">
+						<view style="width: 50%;">
+							<view class="topTxt">考期</view>
+							<view>
+								<picker-view  :indicator-style="indicatorStyle" :value="value" @change="bindChange" class="picker-view">
+									<picker-view-column>
+										<view class="picker-item" v-for="(item,index) in list1" :key="index">{{item.label}}</view>
+									</picker-view-column>
+								</picker-view>
+							</view>
+						</view>
+						<view style="width: 50%;">
+							<view class="topTxt">地区</view>
+							<view>
+								<picker-view  :indicator-style="indicatorStyle" :value="value" @change="bindChange" class="picker-view">
+									<picker-view-column>
+										<view class="picker-item" v-for="(item,index) in list2" :key="index">{{item.label}}</view>
+									</picker-view-column>
+									<picker-view-column>
+										<view class="picker-item" v-for="(item,index) in list3" :key="index">{{item.label}}</view>
+									</picker-view-column>
+								</picker-view>
+							</view>
 						</view>
 					</view>
+					<view class="confrim-btn">
+						<view class="okBtn">确定</view>
+					</view>
 				</view>
-				<view class="confrim-btn">
-					<view class="okBtn">确定</view>
-				</view>
+			</u-popup>
+		</view>
+		<view v-show="!isLogin">
+			<view style="display: flex;align-items:center;flex-direction: column;margin-top: 40%;font-size: 32rpx;">
+				<view style="color: #999999;">您还没有登录哦~</view>
+				<view style="margin-top: 30rpx;" ><u-button type="primary" @click="login">去登录</u-button></view>
 			</view>
-		</u-popup>
+		</view>
 	</view>
 </template>
 
@@ -154,26 +166,10 @@
 	export default {
 		data() {
 			return {
+				isLogin:false,
 				allChecked:false,
 				checkboxValue1:[],
-				list: [{
-					name: 'apple',
-					checked: false,
-					disabled: false,
-					show: false
-				},
-				{
-					name: 'banner',
-					checked: false,
-					disabled: false,
-					show: false
-				},
-				{
-					name: 'orange',
-					checked: false,
-					disabled: false,
-					show: false
-				}
+				list: [
 				],
 				list1:[
 						{
@@ -225,31 +221,54 @@
 					],
 					value1:'',
 				show:false,
-				show1:false
+				show1:false,
+				totalPrice:0.00,
+				isOld:false
 			}
 		},
 		onLoad(option) {
 			
 		},
 		onShow() {
-			this.cartList()
+			this.isLogin = this.$method.isLogin()
+			if(this.isLogin){
+				if(uni.getStorageSync('updateCart')||!this.isOld){
+					this.isOld = true
+					this.cartList()
+					uni.removeStorageSync('updateCart')//消费购物车刷新事件
+				}
+				
+			}
+			
 		},
 		methods: {
+			countPrice(list){
+				
+			},
+			checkboxChange1(e) {
+				//console.log(e);
+			},
+			
+			login(){
+				uni.navigateTo({url:'/pages/login/login'});
+			},
 			cartList() {
 				let self = this
+				this.allChecked = false
+				this.totalPrice = 0.00
 				this.$api.cartList().then(res => {
 					if(res.data.code==200){
-						self.list = res.data.rows
-						for (let i = 0; i < self.list.length; i++) {
-							let item = self.list[i]
+						for (let i = 0; i < res.data.rows.length; i++) {
+							let item = res.data.rows[i]
 							item.checked = false
-							if(item.status!=1||item.goodsStatus!=1){
+							 if(item.status!=1||item.goodsStatus!=1){
 								item.disabled = true
 							}else{
 								item.disabled = false
 							}
 							item.show = false
 						}
+						self.list = res.data.rows
 					}
 				});
 			},
@@ -269,6 +288,11 @@
 			},
 			checkboxChange(n) {
 				console.log('change', n);
+				if(n.value){
+					this.totalPrice += this.list[n.name].standPrice
+				}else{
+					this.totalPrice -= this.list[n.name].standPrice
+				}
 			},
 			openPopup(index){
 				if(index==0){
@@ -279,10 +303,11 @@
 				
 			},
 			checkboxAllChange(n){
-				console.log(this.allChecked,n)
+				this.totalPrice = 0.00
 				if(n.value){
 					for(let i =0;i<this.list.length;i++){
 						this.list[i].checked = true
+						this.totalPrice += this.list[i].standPrice
 					}
 				}else{
 					for(let i =0;i<this.list.length;i++){

+ 37 - 6
pages2/course/detail.vue

@@ -28,9 +28,17 @@
 		</view>
 		<view style="padding: 20rpx;" v-show="current==1">
 			<view >
-				<view v-for="(item,index) in courseList" class="courseItem">
-					<view>{{item.courseName}}</view>
-					<view><u-icon name="arrow-down" ></u-icon></view>
+				<view v-for="(item,index) in courseList" >
+					<view class="courseItem" @click="openCourse(item)">
+						<view>{{item.courseName}}</view>
+						<view>
+							<u-icon name="arrow-down" v-if="item.down"></u-icon>
+							<u-icon name="arrow-up" v-if="!item.down"></u-icon>
+						</view>
+					</view>
+					<view v-if="item.down">
+						
+					</view>
 				</view>
 			</view>
 		</view>
@@ -60,8 +68,7 @@ export default {
 			],
 			current:0,
 			detail:{},
-			courseList:[]
-					
+			courseList:[]	
 		};
 	},
 	onUnload() {
@@ -77,10 +84,18 @@ export default {
 		
 	},
 	methods: {
+		openCourse(item){
+			item.down = !item.down
+			if(!item.down){
+				this.menuList(item.courseId)
+			}
+			
+		},
 		addShopCart() {
 			let self = this
 			this.$api.addCart({goodsId:this.id}).then(res => {
 				if(res.data.code==200){
+					uni.setStorageSync('updateCart',1) //提醒刷新购物车
 					uni.showToast({
 					    title: '添加成功'
 					});
@@ -93,10 +108,24 @@ export default {
 			let self = this
 			this.$api.goodsCourseList(this.id).then(res => {
 				if(res.data.code==200){
+					
+					for(let i=0;i<res.data.rows.length;i++){
+						let item = res.data.rows[i]
+						item.down = true
+					}
 					self.courseList = res.data.rows
 				}
 			});
 		},
+		menuList(courseId) {
+			let self = this
+			this.$api.menuList({courseId:courseId}).then(res => {
+				if(res.data.code==200){
+					
+					console.log(res.data)
+				}
+			});
+		},
 		getDetail() {
 			let self = this
 			this.$api.goodsDetail(this.id).then(res => {
@@ -117,7 +146,6 @@ export default {
 				return
 			}
 			this.addShopCart()
-			
 		},
 		open(item){
 			item.showChildren = !item.showChildren
@@ -134,6 +162,9 @@ export default {
 	}
 </style>
 <style scope>
+	.contentBox{
+		
+	}
 	.courseItem{
 		width: 100%;
 		height: 80rpx;