Browse Source

接口规整

Joe 4 years ago
parent
commit
da3bfa2be6
3 changed files with 29 additions and 4 deletions
  1. 4 2
      api/home.js
  2. 4 2
      app.js
  3. 21 0
      setting.js

+ 4 - 2
api/home.js

@@ -5,8 +5,10 @@ import {
   mGet,
   mPost
 } from "../utils/request/xhr";
-//定义接口前缀:demo-演示版  api-正式版
-const prefix='demo';
+
+// 接口前缀
+import { prefix } from "../setting"
+
 //获取油站列表方法
 const getStationList = (params) => mGet("/"+prefix+"/getStationInfoList", params);
 //获取油枪list方法

+ 4 - 2
app.js

@@ -2,6 +2,8 @@
 import {
   getMpOpenId
 } from "api/home"
+
+import { appId, stationId } from "./setting"
 App({
   onLaunch: function () {
     // 展示本地存储能力
@@ -20,7 +22,7 @@ App({
         // 发送 res.code 到后台换取 openId, sessionKey, unionId
         getMpOpenId({
           code: code,
-          stationId:1
+          stationId
         }).then(res => { // handle success
           // console.log("app.js openid:"+res.openid);
 
@@ -62,7 +64,7 @@ App({
     phoneNumber:null,//用户手机号
     mpOpenId: null,
     unionId:null,
-    appId:'wxe1135cd390b38a54',//小程序的appid
+    appId,
     stationId: null, //加油站ID
     stationName: null, //油站名称
     picUrl: null, //油站图片URL

+ 21 - 0
setting.js

@@ -0,0 +1,21 @@
+// 接口  定义接口前缀:demo-演示版  api-正式版
+// 小程序的appid
+// 站点Id
+
+
+// 智慧油驿站
+// 山东石化879站
+
+export const prefix='demo';
+export const appId = 'wxe1135cd390b38a54'
+export const stationId = 1
+
+
+// export const prefix='api';
+// export const appId = 'wx5285c34adff1069d'
+// export const  stationId = 5;
+
+
+
+
+