Initial commit
This commit is contained in:
11
wechat-mini-program/app.js
Normal file
11
wechat-mini-program/app.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const env = require('./config/env')
|
||||
|
||||
App({
|
||||
onLaunch() {
|
||||
console.log('App Launch')
|
||||
},
|
||||
globalData: {
|
||||
userInfo: null,
|
||||
baseUrl: env.baseUrl
|
||||
}
|
||||
})
|
||||
41
wechat-mini-program/app.json
Normal file
41
wechat-mini-program/app.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/coupon/coupon",
|
||||
"pages/profile/profile",
|
||||
"pages/detail/detail"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#fff",
|
||||
"navigationBarTitleText": "Edu App",
|
||||
"navigationBarTextStyle": "black"
|
||||
},
|
||||
"style": "v2",
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"tabBar": {
|
||||
"color": "#999999",
|
||||
"selectedColor": "#2563eb",
|
||||
"backgroundColor": "#ffffff",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "首页",
|
||||
"iconPath": "",
|
||||
"selectedIconPath": ""
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/coupon/coupon",
|
||||
"text": "优惠券",
|
||||
"iconPath": "",
|
||||
"selectedIconPath": ""
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/profile/profile",
|
||||
"text": "我的",
|
||||
"iconPath": "",
|
||||
"selectedIconPath": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
10
wechat-mini-program/app.wxss
Normal file
10
wechat-mini-program/app.wxss
Normal file
@@ -0,0 +1,10 @@
|
||||
/**app.wxss**/
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
page {
|
||||
background-color: #f9fafb;
|
||||
}
|
||||
11
wechat-mini-program/config/env.js
Normal file
11
wechat-mini-program/config/env.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const env = 'development'
|
||||
const configs = {
|
||||
development: {
|
||||
baseUrl: 'http://localhost:8000/api'
|
||||
},
|
||||
production: {
|
||||
baseUrl: 'https://your-domain.example.com/api'
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = configs[env]
|
||||
76
wechat-mini-program/pages/coupon/coupon.js
Normal file
76
wechat-mini-program/pages/coupon/coupon.js
Normal file
@@ -0,0 +1,76 @@
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
coupons: []
|
||||
},
|
||||
onLoad() {
|
||||
this.fetchCoupons();
|
||||
},
|
||||
fetchCoupons() {
|
||||
const { request } = require('../../utils/request')
|
||||
request({ url: '/coupons' })
|
||||
.then((data) => {
|
||||
const list = Array.isArray(data) ? data : (data && data.results) || []
|
||||
this.setData({ coupons: list })
|
||||
})
|
||||
.catch(() => {
|
||||
this.setData({
|
||||
coupons: [
|
||||
{
|
||||
id: 1,
|
||||
amount: '50',
|
||||
unit: '元',
|
||||
title: '新人见面礼',
|
||||
desc: '无门槛使用,适用于所有课程',
|
||||
expiry: '2023-12-31',
|
||||
status: 'available',
|
||||
color: 'from-blue-500 to-cyan-400',
|
||||
bgStart: 'from-blue-50',
|
||||
bgEnd: 'to-cyan-50',
|
||||
shadow: 'shadow-blue-100'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
amount: '8.5',
|
||||
unit: '折',
|
||||
title: '编程课程专享',
|
||||
desc: '仅限编程开发类课程使用',
|
||||
expiry: '2023-11-30',
|
||||
status: 'available',
|
||||
color: 'from-violet-500 to-fuchsia-500',
|
||||
bgStart: 'from-violet-50',
|
||||
bgEnd: 'to-fuchsia-50',
|
||||
shadow: 'shadow-violet-100'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
amount: '100',
|
||||
unit: '元',
|
||||
title: '高阶课程抵扣券',
|
||||
desc: '满 999 元可用',
|
||||
expiry: '2023-10-15',
|
||||
status: 'claimed',
|
||||
color: 'from-orange-400 to-rose-500',
|
||||
bgStart: 'from-orange-50',
|
||||
bgEnd: 'to-rose-50',
|
||||
shadow: 'shadow-orange-100'
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
},
|
||||
handleClaim(e) {
|
||||
const id = e.currentTarget.dataset.id;
|
||||
if (this.data.coupons.find(c => c.id === id).status === 'claimed') return;
|
||||
|
||||
const updatedCoupons = this.data.coupons.map(c =>
|
||||
c.id === id ? { ...c, status: 'claimed' } : c
|
||||
);
|
||||
this.setData({ coupons: updatedCoupons });
|
||||
wx.showToast({
|
||||
title: '领取成功',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
})
|
||||
3
wechat-mini-program/pages/coupon/coupon.json
Normal file
3
wechat-mini-program/pages/coupon/coupon.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "优惠券"
|
||||
}
|
||||
38
wechat-mini-program/pages/coupon/coupon.wxml
Normal file
38
wechat-mini-program/pages/coupon/coupon.wxml
Normal file
@@ -0,0 +1,38 @@
|
||||
<view class="container">
|
||||
<view class="header">
|
||||
<text class="title">优惠券中心</text>
|
||||
</view>
|
||||
|
||||
<!-- VIP Banner -->
|
||||
<view class="vip-banner">
|
||||
<view class="vip-content">
|
||||
<view class="vip-title">
|
||||
<text class="icon">🎁</text> VIP 会员权益
|
||||
</view>
|
||||
<view class="vip-desc">每月免费领取 3 张大额优惠券</view>
|
||||
</view>
|
||||
<view class="vip-btn">立即开通</view>
|
||||
</view>
|
||||
|
||||
<!-- Coupon List -->
|
||||
<view class="section-title">可领取的优惠券</view>
|
||||
<view class="coupon-list">
|
||||
<block wx:for="{{coupons}}" wx:key="id">
|
||||
<view class="coupon-card {{item.status === 'claimed' ? 'claimed' : ''}}" bindtap="handleClaim" data-id="{{item.id}}">
|
||||
<view class="coupon-left">
|
||||
<view class="amount">
|
||||
<text class="num">{{item.amount}}</text>
|
||||
<text class="unit">{{item.unit}}</text>
|
||||
</view>
|
||||
<view class="info">
|
||||
<view class="coupon-name">{{item.title}}</view>
|
||||
<view class="coupon-desc">{{item.desc}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="coupon-right">
|
||||
<text class="btn-text">{{item.status === 'claimed' ? '已领取' : '领取'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
110
wechat-mini-program/pages/coupon/coupon.wxss
Normal file
110
wechat-mini-program/pages/coupon/coupon.wxss
Normal file
@@ -0,0 +1,110 @@
|
||||
.container {
|
||||
padding: 30rpx;
|
||||
background-color: #f9fafb;
|
||||
min-height: 100vh;
|
||||
}
|
||||
.header {
|
||||
padding: 20rpx 0;
|
||||
text-align: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #1f2937;
|
||||
}
|
||||
.vip-banner {
|
||||
background: linear-gradient(to bottom right, #111827, #1f2937);
|
||||
border-radius: 30rpx;
|
||||
padding: 40rpx;
|
||||
color: white;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 40rpx;
|
||||
box-shadow: 0 10rpx 20rpx rgba(0,0,0,0.1);
|
||||
}
|
||||
.vip-title {
|
||||
color: #fcd34d;
|
||||
font-weight: bold;
|
||||
font-size: 32rpx;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
.vip-desc {
|
||||
color: #d1d5db;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.vip-btn {
|
||||
background: linear-gradient(to right, #fcd34d, #fbbf24);
|
||||
color: #111827;
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
padding: 10rpx 30rpx;
|
||||
border-radius: 40rpx;
|
||||
margin: 0;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20rpx;
|
||||
color: #1f2937;
|
||||
}
|
||||
.coupon-card {
|
||||
background-color: white;
|
||||
background: linear-gradient(to bottom right, #eff6ff, #ecfeff);
|
||||
border-radius: 30rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-shadow: 0 4rpx 10rpx rgba(59, 130, 246, 0.1);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.coupon-card.claimed {
|
||||
background: linear-gradient(to bottom right, #f9fafb, #f3f4f6);
|
||||
box-shadow: none;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.coupon-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.amount {
|
||||
margin-right: 30rpx;
|
||||
color: #2563eb;
|
||||
}
|
||||
.coupon-card.claimed .amount {
|
||||
color: #9ca3af;
|
||||
}
|
||||
.num {
|
||||
font-size: 60rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.unit {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.coupon-name {
|
||||
font-weight: bold;
|
||||
font-size: 30rpx;
|
||||
color: #1f2937;
|
||||
}
|
||||
.coupon-desc {
|
||||
font-size: 22rpx;
|
||||
color: #6b7280;
|
||||
margin-top: 6rpx;
|
||||
}
|
||||
.coupon-right {
|
||||
background-color: white;
|
||||
padding: 10rpx 30rpx;
|
||||
border-radius: 30rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
color: #2563eb;
|
||||
box-shadow: 0 2rpx 4rpx rgba(0,0,0,0.05);
|
||||
}
|
||||
.coupon-card.claimed .coupon-right {
|
||||
background-color: #e5e7eb;
|
||||
color: #9ca3af;
|
||||
}
|
||||
69
wechat-mini-program/pages/detail/detail.js
Normal file
69
wechat-mini-program/pages/detail/detail.js
Normal file
@@ -0,0 +1,69 @@
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
project: null
|
||||
},
|
||||
onLoad(options) {
|
||||
const { id } = options;
|
||||
this.fetchProject(id);
|
||||
},
|
||||
fetchProject(id) {
|
||||
const { request } = require('../../utils/request')
|
||||
request({ url: `/projects/${id}` })
|
||||
.then((data) => {
|
||||
this.setData({ project: data })
|
||||
})
|
||||
.catch(() => {
|
||||
const projects = [
|
||||
{
|
||||
id: 1,
|
||||
title: 'Python 数据分析实战',
|
||||
category: '编程开发',
|
||||
image:
|
||||
'https://images.unsplash.com/photo-1526379095098-d400fd0bf935?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3',
|
||||
students: 1205,
|
||||
rating: 4.8,
|
||||
duration: '12 周'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: '零基础英语口语速成',
|
||||
category: '语言学习',
|
||||
image:
|
||||
'https://images.unsplash.com/photo-1543269865-cbf427effbad?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3',
|
||||
students: 850,
|
||||
rating: 4.9,
|
||||
duration: '8 周'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
title: 'UI/UX 设计全能班',
|
||||
category: '设计创作',
|
||||
image:
|
||||
'https://images.unsplash.com/photo-1561070791-2526d30994b5?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3',
|
||||
students: 2340,
|
||||
rating: 4.7,
|
||||
duration: '16 周'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
title: '职场高效沟通技巧',
|
||||
category: '职场提升',
|
||||
image:
|
||||
'https://images.unsplash.com/photo-1552581234-26160f608093?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3',
|
||||
students: 5600,
|
||||
rating: 4.6,
|
||||
duration: '4 周'
|
||||
}
|
||||
]
|
||||
this.setData({ project: projects.find((p) => p.id == id) })
|
||||
})
|
||||
},
|
||||
handleEnroll() {
|
||||
wx.showToast({
|
||||
title: '报名成功',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
})
|
||||
5
wechat-mini-program/pages/detail/detail.json
Normal file
5
wechat-mini-program/pages/detail/detail.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"navigationBarTitleText": "课程详情",
|
||||
"navigationBarBackgroundColor": "#ffffff",
|
||||
"navigationBarTextStyle": "black"
|
||||
}
|
||||
59
wechat-mini-program/pages/detail/detail.wxml
Normal file
59
wechat-mini-program/pages/detail/detail.wxml
Normal file
@@ -0,0 +1,59 @@
|
||||
<view class="container" wx:if="{{project}}">
|
||||
<image class="hero-image" src="{{project.image}}" mode="aspectFill"></image>
|
||||
|
||||
<view class="content">
|
||||
<view class="header">
|
||||
<view class="badge">{{project.category}}</view>
|
||||
<view class="rating">
|
||||
<text class="star">⭐</text> {{project.rating}}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="title">{{project.title}}</view>
|
||||
|
||||
<view class="meta-row">
|
||||
<view class="meta-item">
|
||||
<text class="icon">👥</text> {{project.students}} 人已报名
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="icon">🕒</text> {{project.duration}}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">课程简介</view>
|
||||
<view class="desc">
|
||||
本课程将带领你深入了解{{project.title}}的核心概念与实战技巧。通过{{project.duration}}的系统学习,你将掌握行业前沿知识,提升职业竞争力。
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section" wx:if="{{project.outline}}">
|
||||
<view class="section-title">课程大纲</view>
|
||||
<view class="chapter-list">
|
||||
<block wx:for="{{project.outline}}" wx:key="chapter" wx:for-item="chapter" wx:for-index="idx">
|
||||
<view class="chapter-header">{{chapter.chapter}}</view>
|
||||
<block wx:for="{{chapter.lessons}}" wx:key="title" wx:for-item="lesson">
|
||||
<view class="lesson-item">
|
||||
<view class="lesson-info">
|
||||
<view class="lesson-title">{{lesson.title}}</view>
|
||||
<view class="lesson-time">{{lesson.duration}}</view>
|
||||
</view>
|
||||
<view class="play-btn" wx:if="{{lesson.isFree}}">▶</view>
|
||||
<view class="lock-btn" wx:else>🔒</view>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
<!-- Fallback if no outline data -->
|
||||
<view class="section" wx:else>
|
||||
<view class="section-title">课程大纲</view>
|
||||
<view class="desc">暂无大纲信息</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="footer-bar">
|
||||
<view class="price">¥ 299</view>
|
||||
<button class="enroll-btn" bindtap="handleEnroll">立即报名</button>
|
||||
</view>
|
||||
</view>
|
||||
139
wechat-mini-program/pages/detail/detail.wxss
Normal file
139
wechat-mini-program/pages/detail/detail.wxss
Normal file
@@ -0,0 +1,139 @@
|
||||
.container {
|
||||
background-color: white;
|
||||
min-height: 100vh;
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
.hero-image {
|
||||
width: 100%;
|
||||
height: 400rpx;
|
||||
}
|
||||
.content {
|
||||
padding: 40rpx;
|
||||
border-top-left-radius: 40rpx;
|
||||
border-top-right-radius: 40rpx;
|
||||
margin-top: -40rpx;
|
||||
background-color: white;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
}
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.badge {
|
||||
background-color: #dbeafe;
|
||||
color: #2563eb;
|
||||
font-size: 24rpx;
|
||||
padding: 8rpx 20rpx;
|
||||
border-radius: 12rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.rating {
|
||||
color: #f59e0b;
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.title {
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
color: #111827;
|
||||
margin-bottom: 20rpx;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.meta-row {
|
||||
display: flex;
|
||||
gap: 30rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
.meta-item {
|
||||
font-size: 24rpx;
|
||||
color: #6b7280;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.icon {
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
.section {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #1f2937;
|
||||
margin-bottom: 20rpx;
|
||||
border-left: 8rpx solid #2563eb;
|
||||
padding-left: 20rpx;
|
||||
}
|
||||
.desc {
|
||||
font-size: 28rpx;
|
||||
color: #4b5563;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.chapter-header {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #374151;
|
||||
margin: 30rpx 0 20rpx 0;
|
||||
background-color: #f3f4f6;
|
||||
padding: 10rpx 20rpx;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
.lesson-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #f3f4f6;
|
||||
}
|
||||
.lesson-info {
|
||||
flex: 1;
|
||||
}
|
||||
.lesson-title {
|
||||
font-size: 28rpx;
|
||||
color: #1f2937;
|
||||
margin-bottom: 6rpx;
|
||||
}
|
||||
.lesson-time {
|
||||
font-size: 22rpx;
|
||||
color: #9ca3af;
|
||||
}
|
||||
.play-btn {
|
||||
color: #2563eb;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
.lock-btn {
|
||||
color: #9ca3af;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.footer-bar {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: white;
|
||||
padding: 20rpx 40rpx;
|
||||
box-shadow: 0 -4rpx 10rpx rgba(0,0,0,0.05);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
z-index: 20;
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
.price {
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
color: #2563eb;
|
||||
}
|
||||
.enroll-btn {
|
||||
background-color: #2563eb;
|
||||
color: white;
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
padding: 20rpx 60rpx;
|
||||
border-radius: 50rpx;
|
||||
margin: 0;
|
||||
}
|
||||
78
wechat-mini-program/pages/index/index.js
Normal file
78
wechat-mini-program/pages/index/index.js
Normal file
@@ -0,0 +1,78 @@
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
projects: [],
|
||||
categories: [],
|
||||
userInfo: {},
|
||||
hasUserInfo: false,
|
||||
canIUse: wx.canIUse('button.open-type.getUserInfo'),
|
||||
canIUseGetUserProfile: false,
|
||||
canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
|
||||
},
|
||||
onLoad() {
|
||||
if (wx.getUserProfile) {
|
||||
this.setData({
|
||||
canIUseGetUserProfile: true
|
||||
})
|
||||
}
|
||||
this.fetchData();
|
||||
},
|
||||
fetchData() {
|
||||
const { request } = require('../../utils/request')
|
||||
|
||||
request({ url: '/projects' })
|
||||
.then((data) => {
|
||||
const list = Array.isArray(data) ? data : (data && data.results) || []
|
||||
this.setData({ projects: list })
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
this.setData({
|
||||
projects: [
|
||||
{
|
||||
id: 1,
|
||||
title: 'Python 数据分析实战',
|
||||
category: '编程开发',
|
||||
image:
|
||||
'https://images.unsplash.com/photo-1526379095098-d400fd0bf935?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3',
|
||||
students: 1205,
|
||||
rating: 4.8,
|
||||
duration: '12 周'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: '零基础英语口语速成',
|
||||
category: '语言学习',
|
||||
image:
|
||||
'https://images.unsplash.com/photo-1543269865-cbf427effbad?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3',
|
||||
students: 850,
|
||||
rating: 4.9,
|
||||
duration: '8 周'
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
request({ url: '/categories' })
|
||||
.then((data) => {
|
||||
const list = Array.isArray(data) ? data : data
|
||||
this.setData({ categories: list })
|
||||
})
|
||||
.catch(() => {
|
||||
this.setData({
|
||||
categories: [
|
||||
{ name: '全部', color: 'bg-blue-100 text-blue-600' },
|
||||
{ name: '编程', color: 'bg-orange-100 text-orange-600' },
|
||||
{ name: '设计', color: 'bg-purple-100 text-purple-600' }
|
||||
]
|
||||
})
|
||||
})
|
||||
},
|
||||
goToDetail(e) {
|
||||
const id = e.currentTarget.dataset.id;
|
||||
wx.navigateTo({
|
||||
url: `/pages/detail/detail?id=${id}`,
|
||||
})
|
||||
}
|
||||
})
|
||||
6
wechat-mini-program/pages/index/index.json
Normal file
6
wechat-mini-program/pages/index/index.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "首页",
|
||||
"navigationBarBackgroundColor": "#2563eb",
|
||||
"navigationBarTextStyle": "white",
|
||||
"usingComponents": {}
|
||||
}
|
||||
65
wechat-mini-program/pages/index/index.wxml
Normal file
65
wechat-mini-program/pages/index/index.wxml
Normal file
@@ -0,0 +1,65 @@
|
||||
<view class="page-container">
|
||||
<!-- Header -->
|
||||
<view class="header">
|
||||
<view class="header-content">
|
||||
<view>
|
||||
<view class="greeting">你好,学员</view>
|
||||
<view class="title">今天想学点什么?</view>
|
||||
</view>
|
||||
<view class="bell-btn">🔔</view>
|
||||
</view>
|
||||
|
||||
<!-- Search Bar -->
|
||||
<view class="search-bar">
|
||||
<icon type="search" size="16" color="#9ca3af"></icon>
|
||||
<input type="text" placeholder="搜索项目名称..." placeholder-class="search-placeholder"/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="content-body">
|
||||
<!-- Banner -->
|
||||
<view class="banner">
|
||||
<view>
|
||||
<view class="banner-title">热门实训项目</view>
|
||||
<view class="banner-desc">参与项目实战,提升就业能力</view>
|
||||
<view class="banner-btn">立即查看</view>
|
||||
</view>
|
||||
<view class="banner-circle"></view>
|
||||
</view>
|
||||
|
||||
<!-- Categories -->
|
||||
<view class="section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">热门分类</text>
|
||||
<text class="see-all">查看全部</text>
|
||||
</view>
|
||||
<scroll-view scroll-x="true" class="categories-scroll" enable-flex="true">
|
||||
<view class="categories-list">
|
||||
<block wx:for="{{categories}}" wx:key="name">
|
||||
<view class="category-item" style="background-color: {{index == 0 ? '#dbeafe' : (index == 1 ? '#ffedd5' : (index == 2 ? '#f3e8ff' : '#dcfce7'))}}; color: {{index == 0 ? '#2563eb' : (index == 1 ? '#ea580c' : (index == 2 ? '#9333ea' : '#16a34a'))}}">
|
||||
{{item.name}}
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- Projects -->
|
||||
<view class="projects-list">
|
||||
<block wx:for="{{projects}}" wx:key="id">
|
||||
<view class="project-card" bindtap="goToDetail" data-id="{{item.id}}">
|
||||
<image class="project-image" src="{{item.image}}" mode="aspectFill"></image>
|
||||
<view class="project-info">
|
||||
<view class="project-category-tag">{{item.category}}</view>
|
||||
<view class="project-title">{{item.title}}</view>
|
||||
<view class="project-meta">
|
||||
<view class="meta-item"><text class="icon">👥</text> {{item.students}}</view>
|
||||
<view class="meta-item"><text class="icon">⭐</text> {{item.rating}}</view>
|
||||
<view class="meta-item"><text class="icon">🕒</text> {{item.duration}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
224
wechat-mini-program/pages/index/index.wxss
Normal file
224
wechat-mini-program/pages/index/index.wxss
Normal file
@@ -0,0 +1,224 @@
|
||||
.page-container {
|
||||
padding-bottom: 50rpx;
|
||||
background-color: #f9fafb;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.header {
|
||||
background-color: #2563eb;
|
||||
padding: 40rpx 30rpx 80rpx 30rpx;
|
||||
border-bottom-left-radius: 40rpx;
|
||||
border-bottom-right-radius: 40rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.header-content {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.greeting {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: white;
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.bell-btn {
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
padding: 15rpx;
|
||||
border-radius: 50%;
|
||||
color: white;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
position: absolute;
|
||||
bottom: -40rpx;
|
||||
left: 30rpx;
|
||||
right: 30rpx;
|
||||
background-color: white;
|
||||
border-radius: 30rpx;
|
||||
padding: 20rpx 30rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.search-bar input {
|
||||
margin-left: 20rpx;
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.search-placeholder {
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.content-body {
|
||||
padding: 60rpx 30rpx 0 30rpx;
|
||||
}
|
||||
|
||||
.banner {
|
||||
background: linear-gradient(to right, #fb923c, #ef4444);
|
||||
border-radius: 30rpx;
|
||||
padding: 30rpx;
|
||||
color: white;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8rpx 16rpx rgba(239, 68, 68, 0.2);
|
||||
margin-bottom: 40rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.banner-circle {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 50%;
|
||||
position: absolute;
|
||||
right: -20rpx;
|
||||
bottom: -20rpx;
|
||||
filter: blur(20rpx);
|
||||
}
|
||||
|
||||
.banner-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.banner-desc {
|
||||
font-size: 24rpx;
|
||||
opacity: 0.9;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.banner-btn {
|
||||
background-color: white;
|
||||
color: #f97316;
|
||||
font-size: 24rpx;
|
||||
padding: 10rpx 24rpx;
|
||||
border-radius: 30rpx;
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.see-all {
|
||||
font-size: 24rpx;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.categories-scroll {
|
||||
white-space: nowrap;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.categories-list {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
padding: 16rpx 40rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 28rpx;
|
||||
margin-right: 20rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.projects-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 30rpx;
|
||||
}
|
||||
|
||||
.project-card {
|
||||
background-color: white;
|
||||
padding: 24rpx;
|
||||
border-radius: 30rpx;
|
||||
box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.05);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
.project-image {
|
||||
width: 192rpx;
|
||||
height: 192rpx;
|
||||
border-radius: 20rpx;
|
||||
flex-shrink: 0;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.project-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.project-category-tag {
|
||||
font-size: 20rpx;
|
||||
color: #3b82f6;
|
||||
background-color: #eff6ff;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 8rpx;
|
||||
display: inline-block;
|
||||
align-self: flex-start;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.project-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #1f2937;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.project-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
font-size: 20rpx;
|
||||
color: #9ca3af;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.icon {
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
58
wechat-mini-program/pages/profile/profile.js
Normal file
58
wechat-mini-program/pages/profile/profile.js
Normal file
@@ -0,0 +1,58 @@
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
user: {},
|
||||
formData: {
|
||||
name: '',
|
||||
phone: '',
|
||||
age: '',
|
||||
education: '',
|
||||
address: ''
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.fetchUser();
|
||||
},
|
||||
fetchUser() {
|
||||
const { request } = require('../../utils/request')
|
||||
request({ url: '/user' })
|
||||
.then((data) => {
|
||||
this.setData({ user: data })
|
||||
})
|
||||
.catch(() => {
|
||||
this.setData({
|
||||
user: {
|
||||
id: '8839201',
|
||||
name: '学员用户',
|
||||
avatar:
|
||||
'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=200&auto=format&fit=crop&q=60',
|
||||
stats: {
|
||||
learning: 12,
|
||||
coupons: 3,
|
||||
hours: 28
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
handleInput(e) {
|
||||
const field = e.currentTarget.dataset.field;
|
||||
const value = e.detail.value;
|
||||
this.setData({
|
||||
[`formData.${field}`]: value
|
||||
});
|
||||
},
|
||||
handleSubmit() {
|
||||
console.log(this.data.formData);
|
||||
wx.showToast({
|
||||
title: '保存成功',
|
||||
icon: 'success'
|
||||
})
|
||||
const { request } = require('../../utils/request')
|
||||
request({ url: '/user', method: 'POST', data: this.data.formData })
|
||||
.then((data) => {
|
||||
console.log(data)
|
||||
})
|
||||
}
|
||||
})
|
||||
3
wechat-mini-program/pages/profile/profile.json
Normal file
3
wechat-mini-program/pages/profile/profile.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "个人中心"
|
||||
}
|
||||
71
wechat-mini-program/pages/profile/profile.wxml
Normal file
71
wechat-mini-program/pages/profile/profile.wxml
Normal file
@@ -0,0 +1,71 @@
|
||||
<view class="container">
|
||||
<view class="profile-header">
|
||||
<view class="user-info">
|
||||
<image class="avatar" src="{{user.avatar}}" mode="aspectFill"></image>
|
||||
<view class="user-details">
|
||||
<view class="username">{{user.name}}</view>
|
||||
<view class="userid">ID: {{user.id}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="stats-card">
|
||||
<view class="stat-item">
|
||||
<view class="stat-val">{{user.stats.learning}}</view>
|
||||
<view class="stat-label">在学课程</view>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<view class="stat-val">{{user.stats.coupons}}</view>
|
||||
<view class="stat-label">优惠券</view>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<view class="stat-val">{{user.stats.hours}}h</view>
|
||||
<view class="stat-label">学习时长</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-section">
|
||||
<view class="form-title-bar">
|
||||
<view class="blue-line"></view>
|
||||
<text class="form-title">录入学员信息</text>
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="label">学员姓名</text>
|
||||
<view class="input-wrap">
|
||||
<input type="text" placeholder="请输入真实姓名" bindinput="handleInput" data-field="name" value="{{formData.name}}"/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="label">联系电话</text>
|
||||
<view class="input-wrap">
|
||||
<input type="number" placeholder="请输入手机号码" bindinput="handleInput" data-field="phone" value="{{formData.phone}}"/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-row">
|
||||
<view class="form-group half">
|
||||
<text class="label">年龄</text>
|
||||
<view class="input-wrap">
|
||||
<input type="number" placeholder="0" bindinput="handleInput" data-field="age" value="{{formData.age}}"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-group half">
|
||||
<text class="label">学历</text>
|
||||
<view class="input-wrap">
|
||||
<input type="text" placeholder="学历" bindinput="handleInput" data-field="education" value="{{formData.education}}"/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="label">居住地址</text>
|
||||
<view class="input-wrap">
|
||||
<input type="text" placeholder="请输入详细地址" bindinput="handleInput" data-field="address" value="{{formData.address}}"/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="submit-btn" bindtap="handleSubmit">保存信息</button>
|
||||
</view>
|
||||
</view>
|
||||
112
wechat-mini-program/pages/profile/profile.wxss
Normal file
112
wechat-mini-program/pages/profile/profile.wxss
Normal file
@@ -0,0 +1,112 @@
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
background-color: #f9fafb;
|
||||
}
|
||||
.profile-header {
|
||||
background-color: white;
|
||||
padding: 40rpx 40rpx 100rpx 40rpx;
|
||||
position: relative;
|
||||
margin-bottom: 60rpx;
|
||||
}
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 30rpx;
|
||||
}
|
||||
.avatar {
|
||||
width: 128rpx;
|
||||
height: 128rpx;
|
||||
border-radius: 50%;
|
||||
border: 4rpx solid white;
|
||||
box-shadow: 0 4rpx 10rpx rgba(0,0,0,0.1);
|
||||
background-color: #eee;
|
||||
}
|
||||
.user-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.username {
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
color: #1f2937;
|
||||
}
|
||||
.userid {
|
||||
font-size: 28rpx;
|
||||
color: #6b7280;
|
||||
}
|
||||
.stats-card {
|
||||
position: absolute;
|
||||
bottom: -40rpx;
|
||||
left: 40rpx;
|
||||
right: 40rpx;
|
||||
background-color: white;
|
||||
border-radius: 20rpx;
|
||||
box-shadow: 0 10rpx 30rpx rgba(0,0,0,0.05);
|
||||
padding: 30rpx;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
text-align: center;
|
||||
}
|
||||
.stat-val {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #1f2937;
|
||||
}
|
||||
.stat-label {
|
||||
font-size: 24rpx;
|
||||
color: #9ca3af;
|
||||
}
|
||||
.form-section {
|
||||
padding: 40rpx;
|
||||
background-color: white;
|
||||
margin: 0 30rpx 40rpx 30rpx;
|
||||
border-radius: 30rpx;
|
||||
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
|
||||
}
|
||||
.form-title-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 40rpx;
|
||||
gap: 16rpx;
|
||||
}
|
||||
.blue-line {
|
||||
width: 8rpx;
|
||||
height: 32rpx;
|
||||
background-color: #2563eb;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
.form-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #1f2937;
|
||||
}
|
||||
.form-group {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
.label {
|
||||
font-size: 24rpx;
|
||||
color: #6b7280;
|
||||
margin-bottom: 10rpx;
|
||||
display: block;
|
||||
}
|
||||
.input-wrap {
|
||||
background-color: #f9fafb;
|
||||
padding: 24rpx;
|
||||
border-radius: 20rpx;
|
||||
border: 2rpx solid #f3f4f6;
|
||||
}
|
||||
.form-row {
|
||||
display: flex;
|
||||
gap: 30rpx;
|
||||
}
|
||||
.half {
|
||||
flex: 1;
|
||||
}
|
||||
.submit-btn {
|
||||
background-color: #2563eb;
|
||||
color: white;
|
||||
border-radius: 20rpx;
|
||||
margin-top: 40rpx;
|
||||
font-weight: bold;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
61
wechat-mini-program/project.config.json
Normal file
61
wechat-mini-program/project.config.json
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"miniprogramRoot": "",
|
||||
"projectname": "edu-app",
|
||||
"description": "Edu App Mini Program",
|
||||
"appid": "wx2d9b9759137ef46b",
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"enhance": true,
|
||||
"postcss": true,
|
||||
"preloadBackgroundData": false,
|
||||
"minified": true,
|
||||
"newFeature": true,
|
||||
"coverView": true,
|
||||
"nodeModules": false,
|
||||
"autoAudits": false,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"scopeDataCheck": false,
|
||||
"uglifyFileName": false,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
"compileHotReLoad": false,
|
||||
"lazyloadPlaceholderEnable": false,
|
||||
"useMultiFrameRuntime": true,
|
||||
"useApiHook": true,
|
||||
"useApiHostProcess": true,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"enableEngineNative": false,
|
||||
"useIsolateContext": true,
|
||||
"userConfirmedBundleSwitch": false,
|
||||
"packNpmManually": false,
|
||||
"packNpmRelationList": [],
|
||||
"minifyWXSS": true,
|
||||
"compileWorklet": false,
|
||||
"minifyWXML": true,
|
||||
"localPlugins": false,
|
||||
"disableUseStrict": false,
|
||||
"useCompilerPlugins": false,
|
||||
"condition": false,
|
||||
"swc": false,
|
||||
"disableSWC": true
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.19.4",
|
||||
"srcMiniprogramRoot": "",
|
||||
"packOptions": {
|
||||
"ignore": [],
|
||||
"include": []
|
||||
},
|
||||
"editorSetting": {
|
||||
"tabIndent": "insertSpaces",
|
||||
"tabSize": 2
|
||||
},
|
||||
"condition": {},
|
||||
"simulatorPluginLibVersion": {}
|
||||
}
|
||||
24
wechat-mini-program/project.private.config.json
Normal file
24
wechat-mini-program/project.private.config.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"projectname": "wechat-mini-program",
|
||||
"setting": {
|
||||
"compileHotReLoad": true,
|
||||
"urlCheck": false,
|
||||
"coverView": true,
|
||||
"lazyloadPlaceholderEnable": false,
|
||||
"skylineRenderEnable": false,
|
||||
"preloadBackgroundData": false,
|
||||
"autoAudits": false,
|
||||
"useApiHook": true,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"useStaticServer": false,
|
||||
"useLanDebug": false,
|
||||
"showES6CompileOption": false,
|
||||
"checkInvalidKey": true,
|
||||
"ignoreDevUnusedFiles": true,
|
||||
"bigPackageSizeSupport": false,
|
||||
"useIsolateContext": true
|
||||
},
|
||||
"libVersion": "3.12.0",
|
||||
"condition": {}
|
||||
}
|
||||
25
wechat-mini-program/utils/request.js
Normal file
25
wechat-mini-program/utils/request.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const app = getApp()
|
||||
|
||||
function unwrap(data) {
|
||||
if (data && typeof data === 'object' && 'code' in data && 'data' in data) {
|
||||
return data.data
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
function request({ url, method = 'GET', data = {}, header = {} }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.request({
|
||||
url: `${app.globalData.baseUrl}${url.startsWith('/') ? '' : '/'}${url}`,
|
||||
method,
|
||||
data,
|
||||
header,
|
||||
success: (res) => {
|
||||
resolve(unwrap(res.data))
|
||||
},
|
||||
fail: (err) => reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { request }
|
||||
Reference in New Issue
Block a user