baimeng 9 سال پیش
والد
کامیت
7400c93c3a
4فایلهای تغییر یافته به همراه39 افزوده شده و 0 حذف شده
  1. BIN
      wl/www/img/demo/defaultmap.png
  2. 1 0
      wl/www/js/app.js
  3. 37 0
      wl/www/js/filters/filter.js
  4. 1 0
      wl/www/templates/goods/detail.html

BIN
wl/www/img/demo/defaultmap.png


+ 1 - 0
wl/www/js/app.js

xqd
@@ -40,6 +40,7 @@
          $httpProvider.defaults.headers.common['Authorization'] = 'Bearer ' + token;
      }
      $httpProvider.interceptors.push('myHttpInterceptor');
+     
  }])
 .run(["$ionicPlatform", "$location", "msg", "$rootScope", "$timeout", "$ionicHistory", "userService", "$state", "$http",
     function ($ionicPlatform, $location, msg, $rootScope, $timeout, $ionicHistory, userService, $state, $http) {

+ 37 - 0
wl/www/js/filters/filter.js

xqd
@@ -52,4 +52,41 @@
             return input.replace(',','--');
         };
     });
+    module.filter('mapPic', ["$http", function ($http) {
+        return function (input) {
+
+            if (!input) return "img/demo/defaultmap.png";
+            var arr = input.split(',');
+            var key = '9f832e163baac0a04d437a52dd3e5d29';
+            var keywords = arr[arr.length - 1];
+            
+            var url = 'http://restapi.amap.com/v3/place/text?key=' + key + '&keywords=' + keywords + "&callback=JSON_CALLBACK";
+           
+           // http://restapi.amap.com/v3/staticmap?location=116.481485,39.990464&zoom=10&size=750*300&markers=mid,,A:116.481485,39.990464&key=9f832e163baac0a04d437a52dd3e5d29
+            //$http({
+            //    url: 'http://restapi.amap.com/v3/place/text?key=' + key + '&keywords=' + keywords,
+            //    method: "get",
+            //    withCredentials: true,
+            //    headers: {
+            //        common: { Authorization: undefined },
+            //        'Content-Type': 'application/json; charset=utf-8'
+            //    }
+            //}).then(function (result) {
+            //    debugger;
+            //});
+            var map = '';
+            $http.jsonp(url).success(function (result) {
+                var p = result.pois[0];
+                if (p) {
+                    var l = result.pois[0].location;
+                    map = "http://restapi.amap.com/v3/staticmap?location=" + l + "&zoom=9&size=360*160&markers=mid,,A:" + l + "&key=" + key;
+                    debugger;
+                } else {
+                    map="img/demo/defaultmap.png";
+                }
+           });
+            debugger;
+            return map;
+        };
+    }]);
 })(angular.module('app.filters'));

+ 1 - 0
wl/www/templates/goods/detail.html

xqd
@@ -1,6 +1,7 @@
 <ion-view view-title="货源信息">
     <ion-content>
         <div class="list">
+            <img  ng-src="{{vm.begin_address | mapPic}}"/>
             <div class="list card">
                 <div class="item item-avatar">
                     <img ng-src="{{user.data.avatar | avator}}" />