zhaoxiaohai 4 rokov pred
rodič
commit
1ce896ed10

+ 2 - 0
README.md

@@ -18,6 +18,8 @@
 
 ​	My_GeneralTemplate -- 通用模板 个人主页 个人信息 团队管理 产品管理
 
+​	My_GreyRectangle -- 灰色矩形 用于个人信息表单
+
 # 缓存
 
 userData -- 用户基本数据 -- 保存数据:index-用户列表下标,token,fisadministrator--是否主账号,tagentsid,tenterpriseid,userid

+ 3 - 3
components/My_GeneralTemplate/index.wxss

@@ -1,4 +1,3 @@
-
 /* 容器 */
 .container {
     width: 702rpx;
@@ -11,7 +10,7 @@
 
 /* 顶部背景图片 */
 .backImg {
-    position: fixed;
+    position: absolute;
     width: 100vw;
     top: 0;
     left: 0;
@@ -20,4 +19,5 @@
 
 .backImg>image {
     width: 100%;
-}
+}
+

+ 31 - 0
components/My_GreyRectangle/index.js

@@ -0,0 +1,31 @@
+// components/My_GreyRectangle/index.js
+Component({
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+        /* 标题 */
+        title: {
+            type: String,
+            value: "title"
+        },
+        /* 是否必填 */
+        required: {
+            type: Boolean
+        }
+    },
+
+    /**
+     * 组件的初始数据
+     */
+    data: {
+
+    },
+
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+
+    }
+})

+ 4 - 0
components/My_GreyRectangle/index.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 6 - 0
components/My_GreyRectangle/index.wxml

@@ -0,0 +1,6 @@
+<view class="grey_rectangle">
+    <view class="grey_rectangle_title">{{title}}<text wx:if="{{required}}">*</text></view>
+    <view class="grey_rectangle_slot">
+        <slot></slot>
+    </view>
+</view>

+ 26 - 0
components/My_GreyRectangle/index.wxss

@@ -0,0 +1,26 @@
+/* 盒子 */
+.grey_rectangle{
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    padding: 28rpx;
+    background-color: #F6F7F8;
+    border-radius: 10rpx;
+    box-sizing: border-box;
+    margin-bottom: 30rpx;
+}
+
+/* 标题 */
+.grey_rectangle_title{
+    font-size: 32rpx;
+    color: #000000;
+}
+.grey_rectangle_title>text{
+    color: #4BBECF;
+}
+
+/* 插槽 */
+.grey_rectangle_slot{
+    display: flex;
+    align-items: center;
+}

+ 1 - 1
pages/login/index.js

@@ -12,7 +12,7 @@ Page({
      * 页面的初始数据
      */
     data: {
-        pageType: "firm", //页面类型 login 手机登录页面 signin 注册页面 firm 商户认证 changeUser 切换用户
+        pageType: "login", //页面类型 login 手机登录页面 signin 注册页面 firm 商户认证 changeUser 切换用户
         butText: "", //按钮文本
         /* 登录 */
         fphonenumber: 17757394388, //手机号码

+ 79 - 3
pages/userCenter/index.js

@@ -1,4 +1,11 @@
-// pages/userCenter/index.js
+import {
+    ApiModel
+} from "../../utils/api";
+const _Http = new ApiModel();
+import {
+    TestVerify
+} from "../../utils/verify";
+const _Verify = new TestVerify();
 Page({
 
     /**
@@ -6,6 +13,12 @@ Page({
      */
     data: {
         userMessage: {}, //用户数据列表
+        /* 错误提示 */
+        errTips: {
+            fname: false, //用户名
+            frole: false, //身份/职位
+            fphonenumber: false, //手机号
+        },
     },
 
     /**
@@ -13,9 +26,72 @@ Page({
      */
     onLoad: function (options) {
         const userMessage = JSON.parse(options.data);
-        console.log(userMessage)
+        const attinfos = {
+            attinfos: userMessage.attinfos
+        }
         this.setData({
-            userMessage
+            userMessage: attinfos,
+            fname: userMessage.fname,
+            fphonenumber: userMessage.fphonenumber,
+            fsex: userMessage.fsex,
+            fbirthdate: userMessage.fbirthdate,
+            femail: userMessage.femail,
+            fwechatno: userMessage.fwechatno,
+            faddress: userMessage.faddress,
+            frole: userMessage.frole
+        })
+    },
+    /* 表单验证 */
+    formVerify() {
+        let errTips = this.data.errTips,
+            verify = true;
+        /* 验证用户名  */
+        if (!_Verify.required(this.data.fname)) {
+            errTips.fname = true;
+            verify = false;
+        }
+        /* 验证身份 */
+        if (!_Verify.required(this.data.frole)) {
+            errTips.frole = true;
+            verify = false;
+        }
+        if (!verify) {
+            this.setData({
+                errTips
+            })
+        }
+        return verify;
+    },
+    /* 提交 */
+    submit() {
+        if (!this.formVerify()) return wx.showToast({
+            title: '请检查表单内容',
+            icon: "none"
+        });
+        _Http.basic({
+            "accesstoken": wx.getStorageSync('userData').token,
+            "classname": "customer.usercenter.usermsg.usermsg",
+            "method": "update_usermsg",
+            "content": {
+                "fname": this.data.fname,
+                "fsex": this.data.fsex,
+                "fbirthdate": this.data.fbirthdate,
+                "femail": this.data.femail,
+                "fwechatno": this.data.fwechatno,
+                "faddress": this.data.faddress,
+                "frole": this.data.frole
+            }
+        }).then(res => {
+            if (res.msg == "成功") {
+                wx.showToast({
+                    title: '保存成功',
+                })
+                setTimeout(() => {
+                    wx.navigateBack({
+                        delta: 1
+                    })
+                }, 500)
+            }
         })
     },
     /* 修改用户头像 */

+ 2 - 1
pages/userCenter/index.json

@@ -1,6 +1,7 @@
 {
   "usingComponents": {
     "My_GeneralTemplate": "../../components/My_GeneralTemplate/index",
-    "My_UploadFiles":"../../components/My_UploadFiles/index"
+    "My_UploadFiles":"../../components/My_UploadFiles/index",
+    "My_GreyRectangle":"../../components/My_GreyRectangle/index"
   }
 }

+ 34 - 3
pages/userCenter/index.wxml

@@ -1,4 +1,5 @@
-<My_GeneralTemplate>
+<My_GeneralTemplate padBot="30rpx">
+    <!-- 用户头像 -->
     <view class="user_header">
         <view class="user_header_msg">
             <!-- 头像 -->
@@ -13,5 +14,35 @@
         </view>
         <view style="height: 2rpx; width: 100%; background-color: #979797; opacity: 0.3;"></view>
     </view>
-
-</My_GeneralTemplate>
+    <!-- 表单输入区 -->
+    <view class="user_message_input">
+        <My_GreyRectangle title="账号名" required>
+            <van-field autosize model:value="{{ fname }}" data-name="fname" bind:focus='inputFocus' bindblur='inputBlur' error="{{errTips.fname}}" input-class="input-class" placeholder="请输入账户名" border="{{ false }}" bind:change="onChange" />
+        </My_GreyRectangle>
+        <My_GreyRectangle title="身份/职位" required>
+            <van-field autosize model:value="{{ frole }}" data-name="frole" bind:focus='inputFocus' bindblur='inputBlur' error="{{errTips.frole}}" input-class="input-class" placeholder="身份/职位" border="{{ false }}" bind:change="onChange" />
+        </My_GreyRectangle>
+        <My_GreyRectangle title="手机" required>
+            <van-field autosize disabled model:value="{{ fphonenumber }}" data-name="fphonenumber" bind:focus='inputFocus' bindblur='inputBlur' error="{{errTips.fphonenumber}}" input-class="input-class" placeholder="身份/职位" border="{{ false }}" bind:change="onChange" />
+        </My_GreyRectangle>
+        <My_GreyRectangle title="微信">
+            <van-field autosize model:value="{{ fwechatno }}" input-class="input-class" placeholder="微信号/手机号" border="{{ false }}" bind:change="onChange" />
+        </My_GreyRectangle>
+        <My_GreyRectangle title="地址">
+            <van-field autosize model:value="{{ faddress }}" input-class="input-class" placeholder="请输入地址" border="{{ false }}" bind:change="onChange" />
+        </My_GreyRectangle>
+        <My_GreyRectangle title="性别">
+        </My_GreyRectangle>
+        <My_GreyRectangle title="生日">
+            <view></view>
+        </My_GreyRectangle>
+        <My_GreyRectangle title="邮箱">
+            <van-field autosize model:value="{{ femail }}" input-class="input-class" placeholder="邮箱地址" border="{{ false }}" bind:change="onChange" />
+        </My_GreyRectangle>
+    </view>
+</My_GeneralTemplate>
+<!-- 时间选择器 -->
+<!-- 提交按钮 -->
+<view class="submit_but">
+    <van-button bindtap="submit" custom-class="custom-class" round color="linear-gradient(180deg, #82E0E9 0%, #4BBECF 100%);">保存</van-button>
+</view>

+ 30 - 0
pages/userCenter/index.wxss

@@ -34,4 +34,34 @@
 .changeImage {
     font-size: 32rpx;
     color: #333333;
+}
+
+/* 表单输入 */
+.user_message_input {
+    padding: 0 30rpx;
+    margin-top: 40rpx;
+    box-sizing: border-box;
+}
+
+.input-class {
+    font-size: 32rpx !important;
+    width: 350rpx !important;
+    text-align: right !important;
+    background-color: #F6F7F8 !important;
+}
+
+/* 提交按钮 */
+.submit_but {
+    width: 240rpx;
+    height: 88rpx;
+    box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.1);
+    border-radius: 44px;
+    margin: 60rpx auto;
+    font-size: 32rpx !important;
+    font-family: PingFangSC-Medium, PingFang SC !important;
+    font-weight: 500 !important;
+}
+
+.custom-class {
+    width: 100% !important;
 }