tongshanglei 2 years ago
parent
commit
81838e3691

+ 5 - 5
build/webpack.dev.conf.js

@@ -10,7 +10,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
 const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
 const portfinder = require('portfinder')
 
-var https = require('https');
+// var https = require('https');
 var fs = require('fs');
 
 const HOST = process.env.HOST
@@ -44,10 +44,10 @@ const devWebpackConfig = merge(baseWebpackConfig, {
     proxy: config.dev.proxyTable,
     quiet: true, // necessary for FriendlyErrorsPlugin
 
-    https: {
-      key: fs.readFileSync(path.join(__dirname, './cert/privatekey.pem')),
-      cert: fs.readFileSync(path.join(__dirname, './cert/certificate.pem'))
-      },
+    // https: {
+    //   key: fs.readFileSync(path.join(__dirname, './cert/privatekey.pem')),
+    //   cert: fs.readFileSync(path.join(__dirname, './cert/certificate.pem'))
+    //   },
 
     watchOptions: {
       poll: config.dev.poll,

+ 4 - 4
config/index.js

@@ -11,11 +11,11 @@ module.exports = {
     assetsSubDirectory: 'static',
     assetsPublicPath: '/',
     proxyTable: {
-      '/?s=kq_wx_api': {
-        target:'http://wxt.rltest.cn', // 你请求的第三方接口
+      '/?s=wx_api': {
+        target:'http://fdapi.rltest.cn', // 你请求的第三方接口
         changeOrigin:true, // 在本地会创建一个虚拟服务端,然后发送请求的数据,并同时接收请求的数据,这样服务端和服务端进行数据的交互就不会有跨域问题
         pathRewrite:{  // 路径重写,
-          '^/?s=kq_wx_api': ''  // 替换target中的请求地址,也就是说以后你在请求http://api.douban.com/v2/XXXXX这个地址的时候直接写成/api即可。
+          '^/?s=wx_api': ''  // 替换target中的请求地址,也就是说以后你在请求http://api.douban.com/v2/XXXXX这个地址的时候直接写成/api即可。
         }
       }
     },
@@ -24,7 +24,7 @@ module.exports = {
     host: '192.168.1.77', // can be overwritten by process.env.HOST
     port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
     autoOpenBrowser: false,
-    https:true,
+    https:false,
     errorOverlay: true,
     notifyOnErrors: true,
     poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

File diff suppressed because it is too large
+ 31609 - 0
package-lock.json


+ 2 - 2
src/global.js

@@ -1,6 +1,6 @@
-// const BASE_URL = 'https://wxt.rltest.cn/?s=smart_wx_api';
+const BASE_URL = 'http://fdapi.rltest.cn/?s=wx_api';
 // const BASE_URL = '//api.card.jskedejiaoyu.com/?s=smart_wx_api';
-const BASE_URL = 'https://api.wxt.renlianiot.com/?s=smart_wx_api';
+// const BASE_URL = 'https://api.wxt.renlianiot.com/?s=smart_wx_api';
 
  export default{
     BASE_URL

+ 13 - 28
src/main.js

@@ -53,7 +53,6 @@ Vue.config.productionTip = false
 router.beforeEach((to,from,next)=>{
   // console.log('to.....',to);
 
-  console.log(to.name)
   //车牌扫码校验临时
   if(to.name == 'vehicle' || to.name == 'vehicledecode'){
     console.log('ddddddddddddddddd')
@@ -62,7 +61,7 @@ router.beforeEach((to,from,next)=>{
     return
   }
 
-
+  localStorage.setItem('openid', '2222222');
 
 
   let query = to.query || {};
@@ -91,40 +90,26 @@ router.beforeEach((to,from,next)=>{
   } else {
     // 用户,本地保存 userid, userType, deviceType
     let userid = localStorage.getItem('userid');
-    let userType = localStorage.getItem('userType');
-    loginFlag = (openid && userid && userType);
+    // openid =222222;//测试用
 
-    if (to.name === 'first') {
+    loginFlag = (openid && userid );
+    
+  
+    if (to.name === 'login') {
       next();
-    } else if (to.name ==='login' || to.name === 'register' || to.name === 'reset_pwd') {
+    } else if ( to.name === 'register' || to.name === 'reset_pwd') {
 
-      if (userType) {
+      // if (userType) {
         next();
-      } else {
-        next('/');
-      }
+      // } else {
+      //   next('/');
+      // }
 
     } else {
       if (!loginFlag) {
-        next('/first');
+        next('/login');
       } else {
-
-        // Vue.prototype.$http.get("/checkSingleLogin&openid=" + openid + '&userid=' + userid).then(res => {
-          
-        //   if(!res.data.success){
-        //     Vue.prototype.$dialog.toast({
-        //       mes: '账号已在其他设备登录,请重新选择登录!',
-        //       timeout: 2000
-        //   });
-        //     next('/first');
-        //   }else{
-        //     next();
-        //   }
-          
-        // })
-        // .catch(res => {
-        //   console.log(res);
-        // });
+        next();
         
       }
     }

+ 3 - 3
src/pages/kede/common/layout.vue

@@ -5,10 +5,10 @@
             <router-view></router-view>
     </div>
     <van-tabbar route>
-    <van-tabbar-item replace to="/chat" icon="volume">语音</van-tabbar-item>
-    <van-tabbar-item replace to="/alarm" icon="search">告警</van-tabbar-item>
+    <!-- <van-tabbar-item replace to="/chat" icon="volume">语音</van-tabbar-item> -->
+    <!-- <van-tabbar-item replace to="/alarm" icon="search">告警</van-tabbar-item> -->
     <van-tabbar-item replace to="/location" icon="map-marked">位置</van-tabbar-item>
-    <van-tabbar-item replace to="/fence" icon="aim">围栏</van-tabbar-item>
+    <!-- <van-tabbar-item replace to="/fence" icon="aim">围栏</van-tabbar-item> -->
     <van-tabbar-item replace to="/more" icon="more">更多</van-tabbar-item>
     </van-tabbar>  
 </div>

+ 83 - 60
src/pages/kede/devices/bindDevice.vue

@@ -1,63 +1,49 @@
 <template>
     <div class="app-container">
-        <van-nav-bar title="绑定设备" left-text="返回" left-arrow @click-left="$router.go(-1)" />
+        <van-nav-bar title="购买保险" left-text="返回" left-arrow @click-left="$router.go(-1)" />
 
         <div style="padding-top: 100px;"></div>
 
-        <van-form @submit="onSubmit">
+       
             <van-field
-                v-model="device_name"
+                v-model="vehicle_info.license_plate"
                 name="device_name"
-                label="设备名称"
+                label="车牌号"
                 placeholder="请输入设备名称"
+                readonly 
                 clearable
             />
-            <van-field
-                v-model="imei"
-                name="imei"
-                label="设备编号"
-                placeholder="请输入设备编号"
-                clearable
-                required
-                :rules="rules.imei"
-            >
-                <template #right-icon>
-                    <van-icon name="scan" color="#03a9f4" size="30" @click="scanCode" />
-                </template>
-            </van-field>
-
-            <template v-if="userType == 'group' && deviceType == 'badge'">
-                <van-field
-                    v-model="username"
-                    name="username"
-                    label="用户姓名"
-                    placeholder="请输入用户姓名"
-                    clearable
-                    required
+           <van-field
+                readonly
+                clickable
+                name="picker"
+                :value="value"
+                label="选择保险"
+                placeholder="点击选择保险"
+                @click="showPicker = true"
                 />
-
-                <van-field
-                    v-model="user_no"
-                    name="user_no"
-                    label="用户编号"
-                    placeholder="请输入用户编号"
-                    clearable
-                    required
+                <van-popup v-model="showPicker" position="bottom">
+                <van-picker
+                    show-toolbar
+                    :columns="insureColumns"
+                    @confirm="onConfirm"
+                    @cancel="showPicker = false"
                 />
-            </template>
+                </van-popup>
+            <van-submit-bar :price="insurePrice" button-text="提交订单" @submit="onSubmit" />
 
-            <div style="margin: 36px;">
-                <van-button round block type="info" size="small" native-type="submit">绑定</van-button>
-            </div>
+            <!-- <div style="margin: 36px;">
+                <van-button round block type="info" size="small" native-type="submit">购买</van-button>
+            </div> -->
 
-        </van-form>
+       
     </div>
 </template>
 
 <script>
 import Vue from 'vue';
-import wx from 'weixin-js-sdk'
-import { Form,Field,Icon,NavBar,Dialog,Button } from 'vant';
+
+import { Form,Field,Icon,NavBar,Dialog,Button,Popup,Picker,SubmitBar   } from 'vant';
 
 Vue.use(Form);
 Vue.use(Field);
@@ -65,18 +51,36 @@ Vue.use(Icon);
 Vue.use(NavBar);
 Vue.use(Dialog);
 Vue.use(Button);
-
+Vue.use(Popup);
+Vue.use(Picker);
+Vue.use(SubmitBar);
 export default {
     data() {
         return {
             userid: '',
             openid: '',
-            device_name: '',
+             insureColumns: [
+                 {
+                     text:'测试1',
+                     price:20000,
+                     value:'1',
+                 },
+
+                 {
+                     text:'测试2',
+                     price:30000,
+                     value:'2',
+                 }
+             ],
+            showPicker: false,
+            insurePrice:0,
+            value:'',
+            insureId: '',
+            vehicleId:'',
             imei: '',
             username: '',
             user_no: '',
-            userType: '',
-            deviceType: '',
+            vehicle_info: '',
             rules: {
                 imei: [
                     { required: true, message: '请输入设备号' },
@@ -85,39 +89,58 @@ export default {
         }
     },
     created() {
-        this.userType = localStorage.getItem('userType');
-        this.deviceType = localStorage.getItem('deviceType');
+        this.$http.get("/getInsureOptions").then(res => {
+            console.log(res.data.data)
+          if (!res.data.success) {
+            this.$notify(res.data.message || '获取失败');
+            return;
+          }
+
+          this.insureColumns = res.data.data || [];
+
+        }).catch(res => {
+            this.$notify('出错了');
+        });
+        this.vehicle_info=this.$route.query.vehicle_info
+        this.vehicleId=this.vehicle_info.id
+        console.log('buy',this.vehicle_info)
         this.userid = localStorage.getItem('userid');
         this.openid = localStorage.getItem('openid');
     },
     methods: {
+        onConfirm(item) {
+
+            this.insureId = item.value;
+            this.value = item.text;
+            this.insurePrice = item.price;
+            this.showPicker = false;
+        },
         /**
          * 提交
          */
         onSubmit(values) {
             let postData = {
-                device_name: values.device_name,
-                imei: values.imei,
-                userType: this.userType,
-                deviceType: this.deviceType,
+                vehicle_id: this.vehicleId,
+                insure_id: this.insureId,
             }
-
-            if (values.username) {
-                postData.username = values.username;
+            if (!postData.vehicle_id) {
+                this.$notify('订单异常请重新进入');
+                return;
             }
-            if (values.user_no) {
-                postData.user_no = values.user_no;
+            if (!postData.insure_id) {
+                this.$notify('请选择保险');
+                return;
             }
-            // console.log('onsubmit', values);
-            this.$http.post('userBindDevice&userid=' + this.userid + '&openid=' + this.openid, JSON.stringify(postData))
+            console.log('onsubmit', postData);
+            this.$http.post('userByInsure&userid=' + this.userid + '&openid=' + this.openid, JSON.stringify(postData))
                 .then(resp => {
                     if (!resp.data.success) {
-                        this.$notify(resp.data.message || '绑定失败');
+                        this.$notify(resp.data.message || '提交失败');
                         return;
                     }
                     this.$notify({
                         type: 'success',
-                        message: resp.data.message || '绑定成功',
+                        message: resp.data.message || '提交成功',
                     })
                     // 刷新列表
                     this.$router.replace('devices');

+ 53 - 49
src/pages/kede/devices/index.vue

@@ -1,10 +1,10 @@
 <template>
   <div>
-    <van-nav-bar title="我的设备" left-text="返回" left-arrow @click-left="$router.replace('more')" />
+    <van-nav-bar title="我的车辆" left-text="返回" left-arrow @click-left="$router.replace('more')" />
 
     <div v-if="list.length">
       <van-cell-group v-for="item in list" :key="item.id">
-        <van-cell :title="item.device_name" >
+        <van-cell :title="item.device_info.name" >
           <template #icon>
             <div style="padding-right:5px;display: flex;flex-direction: column;align-items: center;">
               <van-image
@@ -23,14 +23,13 @@
             <van-icon name="edit" @click="showUpdateDialog(item)" color="#03a9f4"></van-icon>
           </template>
           <template #label>
-            <p>IMEI:{{item.imei}}</p>
+            <p>IMEI:{{item.device_info.imei}}</p>
           </template>
         </van-cell>
 
-        <van-cell title="定位模式">
-          <template #title>
+        <van-cell title="">
+          <!-- <template #title>
             <div  class="loc-ways">
-            <!-- <span class="custom-title">定位模式</span> -->
             <van-button type="primary" @click="showPopup(item)" size="mini">定位模式</van-button>
               <van-popup v-model="show" :style="{width:'80%'}" @close="close(dev_info)">
                <van-radio-group v-model="dev_info.pos_mode">
@@ -40,7 +39,6 @@
                       <van-radio :name="mode.value"/>
                     </template>
                   </van-cell>
-                  <!-- 允许输入正整数,调起纯数字键盘 -->
                   <van-field 
                     v-model="dev_info.stopped_rtc_invl"
                     type="digit" 
@@ -68,35 +66,40 @@
               </van-radio-group>
               </van-popup>
               <span class="custom-title">{{item.custom_title}}</span>
-            <!-- <van-tag type="primary">WiFi</van-tag>
-            <van-tag type="warning">GPS</van-tag> -->
-            <!-- <van-tag type="success">WiFi+GPS</van-tag> -->
             </div>
-          </template>
+          </template> -->
+
+ 
           <template #default>
-            <span @click="goPage('urgent', {device_id: item.id})" :style="'color:' + (item.urgent_list ? 'blue' : 'red') + ';'">
-              紧急联系人({{item.urgent_list ? item.urgent_list.length : 0}})</span>
-             
-            <span v-if="showBindBtn" @click="showActionSheet(item)" style="color:blue;"> | <b>更多</b></span>
+            <van-button @click="goPage('buyInsure',{vehicle_info:item})" type="primary" size="small">购买保险</van-button>
+            <van-button @click="showActionSheet(item)" type="info" size="small">车辆详情</van-button>
           </template>
         </van-cell>
       </van-cell-group>
     </div>
     <van-empty v-else description="暂无数据" />
 
-    <div v-if="showBindBtn" class="fl-buttomright-button" @click="goPage('bindDevice')"> 绑定 </div>
+    <!-- <div v-if="showBindBtn" class="fl-buttomright-button" @click="goPage('bindDevice')"> 绑定 </div> -->
     
 
     <van-dialog v-model="showDialog" title="修改信息" show-cancel-button @confirm="editName">
       <van-field v-model="device_name" label="设备名称" placeholder="请输入设备名称" />
     </van-dialog>
-
-    <van-action-sheet 
-      v-model="showActions" 
-      :actions="actions" 
-      @select="onSelect" 
-      close-on-click-action
-    />
+    <van-action-sheet v-model="showActions" title="车辆详情">
+      <div class="content">
+          <van-cell-group inset>
+            <van-cell title="车牌号" :value="currentDeviceInfo.license_plate" />
+            <van-cell title="所属部门" :value="currentDeviceInfo.department_name" />
+            <van-cell title="开户时间" :value="currentDeviceInfo.license_time" />
+            <van-cell title="开户员工" :value="currentDeviceInfo.creator" />
+            <van-cell title="设备编号" :value="currentDeviceInfo.device_info.imei" />
+            <van-cell title="定位模式" :value="currentDeviceInfo.device_info.loc_mode" />
+         
+           
+            <!-- <van-cell title="单元格" value="内容" label="描述信息" /> -->
+          </van-cell-group>
+      </div>
+    </van-action-sheet>
   </div>
 </template>
 
@@ -128,7 +131,9 @@ export default {
       list: [],
       showActions: false,
       showDialog: false, // 显示修改设备名称dialog
-      currentDeviceInfo: {}, // 当前设备信息
+      currentDeviceInfo: {
+        device_info:{},
+      }, // 当前设备信息
       device_name: '', // 设备名称
       userid: null,
       openid: null,
@@ -144,7 +149,7 @@ export default {
         } */
         ],
       show: false,
-      setTimeShow:false,
+
       // custom_title:'定位模式',
       // pos_mode: '',
       // stopped_rtc_invl:'',
@@ -195,12 +200,12 @@ export default {
      */
     showUpdateDialog(info) {
       this.showDialog = true;
-      this.device_name = info.device_name;
+      this.device_name = info.device_info.name;
       this.currentDeviceInfo = info;
     },
      showPopup(info) {
       //  console.log(info);
-        this.dev_info = info
+        this.dev_info = info.device_info
         this.show = true;
         let mode_config = JSON.parse(localStorage.getItem('mode_config_'+this.dev_info.imei));
         if(mode_config){
@@ -369,8 +374,7 @@ export default {
      */
     getList() {
 
-      this.$http
-        .get("/getMyDevices&userid=" + this.userid + '&openid=' + this.openid)
+      this.$http.get("/getMyDevices&userid=" + this.userid + '&openid=' + this.openid)
         .then(res => {
           if (!res.data.success) {
             this.$notify(res.data.message || '获取失败');
@@ -378,26 +382,25 @@ export default {
           }
 
           this.list = res.data.data || [];
-          Object.keys(this.list).forEach(key => {
-            console.log(this.list[key].imei);
-            let mode_config = JSON.parse(localStorage.getItem('mode_config_'+this.list[key].imei))
-            // console.log(mode_config.value,'aaaa');
-            if(mode_config){
-            this.list[key].pos_mode = mode_config.value
-            this.list[key].custom_title = mode_config.text
-             if(mode_config.value == '2'){
-                if(mode_config.stopped_rtc_invl != 'undefind'){
-                   this.list[key].stopped_rtc_invl = mode_config.stopped_rtc_invl
-                }
-                if(mode_config.stopped_rpt_invl != 'undefind'){
-                    this.list[key].stopped_rpt_invl = mode_config.stopped_rpt_invl
-                }
-                this.list[key].setTimeShow = true
-             }else{
-               this.list[key].setTimeShow = false
-             }
-            }
-          })
+          // Object.keys(this.list).forEach(key => {
+         
+          //   let mode_config = JSON.parse(localStorage.getItem('mode_config_'+this.list[key].device_info.imei))
+          //   if(mode_config){
+          //   this.list[key].pos_mode = mode_config.value
+          //   this.list[key].custom_title = mode_config.text
+          //    if(mode_config.value == '2'){
+          //       if(mode_config.stopped_rtc_invl != 'undefind'){
+          //          this.list[key].stopped_rtc_invl = mode_config.stopped_rtc_invl
+          //       }
+          //       if(mode_config.stopped_rpt_invl != 'undefind'){
+          //           this.list[key].stopped_rpt_invl = mode_config.stopped_rpt_invl
+          //       }
+          //       this.list[key].setTimeShow = true
+          //    }else{
+          //      this.list[key].setTimeShow = false
+          //    }
+          //   }
+          // })
           // console.log(this.list);
         })
         .catch(res => {
@@ -443,6 +446,7 @@ export default {
     showActionSheet(info) {
       this.showActions = true;
       this.currentDeviceInfo = info;
+      console.log(this.currentDeviceInfo)
     },
     // 选中action
     onSelect(item) {

+ 0 - 262
src/pages/kede/devices/urgent/addEdit.vue

@@ -1,262 +0,0 @@
-<template>
-  <div>
-    <van-nav-bar title="紧急联系人" left-text="返回" left-arrow @click-left="$router.back()" />
-
-    <van-form @submit="onSubmit">
-      
-      <!-- 设备 -->
-      <van-field
-        readonly
-        clickable
-        name="device_id"
-        :value="deviceName"
-        label="设备名称"
-        placeholder="点击选择"
-        @click="showDevicePicker = true"
-      />
-      <van-popup v-model="showDevicePicker" position="top">
-        <van-picker
-          show-toolbar
-          value-key="device_name"
-          :columns="deviceColumns"
-          @confirm="onConfirmDevice"
-          @cancel="showDevicePicker = false"
-        />
-      </van-popup>
-
-      <!-- 姓名 -->
-      <van-field
-        v-model="name"
-        name="name"
-        label="联系人姓名"
-        placeholder="请输入联系人姓名"
-        clearable
-        :rules="[{ required: true, message: '请输入紧急联系人姓名' }]"
-      />
-      <!-- 电话 -->
-      <van-field
-        v-model="phone"
-        type="number"
-        maxlength="11"
-        show-word-limit
-        name="phone"
-        label="联系人号码"
-        clearable
-        placeholder="请输入联系人手机号码"
-        :rules="[{ required: true, pattern: new RegExp(/[0-9]{11}/), message: '请输入11位的紧急联系人手机号码' }]"
-      />
-      <!-- 社会关系 -->
-      <van-field
-        readonly
-        clickable
-        name="relationship"
-        :value="relationshipText"
-        label="社会关系"
-        placeholder="点击选择"
-        @click="showRelationshipPicker = true"
-      />
-      <van-popup v-model="showRelationshipPicker" position="bottom">
-        <van-picker
-          show-toolbar
-          value-key="text"
-          :columns="relationshipColumns"
-          @confirm="onConfirmRelationship"
-          @cancel="showRelationshipPicker = false"
-        />
-      </van-popup>
-
-      <div style="margin: 16px">
-        <van-button class="form-btn" round block type="info" size="small" native-type="submit">提交</van-button>
-      </div>
-      <div style="margin: 16px">
-        <van-button class="form-btn" round block type="danger" size="small" native-type="button" v-if="urgentId" @click="onDelete">删除</van-button>
-      </div>
-    </van-form>
-  </div>
-</template>
-<script>
-import Vue from "vue";
-import "vant/lib/index.css";
-import { Form, Field, Picker, Popup, Notify, NavBar, Dialog, Button } from "vant";
-
-Vue.use(Form);
-Vue.use(Button);
-Vue.use(Field);
-Vue.use(Picker);
-Vue.use(Popup);
-Vue.use(Notify);
-Vue.use(NavBar);
-Vue.use(Dialog);
-
-export default {
-  data() {
-    return {
-      action: '添加',
-      name: '',
-      phone: '',
-      relationship: '',
-      relationshipText: '',
-      relationshipColumns: [],
-      showRelationshipPicker: false,
-      device_id: null,
-      urgentId: null,
-      userid: null,
-      // 设备
-      showDevicePicker: false,
-      deviceName: '',
-      deviceColumns: [],
-    };
-  },
-  created() {
-
-    this.userid = localStorage.getItem("userid");
-    this.openid = localStorage.getItem("openid");
-    this.device_id = this.$route.query.device_id;
-    this.urgentId = this.$route.query.id;
-    
-    // 社会关系
-    this.getRelationshipData();
-    this.getDeviceList();
-
-    this.$nextTick(() => {
-      // 修改操作
-      if (this.urgentId) {
-          this.action = '修改';
-          this.getUrgentData(this.urgentId);
-      }
-    })
-  },
-  watch: {
-    relationshipColumns(val) {
-      if (!this.relationship) {
-        return;
-      }
-      val.forEach(item => {
-        if (item.id == this.relationship) {
-          this.relationshipText = item.text
-        }
-      })
-    },
-  },
-  methods: {
-    goBack() {
-      this.$router.back()
-    },
-    // 获取联系人数据
-    getUrgentData(id) {
-      this.$http
-          .get('getUrgentById&userid=' + this.userid + '&openid=' + this.openid + '&id=' + id)
-          .then(resp => {
-            if (resp.status === 200 && resp.data && resp.data.success) {
-              let urgentInfo = resp.data.data || {}
-              if (urgentInfo.id) {
-                this.name = urgentInfo.name
-                this.phone = urgentInfo.phone
-                this.relationship = urgentInfo.relationship
-              }
-            }
-          })
-    },
-    // 获取关系数据
-    getRelationshipData() {
-      this.$http
-          .get('getRelationshipList')
-          .then(resp => {
-            if (resp.status === 200 && resp.data && resp.data.success) {
-              this.relationshipColumns = resp.data.data || []
-            }
-          })
-    },
-    onConfirmRelationship(obj) {
-      this.relationship = obj.id;
-      this.relationshipText = obj.text;
-      this.showRelationshipPicker = false;
-    },
-    onSubmit(vals) {
-      let data = {
-        name: this.name,
-        phone: this.phone,
-        relationship: this.relationship,
-        device_id: this.device_id,
-        userid: this.userid,
-      };
-      if (this.urgentId) {
-        data.id = this.urgentId;
-      }
-      this.$http
-        .post("/addEditUrgent", JSON.stringify(data))
-        .then((res) => {
-          let resp = res.data;
-          if (!resp.success) {
-            this.$dialog.toast({
-              mes: resp.message,
-            });
-            return;
-          }
-
-          Notify({ type: "success", message: resp.message });
-          this.$router.back();
-        })
-        .catch((res) => {
-          console.log(res);
-        });
-    },
-    onDelete() {
-      if (!this.userid || !this.urgentId || !this.device_id) {
-        return;
-      }
-      Dialog.confirm({
-        title: '删除联系人',
-        message: '确定要删除该紧急联系人吗?'
-      })
-      .then(resp => {
-        this.$http.get('deleteUrgent&userid='+ this.userid + '&device_id=' + this.device_id +'&id=' + this.urgentId)
-                  .then(resp => {
-                    if (resp.status === 200 && resp.data && resp.data.success) {
-                      Notify({ type: "success", message: resp.data.message });
-                      this.$router.back();
-                    } else {
-                      Notify({ message: resp.data.message });
-                    }
-                  })
-      })
-      .catch(()=>{})
-
-    },
-    /**
-     * 选择设备
-     */
-    onConfirmDevice(obj) {
-      this.device_id = obj.id;
-      this.deviceName = obj.device_name;
-      this.showDevicePicker = false;
-    },
-    /**
-     * 获取设备列表
-     */
-    getDeviceList() {
-
-      this.$http
-        .get("/getMyDevices&userid=" + this.userid + '&openid=' + this.openid)
-        .then(res => {
-          this.deviceColumns = res.data.data || [];
-          // 设备id存在,默认选中
-          if (this.device_id) {
-            this.deviceColumns.forEach(item => {
-              if (item.id == this.device_id) {
-                this.deviceName = item.device_name
-              }
-            })
-          }
-
-        })
-        .catch(res => {
-        });
-    },
-    
-  },
-};
-</script>
-<style scoped="less" >
-
-</style>

+ 0 - 85
src/pages/kede/devices/urgent/index.vue

@@ -1,85 +0,0 @@
-<template>
-  <div>
-    <van-nav-bar title="紧急联系人" left-text="返回" left-arrow @click-left="$router.back()" />
-    <!-- 添加联系人 -->
-    <van-contact-card type="add" add-text="添加紧急联系人" @click="onAdd" />
-
-    <template v-for="device in list"> 
-      <van-cell-group :title="device.device_name" :key="device.id">
-        
-        <template v-if="device.urgent_list && device.urgent_list.length">
-          <van-contact-card
-            v-for="urgent in device.urgent_list"
-            :key="urgent.id"
-            type="edit"
-            :name="urgent.name"
-            :tel="urgent.phone"
-            @click="onEdit(urgent)"
-          />
-        </template>
-        <div v-else>
-          <van-button type="default" block disabled>暂无联系人</van-button>
-        </div>
-
-      </van-cell-group>
-    </template>
-
-  </div>
-</template>
-
-<script type="text/babel">
-import Vue from "vue";
-import { ContactCard, NavBar, CellGroup, Cell, Button } from "vant";
-
-Vue.use(ContactCard);
-Vue.use(NavBar);
-Vue.use(CellGroup);
-Vue.use(Cell);
-Vue.use(Button);
-
-export default {
-  data() {
-    return {
-      list: [],
-      userid: null,
-      openid: null,
-      device_id: null,
-    };
-  },
-  created() {
-    this.userid = localStorage.getItem("userid");
-    this.openid = localStorage.getItem("openid");
-
-    this.device_id = this.$route.query.device_id
-
-    this.getUrgentList();
-  },
-  methods: {
-    // 添加
-    onAdd() {
-      this.$router.push({ path: "/add_edit_urgent?device_id=" + (this.device_id || '')});
-    },
-    // 修改
-    onEdit(urgent) {
-      this.$router.push({ path: "/add_edit_urgent?device_id=" + urgent.device_id + "&id=" + urgent.id});
-    },
-    // 获取联系人
-    getUrgentList() {
-      this.$http
-        .get("/getUrgentList&userid=" + this.userid + '&openid=' + this.openid + '&device_id=' + (this.device_id || ''))
-        .then((res) => {
-          this.list = res.data.data;
-        })
-        .catch((res) => {
-        });
-    },
-    goBack() {
-      this.$router.back()
-    },
-
-  },
-};
-</script>
-<style scoped="less">
-
-</style>

+ 421 - 0
src/pages/kede/insure/index.vue

@@ -0,0 +1,421 @@
+<template>
+  <div>
+    <van-nav-bar title="我的保险" left-text="返回" left-arrow @click-left="$router.replace('more')" />
+
+    <div v-if="list.length">
+      <van-cell-group v-for="item in list" :key="item.id">
+        <van-cell :title="item.insure_info.name" >
+         
+
+          <template #label>
+            <van-tag v-if="item.insure_state==0" type="success">{{item.insure_state_text}}</van-tag>
+            <van-tag v-else-if="item.insure_state==1" type="primary">{{item.insure_state_text}}</van-tag>
+            <van-tag v-else-if="item.insure_state==2" type="warning">{{item.insure_state_text}}</van-tag>
+            <p>生效时间:{{item.start_at}}</p>
+            <p>失效时间:{{item.end_at}}</p>
+          </template>
+          <van-cell title="">
+            <template #default>
+              <van-button @click="showActionSheet(item)" class="detail_btn" type="info" size="small">保单详情</van-button>
+            </template>
+          </van-cell>
+        </van-cell>
+        
+       
+      </van-cell-group>
+    </div>
+    <van-empty v-else description="暂无数据" />
+
+    <!-- <div v-if="showBindBtn" class="fl-buttomright-button" @click="goPage('buyInsuer')"> 购买 </div> -->
+    
+
+    <van-dialog v-model="showDialog" title="修改信息" show-cancel-button @confirm="editName">
+      <van-field v-model="device_name" label="设备名称" placeholder="请输入设备名称" />
+    </van-dialog>
+    <van-action-sheet v-model="showActions" title="保险详情">
+      <div class="content">
+          <van-cell-group inset>
+            <van-cell title="保险名称" :value="currentInfo.insure_info.name" />
+            <van-cell title="保险价格" :value="currentInfo.insure_info.price" />
+            <van-cell title="参保车辆" :value="currentInfo.vehicle_info.license_plate" />
+            <van-cell title="生效时间" :value="currentInfo.start_at" />
+            <van-cell title="失效时间" :value="currentInfo.end_at" />
+          
+         
+           
+            <!-- <van-cell title="单元格" value="内容" label="描述信息" /> -->
+          </van-cell-group>
+      </div>
+    </van-action-sheet>
+  </div>
+</template>
+
+<script type="text/babel">
+import Vue from 'vue';
+import { ActionSheet,Image as VanImage, Notify, NavBar, Tag, Icon, Dialog,Empty, CellGroup, Cell, Field ,Uploader,Popup,Button,RadioGroup, Radio,Toast} from 'vant';
+
+Vue.use(ActionSheet);
+Vue.use(NavBar);
+Vue.use(Tag);
+Vue.use(Icon);
+Vue.use(Dialog);
+Vue.use(Notify);
+Vue.use(Empty);
+Vue.use(CellGroup);
+Vue.use(Cell);
+Vue.use(Field);
+Vue.use(Uploader);
+Vue.use(VanImage);
+Vue.use(Popup);
+Vue.use(Button);
+Vue.use(Radio);
+Vue.use(RadioGroup);
+Vue.use(Toast);
+export default {
+  data() {
+    return {
+      showBindBtn: true,
+      list: [],
+      showActions: false,
+      showDialog: false, // 显示修改设备名称dialog
+      currentInfo: {
+        insure_info:{},
+        vehicle_info:{},
+      }, // 当前设备信息
+      device_name: '', // 设备名称
+      userid: null,
+      openid: null,
+      default_avatar: '/static/avatar_default.png',
+      deviceAvatar: '',
+      actions: [{ 
+          name: '解除绑定', 
+          action: 'unbind',
+        },
+        /* { 
+          name: '补卡',
+          action: 'makeupCard',
+        } */
+        ],
+      show: false,
+
+      // custom_title:'定位模式',
+      // pos_mode: '',
+      // stopped_rtc_invl:'',
+      // stopped_rpt_invl:'',
+      dev_info:{},
+      modes:[
+        {
+          value:'0',
+          text:'常规模式'
+        },
+          {
+          value:'1',
+          text:'追踪模式'
+        },
+          {
+          value:'2',
+          text:'定时模式'
+        }
+      ],
+    };
+  },
+  created() {
+    this.userid = localStorage.getItem("userid");
+    this.openid = localStorage.getItem("openid");
+    this.userType = localStorage.getItem('userType');
+    this.deviceType = localStorage.getItem('deviceType');
+
+    // if (this.userType == 'group' && this.deviceType == 'card') {
+    //     this.showBindBtn = false;
+    // }
+    //  let mode_config = JSON.parse(localStorage.getItem('mode_config_*'));
+    //  console.log(mode_config);
+    //      this.custom_title = mode_config.text
+    //      if(mode_config.value == '2'){
+    //        if(mode_config.stopped_rtc_invl != 'undefind'){
+    //           this.stopped_rtc_invl = mode_config.stopped_rtc_invl
+    //        }
+    //        if(mode_config.stopped_rpt_invl != 'undefind'){
+    //           this.stopped_rpt_invl = mode_config.stopped_rpt_invl
+    //        }
+    //        this.setTimeShow = true
+    //      }
+    this.getList();
+  },
+  methods: {
+    /**
+     * 显示修改设备dialog
+     */
+    showUpdateDialog(info) {
+      this.showDialog = true;
+      this.device_name = info.device_info.name;
+      this.currentInfo = info;
+    },
+     showPopup(info) {
+      //  console.log(info);
+        this.dev_info = info.device_info
+        this.show = true;
+        let mode_config = JSON.parse(localStorage.getItem('mode_config_'+this.dev_info.imei));
+        if(mode_config){
+          this.dev_info.pos_mode = mode_config.value
+          this.dev_info.custom_title = mode_config.text
+          if(mode_config.value == '2'){
+              if(mode_config.stopped_rtc_invl != 'undefind'){
+                this.dev_info.stopped_rtc_invl = mode_config.stopped_rtc_invl
+              }
+              if(mode_config.stopped_rpt_invl != 'undefind'){
+                this.dev_info.stopped_rpt_invl = mode_config.stopped_rpt_invl
+              }
+              this.setTimeShow = true
+          }
+        }
+    },
+    close(info){
+      let config = JSON.parse(localStorage.getItem('mode_config_' + info.imei))
+      if(config){
+        if(info.pos_mode != config.value){
+          this.dev_info.pos_mode = config.value
+          this.dev_info.custom_title = config.text
+        }
+      }
+      this.setTimeShow = false
+    },
+    choice_mode(mode){
+        this.dev_info.pos_mode = mode.value
+        this.dev_info.custom_title = mode.text
+        console.log(mode);
+        if(mode.value == '2'){//定时模式
+          this.setTimeShow = true
+        }else{
+          //下发配置
+          
+          let data = {
+            id:this.dev_info.id,
+            imei:this.dev_info.imei,
+            pos_mode:this.dev_info.pos_mode
+          }
+          if(this.sendMode(data)){
+             //关闭弹窗
+            this.show = false
+          }
+          
+          this.dev_info.setTimeShow = false
+          localStorage.setItem('mode_config_'+this.dev_info.imei, JSON.stringify(mode));
+        }
+        
+    },
+    confirmSet(info){
+      // console.log(info);
+      if(!info.stopped_rtc_invl){
+        Toast.fail('采样间隔不能为空');
+        return
+      }
+      if(info.stopped_rtc_invl<300){
+        Toast.fail('采样间隔不能小于300秒');
+        return
+      }
+      if(!info.stopped_rpt_invl){
+        Toast.fail('上报间隔不能为空');
+        return
+      }
+       if(info.stopped_rpt_invl<300){
+        Toast.fail('上报间隔不能小于300秒');
+        return
+      }
+       //下发配置
+      let data = {
+        id:info.id,
+        imei:info.imei,
+        pos_mode:info.pos_mode,
+        stopped_rpt_invl:info.stopped_rpt_invl,
+        stopped_rtc_invl:info.stopped_rtc_invl
+      }
+      if(this.sendMode(data)){
+       //关闭弹窗
+       this.show = false
+      }
+      let mode_config = {
+         value:'2',
+         text:'定时模式',
+         stopped_rtc_invl:info.stopped_rtc_invl,
+         stopped_rpt_invl:info.stopped_rpt_invl
+       }
+       localStorage.setItem('mode_config_'+this.dev_info.imei, JSON.stringify(mode_config));
+    },
+    sendMode(params){
+      return this.$http.post('setLocModel&userid=' + this.userid + '&openid=' + this.openid, JSON.stringify(params))
+          .then(resp => {
+            if (!resp.data.success) {
+              this.$notify(resp.data.message || '切换失败');
+              return false
+            }
+            this.$notify({
+              type: 'success',
+              message: resp.data.message || '切换成功',
+            })
+            return true
+          })
+    },
+    /**
+     * 修改设备名称
+     */
+    editName() {
+      let device_name = this.device_name.trim();
+      if (device_name === '') {
+        this.$notify('设备名称不能为空')
+        return;
+      }
+      
+      let postData = {
+        device_id: this.currentInfo.id,
+        device_name: device_name,
+      }
+      this.$http.post('updateDeviceInfo&userid=' + this.userid + '&openid=' + this.openid, JSON.stringify(postData))
+          .then(resp => {
+            if (!resp.data.success) {
+              this.$notify(resp.data.message || '修改失败');
+              return;
+            }
+            this.$notify({
+              type: 'success',
+              message: resp.data.message || '修改成功',
+            })
+
+            this.getList();
+          })
+    },
+    /**
+     * 解绑之前
+     */
+    beforeUnbindDevice(info) {
+      Dialog.confirm({
+        title: '提醒',
+        message: '确定要解绑设备吗?',
+      })
+      .then(resp => {
+        this.unbindDevice(info);
+      }).catch(()=>{})
+    },
+    /**
+     * 解绑设备
+     */
+    unbindDevice(info) {
+      let postData = {
+        device_id: info.id,
+      }
+      this.$http.post('userUnbindDevice&userid=' + this.userid + '&openid=' + this.openid, JSON.stringify(postData))
+          .then(resp => {
+            if (!resp.data.success) {
+              this.$notify(resp.data.message || '解绑失败');
+              return;
+            }
+            this.$notify({
+              type: 'success',
+              message: resp.data.message || '解绑成功',
+            })
+
+            this.getList();
+          })
+    },
+    /**
+     * 获取设备列表
+     */
+    getList() {
+
+      this.$http.get("/getMyInsureList&userid=" + this.userid + '&openid=' + this.openid)
+        .then(res => {
+          if (!res.data.success) {
+            this.$notify(res.data.message || '获取失败');
+            return;
+          }
+
+          this.list = res.data.data || [];
+
+        })
+        .catch(res => {
+            this.$notify('出错了');
+        });
+    },
+    /**
+     * 跳转绑定设备页面
+     */
+    goPage(name, query = {}){
+      this.$router.push({name: name, query: query});
+    },
+
+    afterRead(imei){
+
+        return file =>{
+        
+          let that= this;
+          console.log(file)
+          console.log(imei)
+          let postData = {
+              imei: imei,
+              avatar64content: file.content
+          }
+          that.$http({
+              method: "post",
+              url: "/saveDeviceAvatar",
+              data: JSON.stringify(postData) ,
+              })
+          .then(({ data }) => {
+              that.getList()
+              console.log(data, 'save res');
+          });
+        }
+
+    },
+    onOversize(file){
+        Dialog({ message: "头像勿超过500KB"});
+    },
+    /**
+     * 显示选项
+     */
+    showActionSheet(info) {
+      this.showActions = true;
+      this.currentInfo = info;
+      console.log(this.currentInfo)
+    },
+    // 选中action
+    onSelect(item) {
+      let action = item.action
+
+      if (action == 'unbind') { // 解绑
+        this.beforeUnbindDevice(this.currentInfo);
+      }
+      
+    },
+  }
+};
+</script>
+<style scoped="less">
+.fl-buttomright-button{
+  position: fixed;
+  bottom: 24px;
+  right: 16px;
+  display: flex;
+  flex-direction: column;
+  border-radius: 50%;
+  height: 54px;
+  width: 54px;
+  background-color: #2196f3;
+  box-shadow:0 0 6px gray ;
+  font-size: 14px;
+  justify-content: center;
+  align-items: center;
+  color: white;
+  padding: 12px;
+}
+.loc-ways{
+  display:flex;
+}
+.custom-title{
+  margin-left:10px;
+  color:#06a2edfc;
+  font-size: 12px;
+}
+.detail_btn {
+  margin-top:20px;
+}
+</style>

+ 17 - 20
src/pages/kede/login/login.vue

@@ -88,29 +88,28 @@ export default {
         let userType = localStorage.getItem('userType');
         let deviceType = localStorage.getItem('deviceType');
 
-        if (!userType && !deviceType) {
-            Dialog.confirm({
-                title: '提醒',
-                message: '未选择用户类型,前往选择。',
-                showCancelButton: false,
-            })
-            .then(() => {
-                this.$router.replace('first')
-            })
-            .catch(() => {
-                console.log('canc');
-            })
-        }
+        // if (!userType && !deviceType) {
+        //     Dialog.confirm({
+        //         title: '提醒',
+        //         message: '未选择用户类型,前往选择。',
+        //         showCancelButton: false,
+        //     })
+        //     .then(() => {
+        //         this.$router.replace('first')
+        //     })
+        //     .catch(() => {
+        //         console.log('canc');
+        //     })
+        // }
     },
     methods: {
         /**
          * 登录
          */
         onSubmit(values) {
-            let userType = localStorage.getItem('userType');
-            let deviceType = localStorage.getItem('deviceType');
-             let openid ='2222222';
-            // let openid = this.getOpenid();
+
+            //  let openid ='2222222';//测试用
+            let openid = this.getOpenid();
             
             // if (!openid) {
             //     Dialog.confirm({
@@ -124,8 +123,6 @@ export default {
             let postData = {
                 username: values.username,
                 password: values.password,
-                userType: userType,
-                deviceType: deviceType,
             }
             this.$http.post('login&openid='+openid, JSON.stringify(postData))
                 .then(resp => {
@@ -149,7 +146,7 @@ export default {
                         message: resp.data.message || '登录成功',
                     });
                     // 跳转首页
-                    this.$router.push('/');
+                    this.$router.push('/location');
                 }).catch(err =>{
                     console.error(err);
                 })

+ 11 - 36
src/pages/kede/more.vue

@@ -48,54 +48,26 @@
                 <van-cell-group >
                     <van-cell is-link icon="bell" to="devices">
                         <template #title>
-                            <span class="custom-title">我的设备</span>
+                            <span class="custom-title">我的车辆</span>
                             <!-- <van-tag type="danger">标签</van-tag> -->
                         </template>
                     </van-cell>
-                    <van-cell is-link icon="new" to="/news">
+                    <van-cell is-link icon="friends" to="insure">
                         <template #title>
-                            <span class="custom-title">新闻动态</span>
-                            <!-- <van-tag type="danger">标签</van-tag> -->
-                        </template>
-                    </van-cell>
-                    <van-cell is-link icon="friends" to="activities" v-if="userType != 'personal'">
-                        <template #title>
-                            <span class="custom-title">研学活动</span>
-                            <!-- <van-tag type="danger">标签</van-tag> -->
-                        </template>
-                    </van-cell>
-                </van-cell-group>
-
-                <div class="padding-top-20"></div>
-
-                <van-cell-group >
-                    <van-cell is-link icon="live" to="courses" v-if="userType != 'personal'">
-                        <template #title>
-                            <span class="custom-title">研学课程</span>
+                            <span class="custom-title">我的保险</span>
                             <!-- <van-tag type="danger">标签</van-tag> -->
                         </template>
                     </van-cell>
-                    <van-cell is-link icon="manager" to="/urgent">
+                    <!-- <van-cell is-link icon="new" to="/news">
                         <template #title>
-                            <span class="custom-title">紧急联系人</span>
-                            <!-- <van-tag type="danger">标签</van-tag> -->
-                        </template>
-                    </van-cell>
-                    <van-cell is-link icon="warning" to="alarm">
-                        <template #title>
-                            <span class="custom-title">告警消息</span>
-                            <!-- <van-tag type="danger">标签</van-tag> -->
+                            <span class="custom-title">新闻动态</span>
                         </template>
                     </van-cell>
-                    <van-cell is-link icon="bell" to="alarm_records">
+                    <van-cell is-link icon="friends" to="activities" v-if="userType != 'personal'">
                         <template #title>
-                            <span class="custom-title">告警处理</span>
+                            <span class="custom-title">研学活动</span>
                         </template>
-                    </van-cell>
-                </van-cell-group>
-                
-                <div class="padding-top-20"></div>
-                <van-cell-group >
+                    </van-cell> -->
                     <van-cell is-link icon="info">
                         <template #title>
                             <span class="custom-title">关于</span>
@@ -104,6 +76,9 @@
                 </van-cell-group>
 
                 
+                
+              
+                
                 <div style="margin: 26px;">
                     <van-button  block round type="danger" size="small" @click="logout">退出登录</van-button>
                 </div>

+ 7 - 11
src/router/index.js

@@ -116,20 +116,16 @@ export default new Router({
       component: () => import("@/pages/kede/devices/index"),
     },
     {
-      path: "/bind_device",
-      name:"bindDevice",
-      component: () => import("@/pages/kede/devices/bindDevice.vue"),
+      path: "/insure",
+      name:"insure",
+      component: () => import("@/pages/kede/insure/index"),
     },
     {
-      path: '/add_edit_urgent',
-      name: 'addEditUrgent',
-      component: () => import("@/pages/kede/devices/urgent/addEdit.vue"),
-    },
-    {
-      path: '/urgent',
-      name: 'urgent',
-      component: () => import("@/pages/kede/devices/urgent/index.vue"),
+      path: "/buy_insure",
+      name:"buyInsure",
+      component: () => import("@/pages/kede/devices/buyInsure.vue"),
     },
+    
     {
       path: '/news',
       name: 'news',