提交 bd09fba2 authored 作者: lihuihui's avatar lihuihui
......@@ -39,3 +39,7 @@ export function bindVisitor(data) {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
}
// 获取是否VIP
export function getIsVip() {
return httpRequest.get('/zy/user/is-vip')
}
......@@ -23,7 +23,7 @@
</van-checkbox-group>
</div>
</div>
<van-button type="primary" @click="onSubmit">确定</van-button>
<van-button type="primary" :loading="submitLoading" @click="onSubmit">确定</van-button>
</div>
</div>
</template>
......@@ -50,7 +50,8 @@ export default {
status: 1
},
weeks: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
defaultIndex: 13
defaultIndex: 13,
submitLoading: false
}
},
watch: {
......@@ -116,26 +117,38 @@ export default {
const params = Object.assign({}, this.ruleForm)
params.type = this.selectedResultType
params.week_json = JSON.stringify(this.ruleForm.week_json.sort())
api.addAlarm(params).then(response => {
this.submitLoading = true
api
.addAlarm(params)
.then(response => {
if (response.success) {
this.handleSuccess(response)
} else {
this.$toast(JSON.stringify(response.errors))
}
})
.finally(() => {
this.submitLoading = false
})
},
// 更新
handleUpdate() {
const params = Object.assign({}, this.ruleForm)
params.type = this.selectedResultType
params.week_json = JSON.stringify(this.ruleForm.week_json.sort())
api.updateAlaram(params).then(response => {
this.submitLoading = true
api
.updateAlaram(params)
.then(response => {
if (response.success) {
this.handleSuccess(response)
} else {
this.$toast(JSON.stringify(response.errors))
}
})
.finally(() => {
this.submitLoading = false
})
},
handleSuccess(response) {
this.$emit('success', response)
......
<template>
<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)">
<div class="name">{{item.course_name}}</div>
<div class="progress">{{item.video_progress | progressText}}</div>
</li>
</ul>
<van-empty description="暂无内容" v-else />
<van-empty description="您还没有学习课程,快快开始学习吧!" v-else />
</div>
</template>
<script>
......@@ -22,12 +22,22 @@ export default {
computed: {
isWeapp() {
return this.$store.state.isWeapp
},
// 是否学习过
hasLearned() {
return !!this.list.find(item => item.video_progress)
}
},
filters: {
progressText(value) {
value = parseInt(value)
return value === 100 ? '已学完' : `${value}%`
if (value === 0) {
return '未开始'
}
if (value === 100) {
return '已学完'
}
return `已学${value}%`
}
},
methods: {
......
<template>
<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)">
<div class="pic" v-if="item.picture">
<img :src="item.picture" />
......@@ -9,7 +9,7 @@
<div class="progress">{{item.video_progress | progressText}}</div>
</li>
</ul>
<van-empty description="暂无内容" v-else />
<van-empty description="您还没有学习课程,快快开始学习吧!" v-else />
</div>
</template>
<script>
......@@ -25,12 +25,22 @@ export default {
computed: {
isWeapp() {
return this.$store.state.isWeapp
},
// 是否学习过
hasLearned() {
return !!this.list.find(item => item.video_progress)
}
},
filters: {
progressText(value) {
value = parseInt(value)
return value === 100 ? '已学完' : `${value}%`
if (value === 0) {
return '未开始'
}
if (value === 100) {
return '已学完'
}
return `已学${value}%`
}
},
methods: {
......
......@@ -3,7 +3,23 @@
<div class="learn-choose">
<van-cell title="选择已学课程:" :value="selectedItem.name" is-link @click="popupVisible = true" />
</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 />
<van-popup
v-model="popupVisible"
......@@ -44,6 +60,14 @@ export default {
selectedItem: { type: 1, name: '课程学习' }
}
},
computed: {
isWeapp() {
return this.$store.state.isWeapp
},
isVip() {
return this.$store.state.isVip
}
},
methods: {
popupOpen() {
this.changeSelected(this.selectedItem)
......@@ -59,8 +83,20 @@ export default {
const found = this.chooseList.find(item => item.selected)
this.selectedItem = found
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>
......
......@@ -2,14 +2,15 @@ import Vue from 'vue'
import Vuex from 'vuex'
import Cookies from 'js-cookie'
import { getUser, logout } from '@/api/account'
import { getUser, logout, getIsVip } from '@/api/account'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
isWeapp: /miniProgram/.test(navigator.userAgent),
isLogin: false,
user: {},
token: '',
user: {}
isVip: false,
isLogin: false,
isWeapp: /miniProgram/.test(navigator.userAgent)
},
mutations: {
setToken(state, token) {
......@@ -23,6 +24,9 @@ export default new Vuex.Store({
},
setIsLogin(state, isLogin) {
state.isLogin = isLogin
},
setIsVip(state, isVip) {
state.isVip = isVip
}
},
actions: {
......@@ -57,6 +61,16 @@ export default new Vuex.Store({
commit('setIsLogin', false)
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 {
font-size: 14px;
line-height: 1.4;
color: #222;
font-family: 'PingFang SC', 'Source Han Sans CN', -apple-system,
'Microsoft YaHei', 'Helvetica', 'Arial', Verdana, 'Hiragino Sans GB',
'Wenquanyi Micro Hei', sans-serif;
font-family: 'PingFang SC', 'Source Han Sans CN', -apple-system, 'Microsoft YaHei', 'Helvetica', 'Arial', Verdana,
'Hiragino Sans GB', 'Wenquanyi Micro Hei', sans-serif;
background-color: #f7f7f7;
}
.main-container {
......@@ -138,3 +137,36 @@ body {
.van-swipe .van-swipe__indicators {
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论