import { useLoading } from '../../../behaviors/loading';
|
import { useConclusion } from './conclusion-proxy.js';
|
import { useQuestion } from './question-proxy.js';
|
|
import { fetchClue, fetchClueInternal } from '../../../services/clue/fetchClue';
|
|
Page({
|
behaviors: [useLoading, useConclusion, useQuestion],
|
|
data: {
|
clue: {},
|
},
|
|
onLoad(options) {
|
this.getOpenerEventChannel().on('acceptClueTask', data => {
|
this.setData({
|
clueTask: data,
|
});
|
this._startLoad();
|
});
|
},
|
|
onPullDownRefresh() {
|
this._startLoad();
|
},
|
|
onReachBottom() {
|
this._loadMore();
|
},
|
|
/*********************************************************************************** */
|
_fetchData(page) {
|
const array = [];
|
array.push(this.fetchClueQuestion());
|
if (page == 1) {
|
array.push(this.fetchClueData());
|
array.push(this.fetchClueConclusion());
|
}
|
return Promise.all(array).then(res => {
|
return res[0];
|
});
|
},
|
|
fetchClueData() {
|
const { clueTask } = this.data;
|
const func = clueTask.internalTask ? fetchClueInternal : fetchClue;
|
func({ cid: clueTask.clueId }).then(res => {
|
if (res.data.length > 0) {
|
this.setData({ clue: res.data[0] });
|
}
|
});
|
},
|
|
/*********************************************************************************** */
|
});
|