Browse Source

Merge branch 'master' of http://git.nanodreamtech.com/dream/laundry

# Conflicts:
#	project.config.json
luck 2 years ago
parent
commit
3fe98d145c
6 changed files with 148 additions and 100 deletions
  1. 98 5
      app.js
  2. 39 4
      pages/tabber/home/index.js
  3. 6 0
      pages/tabber/order/index.js
  4. 1 1
      pages/tabber/order/index.wxml
  5. 0 87
      project.config.json
  6. 4 3
      utils/api.js

+ 98 - 5
app.js

@@ -1,4 +1,9 @@
 // app.js
+var projectMode=0;//0代表开发模式(本地环境),1代表测试模式(线上测试环境),2代表线上模式(正式运行环境)
+var info=wx.getSystemInfoSync();
+if(info.platform!="devtools"&&projectMode==0){projectMode=1}
+var envVersion = `${__wxConfig.envVersion}`;//develop	开发版,trial	体验版,release	正式版
+if(envVersion=='release'){projectMode=2}
 import api from './utils/api'
 App({
   onLaunch() {
@@ -6,13 +11,20 @@ App({
     const logs = wx.getStorageSync('logs') || []
     logs.unshift(Date.now())
     wx.setStorageSync('logs', logs)
+    var that=this;
+
+    this.getLocation();
 
     // 登录
-    wx.login({
-      success: res => {
-        // 发送 res.code 到后台换取 openId, sessionKey, unionId
+
+    wx.checkSession({
+      success: res=> {
+        console.log(res)
+      },
+      fail:(res)=>{
       }
     })
+  
 
     this.globalData.btnInfo = wx.getMenuButtonBoundingClientRect()
     console.log(this.globalData.btnInfo,'按钮信息');
@@ -20,8 +32,89 @@ App({
   },
   globalData: {
     userInfo: null,
-    btnInfo:null
+    btnInfo:null,
+    baseAppUrl: projectMode==2 ? 'https://bank.nanodreamtech.com/':(projectMode==1 ?'https://bank.nanodreamtech.com/':'http://127.0.0.1:8000/'),
+    location:""
   },
-  api:api
+  api:api,
+
+  getLocation(e){
+    var that=this;
+    wx.startLocationUpdateBackground({
+        success(res) {
+          console.log('开启后台定位', res)
+          wx.onLocationChange(function(res) {
+            console.log('location change', res)
+            that.globalData.location=res;
+
+
+   
+            that.login(res.latitude,res.longitude).then(function(res){
+              if(res.code!=200){
+                
+              }
+
+
+            },function(err){
+
+            })
+
+
+          })
+        },
+        fail(res) {
+          console.log('开启后台定位失败', res)
+        }
+      })
+},
+
+  login(lat="",lng=""){
+    var that=this;
+   return new Promise((resolve,reject)=>{
+
+    wx.checkSession({
+      success: (res) => {
+
+      },
+      fail:(res)=>{
+        wx.login({
+          success: res => {
+            // 发送 res.code 到后台换取 openId, sessionKey, unionId
+            that.api.useApi(that.globalData.baseAppUrl+"api/login",{
+              code:res.code,
+              lat:lat,
+              lng:lng,
+              appid:wx.getAppBaseInfo().host.appId
+            },"post").then(function(res){
+              wx.showLoading({
+                title: '登录中',
+              })
+              if(res.code!=200){
+                setTimeout(function(){
+                  that.login(lat,lng);
+                },1000);
+              }else{
+                wx.hideLoading();
+                resolve(res);
+              }
+          
+    
+            
+            }).catch(function(err){
+              console.log(222);
+            })
+          }
+        })
+      }
+
+    })
+
+
+
+   
+   })
+  }
 
 })
+
+

+ 39 - 4
pages/tabber/home/index.js

@@ -1,5 +1,5 @@
 // pages/tabber/home/index.js
-const api = require('../../../utils/api'), app = getApp();
+const  app = getApp();
 
 Page({
 
@@ -39,9 +39,18 @@ Page({
         //     console.log(res);
         // })
 
-        setTimeout(() => {
-            this.listenerLogin()
-        }, 1000)
+    
+
+    
+
+
+
+
+
+
+        // setTimeout(() => {
+        //     this.listenerLogin()
+        // }, 1000)
     },
     toMap(){
         wx.navigateTo({
@@ -68,7 +77,33 @@ Page({
     },
     rightClick(e) {
         console.log(1);
+    },
+
+    getLocation(e){
+        var that=this;
+        wx.startLocationUpdateBackground({
+            success(res) {
+              console.log('开启后台定位', res)
+              wx.onLocationChange(function(res) {
+                console.log('location change', res)
+                that.setData({
+                    location:res
+                })
+
+                app.api.useApi(app.globalData.baseAppUrl+"api").then(function(res){
+                   console.log(res)
+
+                },function(error){
+                    console.log(error);
+                })
+              })
+            },
+            fail(res) {
+              console.log('开启后台定位失败', res)
+            }
+          })
     }
 
 
+
 })

+ 6 - 0
pages/tabber/order/index.js

@@ -47,6 +47,12 @@ Page({
         });
     },
 
+    detail(){
+        wx.navigateTo({
+          url: '/pages/order/detail/detail',
+        })
+    },
+
     toDetail(){
         wx.navigateTo({
           url: '/pages/order/detail/detail',

+ 1 - 1
pages/tabber/order/index.wxml

@@ -1,6 +1,6 @@
 <van-tabs swipeable title-active-color="#191C27" title-inactive-color="#666666" color="#4699FF" line-width="30" sticky>
     <van-tab title="全部">
-        <view class="itemBoxs" wx:for="{{orderList}}" wx:key="*this">
+        <view class="itemBoxs" bindtap="detail" wx:for="{{orderList}}" wx:key="*this">
             <view class="titBoxs b-bottom  flex ju-b">
                 <view class="le">到柜存取</view>
                 <!-- or skyBlue or gray -->

+ 0 - 87
project.config.json

@@ -1,87 +0,0 @@
-{
-  "description": "项目配置文件",
-  "packOptions": {
-    "ignore": [
-      {
-        "type": "file",
-        "value": ".eslintrc.js"
-      }
-    ]
-  },
-  "setting": {
-    "urlCheck": false,
-    "es6": true,
-    "enhance": true,
-    "postcss": true,
-    "preloadBackgroundData": false,
-    "minified": true,
-    "newFeature": false,
-    "coverView": true,
-    "nodeModules": true,
-    "autoAudits": false,
-    "showShadowRootInWxmlPanel": true,
-    "scopeDataCheck": false,
-    "uglifyFileName": false,
-    "checkInvalidKey": true,
-    "checkSiteMap": true,
-    "uploadWithSourceMap": true,
-    "compileHotReLoad": false,
-    "lazyloadPlaceholderEnable": false,
-    "useMultiFrameRuntime": true,
-    "useApiHook": true,
-    "useApiHostProcess": true,
-    "babelSetting": {
-      "ignore": [],
-      "disablePlugins": [],
-      "outputPath": ""
-    },
-    "enableEngineNative": false,
-    "useIsolateContext": true,
-    "userConfirmedBundleSwitch": false,
-    "packNpmManually": false,
-    "packNpmRelationList": [
-      {
-        "packageJsonPath": "./package.json",
-        "miniprogramNpmDistDir": "./"
-      }
-    ],
-    "minifyWXSS": true,
-    "disableUseStrict": false,
-    "minifyWXML": true,
-    "showES6CompileOption": false,
-    "useCompilerPlugins": false
-  },
-  "compileType": "miniprogram",
-  "libVersion": "2.21.2",
-  "appid": "wxe413e803ee920fe9",
-  "projectname": "%E6%B5%B7%E6%98%9F%E7%94%A8%E6%88%B7%E7%AB%AF",
-  "debugOptions": {
-    "hidedInDevtools": []
-  },
-  "scripts": {},
-  "staticServerOptions": {
-    "baseURL": "",
-    "servePath": ""
-  },
-  "isGameTourist": false,
-  "condition": {
-    "search": {
-      "list": []
-    },
-    "conversation": {
-      "list": []
-    },
-    "game": {
-      "list": []
-    },
-    "plugin": {
-      "list": []
-    },
-    "gamePlugin": {
-      "list": []
-    },
-    "miniprogram": {
-      "list": []
-    }
-  }
-}

+ 4 - 3
utils/api.js

@@ -2,20 +2,20 @@
 
 var useApi = (url, data = {}, method = "get") => {
   
+    console.log(url);
     return new Promise((resolve, reject) => {
         wx.request({
             url: `${url}`, // 云端正式服
             data,
             method,
             header: {
-                token: wx.getStorageSync('token') || '',
+                Authorization: wx.getStorageSync('token') || '',
                 'content-type': 'application/json',
             },
             dataType: 'json', // 添加这个配置
             success(res) {
                 // wx.hideLoading()
-
-                resolve(res)
+                resolve(res.data)
             },
             fail(err) {
                 // wx.hideLoading()
@@ -26,6 +26,7 @@ var useApi = (url, data = {}, method = "get") => {
                 reject(err)
             },
             complete() {
+                     wx.hideLoading(333)
                 wx.hideLoading({ //因为showToast、hideLoading不能同时使用
                     fail() {}
                 })