完成了登录模块

This commit is contained in:
2025-05-19 09:08:33 +08:00
parent 7c934ded5f
commit 3fe9c3c209
20 changed files with 364 additions and 208 deletions

View File

@ -1,65 +1,94 @@
// pages/projectModule/applyCode/applyCode.js
const { baseUrl } = require('../../../request');
Page({
/**
* 页面的初始数据
*/
data: {
projectId: '', // 项目id
promoCodeDesc: '', // 富文本推广码说明
salespersonName: '',
salespersonPhone: '',
mode: 'add' // 'add'(新增) or 'view'(查看资料)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
this.setData({
projectId: options.id || '',
promoCodeDesc: decodeURIComponent(options.desc || ''),
mode: options.mode || 'add',
salespersonName: options.name ? decodeURIComponent(options.name) : '',
salespersonPhone: options.phone ? decodeURIComponent(options.phone) : ''
});
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 输入绑定
onNameInput(e) {
// 仅在新增模式允许编辑
if (this.data.mode !== 'view') {
this.setData({ salespersonName: e.detail.value });
}
},
onPhoneInput(e) {
if (this.data.mode !== 'view') {
this.setData({ salespersonPhone: e.detail.value });
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
// 申请资料报备
onApply() {
// 如果是查看模式,阻止提交
if (this.data.mode === 'view') return;
},
const { salespersonName, salespersonPhone, projectId } = this.data;
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
if (!salespersonName.trim()) {
wx.showToast({ title: '请输入业务员姓名', icon: 'none' });
return;
}
const phoneReg = /^1[3-9]\d{9}$/;
if (!salespersonPhone.trim()) {
wx.showToast({ title: '请输入手机号', icon: 'none' });
return;
}
if (!phoneReg.test(salespersonPhone.trim())) {
wx.showToast({ title: '手机号格式不正确', icon: 'none' });
return;
}
const token = wx.getStorageSync('token');
wx.request({
url: baseUrl + '/promoCodeApply/apply',
method: 'POST',
header: {
'Authorization': token,
'Content-Type': 'application/json'
},
data: {
salespersonName,
salespersonPhone,
projectId
},
success: (res) => {
if (res.data.code === 1) {
wx.showToast({
title: '申请成功',
icon: 'success',
duration: 1000
});
setTimeout(() => {
wx.navigateBack();
}, 1000);
} else {
wx.showToast({
title: res.data.message || '申请失败',
icon: 'none'
});
}
},
fail: () => {
wx.showToast({
title: '网络错误',
icon: 'none'
});
}
});
}
})
});

View File

@ -2,17 +2,32 @@
<view class="flex-col section">
<view class="flex-col section_2">
<text class="self-start font text">业务员姓名</text>
<input class="flex-col justify-start items-start view text-wrapper input" placeholder="请输入" />
<input class="flex-col justify-start items-start view text-wrapper input"
placeholder="请输入"
value="{{salespersonName}}"
bindinput="onNameInput"
disabled="{{mode === 'view'}}" />
<view class="self-stretch divider"></view>
<text class="self-start font text_3">业务员手机号</text>
<input class="flex-col justify-start items-start view text-wrapper input_1" placeholder="请输入" />
<input class="flex-col justify-start items-start view text-wrapper input_1"
placeholder="请输入"
value="{{salespersonPhone}}"
bindinput="onPhoneInput"
disabled="{{mode === 'view'}}" />
<view class="self-stretch divider"></view>
</view>
<view class="flex-col group">
<view class="flex-col justify-start items-center text-wrapper_2">
<view style="padding-top: {{mode === 'view' ? '0' : '80.63rpx'}}" class="flex-col group">
<!-- “申请资料报备”按钮只在新增模式显示 -->
<view class="flex-col justify-start items-center text-wrapper_2"
bindtap="onApply"
wx:if="{{mode !== 'view'}}">
<text class="font text_4">申请资料报备</text>
</view>
<view class="flex-col justify-start section_3 mt-27"><view class="section_4"></view></view>
<view class="flex-col justify-start section_3 mt-27">
<view class="section_4">
<rich-text class="promo-desc" nodes="{{promoCodeDesc}}"></rich-text>
</view>
</view>
</view>
</view>
</view>
</view>

View File

@ -67,8 +67,6 @@
margin-left: 42.19rpx;
margin-right: 44.06rpx;
background-color: #ffffff00;
height: 808.58rpx;
border: solid 1.88rpx #000000;
}
.input {
padding: 13.13rpx 18.75rpx 15rpx 18.75rpx;