提交 9f017995 authored 作者: 王鹏飞's avatar 王鹏飞

fix:提交增加loading

上级 d6d93a5e
...@@ -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)
......
...@@ -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), isWeapp: /miniProgram/.test(navigator.userAgent),
isLogin: false, isLogin: false,
token: '', token: '',
user: {} user: {},
isVip: false
}, },
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,17 @@ export default new Vuex.Store({ ...@@ -57,6 +61,17 @@ export default new Vuex.Store({
commit('setIsLogin', false) commit('setIsLogin', false)
return response return response
}) })
},
async checkIsVip({ commit }) {
const isVip = await getIsVip()
.then(response => {
return response.is_vip
})
.catch(() => {
return false
})
commit('setIsVip', isVip)
return isVip
} }
} }
}) })
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论