diff --git a/application/api/controller/Buy.php b/application/api/controller/Buy.php
index adad7f601..18d410351 100755
--- a/application/api/controller/Buy.php
+++ b/application/api/controller/Buy.php
@@ -83,7 +83,7 @@ class Buy extends Common
return DataReturn('操作成功', 0, $result);
}
- return $ret;
+ return $buy_ret;
}
/**
diff --git a/application/common.php b/application/common.php
index 6bc6c422c..3e8c2c920 100755
--- a/application/common.php
+++ b/application/common.php
@@ -11,6 +11,20 @@
// 应用公共文件
+/**
+ * 是否微信环境
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2020-08-26
+ * @desc description
+ * @return [boolean] [否false, 是true]
+ */
+function IsWeixinEnv()
+{
+ return (!empty($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false);
+}
+
/**
* 笛卡尔积生成规格
* @author Devil
diff --git a/application/index/view/default/goods/index.html b/application/index/view/default/goods/index.html
index d2b205122..497a1322f 100755
--- a/application/index/view/default/goods/index.html
+++ b/application/index/view/default/goods/index.html
@@ -286,7 +286,7 @@
- 库存{{$goods.inventory}}{{$goods.inventory_unit}}
+ 库存{{$goods.inventory}}{{$goods.inventory_unit}}
diff --git a/application/index/view/default/index/index.html b/application/index/view/default/index/index.html
index 7ab5d1d0f..609002114 100755
--- a/application/index/view/default/index/index.html
+++ b/application/index/view/default/index/index.html
@@ -94,7 +94,7 @@
{{if isset($article['article_category_name'])}}
- [{{$article.article_category_name}}]
+ [{{$article.article_category_name}}
]
{{/if}}
{{$article.title}}
diff --git a/application/index/view/default/public/goods_category.html b/application/index/view/default/public/goods_category.html
index 493d3914b..9a086f3ba 100755
--- a/application/index/view/default/public/goods_category.html
+++ b/application/index/view/default/public/goods_category.html
@@ -14,7 +14,7 @@
-
+
{{if !empty($v['icon'])}}
{{/if}}
diff --git a/extend/base/Wechat.php b/extend/base/Wechat.php
index c0c2def92..1f26d5bf1 100755
--- a/extend/base/Wechat.php
+++ b/extend/base/Wechat.php
@@ -180,13 +180,84 @@ class Wechat
}
/**
- * [GetMiniAccessToken 获取access_token]
- * @author Devil
- * @blog http://gong.gg/
- * @version 1.0.0
- * @datetime 2018-01-02T19:53:42+0800
+ * 小程序获取access_token
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2020-08-26
+ * @desc description
*/
public function GetMiniAccessToken()
+ {
+ return $this->GetAccessToken();
+ }
+
+ /**
+ * 获取微信环境签名配置信息
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2020-08-26
+ * @desc description
+ */
+ public function GetSignPackage()
+ {
+ $access_token = $this->GetAccessToken();
+ if(!empty($access_token))
+ {
+ // 获取 ticket
+ $ticket = $this->GetTicket($access_token);
+
+ // 注意 URL 一定要动态获取,不能 hardcode.
+ $url = __MY_VIEW_URL__;
+
+ $timestamp = time();
+ $nonce_str = $this->CreateNonceStr();
+
+ // 这里参数的顺序要按照 key 值 ASCII 码升序排序
+ $string = "jsapi_ticket={$ticket}&noncestr={$nonce_str}×tamp={$timestamp}&url={$url}";
+
+ return [
+ 'appId' => $this->_appid,
+ 'nonceStr' => $nonce_str,
+ 'timestamp' => $timestamp,
+ 'url' => $url,
+ 'signature' => sha1($string),
+ 'rawString' => $string
+ ];
+ }
+ return [];
+ }
+
+ /**
+ * 签名随机字符串创建
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2020-08-26
+ * @desc description
+ * @param [int] $length [长度]
+ */
+ public function CreateNonceStr($length = 16)
+ {
+ $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+ $str = '';
+ for($i = 0; $i < $length; $i++)
+ {
+ $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
+ }
+ return $str;
+ }
+
+ /**
+ * 公共获取access_token
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2020-08-26
+ * @desc description
+ */
+ public function GetAccessToken()
{
// 缓存key
$key = $this->_appid.'_access_token';
@@ -212,6 +283,42 @@ class Wechat
return false;
}
+ /**
+ * 获取授权页ticket
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2020-08-26
+ * @desc description
+ * @param [string] $access_token [access_token]
+ * @param [string] $type [类型(默认jsapi)]
+ */
+ public function GetTicket($access_token, $type = 'jsapi')
+ {
+ // 缓存key
+ $key = $this->_appid.'_get_ticket';
+ $result = cache($key);
+ if(!empty($result))
+ {
+ if($result['expires_in'] > time())
+ {
+ return $result['ticket'];
+ }
+ }
+
+ // 网络请求
+ $url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token='.$access_token.'&type='.$type;
+ $result = $this->HttpRequestGet($url);
+ if(!empty($result['ticket']))
+ {
+ // 缓存存储
+ $result['expires_in'] += time();
+ cache($key, $result);
+ return $result['ticket'];
+ }
+ return false;
+ }
+
/**
* [HttpRequestGet get请求]
* @author Devil
@@ -221,7 +328,7 @@ class Wechat
* @param [string] $url [url地址]
* @return [array] [返回数据]
*/
- private function HttpRequestGet($url)
+ public function HttpRequestGet($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@@ -246,7 +353,7 @@ class Wechat
* @param [array] $is_parsing [是否需要解析数据]
* @return [array] [返回的数据]
*/
- private function HttpRequestPost($url, $data, $is_parsing = true)
+ public function HttpRequestPost($url, $data, $is_parsing = true)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
diff --git a/public/static/admin/default/js/order.js b/public/static/admin/default/js/order.js
index e3c142502..db0c8f5ac 100755
--- a/public/static/admin/default/js/order.js
+++ b/public/static/admin/default/js/order.js
@@ -69,13 +69,13 @@ $(function()
var id = $('form.pay-form input[name=id]').val() || 0;
if(id == 0)
{
- PromptCenter('订单id有误');
+ Prompt('订单id有误');
return false;
}
var payment_id = $('form.pay-form input[name=payment_id]').val() || 0;
if(payment_id == 0)
{
- PromptCenter('请选择支付方式');
+ Prompt('请选择支付方式');
return false;
}
});
diff --git a/public/static/common/css/common.css b/public/static/common/css/common.css
index 180580d50..a5f8a9063 100755
--- a/public/static/common/css/common.css
+++ b/public/static/common/css/common.css
@@ -55,14 +55,12 @@ form.am-form .am-form-group-refreshing, .plug-file-upload-view, .content-app-ite
/**
* 公共提示信息
*/
-#common-prompt {position:fixed;left:0;right:0;text-align:center;padding:5px;font-size:14px;z-index:10000; border-radius: 2px; width: 260px; margin: 0 auto;}
-#common-prompt.am-alert-danger { background-color: #fef0f0; border-color: #fde2e2; color: #f56c6c; box-shadow: 0 2px 4px #fef1f1, 0 0 6px rgba(0, 0, 0, 0); }
-#common-prompt.am-alert-success { background-color: #f0f9eb; border-color: #e1f3d8; color: #67c23a; box-shadow: 0 2px 4px #efffe5, 0 0 6px rgba(0, 0, 0, 0); }
-#common-prompt p { text-align: left; font-size: 12px; }
-#common-prompt .am-close { line-height: 20px; }
-#common-prompt.prompt-center { top: calc(50% - 15px); }
-#common-prompt.prompt-top { top: 0; }
-#common-prompt.prompt-bottom { bottom: 0; }
+#common-prompt {position:fixed;top:20px;left:0;right:0;text-align:center;padding:10px 15px;font-size:14px;z-index:10000; border-radius: 2px; width: 260px; margin: 0 auto;}
+#common-prompt.am-alert-danger { background-color: #fef0f0; border-color: #f9d4d4; color: #f56c6c; box-shadow: 0 2px 4px #fef0f0, 0 0 6px rgba(0, 0, 0, 0); }
+#common-prompt.am-alert-warning { background-color: #ffe7d5; border-color: #fbceac; color: #f37b1d; box-shadow: 0 2px 4px #ffe7d5, 0 0 6px rgba(0, 0, 0, 0); }
+#common-prompt.am-alert-success { background-color: #e3fbd6; border-color: #bbe8a3; color: #67c23a; box-shadow: 0 2px 4px #e3fbd6, 0 0 6px rgba(0, 0, 0, 0); }
+#common-prompt .prompt-content { text-align: left; font-size: 12px; }
+#common-prompt .prompt-msg {width: calc(100% - 50px);display: -webkit-inline-box;}
/**
* 默认地图宽高
diff --git a/public/static/common/js/common.js b/public/static/common/js/common.js
index 0c8c187da..b36f8cd9b 100755
--- a/public/static/common/js/common.js
+++ b/public/static/common/js/common.js
@@ -5,11 +5,11 @@
* @version 0.0.1
* @datetime 2016-12-10T14:32:39+0800
* @param {[string]} msg [提示信息]
- * @param {[string]} type [类型(失败:danger, 成功success)]
+ * @param {[string]} type [类型(失败:danger, 警告:warning, 成功:success)]
* @param {[int]} time [自动关闭时间(秒), 默认3秒]
*/
var temp_time_out;
-function Prompt(msg, type, time, distance, animation_type, location)
+function Prompt(msg, type, time)
{
if(msg != undefined && msg != '')
{
@@ -22,12 +22,23 @@ function Prompt(msg, type, time, distance, animation_type, location)
// 提示信息添加
$('#common-prompt').remove();
if((type || null) == null) type = 'danger';
- if((animation_type || null) == null) animation_type = 'top';
- if((location || null) == null) location = 'top';
- var style = '';
- if((distance || null) != null) style = 'margin-'+animation_type+':'+distance+'px;';
- var html = '';
+ // icon图标, 默认错误
+ var icon = 'am-icon-times-circle';
+ switch(type)
+ {
+ // 成功
+ case 'success' :
+ icon = 'am-icon-check-circle';
+ break;
+
+ // 警告
+ case 'warning' :
+ icon = 'am-icon-exclamation-circle';
+ break;
+
+ }
+ var html = '';
$('body').append(html);
// 自动关闭提示
@@ -37,16 +48,6 @@ function Prompt(msg, type, time, distance, animation_type, location)
}, (time || 3)*1000);
}
}
-// 中间提示信息
-function PromptCenter(msg, type, time, distance)
-{
- Prompt(msg, type, time, distance, 'top', 'center');
-}
-// 底部提示信息
-function PromptBottom(msg, type, time, distance)
-{
- Prompt(msg, type, time, distance, 'bottom', 'bottom');
-}
/**
* [ArrayTurnJson js数组转json]
diff --git a/public/static/index/default/css/common.css b/public/static/index/default/css/common.css
index 675e0e302..7d9d4f864 100755
--- a/public/static/index/default/css/common.css
+++ b/public/static/index/default/css/common.css
@@ -139,7 +139,7 @@ color: #F5F5F2;font-size: 12px;cursor:pointer;border-radius:0px 0px; position: a
.category-content .category-list li.first{ margin-top: 0; }
.category-content .category-list li.last .c-category-list{ border-bottom: none; }
.category-content .category-list a { text-decoration: none; }
- .category-content li:hover, .category-content li:hover .bd-name, .category-content dd a:hover, .category-content dd a:hover * { color: #D2364C; }
+ .category-content .b-category-name:hover, .category-content li:hover, .category-content li:hover .bd-name, .category-content dd a:hover, .category-content dd a:hover * { color: #D2364C; }
.category-content .category-list dd a:hover{ border: 1px solid #D2364C; }
.category-content .category-name{ overflow:hidden; position: relative;}
.category-content .category-name img{ position: absolute; top: 8px; width: 20px; height: 20px; left: 6px; display:block;}
@@ -147,7 +147,7 @@ color: #F5F5F2;font-size: 12px;cursor:pointer;border-radius:0px 0px; position: a
.category-content .category-list .bd-b{ height: 1px; margin: -1px 10px 0 10px; background: #eee; line-height: 1; font-size: 0; }
.category-content .b-category-name {line-height:32px;padding-top:3px ;padding-left:5px; padding-right: 40px;}
.category-content .b-category-name b{ margin-left: 4px; font:400 12px/28px "宋体"; }
- .category-content .bd-name{ color: #fff; }
+ .category-content .b-category-name, .category-content .bd-name{ color: #fff; }
.category-content .c-category-list a{ margin-right:8px; color:#626262; }
.category-content .b-category-name .fr{ background-position:0 -629px; width:22px; height:22px; margin:10px 16px 0 0; }
.category-content .s-category-name{ height:22px;}
diff --git a/public/static/index/default/css/index.css b/public/static/index/default/css/index.css
index 08310d037..e01fbdd44 100755
--- a/public/static/index/default/css/index.css
+++ b/public/static/index/default/css/index.css
@@ -18,6 +18,7 @@ ul, li, ol {list-style: none;}
.banner-news-title{position: absolute;left:10px;padding-right:10px;border-right:1px solid #F5F5F5 ;}
.banner-news li,#banner-news li a{height: 30px;line-height:30px; font-size: 12px; overflow: hidden;}
.banner-news{max-width:1200px; margin:0px auto; overflow:hidden; height:30px;width:100%; text-align:left;color:#ffffff;}
+.news-category-name { line-height: 11px; width: 50px; }
.banner-news li {padding:0 10px 0 80px;}
.mod-vip{display: none;}
diff --git a/public/static/index/default/js/cart.js b/public/static/index/default/js/cart.js
index 218042b01..3363f2bb7 100755
--- a/public/static/index/default/js/cart.js
+++ b/public/static/index/default/js/cart.js
@@ -76,7 +76,7 @@ $(function()
self.parents('.stock-tag').find('input').val(stock);
self.parents('tr').find('.total-price-content').text(__price_symbol__+FomatFloat(stock*price, 2));
- PromptCenter(result.msg, 'success');
+ Prompt(result.msg, 'success');
// 数量更新
self.parents('tr').find('.wap-number').text('x'+stock);
@@ -84,13 +84,13 @@ $(function()
// 计算选择的商品总数和总价
CartBaseTotal();
} else {
- PromptCenter(result.msg);
+ Prompt(result.msg);
}
},
error: function(xhr, type)
{
$.AMUI.progress.done();
- PromptCenter('服务器错误');
+ Prompt('服务器错误');
}
});
}
@@ -178,7 +178,7 @@ $(function()
var ids = $(this).parents('form').find('input[name="ids"]').val() || 0;
if(ids == 0)
{
- PromptCenter('请选择商品');
+ Prompt('请选择商品');
return false;
}
});
diff --git a/public/static/index/default/js/goods.js b/public/static/index/default/js/goods.js
index 544eddc0d..b89f897ac 100755
--- a/public/static/index/default/js/goods.js
+++ b/public/static/index/default/js/goods.js
@@ -85,17 +85,17 @@ function CartAdd(e)
var unit = $('.stock-tips .stock').data('unit') || '';
if(stock < min)
{
- PromptCenter('最低起购数量'+min+unit);
+ Prompt('最低起购数量'+min+unit);
return false;
}
if(max > 0 && stock > max)
{
- PromptCenter('最大限购数量'+max+unit);
+ Prompt('最大限购数量'+max+unit);
return false;
}
if(stock > inventory)
{
- PromptCenter('库存数量'+inventory+unit);
+ Prompt('库存数量'+inventory+unit);
return false;
}
@@ -114,7 +114,7 @@ function CartAdd(e)
$(this).addClass('sku-not-active');
}
});
- PromptCenter('请选择规格');
+ Prompt('请选择规格');
return false;
} else {
$('.iteminfo_parameter .sku-items').removeClass('sku-not-active');
@@ -160,9 +160,9 @@ function CartAdd(e)
if(result.code == 0)
{
HomeCartNumberTotalUpdate(parseInt(result.data));
- PromptCenter(result.msg, 'success');
+ Prompt(result.msg, 'success');
} else {
- PromptCenter(result.msg);
+ Prompt(result.msg);
}
},
error: function(xhr, type)
@@ -170,14 +170,14 @@ function CartAdd(e)
PoptitClose();
$.AMUI.progress.done();
$button.attr('disabled', false);
- PromptCenter('服务器错误');
+ Prompt('服务器错误');
}
});
break;
// 默认
default :
- PromptCenter('操作参数配置有误');
+ Prompt('操作参数配置有误');
}
return true;
}
@@ -247,23 +247,13 @@ function GoodsSpecDetail()
}
}
} else {
- if($(window).width() < 640)
- {
- PromptBottom(result.msg, null, null, 50);
- } else {
- PromptCenter(result.msg);
- }
+ Prompt(result.msg);
}
},
error: function(xhr, type)
{
$.AMUI.progress.done();
- if($(window).width() < 640)
- {
- PromptBottom('服务器错误', null, null, 50);
- } else {
- PromptCenter('服务器错误');
- }
+ Prompt('服务器错误');
}
});
}
@@ -338,23 +328,13 @@ function GoodsSpecType()
}
}
} else {
- if($(window).width() < 640)
- {
- PromptBottom(result.msg, null, null, 50);
- } else {
- PromptCenter(result.msg);
- }
+ Prompt(result.msg);
}
},
error: function(xhr, type)
{
$.AMUI.progress.done();
- if($(window).width() < 640)
- {
- PromptBottom('服务器错误', null, null, 50);
- } else {
- PromptCenter('服务器错误');
- }
+ Prompt('服务器错误');
}
});
}
@@ -566,32 +546,16 @@ $(function() {
} else {
$this.removeClass('text-active');
}
-
- if($(window).width() < 640)
- {
- PromptBottom(result.msg, 'success', null, 50);
- } else {
- PromptCenter(result.msg, 'success');
- }
+ Prompt(result.msg, 'success');
} else {
- if($(window).width() < 640)
- {
- PromptBottom(result.msg, null, null, 50);
- } else {
- PromptCenter(result.msg);
- }
+ Prompt(result.msg);
}
},
error: function(xhr, type)
{
PoptitClose();
$.AMUI.progress.done();
- if($(window).width() < 640)
- {
- PromptBottom('服务器错误', null, null, 50);
- } else {
- PromptCenter('服务器错误');
- }
+ Prompt('服务器错误');
}
});
}
diff --git a/public/static/index/default/js/order.js b/public/static/index/default/js/order.js
index 6da3a538b..89c889210 100755
--- a/public/static/index/default/js/order.js
+++ b/public/static/index/default/js/order.js
@@ -47,13 +47,13 @@ $(function()
var ids = $('form.pay-form input[name=ids]').val() || null;
if(ids == null)
{
- PromptCenter('订单id有误');
+ Prompt('订单id有误');
return false;
}
var payment_id = $('form.pay-form input[name=payment_id]').val() || 0;
if(payment_id == 0)
{
- PromptCenter('请选择支付方式');
+ Prompt('请选择支付方式');
return false;
}
});