作者 李忠强

更新

正在显示 49 个修改的文件 包含 3846 行增加0 行删除

要显示太多修改。

为保证性能只显示 49 of 49+ 个文件。

{
"directory": "public/assets/libs",
"ignoredDependencies": [
"es6-promise",
"file-saver",
"html2canvas",
"jspdf",
"jspdf-autotable"
]
}
\ No newline at end of file
... ...
[app]
debug = false
trace = false
[database]
hostname = 127.0.0.1
database = fastadmin
username = root
password = root
hostport = 3306
prefix = fa_
... ...
/runtime/*
/public/uploads/*
.idea
composer.lock
*.log
*.css.map
!.gitkeep
.env
.svn
.vscode
node_modules
... ...
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "{}" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright 2017 Karson
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
... ...
FastAdmin是一款基于ThinkPHP+Bootstrap的极速后台开发框架。
## 主要特性
* 基于`Auth`验证的权限管理系统
* 支持无限级父子级权限继承,父级的管理员可任意增删改子级管理员及权限设置
* 支持单管理员多角色
* 支持管理子级数据或个人数据
* 强大的一键生成功能
* 一键生成CRUD,包括控制器、模型、视图、JS、语言包、菜单、回收站等
* 一键压缩打包JS和CSS文件,一键CDN静态资源部署
* 一键生成控制器菜单和规则
* 一键生成API接口文档
* 完善的前端功能组件开发
* 基于`AdminLTE`二次开发
* 基于`Bootstrap`开发,自适应手机、平板、PC
* 基于`RequireJS`进行JS模块管理,按需加载
* 基于`Less`进行样式开发
* 强大的插件扩展功能,在线安装卸载升级插件
* 通用的会员模块和API模块
* 共用同一账号体系的Web端会员中心权限验证和API接口会员权限验证
* 二级域名部署支持,同时域名支持绑定到应用插件
* 多语言支持,服务端及客户端支持
* 支持大文件分片上传、剪切板粘贴上传、拖拽上传,进度条显示,图片上传前压缩
* 支持表格固定列、固定表头、跨页选择、Excel导出、模板渲染等功能
* 强大的第三方应用模块支持([CMS](https://www.fastadmin.net/store/cms.html)[博客](https://www.fastadmin.net/store/blog.html)[知识付费问答](https://www.fastadmin.net/store/ask.html)[在线投票系统](https://www.fastadmin.net/store/vote.html)[B2C商城](https://www.fastadmin.net/store/shopro.html)[B2B2C商城](https://www.fastadmin.net/store/wanlshop.html))
* 支持CMS、博客、知识付费问答无缝整合[Xunsearch全文搜索](https://www.fastadmin.net/store/xunsearch.html)
* 第三方小程序支持([CMS小程序](https://www.fastadmin.net/store/cms.html)[预订小程序](https://www.fastadmin.net/store/ball.html)[问答小程序](https://www.fastadmin.net/store/ask.html)[点餐小程序](https://www.fastadmin.net/store/unidrink.html)[B2C小程序](https://www.fastadmin.net/store/shopro.html)[B2B2C小程序](https://www.fastadmin.net/store/wanlshop.html)[博客小程序](https://www.fastadmin.net/store/blog.html))
* 整合第三方短信接口(阿里云、腾讯云短信)
* 无缝整合第三方云存储(七牛云、阿里云OSS、又拍云)功能,支持云储存分片上传
* 第三方富文本编辑器支持(Summernote、Kindeditor、百度编辑器)
* 第三方登录(QQ、微信、微博)整合
* 第三方支付(微信、支付宝)无缝整合,微信支持PC端扫码支付
* 丰富的插件应用市场
## 安装使用
https://doc.fastadmin.net
## 在线演示
https://demo.fastadmin.net
用户名:admin
密 码:123456
提 示:演示站数据无法进行修改,请下载源码安装体验全部功能
## 界面截图
![控制台](https://images.gitee.com/uploads/images/2020/0929/202947_8db2d281_10933.gif "控制台")
## 问题反馈
在使用中有任何问题,请使用以下联系方式联系我们
交流社区: https://ask.fastadmin.net
QQ群: [636393962](https://jq.qq.com/?_wv=1027&k=487PNBb)() [708784003](https://jq.qq.com/?_wv=1027&k=5ObjtwM)(满) [964776039](https://jq.qq.com/?_wv=1027&k=59qjU2P)(3群) [749803490](https://jq.qq.com/?_wv=1027&k=5tczi88)(满) [767103006](https://jq.qq.com/?_wv=1027&k=5Z1U751)() [675115483](https://jq.qq.com/?_wv=1027&k=54I6mts)(6群)
Github: https://github.com/karsonzhang/fastadmin
Gitee: https://gitee.com/karson/fastadmin
## 特别鸣谢
感谢以下的项目,排名不分先后
ThinkPHP:http://www.thinkphp.cn
AdminLTE:https://adminlte.io
Bootstrap:http://getbootstrap.com
jQuery:http://jquery.com
Bootstrap-table:https://github.com/wenzhixin/bootstrap-table
Nice-validator: https://validator.niceue.com
SelectPage: https://github.com/TerryZ/SelectPage
Layer: https://layer.layui.com
DropzoneJS: https://www.dropzonejs.com
## 版权信息
FastAdmin遵循Apache2开源协议发布,并提供免费使用。
本项目包含的第三方源码和二进制文件之版权信息另行标注。
版权所有Copyright © 2017-2020 by FastAdmin (https://www.fastadmin.net)
All rights reserved。
... ...
deny from all
\ No newline at end of file
... ...
{"license":"regular","licenseto":"10789","licensekey":"PHeINvSCEwOx3L0u Ug9MtNwgWslH6i\/j8tZnAHVQnkjzpoSX5aUGQIkBcIg=","menus":["litestore","litestore\/litestorenews","litestore\/litestorenews\/index","litestore\/litestorenews\/add","litestore\/litestorenews\/edit","litestore\/litestorenews\/del","litestore\/litestorenews\/multi","litestore\/litestoregoods","litestore\/litestoregoods\/index","litestore\/litestoregoods\/add","litestore\/litestoregoods\/edit","litestore\/litestoregoods\/del","litestore\/litestoregoods\/multi","litestore\/litestoregoods\/addSpec","litestore\/litestoregoods\/addSpecValue","litestore\/litestorecategory","litestore\/litestorecategory\/index","litestore\/litestorecategory\/add","litestore\/litestorecategory\/edit","litestore\/litestorecategory\/del","litestore\/litestorecategory\/multi","litestore\/litestorefreight","litestore\/litestorefreight\/index","litestore\/litestorefreight\/add","litestore\/litestorefreight\/edit","litestore\/litestorefreight\/del","litestore\/litestorefreight\/multi","litestore\/litestoreorder","litestore\/litestoreorder\/index","litestore\/litestoreorder\/add","litestore\/litestoreorder\/edit","litestore\/litestoreorder\/del","litestore\/litestoreorder\/multi","litestore\/litestoreorder\/detail"],"files":["application\\admin\\controller\\litestore\\Litestorecategory.php","application\\admin\\controller\\litestore\\Litestorefreight.php","application\\admin\\controller\\litestore\\Litestoregoods.php","application\\admin\\controller\\litestore\\Litestorenews.php","application\\admin\\controller\\litestore\\Litestoreorder.php","application\\admin\\lang\\zh-cn\\litestore\\litestorecategory.php","application\\admin\\lang\\zh-cn\\litestore\\litestorefreight.php","application\\admin\\lang\\zh-cn\\litestore\\litestoregoods.php","application\\admin\\lang\\zh-cn\\litestore\\litestorenews.php","application\\admin\\lang\\zh-cn\\litestore\\litestoreorder.php","application\\admin\\model\\litestore\\Litestorearea.php","application\\admin\\model\\litestore\\Litestorecategory.php","application\\admin\\model\\litestore\\Litestorefreight.php","application\\admin\\model\\litestore\\Litestorefreightrule.php","application\\admin\\model\\litestore\\Litestoregoods.php","application\\admin\\model\\litestore\\Litestoregoodsspec.php","application\\admin\\model\\litestore\\Litestoregoodsspecrel.php","application\\admin\\model\\litestore\\Litestorenews.php","application\\admin\\model\\litestore\\Litestoreorder.php","application\\admin\\model\\litestore\\Litestoreorderaddress.php","application\\admin\\model\\litestore\\Litestoreordergoods.php","application\\admin\\model\\litestore\\Litestorespec.php","application\\admin\\model\\litestore\\Litestorespecvalue.php","application\\admin\\validate\\litestore\\Litestorecategory.php","application\\admin\\validate\\litestore\\Litestorefreight.php","application\\admin\\validate\\litestore\\Litestoregoods.php","application\\admin\\validate\\litestore\\Litestorenews.php","application\\admin\\validate\\litestore\\Litestoreorder.php","application\\admin\\view\\litestore\\litestorecategory\\add.html","application\\admin\\view\\litestore\\litestorecategory\\edit.html","application\\admin\\view\\litestore\\litestorecategory\\index.html","application\\admin\\view\\litestore\\litestorefreight\\add.html","application\\admin\\view\\litestore\\litestorefreight\\edit.html","application\\admin\\view\\litestore\\litestorefreight\\index.html","application\\admin\\view\\litestore\\litestoregoods\\add.html","application\\admin\\view\\litestore\\litestoregoods\\edit.html","application\\admin\\view\\litestore\\litestoregoods\\index.html","application\\admin\\view\\litestore\\litestoregoods\\spec_many_template.html","application\\admin\\view\\litestore\\litestorenews\\add.html","application\\admin\\view\\litestore\\litestorenews\\edit.html","application\\admin\\view\\litestore\\litestorenews\\index.html","application\\admin\\view\\litestore\\litestoreorder\\add.html","application\\admin\\view\\litestore\\litestoreorder\\detail.html","application\\admin\\view\\litestore\\litestoreorder\\edit.html","application\\admin\\view\\litestore\\litestoreorder\\index.html","public\\assets\\js\\backend\\litestore\\litestorecategory.js","public\\assets\\js\\backend\\litestore\\litestorefreight.js","public\\assets\\js\\backend\\litestore\\litestoregoods.js","public\\assets\\js\\backend\\litestore\\litestorenews.js","public\\assets\\js\\backend\\litestore\\litestoreorder.js","public\\assets\\addons\\litestore\\css\\litestorefeight.css","public\\assets\\addons\\litestore\\css\\litestoregoods.css","public\\assets\\addons\\litestore\\js\\litestoreart-template.js","public\\assets\\addons\\litestore\\js\\litestorefreight_delivery.js","public\\assets\\addons\\litestore\\js\\litestorefreight_regionalChoice.js","public\\assets\\addons\\litestore\\js\\litestoregoods.js","public\\assets\\addons\\litestore\\vue-mobile\\css\\app.6972b888.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-0e455c8c.e227af02.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-291f569a.86ff993e.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-32ea458a.40817dda.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-3cd027a4.90025fe8.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-585ea9bb.65e9d18a.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-683fd508.85c45e3b.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-72fb80f6.a6c6ff5d.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-7c352045.1d8301ee.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-854219ba.f049a183.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-a1e0e73c.d630cf18.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-c01442dc.8e8beb53.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-c0734d00.1f5b6216.css","public\\assets\\addons\\litestore\\vue-mobile\\css\\chunk-vendors.5858c103.css","public\\assets\\addons\\litestore\\vue-mobile\\favicon.ico","public\\assets\\addons\\litestore\\vue-mobile\\img\\no-data.edbbd919.png","public\\assets\\addons\\litestore\\vue-mobile\\js\\app.76dfabef.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\app.76dfabef.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-0e455c8c.e6bc1143.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-0e455c8c.e6bc1143.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-291f569a.3df6760f.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-291f569a.3df6760f.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-32ea458a.6875721f.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-32ea458a.6875721f.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-3cd027a4.251a00d9.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-3cd027a4.251a00d9.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-585ea9bb.6019f519.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-585ea9bb.6019f519.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-683fd508.67efcbec.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-683fd508.67efcbec.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-72fb80f6.0fb8fbea.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-72fb80f6.0fb8fbea.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-76f88e57.b23592ca.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-76f88e57.b23592ca.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-7c352045.458f60ce.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-7c352045.458f60ce.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-854219ba.87b21345.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-854219ba.87b21345.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-a1e0e73c.02529220.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-a1e0e73c.02529220.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-c01442dc.24c8627c.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-c01442dc.24c8627c.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-c0734d00.0ca64864.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-c0734d00.0ca64864.js.map","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-vendors.7b616be7.js","public\\assets\\addons\\litestore\\vue-mobile\\js\\chunk-vendors.7b616be7.js.map"]}
\ No newline at end of file
... ...
<?php
namespace addons\litestore;
use app\common\library\Menu;
use think\Addons;
/**
* 插件
*/
class Litestore extends Addons
{
/**
* 插件安装方法
* @return bool
*/
public function install()
{
$menu = [
[
'name' => 'litestore',
'title' => '移动端商城',
'icon' => 'fa fa-shopping-basket',
'sublist' => [
[
'name' => 'litestore/litestorenews',
'title' => '首页banner',
'icon' => 'fa fa-image',
'sublist' => [
['name' => 'litestore/litestorenews/index', 'title' => '查看'],
['name' => 'litestore/litestorenews/add', 'title' => '添加'],
['name' => 'litestore/litestorenews/edit', 'title' => '修改'],
['name' => 'litestore/litestorenews/del', 'title' => '删除'],
['name' => 'litestore/litestorenews/multi', 'title' => '批量更新'],
]
],
[
'name' => 'litestore/litestoregoods',
'title' => '商品设置',
'icon' => 'fa fa-gift',
'sublist' => [
['name' => 'litestore/litestoregoods/index', 'title' => '查看'],
['name' => 'litestore/litestoregoods/add', 'title' => '添加'],
['name' => 'litestore/litestoregoods/edit', 'title' => '修改'],
['name' => 'litestore/litestoregoods/del', 'title' => '删除'],
['name' => 'litestore/litestoregoods/multi', 'title' => '批量更新'],
['name' => 'litestore/litestoregoods/addSpec', 'title' => '增加规格'],
['name' => 'litestore/litestoregoods/addSpecValue', 'title' => '增加规格值'],
]
],
[
'name' => 'litestore/litestorecategory',
'title' => '商品分类',
'icon' => 'fa fa-th',
'sublist' => [
['name' => 'litestore/litestorecategory/index', 'title' => '查看'],
['name' => 'litestore/litestorecategory/add', 'title' => '添加'],
['name' => 'litestore/litestorecategory/edit', 'title' => '修改'],
['name' => 'litestore/litestorecategory/del', 'title' => '删除'],
['name' => 'litestore/litestorecategory/multi', 'title' => '批量更新'],
]
],
[
'name' => 'litestore/litestorefreight',
'title' => '运费模板设置',
'icon' => 'fa fa-train',
'sublist' => [
['name' => 'litestore/litestorefreight/index', 'title' => '查看'],
['name' => 'litestore/litestorefreight/add', 'title' => '添加'],
['name' => 'litestore/litestorefreight/edit', 'title' => '修改'],
['name' => 'litestore/litestorefreight/del', 'title' => '删除'],
['name' => 'litestore/litestorefreight/multi', 'title' => '批量更新'],
]
],
[
'name' => 'litestore/litestoreorder',
'title' => '订单管理',
'icon' => 'fa fa-tasks',
'sublist' => [
['name' => 'litestore/litestoreorder/index', 'title' => '查看'],
['name' => 'litestore/litestoreorder/add', 'title' => '添加'],
['name' => 'litestore/litestoreorder/edit', 'title' => '修改'],
['name' => 'litestore/litestoreorder/del', 'title' => '删除'],
['name' => 'litestore/litestoreorder/multi', 'title' => '批量更新'],
['name' => 'litestore/litestoreorder/detail', 'title' => '订单详情'],
]
],
]
]
];
Menu::create($menu);
return true;
}
/**
* 插件卸载方法
* @return bool
*/
public function uninstall()
{
Menu::delete('litestore');
return true;
}
/**
* 插件启用方法
* @return bool
*/
public function enable()
{
Menu::enable('litestore');
return true;
}
/**
* 插件禁用方法
* @return bool
*/
public function disable()
{
Menu::disable('litestore');
return true;
}
public function GetCfg(){
return $this->getConfig();
}
}
... ...
require.config({
paths: {
'litestorefreight_delivery': '../addons/litestore/js/litestorefreight_delivery',
'litestorefreight_regionalChoice': '../addons/litestore/js/litestorefreight_regionalChoice',
'litestoregoods': '../addons/litestore/js/litestoregoods',
},
});
\ No newline at end of file
... ...
<?php
return array (
0 =>
array (
'name' => 'LiteName',
'title' => '小程序名称',
'type' => 'string',
'content' =>
array (
),
'value' => 'Fa商城微信小程序',
'rule' => 'required',
'msg' => '',
'tip' => '小程序顶部展示标题',
'ok' => '',
'extend' => '',
),
1 =>
array (
'name' => 'TopTextColor',
'title' => '小程序标题颜色',
'type' => 'radio',
'content' =>
array (
10 => '黑色',
20 => '白色',
),
'value' => '20',
'rule' => 'required',
'msg' => '',
'tip' => '顶部导航文字颜色',
'ok' => '',
'extend' => '',
),
2 =>
array (
'name' => 'BackgroundColor',
'title' => '小程序导航',
'type' => 'color',
'content' =>
array (
),
'value' => '#6d189e',
'rule' => 'required',
'msg' => '',
'tip' => '顶部背景色',
'ok' => '',
'extend' => '',
),
3 =>
array (
'name' => 'Indexotice',
'title' => '首页通知栏',
'type' => 'string',
'content' =>
array (
),
'value' => '欢迎使用Fastadmin移动端商城插件,在这里您将得到最优质的体验...',
'rule' => '',
'msg' => '',
'tip' => '首页顶部通知栏文字',
'ok' => '',
'extend' => '',
),
4 =>
array (
'name' => 'AppID',
'title' => '小程序ID',
'type' => 'string',
'content' =>
array (
),
'value' => 'wx3XXXXXXf2',
'rule' => 'required',
'msg' => '',
'tip' => '关联小程序AppID',
'ok' => '',
'extend' => '',
),
5 =>
array (
'name' => 'AppSecret',
'title' => '小程序密钥',
'type' => 'string',
'content' =>
array (
),
'value' => '879eXXXXXXXXXXXa',
'rule' => 'required',
'msg' => '',
'tip' => '关联小程序AppSecret',
'ok' => '',
'extend' => '',
),
6 =>
array (
'name' => 'MCHID',
'title' => '小程序商户号',
'type' => 'string',
'content' =>
array (
),
'value' => '1449X02XXX',
'rule' => '',
'msg' => '',
'tip' => '小程序的微信支付商户号',
'ok' => '',
'extend' => '',
),
7 =>
array (
'name' => 'APIKEY',
'title' => '小程序支付密钥',
'type' => 'string',
'content' =>
array (
),
'value' => 'yuXXXXXXXXXXXXjiule',
'rule' => '',
'msg' => '',
'tip' => '小程序的微信支付密钥',
'ok' => '',
'extend' => '',
),
8 =>
array (
'name' => 'MCHIDGZH',
'title' => '公众号商户号',
'type' => 'string',
'content' =>
array (
),
'value' => '14XXXXXXXXX2',
'rule' => '',
'msg' => '',
'tip' => '公众号的微信支付商户号',
'ok' => '',
'extend' => '',
),
9 =>
array (
'name' => 'APIKEYGZH',
'title' => '公众号支付密钥',
'type' => 'string',
'content' =>
array (
),
'value' => 'yuXXXXXXXXXXXXXXXnjiule',
'rule' => '',
'msg' => '',
'tip' => '公众号的微信支付密钥',
'ok' => '',
'extend' => '',
),
10 =>
array (
'name' => 'freight',
'title' => '运费组合设置',
'type' => 'radio_text',
'content' =>
array (
10 => '叠加',
20 => '以最低运费结算',
30 => '以最高运费结算',
),
'value' => '10',
'rule' => 'required',
'msg' => '',
'tip' =>
array (
10 => '订单中有多个运费时,取每个商品的运费之和为总运费',
20 => '订单中有多个运费时,取订单中运费最少的商品的运费为总运费',
30 => '订单中有多个运费时,取订单中运费最多的商品的运费为总运费',
),
'ok' => '',
'extend' => '',
),
11 =>
array (
'name' => 'ShuoMing',
'title' => '插件配置说明',
'type' => 'radio',
'content' =>
array (
10 => '公众号请点击这里查看说明',
),
'value' => '10',
'rule' => 'required',
'msg' => '',
'tip' => '公众号的用户关联的AppSecret和AppSecret,请在第三方登录插件中,配置。',
'ok' => '',
'extend' => '',
),
);
... ...
<?php
namespace addons\litestore\controller;
use think\addons\Controller;
class Index extends Controller
{
public function index()
{
return $this->fetch('vue-mobile');
}
}
... ...
<?php
namespace addons\litestore\controller\api;
use app\common\controller\Api;
use addons\third\model\Third;
use EasyWeChat\Factory;
class Aboutwechat extends Api
{
protected $noNeedRight = ['*'];
public function get_PhoneNum(){
$encryptedData = $this->request->post("encryptedData");
$iv = $this->request->post("iv");
$third = Third::where(['user_id' => $this->auth->id, 'platform' => 'wxapp'])->find();
$sessionKey = $third['access_token'];
$config = get_addon_config('litestore');
$options = [
'app_id' => $config['AppID'],
'secret' => $config['AppSecret'],
// 下面为可选项
// 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
'response_type' => 'array',
'log' => [
'level' => 'debug',
'file' => __DIR__.'/wechat.log',
],
];
$app = Factory::miniProgram($options);
$this->miniProgram = $app;
$this->success('', $this->miniProgram->encryptor->decryptData($sessionKey, $iv, $encryptedData));
}
}
... ...
<?php
namespace addons\litestore\controller\api;
use app\common\controller\Api;
use addons\litestore\model\Litestoreadress;
class Adress extends Api
{
protected $noNeedLogin = [];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
$this->user_id = $this->auth->id;
$this->model = new Litestoreadress;
}
public function lists()
{
$list = $this->model->getList($this->user_id);
return $this->success('',['list' => $list]);
}
public function add()
{
if ($this->model->add($this->user_id, $this->request->post())) {
return $this->success('添加成功');
}
return $this->error('添加失败');
}
public function setdefault(){
if ($this->model->setdefault($this->user_id,$this->request->request('id'))){
return $this->success('设置成功');
}
return $this->error('设置失败');
}
public function del()
{
if ($this->model->del($this->request->request('id'))) {
return $this->success('删除成功');
}
return $this->error('删除失败');
}
public function detail(){
$id = $this->request->request('id');
$detail = $this->model->detail($this->user_id,$id);
$rArea = array_values($detail['Area']);
return $this->success('成功',compact('detail', 'rArea'));
}
public function edit(){
$id = $this->request->request('id');
$detail = $this->model->detail($this->user_id,$id);
if ($detail->edit($this->request->post())) {
return $this->success('成功');
}
return $this->error('更新失败');
}
}
\ No newline at end of file
... ...
<?php
namespace addons\litestore\controller\api;
use app\common\controller\Api;
use app\common\library\Auth;
use addons\litestore\model\CacheCart;
class Cart extends Api
{
protected $noNeedLogin = [];
protected $noNeedRight = ['*'];
//设置返回的会员字段
protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'score', 'level', 'bio', 'balance','group_id'];
public function _initialize()
{
parent::_initialize();
Auth::instance()->setAllowFields($this->allowFields);
$this->user_id = $this->auth->id;
$this->model = new CacheCart($this->user_id);
}
/* 加入购物车*/
public function add()
{
$rq_data = $this->request->request();
$goods_id = $rq_data['goods_id'];
$goods_num = $rq_data['goods_num'];
$goods_sku_id = $rq_data['goods_sku_id'];
if (!$this->model->add($goods_id, $goods_num, $goods_sku_id)) {
return $this->error($this->model->getError() ?: '加入购物车失败');
}
$total_num = $this->model->getTotalNum();
return $this->success('加入购物车成功',['cart_total_num' => $total_num]);
}
//获得购物车商品数量
public function getTotalNum(){
$total_num = $this->model->getTotalNum();
return $this->success('',['cart_total_num' => $total_num]);
}
public function getlists()
{
return $this->success('',$this->model->getList($this->user_id));
}
public function sub(){
$rq_data = $this->request->request();
$goods_id = $rq_data['goods_id'];
$goods_sku_id = $rq_data['goods_sku_id'];
$this->model->sub($goods_id, $goods_sku_id);
return $this->success();
}
public function delete()
{
$rq_data = $this->request->request();
$goods_id = $rq_data['goods_id'];
$goods_sku_id = $rq_data['goods_sku_id'];
$this->model->delete($goods_id, $goods_sku_id);
return $this->success();
}
}
... ...
<?php
namespace addons\litestore\controller\api;
use app\common\controller\Api;
use addons\litestore\model\Litestorecategory;
use fast\Tree;
class Category extends Api
{
protected $noNeedLogin = ['*'];
public function _initialize()
{
parent::_initialize();
}
public function Showlist(){
$tree = Tree::instance();
$tree->init(collection(litestorecategory::order('weigh desc,id desc')->select())->toArray(), 'pid');
$categorydata = $tree->getTreeArray(0);
foreach ($categorydata as $index => $item) {
foreach ($item['childlist'] as $indexImg => $itemImg) {
$categorydata[$index]['childlist'][$indexImg]['ImageFrist'] = cdnurl($itemImg['image'], true);
}
}
$this->success('', [
'categorydata' => $categorydata
]);
}
}
\ No newline at end of file
... ...
<?php
namespace addons\litestore\controller\api;
use app\common\controller\Api;
use addons\litestore\model\Wxlitestoregoods;
use addons\litestore\model\Litestoregoodsspec;
class Goods extends Api
{
protected $noNeedLogin = ['*'];
public function _initialize()
{
parent::_initialize();
}
public function detail()
{
$goods_id = $this->request->request('goods_id');
// 商品详情
$detail = Wxlitestoregoods::detail($goods_id);
$imgs=[];
foreach (explode(",",$detail['images']) as $index => $item) {
$imgs[] = cdnurl($item, true);
}
$detail['imgs_url'] = $imgs;
if (!$detail || $detail['goods_status'] !== '10') {
$this->error('很抱歉,商品信息不存在或已下架');
}
// 规格信息
$specData = $detail['spec_type'] === '20' ? $detail->getManySpecData($detail['spec_rel'], $detail['spec']) : null;
// 这里对规格的img格式化
if($specData!=null){
foreach($specData['spec_list'] as $index => $item){
$specData['spec_list'][$index]["form"]['imgshow'] = $specData['spec_list'][$index]["form"]['spec_image']==='' ? null:cdnurl($specData['spec_list'][$index]["form"]['spec_image'], true);
}
}
$this->success('', [
'detail' => $detail,
'specData' => $specData
]);
}
public function category_list(){
$categoryid = $this->request->request('id');
$page = $this->request->request('page');
$sortType = $this->request->request('types');
$rename = $this->request->request('name');
// 筛选条件
$filter = [];
if($categoryid==-1){
$filter['goods_name'] = ['like', '%' . trim($rename) . '%'];
}else{
$filter['category_id'] = $categoryid;
}
$filter['goods_status'] = '10';
$filter['is_delete'] = '0';
// 排序规则
$sort = [];
if ($sortType === 'normal') {
$sort = ['goods_sort'=> 'desc', 'goods_id' => 'desc'];
} elseif ($sortType === 'sales') {
$sort = ['goods_sales' => 'desc'];
} elseif ($sortType === 'price') {
$sort = ['goods_min_price' => 'asc'];
}
// 商品表名称
$model_temp = new Wxlitestoregoods();
$tableName = $model_temp->getTable();
// 多规格商品 最高价与最低价
$GoodsSpec = new Litestoregoodsspec();
$minPriceSql = $GoodsSpec->field(['MIN(goods_price)'])
->where('goods_id', 'EXP', "= `$tableName`.`goods_id`")->buildSql();
$maxPriceSql = $GoodsSpec->field(['MAX(goods_price)'])
->where('goods_id', 'EXP', "= `$tableName`.`goods_id`")->buildSql();
$listdata = $model_temp->field(['*', '(sales_initial + sales_actual) as goods_sales',
"$minPriceSql AS goods_min_price",
"$maxPriceSql AS goods_max_price"
])->with(['spec'])->where($filter)->order($sort)
->paginate(8, false, [ 'page' => $page ]);
$blistdatarList = [];
foreach ($listdata as $index => $item) {
$blistdatarList[] = ['image' => cdnurl(explode(",",$item['images'])[0], true), 'goods_name' => $item['goods_name'],
'id'=> $item['goods_id'],'goods_min_price'=>$item['goods_min_price'],'goods_max_price'=>$item['goods_max_price'],'goods_sales'=>$item['goods_sales']];
}
$pagedata = $listdata;
$this->success('', [
'listdata' => $blistdatarList,
'pagedata' => $pagedata,
]);
}
}
\ No newline at end of file
... ...
<?php
namespace addons\litestore\controller\api;
use app\common\controller\Api;
use addons\litestore\model\Wxlitestoregoods;
use addons\litestore\model\Litestorenews;
class Index extends Api
{
protected $noNeedLogin = ['*'];
public function _initialize()
{
parent::_initialize();
}
public function index()
{
$Temp_litestoregoods = new Wxlitestoregoods();
$banner = new Litestorenews();
$bannerdata = $banner->where('status', 'normal')->order('updatetime', 'desc')->limit(10)->select();
$bannerList = [];
foreach ($bannerdata as $index => $item) {
$bannerList[] = ['image' => cdnurl($item['image'], true), 'title' => $item['title'],'id'=> $item['id']];
}
$NewList = $Temp_litestoregoods->getNewList();
foreach ($NewList as $index => $item) {
$NewList[$index]['ImageFrist'] = cdnurl(explode(",",$item['images'])[0], true);
}
$Randomlist = $Temp_litestoregoods->getRandom8();
foreach ($Randomlist as $index => $item) {
$Randomlist[$index]['ImageFrist'] = cdnurl(explode(",",$item['images'])[0], true);
}
$this->success('', [
'NewList' => $NewList,
'Randomlist' => $Randomlist,
'bannerlist' => $bannerList
]);
}
public function getnew(){
$new_id = $this->request->request('new_id');
$newdata = Litestorenews::get($new_id);
$newdata['image'] = cdnurl($newdata['image'], true);
$newdata['updatetime'] = datetime($newdata['updatetime']);
$this->success('', [
'newdata' => $newdata
]);
}
}
... ...
<?php
namespace addons\litestore\controller\api;
use app\common\controller\Api;
use addons\litestore\model\Litestoreorder;
use addons\third\model\Third;
use EasyWeChat\Factory as WXPAY_APP;
class Order extends Api
{
protected $noNeedRight = ['*'];
protected $noNeedLogin = ['callback_for_wxapp','callback_for_wxgzh'];
public function _initialize()
{
parent::_initialize();
$this->user_id = $this->auth->id;
$this->model = new Litestoreorder;
}
public function buyNow()
{
$goods_id = $this->request->request('goods_id');
$goods_num = $this->request->request('goods_num');
$goods_sku_id = $this->request->request('goods_sku_id');
$order = $this->model->getBuyNow($this->user_id, $goods_id, $goods_num, $goods_sku_id);
return $this->success('获取成功',$order);
}
public function buyNow_pay(){
$goods_id = $this->request->request('goods_id');
$goods_num = $this->request->request('goods_num');
$goods_sku_id = $this->request->request('goods_sku_id');
$order = $this->model->getBuyNow($this->user_id, $goods_id, $goods_num, $goods_sku_id);
if ($this->model->hasError()) {
return $this->error($this->model->getError());
}
// 创建订单
if ($this->model->order_add($this->user_id, $order)) {
// 发起微信支付
if($this->request->request('type')&&$this->request->request('type')=='gzh'){
$this->init_wx_pay_for_gzh(true);
$this->make_wx_pay('wechat');
}else{
$this->init_wx_pay_for_wxapp();
$this->make_wx_pay('wxapp');
}
}
$error = $this->model->getError() ?: '订单创建失败';
return $this->error($error);
}
public function Get_order_num(){
$NoPayNum = $this->model->where(['user_id' => $this->user_id, 'pay_status' => '10', 'freight_status' => '10', 'order_status' => '10', 'receipt_status' => '10'])->count();
$NoFreightNum = $this->model->where(['user_id' => $this->user_id, 'pay_status' => '20', 'freight_status' => '10', 'order_status' => '10', 'receipt_status' => '10'])->count();
$NoReceiptNum = $this->model->where(['user_id' => $this->user_id, 'pay_status' => '20', 'freight_status' => '20', 'order_status' => '10', 'receipt_status' => '10'])->count();
return $this->success('',['NoPayNum'=>$NoPayNum,'NoFreightNum'=>$NoFreightNum,'NoReceiptNum'=>$NoReceiptNum]);
}
public function my(){
$list = $this->model->getList($this->user_id);
return $this->success('',$list);
}
public function detail(){
$id = $this->request->request('id');
$order = $this->model->getOrderDetail($id, $this->user_id);
return $this->success('',['order' => $order]);
}
public function cart_pay()
{
$order = $this->model->getCart($this->user_id);
// 创建订单
if ($this->model->order_add($this->user_id, $order)) {
// 清空购物车
$this->model->CarclearAll($this->user_id);
// 发起微信支付
if($this->request->request('type')&&$this->request->request('type')=='gzh'){
$this->init_wx_pay_for_gzh(true);
$this->make_wx_pay('wechat');
}else{
$this->init_wx_pay_for_wxapp();
$this->make_wx_pay('wxapp');
}
}
$this->error($this->model->getError() ?: '订单创建失败');
}
public function finish(){
$id = $this->request->post("id");
$order = $this->model;
if ($order->finish($this->user_id,$id)) {
return $this->success('');
}
return $this->error($order->getError());
}
public function cancel(){
$id = $this->request->post("id");
$order = $this->model->getOrderDetail($id, $this->user_id);
if ($order->cancel($this->user_id,$id)) {
return $this->success('');
}
return $this->error($order->getError());
}
public function order_pay(){
$id = $this->request->post("id");
$order = $this->model->getOrderDetail($id, $this->user_id);
if (!$order->checkGoodsStatusFromOrder($order['goods'])) {
return $this->error($order->getError());
}
$this->model = $order;
// 发起微信支付
if($this->request->post('type')&&$this->request->post('type')=='gzh'){
$this->init_wx_pay_for_gzh(true);
$this->make_wx_pay('wechat');
}else{
$this->init_wx_pay_for_wxapp();
$this->make_wx_pay('wxapp');
}
}
private function init_wx_pay_for_gzh($Ischeck=false){
//这里首先判断 此用户是否绑定了微信公众号
if($Ischeck){
$third = Third::where(['user_id' => $this->user_id, 'platform' => 'wechat'])->find();
if(!$third){
//从这里自动绑定微信公众号的账户
$this->error('您未绑定微信号',null,1008);
}
}
$config = get_addon_config('litestore');
$third_config = get_addon_config('third');
$third_options = array_intersect_key($third_config, array_flip(['wechat']));
$third_options = $third_options['wechat'];
$options = [
'debug' => true,
'log' => [
'level' => 'debug',
'file' => '/tmp/easywechat.log',
],
'app_id' => $third_options['app_id'],
'mch_id' => $config['MCHIDGZH'],
'key' => $config['APIKEYGZH'],
'notify_url' => \think\Request::instance()->domain().addon_url('litestore/api.order/callback_for_wxgzh'),
];
$this->wxapp = WXPAY_APP::payment($options);
}
private function init_wx_pay_for_wxapp(){
$config = get_addon_config('litestore');
$options = [
'debug' => true,
'log' => [
'level' => 'debug',
'file' => '/tmp/easywechat.log',
],
'app_id' => $config['AppID'],
'mch_id' => $config['MCHID'],
'key' => $config['APIKEY'],
'notify_url' => \think\Request::instance()->domain().addon_url('litestore/api.order/callback_for_wxapp'),
];
$this->wxapp = WXPAY_APP::payment($options);
}
private function make_wx_pay($platform){
$third = Third::where(['user_id' => $this->user_id, 'platform' => $platform])->find();
$payment = $this->wxapp;
$attributes = [
'trade_type' => 'JSAPI',
'body' => $this->model['order_no'],
'detail' => 'OrderID:'.$this->model['id'],
'out_trade_no' => $this->model['order_no'],
//'total_fee' => $this->model['pay_price'] * 100, // 单位:分
'total_fee' => 1, // 单位:分
'openid' => $third['openid'],
];
$result = $payment->order->unify($attributes);
if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
$prepayId = $result['prepay_id'];
$config = $payment->jssdk->sdkConfig($prepayId);
return $this->success('预支付成功',$config);
}
return $this->error('微信支付调用失败',$result);
}
public function callback_for_wxgzh(){
$this->init_wx_pay_for_gzh(false);
$response = $this->wxapp->handlePaidNotify(function ($message, $fail) {
$order = $this->model->payDetail($message['out_trade_no']);
if (empty($order)) { // 如果订单不存在
return true;
//return 'Order not exist.'; // 告诉微信,我已经处理完了,订单没找到,别再通知我了
}
if ($message['return_code'] === 'SUCCESS') {
if ($message['result_code']=== 'SUCCESS') {
$order->updatePayStatus($message['transaction_id']);
}
}
return true; // 返回处理完成
});
$response->send();
}
public function callback_for_wxapp(){
$this->init_wx_pay_for_wxapp();
$response = $this->wxapp->handlePaidNotify(function ($message, $fail) {
$order = $this->model->payDetail($message['out_trade_no']);
if (empty($order)) { // 如果订单不存在
return true;
//return 'Order not exist.'; // 告诉微信,我已经处理完了,订单没找到,别再通知我了
}
if ($message['return_code'] === 'SUCCESS') {
if ($message['result_code']=== 'SUCCESS') {
$order->updatePayStatus($message['transaction_id']);
}
}
return true; // 返回处理完成
});
$response->send();
}
}
... ...
<?php
namespace addons\litestore\controller\api;
use app\common\controller\Api;
use addons\litestore\library\Service;
use addons\third\model\Third;
use fast\Http;
use think\Config;
class User extends Api
{
protected $noNeedLogin = ['login_hawk','Updata_user_hawk'];
protected $token = '';
public function _initialize()
{
$this->token = $this->request->post('token');
if ($this->request->action() == 'login' && $this->token) {
$this->request->post(['token' => '']);
}
parent::_initialize();
if (!Config::get('fastadmin.usercenter')) {
$this->error(__('User center already closed'));
}
$ucenter = get_addon_info('ucenter');
if ($ucenter && $ucenter['state']) {
include ADDON_PATH . 'ucenter' . DS . 'uc.php';
}
}
public function Updata_user_hawk(){
$userInfo = $this->request->post("userInfo", '', 'trim');
$mobile = $this->request->post("mobile");
if (!$userInfo||!$this->token) {
$this->error("参数不正确");
}
$this->auth->init($this->token);
//检测是否登录
if ($this->auth->isLogin()) {
$user = $this->auth->getUser();
$fields = [];
$userInfo = json_decode($userInfo,true);
$fields['avatar'] = $userInfo['avatarUrl'];
$fields['nickname'] = $userInfo['nickName'];
$fields['mobile'] = $mobile;
$user->save($fields);
$this->success("已经登录", ['userInfo' => $this->auth->getUserinfo()] );
}else{
$this->error("未登录状态");
}
}
public function login_hawk()
{
$config = get_addon_config('litestore');
$code = $this->request->post("code");
if (!$code) {
$this->error("参数不正确");
}
$params = [
'appid' => $config['AppID'],
'secret' => $config['AppSecret'],
'js_code' => $code,
'grant_type' => 'authorization_code'
];
$result = Http::sendRequest("https://api.weixin.qq.com/sns/jscode2session", $params, 'GET');
if ($result['ret']) {
$json = (array)json_decode($result['msg'], true);
if (isset($json['openid'])) {
//如果有传Token
if ($this->token) {
$this->auth->init($this->token);
//检测是否登录
if ($this->auth->isLogin()) {
$third = Third::where(['openid' => $json['openid'], 'platform' => 'wxapp'])->find();
if ($third && $third['user_id'] == $this->auth->id) {
//把最新的 session_key 保存到 第三方表的 access_token 里
$third['access_token'] = $json['session_key'];
$third->save();
$this->success("登录成功", $this->Format_avatarUrl($this->auth->getUserinfo()));
}
}
}
$platform = 'wxapp';
$result = [
'openid' => $json['openid'],
'userinfo' => [
'nickname' => '游客未登录',
],
'access_token' => $json['session_key'],
'refresh_token' => '',
'expires_in' => isset($json['expires_in']) ? $json['expires_in'] : 0,
];
$extend = ['mobile'=>'NoLoginData' ,'gender' => '0', 'nickname' => '游客未登录', 'avatar' =>'/assets/img/avatar.png'];
$ret = Service::connect_hawk($platform, $result, $extend);
if ($ret) {
$this->success("登录成功", $this->Format_avatarUrl($this->auth->getUserinfo()));
} else {
$this->error("连接失败");
}
} else {
$this->error("登录失败",$json);
}
}
return;
}
private function startsWith($str, $prefix)
{
for ($i = 0; $i < strlen($prefix); ++$i) {
if ($prefix[$i] !== $str[$i]) {
return false;
}
}
return true;
}
private function Format_avatarUrl($userInfo){
$avatar = $userInfo['avatar'];
if($this->startsWith($avatar,"/uploads/")){
$userInfo['avatar'] = cdnurl($avatar, true);
}
return ['userInfo' => $userInfo];
}
}
\ No newline at end of file
... ...
<?php
namespace addons\litestore\controller\api;
use app\common\controller\Api;
use addons\third\library\Application;
use addons\litestore\library\Service;
use think\Cookie;
use think\Hook;
use think\Session;
use addons\third\model\Third;
use app\common\model\User;
use think\Db;
use think\exception\PDOException;
class Uservue extends Api
{
protected $noNeedLogin = ['callback','connect'];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
$config = get_addon_config('third');
if (!$config)
{
$this->error(__('Invalid parameters'));
}
$options = array_intersect_key($config, array_flip(['qq', 'weibo', 'wechat']));
foreach ($options as $k => &$v)
{
$v['callback'] = addon_url('litestore/api.uservue/callback', [':platform' => $k], false, true);
$options[$k] = $v;
}
unset($v);
$this->app = new Application($options);
}
public function index()
{
$third_data = Third::where('user_id',$this->auth->id)->find();
$this->success('', [
'user' => $this->auth->getUser(),
'third' => $third_data
]);
}
/**
* 发起授权
*/
public function connect()
{
$platform = $this->request->param('platform');
$url = $this->request->param('url');
if (!$this->app->{$platform}) {
$this->error(__('Invalid parameters'));
}
if ($url) {
Session::set("redirecturl", $url);
}
// 跳转到登录授权页面
$AuthorizeUrl = $this->app->{$platform}->getAuthorizeUrl();
header('Location: '.$AuthorizeUrl);
exit();
return;
}
/**
* 通知回调
*/
public function callback()
{
$auth = $this->auth;
//监听注册登录注销的事件
Hook::add('user_login_successed', function ($user) use ($auth) {
$expire = input('post.keeplogin') ? 30 * 86400 : 0;
Cookie::set('uid', $user->id, $expire);
Cookie::set('token', $auth->getToken(), $expire);
});
Hook::add('user_register_successed', function ($user) use ($auth) {
Cookie::set('uid', $user->id);
Cookie::set('token', $auth->getToken());
});
Hook::add('user_logout_successed', function ($user) use ($auth) {
Cookie::delete('uid');
Cookie::delete('token');
});
$platform = $this->request->param('platform');
if(!$platform){
$platform = 'wechat';
}
// 成功后返回之前页面
$url = Session::has("redirecturl") ? Session::pull("redirecturl") : url('index/user/index');
// 授权成功后的回调
$result = $this->app->{$platform}->getUserInfo();
if ($result) {
//这里根据 本身是否存在用户登录的情况 如果用户登录没有登录微信 那么自动绑定流程 如果没有登录,那么先注册账号 然后再登录
if($this->auth->getUser()){
$loginret = $this->bind_connect($platform, $result);
}else{
$extend = ['mobile'=>'NoLoginData' ,'gender' => '0', 'nickname' => '游客', 'avatar' =>'/assets/img/avatar.png'];
$loginret = Service::connect_hawk($platform, $result,$extend);
}
if ($loginret) {
$synchtml = '';
////////////////同步到Ucenter////////////////
if (defined('UC_STATUS') && UC_STATUS) {
$uc = new \addons\ucenter\library\client\Client();
$synchtml = $uc->uc_user_synlogin($this->auth->id);
}
$UrlSetCookie = explode("/octothorpe",$url)[0];
$UrlSetCookie = explode("?",$UrlSetCookie)[0] . '#/SetToken';
header('Location: '.$UrlSetCookie.'?token='.$auth->getToken().'&url='.urlencode($url));
exit();
}
}
$this->error(__('操作失败'), $url);
}
private function bind_connect($platform, $params = [], $extend = [], $keeptime = 0)
{
$time = time();
$values = [
'platform' => $platform,
'openid' => $params['openid'],
'openname' => isset($params['userinfo']['nickname']) ? $params['userinfo']['nickname'] : '',
'access_token' => $params['access_token'],
'refresh_token' => $params['refresh_token'],
'expires_in' => $params['expires_in'],
'logintime' => $time,
'expiretime' => $time + $params['expires_in'],
];
$third = Third::get(['platform' => $platform, 'openid' => $params['openid']]);
if ($third) {
$user = User::get($third['user_id']);
if (!$user) {
return FALSE;
}
$third->save($values);
return TRUE;
} else {
Db::startTrans();
try {
$user = $this->auth->getUser();
$fields = ['email' => 'u' . $user->id . '@fastadmin.net'];
if (isset($params['userinfo']['nickname']))
$fields['nickname'] = $params['userinfo']['nickname'];
if (isset($params['userinfo']['avatar']))
$fields['avatar'] = $params['userinfo']['avatar'];
// 更新会员资料
$user = User::get($user->id);
$user->save($fields);
// 保存第三方信息
$values['user_id'] = $user->id;
Third::create($values);
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->auth->logout();
return FALSE;
}
return TRUE;
}
}
}
\ No newline at end of file
... ...
<?php
namespace addons\litestore\controller\api;
use app\common\controller\Api;
use addons\litestore\litestore as litestore_add;
class Wxapp extends Api
{
protected $noNeedLogin = ['*'];
public function _initialize()
{
parent::_initialize();
}
public function base()
{
$Temp_litestore = new litestore_add();
$wxapp = $Temp_litestore->GetCfg();
//格式化导航文字颜色
$wxapp['TopTextColor'] = $wxapp['TopTextColor']=='10'? '#000000':'#ffffff' ;
$wxapp['APIKEY'] = $wxapp['AppID'] = $wxapp['AppSecret'] = $wxapp['MCHIDGZH']= $wxapp['APIKEYGZH']= $wxapp['MCHID']= $wxapp['APIKEY'] = '';
$this->success('', ['wxapp' => $wxapp]);
}
}
\ No newline at end of file
... ...
name = litestore
title = 移动端商城
intro = 快速搭建你的第一个移动端购物商城
author = hawk86014
website = www.217dan.com
version = 1.2.0
state = 1
url = /addons/litestore
first_menu = litestore
license = regular
licenseto = 10789
... ...
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
--
-- Database: `falisten`
--
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_adress`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_adress` (
`address_id` int(11) unsigned NOT NULL,
`name` varchar(30) NOT NULL DEFAULT '',
`phone` varchar(20) NOT NULL DEFAULT '',
`province_id` int(11) unsigned NOT NULL DEFAULT '0',
`city_id` int(11) unsigned NOT NULL DEFAULT '0',
`region_id` int(11) unsigned NOT NULL DEFAULT '0',
`detail` varchar(255) NOT NULL DEFAULT '',
`user_id` int(11) unsigned NOT NULL DEFAULT '0',
`isdefault` enum('0','1') NOT NULL DEFAULT '0' COMMENT '是否默认:0=非默认,1=默认地址',
`createtime` int(11) unsigned NOT NULL DEFAULT '0',
`updatetime` int(11) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_category`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_category` (
`id` int(10) NOT NULL COMMENT 'ID',
`pid` int(10) NOT NULL DEFAULT '0' COMMENT '父ID',
`name` varchar(50) NOT NULL COMMENT '分类名称',
`image` varchar(180) NOT NULL COMMENT '图片',
`weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重',
`createtime` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
`updatetime` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间'
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COMMENT='商品分类';
--
-- 转存表中的数据 `fa_litestore_category`
--
INSERT INTO `__PREFIX__litestore_category` (`id`, `pid`, `name`, `image`, `weigh`, `createtime`, `updatetime`) VALUES
(4, 0, '电子产品', 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/509af801726984aaa359b4bf249f5716.png', 4, 1540367287, 1541402940),
(5, 4, '手机', 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/4fffea1c27bfb8df655a39114bb05814.jpg', 5, 1540367298, 1541402932),
(6, 0, '水果', 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/c83a0019dfa7a768037e98f02b70efd5.jpg', 6, 1540367311, 1541403647),
(7, 6, '进口水果', 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/a460ffdbd534b10cdf40487189ccb6b7.jpg', 7, 1540367326, 1541403531),
(8, 4, '笔记本', 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/efb53c4c7814c83aa3c21e0fd408b5df.jpg', 8, 1541402921, 1541403316),
(9, 6, '国产水果', 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/753cd25e97135e874dca8ab5126ad144.jpg', 9, 1541403546, 1541403622);
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_freight`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_freight` (
`id` int(11) unsigned NOT NULL COMMENT 'ID',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '运费模版名称',
`method` enum('10','20') NOT NULL DEFAULT '10' COMMENT '计费方式:10=按件数,20=按重量',
`weigh` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权重',
`createtime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'createtime',
`updatetime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间'
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `fa_litestore_freight`
--
INSERT INTO `__PREFIX__litestore_freight` (`id`, `name`, `method`, `weigh`, `createtime`, `updatetime`) VALUES
(22, '手机', '10', 22, 1540288755, 1540288755),
(23, '电脑', '10', 23, 1540363605, 1540363605),
(24, '水果', '20', 24, 1540363644, 1540363644);
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_freight_rule`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_freight_rule` (
`rule_id` int(11) unsigned NOT NULL,
`litestore_freight_id` int(11) unsigned NOT NULL DEFAULT '0',
`region` text NOT NULL,
`first` double unsigned NOT NULL DEFAULT '0',
`first_fee` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
`additional` double unsigned NOT NULL DEFAULT '0',
`additional_fee` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
`weigh` int(11) NOT NULL DEFAULT '0' COMMENT '权重',
`create_time` int(11) unsigned NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `fa_litestore_freight_rule`
--
INSERT INTO `__PREFIX__litestore_freight_rule` (`rule_id`, `litestore_freight_id`, `region`, `first`, `first_fee`, `additional`, `additional_fee`, `weigh`, `create_time`) VALUES
(18, 23, '2,20,38,61,76,84,104,124,150,168,180,197,208,221,232,244,250,264,271,278,290,304,319,337,352,362,372,376,389,398,407,422,430,442,449,462,467,481,492,500,508,515,522,530,537,545,553,558,566,574,581,586,597,607,614,619,627,634,640,646,656,675,692,702,711,720,730,748,759,764,775,782,793,802,821,833,842,853,861,871,880,887,896,906,913,920,927,934,948,960,972,980,986,993,1003,1010,1015,1025,1035,1047,1057,1066,1074,1081,1088,1093,1098,1110,1118,1127,1136,1142,1150,1155,1160,1169,1183,1190,1196,1209,1222,1234,1245,1253,1264,1274,1279,1285,1299,1302,1306,1325,1339,1350,1362,1376,1387,1399,1408,1415,1421,1434,1447,1459,1466,1471,1476,1479,1492,1504,1513,1522,1533,1546,1556,1572,1583,1593,1599,1612,1623,1630,1637,1643,1650,1664,1674,1685,1696,1707,1710,1724,1731,1740,1754,1764,1768,1774,1782,1791,1802,1809,1813,1822,1828,1838,1848,1854,1867,1880,1890,1900,1905,1912,1924,1936,1949,1955,1965,1977,1988,1999,2003,2011,2017,2025,2035,2041,2050,2056,2065,2070,2077,2082,2091,2123,2146,2150,2156,2163,2177,2189,2207,2215,2220,2225,2230,2236,2245,2258,2264,2276,2283,2292,2297,2302,2306,2324,2363,2368,2388,2395,2401,2409,2416,2426,2434,2440,2446,2458,2468,2475,2486,2493,2501,2510,2516,2521,2535,2554,2573,2584,2589,2604,2611,2620,2631,2640,2657,2671,2686,2696,2706,2712,2724,2730,2741,2750,2761,2775,2784,2788,2801,2807,2812,2817,2826,2845,2857,2870,2882,2890,2899,2913,2918,2931,2946,2958,2972,2984,2997,3008,3016,3023,3032,3036,3039,3045,3053,3058,3065,3073,3081,3090,3098,3108,3117,3127,3135,3142,3147,3152,3158,3165,3172,3179,3186,3190,3196,3202,3207,3216,3221,3225,3229,3237,3242,3252,3262,3267,3280,3289,3301,3309,3317,3326,3339,3378,3386,3416,3454,3458,3461,3491,3504,3518,3532,3551,3578,3592,3613,3632,3666,3683,3697,3704,3711,3717,3722,3728,3739,3745,3747', 1, '20.00', 1, '10.00', 0, 1540363605),
(49, 24, '2,20,38,61,76,84,104,124,150,168,180,197,208,221,232,244,250,264,271,278,290,304,319,337,352,362,372,376,389,398,407,422,430,442,449,462,467,481,492,500,508,515,522,530,537,545,553,558,566,574,581,586,597,607,614,619,627,634,640,646,656,675,692,702,711,720,730,748,759,764,775,782,793,802,821,833,842,853,861,871,880,887,896,906,913,920,927,934,948,960,972,980,986,993,1003,1010,1015,1025,1035,1047,1057,1066,1074,1081,1088,1093,1098,1110,1118,1127,1136,1142,1150,1155,1160,1169,1183,1190,1196,1209,1222,1234,1245,1253,1264,1274,1279,1285,1299,1302,1306,1325,1339,1350,1362,1376,1387,1399,1408,1415,1421,1434,1447,1459,1466,1471,1476,1479,1492,1504,1513,1522,1533,1546,1556,1572,1583,1593,1599,1612,1623,1630,1637,1643,1650,1664,1674,1685,1696,1707,1710,1724,1731,1740,1754,1764,1768,1774,1782,1791,1802,1809,1813,1822,1828,1838,1848,1854,1867,1880,1890,1900,1905,1912,1924,1936,1949,1955,1965,1977,1988,1999,2003,2011,2017,2025,2035,2041,2050,2056,2065,2070,2077,2082,2091,2123,2146,2150,2156,2163,2177,2189,2207,2215,2220,2225,2230,2236,2245,2258,2264,2276,2283,2292,2297,2302,2306,2324,2363,2368,2388,2395,2401,2409,2416,2426,2434,2440,2446,2458,2468,2475,2486,2493,2501,2510,2516,2521,2535,2554,2573,2584,2589,2604,2611,2620,2631,2640,2657,2671,2686,2696,2706,2712,2724,2730,2741,2750,2761,2775,2784,2788,2801,2807,2812,2817,2826,2845,2857,2870,2882,2890,2899,2913,2918,2931,2946,2958,2972,2984,2997,3008,3016,3023,3032,3036,3039,3045,3053,3058,3065,3073,3081,3090,3098,3108,3117,3127,3135,3142,3147,3152,3158,3165,3172,3179,3186,3190,3196,3202,3207,3216,3221,3225,3229,3237,3242,3252,3262,3267,3280,3289,3301,3309,3317,3326,3339,3378,3386,3416,3454,3458,3461,3491,3504,3518,3532,3551,3578,3592,3613,3632,3666,3683,3697,3704,3711,3717,3722,3728,3739,3745,3747', 1, '10.00', 1, '8.00', 0, 1543387208),
(50, 22, '2,20,38,61,76,84,104,124,150,168,180,197,208,221,232,244,250,264,271,278,290,304,319,337,352,362,372,376,389,398,407,422,430,442,449,462,467,481,492,500,508,515,522,530,537,545,553,558,566,574,581,586,597,607,614,619,627,634,640,646,656,675,692,702,711,720,730,748,759,764,775,782,793,802,821,833,842,853,861,871,880,887,896,906,913,920,927,934,948,960,972,980,986,993,1003,1010,1015,1025,1035,1047,1057,1066,1074,1081,1088,1093,1098,1110,1118,1127,1136,1142,1150,1155,1160,1169,1183,1190,1196,1209,1222,1234,1245,1253,1264,1274,1279,1285,1299,1302,1306,1325,1339,1350,1362,1376,1387,1399,1408,1415,1421,1434,1447,1459,1466,1471,1476,1479,1492,1504,1513,1522,1533,1546,1556,1572,1583,1593,1599,1612,1623,1630,1637,1643,1650,1664,1674,1685,1696,1707,1710,1724,1731,1740,1754,1764,1768,1774,1782,1791,1802,1809,1813,1822,1828,1838,1848,1854,1867,1880,1890,1900,1905,1912,1924,1936,1949,1955,1965,1977,1988,1999,2003,2011,2017,2025,2035,2041,2050,2056,2065,2070,2077,2082,2091,2123,2146,2150,2156,2163,2177,2189,2207,2215,2220,2225,2230,2236,2245,2258,2264,2276,2283,2292,2297,2302,2306,2324,2363,2368,2388,2395,2401,2409,2416,2426,2434,2440,2446,2458,2468,2475,2486,2493,2501,2510,2516,2521,2535,2554,2573,2584,2589,2604,2611,2620,2631,2640,2657,2671,2686,2696,2706,2712,2724,2730,2741,2750,2761,2775,2784,2788,2801,2807,2812,2817,2826,2845,2857,2870,2882,2890,2899,2913,2918,2931,2946,2958,2972,2984,2997,3008,3016,3023,3032,3036,3039,3045,3053,3058,3065,3073,3081,3090,3098,3108,3117,3127,3135,3142,3147,3152,3158,3165,3172,3179,3186,3190,3196,3202,3207,3216,3221,3225,3229,3237,3242,3252,3262,3267,3280,3289,3301,3309,3317,3326,3339,3378,3386,3416,3454,3458,3461,3491,3504,3518,3532,3551,3578,3592,3613,3632,3666,3683,3697,3704,3711,3717,3722,3728,3739,3745,3747', 1, '10.00', 1, '5.00', 0, 1543387223);
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_goods`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_goods` (
`goods_id` int(11) unsigned NOT NULL COMMENT 'ID',
`goods_name` varchar(255) NOT NULL DEFAULT '' COMMENT '商品名称',
`category_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商品类别',
`images` varchar(1800) NOT NULL COMMENT '商品图片',
`spec_type` enum('10','20') NOT NULL DEFAULT '10' COMMENT '商品规格:10=单规格,20=多规格',
`deduct_stock_type` enum('10','20') NOT NULL DEFAULT '20' COMMENT '库存计算方式:10=下单减库存,20=付款减库存',
`content` text NOT NULL COMMENT '描述详情',
`sales_initial` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '初始销量',
`sales_actual` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '实际销量',
`goods_sort` int(11) unsigned NOT NULL DEFAULT '100' COMMENT '权重',
`delivery_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '运费模板ID',
`goods_status` enum('10','20') NOT NULL DEFAULT '10' COMMENT '商品状态:10=上架,20=下架',
`is_delete` enum('0','1') NOT NULL DEFAULT '0' COMMENT '是否删除:0=未删除,1=已删除',
`createtime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`updatetime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间'
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `fa_litestore_goods`
--
INSERT INTO `__PREFIX__litestore_goods` (`goods_id`, `goods_name`, `category_id`, `images`, `spec_type`, `deduct_stock_type`, `content`, `sales_initial`, `sales_actual`, `goods_sort`, `delivery_id`, `goods_status`, `is_delete`, `createtime`, `updatetime`) VALUES
(21, '小米Mix3', 5, 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/ffc4440df18661948b9c2d4dd4ae419b.jpg,https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/83bf8f141969a9e3e607a768407fc7e0.jpg,https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/c5d85254fc17b1a1b0e2254470881e59.jpg', '20', '20', '<p><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/f5b49f703245ef61bb3faa574f32076d.jpg" data-filename="filename" style="width: 699px;"><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/7d0fe135394408d4332386117c928003.jpg" data-filename="filename" style="width: 699px;"><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/6a87fa6af95e39d7dc227f666d7b8ff6.jpg" data-filename="filename" style="width: 699px;"><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/32d58a08cf92282c8f28078137c970f2.jpg" data-filename="filename" style="width: 699px;"><br></p>', 20, 4, 21, 22, '10', '0', 1541401778, 1543221954),
(22, 'Mate 20 华为 HUAWEI ', 5, 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/b044b7bcd4930202fcd96d6b50453894.jpg,https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/4fffea1c27bfb8df655a39114bb05814.jpg,https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/e0d6dc822cf7632c66f7718bdd0dc2bc.jpg', '20', '20', '<p style="text-align: center; line-height: 1.6;"><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/3f0233e227359137bb55152c0750f8a2.png" data-filename="filename" style="width: 603px;"><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/509af801726984aaa359b4bf249f5716.png" data-filename="filename" style="width: 603px;"><br></p><p><br></p>', 10, 64, 22, 22, '10', '0', 1541402364, 1543242861),
(23, 'MacBook Pro 13寸', 8, 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/eaccd76080ed9e7ece7642694e734885.png,https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/85587c2e045b71fb4c977884a19a36cb.jpg,https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/efb53c4c7814c83aa3c21e0fd408b5df.jpg', '20', '20', '<p><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/43b7a84d68a15d9058971526068a853a.jpg" data-filename="filename" style="width: 603px;"><br></p>', 0, 12, 23, 23, '10', '0', 1541403061, 1543319289),
(24, '车厘子智利进口', 7, 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/a460ffdbd534b10cdf40487189ccb6b7.jpg,https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/c83a0019dfa7a768037e98f02b70efd5.jpg', '10', '20', '<p><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181105/611619c7dac06511213278a469a1efea.jpg" data-filename="filename" style="width: 603px;"><br></p>', 0, 12, 24, 24, '10', '0', 1541403509, 1543246427);
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_goods_spec`
--
ALTER TABLE `__PREFIX__litestore_goods_spec` ADD `spec_image` VARCHAR(580) NOT NULL DEFAULT '' COMMENT '规格的封面';
ALTER TABLE `__PREFIX__litestore_goods_spec` CHANGE `stock_num` `stock_num` INT(11) NOT NULL DEFAULT '0';
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_goods_spec` (
`goods_spec_id` int(11) unsigned NOT NULL,
`goods_id` int(11) unsigned NOT NULL DEFAULT '0',
`goods_no` varchar(100) NOT NULL DEFAULT '',
`goods_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
`line_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
`stock_num` int(11) NOT NULL DEFAULT '0',
`goods_sales` int(11) unsigned NOT NULL DEFAULT '0',
`goods_weight` double unsigned NOT NULL DEFAULT '0',
`spec_sku_id` varchar(255) NOT NULL DEFAULT '',
`spec_image` varchar(580) NOT NULL DEFAULT '' COMMENT '规格封面',
`create_time` int(11) unsigned NOT NULL DEFAULT '0',
`update_time` int(11) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=107 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `fa_litestore_goods_spec`
--
INSERT INTO `__PREFIX__litestore_goods_spec` (`goods_spec_id`, `goods_id`, `goods_no`, `goods_price`, `line_price`, `stock_num`, `goods_sales`, `goods_weight`, `spec_sku_id`, `create_time`, `update_time`) VALUES
(66, 23, 'mac_0001', '12688.00', '0.00', 989, 10, 1.2, '48', 1541406888, 1543319289),
(67, 23, 'mac_0002', '12688.00', '0.00', 997, 2, 1.2, '49', 1541406888, 1543021905),
(81, 21, 'SN001', '3299.00', '0.00', 997, 2, 0.5, '40_42', 1542271178, 1543221954),
(82, 21, 'SN002', '3999.00', '0.00', 999, 0, 0.5, '40_43', 1542271178, 1542271178),
(83, 21, 'SN011', '3399.00', '0.00', 999, 0, 0.5, '41_42', 1542271178, 1542271178),
(84, 21, 'SN012', '4099.00', '0.00', 999, 0, 0.5, '41_43', 1542271178, 1542271178),
(94, 24, 'CHE001', '258.00', '299.00', 94, 12, 1, '', 1542707236, 1543283382),
(103, 22, 'SNHW001', '4499.00', '0.00', 941, 58, 500, '44_46', 1542784591, 1543242861),
(104, 22, 'SNHW001', '5899.00', '0.00', 997, 2, 500, '44_47', 1542784591, 1542978749),
(105, 22, 'SNHW001', '4699.00', '0.00', 996, 3, 500, '45_46', 1542784591, 1543242861),
(106, 22, 'SNHW001', '6099.00', '0.00', 999, 0, 500, '45_47', 1542784591, 1542784591);
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_goods_spec_rel`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_goods_spec_rel` (
`id` int(11) unsigned NOT NULL,
`goods_id` int(11) unsigned NOT NULL DEFAULT '0',
`spec_id` int(11) unsigned NOT NULL DEFAULT '0',
`spec_value_id` int(11) unsigned NOT NULL DEFAULT '0',
`create_time` int(11) unsigned NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=102 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `fa_litestore_goods_spec_rel`
--
INSERT INTO `__PREFIX__litestore_goods_spec_rel` (`id`, `goods_id`, `spec_id`, `spec_value_id`, `create_time`) VALUES
(64, 23, 20, 48, 1541406888),
(65, 23, 20, 49, 1541406888),
(78, 21, 20, 40, 1542271178),
(79, 21, 20, 41, 1542271178),
(80, 21, 21, 42, 1542271178),
(81, 21, 21, 43, 1542271178),
(98, 22, 20, 44, 1542784591),
(99, 22, 20, 45, 1542784591),
(100, 22, 22, 46, 1542784591),
(101, 22, 22, 47, 1542784591);
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_news`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_news` (
`id` smallint(8) unsigned NOT NULL,
`title` varchar(100) NOT NULL DEFAULT '' COMMENT '标题',
`image` varchar(180) NOT NULL DEFAULT '' COMMENT '图片',
`content` mediumtext COMMENT '内容',
`createtime` int(10) DEFAULT NULL COMMENT '添加时间',
`updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
`status` enum('normal','hidden') NOT NULL DEFAULT 'normal' COMMENT '状态'
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='首页banner';
--
-- 转存表中的数据 `fa_litestore_news`
--
INSERT INTO `__PREFIX__litestore_news` (`id`, `title`, `image`, `content`, `createtime`, `updatetime`, `status`) VALUES
(1, '双十一!来Pink Dream 脱单吧!', 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181114/8543faa4986afc586e953137aaf741c3.png', '<section style="margin: 20px 0px 10px; padding: 0px; max-width: 100%; text-align: center; word-wrap: break-word !important;"><section style="margin: 0px; padding: 0px 10px; max-width: 100%; display: inline-block; min-width: 10%; vertical-align: top; word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="margin: 0px; padding: 0px; max-width: 100%; word-wrap: break-word !important;"><section style="margin: 0px; padding: 0px; max-width: 100%; word-wrap: break-word !important;"><section style="margin: 0px; padding: 3px 10px 6px; max-width: 100%; display: inline-block; min-width: 10%; vertical-align: top; border-width: 1px; border-radius: 0px; border-style: solid none; border-color: rgb(79, 197, 222); word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="margin: 0px; padding: 0px; max-width: 100%; word-wrap: break-word !important;"><section style="margin: 3px 0px 0px; padding: 0px; max-width: 100%; word-wrap: break-word !important;"><section style="margin: 0px; padding: 0px; max-width: 100%; font-size: 14px; color: rgb(238, 162, 193); line-height: 2; letter-spacing: 1px; word-wrap: break-word !important;"><p style="margin-bottom: 0px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; word-wrap: break-word !important;"><span style="margin: 0px; padding: 0px; max-width: 100%; font-size: 16px; word-wrap: break-word !important;">你还是单身吗?</span></p><p style="margin-bottom: 0px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; word-wrap: break-word !important;"><span style="margin: 0px; padding: 0px; max-width: 100%; font-size: 16px; word-wrap: break-word !important;">快来抓娃娃邂逅你的另一半吧!</span></p><p style="margin-bottom: 0px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; word-wrap: break-word !important;"><span style="margin: 0px; padding: 0px; max-width: 100%; font-size: 16px; word-wrap: break-word !important;">或许你的他是百发百中的抓娃娃大神,</span></p><p style="margin-bottom: 0px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; word-wrap: break-word !important;"><span style="margin: 0px; padding: 0px; max-width: 100%; font-size: 16px; word-wrap: break-word !important;">或许你的她是粉粉少女心的小仙女,</span></p><p style="margin-bottom: 0px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; word-wrap: break-word !important;"><span style="margin: 0px; padding: 0px; max-width: 100%; font-size: 16px; word-wrap: break-word !important;">来Pink Dream活动脱单吧!</span></p></section></section></section><section class="" powered-by="xiumi.us" style="margin: 0px; padding: 0px; max-width: 100%; word-wrap: break-word !important;"><section style="margin: -5px 0px -20px; padding: 0px; max-width: 100%; word-wrap: break-word !important;"><section style="margin: 0px; padding: 0px 5px; max-width: 100%; display: inline-block; width: 30px; height: 30px; vertical-align: top; overflow: hidden; word-wrap: break-word !important;"><section class="" powered-by="xiumi.us" style="margin: 0px; padding: 0px; max-width: 100%; word-wrap: break-word !important;"><section style="margin: 0px; padding: 0px; max-width: 100%; word-wrap: break-word !important;"><section style="margin: 0px; padding: 0px; max-width: 100%; vertical-align: middle; display: inline-block; width: 20px; word-wrap: break-word !important;"><svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 168.9 125.4" style="vertical-align: middle; max-width: 100%;" width="100%"><g><path d="M96.7,62.7V9.3c0-5.2,4.3-9.3,9.3-9.3h53.4c5.2,0,9.5,4.1,9.5,9.3v53.4c0,34.6-28.2,62.7-62.8,62.7 c-5.1,0-9.3-4.1-9.3-9.3c0-5.2,4.3-9.3,9.3-9.3c21.1,0,38.8-14.9,43.1-34.7h-43.1C101,72.1,96.7,67.9,96.7,62.7z" fill="rgb(79,197,222)"></path><path d="M0,62.7V9.3C0,4.1,4.3,0,9.3,0h53.4c5.2,0,9.5,4.1,9.5,9.3v53.4c0,34.6-28.2,62.7-62.8,62.7 c-5.1,0-9.3-4.1-9.3-9.3c0-5.2,4.3-9.3,9.3-9.3c21.1,0,38.8-14.9,43.1-34.7H9.3C4.3,72.1,0,67.9,0,62.7z" fill="rgb(79,197,222)"></path></g></svg></section></section></section></section></section></section></section></section></section></section><p style="text-align: center; margin-bottom: 0px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; word-wrap: break-word !important;"><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181114/20181128141517.gif" style="width: 373.172px; height: 311.211px;"></p><p style="text-align: center; margin-bottom: 0px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; word-wrap: break-word !important;"><br></p><p style="text-align: center; margin-bottom: 0px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; word-wrap: break-word !important;"><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181114/50286403e58df6c6cb296036f44f6ea4.png" style="width: 537px;"></p><p style="text-align: center; margin-bottom: 0px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; word-wrap: break-word !important;"><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181114/fe795e4aa817900e223b6152f14eb57b.png" style="width: 533px;"><br style="margin: 0px; padding: 0px; max-width: 100%; word-wrap: break-word !important;"></p></section>', 1542096807, 1543385827, 'normal'),
(2, '轻断食免费送 | 没当上VOGUE女魔头 她却创立了一个婚纱帝国', 'https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181128/88ec778c0b1743586f42b5e848ad5f42.png', '<p><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181128/4647b1cb325061ae2d68c68028a762d0.jpg" style="width: 669px;" data-filename="filename"></p><p>在纽约流行着一段话:</p><p>未婚女人憧憬拥有一件 Vera Wang</p><p>已婚女人时常怀念自己穿过的那件 VeraWang</p><p>再婚女人庆幸自己可以再要一件 Vera Wang</p><p style="margin-right: 16px; margin-bottom: 0px; margin-left: 16px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; font-variant-numeric: normal; font-variant-east-asian: normal; line-height: 1.75em; word-wrap: break-word !important; overflow-wrap: break-word !important;"><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181128/297e2a8798261c7c9e5bc82c27377c57.jpg" style="width: 657px;" data-filename="filename"></p><p style="margin-right: 16px; margin-bottom: 0px; margin-left: 16px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; font-variant-numeric: normal; font-variant-east-asian: normal; line-height: 1.75em; word-wrap: break-word !important; overflow-wrap: break-word !important;"><br></p><p style="margin-right: 16px; margin-bottom: 0px; margin-left: 16px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; font-variant-numeric: normal; font-variant-east-asian: normal; line-height: 1.75em; word-wrap: break-word !important; overflow-wrap: break-word !important;">创造了婚纱帝国的王薇薇 VeraWang,简直就是一位传奇女士。或许大家一直向往她的婚纱,但一定不知道这些华服下的,她那精彩的人生。</p><p style="margin-right: 16px; margin-bottom: 0px; margin-left: 16px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; font-variant-numeric: normal; font-variant-east-asian: normal; line-height: 1.75em; word-wrap: break-word !important; overflow-wrap: break-word !important;"><br></p><p style="margin-right: 16px; margin-bottom: 0px; margin-left: 16px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; font-variant-numeric: normal; font-variant-east-asian: normal; line-height: 1.75em; word-wrap: break-word !important; overflow-wrap: break-word !important;"><img src="https://her-family.oss-cn-qingdao.aliyuncs.com/addons_store_uploads/20181128/241e24822db3cf5edab983d7c3fec03f.jpg" style="width: 657px;" data-filename="filename"></p><p style="margin-right: 16px; margin-bottom: 0px; margin-left: 16px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; font-variant-numeric: normal; font-variant-east-asian: normal; line-height: 1.75em; word-wrap: break-word !important; overflow-wrap: break-word !important;"><br></p><p style="margin-right: 16px; margin-bottom: 0px; margin-left: 16px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; font-variant-numeric: normal; font-variant-east-asian: normal; line-height: 1.75em; word-wrap: break-word !important; overflow-wrap: break-word !important;">今年69岁的王薇薇本身是个富家女。她也常常在采访中表示,能获得现在的财富,家庭对她的帮助和影响都很大。</p><p style="margin-right: 16px; margin-bottom: 0px; margin-left: 16px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; font-variant-numeric: normal; font-variant-east-asian: normal; line-height: 1.75em; word-wrap: break-word !important; overflow-wrap: break-word !important;"><br></p><p style="margin-right: 16px; margin-bottom: 0px; margin-left: 16px; padding: 0px; max-width: 100%; clear: both; min-height: 1em; font-variant-numeric: normal; font-variant-east-asian: normal; line-height: 1.75em; word-wrap: break-word !important; overflow-wrap: break-word !important;">她的家庭非常富有,父亲事业上非常成功,精通工业、制造业,还是新加坡 Oceanic Petroleum 的主要股东,学历也超高,是麻省理工毕业的高材生。母亲吴赤芳是联合国的翻译官,小时候就会带着她去巴黎看时装走秀什么的,从小一直学滑冰,养成系的名媛。。。。。。</p>', 1543386743, 1543387060, 'normal');
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_order`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_order` (
`id` int(11) unsigned NOT NULL COMMENT '订单ID',
`order_no` varchar(20) NOT NULL DEFAULT '' COMMENT '订单编号',
`total_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '商品金额',
`pay_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '订单总支付金额',
`pay_status` enum('10','20') NOT NULL DEFAULT '10' COMMENT '支付状态:10=未支付,20=已支付',
`pay_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '支付时间',
`express_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '邮费',
`express_company` varchar(50) NOT NULL DEFAULT '' COMMENT '快递公司',
`express_no` varchar(50) NOT NULL DEFAULT '' COMMENT '快递单号',
`freight_status` enum('10','20') NOT NULL DEFAULT '10' COMMENT '发货状态:10=未发货,20=已发货',
`freight_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '发货时间',
`receipt_status` enum('10','20') NOT NULL DEFAULT '10' COMMENT '收货状态:10=未收货,20=已收货',
`receipt_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '收货时间',
`order_status` enum('10','20','30') NOT NULL DEFAULT '10' COMMENT '订单状态:10=进行中,20=取消,30=已完成',
`transaction_id` varchar(30) NOT NULL DEFAULT '' COMMENT '微信支付ID',
`user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
`createtime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '生成时间',
`updatetime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_order_address`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_order_address` (
`id` int(11) unsigned NOT NULL COMMENT 'ID',
`name` varchar(30) NOT NULL DEFAULT '' COMMENT '联系人',
`phone` varchar(20) NOT NULL DEFAULT '' COMMENT '手机号',
`province_id` int(11) unsigned NOT NULL DEFAULT '0',
`city_id` int(11) unsigned NOT NULL DEFAULT '0',
`region_id` int(11) unsigned NOT NULL DEFAULT '0',
`detail` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址',
`order_id` int(11) unsigned NOT NULL DEFAULT '0',
`user_id` int(11) unsigned NOT NULL DEFAULT '0',
`createtime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_order_goods`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_order_goods` (
`id` int(11) unsigned NOT NULL COMMENT 'ID',
`goods_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商品ID',
`goods_name` varchar(255) NOT NULL DEFAULT '' COMMENT '商品名称',
`images` varchar(1800) NOT NULL COMMENT '商品图片',
`deduct_stock_type` enum('10','20') NOT NULL DEFAULT '20' COMMENT '库存计算方式:10=下单减库存,20=付款减库存',
`spec_type` enum('10','20') NOT NULL DEFAULT '10' COMMENT '商品规格:10=单规格,20=多规格',
`spec_sku_id` varchar(255) NOT NULL DEFAULT '' COMMENT '规格sku',
`goods_spec_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商品规格ID',
`goods_attr` varchar(500) NOT NULL DEFAULT '' COMMENT '商品规格描述',
`content` text NOT NULL COMMENT '商品描述',
`goods_no` varchar(100) NOT NULL DEFAULT '' COMMENT '商品编号',
`goods_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '商品价格',
`line_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
`goods_weight` double unsigned NOT NULL DEFAULT '0',
`total_num` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '购买数量',
`total_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '总价',
`order_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '订单ID',
`user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
`createtime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_spec`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_spec` (
`id` int(11) unsigned NOT NULL,
`spec_name` varchar(255) NOT NULL DEFAULT '',
`createtime` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `fa_litestore_spec`
--
INSERT INTO `__PREFIX__litestore_spec` (`id`, `spec_name`, `createtime`) VALUES
(20, '颜色', 1541401442),
(21, '版本', 1541401484),
(22, '内存', 1541402270);
-- --------------------------------------------------------
--
-- 表的结构 `fa_litestore_spec_value`
--
CREATE TABLE IF NOT EXISTS `__PREFIX__litestore_spec_value` (
`id` int(11) unsigned NOT NULL,
`spec_value` varchar(255) NOT NULL,
`spec_id` int(11) NOT NULL,
`createtime` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `fa_litestore_spec_value`
--
INSERT INTO `__PREFIX__litestore_spec_value` (`id`, `spec_value`, `spec_id`, `createtime`) VALUES
(40, '黑色', 20, 1541401442),
(41, '翡翠绿', 20, 1541401451),
(42, '6+128', 21, 1541401484),
(43, '8+128', 21, 1541401489),
(44, '亮黑色', 20, 1541402233),
(45, '极光色', 20, 1541402243),
(46, '6GB+64GB', 22, 1541402271),
(47, '8GB+128GB', 22, 1541402279),
(48, '天空灰', 20, 1541403005),
(49, '银色', 20, 1541403011);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `fa_litestore_adress`
--
ALTER TABLE `__PREFIX__litestore_adress`
ADD PRIMARY KEY (`address_id`);
--
-- Indexes for table `fa_litestore_category`
--
ALTER TABLE `__PREFIX__litestore_category`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `fa_litestore_freight`
--
ALTER TABLE `__PREFIX__litestore_freight`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `fa_litestore_freight_rule`
--
ALTER TABLE `__PREFIX__litestore_freight_rule`
ADD PRIMARY KEY (`rule_id`);
--
-- Indexes for table `fa_litestore_goods`
--
ALTER TABLE `__PREFIX__litestore_goods`
ADD PRIMARY KEY (`goods_id`),
ADD KEY `category_id` (`category_id`);
--
-- Indexes for table `fa_litestore_goods_spec`
--
ALTER TABLE `__PREFIX__litestore_goods_spec`
ADD PRIMARY KEY (`goods_spec_id`);
--
-- Indexes for table `fa_litestore_goods_spec_rel`
--
ALTER TABLE `__PREFIX__litestore_goods_spec_rel`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `fa_litestore_news`
--
ALTER TABLE `__PREFIX__litestore_news`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `fa_litestore_order`
--
ALTER TABLE `__PREFIX__litestore_order`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `order_no` (`order_no`) USING BTREE;
--
-- Indexes for table `fa_litestore_order_address`
--
ALTER TABLE `__PREFIX__litestore_order_address`
ADD PRIMARY KEY (`id`) USING BTREE;
--
-- Indexes for table `fa_litestore_order_goods`
--
ALTER TABLE `__PREFIX__litestore_order_goods`
ADD PRIMARY KEY (`id`) USING BTREE;
--
-- Indexes for table `fa_litestore_spec`
--
ALTER TABLE `__PREFIX__litestore_spec`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `fa_litestore_spec_value`
--
ALTER TABLE `__PREFIX__litestore_spec_value`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `fa_litestore_adress`
--
ALTER TABLE `__PREFIX__litestore_adress`
MODIFY `address_id` int(11) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `fa_litestore_category`
--
ALTER TABLE `__PREFIX__litestore_category`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'ID',AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `fa_litestore_freight`
--
ALTER TABLE `__PREFIX__litestore_freight`
MODIFY `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',AUTO_INCREMENT=25;
--
-- AUTO_INCREMENT for table `fa_litestore_freight_rule`
--
ALTER TABLE `__PREFIX__litestore_freight_rule`
MODIFY `rule_id` int(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=25;
--
-- AUTO_INCREMENT for table `fa_litestore_goods`
--
ALTER TABLE `__PREFIX__litestore_goods`
MODIFY `goods_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',AUTO_INCREMENT=25;
--
-- AUTO_INCREMENT for table `fa_litestore_goods_spec`
--
ALTER TABLE `__PREFIX__litestore_goods_spec`
MODIFY `goods_spec_id` int(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=107;
--
-- AUTO_INCREMENT for table `fa_litestore_goods_spec_rel`
--
ALTER TABLE `__PREFIX__litestore_goods_spec_rel`
MODIFY `id` int(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=102;
--
-- AUTO_INCREMENT for table `fa_litestore_news`
--
ALTER TABLE `__PREFIX__litestore_news`
MODIFY `id` smallint(8) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `fa_litestore_order`
--
ALTER TABLE `__PREFIX__litestore_order`
MODIFY `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '订单ID';
--
-- AUTO_INCREMENT for table `fa_litestore_order_address`
--
ALTER TABLE `__PREFIX__litestore_order_address`
MODIFY `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID';
--
-- AUTO_INCREMENT for table `fa_litestore_order_goods`
--
ALTER TABLE `__PREFIX__litestore_order_goods`
MODIFY `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID';
--
-- AUTO_INCREMENT for table `fa_litestore_spec`
--
ALTER TABLE `__PREFIX__litestore_spec`
MODIFY `id` int(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=23;
--
-- AUTO_INCREMENT for table `fa_litestore_spec_value`
--
ALTER TABLE `__PREFIX__litestore_spec_value`
MODIFY `id` int(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=50;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
... ...
<?php
namespace addons\litestore\library;
use addons\third\model\Third;
use app\common\model\User;
use fast\Random;
/**
* 第三方登录服务类
*
* @author Karson
*/
class Service
{
/**
* 第三方登录 ByHawk
* @param string $platform 平台
* @param array $params 参数
* @param int $keeptime 有效时长
* @return boolean
*/
public static function connect_hawk($platform, $params = [],$extend, $keeptime = 0)
{
$time = time();
$values = [
'platform' => $platform,
'openid' => $params['openid'],
'openname' => isset($params['userinfo']['nickname']) ? $params['userinfo']['nickname'] : '',
'access_token' => $params['access_token'],
'refresh_token' => $params['refresh_token'],
'expires_in' => $params['expires_in'],
'logintime' => $time,
'expiretime' => $time + $params['expires_in'],
];
$auth = \app\common\library\Auth::instance();
$auth->keeptime($keeptime);
$third = Third::get(['platform' => $platform, 'openid' => $params['openid']]);
if ($third)
{
$user = User::get($third['user_id']);
if (!$user)
{
//如果没有找到用户,证明已经呗管理员删去了,那么自动增加
$username = Random::alnum(20);
$password = Random::alnum(6);
// 默认注册一个会员
$result = $auth->register($username, $password, $username . '@217dan.com', '', $extend, $keeptime);
if (!$result)
{
return FALSE;
}
$user = $auth->getUser();
$fields = ['username' => 'u' . $user->id, 'email' => 'u' . $user->id . '@217dan.com'];
if (isset($params['userinfo']['nickname']))
$fields['nickname'] = $params['userinfo']['nickname'];
if (isset($params['userinfo']['avatar']))
$fields['avatar'] = $params['userinfo']['avatar'];
$fields['group_id'] = 1;
// 更新会员资料
$user->save($fields);
// 反过来更新 第三方的表
$third['user_id'] = $user->id;
}
$third->save($values);
return $auth->direct($user->id);
}
else
{
// 先随机一个用户名,随后再变更为u+数字id
$username = Random::alnum(20);
$password = Random::alnum(6);
// 默认注册一个会员
$result = $auth->register($username, $password, '', '', $extend, $keeptime);
if (!$result)
{
return FALSE;
}
$user = $auth->getUser();
$fields = ['username' => 'u' . $user->id];
if (isset($params['userinfo']['nickname']))
$fields['nickname'] = $params['userinfo']['nickname'];
if (isset($params['userinfo']['avatar']))
$fields['avatar'] = $params['userinfo']['avatar'];
$fields['group_id'] = 1;
// 更新会员资料
$user->save($fields);
// 保存第三方信息
$values['user_id'] = $user->id;
$values['platform'] = $platform;
Third::create($values);
// 写入登录Cookies和Token
return $auth->direct($user->id);
}
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Cache;
use think\Model;
class Area extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = false;
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
/**
* 根据id获取地区名称
* @param $id
* @return string
*/
public static function getNameById($id)
{
$area = self::getCacheAll();
return $area[$id]['name'];
}
/**
* 根据名称获取地区id
* @param $name
* @param int $level
* @param int $pid
* @return mixed
*/
public static function getIdByName($name, $level = 0, $pid = 0)
{
return static::useGlobalScope(false)->where(compact('name', 'level', 'pid'))
->value('id') ?: static::add($name, $level, $pid);
}
/**
* @param $name
* @param int $level
* @param int $pid
* @return mixed
*/
private static function add($name, $level = 0, $pid = 0)
{
$model = new static;
$model->save(compact('name', 'level', 'pid'));
Cache::rm('area');
return $model->getLastInsID();
}
/**
* 获取所有地区(树状结构)
* @return mixed
*/
public static function getCacheTree()
{
return self::areaCache()['tree'];
}
/**
* 获取所有地区
* @return mixed
*/
public static function getCacheAll()
{
return self::areaCache()['all'];
}
/**
* 获取地区缓存
* @return mixed
*/
private static function areaCache()
{
if (!Cache::get('area')) {
// 所有地区
$all = $allData = self::useGlobalScope(false)->column('id, pid, name, level', 'id');
// 格式化
$tree = [];
foreach ($allData as $pKey => $province) {
if ($province['level'] === 1) { // 省份
$tree[$province['id']] = $province;
unset($allData[$pKey]);
foreach ($allData as $cKey => $city) {
if ($city['level'] === 2 && $city['pid'] === $province['id']) { // 城市
$tree[$province['id']]['city'][$city['id']] = $city;
unset($allData[$cKey]);
foreach ($allData as $rKey => $area) {
if ($area['level'] === 3 && $area['pid'] === $city['id']) { // 地区
$tree[$province['id']]['city'][$city['id']]['area'][$area['id']] = $area;
unset($allData[$rKey]);
}
}
}
}
}
}
Cache::set('area', compact('all', 'tree'));
}
return Cache::get('area');
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Cache;
/**
* 购物车管理
* Class Cart
*/
class CacheCart
{
/* @var string $error 错误信息 */
public $error = '';
/* @var int $user_id 用户id */
private $user_id;
/* @var array $cart 购物车列表 */
private $cart = [];
/* @var bool $clear 是否清空购物车 */
private $clear = false;
/**
* 构造方法
* Cart constructor.
* @param $user_id
*/
public function __construct($user_id)
{
$this->user_id = $user_id;
$this->cart = Cache::get('cart_' . $this->user_id) ?: [];
}
/**
* 购物车列表
*/
public function getList($user_id)
{
// 商品列表
$goodsList = [];
$goodsIds = array_unique(array_column($this->cart, 'goods_id'));
foreach ((new Wxlitestoregoods)->getListByIds($goodsIds) as $goods) {
$goodsList[$goods['goods_id']] = $goods;
}
// 当前用户收货城市id
$defaultcity = Litestoreadress::getdefault($user_id);
$cityId = $defaultcity ? $defaultcity['city_id'] : null;
// 是否存在收货地址
$exist_address = $defaultcity;
// 商品是否在配送范围
$intraRegion = true;
// 购物车商品列表
$cartList = [];
foreach ($this->cart as $key => $cart) {
// 判断商品不存在则自动删除
if (!isset($goodsList[$cart['goods_id']])) {
$this->delete($cart['goods_id'], $cart['goods_sku_id']);
continue;
}
/* @var Goods $goods */
$goods = $goodsList[$cart['goods_id']];
// 商品sku信息
$goods['goods_sku_id'] = $cart['goods_sku_id'];
// 商品sku不存在则自动删除
if (!$goods['goods_sku'] = $goods->getGoodsSku($cart['goods_sku_id'])) {
$this->delete($cart['goods_id'], $cart['goods_sku_id']);
continue;
}
$goods['show_error'] = 0;
// 判断商品是否下架
if ($goods['goods_status']!== '10') {
$goods['show_error'] = 1;
$goods['show_error_text'] = '已下架';
$this->setError('很抱歉,商品 [' . $goods['goods_name'] . '] 已下架');
}
// 判断商品库存
if ($cart['goods_num'] > $goods['goods_sku']['stock_num']) {
$goods['show_error'] = 2;
$goods['show_error_text'] = '库存不足';
$this->setError('很抱歉,商品 [' . $goods['goods_name'] . '] 库存不足');
}
// 商品单价
$goods['goods_price'] = $goods['goods_sku']['goods_price'];
// 商品总价
$goods['total_num'] = $cart['goods_num'];
$goods['total_price'] = $total_price = bcmul($goods['goods_price'], $cart['goods_num'], 2);
// 商品总重量
$goods['goods_total_weight'] = bcmul($goods['goods_sku']['goods_weight'], $cart['goods_num'], 2);
// 验证用户收货地址是否存在运费规则中
if ($intraRegion = $goods['freight']->checkAddress($cityId)) {
$goods['express_price'] = $goods['freight']->calcTotalFee(
$cart['goods_num'], $goods['goods_total_weight'], $cityId);
} else {
//$goods['show_error'] = 3;
//$goods['show_error_text'] = '收货区域无法配送';
$exist_address && $this->setError("很抱歉,您的收货地址不在商品 [{$goods['goods_name']}] 的配送范围内");
}
$cartList[] = $goods->toArray();
}
// 商品总金额
$orderTotalPrice = array_sum(array_column($cartList, 'total_price'));
// 所有商品的运费金额
$allExpressPrice = array_column($cartList, 'express_price');
// 订单总运费金额
$expressPrice = $allExpressPrice ? Litestorefreight::freightRule($allExpressPrice) : 0.00;
return [
'goods_list' => $cartList, // 商品列表
'order_total_num' => $this->getTotalNum(), // 商品总数量
'order_total_price' => round($orderTotalPrice, 2), // 商品总金额 (不含运费)
'order_pay_price' => bcadd($orderTotalPrice, $expressPrice, 2), // 实际支付金额
'address' => $defaultcity, // 默认地址
'exist_address' => $exist_address, // 是否存在收货地址
'express_price' => $expressPrice, // 配送费用
'intra_region' => $intraRegion, // 当前用户收货城市是否存在配送规则中
'has_error' => $this->hasError(),
'error_msg' => $this->getError(),
];
}
/**
* 添加购物车
* @param $goods_id
* @param $goods_num
* @param $goods_sku_id
* @return bool
* @throws \think\exception\DbException
*/
public function add($goods_id, $goods_num, $goods_sku_id)
{
// 购物车商品索引
$index = $goods_id . '_' . $goods_sku_id;
// 商品信息
$goods = Wxlitestoregoods::detail($goods_id);
// 商品sku信息
$goods['goods_sku'] = $goods->getGoodsSku($goods_sku_id);
// 判断商品是否下架
if ($goods['goods_status'] !== '10') {
$this->setError('很抱歉,该商品已下架');
return false;
}
// 判断商品库存
$cartGoodsNum = $goods_num + (isset($this->cart[$index]) ? $this->cart[$index]['goods_num'] : 0);
if ($cartGoodsNum > $goods['goods_sku']['stock_num']) {
$this->setError('很抱歉,商品库存不足');
return false;
}
$create_time = time();
$data = compact('goods_id', 'goods_num', 'goods_sku_id', 'create_time');
if (empty($this->cart)) {
$this->cart[$index] = $data;
return true;
}
isset($this->cart[$index]) ? $this->cart[$index]['goods_num'] = $cartGoodsNum : $this->cart[$index] = $data;
return true;
}
/**
* 减少购物车中某商品数量
* @param $goods_id
* @param $goods_sku_id
*/
public function sub($goods_id, $goods_sku_id)
{
$index = $goods_id . '_' . $goods_sku_id;
$this->cart[$index]['goods_num'] > 1 && $this->cart[$index]['goods_num']--;
}
/**
* 删除购物车中指定商品
* @param $goods_id
* @param $goods_sku_id
*/
public function delete($goods_id, $goods_sku_id)
{
$index = $goods_id . '_' . $goods_sku_id;
unset($this->cart[$index]);
}
/**
* 获取当前用户购物车商品总数量
* @return int
*/
public function getTotalNum()
{
return array_sum(array_column($this->cart, 'goods_num'));
}
/**
* 析构方法
* 将cart数据保存到缓存文件
*/
public function __destruct()
{
$this->clear !== true && Cache::set('cart_' . $this->user_id, $this->cart, 86400 * 15);
}
/**
* 清空当前用户购物车
*/
public function clearAll()
{
$this->clear = true;
Cache::rm('cart_' . $this->user_id);
}
/**
* 设置错误信息
* @param $error
*/
private function setError($error)
{
empty($this->error) && $this->error = $error;
}
/**
* 是否存在错误
* @return bool
*/
private function hasError()
{
return !empty($this->error);
}
/**
* 获取错误信息
* @return string
*/
public function getError()
{
return $this->error;
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
class Litestoreadress extends Model
{
// 表名
protected $name = 'litestore_adress';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 追加属性
protected $append = ['Area'];
public function getList($user_id)
{
return self::all(compact('user_id'));
}
public function getAreaAttr($value, $data)
{
return [
'province' => Area::getNameById($data['province_id']),
'city' => Area::getNameById($data['city_id']),
'region' => Area::getNameById($data['region_id']),
];
}
public function add($use_id, $data)
{
$listdata = $this->all(['user_id'=>$use_id]);
foreach ($listdata as $key => $value) {
$value['isdefault'] = '0';
$value->save();
}
// 添加收货地址
$region = explode(',', $data['region']);
$province_id = Area::getIdByName($region[0], 1);
$city_id = Area::getIdByName($region[1], 2, $province_id);
$region_id = Area::getIdByName($region[2], 3, $city_id);
$this->allowField(true)->save(array_merge([
'user_id' => $use_id,
'province_id' => $province_id,
'city_id' => $city_id,
'region_id' => $region_id,
'isdefault' => '1'
], $data));
return true;
}
public function setdefault($use_id,$id){
$listdata = $this->all(['user_id'=>$use_id]);
foreach ($listdata as $key => $value) {
$value['isdefault'] = '0';
$value->save();
}
return ($this->get($id))->save(['isdefault' => '1']);
}
public function del($id){
return ($this->get($id))->delete();
}
public function detail($user_id, $address_id)
{
return self::get(compact('user_id', 'address_id'));
}
public function edit($data){
$region = explode(',', $data['region']);
$province_id = Area::getIdByName($region[0], 1);
$city_id = Area::getIdByName($region[1], 2, $province_id);
$region_id = Area::getIdByName($region[2], 3, $city_id);
return $this->allowField(true)
->save(array_merge(compact('province_id', 'city_id', 'region_id'), $data));
}
public static function getdefault($use_id){
$filter = [];
$filter['isdefault'] = '1';
$filter['user_id'] = $use_id;
return self::get($filter);
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
class Litestorecategory extends Model
{
// 表名
protected $name = 'litestore_category';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 追加属性
protected $append = [
];
protected static function init()
{
self::afterInsert(function ($row) {
$pk = $row->getPk();
$row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
});
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
use addons\litestore\Litestore as litestore_add;
class Litestorefreight extends Model
{
// 表名
protected $name = 'litestore_freight';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 追加属性
protected $append = [
'method_text'
];
protected static function init()
{
self::afterInsert(function ($row) {
$pk = $row->getPk();
$row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
});
}
public function getMethodList()
{
return ['10' => __('Method 10'),'20' => __('Method 20')];
}
public function getMethodTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['method']) ? $data['method'] : '');
$list = $this->getMethodList();
return isset($list[$value]) ? $list[$value] : '';
}
public function rule()
{
return $this->hasMany('Litestorefreightrule');
}
public function createDeliveryRule($data)
{
$save = [];
$connt = count($data['region']);
for ($i = 0; $i < $connt; $i++) {
$save[] = [
'region' => $data['region'][$i],
'first' => $data['first'][$i],
'first_fee' => $data['first_fee'][$i],
'additional' => $data['additional'][$i],
'additional_fee' => $data['additional_fee'][$i],
];
}
$this->rule()->delete();
return $this->rule()->saveAll($save);
}
/**
* 运费模板详情
* @param $delivery_id
* @return null|static
* @throws \think\exception\DbException
*/
public function detail($delivery_id)
{
return self::get($delivery_id, ['rule']);
}
public function calcTotalFee($total_num, $total_weight, $city_id)
{
$rule = []; // 当前规则
foreach ($this['rule'] as $item) {
if (in_array($city_id, $item['region_data'])) {
$rule = $item;
break;
}
}
// 商品总数量or总重量
$total = $this['method']=== '10' ? $total_num : $total_weight;
if ($total <= $rule['first']) {
return number_format($rule['first_fee'], 2);
}
// 续件or续重 数量
$additional = $total - $rule['first'];
if ($additional <= $rule['additional']) {
return number_format($rule['first_fee'] + $rule['additional_fee'], 2);
}
// 计算续重/件金额
if ($rule['additional'] < 1) {
// 配送规则中续件为0
$additionalFee = 0.00;
} else {
$additionalFee = bcdiv($rule['additional_fee'], $rule['additional'], 2) * $additional;
}
return number_format($rule['first_fee'] + $additionalFee, 2);
}
public static function freightRule($allExpressPrice)
{
$Temp_litestore = new litestore_add();
$wxapp = $Temp_litestore->GetCfg();
$freight_rule = $wxapp['freight'];
$expressPrice = 0.00;
switch ($freight_rule) {
case '10': // 叠加
$expressPrice = array_sum($allExpressPrice);
break;
case '20': // 以最低运费结算
$expressPrice = min($allExpressPrice);
break;
case '30': // 以最高运费结算
$expressPrice = max($allExpressPrice);
break;
}
return $expressPrice;
}
public function checkAddress($city_id)
{
$cityIds = explode(',', implode(',', array_column($this['rule'], 'region')));
return in_array($city_id, $cityIds);
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
class Litestorefreightrule extends Model
{
// 表名
protected $name = 'litestore_freight_rule';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = false;
protected $append = ['region_data'];
public function getRegionDataAttr($value, $data)
{
return explode(',', $data['region']);
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
class Litestoregoodsspec extends Model
{
// 表名
protected $name = 'litestore_goods_spec';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
/**
* 批量添加商品sku记录
* @param $goods_id
* @param $spec_list
* @return array|false
* @throws \Exception
*/
public function addSkuList($goods_id, $spec_list)
{
$data = [];
foreach ($spec_list as $item) {
$data[] = array_merge($item['form'], [
'spec_sku_id' => $item['spec_sku_id'],
'goods_id' => $goods_id,
]);
}
return $this->saveAll($data);
}
/**
* 添加商品规格关系记录
* @param $goods_id
* @param $spec_attr
* @return array|false
* @throws \Exception
*/
public function addGoodsSpecRel($goods_id, $spec_attr)
{
$data = [];
array_map(function ($val) use (&$data, $goods_id) {
array_map(function ($item) use (&$val, &$data, $goods_id) {
$data[] = [
'goods_id' => $goods_id,
'spec_id' => $val['group_id'],
'spec_value_id' => $item['item_id'],
];
}, $val['spec_items']);
}, $spec_attr);
$model = new Litestoregoodsspecrel;
return $model->saveAll($data);
}
/**
* 移除指定商品的所有sku
* @param $goods_id
* @return int
*/
public function removeAll($goods_id)
{
$model = new Litestoregoodsspecrel;
$model->where('goods_id','=', $goods_id)->delete();
return $this->where('goods_id','=', $goods_id)->delete();
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
class Litestoregoodsspecrel extends Model
{
// 表名
protected $name = 'litestore_goods_spec_rel';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = '';
/**
* 关联规格组
* @return \think\model\relation\BelongsTo
*/
public function spec()
{
return $this->belongsTo('Litestorespec');
}
}
\ No newline at end of file
... ...
<?php
namespace addons\litestore\model;
use think\Model;
class Litestorenews extends Model
{
// 表名
protected $name = 'litestore_news';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
use think\Db;
class Litestoreorder extends Model
{
// 表名
protected $name = 'litestore_order';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 追加属性
protected $append = [
'pay_status_text',
'pay_time_text',
'freight_status_text',
'freight_time_text',
'receipt_status_text',
'receipt_time_text',
'order_status_text',
'creattime_text',
];
public function cancel($user_id,$order_id){
if ($this['pay_status'] === '20') {
$this->error = '已付款订单不可取消';
return false;
}
$goods = $this['goods'];
$this->backGoodsStock($goods);
$order = self::get([
'id' => $order_id,
'user_id' => $user_id,
'order_status' => ['<>', '20']
]);
return $order->save([
'order_status' => '20'
]);
}
private function backGoodsStock(&$goodsList)
{
$goodsSpecSave = [];
foreach ($goodsList as $goods) {
// 下单减库存
if ($goods['deduct_stock_type'] === '10') {
$goodsSpecSave[] = [
'goods_spec_id' => $goods['goods_spec_id'],
'stock_num' => ['inc', $goods['total_num']]
];
}
}
if(!empty($goodsSpecSave)){
// 更新商品规格库存
return (new Litestoregoodsspec)->isUpdate()->saveAll($goodsSpecSave);
}
return true;
}
public function finish($user_id,$order_id){
if (!$order = self::get([
'id' => $order_id,
'user_id' => $user_id,
'order_status' => ['<>', '20']
])) {
throw new Exception('订单不存在');
}
if ($order['freight_status'] === '10' || $order['receipt_status'] === '20') {
$order->error = '该订单不合法';
return false;
}
return $order->save([
'receipt_status' => '20',
'receipt_time' => time(),
'order_status' => '30'
]);
}
public function checkGoodsStatusFromOrder($goodsList){
foreach ($goodsList as $goods) {
//商品是否下架
if ($goods['goods']['goods_status'] !== '10') {
$this->setError('很抱歉,商品 [' . $goods['goods_name'] . '] 已下架');
return false;
}
//付款减库存
if ($goods['deduct_stock_type'] === '20' && $goods['spec']['stock_num'] < 1) {
$this->setError('很抱歉,商品 [' . $goods['goods_name'] . '] 库存不足');
return false;
}
}
return true;
}
public function getList($user_id){
return $this->with(['goods'])
->where('user_id', '=', $user_id)
->where('order_status', '<>', '20')
->order(['createtime' => 'desc'])->limit(50)
->select();
}
public function getOrderDetail($order_id, $user_id){
if (!$order = self::get([
'order_id' => $order_id,
'litestoreorder.user_id' => $user_id,
'order_status' => ['<>', '20']
], ['goods'=>['spec','goods'], 'address'])) {
throw new Exception('订单不存在');
}
$goodsList = [];
foreach ($order['goods'] as $index => $item) {
$item['image'] = cdnurl(explode(",",$item['images'])[0], true);
$item['sku_image'] = $item['spec']['spec_image']=='' ? '' : cdnurl($item['spec']['spec_image'], true);
$goodsList[] = $item;
}
$order['goods'] = $goodsList;
return $order;
}
public function payDetail($order_no){
return self::get(['order_no' => $order_no, 'pay_status' => 10], ['goods']);
}
public function getCart($user_id){
$model = new CacheCart($user_id);
return $model->getList($user_id);
}
public function CarclearAll($user_id){
$Card = new CacheCart($user_id);
$Card->clearAll();
}
public function getBuyNow($user_id, $goods_id, $goods_num, $goods_sku_id)
{
// 商品信息
$goods = Wxlitestoregoods::detail($goods_id);
$goods['show_error'] = 0;
// 判断商品是否下架
if ($goods['goods_status'] !== '10') {
$goods['show_error'] = 1;
$goods['show_error_text'] = '已下架';
$this->setError('很抱歉,商品信息不存在或已下架');
}
// 商品sku信息
$goods['goods_sku'] = $goods->getGoodsSku($goods_sku_id);
// 判断商品库存
if ($goods_num > $goods['goods_sku']['stock_num']) {
$goods['show_error'] = 2;
$goods['show_error_text'] = '库存不足';
$this->setError('很抱歉,商品库存不足');
}
// 商品单价
$goods['goods_price'] = $goods['goods_sku']['goods_price'];
// 商品总价
$goods['total_num'] = $goods_num;
$goods['total_price'] = $totalPrice = bcmul($goods['goods_price'], $goods_num, 2);
// 商品总重量
$goods_total_weight = bcmul($goods['goods_sku']['goods_weight'], $goods_num, 2);
// 当前用户收货城市id
$defaultcity = Litestoreadress::getdefault($user_id);
$cityId = $defaultcity ? $defaultcity['city_id'] : null;
// 是否存在收货地址
$exist_address = $defaultcity;
// 验证用户收货地址是否存在运费规则中
if (!$intraRegion = $goods['freight']->checkAddress($cityId)) {
$exist_address && $this->setError('很抱歉,您的收货地址不在配送范围内');
}
// 计算配送费用
$expressPrice = $intraRegion ?
$goods['freight']->calcTotalFee($goods_num, $goods_total_weight, $cityId) : 0;
return [
'goods_list' => [$goods], // 商品详情
'order_total_num' => $goods_num, // 商品总数量
'order_total_price' => $totalPrice, // 商品总金额 (不含运费)
'order_pay_price' => bcadd($totalPrice, $expressPrice, 2), // 实际支付金额
'address' => $defaultcity, // 默认地址
'exist_address' => $exist_address, // 是否存在收货地址
'express_price' => $expressPrice, // 配送费用
'intra_region' => $intraRegion, // 当前用户收货城市是否存在配送规则中
'has_error' => $this->hasError(),
'error_msg' => $this->getError(),
];
}
public function order_add($user_id, $order){
if (empty($order['address'])) {
$this->error = '请先选择收货地址';
return false;
}
Db::startTrans();
// 记录订单信息
$this->save([
'user_id' => $user_id,
'order_no' => $this->orderNo(),
'total_price' => $order['order_total_price'],
'pay_price' => $order['order_pay_price'],
'express_price' => $order['express_price'],
]);
// 订单商品列表
$goodsList = [];
// 更新商品库存 (下单减库存)
$deductStockData = [];
foreach ($order['goods_list'] as $goods) {
/* @var Goods $goods */
$goodsList[] = [
'user_id' => $user_id,
'goods_id' => $goods['goods_id'],
'goods_name' => $goods['goods_name'],
'images' => $goods['images'],
'deduct_stock_type' => $goods['deduct_stock_type'],
'spec_type' => $goods['spec_type'],
'spec_sku_id' => $goods['goods_sku']['spec_sku_id'],
'goods_spec_id' => $goods['goods_sku']['goods_spec_id'],
'goods_attr' => $goods['goods_sku']['goods_attr'],
'content' => $goods['content'],
'goods_no' => $goods['goods_sku']['goods_no'],
'goods_price' => $goods['goods_sku']['goods_price'],
'line_price' => $goods['goods_sku']['line_price'],
'goods_weight' => $goods['goods_sku']['goods_weight'],
'total_num' => $goods['total_num'],
'total_price' => $goods['total_price'],
];
// 下单减库存
$goods['deduct_stock_type'] === '10' && $deductStockData[] = [
'goods_spec_id' => $goods['goods_sku']['goods_spec_id'],
'stock_num' => ['dec', $goods['total_num']]
];
}
// 保存订单商品信息
$this->goods()->saveAll($goodsList);
// 更新商品库存
!empty($deductStockData) && (new Litestoregoodsspec)->isUpdate()->saveAll($deductStockData);
// 记录收货地址
$this->address()->save([
'user_id' => $user_id,
'name' => $order['address']['name'],
'phone' => $order['address']['phone'],
'province_id' => $order['address']['province_id'],
'city_id' => $order['address']['city_id'],
'region_id' => $order['address']['region_id'],
'detail' => $order['address']['detail'],
]);
Db::commit();
return true;
}
public function getPayStatusList()
{
return ['10' => __('Pay_status 10'),'20' => __('Pay_status 20')];
}
public function getFreightStatusList()
{
return ['10' => __('Freight_status 10'),'20' => __('Freight_status 20')];
}
public function getReceiptStatusList()
{
return ['10' => __('Receipt_status 10'),'20' => __('Receipt_status 20')];
}
public function getOrderStatusList()
{
return ['10' => __('Order_status 10'),'20' => __('Order_status 20'),'30' => __('Order_status 30')];
}
public function getPayStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['pay_status']) ? $data['pay_status'] : '');
$list = $this->getPayStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getPayTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['pay_time']) ? $data['pay_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getFreightStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['freight_status']) ? $data['freight_status'] : '');
$list = $this->getFreightStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getFreightTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['freight_time']) ? $data['freight_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getReceiptStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['receipt_status']) ? $data['receipt_status'] : '');
$list = $this->getReceiptStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getReceiptTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['receipt_time']) ? $data['receipt_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getOrderStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['order_status']) ? $data['order_status'] : '');
$list = $this->getOrderStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getCreattimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['createtime']) ? $data['createtime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;;
}
protected function setPayTimeAttr($value)
{
return $value && !is_numeric($value) ? strtotime($value) : $value;
}
protected function setFreightTimeAttr($value)
{
return $value && !is_numeric($value) ? strtotime($value) : $value;
}
protected function setReceiptTimeAttr($value)
{
return $value && !is_numeric($value) ? strtotime($value) : $value;
}
public function goods()
{
return $this->hasMany('Litestoreordergoods','order_id', 'id');
}
public function address()
{
return $this->hasOne('Litestoreorderaddress', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
private function setError($error)
{
empty($this->error) && $this->error = $error;
}
protected function orderNo()
{
return date('Ymd') . substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
}
public function hasError()
{
return !empty($this->error);
}
public function updatePayStatus($transaction_id)
{
Db::startTrans();
// 更新商品库存、销量
$GoodsModel = new Wxlitestoregoods;
$GoodsModel->updateStockSales($this['goods']);
// 更新订单状态
$this->save([
'pay_status' => '20',
'pay_time' => time(),
'transaction_id' => $transaction_id,
]);
Db::commit();
return true;
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
use addons\litestore\model\Area as AddArea;
class Litestoreorderaddress extends Model
{
// 表名
protected $name = 'litestore_order_address';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
// 追加属性
protected $append = ['Area'];
public function getAreaAttr($value, $data)
{
return [
'province' => AddArea::getNameById($data['province_id']),
'city' => AddArea::getNameById($data['city_id']),
'region' => AddArea::getNameById($data['region_id']),
];
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
class Litestoreordergoods extends Model
{
// 表名
protected $name = 'litestore_order_goods';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
// 追加属性
protected $append = [];
public function goods()
{
return $this->belongsTo('Wxlitestoregoods','goods_id','goods_id');
}
public function spec()
{
return $this->belongsTo('Litestoregoodsspec','spec_sku_id','spec_sku_id');
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
/**
* 规格/属性(组)模型
* Class Spec
* @package app\store\model
*/
class Litestorespec extends Model
{
// 表名
protected $name = 'litestore_spec';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = '';
/**
* 根据规格组名称查询规格id
* @param $spec_name
* @return mixed
*/
public function getSpecIdByName($spec_name)
{
return self::where(compact('spec_name'))->value('id');
}
/**
* 新增规格组
* @param $spec_name
* @return false|int
*/
public function add($spec_name)
{
return $this->save(compact('spec_name'));
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
/**
* 规格/属性(组)模型
* Class Spec
* @package app\store\model
*/
class Litestorespecvalue extends Model
{
// 表名
protected $name = 'litestore_spec_value';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = '';
/**
* 根据规格组名称查询规格id
* @param $spec_id
* @param $spec_value
* @return mixed
*/
public function getSpecValueIdByName($spec_id, $spec_value)
{
return self::where(compact('spec_id', 'spec_value'))->value('id');
}
/**
* 新增规格值
* @param $spec_id
* @param $spec_value
* @return false|int
*/
public function add($spec_id, $spec_value)
{
return $this->save(compact('spec_value', 'spec_id'));
}
/**
* 关联规格组表
* @return $this|\think\model\relation\BelongsTo
*/
public function spec()
{
return $this->belongsTo('Litestorespec','spec_id','id');
}
}
... ...
<?php
namespace addons\litestore\model;
use think\Model;
use app\admin\model\litestore\Litestoregoods;
class Wxlitestoregoods extends Litestoregoods
{
protected $append = ['goods_sales'];
public function getGoodsSalesAttr($value, $data)
{
return $data['sales_initial'] + $data['sales_actual'];
}
//这里是最新上架的8件商品
public function getNewList()
{
return $this->with(['spec', 'category'])
->where('is_delete', '=', 0)
->where('goods_status', '=', 10)
->order(['goods_id' => 'desc', 'goods_sort' => 'asc'])
->limit(8)
->select();
}
//这里是随机的8件商品
public function getRandom8()
{
return $this->with(['spec', 'category'])
->where('is_delete', '=', 0)
->where('goods_status', '=', 10)
->orderRaw('rand()')
->limit(8)
->select();
}
public static function detail($goods_id)
{
$dataout = self::get($goods_id, ['category', 'spec', 'specRel', 'freight']);
$dataout['image'] = cdnurl(explode(",",$dataout['images'])[0], true);
return $dataout;
}
/**
* 商品多规格信息
*/
public function getGoodsSku($goods_sku_id)
{
$goodsSkuData = array_column($this['spec'], null, 'spec_sku_id');
if (!isset($goodsSkuData[$goods_sku_id])) {
return false;
}
$goods_sku = $goodsSkuData[$goods_sku_id];
// 多规格文字内容
$goods_sku['goods_attr'] = '';
if ($this['spec_type'] === '20') {
$attrs = explode('_', $goods_sku['spec_sku_id']);
$spec_rel = array_column($this['specRel'], null, 'id');
foreach ($attrs as $specValueId) {
$goods_sku['goods_attr'] .= $spec_rel[$specValueId]['spec']['spec_name'] . ':'
. $spec_rel[$specValueId]['spec_value'] . '; ';
}
//这里格式化 展示图片
$goods_sku['img_show'] = $goods_sku['spec_image']=='' ? '': cdnurl($goods_sku['spec_image'], true);
}
return $goods_sku;
}
public function getListByIds($goodsIds) {
$dataout = $this->with(['category', 'spec', 'spec_rel.spec', 'freight.rule'])
->where('goods_id', 'in', $goodsIds)->select();
$blistdatarList = [];
foreach ($dataout as $index => $item) {
$item['image'] = cdnurl(explode(",",$item['images'])[0], true);
$blistdatarList[] = $item;
}
return $blistdatarList;
}
public function updateStockSales($goodsList)
{
// 整理批量更新商品销量
$goodsSave = [];
// 批量更新商品规格:sku销量、库存
$goodsSpecSave = [];
foreach ($goodsList as $goods) {
$goodsSave[] = [
'goods_id' => $goods['goods_id'],
'sales_actual' => ['inc', $goods['total_num']]
];
$specData = [
'goods_spec_id' => $goods['goods_spec_id'],
'goods_sales' => ['inc', $goods['total_num']]
];
// 付款减库存
if ($goods['deduct_stock_type'] === '20') {
$specData['stock_num'] = ['dec', $goods['total_num']];
}
$goodsSpecSave[] = $specData;
}
// 更新商品总销量
$this->allowField(true)->isUpdate()->saveAll($goodsSave);
// 更新商品规格库存
(new Litestoregoodsspec)->isUpdate()->saveAll($goodsSpecSave);
}
}
... ...
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,viewport-fit=cover"><title>vue移动商城</title><link href=/assets/addons/litestore/vue-mobile/css/chunk-0e455c8c.e227af02.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/chunk-291f569a.86ff993e.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/chunk-32ea458a.40817dda.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/chunk-3cd027a4.90025fe8.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/chunk-585ea9bb.65e9d18a.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/chunk-683fd508.85c45e3b.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/chunk-72fb80f6.a6c6ff5d.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/chunk-7c352045.1d8301ee.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/chunk-854219ba.f049a183.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/chunk-a1e0e73c.d630cf18.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/chunk-c01442dc.8e8beb53.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/chunk-c0734d00.1f5b6216.css rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-0e455c8c.e6bc1143.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-291f569a.3df6760f.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-32ea458a.6875721f.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-3cd027a4.251a00d9.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-585ea9bb.6019f519.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-683fd508.67efcbec.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-72fb80f6.0fb8fbea.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-76f88e57.b23592ca.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-7c352045.458f60ce.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-854219ba.87b21345.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-a1e0e73c.02529220.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-c01442dc.24c8627c.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/js/chunk-c0734d00.0ca64864.js rel=prefetch><link href=/assets/addons/litestore/vue-mobile/css/app.6972b888.css rel=preload as=style><link href=/assets/addons/litestore/vue-mobile/css/chunk-vendors.5858c103.css rel=preload as=style><link href=/assets/addons/litestore/vue-mobile/js/app.76dfabef.js rel=preload as=script><link href=/assets/addons/litestore/vue-mobile/js/chunk-vendors.7b616be7.js rel=preload as=script><link href=/assets/addons/litestore/vue-mobile/css/chunk-vendors.5858c103.css rel=stylesheet><link href=/assets/addons/litestore/vue-mobile/css/app.6972b888.css rel=stylesheet></head><body><noscript><strong>We're sorry but vue-shop-vant doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/assets/addons/litestore/vue-mobile/js/chunk-vendors.7b616be7.js></script><script src=/assets/addons/litestore/vue-mobile/js/app.76dfabef.js></script></body></html>
\ No newline at end of file
... ...
# vue-shop-mobile
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Run your tests
```
npm run test
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
... ...
//项目域名地址
let url = '';
let ROOT;
//由于封装的axios请求中,会将ROOT打包进去,为了方便之后不再更改,判断了当前环境,而生成的不同的ROOT
if (process.env.NODE_ENV === 'development') {
//开发环境下的代理地址,解决本地跨域跨域,配置在config目录下的index.js dev.proxyTable中
url = 'http://mobileshop.217dan.com/';
ROOT = "/api"
} else {
//生产环境下的地址
ROOT = url;
}
module.exports.PROXYROOT = url; //代理指向地址
module.exports.ROOT = ROOT;
//为了防止 冲突
module.exports = {
PROXYROOT:url, //代理指向地址
ROOT:ROOT
}
... ...
module.exports = {
presets: [
'@vue/app'
]
}
... ...
{
"name": "vue-shop-mobile",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.18.0",
"fastclick": "^1.0.6",
"vant": "^1.6.6",
"vue": "^2.6.6",
"vue-router": "^3.0.2",
"vuex": "^3.1.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.4.0",
"@vue/cli-plugin-eslint": "^3.4.0",
"@vue/cli-service": "^3.4.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"vue-template-compiler": "^2.5.21",
"vue-waterfall-easy": "^2.4.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>vue移动商城</title>
</head>
<body>
<noscript>
<strong>We're sorry but vue-shop-vant doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
... ...
<template>
<div id="app">
<router-view />
</div>
</template>
<script>
import * as util from '@/utils/network'
export default {
created: function() {
//在页面加载时读取localStorage里的状态信息
if(localStorage.getItem("Gconfig")){
this.$store.replaceState(
Object.assign(this.$store.state,JSON.parse(localStorage.getItem("Gconfig")))
);
}
//在页面刷新时将vuex里的信息保存到localStorage里
window.addEventListener("beforeunload",()=>{
localStorage.setItem("Gconfig",JSON.stringify(this.$store.state))
})
var url = "/addons/litestore/api.wxapp/base"
let that = this;
//这里直接调用网络接口
util.get(url, { },
function(result) {
that.$store.commit('setCFG',result['data']['wxapp'])
},
);
},
}
</script>
<style>
body {
font-size: 16px;
background-color: #fff;
-webkit-font-smoothing: antialiased;
}
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
margin-bottom: 50px;
}
</style>
... ...