Commit b10d50fe authored by Facius's avatar Facius

improvement: 绑卡

parent 69bdc8cc
...@@ -55,7 +55,7 @@ const install = (Vue, vm) => { ...@@ -55,7 +55,7 @@ const install = (Vue, vm) => {
} else { } else {
// 如果返回false,则会调用Promise的reject回调, // 如果返回false,则会调用Promise的reject回调,
vm.$u.toast(data.msg) vm.$u.toast(data.msg)
return data return false
} }
} else if (res.statusCode === 401) { } else if (res.statusCode === 401) {
// 登录过期 // 登录过期
...@@ -68,6 +68,7 @@ const install = (Vue, vm) => { ...@@ -68,6 +68,7 @@ const install = (Vue, vm) => {
} else { } else {
// HTTP状态非200 // HTTP状态非200
vm.$u.toast(data.msg || '服务器错误') vm.$u.toast(data.msg || '服务器错误')
return false
} }
} }
} }
......
...@@ -242,6 +242,11 @@ export default { ...@@ -242,6 +242,11 @@ export default {
this.visible = info.state this.visible = info.state
this.queryMyQuestionWarehouseDetail(this.selected.id) this.queryMyQuestionWarehouseDetail(this.selected.id)
} }
let refresh = page.refresh
if (refresh) {
page.refresh = null
this.queryMyQuestionWarehouseDetail(this.info.id)
}
}, },
methods: { methods: {
// 题库详情 // 题库详情
......
...@@ -63,8 +63,6 @@ export default { ...@@ -63,8 +63,6 @@ export default {
}, },
}, },
onLoad(e) { onLoad(e) {
e = {}
e.code = '621001500006600c7m1dp8z2'
if (e && e.code) { if (e && e.code) {
var code = e.code var code = e.code
this.param.cardNumber = code.slice(0, 15) this.param.cardNumber = code.slice(0, 15)
...@@ -74,30 +72,31 @@ export default { ...@@ -74,30 +72,31 @@ export default {
}, },
methods: { methods: {
handleClick() { handleClick() {
// 获取题库列表
this.loading = true this.loading = true
this.$u.api this.$u.api
.bindCard(this.param) .bindCard(this.param)
.then((res) => { .then((res) => {
console.log('--------res--------', res) this.$refs.uToast.show({
uni.switchTab({ title: '绑定成功',
url: '/pages/index/index', type: 'success',
duration: 1500,
callback: () => {
this.setPageInfo()
uni.switchTab({
url: '/pages/index/index',
})
},
}) })
}) })
.catch((err) => { .catch((err) => {
this.loading = false this.loading = false
console.log(err)
this.$refs.uToast.show({
title: err.msg,
type: 'error',
})
}) })
}, },
setPageInfo(info) { setPageInfo() {
var pages = getCurrentPages() var pages = getCurrentPages()
if (pages.length >= 2) { if (pages.length >= 2) {
var page = pages[pages.length - 2] var page = pages[pages.length - 2]
page.info = info page.refresh = true
} }
}, },
}, },
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
<u-button <u-button
:customStyle="customStyle" :customStyle="customStyle"
@click="handleClick" @click="handleClick"
:loading="loading"
type="primary" type="primary"
shape="circle" shape="circle"
> >
...@@ -69,6 +70,7 @@ export default { ...@@ -69,6 +70,7 @@ export default {
code: '', code: '',
password: '', password: '',
focus: true, focus: true,
loading: false,
} }
}, },
...@@ -99,29 +101,35 @@ export default { ...@@ -99,29 +101,35 @@ export default {
onLoad(e) {}, onLoad(e) {},
methods: { methods: {
handleClick() { handleClick() {
// 获取题库列表
this.loading = true this.loading = true
this.$u.api this.$u.api
.bindCard(this.param) .bindCard({
cardNumber: this.code,
cardSecret: this.password,
questionWarehouseId: this.questionWarehouseId,
})
.then((res) => { .then((res) => {
uni.switchTab({ this.$refs.uToast.show({
url: '/pages/index/index', title: '绑定成功',
type: 'success',
duration: 1500,
callback: () => {
this.setPageInfo()
uni.switchTab({
url: '/pages/index/index',
})
},
}) })
}) })
.catch((err) => { .catch((err) => {
this.loading = false this.loading = false
console.log(err)
this.$refs.uToast.show({
title: err.msg,
type: 'error',
})
}) })
}, },
setPageInfo(info) { setPageInfo() {
var pages = getCurrentPages() var pages = getCurrentPages()
if (pages.length >= 2) { if (pages.length >= 2) {
var page = pages[pages.length - 2] var page = pages[pages.length - 2]
page.info = info page.refresh = true
} }
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment