Browse Source

feat: 登录、日历页小绿点、二级项目列表

test2
xuesinan 4 years ago
parent
commit
e676cf07f6
  1. 12
      App.vue
  2. 1
      CHANGELOG.md
  3. 11
      apis/tall.js
  4. 5
      common/js/config.js
  5. 286
      components/PrettyExchange/PrettyExchange.vue
  6. 13
      components/Projects/ProjectItem.vue
  7. 2
      pages/index/index.vue
  8. 5
      pages/user/login.vue
  9. 2
      store/socket/actions.js
  10. 5
      utils/request.js

12
App.vue

@ -1,6 +1,4 @@
<script> <script>
// import { mapState } from 'vuex';
export default { export default {
// computed: { // computed: {
// ...mapState(['theme']), // ...mapState(['theme']),
@ -19,13 +17,19 @@ export default {
console.log('onLaunch options: ', options); console.log('onLaunch options: ', options);
this.checkNetwork(); // this.checkNetwork(); //
this.getSystemInfo(); // this.getSystemInfo(); //
await this.syncLocalDataToStore(options.query.u); // localStoragestore
const token = await this.getToken(); const token = this.$store.state.user.token || this.$storage.getStorageSync('anyringToken') || '';
if (!token) { if (!token) {
this.$ui.showToast('获取用户信息失败, 请登录'); this.$ui.showToast('获取用户信息失败, 请登录');
// TODO: // TODO:
return; return;
} else {
this.$store.commit('user/setToken', token);
} }
// await this.syncLocalDataToStore(options.query.u); // localStoragestore
// token = await this.getToken();
this.noPhone(this.$store.state.user.phone); this.noPhone(this.$store.state.user.phone);
this.$store.dispatch('socket/initSocket'); this.$store.dispatch('socket/initSocket');
}, },

1
CHANGELOG.md

@ -20,6 +20,7 @@
- | 项目列表 | [a52e6d5](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/a52e6d5) - | 项目列表 | [a52e6d5](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/a52e6d5)
- | 项目列表新 | [88cf48d](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/88cf48d) - | 项目列表新 | [88cf48d](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/88cf48d)
- | 账户名密码登录 | [ebf456e](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/ebf456e) - | 账户名密码登录 | [ebf456e](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/ebf456e)
- | 注册、用户协议 | [68e9189](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/68e9189)
- | app.vue | [970cf9a](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/970cf9a) - | app.vue | [970cf9a](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/970cf9a)
- | first commit | [8dc26de](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/8dc26de) - | first commit | [8dc26de](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/8dc26de)
project | 日常任务面板添加 | [b3f16ff](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/b3f16ff) project | 日常任务面板添加 | [b3f16ff](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/b3f16ff)

11
apis/tall.js

@ -1,15 +1,16 @@
import Config from '@/common/js/config.js' import Config from '@/common/js/config.js'
const apiUrl = Config.apiUrl; // const apiUrl = Config.apiUrl;
const tall = `${apiUrl}/tall3/v3.0`; const apiUrl = Config.apiUrlNew;
const tall1 = `http://101.201.226.163/gateway/ptos`; // const tall = `${apiUrl}/tall3/v3.0`;
const tall = `${apiUrl}/ptostall`;
export function setupTall(app) { export function setupTall(app) {
uni.$u.api = { ...uni.$u.api } || {}; uni.$u.api = { ...uni.$u.api } || {};
// 登录 // 登录
uni.$u.api.signin = params => uni.$u.http.post(`${tall}/users/signin`, params); // 登录 uni.$u.api.signin = params => uni.$u.http.post(`${tall}/users/signin`, params);
// 注册 // 注册
uni.$u.api.signup = params => uni.$u.http.post(`${tall}/users/signup`, params); // 登录 // uni.$u.api.signup = params => uni.$u.http.post(`${tall}/users/signup`, params);
// 获取图片验证码 // 获取图片验证码
uni.$u.api.getImageCode = () => uni.$u.get(`${tall}/users/code`); uni.$u.api.getImageCode = () => uni.$u.get(`${tall}/users/code`);
// 获取短信验证码 // 获取短信验证码

5
common/js/config.js

@ -4,6 +4,11 @@ var config = {
msgUrl: 'wss://test.tall.wiki/websocket/message/v4.0/ws', msgUrl: 'wss://test.tall.wiki/websocket/message/v4.0/ws',
projectPath: 'https://test.tall.wiki/tall-project', projectPath: 'https://test.tall.wiki/tall-project',
baseUrlNew: 'http://101.201.226.163',
apiUrlNew: 'http://101.201.226.163/gateway',
msgUrlNew: 'wss://101.201.226.163/websocket/message/v4.0/ws',
projectPathNew: 'https://101.201.226.163/tall-project',
// baseUrl: 'https://www.tall.wiki', // baseUrl: 'https://www.tall.wiki',
// apiUrl: 'https://www.tall.wiki/gateway', // apiUrl: 'https://www.tall.wiki/gateway',
// msgUrl: 'wss://www.tall.wiki/websocket/message/v4.0/ws'; // msgUrl: 'wss://www.tall.wiki/websocket/message/v4.0/ws';

286
components/PrettyExchange/PrettyExchange.vue

@ -3,29 +3,17 @@
<scroll-view scroll-y="true"> <scroll-view scroll-y="true">
<view v-if="!data.changeEvent"> <view v-if="!data.changeEvent">
<view :id="'cu-' + index" :key="item.id" class="cu-item flex-col" v-for="(item, index) in data.itemList"> <view :id="'cu-' + index" :key="item.id" class="cu-item flex-col" v-for="(item, index) in data.itemList">
<ProjectItem <ProjectItem class="w-full" :index="index" :item="item" :menuList="data.menuList" @setData="setData"
class="w-full" @openSubProject="openSubProject" />
:index="index"
:item="item"
:menuList="data.menuList"
@setData="setData"
@openSubProject="openSubProject"
/>
</view> </view>
</view> </view>
<view v-else> <view v-else>
<view <view :id="'cu-' + index" :key="index" :style="{ 'background-color': item.color }"
:id="'cu-' + index" @touchend="stops($event, index)" @touchmove.stop.prevent="move" @touchstart="start($event, index)"
:key="index" class="cu-item flex-col" v-for="(item, index) in data.itemList">
:style="{ 'background-color': item.color }"
@touchend="stops($event, index)"
@touchmove.stop.prevent="move"
@touchstart="start($event, index)"
class="cu-item flex-col" v-for="(item, index) in data.itemList"
>
<view class="border-100 bg-blue-500" v-if="item.showTopBorder"></view> <view class="border-100 bg-blue-500" v-if="item.showTopBorder"></view>
111111111111
<!-- 内容区 --> <!-- 内容区 -->
<!-- 父项目 --> <!-- 父项目 -->
<view class="w-full"> <view class="w-full">
@ -48,8 +36,10 @@
<!-- 箭头 --> <!-- 箭头 -->
<view v-if="item.sonProjectList && item.sonProjectList.length"> <view v-if="item.sonProjectList && item.sonProjectList.length">
<u-icon @click="openSubProject(item.sonProjectList.length, index)" class="text-gray-400" name="arrow-up" size="14px" v-if="item.show"></u-icon> <u-icon @click="openSubProject(item.sonProjectList.length, index)" class="text-gray-400" name="arrow-up"
<u-icon @click="openSubProject(item.sonProjectList.length, index)" class="text-gray-400" name="arrow-down" size="14px" v-else></u-icon> size="14px" v-if="item.show"></u-icon>
<u-icon @click="openSubProject(item.sonProjectList.length, index)" class="text-gray-400"
name="arrow-down" size="14px" v-else></u-icon>
</view> </view>
<u-icon class="text-gray-400" name="arrow-right" size="14px" v-else></u-icon> <u-icon class="text-gray-400" name="arrow-right" size="14px" v-else></u-icon>
</view> </view>
@ -60,8 +50,8 @@
<view :id="'cu-' + index + '-' + subIndex" :key="subIndex" <view :id="'cu-' + index + '-' + subIndex" :key="subIndex"
@touchend.stop.prevent="stops($event, index + '-' + subIndex, item.sonProjectList.length)" @touchend.stop.prevent="stops($event, index + '-' + subIndex, item.sonProjectList.length)"
@touchmove.stop.prevent="move($event, item.sonProjectList.length)" @touchmove.stop.prevent="move($event, item.sonProjectList.length)"
@touchstart.stop.prevent="start($event, index + '-' + subIndex)" @touchstart.stop.prevent="start($event, index + '-' + subIndex)" class="cu-item flex-col"
class="cu-item flex-col" v-for="(subItem, subIndex) in item.sonProjectList"> v-for="(subItem, subIndex) in item.sonProjectList">
<view class="flex items-center justify-between p-3 w-full"> <view class="flex items-center justify-between p-3 w-full">
<u-icon class="mover" name="https://www.tall.wiki/staticrec/drag.svg" size="48"> <u-icon class="mover" name="https://www.tall.wiki/staticrec/drag.svg" size="48">
</u-icon> </u-icon>
@ -70,8 +60,7 @@
<view class="flex items-center"> <view class="flex items-center">
<view class="mr-2">{{ subItem.name }}</view> <view class="mr-2">{{ subItem.name }}</view>
<!-- 状态 --> <!-- 状态 -->
<view <view :class="
:class="
subItem.status === 0 subItem.status === 0
? 'text-blue-400 bg-blue-100' ? 'text-blue-400 bg-blue-100'
: subItem.status === 1 : subItem.status === 1
@ -79,8 +68,7 @@
: subItem.status === 2 : subItem.status === 2
? 'text-red-400 bg-red-100' ? 'text-red-400 bg-red-100'
: 'text-gray-400 bg-gray-100' : 'text-gray-400 bg-gray-100'
" " class="px-2 text-xs text-gray-400 bg-gray-100 rounded-full flex-shrink-0">
class="px-2 text-xs text-gray-400 bg-gray-100 rounded-full flex-shrink-0">
{{ subItem.status === 0 ? '未开始' : subItem.status === 1 ? '进行中' : subItem.status === 2 ? '暂停' : '已完成' }} {{ subItem.status === 0 ? '未开始' : subItem.status === 1 ? '进行中' : subItem.status === 2 ? '暂停' : '已完成' }}
</view> </view>
</view> </view>
@ -114,15 +102,15 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted, watch, computed } from 'vue'; import { reactive, onMounted, watch, computed } from 'vue';
import ProjectItem from '@/components/Projects/ProjectItem.vue'; import ProjectItem from '@/components/Projects/ProjectItem.vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
const store = useStore(); const store = useStore();
const projects = computed(() => store.state.project.projects); const projects = computed(() => store.state.project.projects);
const data = ref({ const data = reactive({
itemTop: 0, // itemTop: 0,
itemLeft: 0, itemLeft: 0,
itemHeight: 0, // itemHeight: 0, //
subItemHeight: 0, // subItemHeight: 0, //
@ -135,49 +123,49 @@
deltaTop: 0, deltaTop: 0,
beginleft: 0, beginleft: 0,
begintop: 0, begintop: 0,
itemList: [], itemList: [], //
setSubItem: false, setSubItem: false,
changeEvent: false, changeEvent: false, //
showMenu: false, showMenu: false,
tips: { tips: { text: '', color: '#909399', fontSize: 28, },
text: '',
color: '#909399',
fontSize: 28,
},
projectId: 0, projectId: 0,
menuList: [{ text: '复制' }, { text: '编辑' }, { text: '删除' }, { text: '置顶' }, { text: '排序' }], menuList: [{ text: '复制' }, { text: '编辑' }, { text: '删除' }, { text: '置顶' }, { text: '排序' }],
// show: false, // show: false,
border: 'border border-blue-500 shadow rounded-md', // border: 'border border-blue-500 shadow rounded-md',
showBorder: false, showBorder: false, //
showItemIndex: undefined, showItemIndex: undefined,
}); });
const emit = defineEmits(['changeHeight']);
watch(projects, (val) => { watch(projects, (val) => {
data.value.itemList = val; data.itemList = val;
data.value.itemList.forEach(item => { data.itemList.forEach(item => {
item.showBorder = false; item.showBorder = false; //
item.showSubBorder = false; item.showSubBorder = false; //
item.showTopBorder = false; item.showTopBorder = false; //
}); });
}) })
onMounted(() => { onMounted(() => {
data.value.itemList = projects.value; data.itemList = projects.value;
data.value.itemList.forEach(item => { data.itemList.forEach(item => {
item.showBorder = false; item.showBorder = false; //
item.showSubBorder = false; item.showSubBorder = false; //
item.showTopBorder = false; item.showTopBorder = false; //
}); });
}); });
// //
function openSubProject(length, index) { function openSubProject(length, index) {
setProjectItemShow({ index, show: data.value.itemList[index].show ? false : true }); store.commit('project/setProjectItemShow', {
index,
show: data.itemList[index].show ? false : true
});
if (length && index) { if (length && index) {
this.$emit('changeHeight', length, index); emit('changeHeight', length, index);
} }
data.value.showItemIndex = index; data.showItemIndex = index;
} }
// //
@ -185,38 +173,44 @@
const query = uni.createSelectorQuery().in(this); const query = uni.createSelectorQuery().in(this);
query.select(`#cu-0`).boundingClientRect(res => { query.select(`#cu-0`).boundingClientRect(res => {
console.log('data: ', res); console.log('data: ', res);
data.value.begintop = res.top; data.begintop = res.top;
data.value.beginleft = res.left; data.beginleft = res.left;
}).exec(); }).exec();
} }
function setData(flag, projectId, tips) { function setData(flag, projectId, tips) {
data.value.showMenu = flag; data.showMenu = flag;
data.value.projectId = projectId; data.projectId = projectId;
data.value.tips = tips; data.tips = tips;
} }
function chooseAction(e) { function chooseAction(e) {
let obj = { index: e, projectId: data.value.projectId }; let obj = {
index: e,
projectId: data.projectId
};
// this.$emit('chooseAction', data); // this.$emit('chooseAction', data);
actionFun(obj); actionFun(obj);
} }
// //
function actionFun(obj) { function actionFun(obj) {
let action = data.value.menuList[obj.index].text; let action = data.menuList[obj.index].text;
if (action === '排序') { if (action === '排序') {
data.value.changeEvent = true; data.changeEvent = true;
uni.$ui.showToast('请移动进行排序'); uni.$ui.showToast('请移动进行排序');
} }
if (action === '删除') { if (action === '删除') {
data.value.changeEvent = false; data.changeEvent = false;
delProject(obj.projectId); delProject(obj.projectId);
} }
if (data.value.showItemIndex !== undefined) { if (data.showItemIndex !== undefined) {
setProjectItemShow({ index: data.value.showItemIndex, show: true }); store.commit('project/setProjectItemShow', {
index: data.showItemIndex,
show: true
});
} }
} }
@ -231,70 +225,70 @@
}, 300); }, 300);
if (isNumber(index)) { if (isNumber(index)) {
data.value.setSubItem = false; data.setSubItem = false;
const query = uni.createSelectorQuery().in(this); const query = uni.createSelectorQuery().in(this);
console.log('2222', query) console.log('2222', query)
query.select(`#cu-${index}`).boundingClientRect(res => { query.select(`#cu-${index}`).boundingClientRect(res => {
data.value.moveTop = res.top; data.moveTop = res.top;
data.value.moveLeft = res.left; data.moveLeft = res.left;
data.value.moveItem = data.value.itemList[index]; data.moveItem = data.itemList[index];
data.value.itemWidth = res.width; data.itemWidth = res.width;
data.value.itemHeight = res.height; data.itemHeight = res.height;
}).exec(); }).exec();
} else { } else {
let arr = index.split('-'); let arr = index.split('-');
data.value.setSubItem = true; data.setSubItem = true;
const query = uni.createSelectorQuery().in(this); const query = uni.createSelectorQuery().in(this);
query.select(`#cu-${arr[0] - 0}`).boundingClientRect(res => { query.select(`#cu-${arr[0] - 0}`).boundingClientRect(res => {
data.value.itemHeight = res.height; data.itemHeight = res.height;
}).exec(); }).exec();
query.select(`#cu-${index}`).boundingClientRect(res => { query.select(`#cu-${index}`).boundingClientRect(res => {
data.value.moveTop = res.top; data.moveTop = res.top;
data.value.moveLeft = res.left; data.moveLeft = res.left;
data.value.moveItem = data.value.itemList[arr[0] - 0].sonProjectList[arr[1] - 0]; data.moveItem = data.itemList[arr[0] - 0].sonProjectList[arr[1] - 0];
data.value.itemWidth = res.width; data.itemWidth = res.width;
data.value.subItemHeight = res.height; data.subItemHeight = res.height;
}).exec(); }).exec();
} }
} }
function move(e, length) { function move(e, length) {
console.log('移动'); console.log('移动');
data.value.showMoveImage = true; // data.showMoveImage = true; //
const touch = e.touches[0]; const touch = e.touches[0];
if (data.value.deltaLeft == 0) { if (data.deltaLeft == 0) {
// //
data.value.deltaLeft = touch.pageX - data.value.moveLeft; data.deltaLeft = touch.pageX - data.moveLeft;
data.value.deltaTop = touch.pageY - data.value.moveTop; data.deltaTop = touch.pageY - data.moveTop;
} }
data.value.moveLeft = touch.pageX - data.value.deltaLeft; data.moveLeft = touch.pageX - data.deltaLeft;
data.value.moveTop = touch.pageY - data.value.deltaTop; data.moveTop = touch.pageY - data.deltaTop;
let lastIndex = (lastIndex = findOverIndex(touch.pageY, length)); let lastIndex = (lastIndex = findOverIndex(touch.pageY, length));
console.log('111111', lastIndex); console.log('111111', lastIndex);
// 线 // 线
for (let i = 0; i < data.value.itemList.length; i++) { for (let i = 0; i < data.itemList.length; i++) {
if (data.value.moveLeft > 35) { if (data.moveLeft > 35) {
data.value.itemList[i].showBorder = false; data.itemList[i].showBorder = false;
data.value.itemList[i].showTopBorder = false; data.itemList[i].showTopBorder = false;
if (i === lastIndex) { if (i === lastIndex) {
data.value.itemList[i].showSubBorder = true; data.itemList[i].showSubBorder = true;
} else { } else {
data.value.itemList[i].showSubBorder = false; data.itemList[i].showSubBorder = false;
} }
} else { } else {
if (lastIndex === -1) { if (lastIndex === -1) {
data.value.itemList[0].showTopBorder = true; data.itemList[0].showTopBorder = true;
data.value.itemList[i].showSubBorder = false; data.itemList[i].showSubBorder = false;
data.value.itemList[i].showBorder = false; data.itemList[i].showBorder = false;
} else { } else {
data.value.itemList[i].showSubBorder = false; data.itemList[i].showSubBorder = false;
data.value.itemList[i].showTopBorder = false; data.itemList[i].showTopBorder = false;
if (i === lastIndex) { if (i === lastIndex) {
data.value.itemList[i].showBorder = true; data.itemList[i].showBorder = true;
} else { } else {
data.value.itemList[i].showBorder = false; data.itemList[i].showBorder = false;
} }
} }
} }
@ -307,18 +301,18 @@
let lastIndex = (lastIndex = findOverIndex(touch.pageY, length)); let lastIndex = (lastIndex = findOverIndex(touch.pageY, length));
// //
for (let i = 0; i < data.value.itemList.length; i++) { for (let i = 0; i < data.itemList.length; i++) {
// //
if (data.value.itemList[i].showTopBorder) { if (data.itemList[i].showTopBorder) {
if (isNumber(index)) { if (isNumber(index)) {
let Value = data.value.itemList[index]; let Value = data.itemList[index];
data.value.itemList.unshift(Value); data.itemList.unshift(Value);
data.value.itemList.splice(index + 1, 1); data.itemList.splice(index + 1, 1);
} else { } else {
let arr = index.split('-'); let arr = index.split('-');
let Value = data.value.itemList[arr[0] - 0].sonProjectList[arr[1] - 0]; let Value = data.itemList[arr[0] - 0].sonProjectList[arr[1] - 0];
data.value.itemList.unshift(Value); data.itemList.unshift(Value);
data.value.itemList[arr[0] - 0].sonProjectList.splice([arr[1] - 0], 1); data.itemList[arr[0] - 0].sonProjectList.splice([arr[1] - 0], 1);
const options = { const options = {
id: Value.id, id: Value.id,
parentId: 0, parentId: 0,
@ -327,24 +321,24 @@
} }
// //
clearSet(i); clearSet(i);
this.$emit('change', data.value.itemList); this.$emit('change', data.itemList);
return; return;
} }
// //
if (data.value.itemList[i].showBorder) { if (data.itemList[i].showBorder) {
if (isNumber(index)) { if (isNumber(index)) {
let Value = data.value.itemList[index]; let Value = data.itemList[index];
data.value.itemList.splice(i + 1, 0, Value); data.itemList.splice(i + 1, 0, Value);
if (i < index) { if (i < index) {
data.value.itemList.splice(index + 1, 1); data.itemList.splice(index + 1, 1);
} else { } else {
data.value.itemList.splice(index, 1); data.itemList.splice(index, 1);
} }
} else { } else {
let arr = index.split('-'); let arr = index.split('-');
let Value = data.value.itemList[arr[0] - 0].sonProjectList[arr[1] - 0]; let Value = data.itemList[arr[0] - 0].sonProjectList[arr[1] - 0];
data.value.itemList.splice(i + 1, 0, Value); data.itemList.splice(i + 1, 0, Value);
data.value.itemList[arr[0] - 0].sonProjectList.splice([arr[1] - 0], 1); data.itemList[arr[0] - 0].sonProjectList.splice([arr[1] - 0], 1);
const options = { const options = {
id: Value.id, id: Value.id,
parentId: 0, parentId: 0,
@ -353,40 +347,40 @@
} }
// //
clearSet(i); clearSet(i);
this.$emit('change', data.value.itemList); this.$emit('change', data.itemList);
return; return;
} }
// //
if (data.value.itemList[i].showSubBorder) { if (data.itemList[i].showSubBorder) {
if (isNumber(index)) { if (isNumber(index)) {
let Value = data.value.itemList[index]; let Value = data.itemList[index];
if (data.value.itemList[lastIndex - 1].sonProjectList && data.value.itemList[lastIndex - 1].sonProjectList.length) { if (data.itemList[lastIndex - 1].sonProjectList && data.itemList[lastIndex - 1].sonProjectList.length) {
data.value.itemList[lastIndex - 1].sonProjectList.push(Value); data.itemList[lastIndex - 1].sonProjectList.push(Value);
} else { } else {
data.value.itemList[lastIndex].sonProjectList = [Value]; data.itemList[lastIndex].sonProjectList = [Value];
} }
data.value.itemList.splice(index, 1); data.itemList.splice(index, 1);
// //
clearSet(i); clearSet(i);
const options = { const options = {
id: Value.id, id: Value.id,
parentId: data.value.itemList[lastIndex - 1].id, parentId: data.itemList[lastIndex - 1].id,
}; };
this.$emit('change', options); this.$emit('change', options);
} else { } else {
let arr = index.split('-'); let arr = index.split('-');
let Value = data.value.itemList[arr[0] - 0].sonProjectList[arr[1] - 0]; let Value = data.itemList[arr[0] - 0].sonProjectList[arr[1] - 0];
if (data.value.itemList[lastIndex].sonProjectList && data.value.itemList[lastIndex].sonProjectList.length) { if (data.itemList[lastIndex].sonProjectList && data.itemList[lastIndex].sonProjectList.length) {
data.value.itemList[lastIndex].sonProjectList.push(Value); data.itemList[lastIndex].sonProjectList.push(Value);
} else { } else {
data.value.itemList[lastIndex].sonProjectList = [Value]; data.itemList[lastIndex].sonProjectList = [Value];
} }
data.value.itemList[arr[0] - 0].sonProjectList.splice([arr[1] - 0], 1); data.itemList[arr[0] - 0].sonProjectList.splice([arr[1] - 0], 1);
// //
clearSet(i); clearSet(i);
const options = { const options = {
id: Value.id, id: Value.id,
parentId: data.value.itemList[lastIndex].id, parentId: data.itemList[lastIndex].id,
}; };
this.$emit('change', options); this.$emit('change', options);
@ -403,34 +397,34 @@
// //
function clearSet(i) { function clearSet(i) {
data.value.itemList[i].showBorder = false; data.itemList[i].showBorder = false;
data.value.itemList[i].showSubBorder = false; data.itemList[i].showSubBorder = false;
data.value.itemList[i].showTopBorder = false; data.itemList[i].showTopBorder = false;
data.value.deltaLeft == 0; data.deltaLeft == 0;
data.value.showMoveImage = false; data.showMoveImage = false;
data.value.setSubItem = false; data.setSubItem = false;
data.value.changeEvent = false; data.changeEvent = false;
data.value.showItemIndex = undefined; data.showItemIndex = undefined;
} }
// //
function findOverIndex(posY) { function findOverIndex(posY) {
// //
let leng = data.value.itemList.length * data.value.itemHeight; // let leng = data.itemList.length * data.itemHeight; //
if (posY < data.value.begintop) { if (posY < data.begintop) {
return -1; return -1;
} }
for (var i = 0; i < data.value.itemList.length; i++) { for (var i = 0; i < data.itemList.length; i++) {
let begin = data.value.itemHeight * i + data.value.begintop; let begin = data.itemHeight * i + data.begintop;
let end = data.value.itemHeight * i + data.value.begintop + data.value.itemHeight; let end = data.itemHeight * i + data.begintop + data.itemHeight;
if (begin <= posY && end >= posY) { if (begin <= posY && end >= posY) {
return i; return i;
} }
} }
if (posY > leng) { if (posY > leng) {
// //
return data.value.itemList.length - 1; return data.itemList.length - 1;
} else if (posY < data.value.begintop) { } else if (posY < data.begintop) {
return 0; return 0;
} }
} }
@ -441,18 +435,20 @@
title: '', title: '',
content: '是否删除项目?', content: '是否删除项目?',
showCancel: true, showCancel: true,
success: async ({ confirm }) => { success: async ({
confirm
}) => {
if (confirm) { if (confirm) {
await this.$u.api.delProject(id); await this.$u.api.delProject(id);
let flag_index = 0; let flag_index = 0;
data.value.itemList.forEach((item, index) => { data.itemList.forEach((item, index) => {
if (item.id == id) { if (item.id == id) {
flag_index = index; flag_index = index;
} }
}); });
data.value.itemList.splice(flag_index, 1); data.itemList.splice(flag_index, 1);
setProjects(data.value.itemList); store.commit('project/setProjects', data.itemList);
} }
}, },
}); });

13
components/Projects/ProjectItem.vue

@ -20,8 +20,8 @@
<!-- 箭头 --> <!-- 箭头 -->
<view v-if="item.sonProjectList && item.sonProjectList.length"> <view v-if="item.sonProjectList && item.sonProjectList.length">
<u-icon @click="$emit('openSubProject', item.sonProjectList.length, index)" class="text-gray-400" name="arrow-up" size="14px" v-if="item.show"></u-icon> <u-icon @click="emit('openSubProject', item.sonProjectList.length, index)" class="text-gray-400" name="arrow-up" size="14px" v-if="item.show"></u-icon>
<u-icon @click="$emit('openSubProject', item.sonProjectList.length, index)" class="text-gray-400" name="arrow-down" size="14px" v-else></u-icon> <u-icon @click="emit('openSubProject', item.sonProjectList.length, index)" class="text-gray-400" name="arrow-down" size="14px" v-else></u-icon>
</view> </view>
<u-icon @click="openProject(item)" class="text-gray-400" name="arrow-right" size="14px" v-else></u-icon> <u-icon @click="openProject(item)" class="text-gray-400" name="arrow-right" size="14px" v-else></u-icon>
</view> </view>
@ -63,7 +63,7 @@
</template> </template>
<script setup> <script setup>
import { ref, computed } from 'vue'; import { reactive, computed } from 'vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import config from '@/common/js/config.js'; import config from '@/common/js/config.js';
@ -82,12 +82,12 @@ defineProps({
// default: () => [], // default: () => [],
// }, // },
}); });
const emit = defineEmits(['setData']); const emit = defineEmits(['setData', 'openSubProject']);
const store = useStore(); const store = useStore();
const userId = computed(() => store.getters['user/userId']); const userId = computed(() => store.getters['user/userId']);
const data = ref({ const data = reactive({
showMenu: false, showMenu: false,
tips: { tips: {
text: '', text: '',
@ -102,7 +102,7 @@ const data = ref({
// //
function openProject(project) { function openProject(project) {
const gateway = config.apiUrl; const gateway = config.apiUrlNew;
const url = `${gateway}/defaultwbs`; const url = `${gateway}/defaultwbs`;
const { name, id } = project; const { name, id } = project;
uni.navigateTo({ url: `/pages/project/project?u=${userId.value}&p=${id}&pname=${name}&url=${encodeURIComponent(url)}` }); uni.navigateTo({ url: `/pages/project/project?u=${userId.value}&p=${id}&pname=${name}&url=${encodeURIComponent(url)}` });
@ -117,7 +117,6 @@ function openMenu(project) {
data.tips.text = project.name; data.tips.text = project.name;
emit('setData', data.showMenu, data.projectId, data.tips); emit('setData', data.showMenu, data.projectId, data.tips);
// this.$emit('setData', data.showMenu, data.projectId, data.tips);
} }
</script> </script>

2
pages/index/index.vue

@ -108,7 +108,7 @@ function onMove(event) {
} }
function toLogin() { function toLogin() {
uni.navigateTo({ url: '/pages/user/accountLogin' }) uni.navigateTo({ url: '/pages/user/login' })
} }
</script> </script>

5
pages/user/login.vue

@ -68,9 +68,7 @@
// //
const submitLogin = () => { const submitLogin = () => {
console.log('111111')
phoneLoginForm.value.validate(valid => { phoneLoginForm.value.validate(valid => {
console.log('2222', valid)
if (valid) { if (valid) {
login() login()
} }
@ -100,6 +98,7 @@
}); });
let res = await uni.$u.api.signin(params); let res = await uni.$u.api.signin(params);
console.log(res, '----------')
store.commit('user/setToken', res.token); store.commit('user/setToken', res.token);
store.commit('user/setUser', res); store.commit('user/setUser', res);
uni.$storage.setStorageSync('anyringToken', res.token || ''); uni.$storage.setStorageSync('anyringToken', res.token || '');
@ -112,7 +111,7 @@
}); });
} catch (error) { } catch (error) {
uni.$ui.hideLoading(); uni.$ui.hideLoading();
uni.$ui.showToast(error); uni.$ui.showToast(error.msg);
} }
} }

2
store/socket/actions.js

@ -202,7 +202,7 @@ const actions = {
dispatch('sendHeart'); dispatch('sendHeart');
} else { } else {
uni.$u.toast('消息系统认证失败, 请退出重新登录'); uni.$u.toast('消息系统认证失败, 请退出重新登录');
uni.$t.removeStorageSync('anyringToken'); uni.$storage.removeStorageSync('anyringToken');
commit('setSocket', null); commit('setSocket', null);
} }
}, },

5
utils/request.js

@ -31,6 +31,11 @@ export function setupHttp(app) {
// res为服务端返回值,可能有code,result等字段 // res为服务端返回值,可能有code,result等字段
// 这里对res.result进行返回,将会在this.$u.post(url).then(res => {})的then回调中的res的到 // 这里对res.result进行返回,将会在this.$u.post(url).then(res => {})的then回调中的res的到
// 如果配置了originalData为true,请留意这里的返回值 // 如果配置了originalData为true,请留意这里的返回值
if (res.tokenObj.token) {
storage.setStorageSync('anyringToken', res.tokenObj.token || '');
store.commit('user/setToken', res.tokenObj.token);
}
return res.data; return res.data;
} else if (res.code === 401) { } else if (res.code === 401) {
// 假设201为token失效,这里跳转登录 // 假设201为token失效,这里跳转登录

Loading…
Cancel
Save