任务一:
排查前后台商品商品列表商品不一致原因并修复。
问题描述:
CRMEB系统,后台页面页面设计->组件库->商品列表
后台提交保存的商品数据,去小程序前台查看,小程序展示的商品和后台设置的商品不一致。
技术点:小程序采用vue开发,后台CRMEB。
任务二:
开发解析素材地址的规则,对接打码平台api,解析素材地址规则部分代码展示:
namespace app\common\model;
use app\common\model\Attach;
use app\common\model\HttpCurl;
use think\facade\Debug;
use think\facade\Request;
class ParseUrl
{
private $link;
private $site;
private $cookie;
public function __construct($link, $site, $cookie)
{
$this->link = $link;
$this->site = $site;
$this->cookie = $cookie;
}
private function get_cache($site_code = '', $site_code_type = '')
{
$query = Attach::where('site_id', $this->site['site_id'])->where('site_code_type', $site_code_type)->where('site_code', $site_code)->where('status', '>', 0)->select();
if (!$query->isEmpty()) {
$download = [];
foreach ($query as $attach) {
$download[$attach['button_name']] = url('index/download/index', ['attach_id' => $attach['attach_id']]);
}
if (!empty($download)) {
return ['code' => 1, 'has_attach' => 1, 'msg' => $download];
}
}
return false;
}
public function get_51yuansu_com()
{
preg_match('/\/(\w+).html/', $this->link, $site_code);
if (empty($site_code['1'])) {
return ['code' => 0, 'msg' => '解析失败,网址输入错误或不支持该站点解析'];
}
$cache = $this->get_cache($site_code['1']);
if ($cache !== false) {
return $cache;
}
$header = [
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
'Accept-Encoding' => 'gzip, deflate',
'Accept-Language' => 'zh-CN,zh;q=0.9',
'Connection' => 'keep-alive',
'Cookie' => $this->cookie,
'Host' => 'www.51yuansu.com',
'Upgrade-Insecure-Requests' => '1',
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36',
];
$http_curl = new HttpCurl($this->link, 'GET', null, $header, true);
$html = $http_curl->send_request()->get_response_body();
$header['Accept'] = 'application/json, text/javascript, */*; q=0.01';
$header['Referer'] = $this->link;
$header['X-Requested-With'] = 'XMLHttpRequest';
$download = [];
if (preg_match('/data-id="' . $site_code['1'] . '".*?class="p-down-operate /', $html) > 0) {
$http_curl = new HttpCurl('http://www.51yuansu.com/index.php?m=ajax&a=down&id=' . $site_code['1'], 'GET', null, $header, true);
$response = $http_curl->send_request()->get_response_body();
$response = json_decode($response, true);
if (!empty($response['url'])) {
$download['PNG下载'] = $response['url'];
}
}
if (preg_match('/data-id="' . $site_code['1'] . '".*?class="p-down-operate-zip /', $html) > 0) {
$http_curl = new HttpCurl('http://www.51yuansu.com/index.php?m=ajax&a=downPsd&id=' . $site_code['1'], 'GET', null, $header, true);
$response = $http_curl->send_request()->get_response_body();
$response = json_decode($response, true);
if (!empty($response['url'])) {
$download['PSD下载'] = $response['url'];
}
}
if (preg_match('/data-id="' . $site_code['1'] . '".*?class="b-down-operate-zip /', $html) > 0) {
$http_curl = new HttpCurl('http://www.51yuansu.com/index.php?m=ajax&a=bdownPsd&id=' . $site_code['1'], 'GET', null, $header, true);
$response = $http_curl->send_request()->get_response_body();
$response = json_decode($response, true);
if (!empty($response['url'])) {
$download['背景PSD下载'] = $response['url'];
}
}
if (preg_match('/data-id="' . $site_code['1'] . '".*?class="b-down-operate /', $html) > 0) {
$http_curl = new HttpCurl('http://www.51yuansu.com/index.php?m=ajax&a=bdown&id=' . $site_code['1'], 'GET', null, $header, true);
$response = $http_curl->send_request()->get_response_body();
$response = json_decode($response, true);
if (!empty($response['url'])) {
$download['背景JPG下载'] = $response['url'];
}
}
if (!empty($download)) {
return ['code' => 1, 'site_code_type' => '', 'site_code' => $site_code['1'], 'msg' => $download];
}
return ['code' => 0, 'msg' => '解析失败,请联系管理员'];
}
}
有时间做的小伙伴添加下面微信,报价详聊