1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { $fysp } from '../index';
 
export default {
  /**
   * 查找场景
   * @param {provincecode, citycode, districtcode, towncode, scensetypeid, sceneName} area
   */
  searchScene(area, page = 1, perPage = 20) {
    const params = `page=${page}&per_page=${perPage}`;
    return $fysp.post(`scense/find?${params}`, area).then((res) => res.data);
  },
 
  /**
   * 获取场景详情
   * @param {String} sId 场景id
   * @returns 场景详情
   */
  getSceneDetail(sId) {
    return $fysp
      .get(`scense/detail`, {
        params: {
          sceneId: sId
        }
      })
      .then((res) => res.data);
  },
 
  /**
   * 更新场景详情
   */
  updateSceneDetail(typeId, { scene, subScene, sceneDevice }) {
    const params = `sceneTypeId=${typeId}`;
    const rb = {
      scense: scene ? scene : null,
      subScene: subScene ? JSON.stringify(subScene) : null,
      sceneDevice: sceneDevice ? sceneDevice : null
    };
    return $fysp.post(`scense/detail/update?${params}`, rb).then((res) => res.data);
  },
 
  /**
   * 更新场景额外信息
   */
  updateSubScene(typeId, subScene) {
    return this.updateSceneDetail(typeId, { subScene: subScene }).then((res) => res.data);
  },
 
  /**
   * 更新场景设备信息
   */
  updateSceneDevice(typeId, sceneDevice) {
    return this.updateSceneDetail(typeId, { sceneDevice: sceneDevice }).then((res) => res.data);
  },
 
  /**
   * 新增一个场景
   * @param {Object} scene
   */
  createScene(scene) {
    return $fysp.put('scense', scene).then((res) => res.data);
  },
 
  /**
   * 更新一个场景
   * @param {Object} scene
   */
  updateScene(scene) {
    return $fysp.post('scense', scene).then((res) => res.data);
  }
};