提交 bd09fba2 authored 作者: lihuihui's avatar lihuihui
...@@ -39,3 +39,7 @@ export function bindVisitor(data) { ...@@ -39,3 +39,7 @@ export function bindVisitor(data) {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' } headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}) })
} }
// 获取是否VIP
export function getIsVip() {
return httpRequest.get('/zy/user/is-vip')
}
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</van-checkbox-group> </van-checkbox-group>
</div> </div>
</div> </div>
<van-button type="primary" @click="onSubmit">确定</van-button> <van-button type="primary" :loading="submitLoading" @click="onSubmit">确定</van-button>
</div> </div>
</div> </div>
</template> </template>
...@@ -50,7 +50,8 @@ export default { ...@@ -50,7 +50,8 @@ export default {
status: 1 status: 1
}, },
weeks: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'], weeks: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
defaultIndex: 13 defaultIndex: 13,
submitLoading: false
} }
}, },
watch: { watch: {
...@@ -116,26 +117,38 @@ export default { ...@@ -116,26 +117,38 @@ export default {
const params = Object.assign({}, this.ruleForm) const params = Object.assign({}, this.ruleForm)
params.type = this.selectedResultType params.type = this.selectedResultType
params.week_json = JSON.stringify(this.ruleForm.week_json.sort()) params.week_json = JSON.stringify(this.ruleForm.week_json.sort())
api.addAlarm(params).then(response => { this.submitLoading = true
if (response.success) { api
this.handleSuccess(response) .addAlarm(params)
} else { .then(response => {
this.$toast(JSON.stringify(response.errors)) if (response.success) {
} this.handleSuccess(response)
}) } else {
this.$toast(JSON.stringify(response.errors))
}
})
.finally(() => {
this.submitLoading = false
})
}, },
// 更新 // 更新
handleUpdate() { handleUpdate() {
const params = Object.assign({}, this.ruleForm) const params = Object.assign({}, this.ruleForm)
params.type = this.selectedResultType params.type = this.selectedResultType
params.week_json = JSON.stringify(this.ruleForm.week_json.sort()) params.week_json = JSON.stringify(this.ruleForm.week_json.sort())
api.updateAlaram(params).then(response => { this.submitLoading = true
if (response.success) { api
this.handleSuccess(response) .updateAlaram(params)
} else { .then(response => {
this.$toast(JSON.stringify(response.errors)) if (response.success) {
} this.handleSuccess(response)
}) } else {
this.$toast(JSON.stringify(response.errors))
}
})
.finally(() => {
this.submitLoading = false
})
}, },
handleSuccess(response) { handleSuccess(response) {
this.$emit('success', response) this.$emit('success', response)
......
<template> <template>
<div class="main-list" v-show="loaded"> <div class="main-list" v-show="loaded">
<ul v-if="list.length"> <ul v-if="list.length && hasLearned">
<li v-for="item in list" :key="item.course_id" @click="onClick(item)"> <li v-for="item in list" :key="item.course_id" @click="onClick(item)">
<div class="name">{{item.course_name}}</div> <div class="name">{{item.course_name}}</div>
<div class="progress">{{item.video_progress | progressText}}</div> <div class="progress">{{item.video_progress | progressText}}</div>
</li> </li>
</ul> </ul>
<van-empty description="暂无内容" v-else /> <van-empty description="您还没有学习课程,快快开始学习吧!" v-else />
</div> </div>
</template> </template>
<script> <script>
...@@ -22,12 +22,22 @@ export default { ...@@ -22,12 +22,22 @@ export default {
computed: { computed: {
isWeapp() { isWeapp() {
return this.$store.state.isWeapp return this.$store.state.isWeapp
},
// 是否学习过
hasLearned() {
return !!this.list.find(item => item.video_progress)
} }
}, },
filters: { filters: {
progressText(value) { progressText(value) {
value = parseInt(value) value = parseInt(value)
return value === 100 ? '已学完' : `${value}%` if (value === 0) {
return '未开始'
}
if (value === 100) {
return '已学完'
}
return `已学${value}%`
} }
}, },
methods: { methods: {
......
<template> <template>
<div class="main-list" v-show="loaded"> <div class="main-list" v-show="loaded">
<ul v-if="list.length"> <ul v-if="list.length && hasLearned">
<li v-for="item in list" :key="item.course_id" @click="onClick(item)"> <li v-for="item in list" :key="item.course_id" @click="onClick(item)">
<div class="pic" v-if="item.picture"> <div class="pic" v-if="item.picture">
<img :src="item.picture" /> <img :src="item.picture" />
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<div class="progress">{{item.video_progress | progressText}}</div> <div class="progress">{{item.video_progress | progressText}}</div>
</li> </li>
</ul> </ul>
<van-empty description="暂无内容" v-else /> <van-empty description="您还没有学习课程,快快开始学习吧!" v-else />
</div> </div>
</template> </template>
<script> <script>
...@@ -25,12 +25,22 @@ export default { ...@@ -25,12 +25,22 @@ export default {
computed: { computed: {
isWeapp() { isWeapp() {
return this.$store.state.isWeapp return this.$store.state.isWeapp
},
// 是否学习过
hasLearned() {
return !!this.list.find(item => item.video_progress)
} }
}, },
filters: { filters: {
progressText(value) { progressText(value) {
value = parseInt(value) value = parseInt(value)
return value === 100 ? '已学完' : `${value}%` if (value === 0) {
return '未开始'
}
if (value === 100) {
return '已学完'
}
return `已学${value}%`
} }
}, },
methods: { methods: {
......
...@@ -3,7 +3,23 @@ ...@@ -3,7 +3,23 @@
<div class="learn-choose"> <div class="learn-choose">
<van-cell title="选择已学课程:" :value="selectedItem.name" is-link @click="popupVisible = true" /> <van-cell title="选择已学课程:" :value="selectedItem.name" is-link @click="popupVisible = true" />
</div> </div>
<buy-course-list v-if="selectedItem.type === 1" /> <!-- 已学课程 -->
<template v-if="selectedItem.type === 1">
<buy-course-list v-if="isVip" />
<template v-else>
<van-empty
image="https://zws-imgs-pub.ezijing.com/transport/weapp/empty.png"
description="快去开启课程学习,一起加油考证吧!"
class="custom-empty"
/>
<div class="fixed-box">
<div class="fixed-inner">
<div class="fixed-button" @click="toCourse">学更多课程</div>
</div>
</div>
</template>
</template>
<!-- 试题课程 -->
<free-course-list v-else /> <free-course-list v-else />
<van-popup <van-popup
v-model="popupVisible" v-model="popupVisible"
...@@ -44,6 +60,14 @@ export default { ...@@ -44,6 +60,14 @@ export default {
selectedItem: { type: 1, name: '课程学习' } selectedItem: { type: 1, name: '课程学习' }
} }
}, },
computed: {
isWeapp() {
return this.$store.state.isWeapp
},
isVip() {
return this.$store.state.isVip
}
},
methods: { methods: {
popupOpen() { popupOpen() {
this.changeSelected(this.selectedItem) this.changeSelected(this.selectedItem)
...@@ -59,7 +83,19 @@ export default { ...@@ -59,7 +83,19 @@ export default {
const found = this.chooseList.find(item => item.selected) const found = this.chooseList.find(item => item.selected)
this.selectedItem = found this.selectedItem = found
this.popupVisible = false this.popupVisible = false
},
toCourse(data) {
if (this.isWeapp) {
const url = `/pages/web/index?src=${window.location.origin}/course/learn`
wx.miniProgram.navigateTo({ url })
} else {
this.$router.push({ name: 'courseLearn' })
}
} }
},
beforeMount() {
// 检测是否是付费用户
this.$store.dispatch('checkIsVip')
} }
} }
</script> </script>
......
...@@ -2,14 +2,15 @@ import Vue from 'vue' ...@@ -2,14 +2,15 @@ import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import { getUser, logout } from '@/api/account' import { getUser, logout, getIsVip } from '@/api/account'
Vue.use(Vuex) Vue.use(Vuex)
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
isWeapp: /miniProgram/.test(navigator.userAgent), user: {},
isLogin: false,
token: '', token: '',
user: {} isVip: false,
isLogin: false,
isWeapp: /miniProgram/.test(navigator.userAgent)
}, },
mutations: { mutations: {
setToken(state, token) { setToken(state, token) {
...@@ -23,6 +24,9 @@ export default new Vuex.Store({ ...@@ -23,6 +24,9 @@ export default new Vuex.Store({
}, },
setIsLogin(state, isLogin) { setIsLogin(state, isLogin) {
state.isLogin = isLogin state.isLogin = isLogin
},
setIsVip(state, isVip) {
state.isVip = isVip
} }
}, },
actions: { actions: {
...@@ -57,6 +61,16 @@ export default new Vuex.Store({ ...@@ -57,6 +61,16 @@ export default new Vuex.Store({
commit('setIsLogin', false) commit('setIsLogin', false)
return response return response
}) })
},
async checkIsVip({ commit, state }) {
if (state.isVip) {
return state.isVip
}
const isVip = await getIsVip()
.then(response => response.is_vip)
.catch(() => false)
commit('setIsVip', isVip)
return isVip
} }
} }
}) })
...@@ -85,9 +85,8 @@ body { ...@@ -85,9 +85,8 @@ body {
font-size: 14px; font-size: 14px;
line-height: 1.4; line-height: 1.4;
color: #222; color: #222;
font-family: 'PingFang SC', 'Source Han Sans CN', -apple-system, font-family: 'PingFang SC', 'Source Han Sans CN', -apple-system, 'Microsoft YaHei', 'Helvetica', 'Arial', Verdana,
'Microsoft YaHei', 'Helvetica', 'Arial', Verdana, 'Hiragino Sans GB', 'Hiragino Sans GB', 'Wenquanyi Micro Hei', sans-serif;
'Wenquanyi Micro Hei', sans-serif;
background-color: #f7f7f7; background-color: #f7f7f7;
} }
.main-container { .main-container {
...@@ -138,3 +137,36 @@ body { ...@@ -138,3 +137,36 @@ body {
.van-swipe .van-swipe__indicators { .van-swipe .van-swipe__indicators {
bottom: 5px; bottom: 5px;
} }
.fixed-box {
height: 55px;
box-sizing: content-box;
padding-bottom: env(safe-area-inset-bottom);
}
.fixed-inner {
position: fixed;
left: 0;
right: 0;
bottom: 0;
max-width: 750px;
margin: 0 auto;
padding-bottom: env(safe-area-inset-bottom);
}
.fixed-button {
margin: 10px 20px;
height: 35px;
font-size: 15px;
line-height: 35px;
text-align: center;
color: #fff;
background: #c62245;
border-radius: 6px;
}
.custom-empty .van-empty__image {
width: 250px;
height: 205px;
}
.van-empty__description {
padding: 0 20px !important;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论