Commit abcfa346 authored by Facius's avatar Facius

fix: 【ID1001400】 【小程序-首页-选择题库设置页面】:添加题库时,点2次确定按钮才提示:添加成功

parent a4219333
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
:loading="loading" :loading="loading"
@click="handleClickSure" @click="handleClickSure"
> >
{{ buttonText }} 确定
</u-button> </u-button>
</view> </view>
</view> </view>
...@@ -61,11 +61,6 @@ export default { ...@@ -61,11 +61,6 @@ export default {
type: String, type: String,
default: '', default: '',
}, },
buttonText: {
// 确定按钮
type: String,
default: '确定',
},
}, },
data() { data() {
return { return {
......
...@@ -52,26 +52,6 @@ ...@@ -52,26 +52,6 @@
</view> </view>
</view> </view>
</picker> </picker>
<!-- <view class="select-area">
<view @click="handleClickArea" class="area-text-view">
<text>{{ currentProvince.label }}</text>
<u-icon name="arrow-down"></u-icon>
</view>
<view class="loading-view" v-if="loading">
<u-loading mode="flower"></u-loading>
</view>
<u-picker
mode="selector"
:range="range"
v-model="show"
:params="params"
safe-area-inset-bottom
cancel-color="#9EA5BB"
confirm-color="#2953FF"
:default-region="defaultRegion"
@confirm="handleConform"
></u-picker>
</view> -->
</view> </view>
<view class="bottom-view"> <view class="bottom-view">
<u-button <u-button
...@@ -80,6 +60,7 @@ ...@@ -80,6 +60,7 @@
shape="circle" shape="circle"
:disabled="buttonDisabled" :disabled="buttonDisabled"
:type="buttonDisabled ? '' : 'primary'" :type="buttonDisabled ? '' : 'primary'"
throttle-time="250"
> >
确定 确定
</u-button> </u-button>
...@@ -233,8 +214,8 @@ export default { ...@@ -233,8 +214,8 @@ export default {
console.log(res) console.log(res)
this.range = res || [] this.range = res || []
}, },
async handleClickSubmit() { handleClickSubmit() {
if (this.buttonDisabled) return // if (this.buttonDisabled) return
if (this.range.length <= 0 || this.range.length == null) { if (this.range.length <= 0 || this.range.length == null) {
this.$refs.uToast.show({ this.$refs.uToast.show({
title: '该类型和区域没有的题库', title: '该类型和区域没有的题库',
...@@ -246,6 +227,7 @@ export default { ...@@ -246,6 +227,7 @@ export default {
}) })
return return
} }
if (this.index == 0) { if (this.index == 0) {
this.changeIndex() this.changeIndex()
} }
...@@ -254,46 +236,55 @@ export default { ...@@ -254,46 +236,55 @@ export default {
type: this.selectedTypeId, type: this.selectedTypeId,
} }
// 获取科目对应的题库 // 获取科目对应的题库
let res = await this.$u.api.getQuestionWarehouse(this.category.id, param) this.$u.api
if (res && res.length > 0) { .getQuestionWarehouse(this.category.id, param)
let data = res[0] .then((res) => {
// 学员增加自己的题库 if (res && res.length > 0) {
let result = await this.$u.api let data = res[0]
.addQuestionWarehouse({
questionWarehouseId: data.id,
})
.catch((err) => {
console.log(err)
})
if (result) { // 学员增加自己的题库
data.isAdd = true this.$u.api
this.setPageInfo(data) .addQuestionWarehouse({
// 成功 questionWarehouseId: data.id,
this.$refs.uToast.show({
title: '添加题库成功',
type: 'success',
duration: 1500,
callback: () => {
this.showPop = false
uni.switchTab({
url: '/pages/index/index',
}) })
}, .then((result) => {
}) if (result) {
} else { data.isAdd = true
this.showPop = false this.setPageInfo(data)
} // 成功
} else { this.$refs.uToast.show({
this.$refs.uToast.show({ title: '添加题库成功',
title: '该类型和区域没有的题库', type: 'success',
type: 'warning', duration: 1500,
duration: 1500, callback: () => {
callback: () => { this.showPop = false
this.showPop = false uni.switchTab({
}, url: '/pages/index/index',
})
},
})
} else {
this.showPop = false
}
})
.catch((err) => {
this.showPop = false
console.log(err)
})
} else {
this.$refs.uToast.show({
title: '该类型和区域没有的题库',
type: 'warning',
duration: 1500,
callback: () => {
this.showPop = false
},
})
}
})
.catch((err) => {
console.log(err)
}) })
}
}, },
changeIndex() { changeIndex() {
for (var i = 0; i < this.range.length; i++) { for (var i = 0; i < this.range.length; i++) {
......
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