ts_aimz/pages/copyright/createBuy/createBuy.js
2025-04-09 11:31:24 +08:00

89 lines
2.6 KiB
JavaScript

import ProjectService from '../../../net/api/projectApi'
Page({
/**
* 页面的初始数据
*/
data: {
urgent: 0,
projTypes: [], //全托管,写材料 type= ALL type =MATERIAL
allPrice: 0,
materialPrice: 0,
isUrgent: false, //是否加急
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
wx.setNavigationBarTitle({
title: '创建软著',
})
wx.setNavigationBarColor({
frontColor: '#000000', // 必写项,字体颜色仅支持#ffffff和#000000
backgroundColor: '#F0F0F0', // 传递的颜色值,仅支持十六进制颜色
animation: { // 可选项
duration: 500,
timingFunc: 'easeIn'
}
})
this.doGetPrice()
},
//是否加急
doUrgent(e) {
const _self = this
_self.setData({
isUrgent: !_self.data.isUrgent
})
},
//获取单价
doGetPrice() {
wx.showLoading({
title: '加载中...',
})
const _self = this
ProjectService.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({
title: '数据有误,请稍后重试',
icon: 'error',
success: () => {
wx.navigateBack()
}
})
})
},
//打开项目信息编辑页面
doBuy(e) {
//计算价格
const _self = this
var price = e.currentTarget.dataset.type == 'ALL' ? _self.data.allPrice : _self.data.materialPrice
var type = e.currentTarget.dataset.type
if (type == 'ALL' && _self.data.isUrgent) {
price += _self.data.urgent
}
const urgent = _self.data.isUrgent ? 'URGENT' : ''
wx.navigateTo({
url: '../createProjectInfo/createProjectInfo?type=' + type + '&price=' + price + '&isUrgent=' + urgent
})
}
})