Browse Source

add all

master
刘嘉炜 4 years ago
parent
commit
5b34e689d6
  1. 5
      src/App.vue
  2. 4
      src/js/api.js
  3. 16
      src/js/server.js
  4. 6
      src/main.js
  5. 47
      src/pages/course/list/list.vue
  6. 48
      src/pages/index/index.vue
  7. 112
      src/pages/login/login.vue
  8. 43
      src/pages/store_list/store_list.vue
  9. BIN
      src/static/images/arrow_cff.png
  10. 28
      src/store/index.js
  11. 9
      src/store/mutations.js

5
src/App.vue

@ -8,6 +8,11 @@
}, },
onHide: function() { onHide: function() {
console.log('App Hide') console.log('App Hide')
},
methods: {
isLogin(){
return !!uni.getStorageSync('loginInfo');
}
} }
} }
</script> </script>

4
src/js/api.js

@ -5,6 +5,9 @@ export const ORIGIN = `http://kahing.local:9090`; // 本地测试
export const API = { export const API = {
coachLogin: `${ORIGIN}/stadium/coach/login`, // 小程序-账号登录 coachLogin: `${ORIGIN}/stadium/coach/login`, // 小程序-账号登录
getCoachCourseTimes: `${ORIGIN}/stadium/coach/getCoachCourseTimes`, // 小程序-账号登录 getCoachCourseTimes: `${ORIGIN}/stadium/coach/getCoachCourseTimes`, // 小程序-账号登录
getHomeData: `${ORIGIN}/stadium/coach/getHomeData`, // 小程序-获取教练主页的数据
saveFeedback: `${ORIGIN}/stadium/coach/saveFeedback`, // 小程序-保存教练反馈 saveFeedback: `${ORIGIN}/stadium/coach/saveFeedback`, // 小程序-保存教练反馈
coach_feedback: `${ORIGIN}/upload/file/coach_feedback`, // 上传文件 coach_feedback: `${ORIGIN}/upload/file/coach_feedback`, // 上传文件
@ -15,7 +18,6 @@ API['course'] = {
courseList: `${ORIGIN}/stadium/coach/courseList`, // 小程序-课程列表 courseList: `${ORIGIN}/stadium/coach/courseList`, // 小程序-课程列表
getClassList: `${ORIGIN}/stadium/coach/getClassList`, // 小程序-班级列表 getClassList: `${ORIGIN}/stadium/coach/getClassList`, // 小程序-班级列表
getCourseStudentList: `${ORIGIN}/stadium/coach/getCourseStudentList`, // 小程序-学员列表 getCourseStudentList: `${ORIGIN}/stadium/coach/getCourseStudentList`, // 小程序-学员列表
getCourseStudentList: `${ORIGIN}/stadium/coach/getCourseStudentList`, // 小程序-学员列表
SaveStudentComment: `${ORIGIN}/stadium/coach/SaveStudentComment`, // 小程序-学员点评保存 SaveStudentComment: `${ORIGIN}/stadium/coach/SaveStudentComment`, // 小程序-学员点评保存
courseList: `${ORIGIN}/stadium/coach/courseList`, // 小程序-课程列表 courseList: `${ORIGIN}/stadium/coach/courseList`, // 小程序-课程列表
} }

16
src/js/server.js

@ -1,6 +1,6 @@
import util from '../utils/util'; import util from '../utils/util';
// import { app as vm } from '../main'; // import { app as vm } from '../main';
const islog = true;
const islog = false;
export class Server { export class Server {
request(url,data,method,header,isDefaultGet,failMsg){ request(url,data,method,header,isDefaultGet,failMsg){
@ -9,8 +9,12 @@ export class Server {
// let storeInfo = _store.state.storeInfo || null; // let storeInfo = _store.state.storeInfo || null;
// if(storeInfo)data['brand_id'] = storeInfo.brand_id; // if(storeInfo)data['brand_id'] = storeInfo.brand_id;
const _loginInfo = uni.getStorageSync('loginInfo'); const _loginInfo = uni.getStorageSync('loginInfo');
if(_loginInfo || true){
if(!_loginInfo&&!data.isSkipCheck){
setTimeout(_=>util.routeTo(`/pages/login/login`, 'rL'), 10)
return Promise.reject('not logged in')
}
if(_loginInfo){
data = Object.assign({ data = Object.assign({
coach_token: _loginInfo.coach_token || '7a04dc20-62c0-11eb-8979-00e04c0166b9', coach_token: _loginInfo.coach_token || '7a04dc20-62c0-11eb-8979-00e04c0166b9',
brand_id: _loginInfo.brand_id || '63', brand_id: _loginInfo.brand_id || '63',
@ -24,6 +28,12 @@ export class Server {
method, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT method, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
header: {...header}, // 设置请求的 header // {'custom-header': 'application/json'} header: {...header}, // 设置请求的 header // {'custom-header': 'application/json'}
success: res=>{ success: res=>{
if(res.data.code == 10001){
util.showNone(res.data.message || '校验失败!')
setTimeout(_=>util.routeTo(`/pages/login/login`, 'rL'), 1200);
console.warn('校验失败---->', res);
return Promise.reject(res)
}
if(islog)console.log('req success---->',{ if(islog)console.log('req success---->',{
link: url, link: url,
query: data, query: data,

6
src/main.js

@ -1,11 +1,11 @@
import Vue from 'vue' import Vue from 'vue'
import App from './App' import App from './App'
import store from './store/index.js';
Vue.config.productionTip = false Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
const app = new Vue({ const app = new Vue({
...App
...App,
store
}) })
app.$mount() app.$mount()

47
src/pages/course/list/list.vue

@ -11,15 +11,18 @@
<view>{{e.name || '-'}}</view> <view>{{e.name || '-'}}</view>
<view>{{e.kind || '-'}}</view> <view>{{e.kind || '-'}}</view>
</view> </view>
<view class="ci-lines">
<view class="ci-lines" v-if="getCourseType(e.kind) === 0">
<text>班级数: </text>{{e.class_number || 0}} <text>班级数: </text>{{e.class_number || 0}}
</view> </view>
<view class="ci-lines"> <view class="ci-lines">
<text>学员人数: </text>{{e.join_person_number || 0}} <text>学员人数: </text>{{e.join_person_number || 0}}
</view> </view>
<view class="cl-btns"> <view class="cl-btns">
<view>预约上课</view>
<view>班级</view>
<block v-if="getCourseType(e.kind) === 0">
<view hover-class="hover-active" @click="orderCourseBtn">预约上课</view>
<view hover-class="hover-active" @click="toClass(e)">班级</view>
</block>
<view hover-class="hover-active" v-if="getCourseType(e.kind) === 1">详情</view>
</view> </view>
</view> </view>
<view class="cl-ex-item" v-if="curTabIdx == 1"> <view class="cl-ex-item" v-if="curTabIdx == 1">
@ -35,14 +38,14 @@
</block> </block>
</view> </view>
<view class="cl-mask" v-if="false">
<view class="cl-mask" v-if="isOrderCourseModal">
<view class="cl-modal"> <view class="cl-modal">
<view class="cm-line"> <view class="cm-line">
<view>选择班级</view> <view>选择班级</view>
<picker> <picker>
<view class="cl-frame"> <view class="cl-frame">
<input disabled placeholder="请选择班级" /> <input disabled placeholder="请选择班级" />
<image></image>
<image mode="aspectFit" src="/static/images/arrow_cb2.png"></image>
</view> </view>
</picker> </picker>
</view> </view>
@ -51,7 +54,7 @@
<picker mode="date"> <picker mode="date">
<view class="cl-frame"> <view class="cl-frame">
<input disabled placeholder="请选择日期" /> <input disabled placeholder="请选择日期" />
<image></image>
<image mode="aspectFit" src="/static/images/arrow_cb2.png"></image>
</view> </view>
</picker> </picker>
</view> </view>
@ -61,21 +64,21 @@
<picker mode="time"> <picker mode="time">
<view class="cc-frame"> <view class="cc-frame">
<input disabled placeholder="请选择时间"/> <input disabled placeholder="请选择时间"/>
<image></image>
<image mode="aspectFit" src="/static/images/arrow_cb2.png"></image>
</view> </view>
</picker> </picker>
<view>-</view> <view>-</view>
<picker mode="time"> <picker mode="time">
<view class="cc-frame"> <view class="cc-frame">
<input disabled placeholder="请选择时间"/> <input disabled placeholder="请选择时间"/>
<image></image>
<image mode="aspectFit" src="/static/images/arrow_cb2.png"></image>
</view> </view>
</picker> </picker>
</view> </view>
</view> </view>
<view class="cm-btns"> <view class="cm-btns">
<view hover-class="hover-active">取消</view>
<view hover-class="hover-active">确定</view>
<view hover-class="hover-active" @click="isOrderCourseModal = false">取消</view>
<view hover-class="hover-active" @click="isOrderCourseModal = false">确定</view>
</view> </view>
</view> </view>
</view> </view>
@ -87,17 +90,37 @@
import { API } from '../../../js/api' import { API } from '../../../js/api'
import { servers } from '../../../js/server' import { servers } from '../../../js/server'
import util from '../../../utils/util' import util from '../../../utils/util'
import { mapState } from 'vuex';
export default { export default {
computed: {
...mapState([ 'storeInfo' ]),
},
data(){ data(){
return { return {
curTabIdx: 0, curTabIdx: 0,
courseList: [], courseList: [],
isOrderCourseModal: false,
} }
}, },
onLoad(){ onLoad(){
this.getCourseList({}); this.getCourseList({});
}, },
methods: { methods: {
toClass(e){
console.warn(e);
let _query = {
course_id: e.id,
course_name: e.name,
}
util.routeTo(`/pages/course/class_list/class_list?query=${util.jsonStr(_query)}`, 'nT');
},
orderCourseBtn(){
this.isOrderCourseModal = true;
},
// (0)/(1);
getCourseType(type = ''){
return ['成班课', '私教课'].findIndex(e=>e===type);
},
tabChange: util.debounce(function(i){ tabChange: util.debounce(function(i){
this.curTabIdx = i; this.curTabIdx = i;
this.courseList = []; this.courseList = [];
@ -109,10 +132,12 @@ export default {
is_experience_class = 0, is_experience_class = 0,
kind = '', kind = '',
}){ }){
let { storeInfo } = this;
util.showLoad(); util.showLoad();
servers.get({ servers.get({
url: API.course.courseList, url: API.course.courseList,
data: { data: {
stadium_id: storeInfo.id,
is_experience_class, is_experience_class,
kind, kind,
}, },
@ -311,7 +336,6 @@ export default {
flex-shrink: 0; flex-shrink: 0;
width: 28upx; width: 28upx;
height: 28upx; height: 28upx;
background-color: skyblue;
} }
} }
.cl-content{ .cl-content{
@ -340,7 +364,6 @@ export default {
flex-shrink: 0; flex-shrink: 0;
width: 28upx; width: 28upx;
height: 28upx; height: 28upx;
background-color: skyblue;
} }
} }

48
src/pages/index/index.vue

@ -1,11 +1,16 @@
<template> <template>
<view class="index-container"> <view class="index-container">
<view class="ic-header"> <view class="ic-header">
<button hover-class="hover-active" @click="toLogin">前往登录</button>
<!-- <view class="ih-store-name">
<view>广州欧轩智能场馆(共6家)</view>
<image></image>
</view> -->
<button v-if="!isLogin" hover-class="hover-acti ve" @click="toLogin">前往登录</button>
<view v-else class="ih-store-name">
<view
@click="toStoreList"
>
{{storeInfo.name || '-'}}
<text v-if="indexData.stadium_data">({{indexData.stadium_data.length}})</text>
</view>
<image mode="aspectFit" src="/static/images/arrow_cff.png"></image>
</view>
<view class="ih-tip">本月课时</view> <view class="ih-tip">本月课时</view>
<view class="ih-num">{{ course_times || 0 }}</view> <view class="ih-num">{{ course_times || 0 }}</view>
</view> </view>
@ -37,9 +42,11 @@
</template> </template>
<script> <script>
import authorize_modal from '../../components/authorize_modal/authorize_modal'; import authorize_modal from '../../components/authorize_modal/authorize_modal';
import { API } from '../../js/api';
import { servers } from '../../js/server';
import util from '../../utils/util';
import { API } from '../../js/api';
import { servers } from '../../js/server';
import util from '../../utils/util';
const app = getApp();
import { mapState } from 'vuex';
const tabInfoArr = [ const tabInfoArr = [
{ {
id: '1', id: '1',
@ -83,16 +90,25 @@ import util from '../../utils/util';
components: { components: {
'authorize-modal': authorize_modal 'authorize-modal': authorize_modal
}, },
computed: {
...mapState([ 'storeInfo' ]),
},
data(){ data(){
return { return {
isLogin: app.isLogin(),
tabInfoArr, tabInfoArr,
course_times: 0, // course_times: 0, //
indexData: {},
} }
}, },
onLoad(){ onLoad(){
this.getCoachCourseTimes(); this.getCoachCourseTimes();
this.getHomeData();
}, },
methods: { methods: {
toStoreList(){
util.routeTo('/pages/store_list/store_list', 'nT');
},
getCoachCourseTimes(){ getCoachCourseTimes(){
servers.get({ servers.get({
url: API.getCoachCourseTimes, url: API.getCoachCourseTimes,
@ -104,10 +120,24 @@ import util from '../../utils/util';
this.course_times = res.course_times this.course_times = res.course_times
}) })
}, },
getHomeData(){
util.showLoad();
servers.get({
url: API.getHomeData,
data: {},
failMsg: '加载失败!'
})
.then(res=>{
util.hideLoad();
this.indexData = res;
let _storeList = res.stadium_data || [];
// return console.warn(this.$store)
if(_storeList.length)this.$store.commit('setStoreInfo', _storeList[0])
})
},
tabClick(e){ tabClick(e){
if(e.path === '')return util.showNone('开发中'); if(e.path === '')return util.showNone('开发中');
util.routeTo(e.path, 'nT'); util.routeTo(e.path, 'nT');
console.warn(e);
}, },
toLogin(){ toLogin(){
util.routeTo(`/pages/login/login`, 'nT'); util.routeTo(`/pages/login/login`, 'nT');

112
src/pages/login/login.vue

@ -57,74 +57,80 @@ export default {
account, account,
password, password,
brand_id, brand_id,
isSkipCheck: true
}, },
isDefaultGet: false isDefaultGet: false
}) })
.then(res=>{ .then(res=>{
if(res.data.code == 0){ if(res.data.code == 0){
util.showNone('登陆成功!');
uni.setStorageSync('loginInfo', res.data.data || {});
setTimeout(_=>{
util.routeTo(`/pages/index/index`, 'rL');
}, 1200)
console.warn(res); console.warn(res);
}else{ }else{
util.showNone(res.data.message || '操作失败!'); util.showNone(res.data.message || '操作失败!');
} }
console.log(res);
}) })
.catch(util.hideLoad)
}, },
async submitBtn(userRes){
try{
util.showLoad();
if(!userRes.detail.userInfo){
util.hideLoad();
return util.showNone('获取用户信息失败!请稍后重试');
}
// async submitBtn(userRes){
// try{
// util.showLoad();
// if(!userRes.detail.userInfo){
// util.hideLoad();
// return util.showNone('');
// }
let loginRes = await uniLogin();
// let loginRes = await uniLogin();
if(!loginRes.code){
util.hideLoad();
return util.showNone('获取登陆凭证失败!稍后重试');
}
let userInfo = userRes.detail || {};
console.log(userRes)
let { formData } = this;
servers.post({
url: API.WechatMiniApplogin,
data: {
appid: APPID,
code: loginRes.code,
encryptedData: userInfo.encryptedData,
// is_details: 1,
//
user_info: userInfo.userInfo,
user_raw_data: userInfo.rawData,
...userInfo.userInfo,
username: formData.account,
password: formData.password,
brand_id: formData.brand_id,
},
isDefaultGet: false,
})
.then(res=>{
util.hideLoad();
let _data = res.data || {};
if(_data.code == 0){
util.showNone(_data.message || '操作成功!');
uni.setStorageSync('token',_data.data);
setTimeout(_=>{
util.routeTo(`/pages/index/index`, 'rL');
}, 1200);
}else{
util.showNone(_data.message || '操作失败!');
}
// if(!loginRes.code){
// util.hideLoad();
// return util.showNone('');
// }
// let userInfo = userRes.detail || {};
// console.log(userRes)
// let { formData } = this;
// servers.post({
// url: API.WechatMiniApplogin,
// data: {
// appid: APPID,
// code: loginRes.code,
// encryptedData: userInfo.encryptedData,
// // is_details: 1,
// //
// user_info: userInfo.userInfo,
// user_raw_data: userInfo.rawData,
// ...userInfo.userInfo,
// username: formData.account,
// password: formData.password,
// brand_id: formData.brand_id,
// },
// isDefaultGet: false,
// })
// .then(res=>{
// util.hideLoad();
// let _data = res.data || {};
// if(_data.code == 0){
// util.showNone(_data.message || '');
// console.warn(_data)
// uni.setStorageSync('loginInfo', _data.data);
// setTimeout(_=>{
// util.routeTo(`/pages/index/index`, 'rL');
// }, 1200);
// }else{
// util.showNone(_data.message || '');
// }
})
.catch(util.hideLoad)
}catch(err){
util.hideLoad();
console.warn('login err', err);
}
},
// })
// .catch(util.hideLoad)
// }catch(err){
// util.hideLoad();
// console.warn('login err', err);
// }
// },
toWebView(){ toWebView(){
util.routeTo(`/pages/web_view/web_view`,'rL'); util.routeTo(`/pages/web_view/web_view`,'rL');
} }

43
src/pages/store_list/store_list.vue

@ -1,22 +1,53 @@
<template> <template>
<view class="store-list"> <view class="store-list">
<view class="sl-item" v-for="i in 10" :key="i">
<image class="si-logo"></image>
<view class="sl-item" v-for="(e, i) in courseList" :key="i">
<image class="si-logo" mode="aspectFit" :src="e.logo || ''"></image>
<view class="si-content"> <view class="si-content">
<view class="sc-top"> <view class="sc-top">
<view>欧轩智能场馆(羽毛球永泰店)</view>
<image></image>
<view>{{e.name || '-'}}</view>
<image mode="aspectFit" src="/static/images/arrow_cb2.png"></image>
</view>
<!-- 20210131 pm: 去掉 营业状态-->
<!-- 0/1 -->
<view :class="['sc-tag', e.is_business == 1?'':'active']">
<text>
{{ e.is_business == 1 ?'正常营业':'暂停营业' }}
</text>
</view> </view>
<view :class="['sc-tag', i==2?'active':'']"><text>正常营业</text></view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import { API } from '../../js/api'
import { servers } from '../../js/server'
import util from '../../utils/util'
export default { export default {
data(){
return {
courseList: [],
}
},
onLoad(){
this.getHomeData();
},
methods: {
getHomeData(){
servers.get({
url: API.getHomeData,
data: {},
failMsg: '加载失败!'
})
.then(res=>{
let _list = res.stadium_data || [];
this.courseList = _list;
console.warn(res, 1231321321321321313)
})
},
}
} }
</script> </script>
@ -41,7 +72,6 @@ export default {
height: 100upx; height: 100upx;
border-radius: 50%; border-radius: 50%;
border: 2upx solid #D8D8D8; border: 2upx solid #D8D8D8;
background-color: skyblue;
} }
.si-content{ .si-content{
flex-grow: 1; flex-grow: 1;
@ -66,7 +96,6 @@ export default {
flex-grow: 0; flex-grow: 0;
height: 32upx; height: 32upx;
width: 32upx; width: 32upx;
background-color: skyblue;
} }
} }
.sc-tag{ .sc-tag{

BIN
src/static/images/arrow_cff.png

After

Width: 40  |  Height: 40  |  Size: 333 B

28
src/store/index.js

@ -10,32 +10,8 @@ export default new Vuex.Store({
// device // device
}, },
state: { state: {
// // #ifdef H5
// APPID: uni.getAccountInfoSync().miniProgram.appId,
// // #endif
// brandInfo: {
// brand: {}
// },
// permissionObj: { // 权限代号对应
// '1001': '营业额',
// '1002': '收款记录',
// '1003': '经营分析',
// '1004': '预约订单',
// '1005': '会员卡订单',
// '1006': '积分订单',
// '1007': '员工管理',
// '1008': '查询核销',
// '1009': '场地管理',
// '1010': '设备管理',
// },
// // 场地占用提交页面信息
// occupyInfo: {
// storeInfo: {}, // 店铺信息
// dateInfo: {}, // 时间信息
// typeInfo: {}, // 球场类型
// venueList: [], // 选择场地列表
// }
// 当前小程序店铺信息
storeInfo: {},
}, },
mutations, mutations,
actions, actions,

9
src/store/mutations.js

@ -2,11 +2,10 @@
export default { export default {
// // 设置品牌信息
// setBrandInfo(state, brandInfo){
// // console.log(storeInfo,'-----')
// state.brandInfo = brandInfo
// },
// 设置店铺信息
setStoreInfo(state, storeInfo){
state.storeInfo = storeInfo
},
// // 场地占用信息 // // 场地占用信息
// setOccupyInfo(state, _occupyInfo){ // setOccupyInfo(state, _occupyInfo){

Loading…
Cancel
Save