小程序提交
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { baseUrl, globalImgUrl } from "../../../request";
|
||||
// pages/course/createCourseOrder/createCourseOrder.js
|
||||
Page({
|
||||
|
||||
@ -6,13 +7,56 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
courseId: 0, // 课程id
|
||||
courseObj: '', // 课程对象
|
||||
globalImgUrl, // 全局图片
|
||||
},
|
||||
|
||||
// 创建订单方法
|
||||
createOrder(e) {
|
||||
const courseId = e.currentTarget.dataset.id;
|
||||
wx.navigateTo({
|
||||
url: `/pages/course/waitPayOrder/waitPayOrder?id=${courseId}`,
|
||||
createOrder() {
|
||||
const { courseId } = this.data;
|
||||
let orderId ;
|
||||
wx.request({
|
||||
url: baseUrl + '/courseOrder/add',
|
||||
method: 'POST',
|
||||
data: {
|
||||
courseId: courseId
|
||||
},
|
||||
header: {
|
||||
Authorization :wx.getStorageSync('token'),
|
||||
},
|
||||
success : res => {
|
||||
console.log(res);
|
||||
this.setData({
|
||||
orderId: res.data.data
|
||||
})
|
||||
wx.navigateTo({
|
||||
url: `/pages/course/orderDetail/orderDetail?id=${this.data.orderId}`,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
// 获取课程详情
|
||||
getCourseDetail() {
|
||||
const cid = this.data.courseId;
|
||||
wx.request({
|
||||
url: baseUrl + '/course/detail/id',
|
||||
method: 'POST',
|
||||
data: {
|
||||
id: cid
|
||||
},
|
||||
header: {
|
||||
Authorization :wx.getStorageSync('token'),
|
||||
},
|
||||
success : res => {
|
||||
console.log(res);
|
||||
if (res.data.code === 1) {
|
||||
this.setData({
|
||||
courseObj: res.data.data,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@ -24,6 +68,7 @@ Page({
|
||||
this.setData({
|
||||
courseId: options.id,
|
||||
})
|
||||
this.getCourseDetail()
|
||||
},
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user