Browse Source

系统用户录入

linwu 2 years ago
parent
commit
7371942496

+ 1 - 0
app/admin/controller/User.php

@@ -785,6 +785,7 @@ class User extends BaseController
         $password = input('password/s');
         if (empty($id)) {
             $data['integral'] = 0;
+            $data['wxampcode'] = '';
             $user = UserModel::create($data);
             $auths = UserAuthsModel::create([
                 'userid'		=> $user->id,

+ 2 - 2
app/mainapp/controller/Comjobs.php

@@ -252,11 +252,11 @@ class Comjobs extends BaseController
         if ($share->isEmpty() || $user->isEmpty() || $comjobs->isEmpty()) {
             page_result(1, "招聘、海报或用户信息不存在");
         }
-        $filename       = $comjobsid . "_" . $userid . "_" . md5(time()) . ".jpg";
+        $filename       = $comjobsid . "_" . $userid . "_post.jpg";
         $dst_comjobspic = root_path("public/attachment/comjobspic") . $filename;
         $url_comjobspic = request()->domain() . "/attachment/comjobspic/" . $filename;
         $wxprogram      = new WxProgram();
-        $comjobspic     = $wxprogram->wxacode_get_unlimited($comjobsid . "&" . $userid, "pages/comjobs/detail", 430, "attachment/comjobspic/" . md5(time()) . ".jpg");
+        $comjobspic     = $wxprogram->wxacode_get_unlimited($comjobsid . "&" . $userid, "pages/comjobs/detail", 430, "attachment/comjobspic/" . $comjobsid . "_" . $userid . ".jpg");
         image_copy_image($share->tilpic, $comjobspic, 500, 1270, 200, 200, $dst_comjobspic);
         image_copy_image($url_comjobspic, $user->avatar, 50, 1040, 90, 90, $dst_comjobspic);
 

+ 1 - 1
app/mainapp/controller/My.php

@@ -502,7 +502,7 @@ class My extends BaseController
 
     public function getauthimg()
     {
-        $image_url = "https://" . $_SERVER['SERVER_NAME'];
+        $image_url = "//" . $_SERVER['SERVER_NAME'];
         $head1     = $image_url . "/static/images/head1.png";
         $head2     = $image_url . "/static/images/head2.png";
         page_result(0, "", [

+ 72 - 74
extend/echowx/WxProgram.php

@@ -20,11 +20,11 @@ use echowx\utils\Xml;
 
 class WxProgram
 {
-        
+
     // 微信API域名
     const API_DOMAIN = 'https://api.weixin.qq.com/';
-    
-    
+
+
     // 开发者中心-配置项-AppID(应用ID)
     protected $appId;
     // 开发者中心-配置项-AppSecret(应用密钥)
@@ -33,8 +33,8 @@ class WxProgram
     protected $payMchId;
     // API密钥,微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置
     protected $payKey;
-    
-    
+
+
     /**
      * 设定配置项
      *
@@ -42,13 +42,13 @@ class WxProgram
      */
     public function __construct()
     {
-        $this->appId                    =   config('wxconfig.appId');
-        $this->appSecret                =   config('wxconfig.appSecret');
-        $this->payMchId               	=   config('wxconfig.payMchId');
-        $this->payKey                   =   config('wxconfig.payKey');
+        $this->appId     = config('wxconfig.appId');
+        $this->appSecret = config('wxconfig.appSecret');
+        $this->payMchId  = config('wxconfig.payMchId');
+        $this->payKey    = config('wxconfig.payKey');
     }
-    
-     
+
+
     /**
      * 校验access_token是否过期
      * @param string $token
@@ -58,7 +58,7 @@ class WxProgram
     {
         return $token && isset($token['expires_in']) && ($token['expires_in'] > time() + 1200);
     }
-    
+
     /**
      * 生成新的access_token
      * @return mixed
@@ -78,19 +78,19 @@ class WxProgram
             return false;
         }
         $res['expires_in'] += time();
-        $fp = fopen(dirname(__FILE__)."/json/access_token.json", "w",0777);
+        $fp                = fopen(dirname(__FILE__) . "/json/access_token.json", "w", 0777);
         fwrite($fp, json_encode($res));
         fclose($fp);
         return $res;
     }
-    
+
     /**
      * 获取access_token
      * @return string
      */
     public function get_access_token()
     {
-        $token = json_decode(file_get_contents(dirname(__FILE__)."/json/access_token.json"), true);
+        $token = json_decode(file_get_contents(dirname(__FILE__) . "/json/access_token.json"), true);
         // 验证AccessToken是否有效
         if (!$this->valid_access_token($token)) {
             // 生成新的AccessToken
@@ -101,71 +101,69 @@ class WxProgram
         }
         return $token['access_token'];
     }
-    
-	
-	/**
-	 * MiniProgran - 登录
-	 * 登录凭证校验
-	 * @param code
-	 */
-	public function auth_code2_session($js_code)
-	{
-		$url = self::API_DOMAIN . 'sns/jscode2session?appid=' .$this->appId. '&secret=' .$this->appSecret. '&js_code=' .$js_code. '&grant_type=authorization_code';
-		$res = HttpCurl::get($url, 'json');
-		return $res;
-	}
-	
+
+
+    /**
+     * MiniProgran - 登录
+     * 登录凭证校验
+     * @param code
+     */
+    public function auth_code2_session($js_code)
+    {
+        $url = self::API_DOMAIN . 'sns/jscode2session?appid=' . $this->appId . '&secret=' . $this->appSecret . '&js_code=' . $js_code . '&grant_type=authorization_code';
+        $res = HttpCurl::get($url, 'json');
+        return $res;
+    }
+
     /**
-	 * MiniProgran - 内容安全
+     * MiniProgran - 内容安全
      * 检查一段文本是否含有违法违规内容
-	 * @param string
+     * @param string
      * @return bool
      */
     public function security_msg_sec_check($content)
     {
         $access_token = $this->get_access_token();
-        $url = self::API_DOMAIN . 'wxa/msg_sec_check?access_token=' . $access_token;
-        $postarray = array('content'=>$content);
-		$postjson = json_encode($postarray, JSON_UNESCAPED_UNICODE);
-        $res = HttpCurl::post($url, $postjson, 'json');
-		if ($res['errcode']==0){
-			return true;
-		}else{
-			return false;
-		}
+        $url          = self::API_DOMAIN . 'wxa/msg_sec_check?access_token=' . $access_token;
+        $postarray    = ['content' => $content];
+        $postjson     = json_encode($postarray, JSON_UNESCAPED_UNICODE);
+        $res          = HttpCurl::post($url, $postjson, 'json');
+        if ($res['errcode'] == 0) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * MiniProgran - 小程序码
+     * 获取小程序码,适用于需要的码数量极多的业务场景。通过该接口生成的小程序码,永久有效,数量暂无限制。
+     * @param string
+     * @return bool
+     */
+    public function wxacode_get_unlimited($scene, $page = "", $width = 430, $filepath = '')
+    {
+        if (file_exists(root_path("/" . $filepath))) {
+            return request()->domain() . "/" . $filepath;
+        }
+        $access_token = $this->get_access_token();
+        $url          = self::API_DOMAIN . 'wxa/getwxacodeunlimit?access_token=' . $access_token;
+        $postarray    = [
+            'scene' => $scene,
+            'page'  => $page,
+            'width' => $width,
+        ];
+        $postjson     = json_encode($postarray, JSON_UNESCAPED_UNICODE);
+        $res          = HttpCurl::post($url, $postjson, 'text');
+        if (is_null(json_decode($res))) {
+            $file = fopen($filepath, "w");
+            fwrite($file, $res);
+            fclose($file);
+            return request()->domain() . "/" . $filepath;
+        } else {
+            return false;
+        }
     }
-	
-	/**
-	 * MiniProgran - 小程序码
-	 * 获取小程序码,适用于需要的码数量极多的业务场景。通过该接口生成的小程序码,永久有效,数量暂无限制。 
-	 * @param string
-	 * @return bool
-	 */
-	public function wxacode_get_unlimited($scene, $page="", $width=430, $filepath)
-	{
-		$access_token = $this->get_access_token();
-		$url = self::API_DOMAIN . 'wxa/getwxacodeunlimit?access_token=' . $access_token;
-		$postarray = array(
-			'scene'		=> $scene,
-			'page'		=> $page,
-			'width'		=> $width
-		);
-		$postjson = json_encode($postarray, JSON_UNESCAPED_UNICODE);
-		$res = HttpCurl::post($url, $postjson, 'text');
-		if (is_null(json_decode($res))) {
-			$file = fopen($filepath, "w");
-			fwrite($file, $res);
-			fclose($file);
-			return request()->domain() ."/".$filepath;
-		}else{
-			return false;
-		}
-	}
-	
-	
-	
-	
-	
-	
-	
+
+
 }

BIN
public/11.png