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

fix:提交增加loading

上级 d6d93a5e
......@@ -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 => {
if (response.success) {
this.handleSuccess(response)
} else {
this.$toast(JSON.stringify(response.errors))
}
})
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 => {
if (response.success) {
this.handleSuccess(response)
} else {
this.$toast(JSON.stringify(response.errors))
}
})
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)
......
......@@ -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,
token: '',
user: {}
user: {},
isVip: false
},
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,17 @@ export default new Vuex.Store({
commit('setIsLogin', false)
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论