超V课程

This commit is contained in:
@fawn-nine
2024-06-25 13:18:58 +08:00
parent 2215068cc1
commit 7018a5c242
10 changed files with 139 additions and 34 deletions

View File

@@ -7,11 +7,7 @@
<u-alert
v-if=""
style="
position: fixed;
left: 0;
width: 100%;
z-index: 10;
"
:title="goBuyTitle"
type="warning"
@@ -105,7 +101,8 @@
},
proPriceList:[],
pricespop:false,
userMsg:{},
userMsg:{},
cartList:[]
};
},
//第一次加载
@@ -137,14 +134,111 @@
},
//方法
methods: {
// 获取购物车数据
addCart(val){
console.log(val)
if (val.productStock == 0) {
uni.showToast({
title: '商品库存不足',
icon: "none"
});
} else {
console.log(this.userInfo, '222')
this.$http
.post(`book/ordercart/getCartList?userId=${this.userInfo.id}`)
.then(res => {
// console.log(
this.cartList = res.cartList
this.isAddLink(val)
})
}
},
// 加入到购物车
isAddLink(item) {
// 统计商品信息
let data = {
"userId": this.userInfo.id,
"productId": item.productId,
"productAmount": this.productAmount,
"price": item.price
}
// 判断列表是否为空
if (this.cartList.length > 0) {
let flag = ''
let shagnpin = {}
// 循环购物车列表
flag = this.cartList.some((item, index) => {
if (item.productId == data.productId) {
shagnpin = item
shagnpin.productAmount += 1
return true
}
})
if (flag) {
// 已在购物车中添加
$http.request({
url: "book/ordercart/update",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: shagnpin,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
this.upoShow = false
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
} else {
// 加入购物车
$http.request({
url: "book/ordercart/save",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
this.upoShow = false
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
}
} else {
// 购物车列表为空时直接加入购物车
$http.request({
url: "book/ordercart/save",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data,
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '加入购物车成功',
duration: 1000,
});
}
})
}
},
oprate(data){
console.log(data,'得到的内容')
if(data.name == 'buy'){
this.buy(data.item)
}
// else if(data.name == 'gouwuche'){
// this.addCart(data.item)
// }
else if(data.name == 'gouwuche'){
this.addCart(data.item)
}
},
buy(val){
var mynavData = JSON.stringify({

View File

@@ -37,7 +37,9 @@
</view>
<!-- <view class="imgcontainer" :style="{backgroundImage:surl(item.image)}"> -->
<view class="imgcontainer" @click="onPageJump('/pages/course/myCourseLearn',item.id)">
<image :src="item.image" mode="aspectFit"></image>
<image v-if="item.image && item.image != ''" :src="item.image" mode="aspectFit"></image>
<!-- <image :src="item.image" mode="" @click="goDetail(item.productId)"></image> -->
<!-- <image v-else src="/static/nobg.jpg" mode="widthFix"></image> -->
</view>
<view class="buyItems">
<view class="txt555">
@@ -300,7 +302,7 @@
.then(res => {
// console.log(
this.cartList = res.cartList
// this.isAddLink(val)
this.isAddLink(val)
})
}
},
@@ -321,7 +323,7 @@
flag = this.cartList.some((item, index) => {
if (item.productId == data.productId) {
shagnpin = item
shagnpin.productAmount = item.productAmount + 1
shagnpin.productAmount += 1
return true
}
})

View File

@@ -2,7 +2,7 @@
<view>
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<z-nav-bar :title="pageTitle"></z-nav-bar>
<z-nav-bar title="超V专享课程"></z-nav-bar>
<view class="learnBox box" >
<view class="newBox">
<view class="item flexbox" v-for="(item, index) in courseList" :key="index" @click="onPageJump('/pages/course/courseDetail',item.id, item.title)">
@@ -102,10 +102,9 @@
this.status = 1
this.flag = false
$http.request({
url: "medical/home/getMarketCourseList",
url: "medical/course/getCourseByVip",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: {
"id": this.tagId,
data: {
"limit": 12,
"page": this.page
},
@@ -115,10 +114,10 @@
})
.then(res => {
if (res.code == 0) {
if (res.courseList.records.length > 0) {
var list = res.courseList.records
if (res.data.records.length > 0) {
var list = res.data.records
this.courseList = this.courseList.concat(list)
if(res.courseList.pages > this.page){
if(res.data.pages > this.page){
this.status = 0
}else{
this.status = 2