提交 6aa86796 编写于 作者: D Devil

微信小程序支持可视化装修

上级 47829f61
......@@ -15,6 +15,7 @@ use app\service\GoodsService;
use app\service\BannerService;
use app\service\AppHomeNavService;
use app\service\BuyService;
use app\service\LayoutService;
/**
* 首页
......@@ -47,11 +48,19 @@ class Index extends Common
*/
public function Index()
{
// 数据模式
if(MyC('home_index_floor_data_type', 0, true) == 2)
{
$data_list = LayoutService::LayoutConfigData('home');
} else {
$data_list = GoodsService::HomeFloorList();
}
// 返回数据
$result = [
'navigation' => AppHomeNavService::AppHomeNav(),
'banner_list' => BannerService::Banner(),
'data_list' => GoodsService::HomeFloorList(),
'data_list' => $data_list,
'common_cart_total' => BuyService::UserCartTotal(['user'=>$this->user]),
];
return SystemBaseService::DataReturn($result);
......
......@@ -71,7 +71,7 @@ class Index extends Common
// 设计配置数据
$layout_data = LayoutService::LayoutConfigAdminData('home');
$this->assign('layout_data', $layout_data['data']);
$this->assign('layout_data', $layout_data);
// 页面列表
$pages_list = BaseLayout::PagesList();
......@@ -112,7 +112,7 @@ class Index extends Common
{
// 设计配置数据
$layout_data = LayoutService::LayoutConfigData('home');
$this->assign('layout_data', $layout_data['data']);
$this->assign('layout_data', $layout_data);
// 加载布局样式
$this->assign('is_load_layout', 1);
......
......@@ -114,6 +114,7 @@ class SystemBaseService
'home_footer_info' => MyC('home_footer_info', null, true),
// 首页设置参数
'home_index_floor_data_type' => (int) MyC('home_index_floor_data_type', 0, true),
'home_index_banner_left_status' => (int) MyC('home_index_banner_left_status', 1),
'home_index_banner_right_status' => (int) MyC('home_index_banner_right_status', 1),
......
......@@ -48,8 +48,8 @@ class UserService
// web用户session
$user = session(self::$user_login_key);
// token仅小程序浏览器环境和api接口环境中有效
if(empty($user) && !empty($params['token']) && in_array(MiniAppEnv(), config('shopxo.mini_app_type_list')))
// 用户信息为空,指定了token则设置登录信息
if(empty($user) && !empty($params['token']))
{
$user = self::UserTokenData($params['token']);
if($user !== null && isset($user['id']))
......@@ -420,14 +420,13 @@ class UserService
* @version 0.0.1
* @datetime 2017-03-09T11:37:43+0800
* @param [int] $user_id [用户id]
* @param [boolean] $is_app [是否为app]
* @return [boolean] [记录成功true, 失败false]
*/
public static function UserLoginRecord($user_id = 0, $is_app = false)
public static function UserLoginRecord($user_id = 0)
{
if(!empty($user_id))
{
$user = Db::name('User')->field('*')->find($user_id);
$user = Db::name('User')->find($user_id);
if(!empty($user))
{
// 用户数据处理
......@@ -442,8 +441,8 @@ class UserService
'user_id' => $user_id
]);
// 非app则存储session
if($is_app == false)
// web端设置session
if(APPLICATION == 'web')
{
// 存储session
session(self::$user_login_key, $user);
......@@ -516,6 +515,9 @@ class UserService
$user['avatar'] = config('shopxo.attachment_host').'/static/index/'.strtolower(config('DEFAULT_THEME', 'default')).'/images/default-user-avatar.jpg';
}
// 移除特殊数据
unset($user['pwd'], $user['salt']);
return $user;
}
......@@ -603,10 +605,8 @@ class UserService
];
if(Db::name('User')->where(['id'=>$params['user']['id']])->update($data))
{
if(APPLICATION == 'web')
{
self::UserLoginRecord($params['user']['id']);
}
// 设置session
self::UserLoginRecord($params['user']['id']);
return DataReturn('上传成功', 0);
}
return DataReturn('上传失败', -100);
......@@ -1878,19 +1878,18 @@ class UserService
public static function AppUserInfoHandle($user_id = null, $where_field = null, $where_value = null, $user = [])
{
// 获取用户信息
$field = 'id,username,nickname,mobile,email,avatar,status,alipay_openid,weixin_openid,weixin_unionid,weixin_web_openid,baidu_openid,toutiao_openid,qq_openid,qq_unionid,integral,locking_integral,referrer,add_time';
if(!empty($user_id))
{
$user = self::UserInfo('id', $user_id, $field);
$user = self::UserInfo('id', $user_id);
} elseif(!empty($where_field) && !empty($where_value) && empty($user))
{
$user = self::UserInfo($where_field, $where_value, $field);
$user = self::UserInfo($where_field, $where_value);
}
if(!empty($user))
{
// 用户信息处理
$user = self::GetUserViewInfo(0, $user);
$user = self::UserHandle($user);
// 是否强制绑定手机号码
$user['is_mandatory_bind_mobile'] = intval(MyC('common_user_is_mandatory_bind_mobile'));
......@@ -1901,16 +1900,7 @@ class UserService
// 非token数据库校验,则重新生成token更新到数据库
if($where_field != 'token')
{
// token生成并存储缓存
$user['token'] = self::CreatedUserToken($user['id']);
Db::name('User')->where(['id'=>$user['id']])->update(['token'=>$user['token'], 'upd_time'=>time()]);
cache(config('shopxo.cache_user_info').$user['token'], $user);
}
// 用户登录纪录处理
if(in_array(APPLICATION_CLIENT_TYPE, ['pc', 'h5']))
{
self::UserLoginRecord($user['id'], true);
$user = self::UserTokenUpdate($user['id'], $user);
}
}
......@@ -1929,6 +1919,40 @@ class UserService
return $user;
}
/**
* 用户 token更新
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-07-01
* @desc description
* @param [int] $user_id [用户id]
* @param [array] $user [指定用户信息]
*/
public static function UserTokenUpdate($user_id, $user = [])
{
// 未指定用户则读取用户信息、并处理数据
if(empty($user))
{
$user = self::UserHandle(self::UserInfo('id', $user_id));
}
if(!empty($user))
{
// token生成并存储缓存
$user['token'] = self::CreatedUserToken($user_id);
if(Db::name('User')->where(['id'=>$user_id])->update(['token'=>$user['token'], 'upd_time'=>time()]))
{
cache(config('shopxo.cache_user_info').$user['token'], $user);
}
// web端用户登录纪录处理
self::UserLoginRecord($user_id);
}
// 返回用户信息
return $user;
}
/**
* 用户token生成
* @author Devil
......
......@@ -73,7 +73,7 @@ App({
// 请求地址
request_url: "{{request_url}}",
// request_url: 'http://shopxo.com/',
request_url: 'http://shopxo.com/',
// request_url: 'https://dev.shopxo.net/',
// 基础信息
......
const app = getApp();
Component({
data: {
// 基础配置
is_first: 1,
currency_symbol: app.data.currency_symbol,
// 轮播基础配置
indicator_color: 'rgba(0, 0, 0, .3)',
indicator_active_color: '#e31c55',
circular: true,
},
properties: {
propData: Array
},
lifetimes: {
// 在组件实例进入页面节点树时执行
attached: function() {
this.init_config();
},
},
pageLifetimes: {
// 页面被展示
show: function() {
this.init_config();
// 非首次进入则重新初始化配置接口
if(this.data.is_first == 0) {
app.init_config();
}
this.setData({is_first: 0});
},
},
methods: {
// 初始化配置
init_config(status) {
if((status || false) == true) {
this.setData({
currency_symbol: app.get_config('currency_symbol') || app.data.currency_symbol
});
} else {
app.is_config(this, 'init_config');
}
},
// 链接地址事件
layout_url_event(e) {
var value = e.currentTarget.dataset.value || null;
if(value != null)
{
var temp = value.substr(0, 6);
if(temp == 'http:/' || temp == 'https:')
{
app.open_web_view(value);
} else {
if (app.is_tabbar_pages(value))
{
wx.switchTab({ url: value });
} else {
wx.navigateTo({ url: value });
}
}
}
},
},
});
\ No newline at end of file
{
"component": true
}
\ No newline at end of file
<block wx:if="{{(propData || null) != null && propData.length > 0}}">
<block wx:for="{{propData}}" wx:key="key" wx:for-item="v">
<view wx:if="{{(v.value || null) != null && (v.children || null) != null && v.children.length > 0 && (v.value_arr || null) != null && v.value_arr.length > 0 && v.children.length == v.value_arr.length && (v.status || 0) == 1}}" class="layout-view">
<view class="layout-content-children {{((v.config || null) != null && (v.config.frontend_config || null) != null && (v.config.frontend_config.ent || null) != null) ? v.config.frontend_config.ent : ''}}" style="{{((v.config || null) != null && (v.config.frontend_config || null) != null && (v.config.frontend_config.style || null) != null) ? v.config.frontend_config.style : ''}}">
<block wx:for="{{v.children}}" wx:key="keys" wx:for-item="vs">
<view class="layout-content-container {{((vs.config || null) != null && (vs.config.frontend_config || null) != null && (vs.config.frontend_config.ent || null) != null) ? vs.config.frontend_config.ent : ''}}" style="{{((vs.config || null) != null && (vs.config.frontend_config || null) != null && (vs.config.frontend_config.style || null) != null) ? vs.config.frontend_config.style : ''}}">
<block wx:if="{{(vs.children || null) != null && vs.children.length > 0}}">
<view wx:for="{{vs.children}}" wx:key="keyss" wx:for-item="vss" class="layout-content">
<view wx:if="{{(vss.config || null) != null}}" class="module-content">
<view class="module-{{vss.value}}-container" style="{{((vss.config.frontend_config || null) != null && (vss.config.frontend_config.style || null) != null) ? vss.config.frontend_config.style : ''}}">
<!-- 单图 -->
<block wx:if="{{vss.value == 'images'}}">
<view class="module-images-content {{vss.config.frontend_config.media_fixed.media_container_ent}}" style="{{vss.config.frontend_config.media_fixed.media_container_style}}">
<image bindtap="layout_url_event" data-value="{{vss.config.url || ''}}" src="{{vss.config.images}}" mode="widthFix" class="{{vss.config.frontend_config.media_fixed.media_ent}}"></image>
</view>
</block>
<!-- 多图 -->
<block wx:elif="{{vss.value == 'many-images'}}">
<block wx:if="{{vss.config.view_list_show_style == 'rolling'}}">
<!-- 滚动 -->
<view class="module-list-rolling">
<scroll-view scroll-x>
<view wx:for="{{vss.config.data_list}}" wx:key="ik" class="item">
<view class="module-item {{vss.config.frontend_config.media_fixed.media_container_ent}}" style="width:{{((vss.config.view_list_show_style_value_arr || null) == null || (vss.config.view_list_show_style_value_arr.item_width || null) == null) ? 200 : vss.config.view_list_show_style_value_arr.item_width}}px;margin-left:{{((vss.config.view_list_show_style_value_arr || null) == null || (vss.config.view_list_show_style_value_arr.item_margin || null) == null || index == 0) ? 0 : vss.config.view_list_show_style_value_arr.item_margin}}px;{{vss.config.frontend_config.item_style}}{{vss.config.frontend_config.media_fixed.media_container_style}}" bindtap="layout_url_event" data-value="{{item.url || ''}}">
<image src="{{item.images}}" mode="widthFix" class="{{vss.config.frontend_config.media_fixed.media_ent}}"></image>
</view>
</view>
</scroll-view>
</view>
</block>
<block wx:elif="{{vss.config.view_list_show_style == 'list'}}">
<!-- 列表 -->
<view class="module-list-content {{vss.config.frontend_config.list_ent}}">
<view wx:for="{{vss.config.data_list}}" wx:key="ik" class="item">
<view class="module-item" style="{{vss.config.frontend_config.item_style}}">
<view class="{{vss.config.frontend_config.media_fixed.media_container_ent}}" style="{{vss.config.frontend_config.media_fixed.media_container_style}}" bindtap="layout_url_event" data-value="{{item.url || ''}}">
<image src="{{item.images}}" mode="widthFix" class="{{vss.config.frontend_config.media_fixed.media_ent}}"></image>
</view>
</view>
</view>
</view>
</block>
<block wx:else>
<!-- 默认轮播 -->
<swiper
indicator-dots="{{vss.config.data_list.length > 0}}"
indicator-color="{{indicator_color}}"
indicator-active-color="{{indicator_active_color}}"
autoplay="{{vss.config.data_list.length > 0}}"
circular="{{circular}}" style="{{vss.config.frontend_config.media_fixed.media_container_style}}">
<block wx:for="{{vss.config.data_list}}" wx:key="ik">
<swiper-item class="{{vss.config.frontend_config.media_fixed.media_container_ent}}" bindtap="layout_url_event" data-value="{{item.url || ''}}">
<image src="{{item.images}}" mode="aspectFill" class="{{vss.config.frontend_config.media_fixed.media_ent}}"></image>
</swiper-item>
</block>
</swiper>
</block>
</block>
<!-- 视频 -->
<block wx:elif="{{vss.value == 'video'}}">
<view class="module-video-content {{vss.config.frontend_config.media_fixed.media_container_ent}}" style="{{vss.config.frontend_config.media_fixed.media_container_style}}">
<video src="{{vss.config.video}}" autoplay="{{false}}" show-center-play-btn="{{true}}" controls="{{false}}" show-play-btn="{{false}}" enable-progress-gesture="{{false}}" show-fullscreen-btn="{{false}}" controls poster="{{(vss.config.content_images || null) != null ? vss.config.content_images : ''}}" class="{{vss.config.frontend_config.media_fixed.media_ent}}"></video>
</view>
</block>
<!-- 商品 -->
<block wx:elif="{{vss.value == 'goods'}}">
<block wx:if="{{vss.config.view_list_show_style == 'rolling'}}">
<!-- 滚动 -->
<view class="module-goods-content module-list-rolling">
<scroll-view scroll-x>
<view wx:for="{{vss.config.data_list}}" wx:key="ik" class="item">
<view class="module-item {{vss.config.frontend_config.media_fixed.media_container_ent}}" style="width:{{((vss.config.view_list_show_style_value_arr || null) == null || (vss.config.view_list_show_style_value_arr.item_width || null) == null) ? 200 : vss.config.view_list_show_style_value_arr.item_width}}px;margin-left:{{((vss.config.view_list_show_style_value_arr || null) == null || (vss.config.view_list_show_style_value_arr.item_margin || null) == null || index == 0) ? 0 : vss.config.view_list_show_style_value_arr.item_margin}}px;{{vss.config.frontend_config.item_style}}{{vss.config.frontend_config.media_fixed.media_container_style}}" bindtap="layout_url_event" data-value="{{item.goods_url || ''}}">
<image src="{{item.images}}" mode="widthFix" class="{{vss.config.frontend_config.media_fixed.media_ent}}"></image>
<view class="item-bottom">
<view class="module-title">{{item.title}}</view>
<view class="module-price">{{currency_symbol}}{{item.price}}</view>
</view>
</view>
</view>
</scroll-view>
</view>
</block>
<block wx:else>
<!-- 默认列表 -->
<view class="module-goods-content module-list-content {{vss.config.frontend_config.list_ent}}">
<view wx:for="{{vss.config.data_list}}" wx:key="ik" class="item">
<view class="module-item" style="{{vss.config.frontend_config.item_style}}">
<view class="{{vss.config.frontend_config.media_fixed.media_container_ent}}" style="{{vss.config.frontend_config.media_fixed.media_container_style}}" bindtap="layout_url_event" data-value="{{item.goods_url || ''}}">
<image src="{{item.images}}" mode="widthFix" class="{{vss.config.frontend_config.media_fixed.media_ent}}"></image>
<view class="item-bottom">
<view class="module-title">{{item.title}}</view>
<view class="module-price">{{currency_symbol}}{{item.price}}</view>
</view>
</view>
</view>
</view>
</view>
</block>
</block>
<!-- 标题 -->
<block wx:elif="{{vss.value == 'title'}}">
<view class="module-title-content">
<text class="title-main" style="{{vss.config.frontend_config.style_title_main}}">{{vss.config.title}}</text>
<text wx:if="{{(vss.config.title_vice || null) != null}}" class="title-vice" style="{{vss.config.frontend_config.style_title_vice}}">{{vss.config.title_vice}}</text>
<view wx:if="{{(vss.config.title_more || null) != null}}" class="more-content">
<view style="{{vss.config.frontend_config.style_title_more}}" bindtap="layout_url_event" data-value="{{vss.config.title_more_url || ''}}">{{vss.config.title_more}} ></view>
</view>
</view>
</block>
</view>
</view>
</view>
</block>
</view>
</block>
</view>
</view>
</block>
</block>
此差异已折叠。
......@@ -11,6 +11,7 @@ Page({
// 基础配置
currency_symbol: app.data.currency_symbol,
common_shop_notice: null,
home_index_floor_data_type: 0,
common_app_is_enable_search: 0,
common_app_is_enable_answer: 0,
common_app_is_header_nav_fixed: 0,
......@@ -44,6 +45,7 @@ Page({
this.setData({
currency_symbol: app.get_config('currency_symbol'),
common_shop_notice: app.get_config('config.common_shop_notice'),
home_index_floor_data_type: app.get_config('config.home_index_floor_data_type'),
common_app_is_enable_search: app.get_config('config.common_app_is_enable_search'),
common_app_is_enable_answer: app.get_config('config.common_app_is_enable_answer'),
common_app_is_header_nav_fixed: app.get_config('config.common_app_is_header_nav_fixed'),
......
......@@ -7,6 +7,7 @@
"usingComponents": {
"component-quick-nav": "/components/quick-nav/quick-nav",
"component-icon-nav": "/components/icon-nav/icon-nav",
"component-banner": "/components/slider/slider"
"component-banner": "/components/slider/slider",
"component-layout": "/components/layout/layout"
}
}
\ No newline at end of file
......@@ -12,11 +12,14 @@
<view class="tips">{{common_shop_notice}}</view>
</view>
<!-- 轮播 -->
<component-banner prop-data="{{banner_list}}"></component-banner>
<!-- 拖拽模式下不展示 -->
<block wx:if="{{home_index_floor_data_type != 2}}">
<!-- 轮播 -->
<component-banner prop-data="{{banner_list}}"></component-banner>
<!-- 导航 -->
<component-icon-nav prop-data="{{navigation}}"></component-icon-nav>
<!-- 导航 -->
<component-icon-nav prop-data="{{navigation}}"></component-icon-nav>
</block>
<!-- 限时秒杀 -->
<view wx:if="{{plugins_limitedtimediscount_is_valid == 1}}">
......@@ -25,39 +28,47 @@
</view>
<!-- 楼层数据 -->
<block wx:if="{{data_list.length > 0}}">
<view wx:for="{{data_list}}" wx:key="key" wx:for-item="floor" class="floor spacing-mb">
<view class="spacing-nav-title">
<text class="line"></text>
<text class="text-wrapper">{{floor.name}}</text>
</view>
<view class="floor-list">
<view class="word" style="background-color:{{floor.bg_color || '#eaeaea'}}">
<view wx:if="{{floor.items.length > 0}}">
<block wx:for="{{floor.items}}" wx:key="ck" wx:for-index="icx" wx:for-item="icv">
<navigator class="word-icon" url="/pages/goods-search/goods-search?category_id={{icv.id}}" hover-class="none">
{{icv.name}}
</navigator>
</block>
</view>
<view wx:if="{{floor.describe.length > 0}}" class="vice-name">{{floor.describe}}</view>
<navigator url="/pages/goods-search/goods-search?category_id={{floor.id}}" hover-class="none">
<image wx:if="{{floor.big_images.length > 0}}" src="{{floor.big_images}}" mode="aspectFit" class="dis-block" />
</navigator>
<block wx:if="{{(data_list || nul) != null && data_list.length > 0}}">
<!-- 数据模式0,1自动+手动、2拖拽 -->
<block wx:if="{{home_index_floor_data_type == 2}}">
<!-- 引入拖拽数据模块 -->
<component-layout prop-data="{{data_list}}"></component-layout>
</block>
<block wx:else>
<!-- 自动+手动 -->
<view wx:for="{{data_list}}" wx:key="key" wx:for-item="floor" class="floor spacing-mb">
<view class="spacing-nav-title">
<text class="line"></text>
<text class="text-wrapper">{{floor.name}}</text>
</view>
<view class="goods-list" wx:if="{{floor.goods.length > 0}}">
<view wx:for="{{floor.goods}}" wx:key="keys" wx:for-item="goods" class="goods bg-white">
<navigator url="/pages/goods-detail/goods-detail?goods_id={{goods.id}}" hover-class="none">
<image src="{{goods.images}}" mode="aspectFit" />
<view class="goods-base">
<view class="goods-title multi-text">{{goods.title}}</view>
<view class="sales-price">{{currency_symbol}}{{goods.min_price}}</view>
</view>
<view class="floor-list">
<view class="word" style="background-color:{{floor.bg_color || '#eaeaea'}}">
<view wx:if="{{floor.items.length > 0}}">
<block wx:for="{{floor.items}}" wx:key="ck" wx:for-index="icx" wx:for-item="icv">
<navigator class="word-icon" url="/pages/goods-search/goods-search?category_id={{icv.id}}" hover-class="none">
{{icv.name}}
</navigator>
</block>
</view>
<view wx:if="{{floor.describe.length > 0}}" class="vice-name">{{floor.describe}}</view>
<navigator url="/pages/goods-search/goods-search?category_id={{floor.id}}" hover-class="none">
<image wx:if="{{floor.big_images.length > 0}}" src="{{floor.big_images}}" mode="aspectFit" class="dis-block" />
</navigator>
</view>
<view class="goods-list" wx:if="{{floor.goods.length > 0}}">
<view wx:for="{{floor.goods}}" wx:key="keys" wx:for-item="goods" class="goods bg-white">
<navigator url="/pages/goods-detail/goods-detail?goods_id={{goods.id}}" hover-class="none">
<image src="{{goods.images}}" mode="aspectFit" />
<view class="goods-base">
<view class="goods-title multi-text">{{goods.title}}</view>
<view class="sales-price">{{currency_symbol}}{{goods.min_price}}</view>
</view>
</navigator>
</view>
</view>
</view>
</view>
</view>
</block>
</block>
<!-- 底部购买记录 -->
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册