From 9b09d13712c0c005891450a3bf4b6d848ec0ff37 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 29 十一月 2023 10:28:24 +0800
Subject: [PATCH] 2023.11.29

---
 pages/mUser/baseC/cSceneInfo/cSceneInfo.js |  455 ++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 275 insertions(+), 180 deletions(-)

diff --git a/pages/mUser/baseC/cSceneInfo/cSceneInfo.js b/pages/mUser/baseC/cSceneInfo/cSceneInfo.js
index 695ea15..61d40d8 100644
--- a/pages/mUser/baseC/cSceneInfo/cSceneInfo.js
+++ b/pages/mUser/baseC/cSceneInfo/cSceneInfo.js
@@ -1,13 +1,13 @@
 // pages/mUser/baseC/cSceneInfo/cSceneInfo.js
-import {sceneInfo, sceneLedger} from '../../../../data/sceneInfo'
-import userservice from '../../../../service/userservice'
-import deviceservice from '../../../../service/deviceservice'
-import ledgerservice from "../../../../service/ledgerservice"
-import bInputCheck from '../../../../base/behaviors/bInputCheck'
-import bUploadLedger from '../../../mLedger/behaviors/bUploadLedger'
-import bLoadingToast from '../../../../base/behaviors/bLoadingToast'
+import { sceneInfo, sceneLedger } from '../../../../data/sceneInfo';
+import userservice from '../../../../service/userservice';
+import deviceservice from '../../../../service/deviceservice';
+import ledgerservice from '../../../../service/ledgerservice';
+import bInputCheck from '../../../../base/behaviors/bInputCheck';
+import bUploadLedger from '../../../mLedger/behaviors/bUploadLedger';
+import bLoadingToast from '../../../../base/behaviors/bLoadingToast';
 
-const app = getApp()
+const app = getApp();
 
 Component({
   behaviors: [bInputCheck, bUploadLedger, bLoadingToast],
@@ -20,30 +20,30 @@
   properties: {
     submitText: {
       type: String,
-      value: '鎻愪氦'
+      value: '鎻愪氦',
     },
     sceneType: {
       type: String,
-      value: '1'
+      value: '1',
     },
     authStatus: {
       type: Boolean,
-      value: false
-    }
+      value: false,
+    },
   },
 
   ready() {
     this.setData({
       loadingText: '涓婁紶涓�',
-      loadCompleteText: '涓婁紶瀹屾垚'
-    })
-    const info = sceneInfo()
+      loadCompleteText: '涓婁紶瀹屾垚',
+    });
+    const info = sceneInfo();
     this.setData({
       msg: info.get(this.data.sceneType),
-      ledger: sceneLedger[this.data.sceneType]
-    })
+      ledger: sceneLedger[this.data.sceneType],
+    });
     //鑾峰彇鍦烘櫙淇℃伅
-    this.getSceneInfo()
+    this.getSceneInfo();
   },
 
   /**
@@ -51,7 +51,8 @@
    */
   data: {
     msg: [],
-    info: {}
+    info: {},
+    isUploadFile: true,
   },
 
   /**
@@ -60,200 +61,294 @@
   methods: {
     //鑾峰彇鍦烘櫙淇℃伅
     getSceneInfo() {
-      var that = this
-      userservice.getBaseInfo(app.globalData.accessToken.userId, {
-        success(data) {
-          const msg = that.data.msg
-          switch (that.data.sceneType) {
-            case '1':
-              if (data.baseInfo != null) {
-                msg[0].value = data.baseInfo.biName
-                msg[1].value = data.baseInfo.biNickName
-                msg[3].value = data.baseInfo.biAddress
-                msg[10].value = data.baseInfo.biContact
-                msg[11].value = data.baseInfo.biTelephone
-                msg[12].value = data.baseInfo.biTownName == null ? [] : [
-                  data.baseInfo.biProvinceName, data.baseInfo.biCityName, data.baseInfo.biDistrictName, data.baseInfo.biTownName,
-                  data.baseInfo.biProvinceCode, data.baseInfo.biCityCode, data.baseInfo.biDistrictCode, data.baseInfo.biTownCode,
-                ]
-                msg[12].displayValue = data.baseInfo.biTownName == null ? [] : [
-                  data.baseInfo.biProvinceName, data.baseInfo.biCityName, data.baseInfo.biDistrictName, data.baseInfo.biTownName,
-                ]
-              }
-              if (data.specialInfo != null) {
-                msg[2].value = data.specialInfo.rbCuisine
-                msg[2].options.forEach(o => {
-                  o.checked = false
-                });
-                msg[2].value.split(';').forEach(v => {
-                  for (let i = 0; i < msg[2].options.length; i++) {
-                    const o = msg[2].options[i];
-                    if (v == o.name) {
-                      o.checked = true
-                      break
-                    } else if (o.hasRemark) {
-                      o.checked = true
-                      o.remark += v
-                    }
-                  }
-                });
-                const s = data.specialInfo.rbTotalSeating
-                msg[4].value = data.specialInfo.rbTotalSeating
-                msg[4].options.forEach(o => {
-                  o.checked = false
-                });
-                if (s == 0) {
-                  msg[4].options[0].checked = true
-                } else if (s > 0 && s <= 20) {
-                  msg[4].options[1].checked = true
-                } else if (s > 20 && s <= 50) {
-                  msg[4].options[2].checked = true
-                } else if (s > 50 && s <= 100) {
-                  msg[4].options[3].checked = true
-                } else {
-                  msg[4].options[4].checked = true
+      var that = this;
+      userservice.getBaseInfo(
+        app.globalData.accessToken.userId,
+        {
+          success(data) {
+            const msg = that.data.msg;
+            switch (that.data.sceneType) {
+              case '1':
+                that.setData({ isUploadFile: true });
+                msg[0].value = data.name;
+                msg[12].displayValue = ['涓婃捣甯�', '涓婃捣甯�', data.userInfo.extension1]
+                if (data.baseInfo != null) {
+                  msg[1].value = data.baseInfo.biNickName;
+                  msg[3].value = data.baseInfo.biAddress;
+                  msg[10].value = data.baseInfo.biContact;
+                  msg[11].value = data.baseInfo.biTelephone;
+                  msg[12].value =
+                    data.baseInfo.biTownName == null
+                      ? []
+                      : [
+                          data.baseInfo.biProvinceName,
+                          data.baseInfo.biCityName,
+                          data.baseInfo.biDistrictName,
+                          data.baseInfo.biTownName,
+                          data.baseInfo.biProvinceCode,
+                          data.baseInfo.biCityCode,
+                          data.baseInfo.biDistrictCode,
+                          data.baseInfo.biTownCode,
+                        ];
+                  msg[12].displayValue =
+                    data.baseInfo.biTownName == null
+                      ? []
+                      : [
+                          data.baseInfo.biProvinceName,
+                          data.baseInfo.biCityName,
+                          data.baseInfo.biDistrictName,
+                          data.baseInfo.biTownName,
+                        ];
                 }
-                msg[7].value = data.specialInfo.rbCookingRangeNum
-                msg[8].value = parseInt(data.specialInfo.rbCookingOilCapacity) * 12
-                msg[9].value = data.specialInfo.rbCookingOilType
-                msg[9].options.forEach(o => {
-                  o.checked = false
-                });
-                msg[9].value.split(';').forEach(v => {
-                  for (let i = 0; i < msg[9].options.length; i++) {
-                    const o = msg[9].options[i];
-                    if (v == o.name) {
-                      o.checked = true
-                      break
-                    } else if (o.hasRemark) {
-                      o.checked = true
-                      o.remark += v
-                    }
-                  }
-                });
-                msg[13].value = data.specialInfo.rbConcentrationArea
-                msg[14].value = data.specialInfo.rbOutfallCount
-                msg[15].value = data.specialInfo.rbOutfallLocation
-                msg[16].value = data.specialInfo.rbOutfallNum
-              }
-              deviceservice.getPurifyDeviceInfo(app.globalData.accessToken.userId, {
-                success(res) {
-                  if (res.length > 0) {
-                    that.setData({
-                      ['msg[5].value']: res[0].fpNum
-                    })
-                  }
-                }
-              })
-              deviceservice.getMoniterDeviceInfo(app.globalData.accessToken.userId, {
-                success(res) {
-                  if (res.length > 0) {
-                    that.setData({
-                      ['msg[6].value']: res[0].mdNum
-                    })
-                  }
-                }
-              })
-              ledgerservice.getLedgerDetail(
-                app.globalData.accessToken.userId, that.data.ledger.ledgerSubTypeId, that.data.ledger.sceneType, undefined, {
-                  success(res) {
-                    if (res.length > 0) {
-                      let detail = res[0]
-                      if (detail.upLoad) {
-                        let imgFiles = [{
-                          url: detail.path1[0],
-                          loading: false
-                        }]
-                        that.setData({
-                          imgFiles
-                        })
+                if (data.specialInfo != null) {
+                  msg[2].value = data.specialInfo.rbCuisine;
+                  msg[2].options.forEach(o => {
+                    o.checked = false;
+                  });
+                  msg[2].value.split(';').forEach(v => {
+                    for (let i = 0; i < msg[2].options.length; i++) {
+                      const o = msg[2].options[i];
+                      if (v == o.name) {
+                        o.checked = true;
+                        break;
+                      } else if (o.hasRemark) {
+                        o.checked = true;
+                        o.remark += v;
                       }
                     }
+                  });
+                  const s = data.specialInfo.rbTotalSeating;
+                  msg[4].value = data.specialInfo.rbTotalSeating;
+                  msg[4].options.forEach(o => {
+                    o.checked = false;
+                  });
+                  if (s == 0) {
+                    msg[4].options[0].checked = true;
+                  } else if (s > 0 && s <= 20) {
+                    msg[4].options[1].checked = true;
+                  } else if (s > 20 && s <= 50) {
+                    msg[4].options[2].checked = true;
+                  } else if (s > 50 && s <= 100) {
+                    msg[4].options[3].checked = true;
+                  } else {
+                    msg[4].options[4].checked = true;
                   }
-                })
-              break;
-            case '2':
+                  msg[7].value = data.specialInfo.rbCookingRangeNum;
+                  msg[8].value =
+                    parseInt(data.specialInfo.rbCookingOilCapacity) * 12;
+                  msg[9].value = data.specialInfo.rbCookingOilType;
+                  msg[9].options.forEach(o => {
+                    o.checked = false;
+                  });
+                  msg[9].value.split(';').forEach(v => {
+                    for (let i = 0; i < msg[9].options.length; i++) {
+                      const o = msg[9].options[i];
+                      if (v == o.name) {
+                        o.checked = true;
+                        break;
+                      } else if (o.hasRemark) {
+                        o.checked = true;
+                        o.remark += v;
+                      }
+                    }
+                  });
+                  msg[13].value = data.specialInfo.rbConcentrationArea;
+                  msg[14].value = data.specialInfo.rbOutfallCount;
+                  msg[15].value = data.specialInfo.rbOutfallLocation;
+                  msg[16].value = data.specialInfo.rbOutfallNum;
+                }
+                deviceservice.getPurifyDeviceInfo(
+                  app.globalData.accessToken.userId,
+                  {
+                    success(res) {
+                      if (res.length > 0) {
+                        that.setData({
+                          ['msg[5].value']: res[0].fpNum,
+                        });
+                      }
+                    },
+                  },
+                );
+                deviceservice.getMoniterDeviceInfo(
+                  app.globalData.accessToken.userId,
+                  {
+                    success(res) {
+                      if (res.length > 0) {
+                        that.setData({
+                          ['msg[6].value']: res[0].mdNum,
+                        });
+                      }
+                    },
+                  },
+                );
+                ledgerservice.getLedgerDetail(
+                  app.globalData.accessToken.userId,
+                  that.data.ledger.ledgerSubTypeId,
+                  that.data.ledger.sceneType,
+                  undefined,
+                  {
+                    success(res) {
+                      if (res.length > 0) {
+                        let detail = res[0];
+                        if (detail.upLoad) {
+                          let imgFiles = [
+                            {
+                              url: detail.path1[0],
+                              loading: false,
+                            },
+                          ];
+                          that.setData({
+                            imgFiles,
+                          });
+                        }
+                      }
+                    },
+                  },
+                );
+                break;
+              case '2':
+                break;
+              case '3':
+                break;
+              case '4':
+                break;
+              case '5':
+                break;
+              case '6':
+                that.setData({ isUploadFile: false });
+                msg[0].value = data.name;
+                msg[5].displayValue = ['涓婃捣甯�', '涓婃捣甯�', data.userInfo.extension1]
+                if (data.baseInfo != null) {
+                  msg[1].value = data.baseInfo.biNickName;
+                  msg[2].value = data.baseInfo.biAddress;
+                  msg[3].value = data.baseInfo.biContact;
+                  msg[4].value = data.baseInfo.biTelephone;
+                  msg[5].value =
+                    data.baseInfo.biTownName == null
+                      ? []
+                      : [
+                          data.baseInfo.biProvinceName,
+                          data.baseInfo.biCityName,
+                          data.baseInfo.biDistrictName,
+                          data.baseInfo.biTownName,
+                          data.baseInfo.biProvinceCode,
+                          data.baseInfo.biCityCode,
+                          data.baseInfo.biDistrictCode,
+                          data.baseInfo.biTownCode,
+                        ];
+                  msg[5].displayValue =
+                    data.baseInfo.biTownName == null
+                      ? []
+                      : [
+                          data.baseInfo.biProvinceName,
+                          data.baseInfo.biCityName,
+                          data.baseInfo.biDistrictName,
+                          data.baseInfo.biTownName,
+                        ];
+                }
+                if (data.specialInfo != null) {
+                  msg[6].value = data.specialInfo.ibProductionTechnique;
+                  msg[7].value = data.specialInfo.ibWasteGasTechnique;
+                  that._parseCheckBox(msg[7]);
+                  msg[8].value = data.specialInfo.ibWasteGasMeasure;
+                  that._parseCheckBox(msg[8]);
+                }
+                break;
+              case '7':
+                break;
+              default:
+                break;
+            }
+            that.setData({
+              msg,
+            });
+          },
+        },
+        app.globalData.accessToken.openId,
+      );
+    },
 
-              break;
-            case '3':
-
-              break;
-            case '4':
-
-              break;
-            case '5':
-
-              break;
-            case '6':
-
-              break;
-            case '7':
-
-              break;
-            default:
-              break;
+    _parseCheckBox(data) {
+      data.options.forEach(o => {
+        o.checked = false;
+      });
+      data.value.split(';').forEach(v => {
+        for (let i = 0; i < data.options.length; i++) {
+          const o = data.options[i];
+          if (v == o.name) {
+            o.checked = true;
+            break;
+          } else if (o.hasRemark) {
+            o.checked = true;
+            o.remark += v;
           }
-          console.log(msg);
-          that.setData({
-            msg
-          })
         }
-      }, app.globalData.accessToken.openId)
+      });
     },
 
     //鎻愪氦鍦烘櫙淇℃伅
     _submit() {
-      var that = this
-      this.setData({
-        loading: true
-      })
+      var that = this;
       //閽堝涓嶅悓鍦烘櫙锛屾暟鎹粨鏋勪細鏈変笉鍚岀殑瀹氬埗闇�姹�
       switch (this.data.sceneType) {
         case '1':
-          const m = this.data.msg[4]
+          this.setData({
+            loading: true,
+          });
+          const m = this.data.msg[4];
           for (let i = 0; i < m.options.length; i++) {
             const o = m.options[i];
             if (o.checked) {
               this.setData({
-                [`info.${m.id}`]: o.value
-              })
-              break
+                [`info.${m.id}`]: o.value,
+              });
+              break;
             }
           }
+          const sceneInfoStr = JSON.stringify(this.data.info);
+          userservice.authScene(
+            app.globalData.accessToken.openId,
+            app.globalData.userInfo.extension2,
+            sceneInfoStr,
+            {
+              success(res) {
+                that.submintLedger();
+              },
+            },
+          );
+          break;
+        case '6':
+          // this.setData({
+          //   loading: false,
+          // });
           break;
         default:
           break;
       }
-      const sceneInfoStr = JSON.stringify(this.data.info)
-      userservice.authScene(app.globalData.accessToken.openId, app.globalData.userInfo.extension2, sceneInfoStr, {
-        success(res) {
-          that.submintLedger()
-        },
-      })
     },
 
     //鎻愪氦鍥剧墖淇℃伅
     submintLedger() {
       if (this.data.imgFiles.length == 0) {
         this.setData({
-          loading: false
-        })
+          loading: false,
+        });
         wx.navigateBack({
           delta: 1,
-        })
-        return
+        });
+        return;
       }
       if (this.data.imgFiles[0].url.indexOf('http') != -1) {
         wx.downloadFile({
           url: this.data.imgFiles[0].url,
-          success: (res) => {
-            const imgPath = res.tempFilePath
-            this.data.imgFiles[0].url = imgPath
-            this._uploadLedger()
-          }
-        })
+          success: res => {
+            const imgPath = res.tempFilePath;
+            this.data.imgFiles[0].url = imgPath;
+            this._uploadLedger();
+          },
+        });
       } else {
-        this._uploadLedger()
+        this._uploadLedger();
       }
     },
 
@@ -261,7 +356,7 @@
     _success(res) {
       wx.navigateBack({
         delta: 1,
-      })
-    }
-  }
-})
\ No newline at end of file
+      });
+    },
+  },
+});

--
Gitblit v1.9.3