ts_aimz/pages/index/index.js
2025-03-31 18:23:29 +08:00

205 lines
5.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// index.js
import ProjectService from '../../net/api/projectApi'
const app = getApp()
const deviceInfo = wx.getDeviceInfo()
const screenInfo = wx.getWindowInfo();
const statusBarHeight = screenInfo.statusBarHeight; // 状态栏高度
const navBarHeight = deviceInfo.platform == 'IOS' ? 48 : 50; // 导航栏高度iOS 为 44pxAndroid 为 48px
const windowHeight = screenInfo.windowHeight - navBarHeight - statusBarHeight; //可用内容高度
Page({
data: {
statusBarHeight: statusBarHeight,
navBarHeight: navBarHeight,
totalHeight: navBarHeight, // 导航栏总高度
contentHeight: windowHeight,
tagList: [],
currentTag: '',
typeList: [{
value: 'FREE',
label: '免费试用'
},
{
value: 'MATERIAL',
label: '写材料'
},
{
value: 'ALL',
label: '全托管'
},
],
currentType: '',
expandList: [{
value: 'PKG',
label: '安装包'
},
{
value: 'VIDEO_DEMO',
label: '演示视频'
},
{
value: 'URGENT',
label: '加急'
},
],
currentExpand: '',
currentStatus: 'PROCESSING', //默认状态 PROCESSING进行中 COMPLETE完成
listLoading: 'loading', //loading 状态
listRefreshTrig: false, //是否正在刷新
pageData: {
page: 1,
rows: 10
},
projectList: [], //项目列表
noticeContent: '',
defaultNotice: '用AI创造用平台保护——欢迎来到您的著作权守护站!'
},
onLoad(e) {
const _self = this
//获取通知
_self.doGetNotice()
//获取标签选项
_self.doGetTagList()
//获取列表
_self.doChangeParams(1)
},
//创建项目
createCopy() {
wx.navigateTo({
url: '/pages/copyright/createBuy/createBuy',
})
},
//充值
goPayment() {
wx.navigateTo({
url: '/pages/copyright/payment/payment',
})
},
//切换状态
doChangeStatus(e) {
this.setData({
currentStatus: e.currentTarget.dataset.value
})
this.doChangeParams(1)
},
//切换类型
doChangeType(e) {
const _self = this
if (_self.data.currentType == e.currentTarget.dataset.value) {
_self.setData({
currentType: ''
})
} else {
_self.setData({
currentType: e.currentTarget.dataset.value
})
}
_self.doChangeParams(1)
},
//切换附加
doChangeExpand(e) {
const _self = this
if (_self.data.currentExpand == e.currentTarget.dataset.value) {
_self.setData({
currentExpand: ''
})
} else {
this.setData({
currentExpand: e.currentTarget.dataset.value
})
}
_self.doChangeParams(1)
},
//切换标签
doChangeTag(e) {
const _self = this
if (_self.data.currentTag == e.currentTarget.dataset.value) {
_self.setData({
currentTag: ''
})
} else {
_self.setData({
currentTag: e.currentTarget.dataset.value
})
}
_self.doChangeParams(1)
},
//构建参数
doChangeParams(page) {
const _self = this
_self.setData({
projectList: [],
'pageData.page': page
})
const [part1, part2] = _self.data.currentTag.split(':')
const params = {
page: _self.data.pageData.page,
rows: _self.data.pageData.rows,
tagNot: part2 ? part2 : '',
tagDataId: part1,
chargeType: _self.data.currentType, //
chargeAdditionals: _self.data.currentExpand, //额外附加
status: _self.data.currentStatus, //当前项目状态
}
_self.doGetSelfList(params)
},
//刷新列表
doRefreshList() {
console.log('正在刷新...')
const _self = this
_self.setData({
listRefreshTrig: true,
listLoading: 'loading'
})
_self.doChangeParams(1)
},
//获取通知
doGetNotice() {
const _self = this
ProjectService.doGetNotice()
.then(res => {
console.log(res)
_self.setData({
noticeContent: res.data && res.data != '' ? res.data : _self.data.defaultNotice
})
}, err => {
console.log(err)
})
},
//获取标签
doGetTagList() {
const _self = this
ProjectService.doGetTagList()
.then(res => {
_self.setData({
tagList: res
})
}, err => {
console.log(err)
})
},
//获取项目列表
doGetSelfList(params) {
const _self = this
_self.setData({
listLoading: 'loading'
})
ProjectService.doGetSelfProjectList(params)
.then(res => {
console.log(res)
var status = 'success'
status = res.rows && res.rows.length > 0 ? 'success' : 'empty'
_self.setData({
listLoading: status,
projectList: res.rows,
listRefreshTrig: false
})
}, err => {
_self.setData({
listLoading: 'error',
listRefreshTrig: false
})
})
}
})