支付宝小程序

feat/task1-c-wallet
devil_gong 2018-12-26 18:39:30 +08:00
parent b42677a590
commit efc8ad1c33
15 changed files with 330 additions and 46 deletions

View File

@ -0,0 +1,14 @@
<?php
/**
* 模块配置信息
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
return array(
);
?>

View File

@ -0,0 +1,44 @@
<?php
namespace app\api\controller;
use app\service\BannerService;
/**
* 轮播
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Banner extends Common
{
/**
* [_initialize 前置操作-继承公共前置方法]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-03T12:39:08+0800
*/
public function __construct()
{
// 调用父类前置方法
parent::__construct();
}
/**
* [Index 入口]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-05-25T11:03:59+0800
*/
public function Index()
{
// 获取轮播
$data = BannerService::Banner();
// 返回数据
return json(DataReturn('success', 0, $data));
}
}
?>

View File

@ -0,0 +1,138 @@
<?php
namespace app\api\controller;
use think\Controller;
use app\service\ConfigService;
use app\service\UserService;
/**
* 接口公共控制器
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Common extends Controller
{
// 用户信息
protected $user;
// 输入参数 post
protected $data_post;
// 输入参数 get
protected $data_get;
// 输入参数 request
protected $data_request;
/**
* 构造方法
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-11-30
* @desc description
*/
public function __construct()
{
parent::__construct();
// 是否ajax请求
if(!IS_AJAX)
{
exit(json_encode(DataReturn('非法访问', -500)));
}
// 系统初始化
$this->SystemInit();
// 网站状态
$this->SiteStstusCheck();
// 公共数据初始化
$this->CommonInit();
// 输入参数
$this->data_post = input('post.');
$this->data_get = input('get.');
$this->data_request = input();
}
/**
* 系统初始化
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-07
* @desc description
*/
private function SystemInit()
{
// 配置信息初始化
ConfigService::ConfigInit();
// url模式,后端采用兼容模式
\think\facade\Url::root(__MY_ROOT__.'index.php?s=');
}
/**
* [SiteStstusCheck 网站状态]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-04-18T16:20:58+0800
*/
private function SiteStstusCheck()
{
if(MyC('home_site_state') != 1)
{
die(json_encode(DataReturn(MyC('home_site_close_reason', '网站维护中...'), -10000)));
}
}
/**
* [Is_Login 登录校验]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-09T11:43:48+0800
*/
protected function Is_Login()
{
if(empty($this->user))
{
exit(json_encode(DataReturn('登录失效,请重新登录', -400)));
}
}
/**
* [CommonInit 公共数据初始化]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-09T11:43:48+0800
*/
private function CommonInit()
{
// 用户数据
if(!empty($this->data_request['user_id']))
{
$this->user = UserService::UserLoginRecord($this->data_request['user_id']);
}
}
/**
* [_empty 空方法操作]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-02-25T15:47:50+0800
* @param [string] $name [方法名称]
*/
protected function _empty($name)
{
exit(json_encode(DataReturn($name.' 非法访问', -1000)));
}
}
?>

View File

@ -0,0 +1,48 @@
<?php
namespace app\api\controller;
use app\service\GoodsService;
/**
* 首页
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Index extends Common
{
/**
* [_initialize 前置操作-继承公共前置方法]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-03T12:39:08+0800
*/
public function __construct()
{
// 调用父类前置方法
parent::__construct();
}
/**
* [Index 入口]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-05-25T11:03:59+0800
*/
public function Index()
{
$result = [
'data_list' => GoodsService::HomeFloorList(),
'common_shop_notice' => MyC('common_shop_notice', null, true),
'common_app_is_enable_search' => (int) MyC('common_app_is_enable_search', 1),
'common_app_is_enable_answer' => (int) MyC('common_app_is_enable_answer', 1),
];
// 返回数据
return json(DataReturn('success', 0, $result));
}
}
?>

View File

@ -0,0 +1,44 @@
<?php
namespace app\api\controller;
use app\service\AppNavService;
/**
* 导航
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Navigation extends Common
{
/**
* [_initialize 前置操作-继承公共前置方法]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-03T12:39:08+0800
*/
public function __construct()
{
// 调用父类前置方法
parent::__construct();
}
/**
* [Index 入口]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-05-25T11:03:59+0800
*/
public function Index()
{
// 获取轮播
$data = AppNavService::AppHomeNav();
// 返回数据
return json(DataReturn('success', 0, $data));
}
}
?>

View File

@ -0,0 +1 @@

1
application/api/index.html Executable file
View File

@ -0,0 +1 @@

View File

@ -44,7 +44,7 @@ class Common extends Controller
$this->SystemInit();
// 站点状态校验
$this->SiteStateCheck();
$this->SiteStstusCheck();
// 公共数据初始化
$this->CommonInit();
@ -106,7 +106,7 @@ class Common extends Controller
private function CommonInit()
{
// 用户数据
if(!empty(session('user')))
if(session('user') != null)
{
$this->user = session('user');
}
@ -259,15 +259,15 @@ class Common extends Controller
}
/**
* [SiteStateCheck 站点状态校验]
* [SiteStstusCheck 站点状态校验]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-02-25T21:43:07+0800
*/
private function SiteStateCheck()
private function SiteStstusCheck()
{
if(MyC('home_site_state') == 0)
if(MyC('home_site_state') != 1)
{
// 是否ajax请求
if(IS_AJAX)

View File

@ -304,5 +304,30 @@ class AppNavService
}
return DataReturn('编辑失败或数据未改变', -100);
}
/**
* APP获取首页导航
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-11-19
* @desc description
* @param array $params [description]
*/
public static function AppHomeNav($params = [])
{
$data = Db::name('AppHomeNav')->field('id,name,images_url,event_value,event_type,bg_color')->where(['platform'=>APPLICATION_CLIENT_TYPE, 'is_enable'=>1])->order('sort asc')->select();
if(!empty($data))
{
$images_host = config('images_host');
foreach($data as &$v)
{
$v['images_url_old'] = $v['images_url'];
$v['images_url'] = $images_host.$v['images_url'];
$v['event_value'] = empty($v['event_value']) ? null : $v['event_value'];
}
}
return $data;
}
}
?>

View File

@ -75,31 +75,5 @@ class ResourcesService
return DataReturn('success', 0, $result);
}
/**
* APP获取首页导航
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-11-19
* @desc description
* @param array $params [description]
*/
public static function AppHomeNav($params = [])
{
$data = Db::name('AppHomeNav')->field('id,name,images_url,event_value,event_type,bg_color')->where(['platform'=>APPLICATION_CLIENT_TYPE, 'is_enable'=>1])->order('sort asc')->select();
if(!empty($data))
{
$images_host = config('images_host');
foreach($data as &$v)
{
$v['images_url_old'] = $v['images_url'];
$v['images_url'] = $images_host.$v['images_url'];
$v['event_value'] = empty($v['event_value']) ? null : $v['event_value'];
}
}
return $data;
}
}
?>

View File

@ -49,9 +49,9 @@ App({
},
// 请求地址
request_url: "{{request_url}}",
//request_url: "{{request_url}}",
//request_url: "https://demo.shopxo.net/",
//request_url: 'http://localhost/project/shopxo/',
request_url: 'http://tp5-dev.com/index.php?s=',
// 基础信息
application_title: "{{application_title}}",
@ -154,9 +154,9 @@ App({
* 请求地址生成
*/
get_request_url(a, c, m, params) {
a = a || "Index";
c = c || "Index";
m = m || "Api";
a = a || "index";
c = c || "index";
m = m || "api";
params = params || "";
if (params != "" && params.substr(0, 1) != "&") {
params = "&" + params;
@ -167,12 +167,7 @@ App({
var nickname = user == false ? "" : user.nickname;
return (
this.data.request_url +
"api.php?m=" +
m +
"&c=" +
c +
"&a=" +
a +
"/" + m + "/" + c + "/" + a +
"&application_client=default&&application=app&application_client_type=alipay&application_user_id=" +
app_client_user_id +
"&user_id=" +

View File

@ -27,7 +27,7 @@ Component({
// 加载loding
my.httpRequest({
url: app.get_request_url("HomeBanner", "Resources"),
url: app.get_request_url("index", "banner"),
method: "POST",
data: {},
dataType: "json",

View File

@ -21,7 +21,7 @@ Component({
// 加载loding
my.httpRequest({
url: app.get_request_url("HomeNav", "Resources"),
url: app.get_request_url("index", "navigation"),
method: "POST",
data: {},
dataType: "json",

View File

@ -30,7 +30,7 @@ Page({
// 加载loding
my.httpRequest({
url: app.get_request_url("Index", "Index"),
url: app.get_request_url("index", "index"),
method: "POST",
data: {},
dataType: "json",

View File

@ -77,6 +77,6 @@ define('APPLICATION_CLIENT', empty($_REQUEST['application_client']) ? 'default'
define('APPLICATION_CLIENT_TYPE', empty($_REQUEST['application_client_type']) ? 'pc' : trim($_REQUEST['application_client_type']));
// 是否ajax
define('IS_AJAX', (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 'xmlhttprequest' == strtolower($_SERVER['HTTP_X_REQUESTED_WITH'])));
define('IS_AJAX', ((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 'xmlhttprequest' == strtolower($_SERVER['HTTP_X_REQUESTED_WITH'])) || isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 'ajax'));
?>