110 lines
3.2 KiB
JavaScript
110 lines
3.2 KiB
JavaScript
import ProjectService from '../../../net/api/projectApi'
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
imgAssets: app.globalData.imgAssetsUrl,
|
|
localImgAssets: app.globalData.localAssets,
|
|
appUrl: app.globalData.appUrl,
|
|
urgent: 0,
|
|
projTypes: [], //全托管,写材料 type= ALL type =MATERIAL
|
|
allPrice: 0,
|
|
materialPrice: 0,
|
|
isUrgent: false, //是否加急
|
|
showSuccess: false,
|
|
successHint: ''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
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
|
|
})
|
|
},
|
|
//点击复制
|
|
copyLink() {
|
|
const _self = this
|
|
wx.setClipboardData({
|
|
data: 'https://www.aimzhu.com',
|
|
success: () => {
|
|
_self.setData({
|
|
successHint: '复制成功',
|
|
showSuccess: true
|
|
})
|
|
},
|
|
fail: err => {
|
|
console.log(err)
|
|
}
|
|
})
|
|
}
|
|
}) |