IndexController.php
4.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\admin\model\BabyModel;
use app\admin\model\SlideItemModel;
use cmf\controller\HomeBaseController;
use EasyWeChat\Foundation\Application;
use think\Cache;
use think\Db;
class IndexController extends HomeBaseController
{
protected $abc;
public function index()
{
// $href = file_get_contents('http://suo.im/api.php?format=json&url=http%3a%2f%2fwww.baidu.com');
// echo json_decode($href, true)['url'];
// 生成页面二维码(用户推广)
$url = url('index','','',true);
$qrcode = $this->createQRcode($url,'Q',9);
$name = '首页';
$this->qrcodePage($url,$name,$qrcode);
// 轮播图
$slide_model = new SlideItemModel();
$slide_where = [
'slide_id' => 1,
'status' => 1
];
$slideList = $slide_model->where($slide_where)->order(['list_order'=>'ASC'])->select();
$this->assign('slideList', $slideList);
$this->nav_bottom(1,0,0);
// $url = url('user/Register/index',['type'=>1,'']);
return $this->fetch(':index');
}
// 视频详情页面
public function detail() {
if (cmf_is_user_login()) {
if(!session('baby_age')) {
$this->success("用户已登录",url('user/Login/chooseAge'),['user'=>cmf_get_current_user()]);
} else {
$id = $this->request->param('id',0,'intval');
if(!$id) {
$this->error('参数错误');
}
$baby_model = new BabyModel();
$where = [
'id' => $id
];
$babyInfo = $baby_model->where($where)->find();
$babyInfo['video_url'] = $this->change($babyInfo['video_url']);
$this->assign('babyInfo',$babyInfo);
return $this->fetch(':detail');
}
} else {
$this->error("此用户未登录!",url('user/Login/index'));
}
}
/**
* 腾讯外链视频转换成video可识别视频
* @param video 视频路径
* @return 视频转换后路径
*/
private function change($video) {
$videoArray = explode('/',$video);
$videoId = explode('.',$videoArray[count($videoArray)-1])[0];
$url = "http://vv.video.qq.com/getinfo?vids=$videoId&platform=101001&charge=0&otype=json&defn=shd";
$data = $this->curl($url);
$data = substr($data,13,strlen($data)-14);
$array = json_decode($data,true);
if(!empty($array['msg'])) {
$this->error('视频地址错误');
return $array['msg'];
}
return $array['vl']['vi'][0]['ul']['ui'][0]['url']
.$array['vl']['vi'][0]['fn']
."?vkey="
.$array['vl']['vi'][0]['fvkey'];
}
public function test() {
return $this->fetch(':test');
}
// 微信h5支付(测试)
public function wxpayh5() {
require_once VENDOR_PATH.'WxpayAPI/WxpayH5.php';
$h5 = new \WxpayH5('wx8f31a4eb6d72f174','1512102931','kgAFbJx2MpAxQI2iJBTffrzFwxrnqE4h','2018092053101549',
'测试支付','1','{"h5_info": {"type":"Wap","wap_url": "http://m.wanlin-edu.com","wap_name": "测试支付"}}' );
$result = $h5->pay();
var_dump($result);
$mweb_url = '';
if(!empty($result['mweb_url'])) {
$mweb_url = $result['mweb_url'];
}
$this->assign('mwen_url',$mweb_url);
return $this->fetch(':h5');
}
}