Browse Source

add api

master
刘嘉炜 4 years ago
parent
commit
ef15949d59
  1. 12
      src/js/api.js
  2. 14
      src/js/server.js
  3. 96
      src/pages/course/list/list.vue
  4. 88
      src/pages/index/index.vue
  5. 35
      src/pages/login/login.vue
  6. 9
      src/pages/message_list/message_list.vue
  7. BIN
      src/static/images/arrow_cb2.png
  8. BIN
      src/static/images/index/feedback_c874.png
  9. BIN
      src/static/images/index/i_1.png
  10. BIN
      src/static/images/index/i_2.png
  11. BIN
      src/static/images/index/i_3.png
  12. BIN
      src/static/images/index/i_4.png
  13. BIN
      src/static/images/index/i_5.png
  14. BIN
      src/static/images/index/i_6.png
  15. BIN
      src/static/images/index/i_7.png
  16. BIN
      src/static/images/index/notice_c874.png
  17. BIN
      src/static/images/logo.png

12
src/js/api.js

@ -1,8 +1,14 @@
export const ORIGIN = ``; // 测试
// export const ORIGIN = ``; // 正式
export const ORIGIN = `https://test.ouxuanzhineng.cn`; // 测试
// export const ORIGIN = `https://coach.ouxuanzhineng.cn`; // 正式
export const API = {
ex: `${ORIGIN}/test/test`,
coachLogin: `${ORIGIN}/stadium/coach/login`, // 小程序-账号登录
saveFeedback: `${ORIGIN}/stadium/coach/saveFeedback`, // 小程序-保存教练反馈
}
API['course'] = {
courseList: `${ORIGIN}/stadium/coach/courseList`, // 小程序-课程列表
}

14
src/js/server.js

@ -4,14 +4,20 @@ const islog = true;
export class Server {
request(url,data,method,header,isDefaultGet,failMsg){
return new Promise(async (rs,rj)=>{
return new Promise(async (rs,rj)=>{
// const _store = vm.$store;
// let storeInfo = _store.state.storeInfo || null;
// if(storeInfo)data['brand_id'] = storeInfo.brand_id;
const _loginInfo = uni.getStorageSync('loginInfo');
if(_loginInfo || true){
data = Object.assign({
coach_token: _loginInfo.coach_token || '0c30100d-5ba8-11eb-9029-5254005df464',
brand_id: _loginInfo.brand_id || '63',
}, data);
}
const _token = uni.getStorageSync('token') || '';
if(_token)data['token'] = _token;
if(method === 'POST'&&_token)url = url + `?token=${_token}`
// if(method === 'POST'&&_loginInfo)url = url + `?coach_token=${_loginInfo.coach_token}`
uni.request({
url,
data,

96
src/pages/course/list/list.vue

@ -1,36 +1,39 @@
<template>
<view class="course-list">
<view class="cl-tab">
<view>正式课</view>
<view class="active">体验课</view>
<view :class="[curTabIdx == 0?'active':'']" @click="tabChange(0)">正式课</view>
<view :class="[curTabIdx == 1?'active':'']" @click="tabChange(1)">体验课</view>
</view>
<view class="cl-list">
<view class="cl-item" v-for="i in 2" :key="i">
<view class="ci-name">
<view>羽毛球课包学会(带体验课)</view>
<view>训练课</view>
</view>
<view class="ci-lines">
<text>班级数: </text>10
</view>
<view class="ci-lines">
<text>班级数: </text>10
</view>
<view class="cl-btns">
<view>预约上课</view>
<view>班级</view>
</view>
</view>
<view class="cl-ex-item">
<view class="ei-tit">
<view>羽毛球课包学会(带体验课)</view>
<view>预约中</view>
<block v-for="(e, i) in courseList" :key="i">
<view class="cl-item" v-if="curTabIdx == 0">
<view class="ci-name">
<view>{{e.name || '-'}}</view>
<view>{{e.kind || '-'}}</view>
</view>
<view class="ci-lines">
<text>班级数: </text>{{e.class_number || 0}}
</view>
<view class="ci-lines">
<text>学员人数: </text>{{e.join_person_number || 0}}
</view>
<view class="cl-btns">
<view>预约上课</view>
<view>班级</view>
</view>
</view>
<view class="ei-line"><text>预约人数:</text>20</view>
<view class="ei-btns">
<view hover-class="hover-active">查看详情</view>
<view class="cl-ex-item" v-if="curTabIdx == 1">
<view class="ei-tit">
<view>{{e.name || '-'}}</view>
<view>预约中</view>
</view>
<view class="ei-line"><text>预约人数:</text>{{e.experience_person_number || 0}}</view>
<view class="ei-btns">
<view hover-class="hover-active">查看详情</view>
</view>
</view>
</view>
</block>
</view>
<view class="cl-mask" v-if="false">
<view class="cl-modal">
@ -81,8 +84,49 @@
</template>
<script>
import { API } from '../../../js/api'
import { servers } from '../../../js/server'
import util from '../../../utils/util'
export default {
data(){
return {
curTabIdx: 0,
courseList: [],
}
},
onLoad(){
this.getCourseList({});
},
methods: {
tabChange: util.debounce(function(i){
this.curTabIdx = i;
this.getCourseList({
is_experience_class: i
})
},300,300),
getCourseList({
is_experience_class = 0,
kind = '',
}){
util.showLoad();
servers.get({
url: API.course.courseList,
data: {
is_experience_class,
kind,
},
failMsg: '加载失败!'
})
.then(res=>{
util.hideLoad();
let _list = res.list || [];
if(_list.length<=0)return util.showNone('没有更多!');
console.warn(res);
})
.catch(util.hideLoad)
}
}
}
</script>

88
src/pages/index/index.vue

@ -1,52 +1,108 @@
<template>
<view class="index-container">
<view class="ic-header">
<!-- <button hover-class="hover-active">前往登录</button> -->
<view class="ih-store-name">
<button hover-class="hover-active" @click="toLogin">前往登录</button>
<!-- <view class="ih-store-name">
<view>广州欧轩智能场馆(共6家)</view>
<image></image>
</view>
</view> -->
<view class="ih-tip">本月课时</view>
<view class="ih-num">0</view>
</view>
<view class="ic-notice">
<view class="ic-notice" @click="toNotice">
<view class="in-left">
<image></image>
<image mode="aspectFit" src="/static/images/index/notice_c874.png"></image>
<text>欧轩智能场馆商家助手上线啦</text>
</view>
<view class="in-right">
<view>99</view>
<image></image>
<image mode="aspectFit" src="/static/images/arrow_cb2.png"></image>
</view>
</view>
<view class="ic-tab-section">
<view class="its-item" v-for="e in 8" :key="e">
<image></image>
<view>我的课程</view>
<view class="its-item" v-for="(e, i) in tabInfoArr" :key="i" @click="tabClick(e)">
<image mode="aspectFit" :src="`/static/images/index/i_${e.id}.png`"></image>
<view>{{e.name || '-'}}</view>
</view>
</view>
<view class="ic-feedback">
<view class="ic-feedback" @click="toFeedback">
<view class="if-right">
<image></image>
<image mode="aspectFit" src="/static/images/index/feedback_c874.png"></image>
<text>在线反馈</text>
</view>
<image></image>
<image mode="aspectFit" src="/static/images/arrow_cb2.png"></image>
</view>
<authorize-modal v-if="false"></authorize-modal>
</view>
</template>
<script>
import authorize_modal from '../../components/authorize_modal/authorize_modal';
import util from '../../utils/util';
const tabInfoArr = [
{
id: '1',
name: '我的课程',
path: '/pages/course/list/list',
},
{
id: '2',
name: '我的时间',
path: '',
},
{
id: '3',
name: '我的学员',
path: '',
},
{
id: '4',
name: '场地管理',
path: '',
},
{
id: '5',
name: '审批',
path: '',
},
{
id: '6',
name: '点名',
path: '',
},
{
id: '7',
name: '换班申请',
path: '',
},
];
export default {
components: {
'authorize-modal': authorize_modal
},
data(){
return {
tabInfoArr,
}
},
onLoad(){
},
methods: {
tabClick(e){
if(e.path === '')return util.showNone('开发中');
util.routeTo(e.path, 'nT');
console.warn(e);
},
toLogin(){
util.routeTo(`/pages/login/login`, 'nT');
},
toNotice(){
util.routeTo(`/pages/message_list/message_list`,'nT');
},
toFeedback(){
util.routeTo(`/pages/feedback/feedback`,'nT');
}
}
}
</script>
@ -92,7 +148,6 @@
margin-left: 20upx;
width: 28upx;
height: 28upx;
background-color: skyblue;
}
}
.ih-tip{
@ -132,7 +187,6 @@
width: 52upx;
height: 52upx;
margin-right: 10upx;
background-color: skyblue;
}
}
@ -154,7 +208,6 @@
flex-shrink: 0;
width: 28upx;
height: 28upx;
background-color: skyblue;
}
}
}
@ -168,7 +221,6 @@
width: 33.33%;
height: auto;
>image{
background-color: skyblue;
margin: 0 auto 20upx;
display: block;
width: 52upx;
@ -199,7 +251,6 @@
margin-right: 16upx;
width: 52upx;
height: 52upx;
background-color: skyblue;
}
}
>image{
@ -207,7 +258,6 @@
flex-grow: 0;
width: 28upx;
height: 28upx;
background-color: skyblue;
}
}

35
src/pages/login/login.vue

@ -1,7 +1,9 @@
<template>
<view class="login-container">
<view class="lc-header">
<view class="lh-logo"></view>
<view class="lh-logo">
<image mode="aspectFit" src="/static/images/logo.png"></image>
</view>
<view class="lh-name">欧轩智能场馆</view>
</view>
<view class="lc-form">
@ -9,14 +11,19 @@
<view class="lf-frame"><input placeholder="请输入账号" v-model="formData.account" /></view>
<view class="lf-frame"><input placeholder="请输入密码" v-model="formData.password" password /></view>
</view>
<button
class="lf-btn"
hover-class="hover-active"
@click="_submitBtn"
>登录</button>
<!-- <button
class="lf-btn"
hover-class="hover-active"
open-type="getUserInfo"
lang="zh_CN"
@getuserinfo="submitBtn"
>登录</button>
>登录</button> -->
<!-- <view class="lf-tip">提示请联系管理员添加您为员工账号</view>
<view class="lf-bot-btn" @click="toWebView">成为商家</view> -->
@ -41,6 +48,28 @@ export default {
}
},
methods: {
_submitBtn(){
console.log(this.formData);
let { brand_id, account, password } = this.formData;
servers.post({
url: API.coachLogin,
data:{
account,
password,
brand_id,
},
isDefaultGet: false
})
.then(res=>{
if(res.data.code == 0){
console.warn(res);
}else{
util.showNone(res.data.message || '操作失败!');
}
console.log(res);
})
},
async submitBtn(userRes){
try{
util.showLoad();

9
src/pages/message_list/message_list.vue

@ -1,6 +1,6 @@
<template>
<view class="message-list">
<view class="ml-item" v-for="i in 10" :key="i">
<view class="ml-item" v-for="i in 10" :key="i" @click="toNoticeInfo">
<view class="mi-tit">
<view class="mt-name" >
<view :class="[i==5?'active':'']">欧轩智能商家助手功能更新</view>
@ -16,8 +16,13 @@
</template>
<script>
import util from '../../utils/util'
export default {
methods: {
toNoticeInfo(){
util.routeTo(`/pages/message_info/message_info`,'nT');
}
}
}
</script>

BIN
src/static/images/arrow_cb2.png

After

Width: 28  |  Height: 28  |  Size: 219 B

BIN
src/static/images/index/feedback_c874.png

After

Width: 52  |  Height: 52  |  Size: 432 B

BIN
src/static/images/index/i_1.png

After

Width: 52  |  Height: 52  |  Size: 294 B

BIN
src/static/images/index/i_2.png

After

Width: 52  |  Height: 52  |  Size: 514 B

BIN
src/static/images/index/i_3.png

After

Width: 52  |  Height: 52  |  Size: 447 B

BIN
src/static/images/index/i_4.png

After

Width: 52  |  Height: 52  |  Size: 705 B

BIN
src/static/images/index/i_5.png

After

Width: 52  |  Height: 52  |  Size: 476 B

BIN
src/static/images/index/i_6.png

After

Width: 52  |  Height: 52  |  Size: 374 B

BIN
src/static/images/index/i_7.png

After

Width: 52  |  Height: 52  |  Size: 461 B

BIN
src/static/images/index/notice_c874.png

After

Width: 52  |  Height: 52  |  Size: 452 B

BIN
src/static/images/logo.png

After

Width: 168  |  Height: 168  |  Size: 2.7 KiB

Loading…
Cancel
Save