Переглянути джерело

wesmiler 更新第5期升级

wesmiler 5 роки тому
батько
коміт
3b5541e873

+ 8 - 8
app/weixin/model/Member.php

@@ -493,14 +493,14 @@ class Member extends Model
                     POW(
                         SIN(
                             (
-                                {$lat} * PI() / 180 - `m.lat` * PI() / 180
+                                {$lat} * PI() / 180 - m.`lat` * PI() / 180
                             ) / 2
                         ),
                         2
-                    ) + COS({$lat} * PI() / 180) * COS(`m.lat` * PI() / 180) * POW(
+                    ) + COS({$lat} * PI() / 180) * COS(m.`lat` * PI() / 180) * POW(
                         SIN(
                             (
-                                {$lng} * PI() / 180 - `m.lng` * PI() / 180
+                                {$lng} * PI() / 180 - m.`lng` * PI() / 180
                             ) / 2
                         ),
                         2
@@ -616,7 +616,7 @@ class Member extends Model
                 if($item['lat']<=0 || $item['lng']<=0){
                     $item['distance'] = '';
                 }else{
-                    $item['distance'] = $item['distance']>=1000? $item['distance'].'km' : ($item['distance']? $item['distance'] . 'm' : '');
+                    $item['distance'] = $item['distance']>=1000? round($item['distance']/1000, 2).'km' : ($item['distance']? $item['distance'] . 'm' : '');
                 }
 
                 // 地址
@@ -933,14 +933,14 @@ class Member extends Model
                     POW(
                         SIN(
                             (
-                                {$lat} * PI() / 180 - `m.lat` * PI() / 180
+                                {$lat} * PI() / 180 - m.`lat` * PI() / 180
                             ) / 2
                         ),
                         2
-                    ) + COS({$lat} * PI() / 180) * COS(`m.lat` * PI() / 180) * POW(
+                    ) + COS({$lat} * PI() / 180) * COS(m.`lat` * PI() / 180) * POW(
                         SIN(
                             (
-                                {$lng} * PI() / 180 - `m.lng` * PI() / 180
+                                {$lng} * PI() / 180 - m.`lng` * PI() / 180
                             ) / 2
                         ),
                         2
@@ -1007,7 +1007,7 @@ class Member extends Model
                     if($item['lat']<=0 || $item['lng']<=0){
                         $item['distance'] = '';
                     }else{
-                        $item['distance'] = $item['distance']>=1000? $item['distance'].'km' : ($item['distance']? $item['distance'] . 'm' : '');
+                        $item['distance'] = $item['distance']>=1000? round($item['distance']/1000, 2).'km' : ($item['distance']? $item['distance'] . 'm' : '');
                     }
 
                     // 地址

+ 5 - 2
public/themes/default/weixin/match/hearts.html

@@ -24,11 +24,14 @@
                                     <i v-if="item.idcard_check==2 || item.education_check==2 || item.position_check==2" class="auth" @click.stop="showAuth(item)"><img src="/themes/default/weixin/public/assets/img/auth.png" width="28" height="28"></i>
 <!--                                    <i v-if="item.vip_auth" class="vip-auth"><img  src="/themes/default/weixin/public/assets/img/vip-auth.png" width="24" height="24"><span>已认证</span></i>-->
                                 </h1>
+                                <p class="location" v-if="item.distance!=''"><span>距离你 {{item.distance}}{{item.district? '·'+item.district : ''}}</span><span class="pics"><img
+                                        src="/themes/default/weixin/public/assets/img/pic.png">{{item.pic_count}}</span></p>
                                 <p><span v-text="item.birthday_day?item.birthday_day+'|':''"></span><span
                                         v-text="item.height_txt?item.height_txt+'|':''"></span><span
                                         v-text="item.education_txt? item.education_txt+'|':''"></span><span v-text="item.occupation"></span></p>
-                                <p><span v-text="item.city? '现居'+item.city : ''"></span><span v-text="item.home_province? '·'+item.home_province+'人' : ''"></span><span class="pics"><img
-                                        src="/themes/default/weixin/public/assets/img/pic.png">{{item.pic_count}}</span>
+                                <p><span v-text="item.city? '现居'+item.city : ''"></span><span v-text="item.home_province? '·'+item.home_province+'人' : ''"></span>
+                                    <span class="pics" v-if="item.distance==''"><img
+                                            src="/themes/default/weixin/public/assets/img/pic.png">{{item.pic_count}}</span>
                                 </p></div>
                         </div>
                         <div class="desc">

+ 1 - 0
public/themes/default/weixin/match/index.html

@@ -31,6 +31,7 @@
 <!--                                        <i v-if="item.vip_auth" class="vip-auth"><img  src="/themes/default/weixin/public/assets/img/vip-auth.png" width="24" height="24"><span>已认证</span></i>-->
                                         <span class="pics"><img src="/themes/default/weixin/public/assets/img/pic.png">{{item.pic_count}}</span>
                                     </h1>
+                                    <p class="location" v-if="item.distance!=''">距离你 {{item.distance}}{{item.district? '·'+item.district : ''}}</p>
                                     <p><span v-text="item.birthday_day?item.birthday_day+' | ':''"></span><span
                                             v-text="item.height_txt?item.height_txt+' | ':''"></span><span
                                             v-text="item.education_txt? item.education_txt+'|':''"></span><span v-text="item.occupation"></span></p>

+ 33 - 2
public/themes/default/weixin/public/assets/js/hearts.js

@@ -14,6 +14,14 @@ var app = new Vue({
             married: 0,
             pageSize: 12,
             type: 2,
+            lat: '',
+            lng: '',
+        },
+        // 匹配推荐用户参数
+        matchParams: {
+            page: 1,
+            pageSize: 20,
+            type: 2,
         },
         hasFollow: 0,
         // 数据列表
@@ -176,7 +184,7 @@ var app = new Vue({
         // 获取列表数据
         getMatchList: function () {
             var _this = this;
-            $.post('/api/member/getRecommendList', {page: 1, type: 2, pageSize: 20}, function (res) {
+            $.post('/api/member/getRecommendList', _this.matchParams, function (res) {
                 if (res.code == 'success') {
                     _this.matchList = res.data.data
 
@@ -277,11 +285,34 @@ var app = new Vue({
                     timestamp: params.timestamp, // 必填,生成签名的时间戳
                     nonceStr: params.nonceStr, // 必填,生成签名的随机串
                     signature: params.signature,// 必填,签名
-                    jsApiList: ['updateAppMessageShareData','updateTimelineShareData'] // 必填,需要使用的JS接口列表
+                    jsApiList: ['updateAppMessageShareData','updateTimelineShareData','getLocation','openLocation'] // 必填,需要使用的JS接口列表
                 });
 
                 // 初始化处理
                 wx.ready(function () {
+
+                    // 获取定位数据
+                    wx.getLocation({
+                        success: function (res) {
+                            console.log(res)
+                            $.post('/api/member/getLocationAddress',{type: 2,lat: res.latitude,lng: res.longitude},function(res){
+                                if(res.code == 'success'){
+                                    var location = res.data.location;
+                                    var lat = typeof(location.location.lat)!='undefined'? location.location.lat : 0;
+                                    var lng = typeof(location.location.lng)!='undefined'? location.location.lng : 0;
+                                    if(lat && lng){
+                                        _this.matchParams.lng = lng
+                                        _this.matchParams.lat = lat
+                                        _this.getMatchList();
+                                    }
+                                }
+                            },'json');
+                        },
+                        cancel: function (res) {
+                            $.toast('用户拒绝了授权位置信息', 'text');
+                        }
+                    });
+
                     // 好友
                     wx.updateAppMessageShareData({
                         title: '每一位真诚走心的单身,都值得被推荐~', // 分享标题

+ 2 - 1
public/themes/default/weixin/public/assets/js/match.js

@@ -14,6 +14,8 @@ var app = new Vue({
             married: 0,
             pageSize: 50,
             type: 1,
+            lat: '',
+            lng: '',
         },
         hasFollow: 0,
         // 数据列表
@@ -567,7 +569,6 @@ var app = new Vue({
                             console.log(res)
                             $.post('/api/member/getLocationAddress',{type: 2,lat: res.latitude,lng: res.longitude},function(res){
                                 if(res.code == 'success'){
-                                    _this.locations = res.data
                                     var location = res.data.location;
                                     var lat = typeof(location.location.lat)!='undefined'? location.location.lat : 0;
                                     var lng = typeof(location.location.lng)!='undefined'? location.location.lng : 0;