2025-03-21 18:05:54 +08:00
|
|
|
|
// pages/mine/mine.js
|
2025-03-31 18:23:29 +08:00
|
|
|
|
import UserApi from '../../../net/api/userApi'
|
2025-04-14 15:59:06 +08:00
|
|
|
|
import ProApi from '../../../net/api/projectApi'
|
2025-04-03 17:40:39 +08:00
|
|
|
|
import {
|
|
|
|
|
copyrightUrl
|
|
|
|
|
} from '../../../net/http'
|
2025-04-03 10:44:12 +08:00
|
|
|
|
const Utils = require('../../../utils/util')
|
2025-03-21 18:05:54 +08:00
|
|
|
|
const app = getApp()
|
2025-03-24 18:05:54 +08:00
|
|
|
|
const deviceInfo = wx.getDeviceInfo()
|
|
|
|
|
const screenInfo = wx.getWindowInfo();
|
|
|
|
|
const statusBarHeight = screenInfo.statusBarHeight; // 状态栏高度
|
|
|
|
|
const navBarHeight = deviceInfo.platform == 'IOS' ? 48 : 50; // 导航栏高度(iOS 为 44px,Android 为 48px)
|
2025-04-14 15:59:06 +08:00
|
|
|
|
const tabBarHeight = screenInfo.screenHeight - (screenInfo.safeArea ? screenInfo.safeArea.bottom : 50);
|
|
|
|
|
const screenHeight = screenInfo.screenHeight
|
|
|
|
|
const screenWidth = screenInfo.screenWidth
|
2025-03-24 18:05:54 +08:00
|
|
|
|
const windowHeight = screenInfo.windowHeight - navBarHeight - statusBarHeight; //可用内容高度
|
2025-03-21 18:05:54 +08:00
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
statusBarHeight: statusBarHeight,
|
|
|
|
|
navBarHeight: navBarHeight,
|
|
|
|
|
totalHeight: navBarHeight, // 导航栏总高度
|
|
|
|
|
contentHeight: windowHeight,
|
2025-04-14 15:59:06 +08:00
|
|
|
|
screenHeight: screenHeight, //屏幕高度
|
|
|
|
|
screenWidth: screenWidth, //屏幕宽度
|
|
|
|
|
tabBarHeight: tabBarHeight, //tabbar高度
|
2025-03-31 18:23:29 +08:00
|
|
|
|
allCount: 0,
|
|
|
|
|
materialCount: 0,
|
|
|
|
|
accountInfo: {},
|
2025-03-21 18:05:54 +08:00
|
|
|
|
menuList: [{
|
2025-04-03 17:40:39 +08:00
|
|
|
|
"icon": "ic-user",
|
|
|
|
|
"title": "个人信息",
|
|
|
|
|
"path": "/pages/mine/mineAccount/mineInfo/mineInfo"
|
2025-03-21 18:05:54 +08:00
|
|
|
|
}, {
|
2025-04-03 17:40:39 +08:00
|
|
|
|
"icon": "ic-order",
|
|
|
|
|
"title": "我的订单",
|
|
|
|
|
"path": "/pages/mine/mineAccount/mineOrder/mineOrder"
|
2025-03-21 18:05:54 +08:00
|
|
|
|
}, {
|
2025-04-03 17:40:39 +08:00
|
|
|
|
"icon": "ic-invoice",
|
|
|
|
|
"title": "发票管理",
|
|
|
|
|
"path": ""
|
2025-03-21 18:05:54 +08:00
|
|
|
|
}, {
|
2025-04-03 17:40:39 +08:00
|
|
|
|
"icon": "ic-contact",
|
|
|
|
|
"title": "产权联系人",
|
2025-04-07 11:04:08 +08:00
|
|
|
|
"path": "/pages/mine/mineAccount/mineContact/mineContact"
|
|
|
|
|
}],
|
|
|
|
|
buttons: [{
|
|
|
|
|
text: '知道了'
|
|
|
|
|
}],
|
|
|
|
|
hintTxt: '',
|
2025-04-09 11:31:24 +08:00
|
|
|
|
showHint: false,
|
|
|
|
|
showError: false,
|
|
|
|
|
errorHint: '',
|
|
|
|
|
animationData: {}, //刷新动画
|
|
|
|
|
animation: null,
|
2025-04-14 15:59:06 +08:00
|
|
|
|
tabList: [{
|
|
|
|
|
"pagePath": "pages/index/index",
|
|
|
|
|
"text": "首页",
|
|
|
|
|
"iconPath": "/static/images/ic_home_normal.png",
|
|
|
|
|
"selectedIconPath": "/static/images/ic_home_select.png",
|
|
|
|
|
"selected": true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"pagePath": "pages/mine/mineIndex/mine",
|
|
|
|
|
"text": "我的",
|
|
|
|
|
"iconPath": "/static/images/ic_mine_normal.png",
|
|
|
|
|
"selectedIconPath": "/static/images/ic_mine_select.png",
|
|
|
|
|
"selected": false
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
color: "#515151",
|
|
|
|
|
selectedColor: "#FE9944",
|
|
|
|
|
allPrice: 0, //全托管价格
|
|
|
|
|
materialPrice: 0, //写材料价格
|
|
|
|
|
urgent: 0, //加急价格
|
2025-03-21 18:05:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad(options) {
|
2025-03-31 18:23:29 +08:00
|
|
|
|
const _self = this
|
|
|
|
|
_self.getMineAccount()
|
|
|
|
|
_self.getMinePackageCount()
|
2025-04-09 11:31:24 +08:00
|
|
|
|
// 创建一个动画实例
|
|
|
|
|
const animation = wx.createAnimation({
|
|
|
|
|
duration: 1000,
|
|
|
|
|
timingFunction: 'ease'
|
|
|
|
|
});
|
|
|
|
|
this.setData({
|
|
|
|
|
animation: animation
|
|
|
|
|
})
|
2025-04-14 15:59:06 +08:00
|
|
|
|
this.countViewHeight()
|
|
|
|
|
this.doGetPrice()
|
|
|
|
|
},
|
|
|
|
|
//计算高度
|
|
|
|
|
countViewHeight() {
|
|
|
|
|
//
|
|
|
|
|
const query = wx.createSelectorQuery();
|
|
|
|
|
const _self = this
|
|
|
|
|
// 指定要查询的 view 元素
|
|
|
|
|
query.select('#func-box').boundingClientRect();
|
|
|
|
|
query.exec((res) => {
|
|
|
|
|
if (res[0]) {
|
|
|
|
|
const height = res[0].height;
|
|
|
|
|
//屏幕高度-内容高度-tabbar高度
|
|
|
|
|
const contentHeight = _self.data.screenHeight - height - 50
|
|
|
|
|
const h = Utils.pxToRpx(contentHeight, _self.data.screenWidth)
|
|
|
|
|
const tempH = h - 140
|
|
|
|
|
console.log('转后', h, '内容高度:', tempH)
|
|
|
|
|
_self.setData({
|
|
|
|
|
contentHeight: tempH
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
console.log('未找到指定的 view 元素');
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//跳转创建项目页面
|
|
|
|
|
openCreate(e) {
|
|
|
|
|
//计算价格
|
|
|
|
|
const _self = this
|
|
|
|
|
const type = e.currentTarget.dataset.type
|
|
|
|
|
if (type == 'ALL') {
|
|
|
|
|
if (_self.data.allCount > 0) {
|
|
|
|
|
_self.doGetPackage(type)
|
|
|
|
|
} else {
|
|
|
|
|
//提示充值
|
|
|
|
|
_self.setData({
|
|
|
|
|
errorHint: '您的账户当前无套餐包,为正常使用请及时充值。',
|
|
|
|
|
showError: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (_self.data.materialCount > 0) {
|
|
|
|
|
_self.doGetPackage(type)
|
|
|
|
|
} else {
|
|
|
|
|
//提示充值
|
|
|
|
|
_self.setData({
|
|
|
|
|
errorHint: '您的账户当前无套餐包,为正常使用请及时充值。',
|
|
|
|
|
showError: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//获取套餐包详情
|
|
|
|
|
doGetPackage(type) {
|
|
|
|
|
const _self = this
|
|
|
|
|
const data = {
|
|
|
|
|
page: 1,
|
|
|
|
|
rows: 10,
|
|
|
|
|
packageType: type,
|
|
|
|
|
keyong: 1,
|
|
|
|
|
}
|
|
|
|
|
ProApi.doGetPackageList(data)
|
|
|
|
|
.then(res => {
|
|
|
|
|
console.log(res.rows)
|
|
|
|
|
if (res.rows && res.rows.length > 0) {
|
|
|
|
|
const packageId = res.rows[0].packageInfoId
|
|
|
|
|
const price = type == 'ALL' ? _self.data.allPrice : _self.data.materialPrice
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '../../copyright/createProjectInfo/createProjectInfo?type=' + type + '&price=' + price + '&isUrgent=false&pId=' + packageId,
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
_self.setData({
|
|
|
|
|
errorHint: '您的账户当前无套餐包,为正常使用请及时充值。',
|
|
|
|
|
showError: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
_self.setData({
|
|
|
|
|
errorHint: '获取套餐包失败,请稍后重试',
|
|
|
|
|
showError: true
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//获取单价
|
|
|
|
|
doGetPrice() {
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
title: '加载中...',
|
|
|
|
|
})
|
|
|
|
|
const _self = this
|
|
|
|
|
ProApi.doGetPrice()
|
|
|
|
|
.then(res => {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
console.log(res)
|
|
|
|
|
res.projTypes.forEach(el => {
|
|
|
|
|
if (el.type == 'ALL') {
|
|
|
|
|
_self.setData({
|
|
|
|
|
allPrice: el.price
|
|
|
|
|
})
|
|
|
|
|
} else if (el.type == 'MATERIAL') {
|
|
|
|
|
_self.setData({
|
|
|
|
|
materialPrice: el.price
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
_self.setData({
|
|
|
|
|
urgent: res.additional.urgent, //加急办理
|
|
|
|
|
})
|
|
|
|
|
}, err => {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
wx.showToast({
|
2025-04-16 16:16:35 +08:00
|
|
|
|
title: '数据有误,请刷新页面',
|
|
|
|
|
icon: 'error'
|
2025-04-14 15:59:06 +08:00
|
|
|
|
})
|
|
|
|
|
})
|
2025-04-09 11:31:24 +08:00
|
|
|
|
},
|
|
|
|
|
//刷新账户
|
|
|
|
|
doRefresh() {
|
|
|
|
|
const _self = this
|
|
|
|
|
_self.playAnimation()
|
|
|
|
|
_self.getMineAccount() //获取账户信息
|
|
|
|
|
_self.getMinePackageCount() //获取套餐包信息
|
2025-04-14 15:59:06 +08:00
|
|
|
|
_self.doGetPrice() //获取单价
|
2025-04-09 11:31:24 +08:00
|
|
|
|
},
|
|
|
|
|
//播放刷新动画
|
|
|
|
|
playAnimation() {
|
|
|
|
|
const _self = this
|
|
|
|
|
// 重置动画
|
|
|
|
|
_self.data.animation.scale(1, 1).rotate(0).step({
|
|
|
|
|
duration: 0
|
|
|
|
|
});
|
|
|
|
|
_self.setData({
|
|
|
|
|
animationData: _self.data.animation.export()
|
|
|
|
|
});
|
|
|
|
|
_self.data.animation.scale(0.8, 0.8).rotate(180).step()
|
|
|
|
|
// 定义新的动画
|
|
|
|
|
_self.data.animation.scale(1, 1).rotate(360).step()
|
|
|
|
|
_self.setData({
|
|
|
|
|
animationData: _self.data.animation.export()
|
|
|
|
|
});
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
_self.setData({
|
|
|
|
|
animationData: {}
|
|
|
|
|
})
|
|
|
|
|
}, 1100);
|
2025-04-03 10:44:12 +08:00
|
|
|
|
},
|
|
|
|
|
onShow(options) {
|
2025-04-14 15:59:06 +08:00
|
|
|
|
const pages = getCurrentPages();
|
|
|
|
|
const currentPage = pages[pages.length - 1];
|
|
|
|
|
const tabList = this.data.tabList;
|
|
|
|
|
tabList.forEach(item => {
|
|
|
|
|
item.selected = item.pagePath === currentPage.route;
|
|
|
|
|
});
|
|
|
|
|
this.setData({
|
|
|
|
|
tabList
|
|
|
|
|
});
|
2025-04-03 10:44:12 +08:00
|
|
|
|
this.getMineAccount() //获取账户信息
|
|
|
|
|
this.getMinePackageCount() //获取套餐包信息
|
2025-03-31 18:23:29 +08:00
|
|
|
|
},
|
|
|
|
|
getMineAccount() {
|
|
|
|
|
const _self = this
|
|
|
|
|
UserApi.doGetMineAccount()
|
|
|
|
|
.then(res => {
|
|
|
|
|
_self.setData({
|
|
|
|
|
accountInfo: res
|
|
|
|
|
})
|
|
|
|
|
}, err => {
|
|
|
|
|
console.log(err)
|
2025-04-09 11:31:24 +08:00
|
|
|
|
_self.setData({
|
|
|
|
|
errorHint: err.msg ? err.msg : '网络信号开小差啦,请您稍后再试,给您添麻烦~',
|
|
|
|
|
showError: true
|
|
|
|
|
})
|
2025-03-31 18:23:29 +08:00
|
|
|
|
})
|
|
|
|
|
},
|
2025-04-08 14:36:56 +08:00
|
|
|
|
//获取账户余额
|
2025-03-31 18:23:29 +08:00
|
|
|
|
getMinePackageCount() {
|
2025-04-03 10:44:12 +08:00
|
|
|
|
const _self = this
|
2025-03-31 18:23:29 +08:00
|
|
|
|
UserApi.doGetMinePackageCount()
|
|
|
|
|
.then(res => {
|
2025-04-03 10:44:12 +08:00
|
|
|
|
_self.setData({
|
|
|
|
|
allCount: res.ALL,
|
|
|
|
|
materialCount: res.MATERIAL
|
|
|
|
|
})
|
2025-04-09 11:31:24 +08:00
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
2025-03-31 18:23:29 +08:00
|
|
|
|
console.log(err)
|
2025-04-03 10:44:12 +08:00
|
|
|
|
_self.setData({
|
|
|
|
|
allCount: 0,
|
|
|
|
|
materialCount: 0
|
|
|
|
|
})
|
2025-04-09 11:31:24 +08:00
|
|
|
|
_self.setData({
|
|
|
|
|
errorHint: err.msg ? err.msg : '网络信号开小差啦,请您稍后再试,给您添麻烦~',
|
|
|
|
|
showError: true
|
|
|
|
|
})
|
2025-03-31 18:23:29 +08:00
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//优惠卷
|
|
|
|
|
doCoupons() {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/mine/mineAccount/mineCoupons/mineCoupons',
|
|
|
|
|
})
|
2025-03-21 18:05:54 +08:00
|
|
|
|
},
|
2025-03-24 18:05:54 +08:00
|
|
|
|
//跳转充值页面
|
|
|
|
|
doPay() {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/copyright/payment/payment',
|
|
|
|
|
})
|
2025-04-03 17:40:39 +08:00
|
|
|
|
},
|
|
|
|
|
//条目点击
|
|
|
|
|
itemClick(e) {
|
|
|
|
|
const path = e.currentTarget.dataset.path
|
|
|
|
|
if (path == '') {
|
2025-04-07 11:04:08 +08:00
|
|
|
|
this.setData({
|
|
|
|
|
showHint: true,
|
|
|
|
|
hintTxt: `鉴于功能特性,需在电脑端完成操作。请打开浏览器,登录网址${copyrightUrl},进行后续操作。`
|
2025-04-03 17:40:39 +08:00
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: path,
|
|
|
|
|
})
|
|
|
|
|
}
|
2025-04-07 11:04:08 +08:00
|
|
|
|
},
|
|
|
|
|
closeHint(e) {
|
|
|
|
|
this.setData({
|
|
|
|
|
showHint: false,
|
|
|
|
|
hintTxt: ''
|
|
|
|
|
})
|
2025-04-09 11:31:24 +08:00
|
|
|
|
},
|
|
|
|
|
//下拉刷新
|
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
this.getMineAccount() //获取账户信息
|
|
|
|
|
this.getMinePackageCount() //获取套餐包信息
|
|
|
|
|
wx.stopPullDownRefresh()
|
2025-03-24 18:05:54 +08:00
|
|
|
|
}
|
2025-03-21 18:05:54 +08:00
|
|
|
|
})
|