From 9d5b4d650e5b01081d3537c750e7469db4d161e3 Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期二, 29 四月 2025 08:53:20 +0800
Subject: [PATCH] 提交

---
 pages/tabBar/count/count.vue |  368 +++++++++++++++++++++++++++++++++-------------------
 1 files changed, 231 insertions(+), 137 deletions(-)

diff --git a/pages/tabBar/count/count.vue b/pages/tabBar/count/count.vue
index fc0f45f..a246841 100644
--- a/pages/tabBar/count/count.vue
+++ b/pages/tabBar/count/count.vue
@@ -15,41 +15,38 @@
     <view class="m-p-15">
       <view class="userInfo">
         <view class="info-l">
-          <image src="../../../static/avator.png" mode="widthFix"></image>
-          <view class="info-icons">
-            <u-icon v-if="user.sex==0" name="man" color="#0f7ff9" bold size="24"></u-icon>
-            <u-icon v-else-if="user.sex==1" name="woman" color="#ff69bf" bold size="24"></u-icon>
-            <u-icon v-else name="question" color="#ff69bf" bold size="24"></u-icon>
-          </view>
+          <image :src="avator" mode="aspectFill"></image>
+<!--          <view class="info-icons">-->
+<!--            <u-icon v-if="user.sex==0" name="man" color="#0f7ff9" bold size="24"></u-icon>-->
+<!--            <u-icon v-else-if="user.sex==1" name="woman" color="#ff69bf" bold size="24"></u-icon>-->
+<!--            <u-icon v-else name="question" color="#ff69bf" bold size="24"></u-icon>-->
+<!--          </view>-->
         </view>
 
         <view class="info-r">
           <view class="info-n">
 <!--            用户:-->
-            <span>{{user.name}}</span>
+            <span>{{username}}</span>
 
           </view>
-          <view class="info-id">
-            ID:<span>{{user.idNo}}</span>
+          <view class="info-id" @click="resetPwd()">
+            <u-icon name="edit-pen" color="#e6e6e6" size="16"></u-icon><span>修改密码</span>
           </view>
         </view>
       </view>
       <view class="card-list">
         <view class="paper-card">
-          <view class="company-info">
-            <view class="company-i">
-              <view>电话:</view>
-              <span>{{getPhoneNumber(user.phone)}}</span>
-            </view>
-            <view class="company-i">
-              <view>公司:</view>
-              <span v-if="user.company && user.company.name">{{user.company.name?user.company.name:'暂无'}}</span>
-            </view>
-          </view>
-          <view class="menu-i" @click="toMyScore">
+          <view :class="user.useProd == 1?'menu-i':'menu-i-l'" @click="toHazmat">
             <view class="menu-l">
-              <u-icon name="info-circle-fill" color="#0f7ff9" size="20"></u-icon>
-              <view>我的成绩</view>
+              <u-icon name="warning" color="#0f7ff9" size="32"></u-icon>
+              <view><span style="color: #ed6464">危化品</span>操作记录</view>
+            </view>
+            <u-icon name="arrow-right" color="#ccc" size="20"></u-icon>
+          </view>
+          <view class="menu-i" @click="toProduct" v-if="user.useProd == 1">
+            <view class="menu-l">
+              <u-icon name="bag" color="#0f7ff9" size="32"></u-icon>
+              <view><span style="color: #5fb734">成品</span>操作记录</view>
             </view>
             <u-icon name="arrow-right" color="#ccc" size="20"></u-icon>
           </view>
@@ -60,14 +57,45 @@
         <u-button @click="loginOut" type="primary" text="退出登录" style="width: 80%" shape="circle"></u-button>
       </view>
     </view>
+    <u-modal :show="showModal" title="修改密码" :showConfirmButton="false" :closeOnClickOverlay="true" ref="uModal" :asyncClose="true" @close="closeModal()">
+      <view>
+        <u-form labelPosition="top" labelWidth="120" :model="pwdForm" :rules="rules" ref="uForm">
+          <u-form-item
+              prop="password"
+              ref="password"
+              label="新密码"
+          >
+            <u-input v-model="pwdForm.password" placeholder="请输入新密码" :password="isPwd1">
+              <template slot="suffix">
+                <u-icon :name="isPwd1?'eye':'eye-off'" color="#999" size="20" @click="isPwd1 = !isPwd1"></u-icon>
+              </template>
+            </u-input>
+          </u-form-item>
+          <u-form-item
+              prop="rePassword"
+              ref="rePassword"
+              label="确认密码"
+          >
+            <u-input v-model="pwdForm.rePassword" placeholder="请输入新密码" :password="isPwd2">
+              <template slot="suffix">
+                <u-icon :name="isPwd2?'eye':'eye-off'" color="#999" size="20" @click="isPwd2 = !isPwd2"></u-icon>
+              </template>
+            </u-input>
+          </u-form-item>
+        </u-form>
+        <u-button type="primary" style="margin-top: 20px" text="确认" @click="confirmPwd()"></u-button>
+      </view>
+    </u-modal>
+    <u-toast ref="uToast"></u-toast>
 		<tabBar :currentPagePath="page"></tabBar>
 	</view>
 </template>
 
 <script>
 	import tabBar from '../tabBarIndex.vue'
-  import {getExamList, getUserInfo, loginOut} from "../../../api";
-  import {getCleanRecord} from "../../../api/wearhouse";
+  import {loginOut, postHazmatReturn, resetPwd} from "../../../api";
+  import VUE_APP_BASE_URL from 'common/constant.js'
+  import avatorPic from '../../../static/avator.png'
 	export default {
 		components:{
 			tabBar
@@ -76,14 +104,56 @@
 			return {
 				page: 'pages/tabBar/count/count',
 				statusBarHeight: '',
-        user: {},
+        username: '',
         examParams: {
           pageNum: 1,
           pageSize: 10,
           completed: 1
         },
         examList: [],
-        totalPage: 0
+        totalPage: 0,
+        user: {},
+        avator: avatorPic,
+        showModal: false,
+        pwdForm:{
+          id: null,
+          password: '',
+          rePassword: ''
+        },
+        rules: {
+          password: [
+            {
+              type: 'string',
+              required: true,
+              message: '新密码不可为空',
+              trigger: ['blur', 'change']
+            },
+            {
+              validator: (rule, value, callback) => {
+                return /^(?![a-zA-Z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)(?![a-zA-Z\d]+$)(?![a-zA-Z!@#$%^&\.*]+$)(?![\d!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*\-_]{6,16}$/.test(value)
+              },
+              message: '密码须同时包含字母、数字和特殊字符,长度在6-16之间',
+              trigger: ['change','blur'],
+            }
+          ],
+          rePassword: [
+            {
+              type: 'string',
+              required: true,
+              message: '请再次确认密码',
+              trigger: ['blur', 'change'],
+            },
+            {
+              validator: (rule, value, callback) => {
+                return value == this.pwdForm.password;
+              },
+              message: '两次输入密码不一致',
+              trigger: ['change','blur'],
+            }
+          ]
+        },
+        isPwd1: true,
+        isPwd2: true
 			}
 			
 		},
@@ -92,56 +162,36 @@
     },
 		onLoad() {
 			this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
+      this.username = uni.getStorageSync('name')
 			// uni.hideTabBar();
-      this.getUserInfo()
-      this.getExamList()
+      // this.getUserInfo()
+      this.user = uni.getStorageSync('userSet')
+      // if(this.user.logoPath && this.user.logoPath !== ''){
+      //   this.avator = VUE_APP_BASE_URL + '/api/' + this.user.logoPath
+      // }else{
+      //   this.avator = avatorPic
+      // }
 		},
 
 		methods: {
-			goBack() {
-				uni.switchTab({
-				    url:'/pages/tabBar/firstPage/firstPage'
-				});
-			},
-
-      getUserInfo(){
-        getUserInfo(uni.getStorageSync('uid')).then(res => {
-          if(res.code == 200) {
-            this.user = res.data
-          }else{
-            uni.$u.toast(res.message)
-          }
-        })
+      base64Encode(str) {
+        return btoa(unescape(encodeURIComponent(str)));
       },
 
-      getExamList(){
-        getExamList(this.examParams).then(res => {
-          if(res.code == 200) {
-            let list = res.data.list?res.data.list: [];
-            if (res.pageNum != 1) {
-              this.examList = this.examList.concat(list)
-            } else {
-              this.examList = res.data.list
-            }
-            this.totalPage = res.data.totalPage
-          }else{
-            uni.$u.toast(res.message)
-          }
-        })
-      },
-
-      toDetail(item,type){
+      toHazmat(){
         uni.setStorageSync("prevPage", '/pages/tabBar/count/count');
         uni.navigateTo({
-          url: `/pages/tabBar/firstPage/exam?bank=` + encodeURIComponent(JSON.stringify(item)) + `&type=` + encodeURIComponent(JSON.stringify(type))
+          url: '/pages/tabBar/count/countDetail'
         })
       },
-      toMyScore(){
+
+      toProduct(){
         uni.setStorageSync("prevPage", '/pages/tabBar/count/count');
         uni.navigateTo({
-          url: `/pages/tabBar/count/countDetail`
+          url: '/pages/tabBar/count/productDetail'
         })
       },
+
       loginOut(){
         uni.showModal({
           title: '提示',
@@ -152,7 +202,7 @@
                 if(res.code == 200){
                   uni.showToast({
                     title: '账户已退出',
-                    duration: 1000
+                    duration: 800
                   })
                   setTimeout(()=>{
                     uni.clearStorageSync();
@@ -160,7 +210,7 @@
                     uni.navigateTo({
                       url: '/pages/index/index'
                     })
-                  },1000)
+                  },800)
                 }
               })
             } else if (res.cancel) {
@@ -170,26 +220,62 @@
         })
       },
 
-      upper(e) {
-        // console.log(e)
+      resetPwd(){
+        const t = this
+        t.showModal = true
       },
-      lower(e) {
-        //并且让页码+1,调用获取数据的方法获取第二页数据
-        this.examParams.pageNum++
-        //此处调用自己获取数据列表的方法
-        if (this.examParams.pageNum > this.totalPage){
-          uni.$u.toast('已加载全部数据')
-          return
+
+      confirmPwd(){
+        const t = this
+        t.$refs.uForm.validate().then(res => {
+          let data = {}
+          data.id = uni.getStorageSync("uid");
+          data.password = t.base64Encode(t.pwdForm.password)
+          resetPwd(data).then((r)=>{
+            if(r.code == 200){
+              t.$refs.uToast.show({
+                type: 'default',
+                message: '密码已修改,请重新登录',
+                duration: 1000
+              })
+              loginOut().then(res=>{
+                if(res.code == 200){
+                  setTimeout(()=>{
+                    uni.clearStorageSync();
+                    uni.clearStorage();
+                    uni.navigateTo({
+                      url: '/pages/index/index'
+                    })
+                  },1000)
+                }
+              })
+            }else{
+              t.$refs.uToast.show({
+                type: 'default',
+                message: r.message
+              })
+            }
+          }).catch((err) => {
+            uni.showToast({
+              title: err,
+              duration: 2000
+            })
+          })
+          t.closeModal()
+        }).catch(errors => {
+          uni.$u.toast('请按要求完善信息')
+        })
+      },
+
+      closeModal(){
+        this.showModal = false
+        this.pwdForm = {
+          id: null,
+          password: '',
+          rePassword: ''
         }
-        this.getExamList()
-      },
-      scrollView(e) {
-        // console.log(e)
-      },
-      getPhoneNumber(phone) {
-        const firstThree = phone?phone.slice(0, 3):''
-        const lastFour = phone?phone.slice(-4):''
-        return `${firstThree}****${lastFour}`
+        this.isPwd1 = true
+        this.isPwd2 = true
       }
 		}
 	}
@@ -202,8 +288,6 @@
 	flex-direction: column; 
 	width: 100%; 
 	height: 100%;
-  background: url("../../../static/my-bg.png") no-repeat top fixed;
-  background-size: 100% auto;
 }
 .u-icon{
   margin: 0 !important;
@@ -236,45 +320,48 @@
 	background-color:lightgrey;
 }
 
-.myImg{
-  width: 100%;
-  height: 100%
+/deep/ .u-modal__title{
+  padding-top: 20px !important;
+}
+
+/deep/ .u-modal__content{
+  display: flex;
+  flex-direction: column !important;
+  align-items: center;
+  text-align: left;
+  padding-top: 0 !important;
+
+  &>view{
+    width: 100%;
+  }
 }
 
 .m-p-15{
   width: 100%;
-  margin-top: 50rpx;
+  padding-top: 50rpx;
+  background: url("../../../static/my-bg.jpg") no-repeat top;
+  background-size: 100% auto;
 
   .userInfo{
     display: flex;
     align-items: center;
-    justify-content: left;
     width: calc(100% - 60px);
-    margin: 0 auto;
+    margin: 20rpx auto;
 
     .info-l{
       width: 150rpx;
       height: 150rpx;
-      border-radius: 50%;
-      margin-right: 40rpx;
-      position: relative;
+      border-radius: 75rpx;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+      overflow: hidden;
+      margin-right: 20px;
+      border: 2px solid #fff;
+      box-sizing: border-box;
       image{
-        width: 150rpx;
-        height: 150rpx;
-        border-radius: 50%;
-      }
-      .info-icons{
-        width: 48rpx;
-        height: 48rpx;
-        border-radius: 90%;
-        position: absolute;
-        bottom: 10rpx;
-        right: 0;
-        background: #fff;
-        display: flex;
-        align-items: center;
-        justify-content: center;
-        box-shadow: 0 2px 4px rgba(0,0,0,.1);
+        width: calc(100% + 4px) !important;
+        height: calc(100% + 4px) !important;
       }
     }
 
@@ -291,6 +378,16 @@
           margin-right: 10px;
         }
       }
+
+      .info-id{
+        display: flex;
+        align-items: center;
+
+        span{
+          font-size: 24rpx;
+          color: #e6e6e6;
+        }
+      }
     }
   }
 
@@ -299,48 +396,45 @@
     margin: 20px 0;
 
     .paper-card{
-      width: calc(100% - 60px);
-      background: #fff;
-      border-radius: 20px;
-      padding: 15px 15px 20px;
+      width: calc(100% - 40px);
       margin: 0 auto 15px;
-      box-sizing: border-box;
-      box-shadow: 0 3px 8px rgba(150,150,150,.1);
-      .company-info{
-        margin-bottom: 15px;
-        border-bottom: 1px solid #e6e6e6;
-        .company-i{
-          display: flex;
-          align-items: center;
-          font-size: 28rpx;
-          color: #999;
-          margin-bottom: 15px;
-          view{
-            margin-left: 4px;
-          }
-          span{
-            color: #333;
-          }
-          &:first-of-type{
-            margin-bottom: 5px;
-          }
-        }
-      }
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
 
-      .menu-i{
+      .menu-i,.menu-i-l{
+        width: calc(50% - 5px);
+        background: rgba(255,255,255,1);
+        border-radius: 12px;
         display: flex;
         align-items: center;
+        box-shadow: 0 3px 8px rgba(150,150,150,.1);
         justify-content: space-between;
+        padding: 18px 15px;
+        box-sizing: border-box;
+        cursor: pointer;
 
         .menu-l{
           display: flex;
           align-items: center;
-          font-size: 28rpx;
+          font-size: 22rpx;
+          color: #999;
           view{
             margin-left: 6px;
+            display: flex;
+            flex-direction: column;
+            align-items: flex-start;
+            span{
+              font-size: 32rpx;
+              font-weight: bold;
+              color: #333;
+            }
           }
         }
       }
+      .menu-i-l{
+        width: 100%;
+      }
     }
   }
 }

--
Gitblit v1.9.2