Quellcode durchsuchen

完善农业云H5之“质量安全投诉”bug功能

张启 vor 4 Jahren
Ursprung
Commit
491ba55082
2 geänderte Dateien mit 73 neuen und 47 gelöschten Zeilen
  1. 8 2
      pages/complaints/details/index.vue
  2. 65 45
      pages/complaints/index.vue

+ 8 - 2
pages/complaints/details/index.vue

@@ -22,7 +22,7 @@
             <view class="item-textvalue">
               <text
                 class="item-value"
-              >{{ complaintsDetailsObj.plaPhone.replace(/^(.{3})(.*)(.{4})$/, '$1-$2-$3') }}</text>
+              >{{ complaintsDetailsObj.plaPhone ? complaintsDetailsObj.plaPhone.toString().replace(/^(.{3})(.*)(.{4})$/, '$1-$2-$3') : '' }}</text>
             </view>
           </view>
         </view>
@@ -86,7 +86,13 @@ export default {
   name: 'complaintsdetails',
   data() {
     return {
-      complaintsDetailsObj: {},
+      complaintsDetailsObj: {
+        plaUser: '',
+        plaPhone: null,
+        plaName: '',
+        plaContent: '',
+        plaRes: ''
+      },
       custLabelStyle: {
         'height': '42rpx',
         'font-size': '30rpx',

+ 65 - 45
pages/complaints/index.vue

@@ -88,35 +88,42 @@
         <view class="history-complaints">
           <scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="handleScrolltolower">
             <view class="history-complaints-listbody">
-              <u-row gutter="16" class="listbody-row">
-                <u-col
-                  span="12"
-                  class="listbody-col"
-                  v-for="complaintsItem in hisComplaintsObj.complaintsList"
-                  :key="complaintsItem.plaId"
-                  @click="handleComplaintsDetails(complaintsItem)"
-                >
-                  <view class="listbody-item">
-                    <view class="item-title">
-                      <text class="item-title-left">质量安全投诉</text>
-                      <text class="item-title-right">{{ complaintsItem.plaInTime }}</text>
+              <template v-if="hisComplaintsObj.list_empty">
+                <view class="history-complaints-nodata">
+                  <text class="complaints-nodata">暂无数据</text>
+                </view>
+              </template>
+              <template>
+                <u-row gutter="16" class="listbody-row">
+                  <u-col
+                    span="12"
+                    class="listbody-col"
+                    v-for="complaintsItem in hisComplaintsObj.complaintsList"
+                    :key="complaintsItem.plaId"
+                    @click="handleComplaintsDetails(complaintsItem)"
+                  >
+                    <view class="listbody-item">
+                      <view class="item-title">
+                        <text class="item-title-left">质量安全投诉</text>
+                        <text class="item-title-right">{{ complaintsItem.plaInTime }}</text>
+                      </view>
+                      <view class="item-body">
+                        <text class="item-body-text">
+                          真实姓名:{{ complaintsItem.plaUser }}
+                          <br />
+                          手机号码:{{ complaintsItem.plaPhone ? complaintsItem.plaPhone.toString().replace(/^(.{3})(.*)(.{4})$/, '$1-$2-$3') : '' }}
+                        </text>
+                        <template v-if="complaintsItem.plaIsRe == 1">
+                          <text class="item-body-feedback">已反馈</text>
+                        </template>
+                        <template v-else>
+                          <text class="item-body-nofeedback">未反馈</text>
+                        </template>
+                      </view>
                     </view>
-                    <view class="item-body">
-                      <text class="item-body-text">
-                        真实姓名:{{ complaintsItem.plaUser }}
-                        <br />
-                        手机号码:{{ complaintsItem.plaPhone.replace(/^(.{3})(.*)(.{4})$/, '$1-$2-$3') }}
-                      </text>
-                      <template v-if="complaintsItem.plaIsRe == 1">
-                        <text class="item-body-feedback">已反馈</text>
-                      </template>
-                      <template v-else>
-                        <text class="item-body-nofeedback">未反馈</text>
-                      </template>
-                    </view>
-                  </view>
-                </u-col>
-              </u-row>
+                  </u-col>
+                </u-row>
+              </template>
               <uni-load-more
                 :status="hisComplaintsObj.loadStatus"
                 v-if="!hisComplaintsObj.list_empty"
@@ -167,7 +174,7 @@ export default {
         }],
         plaPhone: [{
           required: true,
-          message: '请输入手机号',
+          message: '请输入手机号',
           trigger: ['change', 'blur']
         },
         {
@@ -216,22 +223,27 @@ export default {
       }
     };
   },
-  onLoad: function (option) {
-    console.log(option.id);
-    this.initData();
-  },
+  onLoad: function (option) { },
   methods: {
-    /** 初始化数据 */
-    initData() {
-
-    },
     /** 切换页签 */
     handletabsChange(index) {
-      this.currentTabs = index;
       if (index == 1) {
+        if (!this.complaintsForm.plaUser) {
+          this.currentTabs = 0;
+          this.$msgbox('请输入真实姓名!', 'none');
+          return;
+        }
+
+        if (!this.complaintsForm.plaPhone) {
+          this.currentTabs = 0;
+          this.$msgbox('请输入手机号码!', 'none');
+          return;
+        }
+
         this.hisComplaintsObj.pagination.pageNum = 1;
         this.getComplaintsListData();
       }
+      this.currentTabs = index;
     },
     /** 获取历史投诉列表 */
     getComplaintsListData() {
@@ -251,12 +263,16 @@ export default {
         // 数据总条数
         this.hisComplaintsObj.pageTotal = res.total || 0;
 
+        // 如果列表为第一页,返回列表数据清空
+        if (this.hisComplaintsObj.pagination.pageNum == 1) {
+          this.hisComplaintsObj.complaintsList = [];
+        };
+
         // 处理返回结果
         if ((res.rows || []).length <= 0) { // 返回结果没有数据
           if ((this.hisComplaintsObj.complaintsList || []).length <= 0) {
             this.hisComplaintsObj.loadStatus = 'noMores';
             this.hisComplaintsObj.list_empty = true;
-            return;
           } else {
             this.hisComplaintsObj.loadStatus = 'noMores';
           }
@@ -282,11 +298,6 @@ export default {
             this.hisComplaintsObj.loadStatus = 'more'
           }
 
-          // 如果列表为第一页,返回列表数据清空
-          if (this.hisComplaintsObj.pagination.pageNum == 1) {
-            this.hisComplaintsObj.complaintsList = [];
-          };
-
           // 组装返回数据
           this.hisComplaintsObj.complaintsList.push.apply(this.hisComplaintsObj.complaintsList, res.rows || []);
 
@@ -334,7 +345,6 @@ export default {
     },
     handleComplaintsDetails(param) {
       this.$store.dispatch("SetComplaintsDetails", param).then(() => {
-        // console.log(this.$store.getters)
         uni.navigateTo({
           url: '/pages/complaints/details/index'
         });
@@ -401,6 +411,16 @@ export default {
     }
 
     .history-complaints-listbody {
+      .history-complaints-nodata {
+        text-align: center;
+        margin-top: 20rpx;
+
+        .complaints-nodata {
+          font-size: 30rpx;
+          color: #777777;
+        }
+      }
+
       .listbody-row {
         .listbody-col {
           padding: 24rpx 0 0 0 !important;