Initial commit
This commit is contained in:
@@ -0,0 +1,356 @@
|
||||
|
||||
import { fetchDemandContractDetail, demandOperate } from '../../../services/demand/fetchDemand';
|
||||
// pages/demand/contract/index.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
demandId: 0,
|
||||
actualAccount: 0,
|
||||
contract: null,
|
||||
agreementUrl: '', // 签约条款URL
|
||||
formData: {
|
||||
contractType: 'personal', // 默认选择个人签约
|
||||
// 个人签约信息
|
||||
name: '',
|
||||
phone: '',
|
||||
idCard: '',
|
||||
// 企业签约信息
|
||||
companyName: '',
|
||||
legalPerson: '',
|
||||
companyPhone: '',
|
||||
// 开发信息
|
||||
taskContent: '',
|
||||
needDays: '',
|
||||
totalCost: '',
|
||||
// 签约条款
|
||||
agreementChecked: false
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
// 设置签约条款URL(进行编码)
|
||||
const source = options?.source;
|
||||
const demandId = options?.demandId;
|
||||
const agreementUrl = encodeURIComponent(wx.$api.ApiRoot + '/assets/h5/terms/platform_contract_service_terms.html');
|
||||
this.setData({
|
||||
source,
|
||||
demandId,
|
||||
agreementUrl
|
||||
});
|
||||
this.getContractDetail();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
},
|
||||
|
||||
// 签约类型切换
|
||||
onContractTypeChange(e) {
|
||||
console.log(e.detail.value)
|
||||
this.setData({
|
||||
'formData.contractType': e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
// 个人签约信息变更
|
||||
onNameChange(e) {
|
||||
this.setData({
|
||||
'formData.name': e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
onPhoneChange(e) {
|
||||
this.setData({
|
||||
'formData.phone': e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
onIdCardChange(e) {
|
||||
this.setData({
|
||||
'formData.idCard': e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
// 企业签约信息变更
|
||||
onCompanyNameChange(e) {
|
||||
this.setData({
|
||||
'formData.companyName': e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
onLegalPersonChange(e) {
|
||||
this.setData({
|
||||
'formData.legalPerson': e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
onCompanyPhoneChange(e) {
|
||||
this.setData({
|
||||
'formData.companyPhone': e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
// 开发信息变更
|
||||
onDevelopmentContentChange(e) {
|
||||
this.setData({
|
||||
'formData.taskContent': e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
onDevelopmentPeriodChange(e) {
|
||||
this.setData({
|
||||
'formData.needDays': e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
onTotalCostChange(e) {
|
||||
const number = Number(e.detail.value * 0.9);
|
||||
this.setData({
|
||||
'formData.totalCost': e.detail.value,
|
||||
'actualAccount': Math.round(e.detail.value * 0.9)
|
||||
});
|
||||
},
|
||||
|
||||
// 签约条款变更
|
||||
onAgreementChange(e) {
|
||||
console.log('checkbox', e);
|
||||
this.setData({
|
||||
'formData.agreementChecked': e.detail.checked
|
||||
});
|
||||
},
|
||||
|
||||
// 表单验证
|
||||
validateForm() {
|
||||
const { formData } = this.data;
|
||||
const contractType = formData.contractType;
|
||||
if (contractType === 'personal') {
|
||||
if (!formData.name || !formData.phone || !formData.idCard) {
|
||||
wx.showToast({
|
||||
title: '请填写完整的个人信息',
|
||||
icon: 'none'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!formData.companyName || !formData.legalPerson || !formData.companyPhone) {
|
||||
wx.showToast({
|
||||
title: '请填写完整的企业信息',
|
||||
icon: 'none'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!formData.taskContent || !formData.needDays || !formData.totalCost) {
|
||||
wx.showToast({
|
||||
title: '请填写完整的开发信息',
|
||||
icon: 'none'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!formData.agreementChecked) {
|
||||
wx.showToast({
|
||||
title: '请阅读并同意签约条款',
|
||||
icon: 'none'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
//获取签约详情
|
||||
getContractDetail() {
|
||||
let { demandId, formData } = this.data;
|
||||
let params = {
|
||||
demandId,
|
||||
}
|
||||
fetchDemandContractDetail(params).then(
|
||||
(res) => {
|
||||
console.log(res);
|
||||
if (res.code == 1) {
|
||||
let resData = res.data;
|
||||
let resFormData = this.data.source == 'dev' ? resData.data_json.devData : resData.data_json.customData;
|
||||
this.setData({
|
||||
contract: resData,
|
||||
formData: resFormData,
|
||||
'formData.contractType': resFormData?.contractType || 'personal',
|
||||
'formData.taskContent': resData.task_content,
|
||||
'formData.needDays': resData.need_days,
|
||||
'formData.totalCost': resData.total_amount,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
//签约订单支付
|
||||
onPay(order) {
|
||||
let goodsList = [];
|
||||
let storeId = order.store_id;
|
||||
order.order_goods.forEach((data) => {
|
||||
let query = {
|
||||
quantity: data.buy_quantity,
|
||||
storeId: storeId,
|
||||
spuId: data.spu_id,
|
||||
goodsName: data.goods_name,
|
||||
available: 1,
|
||||
price: data.goods_payment_price,
|
||||
primaryImage: data.goods_picture_url,
|
||||
skuId: data.sku_id,
|
||||
thumb: data.goods_picture_url,
|
||||
title: data.goods_name,
|
||||
};
|
||||
goodsList.push(query);
|
||||
});
|
||||
console.log(goodsList);
|
||||
console.log(JSON.stringify(goodsList));
|
||||
let urlQueryStr = wx.$util.obj2Params({
|
||||
orderNo: order.order_no,
|
||||
goodsRequestList: JSON.stringify(goodsList),
|
||||
}, true);
|
||||
console.log(urlQueryStr);
|
||||
urlQueryStr = urlQueryStr ? `?${urlQueryStr}` : '';
|
||||
const path = `/pages/order/order-confirm/index${urlQueryStr}`;
|
||||
wx.navigateTo({
|
||||
url: path,
|
||||
});
|
||||
},
|
||||
|
||||
// 提交表单
|
||||
onSubmit() {
|
||||
if (!this.validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: 调用后端API提交签约信息
|
||||
wx.showLoading({
|
||||
title: '提交中...'
|
||||
});
|
||||
|
||||
const { demandId, formData, source } = this.data;
|
||||
let params = {
|
||||
demandId,
|
||||
formData,
|
||||
source,
|
||||
'agree': 1,
|
||||
'contractType': 1,
|
||||
'opType': source == 'dev' ? 'contractDev' : 'contractCustomer',
|
||||
}
|
||||
demandOperate(params).then(
|
||||
(res) => {
|
||||
console.log(res);
|
||||
wx.hideLoading();
|
||||
if (res.code == 1) {
|
||||
if (source == 'dev') {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
showCancel: false,
|
||||
content: '签约已提交,等待客户签约确认',
|
||||
success: (res2) => {
|
||||
if (res2.confirm) {
|
||||
//返回上一页
|
||||
// wx.navigateBack({ delta: 2 });
|
||||
wx.$util.backAndRefresh(2);
|
||||
console.log('用户点击确定');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (res.data.order_status == 20) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
showCancel: false,
|
||||
content: '签约完成,等待开发者开始工作,返回我的需求列表',
|
||||
success: (res3) => {
|
||||
if (res3.confirm) {
|
||||
// wx.navigateBack({ delta: 2 });
|
||||
wx.$util.backAndRefresh(2);
|
||||
console.log('用户点击确定');
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
showCancel: false,
|
||||
content: '签约完成,去支付首付款(总金额的50%)',
|
||||
success: (res2) => {
|
||||
if (res2.confirm) {
|
||||
//支付预付款
|
||||
this.onPay(res.data);
|
||||
console.log('用户点击确定');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
() => {
|
||||
//接口异常处理
|
||||
wx.showToast({
|
||||
title: '操作失败',
|
||||
icon: 'none'
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"t-radio": "tdesign-miniprogram/radio/radio",
|
||||
"t-radio-group": "tdesign-miniprogram/radio-group/radio-group",
|
||||
"t-input": "tdesign-miniprogram/input/input",
|
||||
"t-divider": "tdesign-miniprogram/divider/divider",
|
||||
"t-textarea": "tdesign-miniprogram/textarea/textarea",
|
||||
"t-checkbox": "tdesign-miniprogram/checkbox/checkbox",
|
||||
"t-button": "tdesign-miniprogram/button/button"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<!--pages/demand/contract/index.wxml-->
|
||||
<view class="contract-container">
|
||||
<view class="form-section">
|
||||
<t-radio-group value="{{formData.contractType}}" bind:change="onContractTypeChange" class="radio-group-horizontal">
|
||||
<t-radio value="personal" label="个人签约" />
|
||||
<t-radio value="company" label="企业签约" />
|
||||
</t-radio-group>
|
||||
</view>
|
||||
|
||||
<!-- 个人签约表单 -->
|
||||
<block wx:if="{{formData.contractType === 'personal'}}">
|
||||
<view class="form-group">
|
||||
<t-input label="个人姓名" placeholder="请输入姓名" value="{{formData.name}}" bind:change="onNameChange" />
|
||||
<t-input label="身份证号" placeholder="请输入身份证号" type="idcard" value="{{formData.idCard}}" bind:change="onIdCardChange" />
|
||||
<t-input label="联系电话" placeholder="请输入联系电话" type="number" value="{{formData.phone}}" bind:change="onPhoneChange" />
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!-- 企业签约表单 -->
|
||||
<block wx:if="{{formData.contractType === 'company'}}">
|
||||
<view class="form-group">
|
||||
<t-input label="企业名称" placeholder="请输入企业名称" value="{{formData.companyName}}" bind:change="onCompanyNameChange" />
|
||||
<t-input label="法定代表人" placeholder="请输入法定代表人姓名" value="{{formData.legalPerson}}" bind:change="onLegalPersonChange" />
|
||||
<t-input label="联系电话" placeholder="请输入联系电话" type="number" value="{{formData.companyPhone}}" bind:change="onCompanyPhoneChange" />
|
||||
</view>
|
||||
</block>
|
||||
<t-divider content="以上信息会做加密处理,对方不可见,仅作合同纠纷时使用" />
|
||||
|
||||
<!-- 开发信息 -->
|
||||
<view class="form-group">
|
||||
<t-textarea label="开发内容" placeholder="请详细描述开发内容" disabled="{{source != 'dev'}}" value="{{formData.taskContent}}" bind:change="onDevelopmentContentChange" />
|
||||
<t-input label="总费用" placeholder="请输入总费用" suffix="元" align="right" type="number" tips="{{source == 'dev' ? '预计到手金额 ' + actualAccount + '元 + 10%的平台服务费' : '总费用 = 首付款50% + 尾款50%'}}" disabled="{{source != 'dev'}}" value="{{formData.totalCost}}" bind:change="onTotalCostChange" />
|
||||
<t-input label="开发工期" placeholder="请输入开发工期" suffix="天" align="right" type="number" disabled="{{source != 'dev'}}" value="{{formData.needDays}}" bind:change="onDevelopmentPeriodChange" />
|
||||
</view>
|
||||
|
||||
<!-- 签约条款 -->
|
||||
<view class="agreement-section">
|
||||
<t-checkbox value="{{formData.agreementChecked}}" bind:change="onAgreementChange">
|
||||
我已阅读并同意
|
||||
<navigator url="/pages/demand/agreement/index?url={{agreementUrl}}" class="agreement-link">《签约服务条款》</navigator>
|
||||
</t-checkbox>
|
||||
</view>
|
||||
|
||||
<!-- 提交按钮 -->
|
||||
<view class="submit-section">
|
||||
<t-button theme="primary" disabled="{{(source == 'dev' && contract.status == 2) || (source == 'customer' && contract.status2 == 2)}}" block bind:tap="onSubmit">确认签约</t-button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,75 @@
|
||||
/* pages/demand/contract/index.wxss */
|
||||
.contract-container {
|
||||
padding: 32rpx;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
/* 横向单选组样式 */
|
||||
.radio-group-horizontal {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 48rpx;
|
||||
}
|
||||
|
||||
.radio-group-horizontal .t-radio {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
/* 表单组样式 */
|
||||
.form-group {
|
||||
margin-bottom: 32rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
font-size: 28rpx;
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
margin-bottom: 24rpx;
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
|
||||
/* 输入框样式 */
|
||||
.t-input {
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
/* 文本域样式 */
|
||||
.t-textarea {
|
||||
min-height: 160rpx;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.agreement-section {
|
||||
margin: 32rpx 0;
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
|
||||
.submit-section {
|
||||
margin-top: 48rpx;
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
|
||||
/* 复选框样式 */
|
||||
.t-checkbox {
|
||||
margin: 24rpx 0;
|
||||
}
|
||||
|
||||
/* 签约条款链接样式 */
|
||||
.agreement-link {
|
||||
display: inline;
|
||||
color: #0052d9;
|
||||
text-decoration: underline;
|
||||
}
|
||||
Reference in New Issue
Block a user