浏览代码

ross优化

yuwenjun1997 2 年之前
父节点
当前提交
6ccefec796

+ 8 - 1
apis/index.js

@@ -125,6 +125,12 @@ export default ($axios) => {
       'https://restapi.amap.com/v3/assistant/coordinate/convert' +
         queryStringify(params)
     )
+  const assistantBaidu = (params = {}) =>
+    fetch(
+      'https://api.map.baidu.com/geoconv/v1' +
+        queryStringify(params)
+    )
+
   // 查询授权商品列表
   const fetchProductDetails = (params = {}) =>
     $axios.get('/wx/auth/product/details', { params })
@@ -168,6 +174,7 @@ export default ($axios) => {
     getClubAuthProductList,
     getProductDetails,
     authProducSave,
-    fetchProductDetails
+    fetchProductDetails,
+    assistantBaidu
   }
 }

+ 4 - 4
components/SimpleMapNav/index.vue

@@ -16,16 +16,16 @@
           :size="size"
           :color="color"
           :round="round"
-          @click="$emit('click', 'baidu')"
-          >百度地图</van-button
+          @click="$emit('click', 'tx')"
+          >腾讯地图</van-button
         >
         <van-button
           class="btn"
           :size="size"
           :color="color"
           :round="round"
-          @click="$emit('click', 'tx')"
-          >腾讯地图</van-button
+          @click="$emit('click', 'baidu')"
+          >百度地图</van-button
         >
       </div>
     </van-popup>

+ 3 - 0
nuxt.config.js

@@ -26,6 +26,9 @@ export default {
       {
         src: 'https://webapi.amap.com/maps?v=2.0&key=eae3be059db26dc1f9cae1d1bee9d4cb',
       },
+      {
+        src: 'https://api.map.baidu.com/api?v=2.0&&type=webgl&ak=9kNcqnkFxlS0Kv9jEbDgwG2BAMrD6wPb'
+      }
     ],
   },
 

+ 4 - 1
pages/_template/app/form/components/form-club-device.vue

@@ -37,7 +37,7 @@
               @remove="handleProductImageRemove(formItem, $event)"
             />
           </el-form-item>
-          <el-form-item label="所属品牌:" prop="brandId">
+          <el-form-item label="所属品牌:" prop="brandId" v-if="editPrams">
             <el-select v-model="formItem.brandId" placeholder="请选择品牌">
               <el-option
                 v-for="item in brandList"
@@ -197,6 +197,7 @@ export default {
       formList: [],
       brandList: [],
       deviceList: [],
+      editPrams: true
     }
   },
 
@@ -330,10 +331,12 @@ export default {
         )
         formItem.productImage = deviceInfo.image
         formItem.productImageList = [{ name: '', url: deviceInfo.image }]
+        this.editPrams = false
       } else {
         formItem.productTypeId = ''
         formItem.productImage = ''
         formItem.productImageList = []
+        this.editPrams = true
       }
     },
 

+ 4 - 3
pages/_template/ross/approve/club/detail.vue

@@ -59,7 +59,7 @@
 
 <script>
 import { drawLogo } from '@/utils'
-import { mapNavigate } from '@/utils/map-utils'
+import { convertor, mapNavigate } from '@/utils/map-utils'
 import { mapGetters } from 'vuex'
 export default {
   layout: 'app-ross',
@@ -141,8 +141,9 @@ export default {
     // 导航
     navigation(type) {
       const point = this.clubInfo.lngAndLat.split(',')
-      const lng = point[0]
-      const lat = point[1]
+      let lng = point[0]
+      let lat = point[1]
+
       mapNavigate(
         { lat, lng, title: this.clubInfo.authParty, address: this.address },
         type

+ 5 - 2
pages/_template/ross/approve/device/detail.vue

@@ -23,13 +23,16 @@
             SN码:<span>{{ productInfo.snCode | snCodeRender }}</span>
           </div>
           <div class="row">
-            <span>品牌:{{ productInfo.brandName }}</span><i></i><span>产地:{{ productInfo.productionPlace }}</span>
+            <!-- <span>产地:{{ productInfo.productionPlace }}</span> -->
+            <!-- <span>品牌:{{ productInfo.brandName }}</span><i></i><span>产地:西班牙巴塞罗那</span> -->
+            <span>品牌:RÖS'S</span><i></i><span>产地:西班牙巴塞罗那</span>
           </div>
           <div class="sncode pc">
             SN码:<span>{{ productInfo.snCode | snCodeRender }}</span>
           </div>
           <div class="maker">制造商:{{ productInfo.manufacturer }}</div>
-          <div class="supplier">代理商:{{ productInfo.shopName }}</div>
+          <!-- <div class="supplier">代理商:{{ productInfo.shopName }}</div> -->
+          <div class="supplier">代理商:ACEBELLE生物科技(深圳)有限公司</div>
         </div>
         <div class="auth">
           <div class="auth-icon"></div>

+ 5 - 2
pages/_template/ross/form/components/form-club-device.vue

@@ -37,7 +37,7 @@
               @remove="handleProductImageRemove(formItem, $event)"
             />
           </el-form-item>
-          <el-form-item label="所属品牌:" prop="brandId">
+          <el-form-item label="所属品牌:" prop="brandId" v-if="editPrams">
             <el-select v-model="formItem.brandId" placeholder="请选择品牌">
               <el-option
                 v-for="item in brandList"
@@ -70,7 +70,7 @@
               v-model="formItem.snCode"
             ></el-input>
           </el-form-item>
-          <el-form-item prop="paramList" label="设备参数:">
+          <el-form-item prop="paramList" label="设备参数:" v-if="editPrams">
             <br />
             <div class="device-param-list">
               <span class="add-param" @click="insertParam(formItem)"
@@ -197,6 +197,7 @@ export default {
       formList: [],
       brandList: [],
       deviceList: [],
+      editPrams: true,
     }
   },
 
@@ -330,10 +331,12 @@ export default {
         )
         formItem.productImage = deviceInfo.image
         formItem.productImageList = [{ name: '', url: deviceInfo.image }]
+        this.editPrams = false
       } else {
         formItem.productTypeId = ''
         formItem.productImage = ''
         formItem.productImageList = []
+        this.editPrams = true
       }
     },
 

+ 20 - 50
utils/map-utils.js

@@ -1,49 +1,3 @@
-function mapInit(callback) {
-  function loadScript() {
-    var script = document.createElement('script')
-    script.src =
-      'https://api.map.baidu.com/api?v=1.0&type=webgl&ak=vsIfSztpPmCtmBRfRiIAM57hbxBQbmgQ&callback=initMapApi'
-    document.body.appendChild(script)
-  }
-  if (!window.BMapGL) {
-    window.initMapApi = callback
-    loadScript()
-  } else {
-    callback()
-  }
-}
-
-// 定位当前位置
-export function loactionSelf() {
-  return new Promise((resolve, reject) => {
-    mapInit(() => {
-      const BMapGL = window.BMapGL
-      const geolocation = new BMapGL.Geolocation({
-        // 是否使用高精度定位,默认:true
-        enableHighAccuracy: true,
-        // 设置定位超时时间,默认:无穷大
-        timeout: 10000,
-      })
-      // 开启SDK辅助定位
-      geolocation.enableSDKLocation()
-      geolocation.getCurrentPosition(function (r) {
-        // alert(JSON.stringify(r))
-        console.log(r)
-        // console.log(this)
-        if (this.getStatus() === 0) {
-          // alert(JSON.stringify(r))
-          resolve({
-            point: r.point,
-            address: r.address,
-          })
-        } else {
-          reject('failed' + this.getStatus())
-        }
-      })
-    })
-  })
-}
-
 export function geolocation() {
   return new Promise((resolve, reject) => {
     window.AMap.plugin('AMap.Geolocation', () => {
@@ -51,7 +5,7 @@ export function geolocation() {
         // 是否使用高精度定位,默认:true
         enableHighAccuracy: true,
         // 设置定位超时时间,默认:无穷大
-        timeout: 10000
+        timeout: 10000,
       })
 
       geolocation.getCurrentPosition((status, result) => {
@@ -65,14 +19,30 @@ export function geolocation() {
   })
 }
 
+// 高德转百度坐标
+export function convertor(lng, lat) {
+  return new Promise((resolve, reject) => {
+    const convertor = new window.BMapGL.Convertor()
+    // 高德转百度
+    convertor.translate([new window.BMapGL.Point(lng, lat)], 3, 5, (data) => {
+      if (data.status === 0) {
+        resolve(data.points[0])
+      } else {
+        reject()
+      }
+    })
+  })
+}
 
 // 地址导航
-export function mapNavigate(options = {}, origin) {
+export async function mapNavigate(options = {}, origin) {
   console.log(options)
   // 百度
   if (origin === 'baidu') {
+    const point = await convertor(options.lng, options.lat)
+    console.log(point)
     console.log('百度地图')
-    options.locationUrl = `http://api.map.baidu.com/marker?location=${options.lat},${options.lng}&title=${options.title}&content=${options.address}&output=html&src=webapp.baidu.openAPIdemo`
+    options.locationUrl = `http://api.map.baidu.com/marker?location=${point.lat},${point.lng}&title=${options.title}&content=${options.address}&output=html&src=webapp.baidu.openAPIdemo`
   }
   // 腾讯
   if (origin === 'tx') {
@@ -84,7 +54,7 @@ export function mapNavigate(options = {}, origin) {
     console.log('高德地图')
     options.locationUrl = `https://uri.amap.com/marker?position=${options.lng},${options.lat}&name=${options.title}&coordinate=gaode&callnative=0`
   }
-
+  // return
   // window.open(options.locationUrl)
   window.location.href = options.locationUrl
 }