苹果cmsv10最新版对接微信小程序
1、正常安装苹果cms V10
2、PHP扩展组件安装fileinfo、redis、sg11
3、后端上传wxApi到苹果cms10同级目录,解压后修改wxApi/config/dbs.php(苹果V10数据库信息)、苹果cms首页自定义菜单配置:小程序,wxapi/index
4、苹果cms后台----数据库----执行sql语句----分别执行
ALTER TABLE mac_user ADD user_pid_num INT(10) UNSIGNED NOT NULL Default 0
ALTER TABLE mac_user MODIFY column user_portrait varchar(200) NOT NULL Default 0
5、找到:/application/api/controller/Provide.php 编辑它
找到这大概第十七行左右
public function index()
{
}
←←←把接口方法复制到这理
public function vod() “搜索这个代码”
复制这下面的代码
public function search()
{
if($GLOBALS['config']['api']['vod']['status'] != 1){
echo 'closed';
exit;
}
// if($GLOBALS['config']['api']['vod']['charge'] == 1) {
// $h = $_SERVER['REMOTE_ADDR'];
// if (!$h) {
// echo '域名未授权!';
// exit;
// }
// else {
// $auth = $GLOBALS['config']['api']['vod']['auth'];
// $auths = array();
// if(!empty($auth)){
// $auths = explode('#',$auth);
// foreach($auths as $k=>$v){
// $auths[$k] = gethostbyname(trim($v));
// }
// }
// if($h != 'localhost' && $h != '127.0.0.1') {
// if(!in_array($h, $auths)){
// echo '域名未授权!';
// exit;
// }
// }
// }
// }
$cache_time = intval($GLOBALS['config']['api']['vod']['cachetime']);
$cach_name = 'api_vod_'.md5(http_build_query($this->_param));
$html = Cache::get($cach_name);
if(empty($html) || $cache_time==0) {
$where = [];
if (!empty($GLOBALS['config']['api']['vod']['typefilter'])) {
$where['type_id'] = ['in', $GLOBALS['config']['api']['vod']['typefilter']];
}
if (!empty($this->_param['t'])) {
if (empty($GLOBALS['config']['api']['vod']['typefilter']) || strpos($GLOBALS['config']['api']['vod']['typefilter'], $this->_param['t']) !== false) {
$where['type_id'] = $this->_param['t'];
}
}
if (!empty($this->_param['h'])) {
$todaydate = date('Y-m-d', strtotime('+1 days'));
$tommdate = date('Y-m-d H:i:s', strtotime('-' . $this->_param['h'] . ' hours'));
$todayunix = strtotime($todaydate);
$tommunix = strtotime($tommdate);
$where['vod_time'] = [['gt', $tommunix], ['lt', $todayunix]];
}
if (!empty($this->_param['wd'])) {
$pre = 'vod';
$where[$pre.'_name|'.$pre.'_en'] = ['like', '%' . $this->_param['wd'] . '%'];
}
if (empty($GLOBALS['config']['api']['vod']['from']) && !empty($this->_param['from'])) {
$GLOBALS['config']['api']['vod']['from'] = $this->_param['from'];
}
if (!empty($GLOBALS['config']['api']['vod']['from'])) {
$where['vod_play_from'] = ['like', '%' . $GLOBALS['config']['api']['vod']['from'] . '%'];
}
// if (!empty($GLOBALS['config']['api']['vod']['datafilter'])) {
// $where['_string'] .= ' ' . $GLOBALS['config']['api']['vod']['datafilter'];
// }
// if (empty($this->_param['pg'])) {
// $this->_param['pg'] = 1;
// }
$where['type_id'] =["in","1,2,3,4"];
$order = 'vod_id desc';
$field = 'vod_id as id,vod_name as name,vod_en as en';
if ($this->_param['ac'] == 'videolist' || $this->_param['ac'] == 'detail') {
$field = 'vod_id as id,vod_name as name,vod_en as en';
}
$res = model('vod')->listData($where,$order,1,10,0,$field);
if ($this->_param['at'] == 'xml') {
$html = $this->vod_xml($res);
} else {
$html = json_encode($res);
}
if($cache_time>0) {
Cache::set($cach_name, $html, $cache_time);
}
}
echo $html;
exit;
}
然后保存!第六步和第七步主要修复内容,移植到最新版无法登录、搜索页无联想搜索,暂时没发现其他毛病,如有请留言我尝试修复
后端插件已经完成
关于升级:苹果cmsvV10可以升级但你需要做好如下准备
1、请主动备份/application/extra/wxapi.php文件到网站外的路径,此文件为小程序设置的配置文件,苹果cms更新主程序可能会删除本身以外的PHP文件(以防万一)
说明:
如果更新完主程序后小程序后台异常可参考如下方案或直接从头来一遍
一、点击小程序配置提示找不到控制器或者方法不存在?
解决办法:重新解压小程序后端压缩包
二、后台配置都正常但是原来添加的小程序数据没了?
把上面备份的wxapi.php恢复到原来的路径
三、升级后无法登录?
尝试重复第四步
四、升级后搜索页没有联系搜索
尝试重复第六步
评论 (0)