浏览代码

获取用户昵称和头像

macmini 1 周之前
父节点
当前提交
d4dbd5c0e8
共有 2 个文件被更改,包括 204 次插入192 次删除
  1. 73 56
      src/pages-A/applyForm/index.vue
  2. 131 136
      src/pages/me/me.vue

+ 73 - 56
src/pages-A/applyForm/index.vue

@@ -81,18 +81,30 @@ function submitForm() {
             couponIssuerApplyByAddRequest(couponIssuerApplyByAddForm).then(() => {
                 // 返回上一页
                 console.log('提交成功:', couponIssuerApplyByAddData)
-                uni.$u.toast('校验通过')
+                uni.showToast({
+                    title: '校验通过',
+                    icon: 'success',
+                })
                 uni.navigateBack()
             }).catch(() => {
-                uni.$u.toast('校验失败')
+                uni.showToast({
+                    title: '校验失败',
+                    icon: 'error',
+                })
             })
         }
-    else {
-            uni.$u.toast('校验失败')
+        else {
+            uni.showToast({
+                title: '校验失败',
+                icon: 'error',
+            })
         }
     }).catch(() => {
         // 处理验证错误
-        uni.$u.toast('校验失败')
+        uni.showToast({
+            title: '校验失败',
+            icon: 'error',
+        })
     })
 }
 </script>
@@ -102,10 +114,10 @@ function submitForm() {
         <view class="form-wrapper">
             <u-form ref="uFormRef" label-position="left" :model="model" :rules="rules">
                 <u-form-item ref="item1" label="申请人姓名" prop="name" :border-bottom="true">
-                    <u-input v-model="model.name" border="none" placeholder="请输入申请人姓名" />
+                    <u-input v-model="model.name" border="none" disabled="formResult" placeholder="请输入申请人姓名" />
                 </u-form-item>
                 <u-form-item ref="item2" label="电话" prop="phone" :border-bottom="true">
-                    <u-input v-model="model.phone" border="none" placeholder="请输入小程序登录的手机号" />
+                    <u-input v-model="model.phone" border="none" disabled="formResult" placeholder="请输入小程序登录的手机号" />
                 </u-form-item>
                 <u-form-item v-if="formResult" ref="item3" label="申请结果" :border-bottom="true">
                     <view v-if="formResult.status === '2'" class="form-item-result u-text-danger">
@@ -131,81 +143,86 @@ function submitForm() {
 
 <style lang="scss" scoped>
 ::v-deep .u-form-item__body__left {
-  width: 150rpx !important;
-  font-weight: 400 !important;
-  font-size: 26rpx !important;
-  color: #333333 !important;
+    width: 150rpx !important;
+    font-weight: 400 !important;
+    font-size: 26rpx !important;
+    color: #333333 !important;
 }
 
 ::v-deep .u-input__content__field-wrapper__field {
-  text-align: right !important;
+    text-align: right !important;
 }
 
 ::v-deep .u-form-item__body__left__content__label {
-  color: #333333 !important;
-  font-size: 26rpx !important;
-  font-weight: 400 !important;
+    color: #333333 !important;
+    font-size: 26rpx !important;
+    font-weight: 400 !important;
 }
 
 ::v-deep .u-line {
-  border-color: #eeeeee !important;
+    border-color: #eeeeee !important;
 }
 
 ::v-deep .u-form-item__body__right__content__slot {
-  display: flex;
-  justify-content: flex-end;
+    display: flex;
+    justify-content: flex-end;
+}
+
+/* 为禁用状态的input添加白色背景 */
+::v-deep .u-input__content__field-wrapper__field {
+    background-color: #fff !important;
 }
 
 .form-container {
-  background-color: #f5f5f5;
-  min-height: 100vh;
-  padding: 20rpx;
+    background-color: #f5f5f5;
+    min-height: 100vh;
+    padding: 20rpx;
 }
 
 .form-wrapper {
-  background-color: #fff;
-  border-radius: 12rpx;
-  padding: 0 32rpx;
+    background-color: #fff;
+    border-radius: 12rpx;
+    padding: 0 32rpx;
 }
 
 .form-item-result {
-  width: 112rpx;
-  height: 44rpx;
-  line-height: 44rpx;
-  border-radius: 10rpx;
-  text-align: center;
-
-  &.u-text-danger {
-    color: #ff3333;
-    background: rgba(#ff7171, 0.2);
-  }
-
-  &.u-text-success {
-    color: #64a6ff;
-    background: rgba(#64a6ff, 0.2);
-  }
+    width: 112rpx;
+    height: 44rpx;
+    line-height: 44rpx;
+    border-radius: 10rpx;
+    text-align: center;
+
+    &.u-text-danger {
+        color: #ff3333;
+        background: rgba(#ff7171, 0.2);
+    }
+
+    &.u-text-success {
+        color: #64a6ff;
+        background: rgba(#64a6ff, 0.2);
+    }
 }
 
 .form-item-des {
-  ::v-deep .u-form-item__body {
-    flex-direction: column !important;
-    gap: 32rpx !important;
-  }
+    ::v-deep .u-form-item__body {
+        flex-direction: column !important;
+        gap: 32rpx !important;
+    }
 }
 
 .form-btn {
-  width: 600rpx;
-  height: 80rpx;
-  line-height: 80rpx;
-  background: linear-gradient(90deg, #ee6b67 0%, #ff7d78 100%);
-  border-radius: 10rpx;
-  position: fixed;
-  bottom: 52rpx;
-  left: 50%;
-  transform: translateX(-50%);
-  font-weight: 400;
-  font-size: 30rpx;
-  color: #ffffff;
-  text-align: center;
+    width: 600rpx;
+    height: 80rpx;
+    line-height: 80rpx;
+    background: linear-gradient(90deg, #ee6b67 0%, #ff7d78 100%);
+    border-radius: 10rpx;
+    position: fixed;
+    bottom: 52rpx;
+    left: 50%;
+    transform: translateX(-50%);
+    font-weight: 400;
+    font-size: 30rpx;
+    color: #ffffff;
+    text-align: center;
 }
 </style>

+ 131 - 136
src/pages/me/me.vue

@@ -45,7 +45,7 @@ onShow(() => {
         })
         getCouponSituationRequest()
         getCouponIssuerApplyByIdRequest()
-        if (couponIssuerApplyByIdData.value) {
+        if (couponIssuerApplyByIdData.value?.status === '0') {
             console.log('优惠券统计数据:', couponSituationData.value)
             open()
         }
@@ -191,10 +191,8 @@ function menuClick(page) {
 <template>
     <view class="profile-container">
         <!-- 顶部区域 -->
-        <view
-            class="me-header"
-            style="background: url('../../static/images/me/me-bg.png') no-repeat center center; background-size: cover;"
-        >
+        <view class="me-header"
+            style="background: url('../../static/images/me/me-bg.png') no-repeat center center; background-size: cover;">
             <view class="me-header-avatar-info" :style="{ paddingTop: `${navigationBarHeight}px` }">
                 <button class="me-header-avatar" open-type="chooseAvatar" @click="handleGetAvatar">
                     <image :src="avatarDisplay" mode="aspectFill" />
@@ -202,11 +200,9 @@ function menuClick(page) {
                 <view class="me-header-info">
                     <view class="me-header-name">
                         <!-- #ifdef MP-WEIXIN -->
-                        <input
-                            v-model="nicknameInput" type="nickname" placeholder="用户昵称"
+                        <input v-model="nicknameInput" type="nickname" placeholder="用户昵称"
                             placeholder-style="color: #fff; opacity: 0.7;" class="nickname-input"
-                            @confirm="saveNickname" @blur="saveNickname"
-                        >
+                            @confirm="saveNickname" @blur="saveNickname">
                         <!-- #endif -->
                         <!-- #ifndef MP-WEIXIN -->
                         {{ userInfo.value?.nickname || '用户' }}
@@ -280,160 +276,159 @@ function menuClick(page) {
 <style lang="scss" scoped>
 // 提示框
 ::v-deep .u-modal {
-  width: 580rpx !important;
-  //   height: 376rpx !important;
-  border-radius: 20rpx !important;
+    width: 580rpx !important;
+    //   height: 376rpx !important;
+    border-radius: 20rpx !important;
 }
 
 ::v-deep .u-modal__title {
-  font-weight: 500 !important;
-  font-size: 34rpx !important;
-  color: #333333 !important;
-  padding-top: 29rpx !important;
-  padding-bottom: 28rpx !important;
+    font-weight: 500 !important;
+    font-size: 34rpx !important;
+    color: #333333 !important;
+    padding-top: 29rpx !important;
+    padding-bottom: 28rpx !important;
 }
 
 ::v-deep .u-modal__content {
-  border-top: 1px solid #eeeeee;
-  border-bottom: 1px solid #eeeeee;
-  padding-top: 82rpx !important;
-  padding-bottom: 64rpx !important;
+    border-top: 1px solid #eeeeee;
+    border-bottom: 1px solid #eeeeee;
+    padding-top: 82rpx !important;
+    padding-bottom: 64rpx !important;
 }
 
 ::v-deep .u-modal__content__text {
-  font-weight: 500 !important;
-  font-size: 32rpx !important;
-  color: #333333 !important;
-  text-align: center !important;
+    font-weight: 500 !important;
+    font-size: 32rpx !important;
+    color: #333333 !important;
+    text-align: center !important;
 }
 
 .rounded {
-  width: 300rpx;
-  line-height: 69rpx;
-  background: linear-gradient(90deg, #ee6b67 0%, #ff7d78 100%);
-  border-radius: 35rpx;
-  font-weight: 400;
-  font-size: 30rpx;
-  color: #ffffff;
-  text-align: center;
-  margin: 0 auto;
+    width: 300rpx;
+    line-height: 69rpx;
+    background: linear-gradient(90deg, #ee6b67 0%, #ff7d78 100%);
+    border-radius: 35rpx;
+    font-weight: 400;
+    font-size: 30rpx;
+    color: #ffffff;
+    text-align: center;
+    margin: 0 auto;
 }
 
 .profile-container {
-  font-family: Alibaba PuHuiTi;
-
-  .me-header {
-    height: 575rpx;
-
-    .me-header-avatar-info {
-      display: flex;
-      flex-direction: column;
-      justify-content: center;
-      align-items: center;
-      gap: 24rpx;
-
-      .me-header-avatar {
-        width: 128rpx;
-        height: 128rpx;
-        border-radius: 50%;
-        overflow: hidden;
-
-        image {
-          width: 100%;
-          height: 100%;
-          object-fit: cover;
+    font-family: Alibaba PuHuiTi;
+
+    .me-header {
+        height: 575rpx;
+
+        .me-header-avatar-info {
+            display: flex;
+            flex-direction: column;
+            justify-content: center;
+            align-items: center;
+            gap: 24rpx;
+
+            .me-header-avatar {
+                width: 128rpx;
+                height: 128rpx;
+                border-radius: 50%;
+                overflow: hidden;
+
+                image {
+                    width: 100%;
+                    height: 100%;
+                    object-fit: cover;
+                }
+            }
+
+            .me-header-info {
+                .me-header-name {
+                    font-weight: 500;
+                    font-size: 30rpx;
+                    color: #ffffff;
+                }
+            }
         }
-      }
 
-      .me-header-info {
-        .me-header-name {
-          font-weight: 500;
-          font-size: 30rpx;
-          color: #ffffff;
+        .me-header-tips {
+            display: flex;
+            margin-top: 49rpx;
+
+            .me-header-tips-item {
+                flex: 1;
+                display: flex;
+                flex-direction: column;
+                justify-content: center;
+                align-items: center;
+                gap: 15rpx;
+                font-weight: 500;
+                font-size: 34rpx;
+                color: #ffffff;
+                line-height: 1;
+
+                .me-header-tips-item-num {
+                    font-weight: bold;
+                }
+
+                .me-header-tips-item-des {
+                    font-weight: 400;
+                    font-size: 24rpx;
+                    color: #ffffff;
+                }
+            }
         }
-      }
     }
 
-    .me-header-tips {
-      display: flex;
-      margin-top: 49rpx;
-
-      .me-header-tips-item {
-        flex: 1;
-        display: flex;
-        flex-direction: column;
-        justify-content: center;
-        align-items: center;
-        gap: 15rpx;
-        font-weight: 500;
-        font-size: 34rpx;
-        color: #ffffff;
-        line-height: 1;
-
-        .me-header-tips-item-num {
-          font-weight: bold;
-        }
+    .me-header-menu {
+        background: #ffffff;
+        border-radius: 10rpx 10rpx 0rpx 0rpx;
+        margin: -50rpx 24rpx 0;
+        padding: 0 20rpx;
+
+        .me-header-menu-item {
+            height: 88rpx;
+            display: flex;
+            justify-content: space-between;
+            align-items: center;
+            border-bottom: 1px solid #eeeeee;
+
+            &:last-child {
+                border-bottom: none;
+            }
 
-        .me-header-tips-item-des {
-          font-weight: 400;
-          font-size: 24rpx;
-          color: #ffffff;
-        }
-      }
-    }
-  }
-
-  .me-header-menu {
-    background: #ffffff;
-    border-radius: 10rpx 10rpx 0rpx 0rpx;
-    margin: -50rpx 24rpx 0;
-    padding: 0 20rpx;
-
-    .me-header-menu-item {
-      height: 88rpx;
-      display: flex;
-      justify-content: space-between;
-      align-items: center;
-      border-bottom: 1px solid #eeeeee;
-
-      &:last-child {
-        border-bottom: none;
-      }
-
-      .me-header-menu-icon {
-        display: flex;
-        justify-content: center;
-        align-items: center;
-        gap: 13rpx;
-
-        image {
-          width: 40rpx;
-          height: 40rpx;
-        }
+            .me-header-menu-icon {
+                display: flex;
+                justify-content: center;
+                align-items: center;
+                gap: 13rpx;
+
+                image {
+                    width: 40rpx;
+                    height: 40rpx;
+                }
+
+                .me-header-menu-text {
+                    font-weight: 400;
+                    font-size: 26rpx;
+                    color: #333333;
+                }
+            }
 
-        .me-header-menu-text {
-          font-weight: 400;
-          font-size: 26rpx;
-          color: #333333;
+            .me-header-menu-left {}
         }
-      }
-
-      .me-header-menu-left {
-      }
     }
-  }
 }
 
 /* 昵称输入框样式 */
 .nickname-input {
-  width: 100%;
-  height: 100%;
-  font-weight: 500;
-  font-size: 30rpx;
-  color: #ffffff;
-  background: transparent;
-  border: none;
-  outline: none;
-  text-align: center;
+    width: 100%;
+    height: 100%;
+    font-weight: 500;
+    font-size: 30rpx;
+    color: #ffffff;
+    background: transparent;
+    border: none;
+    outline: none;
+    text-align: center;
 }
 </style>