初始化
This commit is contained in:
165
pages/updateUser/updateUser.js
Normal file
165
pages/updateUser/updateUser.js
Normal file
@@ -0,0 +1,165 @@
|
||||
const app = getApp();
|
||||
const phoneReg = /^((\+|00)86)?1\d{10}$/;
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
nvabarData: {
|
||||
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
|
||||
title: "编辑站员", //导航栏 中间的标题
|
||||
},
|
||||
name: "",
|
||||
phone: "",
|
||||
userItem: null,
|
||||
// 此页面 页面内容距最顶部的距离
|
||||
height: app.globalData.height * 2 + 20,
|
||||
confirmName: '',//确认按钮名称
|
||||
confirmBtn: false,//按钮颜色变化
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
const userItem = JSON.parse(options.queryBean) || null;
|
||||
this.setData({
|
||||
userItem,
|
||||
["nvabarData.title"]: userItem ? "编辑站员" : "添加站员",
|
||||
confirmName: userItem ? "修改" : "添加",
|
||||
name: userItem ? userItem.name : "",
|
||||
phone: userItem ? userItem.phone : "",
|
||||
});
|
||||
},
|
||||
bindNameInput(e) {
|
||||
this.setData({
|
||||
name: e.detail.value,
|
||||
});
|
||||
this.isConfirmBtn()
|
||||
},
|
||||
bindPhoneInput(e) {
|
||||
this.setData({
|
||||
phone: e.detail.value,
|
||||
});
|
||||
this.isConfirmBtn()
|
||||
},
|
||||
isConfirmBtn() {
|
||||
if (this.data.name != '' && this.data.phone != '') {
|
||||
this.setData({
|
||||
confirmBtn: true
|
||||
});
|
||||
}
|
||||
},
|
||||
cancelBtnHandle() {
|
||||
wx.navigateBack();
|
||||
},
|
||||
confirmBtnHandle() {
|
||||
if (!this.data.name) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "请输入姓名!",
|
||||
showCancel: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!this.data.phone) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "请输入手机号!",
|
||||
showCancel: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.data.phone && !phoneReg.test(this.data.phone)) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "请输入正确的手机号!",
|
||||
showCancel: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const cooId = wx.getStorageSync("cooperation").id;
|
||||
let params = {};
|
||||
if (this.data.userItem) {
|
||||
params.id = this.data.userItem.id;
|
||||
}
|
||||
params.cooId = cooId;
|
||||
params.parentUserId = wx.getStorageSync("cooperation").userId;
|
||||
params.name = this.data.name;
|
||||
params.phone = this.data.phone;
|
||||
params.userType = 1;
|
||||
this.upadteUserHandle(params);
|
||||
},
|
||||
upadteUserHandle(params) {
|
||||
wx.request({
|
||||
url: app.globalData.devUrl + `/zx/user/create-or-update/user`,
|
||||
method: `post`,
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
data: {
|
||||
...params,
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.data.code == "0000") {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "操作成功",
|
||||
showCancel: false,
|
||||
});
|
||||
wx.navigateBack();
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: res.data.msg,
|
||||
showCancel: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
console.log(res);
|
||||
},
|
||||
fail: function (data) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "网络传输异常",
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() { },
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() { },
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() { },
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() { },
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() { },
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() { },
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() { },
|
||||
});
|
||||
5
pages/updateUser/updateUser.json
Normal file
5
pages/updateUser/updateUser.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"nav-bar": "/components/navbarMyOil/index"
|
||||
}
|
||||
}
|
||||
25
pages/updateUser/updateUser.wxml
Normal file
25
pages/updateUser/updateUser.wxml
Normal file
@@ -0,0 +1,25 @@
|
||||
<nav-bar navbar-data='{{nvabarData}}'></nav-bar>
|
||||
<view class='home-page' style='padding-top: {{height}}px'>
|
||||
<view>
|
||||
<view class="item firstItem">
|
||||
<view class="title">
|
||||
<text class='titleCell'>站员姓名</text>
|
||||
</view>
|
||||
<view class="name">
|
||||
<input value="{{name}}" maxlength='{{12}}' placeholder='请输入站员姓名' bindinput='bindNameInput' />
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="title">
|
||||
<text class='titleCell'>手机号码</text>
|
||||
</view>
|
||||
<view class="name">
|
||||
<input value="{{phone}}" maxlength='{{11}}' placeholder='请输入站员手机号码' bindinput='bindPhoneInput' />
|
||||
</view>
|
||||
</view>
|
||||
<view class="btnList">
|
||||
<view class="cancelBtn" bind:tap="cancelBtnHandle">取消</view>
|
||||
<view class="confirmBtn {{confirmBtn?'confirmBtnEdit':'confirmBtn'}}" bind:tap="confirmBtnHandle" >{{confirmName}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
174
pages/updateUser/updateUser.wxss
Normal file
174
pages/updateUser/updateUser.wxss
Normal file
@@ -0,0 +1,174 @@
|
||||
.container {
|
||||
min-height: 100%;
|
||||
overflow: hidden;
|
||||
overflow-y: hidden;
|
||||
/* background:#fff; */
|
||||
}
|
||||
|
||||
.Big {
|
||||
position: relative;
|
||||
top: -250rpx;
|
||||
width: 100%;
|
||||
margin: 10rpx auto;
|
||||
/* left: 2.5%; */
|
||||
}
|
||||
|
||||
.BoxLine {
|
||||
display: flex;
|
||||
font-size: 30rpx;
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
text-align: center;
|
||||
border-bottom: 2rpx solid #e5e5e5;
|
||||
}
|
||||
|
||||
.firstItem {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
height: 44px;
|
||||
align-items: center;
|
||||
margin: 24rpx 34rpx;
|
||||
padding-left: 12px;
|
||||
gap: 8px;
|
||||
box-shadow: 0 0 4px 0 #F3F5F7;
|
||||
}
|
||||
|
||||
.title {
|
||||
position: relative;
|
||||
font-size: 30rpx;
|
||||
line-height: 80rpx;
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.name {
|
||||
position: relative;
|
||||
font-size: 30rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
flex: 3;
|
||||
}
|
||||
|
||||
.name input {
|
||||
font-size: 30rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
flex: 3;
|
||||
/* flex: 1; */
|
||||
}
|
||||
|
||||
.titleCell {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.titleCell::before {
|
||||
position: absolute;
|
||||
content: "*";
|
||||
top: -14px;
|
||||
left: -8px;
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
.phone {
|
||||
flex: 3;
|
||||
}
|
||||
|
||||
.btnList {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
margin-top: 65.4px;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.cancelBtn,
|
||||
.confirmBtn {
|
||||
width: 140px;
|
||||
height: 40px;
|
||||
text-align: center;
|
||||
line-height: 40px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.cancelBtn {
|
||||
border: 1px solid #AEAEAE;
|
||||
background: #FFF;
|
||||
color: #808080;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.confirmBtn {
|
||||
background: linear-gradient(0deg, #ffffff80 0%, #ffffff80 100%), linear-gradient(115deg, #62B2FF -1.34%, #3C80F6 100%);
|
||||
color: #ffffff;
|
||||
font-size: 16px;
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
.createBtn {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
background: #169bd5;
|
||||
color: #fff;
|
||||
height: 52px;
|
||||
line-height: 52px;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
width: 90%;
|
||||
position: relative;
|
||||
top: -150rpx;
|
||||
}
|
||||
.confirmBtnEdit{
|
||||
background: linear-gradient(115deg, #62B2FF -1.34%, #3C80F6 100%);
|
||||
}
|
||||
/* .btn {
|
||||
background: #0093dd;
|
||||
border: none;
|
||||
color: #fff;
|
||||
letter-spacing: 4rpx;
|
||||
border-radius: 10rpx;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
text-align: center;
|
||||
font-weight: 400;
|
||||
font-size: 38rpx;
|
||||
} */
|
||||
|
||||
/* .input-box .btn {
|
||||
width: 100%;
|
||||
} */
|
||||
|
||||
/* .number {
|
||||
font-size: 30rpx;
|
||||
margin-top: 30rpx;
|
||||
} */
|
||||
|
||||
/* .boxIMg_top { */
|
||||
/* width: 100%; */
|
||||
/* position: absolute; */
|
||||
/* } */
|
||||
|
||||
/* .boxIMg_top image {
|
||||
width: 100%;
|
||||
height: 510rpx;
|
||||
} */
|
||||
|
||||
/* .boxName {
|
||||
position: absolute;
|
||||
top: 260rpx;
|
||||
left: 34%;
|
||||
} */
|
||||
|
||||
/* .top_img {
|
||||
position: absolute;
|
||||
top: 320rpx;
|
||||
left: 6%;
|
||||
} */
|
||||
Reference in New Issue
Block a user