931 lines
25 KiB
JavaScript
931 lines
25 KiB
JavaScript
// pages/projectMy/projectMy.js
|
|
var miucms = require('../../utils/miucms.js');
|
|
let app = getApp()
|
|
const util = require('../../utils/util')
|
|
const common = require('../../utils/commonMethod')
|
|
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
informationState: false, // 授权后可能需要弹出完成信息框 个人背景那些
|
|
islogin: false,
|
|
isloginBtnState: false,
|
|
|
|
classify: "vs", // vs manage '' 代表都没有数据
|
|
move: 0,
|
|
manageHintState: false, // 底部的提示的显示状态
|
|
|
|
list: [],
|
|
listCount: 0,
|
|
page: 1,
|
|
|
|
stateObj: {
|
|
0: "待定",
|
|
1: "主申",
|
|
2: "冲刺",
|
|
3: "保底",
|
|
},
|
|
|
|
isloading: false, // 项目管理获取 item 高度是否完成
|
|
headTop: 0, // 项目管理头部的高度
|
|
dragging: null, // 是否在拖拽中
|
|
arrHeight: 0, // 项目管理的高度
|
|
|
|
quickList: [], // 快速对比 列表
|
|
quickMoreState: false, // 快速对比 的 全部显示状态
|
|
|
|
typeList: [],
|
|
typeIndex: 0,
|
|
typeid: "", // 项目管理
|
|
|
|
projectPage: 1,
|
|
projectList: [], // 项目对比
|
|
projectCount: [], // 项目对比 数量
|
|
|
|
selectList: [], // 选中列表
|
|
|
|
// allQuickHeight: 0,
|
|
|
|
vsBottom: false, // 底部显示状态
|
|
user: {},
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
rpx30: 30,
|
|
rpx219: 219,
|
|
options: {},
|
|
onLoad(options) {
|
|
this.options = options
|
|
this.deleteWidth = util.rpxTopx(180 + 30)
|
|
miucms.pageStart(app).then(() => {
|
|
// 判断是否需要显示底部提示
|
|
let manageHintState = true
|
|
if (wx.getStorageSync("PMState")) manageHintState = false
|
|
|
|
const islogin = app.globalData.user.uid > 0 ? true : false
|
|
const screen_data = app.globalData.screen_data
|
|
this.setData({
|
|
screen_data,
|
|
islogin,
|
|
manageHintState,
|
|
user: app.globalData.user,
|
|
})
|
|
|
|
this.windowHeight = screen_data.windowHeight || 812
|
|
|
|
// if (!this.indexSidebar) this.indexSidebar = this.selectComponent('#index-sidebar')
|
|
|
|
if (!islogin) this.openLoginBtnState()
|
|
|
|
this.rpx30 = util.rpxTopx(30)
|
|
this.rpx219 = util.rpxTopx(219)
|
|
|
|
this.getList().then(res => {
|
|
if (res.code != 200) return
|
|
const data = res.data
|
|
const nums = data.nums || {}
|
|
let classify = 'vs'
|
|
if (nums['contrast'] == 0 && nums['manage'] == 0) {
|
|
classify = ''
|
|
} else if (nums['contrast'] == 0 && nums['manage'] != 0) {
|
|
classify = 'manage'
|
|
this.handleUserProjectData(res)
|
|
} else {
|
|
this.getQuickList()
|
|
this.handleProjectListData(res)
|
|
}
|
|
|
|
this.setData({
|
|
classify,
|
|
})
|
|
})
|
|
}).catch(res => {})
|
|
},
|
|
|
|
// 公共的获取列表 方法
|
|
getList(obj = {}) {
|
|
return new Promise((resolve, reject) => {
|
|
wx.showLoading({
|
|
title: '加载中...',
|
|
})
|
|
|
|
util.wxpost("/api/project.user", {
|
|
limit: 2000,
|
|
page: obj.page || 1,
|
|
typeid: obj.typeid || '',
|
|
}).then(res => resolve(res)).finally(() => wx.hideLoading())
|
|
})
|
|
},
|
|
|
|
getProjectList() {
|
|
if (this.data.projectPage == 0) return
|
|
|
|
this.getList({
|
|
page: this.data.projectPage,
|
|
}).then(res => {
|
|
this.handleProjectListData(res)
|
|
})
|
|
},
|
|
|
|
handleProjectListData(res) {
|
|
if (res.code != 200) return
|
|
const data = res.data
|
|
let list = data.data || []
|
|
let projectCount = 0
|
|
list.forEach(element => {
|
|
if (element.status == 1) projectCount++
|
|
})
|
|
let projectList = this.data.projectList.concat(list)
|
|
|
|
this.setData({
|
|
projectCount: projectCount + this.data.projectCount,
|
|
projectList,
|
|
projectPage: data.count > data.limit * data.page ? this.data.projectPage + 1 : 0,
|
|
})
|
|
},
|
|
|
|
// 获取快速列表
|
|
getQuickList() {
|
|
util.wxget("/api/project.contrast/getQuickList", {}).then(res => {
|
|
if (res.code != 200) return
|
|
const data = res.data
|
|
const quickList = data || []
|
|
this.setData({
|
|
quickList,
|
|
quickMoreState: quickList.length > 3 ? false : true,
|
|
|
|
vsBottom: quickList.length == 0 ? true : false,
|
|
})
|
|
|
|
// 计算 快速对比的高度的 隐藏高度
|
|
if (quickList.length > 3) this.calculateQuickHeight()
|
|
this.listeningNode()
|
|
})
|
|
},
|
|
|
|
// 获取项目管理
|
|
getUserProject() {
|
|
if (this.data.page == 0) return
|
|
this.getList({
|
|
page: this.data.page,
|
|
typeid: this.data.typeid
|
|
}).then(res => {
|
|
this.handleUserProjectData(res)
|
|
})
|
|
},
|
|
|
|
handleUserProjectData(res) {
|
|
if (res.code != 200) return
|
|
const data = res.data
|
|
let list = this.data.list.concat(data.data || [])
|
|
list.forEach((element, index) => {
|
|
element['sortKey'] = index
|
|
})
|
|
|
|
this.setData({
|
|
list,
|
|
typeList: data.typeList,
|
|
page: data.count > data.limit * data.page ? this.data.page + 1 : 0,
|
|
listCount: data.count,
|
|
}, () => this.calculateManageHeight())
|
|
},
|
|
|
|
// 计算快速对比的高度 和 隐藏高度
|
|
calculateQuickHeight() {
|
|
const quickList = this.data.quickList || []
|
|
let allQuickHeight = 0
|
|
let first3_5 = 0
|
|
quickList.forEach((element, index) => {
|
|
let height = 186
|
|
if (element.data.length == 3) height = 239.25
|
|
|
|
if (index < 3) first3_5 += height
|
|
if (index == 3) first3_5 += (height / 2)
|
|
|
|
allQuickHeight += height
|
|
})
|
|
|
|
first3_5 = util.rpxTopx(first3_5)
|
|
allQuickHeight = util.rpxTopx(allQuickHeight)
|
|
|
|
this.setData({
|
|
first3_5,
|
|
allQuickHeight,
|
|
})
|
|
},
|
|
|
|
// 计算项目管理的高度
|
|
calculateManageHeight() {
|
|
const query = this.createSelectorQuery();
|
|
let arrHeight = 0
|
|
query.select(".manage-box .list").boundingClientRect(res => {
|
|
const top = res.top
|
|
|
|
this.createSelectorQuery().selectAll(".manage-box .list .item").boundingClientRect(res => {
|
|
|
|
let obj = {}
|
|
res.sort((a, b) => a.dataset.key - b.dataset.key);
|
|
|
|
let totalHeight = 0
|
|
res.forEach(element => {
|
|
const key = element.dataset.key
|
|
let height = element.height
|
|
|
|
if (height != 0) height += this.rpx30 // 删除了不需要高度
|
|
|
|
arrHeight += height
|
|
|
|
obj[key] = {
|
|
top: totalHeight,
|
|
height,
|
|
}
|
|
|
|
totalHeight += height
|
|
})
|
|
|
|
let list = this.data.list || []
|
|
|
|
list.forEach((element, index) => {
|
|
element['top'] = obj[element.sortKey].top
|
|
element['height'] = obj[element.sortKey].height
|
|
})
|
|
|
|
this.setData({
|
|
list,
|
|
isloading: true,
|
|
headTop: top,
|
|
arrHeight,
|
|
})
|
|
|
|
}).exec();
|
|
}).exec();
|
|
},
|
|
|
|
// 切换查看类型
|
|
cutClassify(e) {
|
|
const classify = e.currentTarget.dataset.type
|
|
if (classify == this.data.classify) return
|
|
this.setData({
|
|
classify,
|
|
})
|
|
|
|
if (this.data.classify == 'manage') {
|
|
this.setData({
|
|
page: 1,
|
|
typeid: "",
|
|
arrHeight: 0,
|
|
list: [],
|
|
})
|
|
this.getUserProject()
|
|
}
|
|
if (this.data.classify == 'vs') {
|
|
this.setData({
|
|
quickList: [],
|
|
quickMoreState: false,
|
|
projectPage: 1,
|
|
projectList: [],
|
|
selectList: [],
|
|
})
|
|
this.getProjectList()
|
|
this.getQuickList()
|
|
}
|
|
},
|
|
|
|
deleteWidth: 150, // 删除按钮的 宽度
|
|
x: 0,
|
|
shtouchmove(e) {
|
|
this.x = e.detail.x
|
|
},
|
|
|
|
handleTouchEnd(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
const type = e.currentTarget.dataset.type
|
|
let move = 0
|
|
|
|
if (Math.abs(this.x) > this.deleteWidth / 2) move = -this.deleteWidth
|
|
this.setData({
|
|
[`${type}[${index}].move`]: move
|
|
})
|
|
|
|
this.x = 0
|
|
},
|
|
|
|
// 关闭 底部提示框
|
|
manageClose() {
|
|
this.setData({
|
|
manageHintState: false,
|
|
})
|
|
|
|
wx.setStorageSync('PMState', 1)
|
|
},
|
|
|
|
// 项目的里的排序 拖拽
|
|
movableChange(e) {
|
|
if (e.detail.source != 'touch') return
|
|
|
|
let list = this.data.list || []
|
|
const index = e.target.dataset.index
|
|
let item = list[index]
|
|
item.touch = true
|
|
},
|
|
|
|
pointDistance: 0, // 点距离顶部
|
|
longPress(e) {
|
|
let index = e.currentTarget.dataset.index;
|
|
let list = this.data.list || []
|
|
this.setData({
|
|
dragging: index,
|
|
})
|
|
this.pointDistance = e.detail.y - list[index].top - this.data.headTop
|
|
wx.vibrateShort({
|
|
type: "heavy",
|
|
})
|
|
this.setData({
|
|
list,
|
|
})
|
|
},
|
|
|
|
timerr: null,
|
|
touchMove(e) {
|
|
clearTimeout(this.touchEndTmer)
|
|
if (Math.random() < 0.3 || Date.now() - this.timerr < 20) return
|
|
this.timerr = Date.now()
|
|
|
|
let key = e.currentTarget.dataset.key;
|
|
let list = this.data.list || []
|
|
let currentTouch = e.changedTouches[0];
|
|
if (!currentTouch) return;
|
|
|
|
let index = 0 // 当前 item 的下标 注意 因为 拖拽的 所以和 wx:for 表面上的 index 不一致
|
|
list.forEach((element, i) => {
|
|
if (element.sortKey == key) index = i
|
|
})
|
|
|
|
if (this.data.dragging == null) return;
|
|
|
|
// 设置当前 item 的定位 item
|
|
const top = currentTouch.pageY - this.data.headTop - this.pointDistance
|
|
const bottom = top + list[index].height
|
|
list[index].top = top
|
|
|
|
// 判断 有没有到其他 item 地盘
|
|
let keyTop = key - 1
|
|
let keyBottom = key + 1
|
|
if (keyTop >= 0) {
|
|
let keyTopIndex = list.findIndex(element => element.sortKey === keyTop);
|
|
let keyItem = list[keyTopIndex]
|
|
|
|
let keyHeight = keyItem.height || 0
|
|
const middleLine = keyItem.top + keyHeight / 2 // 上一个的中间线
|
|
if (top <= middleLine) {
|
|
// 交换 sortKey
|
|
const akey = key
|
|
list[index].sortKey = keyItem.sortKey
|
|
list[keyTopIndex].sortKey = akey
|
|
list[keyTopIndex].top = this.calculateHeight(JSON.parse(JSON.stringify(list)), key)
|
|
}
|
|
}
|
|
|
|
if (keyBottom < list.length) {
|
|
let keyBottomIndex = list.findIndex(element => element.sortKey === keyBottom);
|
|
|
|
let keyItem = JSON.parse(JSON.stringify(list[keyBottomIndex]))
|
|
|
|
let keyHeight = keyItem.height
|
|
const middleLine = keyItem.top + keyHeight / 2 // 下一个的中间线
|
|
if (bottom >= middleLine) {
|
|
// 交换 sortKey
|
|
const akey = key
|
|
list[index].sortKey = keyItem.sortKey
|
|
list[keyBottomIndex].sortKey = akey
|
|
list[keyBottomIndex].top = this.calculateHeight(JSON.parse(JSON.stringify(list)), key)
|
|
}
|
|
}
|
|
|
|
this.setData({
|
|
list,
|
|
})
|
|
},
|
|
|
|
touchEndTmer: null,
|
|
touchEnd(e) {
|
|
this.setData({
|
|
dragging: null,
|
|
})
|
|
let key = e.currentTarget.dataset.key;
|
|
let list = this.data.list || []
|
|
|
|
let index = 0
|
|
|
|
list.forEach((element, i) => {
|
|
if (element.sortKey == key) index = i
|
|
})
|
|
|
|
list[index].top = this.calculateHeight(JSON.parse(JSON.stringify(list)), key)
|
|
|
|
this.setData({
|
|
list
|
|
})
|
|
|
|
this.touchEndTmer = setTimeout(() => {
|
|
let list = JSON.parse(JSON.stringify(this.data.list)) || []
|
|
// 按照 id 属性排序
|
|
const sortedArray = list.slice().sort((a, b) => a.sortKey - b.sortKey);
|
|
|
|
// 获取排序后的对象在原数组中的索引位置
|
|
const indexes = sortedArray.map(obj => list.indexOf(obj));
|
|
|
|
let accumulatedHeight = 0;
|
|
|
|
indexes.forEach((element, i) => {
|
|
list[element].top = accumulatedHeight
|
|
accumulatedHeight += list[element].height
|
|
})
|
|
this.setData({
|
|
list
|
|
})
|
|
}, 800)
|
|
|
|
let targetList = JSON.parse(JSON.stringify(list))
|
|
// 按照 sortKey 属性对数组进行排序
|
|
targetList.sort((a, b) => a.sortKey - b.sortKey);
|
|
|
|
let newId = []
|
|
// 输出排序后的对象的 id 属性
|
|
targetList.forEach(obj => {
|
|
newId.push(obj.projectid)
|
|
});
|
|
|
|
util.wxpost("/api/project.user/changeSorting", {
|
|
projectids: newId
|
|
}).then(res => common.toast(res.message))
|
|
},
|
|
|
|
calculateHeight(list, key) {
|
|
let height = 0
|
|
list.forEach(element => {
|
|
if (element.sortKey < key) height += element.height
|
|
})
|
|
return height
|
|
},
|
|
|
|
scrollTop: 0, // 滚动的距离
|
|
// indexSidebar: null,
|
|
windowHeight: 812,
|
|
onPageScroll(e) {
|
|
if (Math.random() < 0.5) return
|
|
let scrollTop = e.scrollTop
|
|
this.scrollTop = scrollTop
|
|
|
|
},
|
|
|
|
slowScrollNow: "",
|
|
slowScrollTo(type) {
|
|
if (Date.now() - this.slowScrollNow > 350) {
|
|
wx.pageScrollTo({
|
|
scrollTop: this.scrollTop - 150,
|
|
});
|
|
this.slowScrollNow = Date.now()
|
|
}
|
|
},
|
|
|
|
openInput(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
let list = this.data.list
|
|
list[index]['input'] = 1
|
|
this.setData({
|
|
list
|
|
})
|
|
},
|
|
|
|
linechange(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
this.calculateManageHeight()
|
|
},
|
|
|
|
remarks: "",
|
|
focusfocus(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
let list = this.data.list
|
|
this.remarks = list[index]['remarks']
|
|
},
|
|
|
|
bindblur(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
let list = this.data.list
|
|
list[index]['input'] = 0
|
|
this.setData({
|
|
list
|
|
})
|
|
|
|
wx.nextTick(() => {
|
|
this.calculateManageHeight()
|
|
})
|
|
|
|
const target = list[index] || {}
|
|
if (this.remarks != target.remarks) this.postRemarks(target.token, target.remarks)
|
|
this.remarks = ""
|
|
},
|
|
|
|
// 发送 备注
|
|
postRemarks(token, remarks) {
|
|
util.wxpost("/api/project.user/remarks", {
|
|
token,
|
|
remarks,
|
|
}).then(res => common.toast(res.message))
|
|
},
|
|
|
|
// 备注输入
|
|
inputRemark(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
let list = this.data.list
|
|
const value = e.detail.value
|
|
list[index]['remarks'] = value
|
|
this.setData({
|
|
list
|
|
})
|
|
},
|
|
|
|
// 展开 快速对比的 全部
|
|
openQuickMore() {
|
|
this.setData({
|
|
quickMoreState: !this.data.quickMoreState,
|
|
})
|
|
},
|
|
|
|
// 选中
|
|
cutSelect(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
const pitch = e.currentTarget.dataset.pitch || false // false 表示还没有选中
|
|
|
|
let projectList = this.data.projectList || []
|
|
|
|
const projectid = projectList[index].projectid
|
|
|
|
let selectList = this.data.selectList
|
|
|
|
// 检查数组中是否存在指定的id
|
|
let indexx = selectList.findIndex(item => item == projectid);
|
|
|
|
if (indexx !== -1) {
|
|
// 如果存在,删除该元素
|
|
selectList.splice(indexx, 1);
|
|
projectList[index]['pitch'] = false
|
|
} else if (selectList.length < 3) {
|
|
// 如果不存在,将新元素推入数组
|
|
selectList.push(projectid);
|
|
projectList[index]['pitch'] = true
|
|
}
|
|
|
|
if (selectList.length >= 2) {
|
|
this.setData({
|
|
vsBottom: true,
|
|
})
|
|
}
|
|
|
|
this.setData({
|
|
projectList,
|
|
selectList,
|
|
})
|
|
},
|
|
|
|
// 跳转 项目对比
|
|
goContrast(e) {
|
|
const ids = e.currentTarget.dataset.ids
|
|
common.goPage(`/pages/projectComparison/projectComparison?ids=${ ids }`)
|
|
},
|
|
|
|
// 点击删除快速对比
|
|
quickDelete(e) {
|
|
const id = e.currentTarget.dataset.id
|
|
const index = e.currentTarget.dataset.index
|
|
const quickList = this.data.quickList
|
|
|
|
util.wxpost("/api/project.contrast/deleteQuick", {
|
|
id
|
|
}).then(res => {
|
|
quickList.splice(index, 1)
|
|
common.toast(res.message)
|
|
let allQuickHeight = this.data.allQuickHeight
|
|
this.setData({
|
|
quickList,
|
|
allQuickHeight,
|
|
})
|
|
|
|
this.calculateQuickHeight()
|
|
})
|
|
|
|
this.x = 0
|
|
},
|
|
|
|
// 跳转 对比
|
|
statePitch(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
const state = e.currentTarget.dataset.state
|
|
|
|
let list = this.data.list || []
|
|
list.forEach(element => {
|
|
element['state'] = false
|
|
})
|
|
list[index]['state'] = !state
|
|
this.setData({
|
|
list,
|
|
})
|
|
},
|
|
|
|
// 点击对比
|
|
startContrast() {
|
|
let arr = this.data.selectList
|
|
|
|
if (arr.length == 0 || arr.length < 2) {
|
|
common.toast(arr.length == 0 ? '请选择项目' : '请选择2~3个项目')
|
|
return
|
|
}
|
|
common.goPage(`/pages/projectComparison/projectComparison?ids=${arr}`)
|
|
let projectList = this.data.projectList || []
|
|
projectList.forEach(element => {
|
|
element['pitch'] = false
|
|
})
|
|
this.setData({
|
|
selectList: [],
|
|
projectList,
|
|
})
|
|
},
|
|
|
|
// 点击项目管理的删除
|
|
delete(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
|
|
let list = this.data.list
|
|
const target = list[index]
|
|
|
|
util.wxpost("/api/project.user/delete", {
|
|
token: target.token,
|
|
}).then(res => {
|
|
if (res.code != 200) return
|
|
common.toast(res.message)
|
|
|
|
const typeList = this.data.typeList || []
|
|
|
|
const stateObj = this.data.stateObj
|
|
const stateName = stateObj[target.typeid]
|
|
typeList.forEach(element => {
|
|
if (element.name == '全部') element.count--
|
|
if (element.name == stateName) element.count--
|
|
})
|
|
|
|
const height = target['height']
|
|
list[index]['ismanage'] = 0
|
|
list[index]['height'] = 0
|
|
|
|
// 对数组按sortKey进行排序
|
|
list.sort((a, b) => a.sortKey - b.sortKey);
|
|
|
|
// 初始化累加的高度
|
|
let accumulatedHeight = 0;
|
|
|
|
list.forEach((element, i) => {
|
|
element.top = accumulatedHeight
|
|
accumulatedHeight += element.height
|
|
})
|
|
|
|
let arrHeight = 0
|
|
|
|
list.forEach(element => {
|
|
arrHeight += element.height
|
|
})
|
|
|
|
this.setData({
|
|
list,
|
|
arrHeight,
|
|
typeList,
|
|
})
|
|
})
|
|
},
|
|
|
|
// 修改 项目 状态
|
|
changeType(e) {
|
|
const typeid = e.currentTarget.dataset.typeid
|
|
const index = e.currentTarget.dataset.index
|
|
const list = this.data.list || []
|
|
const target = JSON.parse(JSON.stringify(list[index])) || {}
|
|
|
|
util.wxpost("/api/project.user/changeType", {
|
|
token: target.token,
|
|
typeid,
|
|
}).then(res => {
|
|
if (res.code != 200) return
|
|
|
|
const typeList = this.data.typeList || []
|
|
const typeIndex = this.data.typeIndex || 0
|
|
|
|
const stateObj = this.data.stateObj
|
|
const stateNameFront = stateObj[target.typeid] // 修改前的状态
|
|
const stateNameAfter = stateObj[typeid] // 修改后的状态
|
|
typeList.forEach(element => {
|
|
if (element.name == stateNameFront) element.count--
|
|
if (element.name == stateNameAfter) element.count++
|
|
})
|
|
|
|
list[index]['typeid'] = typeid
|
|
list[index]['state'] = false
|
|
|
|
if (typeIndex != 0) {
|
|
list[index]['ismanage'] = 0
|
|
list[index]['height'] = 0
|
|
|
|
// 对数组按sortKey进行排序
|
|
list.sort((a, b) => a.sortKey - b.sortKey);
|
|
|
|
// 初始化累加的高度
|
|
let accumulatedHeight = 0;
|
|
|
|
list.forEach((element, i) => {
|
|
element.top = accumulatedHeight
|
|
accumulatedHeight += element.height
|
|
})
|
|
|
|
let arrHeight = 0
|
|
|
|
list.forEach(element => {
|
|
arrHeight += element.height
|
|
})
|
|
|
|
this.setData({
|
|
arrHeight,
|
|
})
|
|
}
|
|
|
|
this.setData({
|
|
list,
|
|
typeList,
|
|
})
|
|
})
|
|
|
|
},
|
|
|
|
// 点击头部 tab
|
|
cutTypeid(e) {
|
|
const typeid = e.currentTarget.dataset.value
|
|
const index = e.currentTarget.dataset.index
|
|
|
|
this.setData({
|
|
typeid,
|
|
typeIndex: index,
|
|
list: [],
|
|
page: 1,
|
|
}, () => this.getUserProject())
|
|
|
|
},
|
|
|
|
// 点击删除对比库
|
|
projectDelete(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
const projectid = e.currentTarget.dataset.projectid
|
|
|
|
util.wxpost("/api/project.contrast/delete", {
|
|
projectid
|
|
}).then(res => {
|
|
if (res.code != 200) return
|
|
|
|
common.toast(res.message)
|
|
|
|
let projectList = this.data.projectList
|
|
projectList.splice(index, 1)
|
|
this.setData({
|
|
projectList,
|
|
projectCount: this.data.projectCount--,
|
|
})
|
|
})
|
|
},
|
|
|
|
goPage(e) {
|
|
const url = e.currentTarget.dataset.url
|
|
common.goPage(url)
|
|
},
|
|
|
|
observer: null,
|
|
listeningNode() {
|
|
this.observer = wx.createIntersectionObserver(this, {
|
|
observeAll: true,
|
|
thresholds: [0] // 设定阈值,表示元素一半进入可视区域时触发
|
|
});
|
|
|
|
this.observer.relativeToViewport().observe('.quick-border', res => {
|
|
if (res.intersectionRatio == 0) {
|
|
this.setData({
|
|
vsBottom: true,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
// 打开 授权按钮
|
|
openLoginBtnState() {
|
|
this.setData({
|
|
isloginBtnState: true,
|
|
})
|
|
},
|
|
|
|
// 关闭授权登录事件
|
|
popClose() {
|
|
this.setData({
|
|
isloginBtnState: !this.data.isloginBtnState
|
|
})
|
|
},
|
|
|
|
userClickLogin(e) {
|
|
let data = e.detail.data
|
|
this.setData({
|
|
islogin: true,
|
|
isloginBtnState: false,
|
|
informationState: data.regdatastep == 'success' ? false : true,
|
|
quickList: [],
|
|
quickMoreState: false,
|
|
projectPage: 1,
|
|
projectList: [],
|
|
selectList: [],
|
|
page: 1,
|
|
typeid: "",
|
|
arrHeight: 0,
|
|
list: [],
|
|
})
|
|
this.onLoad(this.options)
|
|
},
|
|
|
|
// 子组件传值 修改 完善信息组件的状态
|
|
revampInformationState() {
|
|
this.setData({
|
|
informationState: false
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
if (app.globalData['isquickState']) this.getQuickList()
|
|
|
|
app.globalData['isquickState'] = false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
wx.stopPullDownRefresh()
|
|
|
|
if (this.data.classify == 'manage') {
|
|
this.setData({
|
|
page: 1,
|
|
typeid: "",
|
|
arrHeight: 0,
|
|
})
|
|
this.getUserProject()
|
|
}
|
|
if (this.data.classify == 'vs') {
|
|
this.setData({
|
|
quickList: [],
|
|
quickMoreState: false,
|
|
projectPage: 1,
|
|
projectList: [],
|
|
selectList: [],
|
|
})
|
|
this.getProjectList()
|
|
this.getQuickList()
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
if (this.data.classify == 'manage') this.getUserProject()
|
|
if (this.data.classify == 'vs') this.getProjectList()
|
|
},
|
|
}) |