riku
2022-10-12 741d1f7b2e2ac1c3f89d80dfac7625e3427e2367
2022.10.12
已修改16个文件
已添加4个文件
716 ■■■■■ 文件已修改
base/behaviors/b_loadingStatus.js 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
base/behaviors/b_loadingToast.js 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
base/behaviors/b_upload.js 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/sceneInfo.js 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_consult/behaviors/b_questions.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_consult/behaviors/b_search.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_ledger/behaviors/b_uploadLedger.js 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_ledger/ledgerupload/ledgerupload.js 77 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_user/base_c/c_scene-info/c_scene-info.js 201 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_user/base_c/c_scene-info/c_scene-info.wxml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_user/base_c/c_scene-info/c_scene-info.wxss 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_user/behaviors/b_inputCheck.js 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_user/behaviors/b_login.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_user/mine/mine.js 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_user/mine/mine.wxml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_user/sceneauthentication/sceneauthentication.js 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/m_user/userlogin/userlogin.js 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/baserequest.js 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/deviceservice.js 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/userservice.js 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
base/behaviors/b_loadingStatus.js
@@ -1,5 +1,6 @@
/**
 * æ•°æ®åŠ è½½ç›‘å¬
 * æ•°æ®åŠ è½½çŠ¶æ€ç›‘å¬
 * @see './b_loadingToast.js' å’Œ '../../component/loadingstatus'
 */
module.exports = Behavior({
  data: {
@@ -15,6 +16,7 @@
      if (loading) {
        this._loadStart()
        this._loading()
        setTimeout(() => { this.setData({loading: false}) }, 20000);
      } else {
        this._loadComplete()
      }
base/behaviors/b_loadingToast.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,45 @@
const { clearTimeout } = require("timers");
/**
 * æ•°æ®åŠ è½½å¼¹çª—
 * æ ¹æ®åŠ è½½çŠ¶æ€ï¼Œå±•ç¤ºå¯¹åº”çš„å¼¹çª—
 * @see './b_loadingStatus.js'
 */
module.exports = Behavior({
  data: {
    loadingText: '加载中',
    loadCompleteText: '加载完成'
  },
  timeoutId: '',
  methods: {
    // åŠ è½½å¼€å§‹toast
    loadStart() {
      clearTimeout(this.timeoutId)
      wx.showLoading({
        title: this.data.loadingText,
        mask: true,
      })
      this.timeoutId = setTimeout(() => {
        wx.hideLoading()
      }, 20000);
    },
    // åŠ è½½ä¸­toast
    loading() {
    },
    // åŠ è½½å®Œæˆtoast
    loadComplete() {
      clearTimeout(this.timeoutId)
      wx.hideLoading({
        success: (res) => {
          wx.showToast({
            title: this.data.loadCompleteText,
            duration: 1000,
            icon: 'success',
            mask: true,
          })
        },
      })
    },
  }
})
base/behaviors/b_upload.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
/**
 * å›¾ç‰‡ä¸Šä¼ ç®¡ç†
 */
module.exports = Behavior({
  data: {
    imgFiles: [],
  },
  lifetimes: {
    attached: function () {}
  },
  methods: {
    uploadFile(file) {
      let data = file.detail.newFiles
      console.log(data);
      data.forEach(element => {
        element.loading = false
      });
      this.setData({
        imgFiles: data
      })
      console.log(imgFiles);
    },
    /**
     * ç›‘听图片删除动作
     */
    delImg(e) {
      let imgIndex = e.detail.index
      let imgFiles = this.data.imgFiles
      imgFiles.splice(imgIndex, 1)
      this.setData({
        imgFiles
      })
      console.log(imgFiles);
    },
  }
})
data/sceneInfo.js
@@ -4,21 +4,21 @@
  //餐饮**************************************************************************************************
  map.set('1', [{
      name: "店铺名称",
      id: "sceneName",
      id: "biName",
      input: true,
      value: '',
      noValue: false,
    },
    {
      name: "店铺简称",
      id: "sceneNickName",
      id: "biNickName",
      input: true,
      value: '',
      noValue: false,
    },
    {
      name: "经营菜系",
      id: "cuisine",
      id: "rbCuisine",
      type: 'checkbox',
      value: '',
      options: [
@@ -35,27 +35,27 @@
    },
    {
      name: "经营地址",
      id: "address",
      id: "biAddress",
      input: true,
      value: '',
      noValue: false,
    },
    {
      name: "就餐位数",
      id: "totalSeating",
      id: "rbTotalSeating",
      type: 'radio',
      value: '',
      options: [
        {name: '无', value: '0', checked: true},
        {name: '1~20', value: '1', },
        {name: '21~50', value: '2', },
        {name: '51~100', value: '3', },
        {name: '100以上', value: '4', },
        {name: '1~20', value: '20', },
        {name: '21~50', value: '50', },
        {name: '51~100', value: '100', },
        {name: '100以上', value: '120', },
      ]
    },
    {
      name: "净化设备数量",
      id: "purifyDeviceNum",
      id: "fpNum",
      type: 'number',
      input: true,
      value: "",
@@ -64,7 +64,7 @@
    },
    {
      name: "监测设备数量",
      id: "supervisionDeviceNum",
      id: "mdNum",
      type: 'number',
      input: true,
      value: "",
@@ -73,7 +73,7 @@
    },
    {
      name: "灶头数量",
      id: "cookingRangeNum",
      id: "rbCookingRangeNum",
      type: 'number',
      input: true,
      value: "",
@@ -82,7 +82,7 @@
    },
    {
      name: "年均用油量",
      id: "annualAvgOil",
      id: "rbCookingOilCapacity",
      type: 'number',
      input: true,
      value: "",
@@ -91,7 +91,7 @@
    },
    {
      name: "用油类型",
      id: "oilType",
      id: "rbCookingOilType",
      type: 'checkbox',
      value: "",
      options: [
@@ -102,31 +102,31 @@
    },
    {
      name: "联系人",
      id: "contract",
      id: "biContract",
      input: true,
      value: '',
      noValue: false,
    },
    {
      name: "联系方式",
      id: "telephone",
      id: "biTelephone",
      input: true,
      value: '',
      noValue: false,
    },
    {
      name: "街镇",
      id: "town",
      id: "biLocation",
      type: 'picker',
      pickerMode: 'region',
      // value: ['上海市', '上海市', '金山区', '石化街道'],
      value: [],
      displayValue: [],
      noValue: false,
      required: false,
    },
    {
      name: "集中区",
      id: "concentrationArea",
      id: "rbConcentrationArea",
      input: true,
      value: '',
      noValue: false,
@@ -134,7 +134,7 @@
    },
    {
      name: "排口数量",
      id: "outfallCount",
      id: "rbOutfallCount",
      type: 'number',
      input: true,
      value: '',
@@ -144,7 +144,7 @@
    },
    {
      name: "排口位置",
      id: "outfallLocation",
      id: "rbOutfallLocation",
      input: true,
      value: '',
      noValue: false,
@@ -152,7 +152,7 @@
    },
    {
      name: "排口编号",
      id: "outfallNum",
      id: "rbOutfallNum",
      input: true,
      value: '',
      noValue: false,
pages/m_consult/behaviors/b_questions.js
@@ -25,9 +25,9 @@
    getQuestionsByType(page = 1, selectedValues, perPage = this.data.perPage) {
      this.selectedValues = selectedValues
      this.setData({loading: true})
      const t = setTimeout(() => {
        this.setData({loading: false})
      }, 10000);
      // const t = setTimeout(() => {
      //   this.setData({loading: false})
      // }, 10000);
      var that = this
      consultservice.getQuestionsByType(app.globalData.accessToken.userId, selectedValues[0], selectedValues[1], page, perPage, {
          onPage(head) {
pages/m_consult/behaviors/b_search.js
@@ -23,7 +23,7 @@
    search(obj, cPage = 1, perPage = this.data.perPage) {
      this.obj = obj
      this.setData({loading: true})
      const t = setTimeout(() => { this.setData({loading: false}) }, 10000);
      // const t = setTimeout(() => { this.setData({loading: false}) }, 10000);
      var that = this
      const {keyword, type} = obj
      consultservice.searchLaw(app.globalData.accessToken.userId, keyword, cPage, perPage, {
pages/m_ledger/behaviors/b_uploadLedger.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,41 @@
import b_upload from "../../../base/behaviors/b_upload"
import ledgerservice from"../../../service/ledgerservice"
import b_loadingStatus from '../../../base/behaviors/b_loadingStatus'
const app = getApp()
/**
 * å°è´¦ä¸Šä¼ ç®¡ç†
 */
module.exports = Behavior({
  behaviors: [b_upload, b_loadingStatus],
  data: {
    ledger: {},
    remark: '',
  },
  methods: {
    _uploadLedger() {
      if (this.data.imgFiles.length == 0) return
      var that = this
      let path = []
      this.data.imgFiles.forEach(f => {
        path.push(f.url)
      });
      let ledger = this.data.ledger
      ledger.remark1 = this.data.remark
      this.setData({loading: true})
      ledgerservice.uploadLedger(app.globalData.accessToken.userId, ledger, path, {
        success (res) {
          this.setData({loading: false})
          if (typeof that._success === 'function') {
            that._success(res)
          }
        },
        complete (res) {
        }
      })
    },
  }
})
pages/m_ledger/ledgerupload/ledgerupload.js
@@ -1,11 +1,14 @@
// pages/m_ledger/ledgerupload/ledgerupload.js
const ledgerservice = require("../../../service/ledgerservice")
const moment = require('../../../utils/moment.min')
const $f = require('../../../service/baserequest')
import b_upload from "../behaviors/b_uploadLedger"
import b_uploadLedger from '../behaviors/b_uploadLedger'
import ledgerservice from "../../../service/ledgerservice"
import moment from '../../../utils/moment.min'
import b_loadingToast from '../../../base/behaviors/b_loadingToast'
const app = getApp()
Page({
  behaviors: [b_upload, b_uploadLedger, b_loadingToast],
  /**
   * é¡µé¢çš„初始数据
   */
@@ -40,13 +43,6 @@
    })
  },
  /**
   * ç”Ÿå‘½å‘¨æœŸå‡½æ•°--监听页面初次渲染完成
   */
  onReady() {
  },
  checkStatus() {
    if (this.data.ledger.path1) {
      let imgFiles = this.data.ledger.path1
@@ -75,17 +71,6 @@
    }
  },
  uploadFile(file) {
    let data = file.detail.newFiles
    console.log(data);
    data.forEach(element => {
      element.loading = false
    });
    this.setData({
      imgFiles: data
    })
  },
  onSubmit: function () {
    if (this.data.imgFiles.length == 0) {
      wx.showToast({
@@ -100,50 +85,18 @@
  },
  submitLedger() {
    var that = this
    this.setData({
      showDialog: false,
    })
    wx.showLoading({
      title: '提交中',
      mask: true,
      success: (res) => {},
      fail: (res) => {},
      complete: (res) => {},
    this._uploadLedger()
  },
  _success(res) {
    this.getOpenerEventChannel().emit('uploadOver', {
      indexGroup: that.data.indexGroup
    })
    setTimeout(() => {
      wx.hideLoading()
    }, 20000);
    let path = []
    this.data.imgFiles.forEach(f => {
      path.push(f.url)
    });
    let ledger = this.data.ledger
    ledger.remark1 = this.data.remark
    ledgerservice.uploadLedger(app.globalData.accessToken.userId, ledger, path, {
      success (res) {
        wx.hideLoading({
          success: (res) => {
            wx.showToast({
              title: '提交成功',
              duration: 1000,
              icon: 'success',
              mask: true,
              success: (res) => {
                that.getOpenerEventChannel().emit('uploadOver', {
                  indexGroup: that.data.indexGroup
                })
                wx.navigateBack({
                  delta: 1,
                })
              },
            })
          },
        })
      },
      complete (res) {
      }
    wx.navigateBack({
      delta: 1,
    })
  },
pages/m_user/base_c/c_scene-info/c_scene-info.js
@@ -1,9 +1,15 @@
// pages/m_user/base_c/c_scene-info/c_scene-info.js
import b_inputCheck from '../../behaviors/b_inputCheck'
import sceneInfo from '../../../../data/sceneInfo'
import userservice from '../../../../service/userservice'
import deviceservice from '../../../../service/deviceservice'
import b_inputCheck from '../../behaviors/b_inputCheck'
import b_uploadLedger from '../../../m_ledger/behaviors/b_uploadLedger'
import b_loadingToast from '../../../../base/behaviors/b_loadingToast'
const app = getApp()
Component({
  behaviors: [b_inputCheck],
  behaviors: [b_inputCheck, b_uploadLedger, b_loadingToast],
  options: {
    addGlobalClass: true,
  },
@@ -18,11 +24,18 @@
    sceneType: {
      type: String,
      value: '1'
    },
    authStatus: {
      type: Boolean,
      value: false
    }
  },
  attached() {
    this.setData({
      loadingText: '上传中',
      loadCompleteText: '上传完成'
    })
  },
  pageLifetimes: {
@@ -32,6 +45,8 @@
      this.setData({
        msg: info.get(this.data.sceneType)
      })
      //获取场景信息
      this.getSceneInfo()
    },
    hide: function () {
      // é¡µé¢è¢«éšè—
@@ -45,38 +60,174 @@
   * ç»„件的初始数据
   */
  data: {
    msg: [],
    info: {}
  },
  /**
   * ç»„件的方法列表
   */
  methods: {
    selectChange(e) {
      const index = e.currentTarget.dataset.index
      const options = e.detail.options
      this.setData({
        [`msg[${index}].options`]: options
    //获取场景信息
    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
                }
                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
                    })
                  }
                }
              })
              break;
            case '2':
              break;
            case '3':
              break;
            case '4':
              break;
            case '5':
              break;
            case '6':
              break;
            case '7':
              break;
            default:
              break;
          }
          console.log(msg);
          that.setData({
            msg
          })
        }
      })
    },
    pickerChange(e) {
      console.log(e);
      const {
        index,
        mode
      } = e.currentTarget.dataset
      let i = e.detail.value
      if (mode == 'region') {
        this.setData({
          [`msg[${index}].value`]: i
        })
      } else if (mode == 'selector') {
        this.setData({
          [`msg[${index}].selectIndex`]: i,
          [`msg[${index}].value`]: this.data.msg[index].options[i].value
        })
    //提交场景信息
    submit() {
      var that = this
      this.setData({loading: true})
      //针对不同场景,数据结构会有不同的定制需求
      switch (this.data.sceneType) {
        case '1':
          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
            }
          }
          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() {
      this._uploadLedger()
    }
  }
})
pages/m_user/base_c/c_scene-info/c_scene-info.wxml
@@ -22,7 +22,7 @@
            <picker wx:if="{{item.pickerMode == 'selector'}}" mode="selector" bindchange="pickerChange" data-index="{{index}}" data-mode="selector" value="{{item.selectIndex}}" range="{{item.options}}" range-key="name" class="value">
              <view class="picker-text">{{item.options[item.selectIndex].name}}</view>
            </picker>
            <picker wx:elif="{{item.pickerMode == 'region'}}" mode="region" bindchange="pickerChange" data-index="{{index}}" data-mode="region" value="{{item.value}}" class="value" level="sub-district" custom-item="空">
            <picker wx:elif="{{item.pickerMode == 'region'}}" mode="region" bindchange="pickerChange" data-index="{{index}}" data-mode="region" value="{{item.displayValue}}" class="value" level="sub-district" custom-item="空">
              <view class="picker-text" wx:if="{{item.value.length > 0}}">{{item.value[0] + (item.value[1] == item.value[0] ? '' : item.value[1]) + item.value[2] + item.value[3]}}</view>
              <view wx:else class="picker-text" style="color: #B2B2B2;">请选择街镇</view>
            </picker>
pages/m_user/base_c/c_scene-info/c_scene-info.wxss
@@ -75,4 +75,8 @@
.not-required {
  color: transparent;
}
.upload-title-class {
  font-size: small;
}
pages/m_user/behaviors/b_inputCheck.js
@@ -1,5 +1,7 @@
/**
 *
 * ä¿¡æ¯è¾“入逻辑
 * åŒ…括输入信息存储、输入规范性检测、错误提示等
 * @see "/data/sceneInfo.js"
 */
module.exports = Behavior({
  data: {
@@ -10,6 +12,33 @@
    attached: function () {}
  },
  methods: {
    selectChange(e) {
      const index = e.currentTarget.dataset.index
      const options = e.detail.options
      this.setData({
        [`msg[${index}].options`]: options
      })
    },
    pickerChange(e) {
      console.log(e);
      const {
        index,
        mode
      } = e.currentTarget.dataset
      let i = e.detail.value.concat(e.detail.code)
      if (mode == 'region') {
        this.setData({
          [`msg[${index}].value`]: i
        })
      } else if (mode == 'selector') {
        this.setData({
          [`msg[${index}].selectIndex`]: i,
          [`msg[${index}].value`]: this.data.msg[index].options[i].value
        })
      }
    },
    changeMsg(e) {
      let id = e.detail.params.id
      let value = e.detail.params.value
@@ -24,30 +53,6 @@
            [nPath]: false
          })
        }
      }
    },
    onSubmit: function () {
      console.log('onSubmit');
      if (!this.submitCheck()) return
      let msg = this.data.msg
      if (msg) {
        let info = {}
        msg.forEach(m => {
          info[m.id] = m.value
        });
        // console.log(info);
        this.setData({info})
        this.triggerEvent('onSubmit', info)
        // wx.showToast({
        //   title: 'onSubmit',
        //   duration: 1000,
        //   icon: 'none',
        //   success: (res) => {},
        //   fail: (res) => {},
        //   complete: (res) => {},
        // })
      }
    },
@@ -109,7 +114,7 @@
          }
        }
        //输入框
        else if (m.value === "") {
        else if (m.value === "" || m.value === null || m.value === undefined) {
          this.showErrorMsg(i)
          return false
        }
@@ -164,6 +169,22 @@
          })
        }).exec();
      }).exec();
    }
    },
    onSubmit: function () {
      console.log('onSubmit');
      if (!this.submitCheck()) return
      let msg = this.data.msg
      if (msg) {
        let info = {}
        msg.forEach(m => {
          info[m.id] = m.value
        });
        this.setData({info})
        this.triggerEvent('onSubmit', info)
        this.submit()
      }
    },
  }
})
pages/m_user/behaviors/b_login.js
@@ -35,6 +35,7 @@
                    app.globalData.accessToken = res.data
                    app.globalData.accessToken.userId = data.userId
                    app.globalData.accessToken.suserId = data.suserId
                    app.globalData.accessToken.openId = data.openId
                    if (accessTokenPW.userName) {
                      app.globalData.accessToken.userName = accessTokenPW.userName
                    }
@@ -53,6 +54,7 @@
                      password: accessTokenPW.password,
                      userId: data.userId,
                      suserId: data.suserId,
                      openId: data.openId
                    }
                    wx.setStorage({
                      key: 'accessToken',
pages/m_user/mine/mine.js
@@ -1,4 +1,6 @@
// pages/mine/mine.js
import userservice from '../../../service/userservice'
const app = getApp()
Page({
@@ -7,7 +9,8 @@
   * é¡µé¢çš„初始数据
   */
  data: {
    //认证状态,[企业, åœºæ™¯, ä¸ªäºº]
    authStatus:[]
  },
  /**
@@ -16,6 +19,27 @@
  onLoad: function (options) {
    this.setData({
      userRealName: app.globalData.userInfo.realname
    })
    this.getAuthStatus()
  },
  //获取用户认证状态
  getAuthStatus() {
    var that = this
    userservice.getAuthStatus(app.globalData.accessToken.openId, app.globalData.accessToken.userId, {
      success(res) {
        if (res.success) {
          that.setData({
            authStatus: res.data
          })
        }else{
          wx.showToast({
            title: res.message,
            duration: 2000,
            icon: 'error',
          })
        }
      }
    })
  },
@@ -64,6 +88,8 @@
  //认证
  gotoAuthentication(e) {
    //等待认证状态加载完毕
    if (this.data.authStatus.length == 0) return
    var url = ""
    var index = e.currentTarget.dataset.index
    switch (index) {
@@ -82,7 +108,12 @@
    }
    if (url != "") {
      wx.navigateTo({
        url: url
        url: url,
        success: (res) => {
          res.eventChannel.emit('acceptDataFromOpenerPage', {
            authStatus: this.data.authStatus[parseInt(index)]
          })
        },
      })
    } else {
      wx.showToast({
pages/m_user/mine/mine.wxml
@@ -17,15 +17,15 @@
    <view class="fyui-panel user-authentication">
      <view bindtap="gotoAuthentication" data-index="0">
        <image src="/res/icons/icon3.png"></image>
        <view>企业认证</view>
        <view>{{authStatus[0] ? '修改企业信息' : '企业信息认证'}}</view>
      </view>
      <view bindtap="gotoAuthentication" data-index="1">
        <image src="/res/icons/icon3.png"></image>
        <view>店铺认证</view>
        <view>{{authStatus[1] ? '修改店铺信息' : '店铺信息认证'}}</view>
      </view>
      <view bindtap="gotoAuthentication" data-index="2">
        <image src="/res/icons/icon3.png"></image>
        <view>个人认证</view>
        <view>{{authStatus[2] ? '修改个人信息' : '个人信息认证'}}</view>
      </view>
    </view>
    <view class="fyui-panel">
pages/m_user/sceneauthentication/sceneauthentication.js
@@ -1,4 +1,6 @@
// pages/m_user/sceneauthentication/sceneauthentication.js
const app = getApp()
Page({
@@ -7,19 +9,25 @@
   * é¡µé¢çš„初始数据
   */
  data: {
  },
  /**
   * ç”Ÿå‘½å‘¨æœŸå‡½æ•°--监听页面加载
   */
  onLoad(options) {
    console.log(app.globalData.userInfo.extension2);
    this.setData({
      sceneType: app.globalData.userInfo.extension2
    })
    this.getOpenerEventChannel().on('acceptDataFromOpenerPage', (data) => {
      this.setData({
        authStatus: data.authStatus
      })
    })
  },
  onSubmit(e) {
    console.log(e);
    const info = e.detail
pages/m_user/userlogin/userlogin.js
@@ -1,8 +1,7 @@
// pages/m_user/userlogin/userlogin.js
import b_login from '../behaviors/b_login'
import $f from "../../../service//baserequest"
const $f = require("../../../service//baserequest")
const userservice = require("../../../service/userservice")
const app = getApp()
Page({
@@ -41,7 +40,7 @@
   * ç”Ÿå‘½å‘¨æœŸå‡½æ•°--监听页面初次渲染完成
   */
  onReady: function () {
    // this.login()
  },
  /**
@@ -67,74 +66,11 @@
            key: 'userProfile',
          })
          this.loginPw(res.userInfo)
          // that.login()
        }
      })
    }
    
  },
  login() {
    //获取缓存的用户账户密码
    var that = this
    wx.getStorage({
      key: 'accessToken',
      success(res) { //获取成功自动登录
        app.globalData.accessToken = res.data
        that.setData({
          userName: res.data.userName,
          password: res.data.password
        })
        wx.showLoading({
          title: '登录中',
          mask: true,
        })
        setTimeout(() => {
          wx.hideLoading()
        }, 10000);
        userservice.login(that.data.userName, that.data.password, {
          success(data) {
            if (data.success) {
              app.globalData.accessToken = {
                userName: that.data.userName,
                password: that.data.password,
                userId: data.userId,
                suserId: data.suserId,
              }
              wx.setStorage({
                key: 'accessToken',
                data: app.globalData.accessToken,
              })
              that.getUserInfo()
            } else {
              wx.showToast({
                title: '账户或密码错误',
                duration: 1000,
                icon: 'none',
              })
            }
          },
          complete() {
            that.setData({
              loading: false
            })
            wx.hideLoading()
          }
        })
      },
      fail(e) { //获取失败
        //后台查询微信是否绑定账号,未绑定则跳转注册界面
        wx.navigateTo({
          url: '/pages/m_user/userregistercompany/userregistercompany',
          success: (result) => {},
          fail: (res) => {},
          complete: (res) => {},
        })
      }
    })
  },
  _onLoginFail(e) {
service/baserequest.js
@@ -11,8 +11,7 @@
const util = require("../utils/util.js")
const originProperties = ['url', 'data', 'header', 'method', 'success', 'fail', 'complete'];
// const baseUrl = "http://127.0.0.1:8080"
// const baseUrl = "http://192.168.1.106:8080"
// const baseUrl = "http://192.168.0.137:8080"
const baseUrl = "https://fyami.com.cn:447"
// const basePicUrl = baseUrl + "/images/"
const basePicUrl = "https://fyami.com.cn:447/images/"
service/deviceservice.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
const $f = require('./baserequest')
module.exports = {
  //获取净化设备信息
  getPurifyDeviceInfo: function (userId, fun) {
    let cb = {
      url: `/device/purify/info`,
      params: {
        userId: userId
      }
    }
    Object.assign(cb, fun)
    $f.get(cb)
  },
  //获取监测设备信息
  getMoniterDeviceInfo: function (userId, fun) {
    let cb = {
      url: `/device/monitor/info`,
      params: {
        userId: userId
      }
    }
    Object.assign(cb, fun)
    $f.get(cb)
  },
}
service/userservice.js
@@ -58,13 +58,31 @@
  },
  //场景信息认证
  authScene: function (userId, info, fun) {
  authScene: function (wxUserId, sceneType, sceneInfo, fun) {
    let cb = {
      url: '/wxuser/loginPW',
      data: accessTokenPW,
      url: '/auth/scene',
      params: {
        wxUserId: wxUserId,
        sceneType: sceneType
      },
      data: sceneInfo,
    }
    Object.assign(cb, fun)
    $f.post(cb)
  },
  //获取用户认证状态
  getAuthStatus: function (wxUserId, userId, fun) {
    let cb = {
      url: `/auth/status`,
      params: {
        wxUserId: wxUserId,
        userId: userId
      }
    }
    Object.assign(cb, fun)
    $f.get(cb)
  },
}