Commit b10d50fe authored by Facius's avatar Facius

improvement: 绑卡

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