Browse Source

fix: 返回错误码不提示

test2
xuesinan 3 years ago
parent
commit
29e4655d72
  1. 3
      CHANGELOG.md
  2. 14
      hooks/project/useGetTasks.js
  3. 2
      manifest.json
  4. 10
      pages/project/project.vue
  5. 5
      store/user/actions.js
  6. 12
      uni_modules/vk-uview-ui/libs/request/index.js

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 1.0.0 (2022-03-09)
# 1.0.0 (2022-03-10)
### 🌟 新功能
范围|描述|commitId
@ -127,6 +127,7 @@
- | 切换项目存储的任务id未清空 | [77fe17f](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/77fe17f)
- | 切换项目任务清空 | [1dd3b4b](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/1dd3b4b)
- | 日历列表H5在手机端不显示 | [0b4ae72](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/0b4ae72)
- | 如果插件列表为空 | [f6a8fce](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/f6a8fce)
- | 删除多余的引入 | [050b12a](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/050b12a)
- | 上查下查 | [48ee8cb](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/48ee8cb)
- | 上查下查 | [002f270](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/002f270)

14
hooks/project/useGetTasks.js

@ -31,6 +31,7 @@ export default function useGetTasks() {
// 初始化 定期任务
async function initPlanTasks() {
if (timeLineType.value === 1) setNextPlaceholderTasks({});
console.log('查询定期任务');
await getTasks({}); // 获取初始数据
// await dataRender({});
}
@ -64,6 +65,7 @@ export default function useGetTasks() {
store.commit('task/setShowSkeleton', false);
const params = generateGetTaskParam(query);
console.log('查询定期任务api', params);
uni.$catchReq.getTaskByNum(params, (err, data) => {
store.commit('task/setShowSkeleton', false);
if (err) {
@ -74,12 +76,15 @@ export default function useGetTasks() {
params.queryType === 0 ? store.commit('task/setUpRealTasks', data.list) : store.commit('task/setDownRealTasks', data.list);
console.log('查询到的真实任务', data.list);
const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
console.log('api当前角色id', roleId.value, index);
const arr = [...allTasks.value];
arr[index].realTasks = [...realTasks.value];
arr[index].upNextPage = params.queryType === 0 ? data.nextPage : 1;
arr[index].downNextPage = params.queryType === 1 ? data.nextPage : 1;
store.commit('task/setAllTasks', arr);
console.log('设置当前真实任务', arr[index].realTasks);
store.commit('task/setCurrRoleRealTasks', arr[index].realTasks); // 设置当前角色的真实任务数据
params.queryType === 0 ? store.commit('task/setUpNextPage', arr[index].upNextPage) : store.commit('task/setDownNextPage', arr[index].downNextPage); // 下一页
@ -101,7 +106,10 @@ export default function useGetTasks() {
// 刻度模式数据处理
async function renderScaleTask(query) {
const params = generateGetTaskParam(query);
console.log('当前角色id', roleId.value);
console.log('当前角色的真实任务', currRoleRealTasks.value);
let centerData = await showTaskTime(params, currRoleShowTasks.value, currRoleRealTasks.value) || [];
console.log('需要显示的真实任务', centerData);
await handleTasksData(params, centerData, currRoleRealTasks.value);
}
@ -221,11 +229,13 @@ export default function useGetTasks() {
showTasks = params.queryType === 0 ? showTasks.slice(len) : showTasks.slice(0, len + 1);
}
} else if (nextPage > 0) {
console.log('数据不为空,时间跨度小于15')
getTasks({pageNum: nextPage, queryType: params.queryType});
}
}
} else {
if (nextPage > 0) {
console.log('数据为空')
getTasks({pageNum: nextPage, queryType: params.queryType});
} else {
params.queryType === 0 ? setPrevPlaceholderTasks(params) : setNextPlaceholderTasks(params);
@ -309,11 +319,11 @@ export default function useGetTasks() {
* 当日常任务发生变化时
* 将新获取到的日常任务放在allTasks里
*/
watch(tasks, newValue => {
watch(tasks, () => {
// 添加到allTasks里
const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
const arr = [...allTasks.value];
arr[index].task = [...newValue];
arr[index].task = [...tasks.value];
store.commit('task/setAllTasks', arr);
store.commit('task/setCurrRoleShowTasks', arr[index].task); // 设置当前角色的展示任务数据
});

2
manifest.json

@ -2,7 +2,7 @@
"name" : "时物链条",
"appid" : "__UNI__3CBCFFF",
"description" : "",
"versionName" : "1.0.12",
"versionName" : "1.0.13",
"versionCode" : "100",
"transformPx" : false,
/* 5+App */

10
pages/project/project.vue

@ -35,7 +35,7 @@
</template>
<script setup>
import { ref, computed, watch, onMounted } from 'vue';
import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
import { useStore } from 'vuex';
import dayjs from 'dayjs';
import useInit from '@/hooks/project/useInit';
@ -74,6 +74,14 @@ if (!userInfo.value) {
}
}
onUnmounted(() => {
console.log('卸载组件实例后调用');
clearTasksData();
store.commit('task/setCurrRoleRealTasks', []); //
store.commit('task/setCurrRoleShowTasks', []); //
store.commit('socket/setCurrLocationTaskId', '');
});
/**
* 当角色发生变化时
* 重新查询永久日常任务和普通日常任务

5
store/user/actions.js

@ -27,11 +27,6 @@ const actions = {
async sendCode({ commit }, params) {
try {
const res = await uni.$u.api.getSmsCode(params);
if (res) {
uni.$ui.showToast('验证码发送成功');
} else {
uni.$ui.showToast('验证码发送失败');
}
return res;
} catch (error) {
uni.$ui.showToast(error.msg || '验证码发送失败');

12
uni_modules/vk-uview-ui/libs/request/index.js

@ -27,7 +27,7 @@ class Request {
options.method = options.method || this.config.method;
return new Promise((resolve, reject) => {
options.complete = (response) => {
options.complete = async (response) => {
// 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading)
uni.hideLoading();
// 清除定时器,如果请求回来了,就无需loading
@ -52,7 +52,7 @@ class Request {
} else {
if (response.statusCode == 200) {
if (this.interceptor.response && typeof this.interceptor.response === 'function') {
let resInterceptors = this.interceptor.response(response.data);
let resInterceptors = await this.interceptor.response(response.data);
if (resInterceptors !== false) {
resolve(resInterceptors);
} else {
@ -77,7 +77,7 @@ class Request {
// 判断用户传递的URL是否/开头,如果不是,加上/,这里使用了uView的test.js验证库的url()方法
options.url = validate.url(options.url) ? options.url : (this.config.baseUrl + (options.url.indexOf('/') == 0 ?
options.url : '/' + options.url));
// 是否显示loading
// 加一个是否已有timer定时器的判断,否则有两个同时请求的时候,后者会清除前者的定时器id
// 而没有清除前者的定时器,导致前者超时,一直显示loading
@ -116,7 +116,7 @@ class Request {
originalData: false, // 是否在拦截器中返回服务端的原始数据,见文档说明
loadingMask: true, // 展示loading的时候,是否给一个透明的蒙层,防止触摸穿透
}
// 拦截器
this.interceptor = {
// 请求前的拦截
@ -144,7 +144,7 @@ class Request {
data
})
}
// put请求,不支持支付宝小程序(HX2.6.15)
this.put = (url, data = {}, header = {}) => {
return this.request({
@ -154,7 +154,7 @@ class Request {
data
})
}
// delete请求,不支持支付宝和头条小程序(HX2.6.15)
this.delete = (url, data = {}, header = {}) => {
return this.request({

Loading…
Cancel
Save