Explorar o código

遇见你电单车支付宝

liangxvying hai 2 semanas
pai
achega
2f00e35414

BIN=BIN
.DS_Store


+ 7 - 0
.mini-ide/compileMode.json

@@ -3,7 +3,14 @@
     {
       "title": "二维码编译",
       "page": "pages/use_bike/use_bike",
+      "launchMode": "common",
       "query": "qrCode=https%3A%2F%2Fcode.mtu.ximengnaikang.com%3Fp%3D1%26no%3D411311155"
+    },
+    {
+      "title": "pages/use_bike/use_bike",
+      "page": "pages/use_bike/use_bike",
+      "launchMode": "common",
+      "pageQuery": "code=411311155"
     }
   ],
   "current": null

+ 134 - 64
app.js

@@ -1,7 +1,7 @@
 App({
   onLaunch: function (options) {
     if (options.query) {
-      console.log('扫码加载')
+      console.log('扫码加载', options.query)
       var code1 = decodeURIComponent(options.query.qrCode)
       var index = code1.lastIndexOf("\=");
       let code = code1.substring(index + 1, code1.length);
@@ -39,16 +39,32 @@ App({
         content: '当前支付宝版本过低,无法使用该功能,请升级到最新支付宝版本后重试。'
       })
     }
-    console.log(my.getStorageSync({ 'key': 'token' }).data, 'XXXXXXXXXXXXXXXXXXXXX')
+    console.log(my.getStorageSync({
+      'key': 'token'
+    }).data, 'XXXXXXXXXXXXXXXXXXXXX')
 
   },
+  onShow(options){
+ 
+      if (options.query) {
+        console.log('扫码加载', options.query)
+        var code1 = decodeURIComponent(options.query.qrCode)
+        var index = code1.lastIndexOf("\=");
+        let code = code1.substring(index + 1, code1.length);
+        this.globalData.scanCode = code
+        console.log(code, 'onShow-------------------------------------')
+      }
+
+   
+  },
   globalData: {
     statusBarHeight: my.getSystemInfoSync()['statusBarHeight'],
     windowHeight: my.getSystemInfoSync()['windowHeight'],
     imgUrl: 'http://resource.bike.hanyiyun.com/',
+    localSearchStop: true, //是否开启使用当前位置查询还车点
     screenHeight: '',
     login: false,
-    scanCode: '',//扫描普通二维码跳转小程序解析出的车牌号码
+    scanCode: '', //扫描普通二维码跳转小程序解析出的车牌号码
     platform: '',
     version: '',
     req: true,
@@ -68,35 +84,41 @@ App({
     // url: 'https://api.mtu.ximengnaikang.com/api', //线上域名
     // mapKey: 'GTLBZ-F6BKO-5EDWH-SDHIX-K2ART-O2FRQ' //地图key值
 
-    
-    // appName:'mtu',
-    // isOnlineKefu:false,//是否使用在线客服
-    // title: '禹见你', //全局修改此小程序名称
-    // company:'禹州市途娱科技有限公司',
-    // company_1:'途娱科技',
-    // scanLength: 9, //车辆编码位数  跶跶出行为11位 沃骑、禹见你9位
-    // logoUrl: '../../img/logo.png', //禹见你
-    // appid: '2021002147603404', //禹见你
-    // url: 'https://api.mtu.ximengnaikang.com/api', //禹见你
-    // mapKey: 'GTLBZ-F6BKO-5EDWH-SDHIX-K2ART-O2FRQ', //禹见你
-    // merchant_id: 1, //商户id
-    // imgUrl: 'http://resource.mtu.ximengnaikang.com/',
-    // videoUrl:'https://resource.mtu.ximengnaikang.com'
 
-    appName:'tkcx',
-    isUseTK:true,// 是否使用头盔
-    isOnlineKefu:false,//是否使用在线客服
-    title: '太康共享出行', //全局修改此小程序名称
-    company:'太康县速柯行科技有限公司',
-    company_1:'太康科技',
+    appName: 'mtu',
+    isUseTK: true, // 是否使用头盔
+    isOnlineKefu: false, //是否使用在线客服
+    title: '禹见你', //全局修改此小程序名称
+    localSearchStop: false, //是否开启使用当前位置查询还车点
+    isUseLinTing: true, //是否使用临时停车
+    noShowRefOpenLock:false,//是否在两分钟后隐藏车辆为开锁按钮
+    company: '禹州市途娱科技有限公司',
+    company_1: '途娱科技',
     scanLength: 9, //车辆编码位数  跶跶出行为11位 沃骑、禹见你9位
-    logoUrl: '../../img/tkcx.png', //太康共享出行
-    appid: '2021004144649616', //太康共享出行
-    url: 'https://api.yjtk.ximengnaikang.com/api', //太康共享出行
-    mapKey: 'GWTBZ-3B7HN-XYVFI-SNRHK-HF2F5-2WBB2', //太康共享出行
+    logoUrl: '../../img/logo.png', //禹见你
+    appid: '2021002147603404', //禹见你
+    url: 'https://api.mtu.ximengnaikang.com/api', //禹见你
+    mapKey: 'GTLBZ-F6BKO-5EDWH-SDHIX-K2ART-O2FRQ', //禹见你
     merchant_id: 1, //商户id
     imgUrl: 'http://resource.mtu.ximengnaikang.com/',
-    videoUrl:'https://resource.mtu.ximengnaikang.com'
+    videoUrl: 'https://resource.mtu.ximengnaikang.com'
+   // appName: 'tkcx',
+    // isUseTK: true, // 是否使用头盔
+    // localSearchStop: true, //是否开启使用当前位置查询还车点
+    // isOnlineKefu: true, //是否使用在线客服
+    // isUseLinTing: true, //是否使用临时停车
+    // noShowRefOpenLock:false,//是否在两分钟后隐藏车辆为开锁按钮
+    // title: '太康共享出行', //全局修改此小程序名称
+    // company: '太康县速柯行科技有限公司',
+    // company_1: '太康科技',
+    // scanLength: 9, //车辆编码位数  跶跶出行为11位 沃骑、禹见你9位
+    // logoUrl: '../../img/tkcx.png', //太康共享出行
+    // appid: 'wxaaa1587f918c7e8a', //太康共享出行
+    // url: 'https://api.yjtk.ximengnaikang.com/api', //太康共享出行
+    // mapKey: 'GWTBZ-3B7HN-XYVFI-SNRHK-HF2F5-2WBB2', //太康共享出行
+    // merchant_id: 1, //商户id
+    // imgUrl: 'http://resource.mtu.ximengnaikang.com/',
+    // videoUrl: 'https://resource.mtu.ximengnaikang.com'
   },
   request(api, params, method, req1) {
     var that = this;
@@ -114,7 +136,9 @@ App({
           'content-type': 'application/json',
           'Accept': 'application/json',
           'Cache-Control': 'no-cache',
-          'Authorization': my.getStorageSync({ 'key': 'token' }).data,
+          'Authorization': my.getStorageSync({
+            'key': 'token'
+          }).data,
           'merchant-id': this.globalData.merchant_id,
           'source-type': 'alipay'
         },
@@ -130,14 +154,22 @@ App({
               'url': api,
               'data': params,
               'merchant-id': this.globalData.merchant_id,
-              'authorization':my.getStorageSync({ 'key': 'token' }).data,
+              'authorization': my.getStorageSync({
+                'key': 'token'
+              }).data,
               type: 'success',
-              user: my.getStorageSync({ 'key': 'userInfo' }).data ? my.getStorageSync({ 'key': 'userInfo' }).data.user : '',
+              user: my.getStorageSync({
+                'key': 'userInfo'
+              }).data ? my.getStorageSync({
+                'key': 'userInfo'
+              }).data.user : '',
               version: '1.2.2'
             }
             my.request({
               url: this.globalData.url + '/logs', //仅为示例,并非真实的接口地址
-              data: { data: data },
+              data: {
+                data: data
+              },
               method: 'POST',
               header: {
                 'content-type': 'application/json', // 默认值
@@ -189,8 +221,12 @@ App({
             var timeout;
             console.log('token过期')
 
-            my.removeStorageSync({ key: 'token' })
-            my.removeStorageSync({ key: 'token_time' })
+            my.removeStorageSync({
+              key: 'token'
+            })
+            my.removeStorageSync({
+              key: 'token_time'
+            })
             // this.token()
             my.reLaunch({
               url: '/pages/index/index',
@@ -199,7 +235,8 @@ App({
             my.navigateTo({
               url: '/pages/undefind/undefind',
             })
-          } else {
+          } 
+          else {
             my.showToast({
               content: err.data.message || err.data,
               icon: 'none',
@@ -209,18 +246,26 @@ App({
           }
           console.log(err, 'qingqiushibai')
           let data = {
-            response: res,
+            response: err,
             'url': api,
             'data': params,
             'merchant-id': this.globalData.merchant_id,
-            'authorization': my.getStorageSync({'key':'token'}).data,
+            'authorization': my.getStorageSync({
+              'key': 'token'
+            }).data,
             type: 'success',
-            user: my.getStorageSync({ 'key': 'userInfo' }).data ? my.getStorageSync({ 'key': 'userInfo' }).data.user : '',
+            user: my.getStorageSync({
+              'key': 'userInfo'
+            }).data ? my.getStorageSync({
+              'key': 'userInfo'
+            }).data.user : '',
             version: '1.2.2'
           }
           my.request({
             url: this.globalData.url + '/logs', //仅为示例,并非真实的接口地址
-            data: { data: data },
+            data: {
+              data: data
+            },
             method: 'POST',
             header: {
               'content-type': 'application/json', // 默认值
@@ -241,9 +286,13 @@ App({
 
   login() {
     let that = this
-    let token = my.getStorageSync({ 'key': 'token' }).data
+    let token = my.getStorageSync({
+      'key': 'token'
+    }).data
     let data = Math.round(new Date().getTime() / 1000).toString();
-    let tokenTime = my.getStorageSync({ 'key': 'token_time' }).data || 0;
+    let tokenTime = my.getStorageSync({
+      'key': 'token_time'
+    }).data || 0;
     let cha = data - tokenTime
     let data1 = 60 * 60 * 4
     return new Promise((resolve, reject) => {
@@ -259,6 +308,7 @@ App({
               console.log(res.authCode)
               var data = {
                 'code': res.authCode,
+                // 'code':'040a788085094e47a75028874861PX410',
                 'appid': that.globalData.appid,
                 'type': 1
               };
@@ -276,41 +326,61 @@ App({
                 method: 'POST',
                 success: (res) => {
                   console.log(res, 'token')
-                  if (res.status == 401) {
-                    my.showToast({
-                      content: '登陆失败,请重新登录',
-                      icon: 'none'
+                
+                    my.setStorageSync({
+                      'key': 'token',
+                      data: res.data.token
+                    });
+                    my.setStorageSync({
+                      'key': 'session_key',
+                      data: res.data.session_key
+                    });
+                    my.setStorageSync({
+                      'key': 'token_time',
+                      data: res.data.exp
+                    });
+                    my.setStorageSync({
+                      'key': 'user_ID',
+                      data: res.data.user.id
+                    });
+                  
+                  resolve()
+                },
+                fail: (err) => {
+                  console.log('err',err)
+                  if (err.status == 401) {
+                    my.showModal({
+                      title: '提示',
+                      content: '登录失效,是否重新登录',
+                      confirmText: '重新登录',
+                      complete: (res) => {
+                        if (res.confirm) {
+                          my.reLaunch({
+                            url: '/pages/index/index'
+                          })
+                        }
+                      }
                     })
-                    setTimeout(function () {
-                      my.reLaunch({
-                        url: '/pages/authorization/authorization',
-                      })
-                    }, 1000)
-                  } else if (res.status != 200) {
+                    return
+                  }
+                  if (err.status != 200) {
                     console.log(res, 'cesgu---------------')
                     my.showToast({
-                      content: res.data.message,
+                      content: err.data.message,
                       icon: 'none'
                     })
-                  } else {
-                    my.setStorageSync({ 'key': 'token', data: res.data.token });
-                    my.setStorageSync({ 'key': 'session_key', data: res.data.session_key });
-                    my.setStorageSync({ 'key': 'token_time', data: res.data.exp });
-                    my.setStorageSync({ 'key': 'user_ID', data: res.data.user.id });
-                  }
-
-                  resolve()
-                }, fail: (err) => {
+                    return
+                  } 
                   my.alert({
                     title: '提示',
                     content: '可能网络不太好,请重试!',
                     success: () => {
                       my.reLaunch({
-                        url: '/pages/error/error?error=0'
+                        url: '/pages/error/index?error=0'
                       });
                     }
                   })
-                 
+
                 }
               })
             } else {
@@ -324,4 +394,4 @@ App({
       }
     })
   },
-})
+})

+ 2 - 1
app.json

@@ -35,7 +35,8 @@
     "pages/weizhang_detail/weizhang_detail",
     "pages/agreement/agreement",
     "pages/parking/parking",
-    "pages/video/video"
+    "pages/video/video",
+    "pages/error/index"
   ],
   "window": {
     "titleBarColor": "#fff",

BIN=BIN
img/dianche.png


BIN=BIN
img/local_posi.png


+ 2 - 1
mini.project.json

@@ -4,7 +4,8 @@
     "component2": true
   },
   "developOptions": {
-    "parallel": true
+    "parallel": true,
+    "hotReload": false
   },
   "unknownConfig": {
     "axmlStrictCheck": false

+ 67 - 27
pages/buy-card/buy-card.axml

@@ -1,51 +1,74 @@
 <view class="box">
-  <view class="top" a:if="{{arr!=''}}">
+  <view a:if="{{arr!='' || hotInfo}}"  class="top">
     <text>电单车骑行卡</text>
     <text>购卡骑行更划算</text>
   </view>
-  <view a:if="{{arr!=''}}" class="card">
-    <view  class="{{currentCard==hotInfo.id ? 'active' : 'card-list1'}}" onTap="changeCard" data-id="{{hotInfo}}">
-      <view class="right-tips" a:if="{{hotInfo.is_discount==1}}" >限时{{item.discount}}折</view>
+  <view class="card">
+    <view
+      class="{{currentCard==hotInfo.id ? 'active' : 'card-list1'}}"
+      onTap="changeCard"
+      data-id="{{hotInfo}}"
+    >
+      <view a:if="{{hotInfo.is_discount==1}}" class="right-tips">
+        限时{{item.discount}}折
+      </view>
       <!--  -->
       <view class="card-title">
-        <text a:if="{{hotInfo.is_limit_times==1}}">{{hotInfo.times}}次/{{hotInfo.effective_days}}天</text>
+        <text a:if="{{hotInfo.is_limit_times==1}}">
+          {{hotInfo.times}}次/{{hotInfo.effective_days}}天
+        </text>
         <text a:if="{{hotInfo.is_limit_times==0}}">{{hotInfo.effective_days}}天不限次</text>
       </view>
       <view class="card-tips">单次最高抵扣{{hotInfo.deduction_money}}元</view>
       <view class="card-money">
         <text class="money-num">{{hotInfo.now_price}}</text>元
-        <text class="yuanjia" a:if="{{hotInfo.is_discount==1}}">{{hotInfo.price}}元</text>
+        <text a:if="{{hotInfo.is_discount==1}}" class="yuanjia">
+          {{hotInfo.price}}元
+        </text>
       </view>
     </view>
-    <view class="card-list" a:for="{{arr}}" a:key="key">
+    <view a:for="{{arr}}" class="card-list" a:key="key">
 
-      <view class="card-list-item" class="{{currentCard==item.id ? 'active1' : 'card-list-item'}}" onTap="changeCard" data-id="{{item}}">
-      <view class="right-tips" a:if="{{item.is_discount==1}}">限时{{item.discount}}折</view>
+      <view
+        class="card-list-item"
+        class="{{currentCard==item.id ? 'active1' : 'card-list-item'}}"
+        onTap="changeCard"
+        data-id="{{item}}"
+      >
+        <view a:if="{{item.is_discount==1}}" class="right-tips">
+          限时{{item.discount}}折
+        </view>
         <view class="card-content">
           <view class="card-title">
-            <text a:if="{{item.is_limit_times==1}}">{{item.times}}次/{{item.effective_days}}天</text>
+            <text a:if="{{item.is_limit_times==1}}">
+              {{item.times}}次/{{item.effective_days}}天
+            </text>
             <text a:if="{{item.is_limit_times==0}}">{{item.effective_days}}天不限次</text>
           </view>
           <view class="item-money">
             <text class="money-num">{{item.now_price}}</text>元
-            <text class="yuanjia" a:if="{{item.is_discount==1}}">{{hotInfo.price}}元</text>
+            <text a:if="{{item.is_discount==1}}" class="yuanjia">{{hotInfo.price}}元</text>
+          </view>
+          <view class="card-tips" style="font-size:22rpx">
+            单次最高抵扣{{item.deduction_money}}元
           </view>
-          <view class="card-tips" style="font-size:22rpx">单次最高抵扣{{item.deduction_money}}元</view>
         </view>
       </view>
     </view>
 
   </view>
-<view class="buy-buttom" a:if="{{arr!=''}}" onTap="buyButtom">购买</view>
-  <view class="background" a:if="{{info}}" onTap="background"></view>
-  <view class="model" a:if="{{info}}">
+  <view a:if="{{arr!='' || hotInfo!=''}}" class="buy-buttom" onTap="buyButtom">购买</view>
+  <view a:if="{{info}}" class="background" onTap="background"></view>
+  <view a:if="{{info}}" class="model">
     <view class="view">
       <text class="title">购买骑行卡</text>
       <view class="content">
         <view class="count">
           <view class="count_a">
-            <text class="text" a:if="{{infoDetail.is_limit_times==1}}">{{infoDetail.times}}次</text>
-            <text class="text" a:if="{{infoDetail.is_limit_times==0}}">不限次</text>
+            <text a:if="{{infoDetail.is_limit_times==1}}" class="text">
+              {{infoDetail.times}}次
+            </text>
+            <text a:if="{{infoDetail.is_limit_times==0}}" class="text">不限次</text>
             <text>(有效期{{infoDetail.effective_days}}天)</text>
           </view>
           <view class="count_b">
@@ -54,22 +77,39 @@
           </view>
         </view>
         <text class="title1">使用规则</text>
-         <text>1.用户购买电单车骑行卡后,对应<text style="color:red;">骑行卡的优惠权益立即生效</text>。</text>
-        <text>2.骑行卡<text style="color:red;">无法抵扣订单调度费</text>。</text>
-        <text>3.请在有效期内使用,骑行卡<text style="color:red;">使用完毕或超出有效期</text>即视为无效。</text>
-        <text>4.电单车骑行卡生效期间,每次骑行最多可抵扣<text
-            style="color:red;">{{infoDetail.deduction_money}}</text>元骑行费用,超出部分依据计费规则计费。</text>
-        <text>5.骑行卡<text style="color:red;">一旦购买,不能退还,不能转赠</text>。</text>
-        <text style="padding-bottom:20rpx;">6.骑行卡只适用于<text style="color:red;">分时租赁</text>,不支持日租用车使用。</text>
+        <text>1.用户购买电单车骑行卡后,对应
+          <text style="color:red;">骑行卡的优惠权益立即生效</text>。</text>
+        <text>2.骑行卡
+          <text style="color:red;">无法抵扣订单调度费</text>。</text>
+        <text>3.请在有效期内使用,骑行卡
+          <text style="color:red;">使用完毕或超出有效期</text>即视为无效。</text>
+        <text>4.电单车骑行卡生效期间,每次骑行最多可抵扣
+          <text style="color:red;">
+            {{infoDetail.deduction_money}}
+          </text>
+          元骑行费用,超出部分依据计费规则计费。
+        </text>
+        <text>5.骑行卡
+          <text style="color:red;">一旦购买,不能退还,不能转赠</text>。</text>
+        <text style="padding-bottom:20rpx;">
+          6.骑行卡只适用于
+          <text style="color:red;">分时租赁</text>,不支持日租用车使用。
+        </text>
       </view>
       <view class="btn1" onTap="form">
         <text>{{infoDetail.now_price}}元购买</text>
       </view>
     </view>
-    <image src="{{img}}weapp/guanbi.png" style="width:48rpx;height:48rpx;" class="over1" onTap="background"></image>
+    <image
+      src="{{img}}weapp/guanbi.png"
+      style="width:48rpx;height:48rpx;"
+      class="over1"
+      onTap="background"
+    >
+    </image>
   </view>
 </view>
-<view class="none" a:if="{{arr=='' && hotInfo==''}}">
-  <image src="../../img/nocard.png" ></image>
+<view a:if="{{arr=='' && hotInfo==''}}" class="none">
+  <image src="../../img/nocard.png"></image>
   <text>暂无骑行卡</text>
 </view>

+ 2 - 0
pages/buy-card/buy-card.js

@@ -28,11 +28,13 @@ Page({
     }
     app.request("/card_riding/index", data, "GET").then(res => {
       console.log(res)
+     
       my.hideLoading()
       if (res.data.data == '') {
         return;
       }
       var arr1 = res.data.data.shift()
+      console.log('骑行卡数据',res.data.data.shift())
       console.log(arr1)
       console.log(res.data.data)
       that.setData({

+ 27 - 0
pages/error/index.acss

@@ -0,0 +1,27 @@
+/* pages/error/error.wxss */
+.image{
+  text-align: center;
+  margin-top: 25%;
+}
+.image image{
+height: 230rpx;
+width: 310rpx;
+}
+.err{
+width: 60%;
+height: 80rpx;
+background-color: var(--globleColor);
+margin: 0 auto;
+border-radius: 50rpx;
+line-height: 80rpx;
+font-size: 34rpx;
+font-weight: 500;
+color:var(--fillBgColor);
+text-align: center;
+margin-top:90rpx;
+}
+.tip{
+  font-size:28rpx;
+  color: #808080;
+  margin-top:30rpx;
+}

+ 10 - 0
pages/error/index.axml

@@ -0,0 +1,10 @@
+<view>
+  <view class="image">
+    <image src="../../img/error.png" ></image>
+    <view class="tip">当前网络不稳定,请重试</view>
+  </view>
+  <view class="bottom">
+    <view class="err" onTap="reLoad" a:if="{{error==1}}">重新加载</view>
+    <navigator hover-class="none" url=""   a:if="{{error==0}}"  class="err" open-type="exit">退出重试</navigator>
+  </view>
+</view>

+ 19 - 0
pages/error/index.js

@@ -0,0 +1,19 @@
+Page({
+  data: {
+    error:0 // 0:需要退出小程序 1:可以重新发起网络请求重试
+  },
+  reLoad:function(error){
+   
+    my.reLaunch({
+      url: '/pages/index/index',
+    })
+  },
+ 
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    this.setData({ error: options.error});
+  },
+  
+});

+ 4 - 0
pages/error/index.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "styleIsolation": "apply-shared"
+}

+ 8 - 1
pages/index/index.acss

@@ -187,7 +187,7 @@ font-size: 30rpx;
 }
 
 #map {
-  height: 100vh;
+  height: calc(100vh - 155px);
   width: 100%;
   z-index: 3;
 }
@@ -373,4 +373,11 @@ bottom: 350rpx;
 
 .marqueeTitle {
   height: 70rpx;
+}
+.center-posi {
+  width: 60rpx;
+  height: 60rpx;
+  position: fixed;
+ top: calc((100vh - 175px)/2);
+  left: calc(50% - 30rpx);
 }

+ 8 - 2
pages/index/index.axml

@@ -85,9 +85,15 @@
     <image src="../../img/more.png" style="width:48rpx;height:48rpx;"></image>
   </view>
   <!-- 地图 -->
-  <map name="map" id="map" show-location="true" longitude='{{longitude}}' latitude='{{latitude}}' scale='{{zoom}}' markers="{{markers}}" 
+  <!-- <map name="map" id="map" show-location="true" longitude='{{longitude}}' latitude='{{latitude}}' scale='{{zoom}}' markers="{{markers}}" 
     data-markers="{{markers}}" controls="{{controls}}" polygon="{{polygons}}">
-  </map>
+  </map> -->
+   <!-- 地图显示停车区域-->
+   <map name="map" id="map" show-location="true" longitude='{{centerLon}}' latitude='{{centerLat}}' scale='{{zoom}}' enable-zoom='true' 
+   markers="{{markers}}" data-markers="{{markers}}" controls="{{controls}}" polygon="{{polygons}}" onRegionChange="regionchange">
+  
+ </map>
+ <cover-image a:if="{{localSearchStop}}" src="../../img/local_posi.png" class="center-posi"></cover-image>
   <view class="map-icon">
     <view class="kefu" onTap="findPark">
       <image src="../../img/park.png"></image>

+ 187 - 113
pages/index/index.js

@@ -2,17 +2,22 @@
 // 获取应用实例
 //获取应用实例
 // const log = require('../../utils/log')
-const { getCache, setCache, CacheKeys } = require('../../utils/cache')
+const {
+  getCache,
+  setCache,
+  CacheKeys
+} = require('../../utils/cache')
 const app = getApp();
-var token = my.getStorageSync({ 'key': 'token' }).data;
+var token = my.getStorageSync({
+  'key': 'token'
+}).data;
 const util = require('../../utils/utils.js');
 //const { content } = require('/utils/dataTransition.js');
 var mytime = null;
 let testToken = ''
 Page({
   data: {
-    cardBottom: [
-      {
+    cardBottom: [{
         id: 1,
         name: '故障上报',
         icon: 'icon-banshou',
@@ -38,7 +43,7 @@ Page({
         url: '/pages/mine/mine'
       }
     ],
-    adFrame: false,//首页中间广告弹框
+    adFrame: false, //首页中间广告弹框
     markers: [], //显示单车、停车的P
     polygons: [], //区域
     longitude: '', //113.786111
@@ -54,8 +59,8 @@ Page({
     userStatus: '', //用户的一些状态 是否交押金等   0                                                                                           
     scanfail: false, //扫码失败弹窗
     is_pay_order: false, //检测当前是否有订单未支付
-    is_ride_order: false,//是否有骑行中订单
-    is_punishment: false,//有违章订单
+    is_ride_order: false, //是否有骑行中订单
+    is_punishment: false, //有违章订单
     code: '', //点击立即用车 把编号赋值给code
     over: false, //关闭图标
     over1: false, //扫码失败关闭图标
@@ -63,8 +68,8 @@ Page({
     screenHeight: '', //屏幕可视高度
     box_no: '', //中控编号
     abnormal: '', //提示账号异常
-    mid: [],//顶部广告
-    ads: [],//首页中间广告
+    mid: [], //顶部广告
+    ads: [], //首页中间广告
     currentSwiper: 0,
     center_currentSwiper: 0,
     bike_no: undefined,
@@ -73,7 +78,7 @@ Page({
     notice: [], //公告内容
     animationData: {},
     tabbar_index: 0,
-    zoom: 18,
+    zoom: 12,
     versions: false, //版本过低弹窗
     chooseSize: false,
     animationData1: {},
@@ -83,19 +88,32 @@ Page({
     marqueeDistance: 520, //初始滚动距离 用到
     size: 26, //通知公告用到
     marqueeWidth: 560, //通知公告用到
-    length: '',//通知公告
+    length: '', //通知公告
     swiperCurrent: 0,
     midbolear: '',
     per_money: '',
     img: app.globalData.imgUrl,
     new_user_coupons: [],
-    scanCodeErr: false,//扫码失败弹框
-    isScan: false
+    scanCodeErr: false, //扫码失败弹框
+    isScan: false,
+    centerLon: '', //地图中心点经纬度
+    centerLat: '', //地图中心点经纬度
+    localSearchStop: app.globalData.localSearchStop, //是否开启使用当前位置查询还车点
+    bikeMarker: [], //当前车辆位置的mark
+    mapCtx:''
+
+
+  },
+  onReady() {
+    // 使用 my.createMapContext 获取 map 上下文
+    this.mapCtx = my.createMapContext('map');
   },
 
   onLoad: function (query) {
     var that = this;
-    console.log(my.getStorageSync({ 'key': 'token' }).data, 'yyyyyyyyyyyyyyy')
+    console.log(my.getStorageSync({
+      'key': 'token'
+    }).data, 'yyyyyyyyyyyyyyy')
     my.setNavigationBar({
       title: app.globalData.title
     })
@@ -110,11 +128,19 @@ Page({
     my.setNavigationBar({
       title: app.globalData.title
     })
-    token = my.getStorageSync({ 'key': 'token' }).data
+    token = my.getStorageSync({
+      'key': 'token'
+    }).data
+    let home = my.setStorageSync({
+      'key': 'home'
+    }).data
     this.setData({
       show: false,
-      midbolear: my.getStorageSync({ 'key': 'midTimes' }).data,
-      polygons: []
+      midbolear: my.getStorageSync({
+        'key': 'midTimes'
+      }).data,
+      polygons: [],
+      zoom: home && home.zoom ? home.zoom : 12
     })
     if (!this.data.isScan) {
       app.login().then(res => {
@@ -151,7 +177,7 @@ Page({
     if (isCache) {
       if (isCache == '') return
       if (isCache instanceof Object && isCache.hasOwnProperty('header')) {
-  
+
 
         that.setData({
           ads: isCache.header
@@ -253,7 +279,9 @@ Page({
     let isCache = getCache('Notice:' + id)
     if (isCache) {
       if (isCache instanceof Object && !isCache.hasOwnProperty('id')) return
-      this.setData({ notice: isCache })
+      this.setData({
+        notice: isCache
+      })
       var length = isCache.description.length * this.data.size; //计算文字的长度
       this.setData({
         length: length
@@ -273,7 +301,9 @@ Page({
       console.log(res)
       if (200 == res.status && res.data.id) {
         setCache('Notice:' + id, res.data)
-        this.setData({ notice: res.data })
+        this.setData({
+          notice: res.data
+        })
         var length = res.data.description.length * this.data.size; //计算文字的长度
         this.setData({
           length: length
@@ -320,8 +350,8 @@ Page({
         console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
         my.hideLoading()
         that.setData({
-          longitude: res.longitude,
-          latitude: res.latitude
+          centerLon: res.longitude,
+          centerLat: res.latitude
         })
       },
       fail: function (err) {
@@ -333,7 +363,9 @@ Page({
 
             },
             fail: (error) => {
-              my.alert({ content: '获取位置授权失败' });
+              my.alert({
+                content: '获取位置授权失败'
+              });
             },
           });
         }
@@ -355,16 +387,17 @@ Page({
   }, 1000),
   //点击扫描二维码
   sweepCode: util.throttle(function () {
-    let that = this
-    console.log('点击扫码,‘iooooo')
-    if (!that.data.latitude && !that.data.longitude) {
-      that.setData({
-        background: true,
-        location: true
-      })
-    } else {
-      that.sweep_code()
-    }
+    this.sweep_code()
+    // let that = this
+    // console.log('点击扫码,‘iooooo')
+    // if (!that.data.latitude && !that.data.longitude) {
+    //   that.setData({
+    //     background: true,
+    //     location: true
+    //   })
+    // } else {
+      // that.sweep_code()
+    // }
   }, 1500),
   //骑行区禁停区车辆
   home: function () {
@@ -381,8 +414,6 @@ Page({
         console.log(res)
         if (res.status == 200) {
           var data = res.data;
-          data.width = 1
-          data.strokeWidth =1
           console.log(data, '区域')
           let id = data.id
           this.getNotice(id)
@@ -392,14 +423,17 @@ Page({
               polygons1: that.data.polygons.concat(data),
               setting: data.setting,
               per_money: Number(data.setting.starting_price),
-              polygons: []
+              polygons: that.data.polygons.concat(data),
+              zoom: data.zoom ? data.zoom : 12
             })
             if (!data.id) return
 
-            that.adsList(data.id),
-              that.ban_stop(data.id), that.setData({
-                polygons: that.data.polygons.concat(data)
-              })
+            that.adsList(data.id)
+             //原获取全部还车点接口
+            if (that.data.localSearchStop == false) that.ban_stop(data.id)
+            //根据位置请求区域
+            if (that.data.localSearchStop == true) that.searchStopArea(that.data.longitude, that.data.latitude)
+
           }
           if (res.status == 423) {
             my.getLocation({
@@ -422,14 +456,24 @@ Page({
               }
             })
           }
-          my.setStorageSync({ 'key': 'home', data: data })
+          my.setStorageSync({
+            'key': 'home',
+            data: data
+          })
         }
         if (data) {
-          my.setStorageSync({ 'key': 'setting', data: data.setting })
+          my.setStorageSync({
+            'key': 'setting',
+            data: data.setting
+          })
 
         } else {
-          my.removeStorageSync({ key: 'setting' })
-          my.removeStorageSync({ key: 'home' })
+          my.removeStorageSync({
+            key: 'setting'
+          })
+          my.removeStorageSync({
+            key: 'home'
+          })
         }
 
       }).catch(err => {
@@ -445,6 +489,35 @@ Page({
       })
     }
   },
+  regionchange: function (e) {
+    if (this.data.localSearchStop == false) return
+    if (e.type == 'end') {
+      this.searchStopArea(e.longitude, e.latitude)
+    }
+  },
+  //添加定位点,并展示周围还车点
+  searchStopArea: function (longitude, latitude) {
+    let home = my.getStorageSync({
+      'key': 'home'
+    }).data
+    if (!home || !home.id) return
+    let params = {
+      'lat': latitude,
+      'lng': longitude,
+      'area_id':home.id,
+    }
+    console.log(this.data.polygons)
+    app.request('/parking/nearby-all', params, 'GET').then(res => {
+      console.log('根据位置获取区域', res)
+      let arr = [home]
+      this.setData({
+        markers: this.data.bikeMarker.concat(res.data.points),
+        polygons: arr.concat(res.data.polygons),
+        centerLat:latitude,
+        centerLon:longitude
+      })
+    })
+  },
   //停车区域
   ban_stop: function (id) {
     var that = this;
@@ -528,7 +601,9 @@ Page({
   }, 1500),
   //    //点击去实名认证
   authentication: util.throttle(function () {
-    var state = my.getStorageSync({ 'key': 'userState' }).data
+    var state = my.getStorageSync({
+      'key': 'userState'
+    }).data
     if (state.is_bind_mobile == 1) {
       my.navigateTo({
         url: '/pages/real_name/real_name?state1=1&index=0',
@@ -549,35 +624,41 @@ Page({
     var that = this;
     console.log('ooooooo')
     var userStatus = that.data.userStatus;
-    var setting = my.getStorageSync({ 'key': 'setting' }).data
+    var setting = my.getStorageSync({
+      'key': 'setting'
+    }).data
     if (!setting) {
       my.alert({
         title: '提示',
         content: '您附近暂无运营区,暂不可用车'
       })
     } else {
-      if (!userStatus) {
-        my.navigateTo({
-          url: '/pages/authorization/authorization',
-        })
-      }
-      else {
-        that.jiance('scan');
-      }
+      that.jiance('scan');
+      // if (!userStatus) {
+      //   my.navigateTo({
+      //     url: '/pages/authorization/authorization',
+      //   })
+      // } else {
+      //   that.jiance('scan');
+      // }
     }
   }, 1500),
   //扫码用车检测不可用车条件
   jiance: function (source) {
     var that = this;
     var userStatus = that.data.userStatus;
-    var setting = my.getStorageSync({ 'key': 'setting' }).data
+    var setting = my.getStorageSync({
+      'key': 'setting'
+    }).data
     //未绑定手机号
-    if (userStatus.is_bind_mobile == 0) {
-      my.navigateTo({
-        url: '/pages/authorization/authorization',
-      })
-      //未实名认证
-    } else if (userStatus.is_card_certified == 0 && setting.is_card == 1) {
+    // if (userStatus.is_bind_mobile == 0) {
+    //   my.navigateTo({
+    //     url: '/pages/authorization/authorization',
+    //   })
+      
+    // } else 
+   //未实名认证 
+    if (userStatus.is_card_certified == 0 && setting.is_card == 1) {
       my.navigateTo({
         url: '/pages/real_name/real_name',
       })
@@ -749,14 +830,7 @@ Page({
     })
   },
 
-  onReady: function () {
 
-  },
-  kefu: util.throttle(function () {
-    my.makePhoneCall({
-      number: my.getStorageSync({ 'key': 'home' }).data.customer_service_phone,
-    })
-  }, 1500),
   //用户状态
   userState: function (id) {
     var that = this;
@@ -769,7 +843,10 @@ Page({
           is_pay_order: res.data.is_pay_order,
           is_ride_order: res.data.is_ride_order,
           is_punishment: res.data.is_punishment,
-        }), my.setStorageSync({ 'key': 'userState', data: res.data })
+        }), my.setStorageSync({
+          'key': 'userState',
+          data: res.data
+        })
       }
     }).catch(err => {
       console.log(err)
@@ -779,7 +856,10 @@ Page({
   getUser() {
     app.request("/me", '', "GET").then(res => {
       console.log(res)
-      200 == res.status && my.setStorageSync({ 'key': 'userInfo', data: res.data })
+      200 == res.status && my.setStorageSync({
+        'key': 'userInfo',
+        data: res.data
+      })
     }).catch(err => {
       console.log(err)
     })
@@ -791,8 +871,7 @@ Page({
       location: false
     })
     my.openSetting({
-      success: function (res) {
-      }
+      success: function (res) {}
     })
   }, 1500),
 
@@ -816,9 +895,11 @@ Page({
       type: 'gcj02',
       success: (res) => {
         console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
+        this.data.longitude =res.longitude
+        this.data.latitude =res.latitude
         that.setData({
-          longitude: res.longitude,
-          latitude: res.latitude,
+          centerLon: res.longitude,
+          centerLat: res.latitude,
           show: false
         })
         console.log(res, 'ppp')
@@ -840,7 +921,9 @@ Page({
 
             },
             fail: (error) => {
-              my.alert({ content: '获取位置授权失败' });
+              my.alert({
+                content: '获取位置授权失败'
+              });
             },
           });
 
@@ -870,7 +953,9 @@ Page({
     console.log(that.data, 'oooooo')
 
     var userStatus = that.data.userStatus;
-    var setting = my.getStorageSync({ 'key': 'setting' }).data
+    var setting = my.getStorageSync({
+      'key': 'setting'
+    }).data
     if (data.id == 2 && !that.data.latitude && !that.data.longitude) {
       that.setData({
         background: true,
@@ -887,14 +972,14 @@ Page({
       return
     }
     if (data.id == 2 && setting) {
-      if (!userStatus) {
-        my.navigateTo({
-          url: '/pages/authorization/authorization',
-        })
-      }
-      else {
-        that.jiance1();
-      }
+      // if (!userStatus) {
+      //   my.navigateTo({
+      //     url: '/pages/authorization/authorization',
+      //   })
+      // } else {
+      //   that.jiance1();
+      // }
+      that.jiance1();
     } else {
       my.navigateTo({
         url: data.url,
@@ -955,15 +1040,19 @@ Page({
   //输码开锁检测
   jiance1: function (source) {
     var that = this;
-    let setting = my.getStorageSync({ 'key': 'setting' }).data
+    let setting = my.getStorageSync({
+      'key': 'setting'
+    }).data
     var userStatus = that.data.userStatus;
     //未绑定手机号
-    if (userStatus.is_bind_mobile == 0) {
-      my.navigateTo({
-        url: '/pages/authorization/authorization',
-      })
-      //未实名认证
-    } else if (userStatus.is_card_certified == 0 && setting.is_card == 1) {
+    // if (userStatus.is_bind_mobile == 0) {
+    //   my.navigateTo({
+    //     url: '/pages/authorization/authorization',
+    //   })
+      
+    // } else 
+    //未实名认证
+    if (userStatus.is_card_certified == 0 && setting.is_card == 1) {
       my.navigateTo({
         url: '/pages/real_name/real_name',
       })
@@ -981,8 +1070,7 @@ Page({
           icon: 'none'
         })
         return;
-      }
-      else {
+      } else {
         //有待支付骑行订单
         if (userStatus.is_pay_order != false && userStatus.is_pay_order != undefined) {
           my.showToast({
@@ -1006,10 +1094,13 @@ Page({
       }
     }
   },
-  // 客服
+  // // 客服
   kefu: function () {
+    let phone = my.getStorageSync({
+      'key': 'home'
+    })
     my.makePhoneCall({
-      number: my.getStorageSync({ 'key': 'home' }).data.customer_service_phone,
+      number: phone ? phone.data.customer_service_phone : '13203706613'
     })
   },
 
@@ -1049,21 +1140,4 @@ Page({
     })
   },
 
-})
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+})

+ 1 - 1
pages/mine/mine.axml

@@ -14,7 +14,7 @@
   <view class="mine-ad" onTap="adDetail" a:if="{{deposit.is_deposit==1 && deposit.deposit_type==6}}">
     您已获得终身免押资格!
   </view>
-  <view class="mine-tab">
+  <view class="mine-tab"  a:if="{{ is_dev==false }}">
     <view class="mine-tab-item" onTap="balance">
       <view class="tab-num">¥{{userInfo.wallet_money | parseFloat}}</view>
       <view class="tab-text">余额</view>

+ 3 - 1
pages/mine/mine.js

@@ -8,6 +8,7 @@ Page({
     show: false,
     setting: '',//设置
     src: '',//用户头像地址
+    is_dev:true,//是否为开发环境是的话隐藏购卡充值
   },
   onLoad: function (options) {
     // 页面加载完成
@@ -77,7 +78,8 @@ Page({
         this.setData({
           userInfo: res.data,
           deposit: my.getStorageSync({ 'key': 'userState' }).data,
-          setting: my.getStorageSync({ 'key': 'setting' }).data
+          setting: my.getStorageSync({ 'key': 'setting' }).data,
+          is_dev:res.data.is_dev
         })
       }).catch(err => {
         console.log(err)

+ 19 - 3
pages/use_bike/use_bike.acss

@@ -5,6 +5,13 @@
   /* z-index: 999999999999999999; */
   width: 100%;
 }
+.center-posi {
+  width: 60rpx;
+  height: 60rpx;
+  position: fixed;
+ top: calc((100vh - 625rpx)/2);
+  left: calc(50% - 30rpx);
+}
 
 .map-icon {
   position: fixed;
@@ -217,7 +224,7 @@ image {
 
 .step3-title {
   display: flex;
-  padding: 0 40rpx;
+  padding: 0 30rpx;
   font-size: 32rpx;
   color: #484848;
 }
@@ -244,7 +251,15 @@ image {
   border-radius: 40rpx;
   border: solid 1rpx #e5e5e5;
 }
+.toukui{
+  flex: 0 0 140rpx;
+  margin-right: 12rpx;
 
+}
+.unOpen{
+  color: #000;
+  border: solid 1px #000;
+}
 .bell {
   flex: 0 0 50rpx;
   height: 50rpx;
@@ -688,8 +703,9 @@ image {
 }
 
 .pops .pop-cont {
-  display: flex;
-  align-items: center;
+  /* display: flex; */
+  /* align-items: center; */
+  text-align: left;
   font-size: 30rpx;
   color: red;
   width: 88%;

+ 21 - 9
pages/use_bike/use_bike.axml

@@ -35,9 +35,11 @@
     </view>
   </view>
   <!-- 地图显示停车区域-->
-  <map name="" id="map" show-location="true" longitude='{{longitude}}' latitude='{{latitude}}' scale='{{zoom}}' enable-zoom='true' 
-    markers="{{markers}}" data-markers="{{markers}}" controls="{{controls}}" polygon="{{polygons}}">
+  <map name="" id="map" show-location="true" longitude='{{centerLon}}' latitude='{{centerLat}}' scale='{{zoom}}' enable-zoom='true' 
+    markers="{{markers}}" data-markers="{{markers}}" controls="{{controls}}" polygon="{{polygons}}" onRegionChange="regionchange">
+   
   </map>
+  <cover-image a:if="{{localSearchStop}}" src="../../img/local_posi.png" class="center-posi"></cover-image>
   <view class="map-icon">
     <view class="park" onTap="findPark">
       <image src="../../img/park.png"></image>
@@ -114,10 +116,6 @@
       <view class="ad-frame-close" onTap="closeAdframe">
         <text class="iconfont icon-cha"></text></view>
     </view>
-    
-    
-    
-    
     <view class="use-bike-bottom" catchtouchmove='ture'>
       <!-- 骑行第一步 -->
       <view class="step1" a:if="{{steps==1}}">
@@ -175,7 +173,8 @@
             剩余电量可行驶
             <text class="title-left-num">{{bikeMessage.riding_bike_mileage||'--'}}</text>公里
           </view>
-          <view class="step3-title-right" onTap="frameShow" a:if="{{parkStatus==0 || parkStatus==2}}">车辆未开锁</view>
+          <view class="step3-title-right toukui" onTap="controlToukui" a:if="{{parkStatus==0 && chaButton==0 && isUseTK==true}}">开头盔锁</view>
+          <view class="step3-title-right unOpen" onTap="frameShow" a:if="{{parkStatus==0 || parkStatus==2}}">车辆未开锁</view>
           <view class="bell" onTap="clickBell" a:if="{{parkStatus==1}}">
             <image class="bell-image" src="../../img/bell1.png"></image></view>
         </view>
@@ -220,7 +219,7 @@
           <view class="step3-bottom-left" a:if="{{parkStatus==1 && chaButton==0}}" onTap="openPark">解锁</view>
           <view class="step3-cha" onTap="cancelEndBike" a:if="{{chaButton==1}}">
             <text class="iconfont icon-cha"></text></view>
-          <view class="step3-bottom-left" onTap="controlToukui" wx:if="{{parkStatus==0 && chaButton==0 && isUseTK==true}}">开头盔锁</view>
+          <!-- <view class="step3-bottom-left" onTap="controlToukui" wx:if="{{parkStatus==0 && chaButton==0 && isUseTK==true}}">开头盔锁</view> -->
           <view class="step3-bottom-right" onTap="endUseBike" a:if="{{parkStatus!==2 && chaButton==0}}">结束用车</view>
           <view class="step3-bottom-right" onTap="sureEndUseBike" a:if="{{chaButton==1}}">确认结束</view>
           <!-- 不在还车区还车提示 -->
@@ -236,6 +235,19 @@
             </view>
           </view>
           <view class="popbj" a:if="{{popShow}}"></view>
+          <!-- 头盔弹框 -->
+          <view class="pops" a:if="{{TKtipsProp}}">
+            <text class="pop-title" style="color: black;">提示</text>
+            <view class="pop-cont">
+              <view style="font-size: 32rpx;"><text style="color: rgb(51, 51, 51);">头盔未放好!请将头盔归位后重新结束用车!</text> <text>若头盔已经放置好,请选择强制换车。【注:强制换车时,系统检测到头盔未归还,将额外扣取80元头盔费用】</text></view>
+            </view>
+  
+            <view class="pop-btn">
+              <view style="border-right: 1rpx solid #e5e5e5;color: black;" bindtap="continueHuanche"><text>强制还车</text></view>
+              <view style="color: #1e80ff;" bindtap="tkKnow"><text>我知道了</text></view>
+            </view>
+          </view>
+          <view class="popbj" a:if="{{TKtipsProp}}"></view>
         </view>
         <view class="bike_no">NO:{{code}}</view>
       </view>
@@ -249,7 +261,7 @@
         <view class="bottom-list-item" onTap="bikeKnow">
           <text class="iconfont icon-guize buttom-icon"></text>
           <text>骑行须知</text></view>
-        <view class="bottom-list-item" onTap="bikeCoupon">
+        <view class="bottom-list-item"  a:if="{{ is_dev==false }}" onTap="bikeCoupon">
           <text class="iconfont icon-coupon buttom-icon"></text>
           <text>特惠购卡</text></view>
       </view>

+ 254 - 158
pages/use_bike/use_bike.js

@@ -66,7 +66,7 @@ Page({
     markers: [],
     polygons: [],
     polygons1: [],
-    zoom: 18,
+    zoom: 12,
     temporaryTime: '', //临时锁车时间
     background: false, //位置权限弹框
     location: false, //位置权限弹框
@@ -83,15 +83,33 @@ Page({
     load_num: 0, //超出区域弹窗提示弹出次数控制控制弹窗弹出次数
     isUseTK: app.globalData.isUseTK, //是否使用头盔
     ifKnowUseTK: true, //是否已点击使用头盔
+    is_dev: true, //是否为开发环境是的话隐藏购卡充值
+    localSearchStop: app.globalData.localSearchStop, //是否开启使用当前位置查询还车点
+    bikeMarker: [], //当前车辆位置的mark
+    isUseLinTing: app.globalData.isUseLinTing, //是否使用临时停车
+    TKfuwei: true, //头盔是否复位
+    TKtipsProp: false, //头盔是否在位提示框
+    start_use_bike_time: 0, //开始用车的时间
+    noShowRefOpenLock: false,//隐藏为开锁按钮,false不隐藏
   },
+
   onShow: function () {
     let isLearn = my.getStorageSync({
       'key': 'videoLearn'
     }).data
+    let is_dev = my.getStorageSync({
+      'key': 'userInfo'
+    }).data
+    let home = my.setStorageSync({
+      'key': 'home'
+    }).data
     let that = this
     that.setData({
       polygons1: [],
-      polygons: []
+      polygons: [],
+      is_dev: is_dev ? is_dev.is_dev : true,
+      markers: [],
+      zoom: home &&home.zoom ? home.zoom : 12
     })
     my.setNavigationBar({
       title: app.globalData.title
@@ -169,9 +187,13 @@ Page({
   },
   onLoad: function (options) {
     let that = this
-
-    if (app.globalData.scanCode) {
-
+    console.log(options!=={},!app.globalData.scanCode)
+  
+    if(options.code){
+      that.setData({
+        code: options.code
+      })
+    }else if (app.globalData.scanCode) {
       that.setData({
         code: app.globalData.scanCode
       })
@@ -179,9 +201,9 @@ Page({
       that.setData({
         order: options.order,
       })
-    } else {
-      that.setData({
-        code: options.code
+    }else if(options!=={} && !app.globalData.scanCode){
+      my.reLaunch({
+        url:'/pages/index/index'
       })
     }
   },
@@ -454,17 +476,24 @@ Page({
         if (res.status == 200) {
           var data = res.data;
           that.setData({
-            area_id: res.data.id
+            area_id: res.data.id,
+            zoom: data.zoom ? data.zoom : 12,
+            polygons: that.data.polygons.concat(data),
           })
-          let area_id = res.data.id
-          that.ban_stop(area_id)
-          that.getNotice(area_id)
-          that.adsList(area_id)
-          console.log(data, '区域')
           my.setStorageSync({
             'key': 'home',
             data: data
           });
+          let area_id = res.data.id
+           //原获取全部还车点接口
+           if (that.data.localSearchStop == false) that.ban_stop(area_id)
+           //根据位置请求区域
+           if (that.data.localSearchStop == true) that.searchStopArea(that.data.longitude, that.data.latitude)
+ 
+          that.getNotice(area_id)
+          that.adsList(area_id)
+          console.log(data, '区域')
+      
 
         }
         console.log(data, 'tdada')
@@ -488,7 +517,35 @@ Page({
       })
     }
   },
-
+  regionchange: function (e) {
+    if (this.data.localSearchStop == false) return
+    if (e.type == 'end') {
+      this.searchStopArea(e.longitude, e.latitude)
+    }
+  },
+  //添加定位点,并展示周围还车点
+  searchStopArea: function (longitude, latitude) {
+    let home = my.getStorageSync({
+      'key': 'home'
+    }).data
+    if (!home || !home.id) return
+    let params = {
+      'lat': latitude,
+      'lng': longitude,
+      'area_id':home.id,
+    }
+    console.log(this.data.polygons)
+    app.request('/parking/nearby-all', params, 'GET').then(res => {
+      console.log('根据位置获取区域', res)
+      let arr = [home]
+      this.setData({
+        markers: this.data.bikeMarker.concat(res.data.points),
+        polygons: arr.concat(res.data.polygons),
+        centerLat:latitude,
+        centerLon:longitude
+      })
+    })
+  },
 
   //停车区域
   ban_stop: function (area_id) {
@@ -548,6 +605,7 @@ Page({
             load_num: that.data.load_num + 1
           })
         }
+        this.data.start_use_bike_time = res.data.start_use_bike_time
         if (res.data.is_out_area == true && that.data.load_num == 1) {
           my.showModal({
             title: '提示',
@@ -579,49 +637,7 @@ Page({
             minute: 0
           })
         } else {
-          let cha = date - res.data.start_use_bike_time
-          let setting = my.getStorageSync({
-            'key': 'setting'
-          }).data;
-          var time = parseInt(cha / 60) - setting.starting_price_time;
-          var per_money = setting.per_money;
-          var per_minute = setting.per_minute;
-          // console.log('测试1',times)
-          //页面进来时初始化金额
-
-          // let money = parseFloat(parseFloat(time / per_minute * per_money + parseFloat(setting.starting_price)).toFixed(2));
-          let money = parseInt(time / per_minute) * per_money + parseFloat(setting.starting_price)
-
-          var hour = Math.floor(cha / 3600 % 24);
-          // 分钟
-          var minute = Math.floor(cha / 60 % 60);
-          // let hour = parseInt(cha / 3600)
-          console.log(hour, 'hour')
-          console.log(minute, 'hour')
-          hour = hour < 10 ? '0' + hour : hour
-          minute = minute < 10 && hour > 0 ? '0' + minute : minute
-          if (hour > 0) {
-            // let minute=
-
-            that.setData({
-              minute: date - res.data.start_use_bike_time,
-              times: hour + ":" + minute,
-              estimate_money: money,
-              isHour: true
-            })
-          } else {
-            // let minute = parseInt(cha / 60)
-            that.setData({
-              minute: date - res.data.start_use_bike_time,
-              times: minute,
-              estimate_money: money,
-              isHour: false
-            })
-          }
-
-          // that.setData({
-          //   minute: date - res.data.start_use_bike_time
-          // })
+          that.countBikeMoney()
         }
         that.terval()
         my.showToast({
@@ -696,12 +712,50 @@ Page({
             url: '../index/index',
           })
         }
-        // that.bikeLocation();
+        that.bikeLocation();
       }
     }).catch(err => {
       console.log(err)
     })
   },
+    //获取车辆位置信息
+    bikeLocation: function (type) {
+      var that = this;
+      var data = {
+        bike_no: that.data.code
+      }
+      app.request('/order/orderBikePosition', data, 'GET').then(res => {
+        if (res.statusCode == 200) {
+          if (type == 'getPosition') {
+            this.data.markers.map((item, index) => {
+              if (item.id == 12345) {
+                this.setData({
+                  ['markers[' + index + '].longitude']: res.data.lng,
+                  ['markers[' + index + '].latitude']: res.data.lat
+                })
+                this.data.bikeMarker[0].latitude = res.data.lat 
+                this.data.bikeMarker[0].longitude = res.data.lng 
+              }
+            })
+          } else {
+            var array = {}
+            array.iconPath = '/img/dianche.png';
+            array.width = 28;
+            array.height = 28;
+            array.zIndex = 1111;
+            array.id = 12345;
+            array.latitude = res.data.lat;
+            array.longitude = res.data.lng;
+            this.setData({
+              markers:this.data.markers.concat(array)
+            })
+            this.data.bikeMarker = [array]
+          }
+        }
+      }).catch(err => {
+        console.log(err)
+      })
+    },
   //获取当前位置
   posiLoca: function () {
     var that = this;
@@ -784,94 +838,72 @@ Page({
     var that = this;
     clearInterval(interval)
     clearInterval(huancheTime)
-    var times = ''; //秒数
-    var minute = Math.round(that.data.minute / 60); //分钟
-    var minute1 = '0'; //分钟
-    var hour = 0; //小时
-    var hour1 = '0'; //小时
-    var time = that.data.minute //获取当前已骑行的秒数
-    var setting = my.getStorageSync({
-      'key': 'setting'
-    }).data;
-
-    if (time > 60) { //秒数大于60 分钟= 秒数/60  秒数=  -1*60  40
-      minute = parseInt(time / 60);
-      times = time - minute * 60;
-      //minute代表分钟  times 代表秒数
-    } else {
-      minute = parseInt(time / 60);
-      times = time;
-    }
+ 
     interval = setInterval(function () {
-      //定时器 秒数一秒加1
-      minute++
-      if (minute < 10 && hour > 0) { //如果分钟小于10 加一个0
-        minute1 = '0' + minute
-      } else {
-        minute1 = minute
-      }
-      if (minute > 59) {
-        //分钟大于59 让小时+1
-        hour = parseInt(minute / 60)
-        minute1 = minute - hour * 60;
-        if (hour < 10) {
-          hour1 = '0' + hour;
-        } else {
-          hour1 = hour
-        }
-      }
-      if (minute1 < 10 && hour > 0) { //如果分钟小于10 加一个0
-        minute1 = '0' + minute1
-      } else {
-        minute1 = minute1
-      }
-      if (hour > 0) {
-        // //如果小时大于0 显示 时分
-        that.setData({
-          times: hour1 + ':' + minute1,
-          isHour: true
-        })
-      } else {
-        // //else 显示 分秒
-        that.setData({
-          times: minute1,
-          isHour: false
-        })
-      }
-      // that.setData({ times: minute1 + ':' + times})
-      //计算钱   分钟除以5*5   判断秒数>30  minute = minute+1
-      //不满12分钟按12分钟算   并且大于30秒   
-      var per_money = setting.per_money;
-      var per_minute = setting.per_minute;
-      // console.log(minute)
-      // console.log(minute1)
-      if (setting.starting_price_time > minute) {
-        that.setData({
-          estimate_money: setting.starting_price
-        })
-      } else {
-
-        //起步价+(分钟数-起步时长)/ 一块钱可骑多少分钟 * 钱数
-        var time = minute - setting.starting_price_time;
-        // console.log('测试1',times)
-        //页面进来时初始化金额
-
-        // let money = Math.round(time / per_minute) * per_money + parseFloat(setting.starting_price)
-        let money = parseInt(time / per_minute) * per_money + parseFloat(setting.starting_price)
-        that.setData({
-          estimate_money: money,
-          onload: true
-        })
-      }
-    }, 60000)
+      that.countBikeMoney()
+    }, 5000)
   },
+//计算骑行费用
+countBikeMoney: function () {
+  var that = this
+  var setting = my.getStorageSync({
+    'key': 'setting'
+  }).data;
+  var total_minute = this.data.minute
+  console.log("this.data.start_use_bike_time",this.data.start_use_bike_time)
+  let cha = (new Date()).getTime() / 1000 - this.data.start_use_bike_time
+  var time = 0
+  var _minute = Math.ceil(cha / 60); //分钟 
+  console.log('骑行总时长分钟', _minute, cha, total_minute, setting.starting_price_time)
+  if (_minute == total_minute) return 0; //分钟相等
+  if (_minute === 0) {
+    time = _minute + 1 - setting.starting_price_time;
+  } else {
+    time = _minute - setting.starting_price_time;
+  }
+  var per_money = setting.per_money;
+  var per_minute = setting.per_minute;
+  // 向上取整
+  let money = 0
+  if (time <= 0) {
+    money = parseFloat(setting.starting_price)
+  } else {
+    money = Math.ceil(time / per_minute) * per_money + parseFloat(setting.starting_price)
+  }
+  //将全部分钟分开为小时+分钟用于显示时间
+  var hour = Math.floor(_minute / 60);
+  var minute = Math.floor(_minute % 60);
+  money = money.toFixed(2)
+  hour = hour < 10 ? '0' + hour : hour
+  minute = minute < 10 && hour > 0 ? '0' + minute : minute
+  if (app.globalData.noShowRefOpenLock == true && that.data.noShowRefOpenLock == false && minute >= 3) {
+    that.setData({
+      noShowRefOpenLock: true
+    })
+  }
+  if (hour > 0) {
+    that.setData({
+      minute: _minute, // 骑行总分钟
+      times: hour + ":" + minute,
+      estimate_money: money,
+      isHour: true
+    })
+  } else {
+    that.setData({
+      minute: _minute,
+      times: minute,
+      estimate_money: money,
+      isHour: false
+    })
+  }
 
+},
   //获取车辆信息
   getBikeMessage: function () {
     my.showLoading()
     var that = this;
     app.request('/bike/' + that.data.code, '', 'GET').then(res => {
-      console.log(res, '车辆信息--------------------')
+
       machineNO = res.data.box_no
       my.hideLoading()
       if (res.status == 200) {
@@ -1037,6 +1069,9 @@ Page({
   //开锁方法
   openBike() {
     var that = this;
+    var setting = my.getStorageSync({
+      'key': 'setting'
+    }).data;
     my.showLoading({
       content: '开锁中...',
       mask: true
@@ -1054,7 +1089,10 @@ Page({
       if (res.status == 200) {
         that.setData({
           steps: 3,
-          order: res.data.no
+          order: res.data.no,
+          ifKnowUseTK: false,
+          estimate_money: parseFloat(setting.starting_price),
+          start_use_bike_time: res.data.start_use_bike_timestamp
         })
         that.terval()
         //蓝牙开锁
@@ -1332,6 +1370,7 @@ Page({
   },
   endUseBike: function () {
     let that = this
+    this.data.TKfuwei = true
     my.showLoading({
       content: '加载中...'
     })
@@ -1351,14 +1390,10 @@ Page({
         let data1 = parseFloat(data)
 
         if (res.data.is_app_check_helmet_status == true && res.data.helmet_status == 1) {
-          my.showModal({
-            title: '提示',
-            content: '头盔未放好!请将头盔放置在头盔卡槽后重新结束用车',
-            confirmText: '我知道了',
-            showCancel: false,
-            complete: (res) => {
-
-            }
+          this.setData({
+            TKtipsProp: true,
+            dispatch_money: data1,
+            money: res.data,
           })
         } else {
           that.setData({
@@ -1368,9 +1403,28 @@ Page({
             parkStatus: 2
           })
         }
+      }else{
+        my.hideLoading()
       }
+    }).catch(res => {
+      my.hideLoading()
+    })
+  },
+   //继续还车
+   continueHuanche: function () {
+    this.data.TKfuwei = false
+    this.setData({
+      chaButton: 1,
+      parkStatus: 2,
+      TKtipsProp: false,
     })
   },
+    //我知道了
+    tkKnow: function () {
+      this.setData({
+        TKtipsProp: false,
+      })
+    },
   //确定结束用车
   sureEndUseBike: util.throttle(function () {
 
@@ -1396,6 +1450,7 @@ Page({
       lat: that.data.latitude,
       lng: that.data.longitude
     }
+    if (this.data.TKfuwei == false) data.forceCloseBike = true
     app.request('/bike/close-lock', data, 'POST').then(res => {
       console.log(res)
       my.hideLoading()
@@ -1512,14 +1567,11 @@ Page({
   },
   //客服
   keFu: function () {
-    console.log('点击联系客服', my.getStorageSync({
-      'key': 'home'
-    }).data.customer_service_phone)
     let phone = my.getStorageSync({
       'key': 'home'
-    }).data.customer_service_phone
+    })
     my.makePhoneCall({
-      number: phone || '13203706613'
+      number: phone.data.customer_service_phone || '13203706613'
     })
   },
   //车辆为未开锁弹框
@@ -1594,10 +1646,54 @@ Page({
     })
   },
   //将地图将当前位置展示在屏幕中央,防止用户滑动查看停车区时频繁定位中心点
-  getPosition: function () {
-    this.setData({
-      centerLon: this.data.longitude,
-      centerLat: this.data.latitude,
+  // getPosition: function () {
+  //   this.setData({
+  //     centerLon: this.data.longitude,
+  //     centerLat: this.data.latitude,
+  //   })
+  //   this.mapCtx.moveToLocation();
+  //   this.bikeLocation('getPosition');
+  // },
+  getPosition:util.throttle(function () {
+    //点击定位  
+    //这是一段注
+    var that = this;
+    my.showLoading({
+      content: '定位中'
     })
-  },
+    my.getLocation({
+      type: 'gcj02',
+      success: (res) => {
+        console.log('经纬度为:+++++++++++++++++++++' + res.latitude + '++++++++' + res.longitude)
+        my.hideLoading()
+        that.setData({
+          centerLon: res.longitude,
+          centerLat: res.latitude
+        })
+        this.bikeLocation('getPosition');
+      },
+      fail: function (err) {
+        console.log(err, '用户授权失败')
+        if (err.error == 11) {
+          my.showAuthGuide({
+            authType: 'LBS',
+            success: (res) => {
+
+            },
+            fail: (error) => {
+              my.alert({
+                content: '获取位置授权失败'
+              });
+            },
+          });
+        }
+        my.hideLoading()
+        my.showToast({
+          content: '定位失败',
+          icon: 'none'
+        })
+      }
+
+    })
+  }, 1000),
 })

+ 2 - 2
utils/cache.js

@@ -1,7 +1,7 @@
 function getCache(key, hour = 4) {
   let k = 'chche:' + key
   let ct = Date.parse(new Date()) / 1000;
-  let ca = my.getStorageSync({ 'key': 'k' }).data
+  let ca = my.getStorageSync({ 'key': k }).data
   if (ca) {
     if ((ct - ca.time) < (hour * 60 * 60)) {
       return ca.value
@@ -14,7 +14,7 @@ function getCache(key, hour = 4) {
 function setCache(key, data = {}, hour = 4) {
   let k = 'chche:' + key
   let ct = Date.parse(new Date()) / 1000;
-  my.setStorageSync({ 'key': 'k', 'data': { 'time': ct, 'value': data } })
+  my.setStorageSync({ 'key': k, 'data': { 'time': ct, 'value': data } })
 }
 
 const CacheKeys = {