mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-11-29 18:39:16 +08:00
细节优化
This commit is contained in:
parent
e2979b0ce2
commit
595e490818
@ -83,7 +83,7 @@ class Buy extends Common
|
||||
|
||||
return DataReturn('操作成功', 0, $result);
|
||||
}
|
||||
return $ret;
|
||||
return $buy_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -286,7 +286,7 @@
|
||||
<input type="number" class="am-form-field" value="{{$goods.buy_min_number}}" id="text_box" min="{{$goods.buy_min_number}}" max="{{if empty($goods['buy_max_number'])}}{{$goods.inventory}}{{else /}}{{$goods.buy_max_number}}{{/if}}" data-original-max="{{$goods.inventory}}" />
|
||||
<button class="am-input-group-label" id="add" type="button">+</button>
|
||||
</div>
|
||||
<span class="tb-hidden stock-tips">库存<span class="stock" data-original-stock="{{$goods.inventory}}" data-min-limit="{{$goods.buy_min_number}}" data-max-limit="{{$goods.buy_max_number}}" data-unit="{{$goods.inventory_unit}}">{{$goods.inventory}}</span>{{$goods.inventory_unit}}</span>
|
||||
<span class="tb-hidden stock-tips"><span>库存</span><span class="stock" data-original-stock="{{$goods.inventory}}" data-min-limit="{{$goods.buy_min_number}}" data-max-limit="{{$goods.buy_max_number}}" data-unit="{{$goods.inventory_unit}}">{{$goods.inventory}}</span><span>{{$goods.inventory_unit}}</span></span>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
@ -94,7 +94,7 @@
|
||||
<li>
|
||||
<a href="{{$article.url}}" target="_blank">
|
||||
{{if isset($article['article_category_name'])}}
|
||||
<span>[{{$article.article_category_name}}]</span>
|
||||
<span>[</span><p class="news-category-name am-inline-block am-text-truncate">{{$article.article_category_name}}</p><span>]</span>
|
||||
{{/if}}
|
||||
<span {{if !empty($article.title_color)}}style="color:{{$article.title_color}};"{{/if}} >{{$article.title}}</span>
|
||||
</a>
|
||||
|
@ -14,7 +14,7 @@
|
||||
<li class="first">
|
||||
<a href="{{:MyUrl('index/search/index', ['category_id'=>$v['id']])}}" class="am-block" title="{{$v.name}}">
|
||||
<div class="category-info">
|
||||
<h3 class="category-name b-category-name">
|
||||
<h3 class="category-name b-category-name am-text-truncate">
|
||||
{{if !empty($v['icon'])}}
|
||||
<img src="{{$v.icon}}" />
|
||||
{{/if}}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
@ -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;}
|
||||
|
||||
/**
|
||||
* 默认地图宽高
|
||||
|
@ -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 = '<div id="common-prompt" class="am-alert am-alert-'+type+' am-animation-slide-'+animation_type+' prompt-'+location+'" style="'+style+'" data-am-alert><button type="button" class="am-close am-close-spin">×</button><p>'+msg+'</p></div>';
|
||||
// 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 = '<div id="common-prompt" class="am-alert am-alert-'+type+' am-animation-slide-top" data-am-alert><button type="button" class="am-close">×</button><div class="prompt-content"><i class="'+icon+' am-icon-sm am-margin-right-sm"></i><p class="prompt-msg">'+msg+'</p></div></div>';
|
||||
$('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]
|
||||
|
@ -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;}
|
||||
|
@ -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;}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
@ -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('服务器错误');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user