微信开发笔记

1、token验证。服务器地址:http://***/public/index.php/index/Wechat/index
文件路径:\application\index\controller\Wechat.php

<?php
namespace app\index\controller;

use think\facade\Config;
use think\facade\Request;

class Wechat{
    public function index(){
        $token     = Config::get('wechat.official_account.default.token');    
        $echostr   = 'failure';  
        $timestamp =Request::get('timestamp');          //input('timestamp');//
        $nonce     =Request::get('nonce');              //input('nonce');// 
        $signature = Request::get('signature');         //input('signature');//
       
        $list     = array($token, $timestamp, $nonce);
        $hashcode = sort($list, SORT_STRING) ? sha1(implode('', $list)) : '';
        if($hashcode == $signature) {
            $echostr =input('echostr');
        }
        return $echostr;    // 验证时必须关闭调试模式
    }
}

 

ThinkPHP 笔记

1、查看版本号

\thinkphp\library\think\App.php

2、模板输出

目录结构

index.php 内容

<?php
namespace app\index\controller;

use think\Controller;

class Index extends Controller
{
    public function index(){              
       return $this->fetch();          
    }
}

2.1、模板 比较标签

{lt name="product.total_count" value="$product.min_count"}    
    <div class="ProductCountLow">
        库存不足:{$product.total_count}/{$product.min_count}
    </div>
{/lt}

{egt name="product.total_count" value="$product.min_count"}    
    <div class="ProductCount">
        库存:{$product.total_count}
    </div>
{/egt}

2.2、输出关联对象

public function unit(){
   return $this->belongsTo("CateProductUnitModel")->field("id","name");
}
{$product.unit.name}

 

3、路由

以下路由定义匹配,当访问 http://domain.com/index.php/product时,转到 http://domain.com/index.php/index/Product/index。写链接时别忘了index.php

Route::rule('product','index/Product/index');

4、常量问题

参考:https://blog.csdn.net/yiyuwu7069/article/details/78466400

5、文件上传

 

composer 更新报错:SSL/TLS

在项目下执行一下更新命令时报错:

composer update

[Composer\Exception\NoSslException]
The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl extension, you can disable this error, at your own risk, by setting the ‘disable-tls’ option to true. 

 

=======================

解决方法

进入php.ini 修改配置打开ssl

//将这行代码前的 ; 去掉
extension=php_openssl.dll

 

Devexpress 笔记

GridView显示行号

Private Sub GridView1_CustomDrawRowIndicator(sender As Object, e As DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs) Handles GridView1.CustomDrawRowIndicator
     e.Info.DisplayText = e.RowHandle.ToString()
End Sub

 

调用百度地图接口获取地理位置手机电脑通用

<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>调用百度地图接口获取位置</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
<script src="http://api.map.baidu.com/api?v=1.4" type="text/javascript"></script>
<script>
var x=document.getElementById("demo");
function getLocation(){
    if(navigator.geolocation){
       navigator.geolocation.getCurrentPosition(showPosition);
      }else{
       alert("您的浏览器不支持地理定位");
      }
      
   }
 
function showPosition(position){
    lat=position.coords.latitude;
    lon=position.coords.longitude;
    //var map = new BMap.Map("container");            // 创建Map实例
    var point = new BMap.Point(lon, lat);    // 创建点坐标
    //map.centerAndZoom(point,15);                     // 
    //map.enableScrollWheelZoom(); 
    var gc = new BMap.Geocoder();    
    gc.getLocation(point, function(rs){
       var addComp = rs.addressComponents;
       alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street);
       var local=addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street;
         document.getElementById("local").value=local;  //查找元
      });
   }
</script>
</head>
<body>
<p id="demo">点击这个按钮,获得您的位置:</p>
<button onclick="getLocation()">试一下</button>
<input type="text" id="local"/>
</body>
</html>