RoutineCode.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\routine\model\routine;
  3. class RoutineCode{
  4. /**
  5. * 获取分销二维码
  6. * @param int $uid yonghuID
  7. * @param array $color 二维码线条颜色
  8. * @return mixed
  9. */
  10. public static function getCode($uid = 0,$imgUrl = '',$color = array(),$page = '',$thirdType = 'spread'){
  11. $accessToken = RoutineServer::get_access_token();
  12. $res = RoutineQrcode::setRoutineQrcodeForever($uid,$thirdType,$page,$imgUrl);
  13. if($res){
  14. $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=".$accessToken;
  15. if($uid) $data['scene'] = $res->id;
  16. else $data['scene'] = 0;
  17. if(empty($color)){
  18. $color['r'] = 0;
  19. $color['g'] = 0;
  20. $color['b'] = 0;
  21. }
  22. $data['page'] = '';
  23. $data['width'] = 430;
  24. $data['auto_color'] = false;
  25. $data['line_color'] = $color;
  26. $data['is_hyaline'] = false;
  27. $resCode = RoutineServer::curlPost($url,json_encode($data));
  28. if($resCode){
  29. $dataQrcode['status'] = 1;
  30. $dataQrcode['url_time'] = time();
  31. $res = RoutineQrcode::setRoutineQrcodeFind($res->id,$dataQrcode);
  32. if($res) return $resCode;
  33. else return false;
  34. }else return false;
  35. }else return false;
  36. }
  37. /**
  38. * 获取小程序内访问页面的二维码
  39. * @param string $path
  40. * @param int $width
  41. * @return mixed
  42. */
  43. public static function getPages($path = '',$width = 430){
  44. $accessToken = RoutineServer::get_access_token();
  45. $url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=".$accessToken;
  46. $data['path'] = $path;
  47. $data['width'] = $width;
  48. return RoutineServer::curlPost($url,json_encode($data));
  49. }
  50. }