小程序分类优化

This commit is contained in:
devil 2020-08-07 22:01:18 +08:00
parent 904c2af7e6
commit e6631cd440
15 changed files with 174 additions and 70 deletions

View File

@ -12,7 +12,7 @@
<span>{{$module_data.address_data.city_name}}</span>
<span>{{$module_data.address_data.county_name}}</span>
<span>{{$module_data.address_data.address}}</span>
{{if isset($module_data['address_data']['lng']) and isset($module_data['address_data']['lat']) and $module_data.address_data.lng gt 0 and $module_data.address_data.lat gt 0}}
{{if !empty($module_data['address_data']['lng']) and !empty($module_data['address_data']['lat'])}}
<div class="am-margin-top-xs">
<button type="button" class="am-btn am-btn-success am-btn-xs am-radius am-icon-map-marker am-padding-xs submit-map-popup" data-lng="{{$module_data.address_data.lng}}" data-lat="{{$module_data.address_data.lat}}"> 查看位置</button>
</div>

View File

@ -26,8 +26,8 @@
<button class="am-btn am-btn-default" type="button">分钟</button>
</span>
</div>
<div class="am-alert am-alert-warning" data-am-alert>
<p class="am-text-warning">建议将该地址添加到linux定时任务定时请求即可结果 sucs:0, fail:0 冒号后面则是处理的数据条数sucs成功fali失败</p>
<div class="am-alert am-alert-warning">
<p>建议将该地址添加到linux定时任务定时请求即可结果 sucs:0, fail:0 冒号后面则是处理的数据条数sucs成功fali失败</p>
<a href="{{:MyUrl('api/crontab/orderclose')}}" target="_blank">{{:MyUrl('api/crontab/orderclose')}}</a>
</div>
</div>
@ -40,8 +40,8 @@
<button class="am-btn am-btn-default" type="button">分钟</button>
</span>
</div>
<div class="am-alert am-alert-warning" data-am-alert>
<p class="am-text-warning">建议将该地址添加到linux定时任务定时请求即可结果 sucs:0, fail:0 冒号后面则是处理的数据条数sucs成功fali失败</p>
<div class="am-alert am-alert-warning">
<p>建议将该地址添加到linux定时任务定时请求即可结果 sucs:0, fail:0 冒号后面则是处理的数据条数sucs成功fali失败</p>
<a href="{{:MyUrl('api/crontab/ordersuccess')}}" target="_blank">{{:MyUrl('api/crontab/ordersuccess')}}</a>
</div>
</div>
@ -54,8 +54,8 @@
<button class="am-btn am-btn-default" type="button">分钟</button>
</span>
</div>
<div class="am-alert am-alert-warning" data-am-alert>
<p class="am-text-warning">建议将该地址添加到linux定时任务定时请求即可结果 sucs:0, fail:0 冒号后面则是处理的数据条数sucs成功fali失败</p>
<div class="am-alert am-alert-warning">
<p>建议将该地址添加到linux定时任务定时请求即可结果 sucs:0, fail:0 冒号后面则是处理的数据条数sucs成功fali失败</p>
<a href="{{:MyUrl('api/crontab/paylogorderclose')}}" target="_blank">{{:MyUrl('api/crontab/paylogorderclose')}}</a>
</div>
</div>

View File

@ -17,6 +17,20 @@
{{/foreach}}
</select>
</div>
<div class="am-form-group">
<label>{{$data.common_show_goods_category_level.name}}<span class="am-form-group-label-tips">{{$data.common_show_goods_category_level.describe}}</span></label>
<div class="am-input-group am-input-group-sm">
<input type="number" min="1" max="3" name="{{$data.common_show_goods_category_level.only_tag}}" placeholder="{{$data.common_show_goods_category_level.name}}" data-validation-message="{{$data.common_show_goods_category_level.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_show_goods_category_level.value}}"{{/if}} />
<span class="am-input-group-btn">
<button class="am-btn am-btn-default" type="button"></button>
</span>
</div>
<div class="am-alert am-alert-warning">
<p>1. 默认展示3级最低1级、最高3级</p>
<p>2. 层级不一样、前端分类页样式也会不一样</p>
</div>
</div>
<div class="am-form-group am-form-group-refreshing">
<input type="hidden" name="nav_type" value="{{$nav_type}}" />

View File

@ -10,7 +10,7 @@
<div class="am-panel am-panel-default">
<div class="am-panel-hd">地图</div>
<div class="am-panel-bd">
{{if !empty($data['lng']) and $data['lng'] gt 0 and !empty($data['lat']) and $data['lat']}}
{{if !empty($data['lng']) and !empty($data['lat'])}}
<div id="map" data-level="17" class="am-margin-top-xs"></div>
{{else /}}
<div class="table-no"><i class="am-icon-warning"></i> 未配置</div>

View File

@ -1,7 +1,7 @@
<!-- 经纬度 -->
{{if !empty($module_data['lng']) and $module_data['lng'] gt 0}}
{{if !empty($module_data['lng'])}}
<p><span class="am-badge am-radius">经度</span> {{$module_data.lng}}</p>
{{/if}}
{{if !empty($module_data['lat']) and $module_data['lat'] gt 0}}
{{if !empty($module_data['lat'])}}
<p class="am-margin-top-xs"><span class="am-badge am-radius">纬度</span> {{$module_data.lat}}</p>
{{/if}}

View File

@ -227,9 +227,11 @@ class Goods extends Common
*/
public function Category()
{
// 开始处理
$params = $this->data_post;
return DataReturn('success', 0, GoodsService::GoodsCategoryAll($params));
$result = [
'category' => GoodsService::GoodsCategoryAll($this->data_post),
'category_show_level' => MyC('common_show_goods_category_level', 3, true),
];
return DataReturn('success', 0, $result);
}
/**

View File

@ -1362,6 +1362,55 @@ function IsJson($jsonstr)
}
}
/**
* 请求get支持本地文件
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-08-07
* @desc description
* @param [string] $value [本地文件路径或者远程url地址]
*/
function RequestGet($value)
{
// 远程
if(substr($value, 0, 4) == 'http')
{
// 是否有curl模块
if(function_exists('curl_init'))
{
return CurlGet($value);
}
return file_get_contents($value);
}
// 本地文件
return file_exists($value) ? file_get_contents($value) : '';
}
/**
* curl模拟get请求
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-01-03T19:21:38+0800
* @param [string] $url [url地址]
* @return [array] [返回数据]
*/
function CurlGet($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_URL, $url);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
/**
* curl模拟post
* @author Devil

View File

@ -43,6 +43,9 @@ class Category extends Common
*/
public function Index()
{
// 展示层级
$this->assign('category_show_level', MyC('common_show_goods_category_level', 3, true));
// 浏览器名称
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('商品分类', 1));

View File

@ -182,7 +182,7 @@
<span>{{$address.city_name}}</span>
<span>{{$address.county_name}}</span>
<span>{{$address.address}}</span>
{{if isset($address['lng']) and $address['lng'] gt 0 and isset($address['lat']) and $address['lat'] gt 0}}
{{if !empty($address['lng']) and !empty($address['lat'])}}
<a href="javascript:;" class="am-badge am-badge-default am-radius extraction-address-map-submit am-icon-map-marker am-margin-left-sm" data-lng="{{$address.lng}}" data-lat="{{$address.lat}}"> 查看地图</a>
{{/if}}
</p>
@ -266,7 +266,7 @@
<div class="am-panel am-panel-default am-margin-top-sm am-margin-bottom-0">
<div class="am-panel-hd">
<strong>{{$v.name}}{{if !empty($v['alias'])}}<span class="am-badge am-badge-secondary-plain am-radius am-margin-left-xs">{{$v.alias}}</span>{{/if}}</strong>
{{if isset($v['lng']) and isset($v['lat']) and $v['lng'] gt 0 and $v['lat'] gt 0}}
{{if isset($v['lng']) and isset($v['lat'])}}
<div class="am-fr">
<a href="javascript:;" class="am-badge am-badge-default am-radius am-icon-map-marker submit-map-popup" data-lng="{{$v.lng}}" data-lat="{{$v.lat}}"> 查看地图</a>
</div>

View File

@ -325,7 +325,7 @@
</div>
<div>
<span>{{$data.address_data.province_name}} {{$data.address_data.city_name}} {{$data.address_data.county_name}} {{$data.address_data.address}}</span>
{{if $data.address_data.lng gt 0 and $data.address_data.lat gt 0}}
{{if !empty($data['address_data']['lng']) and !empty($data['address_data']['lat'])}}
<button type="button" class="am-btn am-btn-success am-radius am-icon-map-marker submit-map-popup" data-lng="{{$data.address_data.lng}}" data-lat="{{$data.address_data.lat}}"> 查看位置</button>
{{/if}}
</div>

View File

@ -12,7 +12,7 @@
<span>{{$module_data.address_data.city_name}}</span>
<span>{{$module_data.address_data.county_name}}</span>
<span>{{$module_data.address_data.address}}</span>
{{if isset($module_data['address_data']['lng']) and isset($module_data['address_data']['lat']) and $module_data.address_data.lng gt 0 and $module_data.address_data.lat gt 0}}
{{if !empty($module_data['address_data']['lng']) and !empty($module_data['address_data']['lat'])}}
<div class="am-margin-top-xs">
<button type="button" class="am-btn am-btn-success am-btn-xs am-radius am-icon-map-marker am-padding-xs submit-map-popup" data-lng="{{$module_data.address_data.lng}}" data-lat="{{$module_data.address_data.lat}}"> 查看位置</button>
</div>

View File

@ -68,7 +68,7 @@ App({
// 请求地址
request_url: "{{request_url}}",
request_url: 'http://shopxo.com/',
request_url: 'https://dev.shopxo.net/',
// request_url: 'https://dev.shopxo.net/',
// 基础信息
application_title: "{{application_title}}",

View File

@ -4,6 +4,7 @@ Page({
data_list_loding_status: 1,
nav_active_index: 0,
data_list: [],
category_show_level: 3,
data_content: null,
},
@ -32,18 +33,19 @@ Page({
success: res => {
wx.stopPullDownRefresh();
if (res.data.code == 0) {
var data = res.data.data;
var category = res.data.data.category;
var data_content = [];
var index = this.data.nav_active_index || 0;
if (data.length > 0)
if (category.length > 0)
{
data[index]['active'] = 'nav-active';
data_content = data[index];
category[index]['active'] = 'nav-active';
data_content = category[index];
}
this.setData({
data_list: data,
data_list: category,
category_show_level: res.data.data.category_show_level || 3,
data_content: data_content,
data_list_loding_status: data.length == 0 ? 0 : 3,
data_list_loding_status: category.length == 0 ? 0 : 3,
data_bottom_line_status: true,
});
} else {

View File

@ -1,41 +1,68 @@
<view wx:if="{{data_list.length > 0}}">
<view class='left-nav'>
<block wx:for="{{data_list}}" wx:key="key">
<view class='items {{item.active || ""}}' data-index="{{index}}" bindtap='nav_event'>
<text>{{item.name}}</text>
</view>
</block>
</view>
<view class='right-container'>
<!-- 一级 -->
<view wx:if="{{(data_content || null) != null}}" class="right-content">
<view wx:if="{{(data_content.vice_name || null) != null || (data_content.describe || null) != null}}" class="one-content bg-white" data-value="{{data_content.id}}" bindtap="category_event">
<view wx:if="{{(data_content.vice_name || null) != null}}" class="one-vice-name cr-main" style="color:{{data_content.bg_color}};">{{data_content.vice_name}}</view>
<view wx:if="{{(data_content.describe || null) != null}}" class="one-desc">{{data_content.describe}}</view>
</view>
<!-- 二级 -->
<block wx:if="{{data_content.items.length > 0}}">
<block wx:for="{{data_content.items}}" wx:key="key" wx:for-item="v">
<view class="content-tow bg-white oh">
<view class="tc two-name" data-value="{{v.id}}" bindtap="category_event">{{v.name}}</view>
<!-- 三级 -->
<block wx:if="{{v.items.length > 0}}">
<block wx:for="{{v.items}}" wx:key="key" wx:for-item="vs">
<view class="content-three" data-value="{{vs.id}}" bindtap="category_event">
<image wx:if="{{(vs.icon || null) != null}}" src="{{vs.icon}}" mode="aspectFit" class="icon" />
<view class="text single-text">{{vs.name}}</view>
</view>
</block>
</block>
</view>
</block>
</block>
<block wx:else>
<import src="/pages/common/nodata.wxml" />
<template is="nodata" data="{{status: 0, msg: '没有子分类数据'}}"></template>
<block wx:if="{{category_show_level == 1}}">
<!-- 一级模式 -->
<view class="model-one bg-white oh">
<block wx:for="{{data_list}}" wx:key="key" wx:for-item="v">
<view class="content-item br-b br-r" data-value="{{v.id}}" bindtap="category_event">
<image wx:if="{{(v.icon || null) != null}}" src="{{v.icon}}" mode="aspectFit" class="icon" />
<view class="text single-text">{{v.name}}</view>
</view>
</block>
</view>
</view>
</block>
<block wx:else>
<!-- 一级内导航 -->
<view class='left-nav'>
<block wx:for="{{data_list}}" wx:key="key">
<view class='items {{item.active || ""}}' data-index="{{index}}" bindtap='nav_event'>
<text>{{item.name}}</text>
</view>
</block>
</view>
<view class='right-container'>
<!-- 一级内基础容 -->
<view wx:if="{{(data_content || null) != null}}" class="right-content">
<view wx:if="{{(data_content.vice_name || null) != null || (data_content.describe || null) != null}}" class="one-content bg-white" data-value="{{data_content.id}}" bindtap="category_event">
<view wx:if="{{(data_content.vice_name || null) != null}}" class="one-vice-name cr-main" style="color:{{data_content.bg_color}};">{{data_content.vice_name}}</view>
<view wx:if="{{(data_content.describe || null) != null}}" class="one-desc">{{data_content.describe}}</view>
</view>
<!-- 一二级数据渲染 -->
<block wx:if="{{data_content.items.length > 0}}">
<!-- 二级模式 -->
<block wx:if="{{category_show_level == 2}}">
<view class="bg-white oh">
<block wx:for="{{data_content.items}}" wx:key="key" wx:for-item="v">
<view class="content-item" data-value="{{v.id}}" bindtap="category_event">
<image wx:if="{{(v.icon || null) != null}}" src="{{v.icon}}" mode="aspectFit" class="icon" />
<view class="text single-text">{{v.name}}</view>
</view>
</block>
</view>
</block>
<!-- 三级模式 -->
<block wx:if="{{category_show_level == 3}}">
<block wx:for="{{data_content.items}}" wx:key="key" wx:for-item="v">
<view class="bg-white oh">
<view class="tc two-name" data-value="{{v.id}}" bindtap="category_event">{{v.name}}</view>
<block wx:if="{{v.items.length > 0}}">
<block wx:for="{{v.items}}" wx:key="key" wx:for-item="vs">
<view class="content-item" data-value="{{vs.id}}" bindtap="category_event">
<image wx:if="{{(vs.icon || null) != null}}" src="{{vs.icon}}" mode="aspectFit" class="icon" />
<view class="text single-text">{{vs.name}}</view>
</view>
</block>
</block>
</view>
</block>
</block>
</block>
<block wx:else>
<import src="/pages/common/nodata.wxml" />
<template is="nodata" data="{{status: 0, msg: '没有子分类数据'}}"></template>
</block>
</view>
</view>
</block>
</view>
<view wx:if="{{data_list.length == 0 && data_list_loding_status != 0}}">

View File

@ -45,6 +45,7 @@
}
.right-content, .one-content {
padding: 20rpx;
margin-bottom: 20rpx;
}
.one-vice-name {
font-size: 30rpx;
@ -60,17 +61,23 @@
background: #f5f5f5;
padding: 20rpx 10rpx;
}
.content-three {
float: left;
width: calc(33.33% - 20rpx);
padding: 25rpx 10rpx;
text-align: center;
.content-item {
float: left;
width: calc(33.33% - 20rpx);
padding: 25rpx 10rpx;
text-align: center;
}
.content-three .text {
font-size: 28rpx;
line-height: 46rpx;
.content-item .text {
font-size: 28rpx;
line-height: 46rpx;
}
.content-three .icon {
width: 100%;
height: 120rpx;
.content-item .icon {
width: 100%;
height: 120rpx;
}
.model-one .content-item {
width: calc(33.33% - 21.1rpx);
}
.model-one .content-item:nth-child(3n) {
border-right: 0;
}