Giter Site home page Giter Site logo

tumobi / nideshop Goto Github PK

View Code? Open in Web Editor NEW
5.5K 321.0 1.8K 1.46 MB

NideShop 开源微信小程序商城服务端 API(Node.js + ThinkJS)

Home Page: https://www.nideshop.com/

License: MIT License

JavaScript 100.00%
nideshop wechat-app min-program shopping nodejs thinkjs mysql b2c api weapp

nideshop's Introduction

NideShop商城(服务端)

  • 界面高仿网易严选商城(主要是2016年wap版)
  • 测试数据采集自网易严选商城
  • 功能和数据库参考ecshop
  • 服务端api基于Node.js+ThinkJS+MySQL
  • 计划添加基于Vue.js的后台管理系统、PC版、Wap版

本项目需要配合微信小程序端使用,GitHub: https://github.com/tumobi/nideshop-mini-program

本地开发环境配置

  • 克隆项目到本地
git clone https://github.com/tumobi/nideshop
  • 创建数据库nideshop并导入项目根目录下的nideshop.sql
CREATE SCHEMA `nideshop` DEFAULT CHARACTER SET utf8mb4 ;

注意数据库字符编码为utf8mb4

  • 更改数据库配置 src/common/config/database.js
const mysql = require('think-model-mysql');

module.exports = {
    handle: mysql,
    database: 'nideshop',
    prefix: 'nideshop_',
    encoding: 'utf8mb4',
    host: '127.0.0.1',
    port: '3306',
    user: 'root',
    password: '你的密码',
    dateStrings: true
};
  • 填写微信登录和微信支付配置 src/common/config/config.js
// default config
module.exports = {
  default_module: 'api',
  weixin: {
    appid: '', // 小程序 appid
    secret: '', // 小程序密钥
    mch_id: '', // 商户帐号ID
    partner_key: '', // 微信支付密钥
    notify_url: '' // 微信异步通知,例:https://www.nideshop.com/api/pay/notify
  }
};
  • 安装依赖并启动
npm install
npm start

访问http://127.0.0.1:8360/

线上部署

云服务器ECS-云主机优惠-2折上云

在阿里云(CentOS 7)上部署文档

微信小程序客户端截图

首页

专题

分类

商品列表

商品详情

购物车

订单中心

功能列表

  • 首页
  • 分类首页、分类商品、新品首发、人气推荐商品页面
  • 商品详情页面,包含加入购物车、收藏商品、商品评论功能
  • 搜索功能
  • 专题功能
  • 品牌功能
  • 完整的购物流程,商品的加入、编辑、删除、批量选择,收货地址的选择,下单支付
  • 会员中心(订单、收藏、足迹、收货地址、意见反馈) ....

交流

喜欢别忘了 Star,有问题可通过微信、公众号、QQ 群联系我,谢谢您的关注。

联系方式

nideshop's People

Contributors

remsin avatar tumobi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nideshop's Issues

请问一下这是什么情况。。。

  {"errno":0,"errmsg":"","data":{"banner":[{"id":1,"ad_position_id":1,"media_type":1,"name":"合作 谁是你的菜","link":"","image_url":"http://yanxuan.nosdn.127.net/65091eebc48899298171c2eb6696fe27.jpg","content":"合作 谁是你的菜","end_time":0,"enabled":1},{"id":2,"ad_position_id":1,"media_type":1,"name":"活动 美食节","link":"","image_url":"http://yanxuan.nosdn.127.net/bff2e49136fcef1fd829f5036e07f116.jpg","content":"活动 美食节","end_time":0,"enabled":1},{"id":3,"ad_position_id":1,"media_type":1,"name":"活动 母亲节","link":"","image_url":"http://yanxuan.nosdn.127.net/8e50c65fda145e6dd1bf4fb7ee0fcecc.jpg","content":"活动 母亲节","end_time":0,"enabled":1}],"channel":[{"id":1,"name":"居家","url":"/pages/category/category?id=1005000","icon_url":"http://ac-3yr0g9cz.clouddn.com/c031ea3cf575f885cd1c.png","sort_order":1},{"id":2,"name":"餐厨","url":"/pages/category/category?id=1005001","icon_url":"http://ac-3yr0g9cz.clouddn.com/4fbe8913819b017ebe1b.png","sort_order":2},{"id":3,"name":"配件","url":"/pages/category/category?id=1008000","icon_url":"http://ac-3yr0g9cz.clouddn.com/e8070853e6c6f5627713.png","sort_order":3},{"id":4,"name":"服装","url":"/pages/category/category?id=1005002","icon_url":"http://ac-3yr0g9cz.clouddn.com/4fa3c0c72964901c5a45.png","sort_order":4},{"id":5,"name":"志趣","url":"/pages/category/category?id=1019000","icon_url":"http://ac-

导入sql文件出错

新浪云导入nideshop.sql 出现以下错误,求解

错误
SQL 查询:

MySQL 返回:文档

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel' at line 1

下单失败:请求收货地址失败

git版本号 d957dc5 的后台,下单时请求收货地址失败:

请求详情:

Request URL:http://127.0.0.1:8360/api/cart/checkout?addressId=0&couponId=0
Request Method:GET
Status Code:200 OK
Remote Address:127.0.0.1:8360
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Connection:keep-alive
Content-Length:37
Content-Type:application/json; charset=utf-8
Date:Wed, 07 Mar 2018 14:49:55 GMT
Vary:Origin
X-Powered-By:thinkjs-3.2.7
X-Response-Time:1ms
Request Headers
view source
Accept:*/*
Accept-Encoding:gzip, deflate, br
Cache-Control:no-cache
Connection:keep-alive
content-type:application/json
Host:127.0.0.1:8360
Pragma:no-cache
User-Agent:wechatdevtools appservice port/64469

请求的相应:

{"errno":401,"errmsg":"请先登录"}

程序截图:

image

npm install 报错

npm ERR! Linux 4.15.0-43-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror http://github.com/npm/npm/issues
npm ERR! Linux 4.15.0-43-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror http://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! /home/lesvere/oss/code/node/nideshop/npm-debug.log

编译出错

npm run compile

error:SyntaxError: src/common/config/adapter.js: Unexpected token, expected ; (1:8)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] compile: babel --no-babelrc src/ --presets think-node --out-dir app/
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] compile script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

const fileCache = require('think-cache-file');
const {Console, File, DateFile} = require('think-logger3');
const path = require('path');
const database = require('./database.js');
const isDev = think.env === 'development';

/**

  • cache adapter config
  • @type {Object}
    */

exports.cache = {
type: 'file',
common: {
timeout: 24 * 60 * 60 * 1000
},
file: {
handle: fileCache,
cachePath: path.join(think.ROOT_PATH, 'runtime/cache'), // absoulte path is necessarily required
pathDepth: 1,
gcInterval: 24 * 60 * 60 * 1000 // gc interval
}
};

/**

  • model adapter config
  • @type {Object}
    */

exports.model = {
type: 'mysql',
common: {
logConnect: isDev,
logSql: isDev,
logger: msg => think.logger.info(msg)
},
mysql: {
handle: mysql,
database: 'nideshop',
prefix: 'nideshop_',
encoding: 'utf8mb4',
host: '127.0.0.1',
port: '3306',
user: 'root',
password: '我的密码',
dateStrings: true
}
};

我检查了adapter.js语法应该没错的 能帮助一起找一下原因吗?

SSL配置问题

使用acme自动配置SSL,在middleware.js里添加了
{
handle: 'resource',
enable: isDev,
options: {
root: path.join(think.ROOT_PATH, 'www'),
publicPath: /^/(static|favicon.ico|index.html|web.js|styles.css|fonts|.well-known|well-known|.well-known/acme-challenge)/
}
},

试了一下,SSL验证key文件在www里放在well-known/acme-challenge文件夹下的可以访问到,但在.well-known/acme-challenge下访问不到,不知道是为什么

项目启动不起来

更改了自己的数据库地址和端口,但是报连不上,同样的地址端口,在terminal里面就登陆上了,为啥呢?

您好,以下是发现部分界面问题

您好,以下是发现部分界面问题:

  • 分类页:滑动页面左栏不能固定
  • 分类商品页:点顶部子分类建议加载显示loading
  • 购物车页:无法修改数量
  • 商品详情页:选择规格数量,建议做成有赞那种(点击加入购物车,弹出规格和数量)
  • 下单页:收货地址建议整合微信地址库
  • 下单页:选择优惠券建议可以选择会员中心优惠券数据
  • 专题详情页:留言没有新增效果,查看更多没反应

有wiki吗

hi,大神,有api接口文档吗,这样就完美了

支付成功后,我的-订单列表中数据状态不正确

原因:支付成功后的notify回调,修改了order.pay_status=2,但是order_status并没有修改,在我的-订单列表中显示的数据只根据order_status判断,所以出现了此bug。

解决:处理好pay_status和order_status

后台管理系统

麻烦问一下作者什么时候会做后台管理系统,非常感谢!

TtpeError

安装完npm start的时候报的错
TypeError: publicController.includes is not a function

报错

xuetianhhbdeMac-mini:~ xuetianhhb$ npm install
npm WARN enoent ENOENT: no such file or directory, open '/Users/xuetianhhb/package.json'
npm WARN xuetianhhb No description
npm WARN xuetianhhb No repository field.
npm WARN xuetianhhb No README data
npm WARN xuetianhhb No license field.
xuetianhhbdeMac-mini:~ xuetianhhb$

admin/brand/upload 上传无法接收到上传文件

async uploadAction() {
        let brandFile = this.file('brand_pic');
        if (think.isEmpty(brandFile)) {
            return this.fail('保存失败');
        }
        let that = this;
        let filename = '/static/brand/' + think.uuid(32) + '.jpg';
        gm(brandFile.path)
            .resize(750, 420, "!")
            .write(think.RESOURCE_PATH + filename, function (err) {
                if (err) {
                    that.fail('图片上传失败');
                }
                that.success({
                    fileUrl: '' + filename
                });
            });
    }

这部分执行有问题
Linux服务器 执行gm.write 方法, 回调参数 err 是一个空对象,出错信息不明,不知道到底是哪里出错了。
查看 www 下的 brand 文件夹, 也没有刚上传的文件

为什么出现500错误

### `[root@hZ ~]# curl -I http://127.0.0.1:8360/

HTTP/1.1 500 Internal Server Error
Vary: Origin
X-Powered-By: thinkjs-3.2.8
Content-Type: text/html; charset=utf-8
Content-Length: 87146
Date: Wed, 15 Aug 2018 07:41:33 GMT
Connection: keep-alive
`

Incorrect table definition; there can be only one auto column and it must be defined as a key

错误
SQL 查询:

CREATE TABLE nideshop_keywords (
keyword varchar(90) NOT NULL DEFAULT '',
is_hot tinyint(1) unsigned NOT NULL DEFAULT '0',
is_default tinyint(1) unsigned NOT NULL DEFAULT '0',
is_show tinyint(1) unsigned NOT NULL DEFAULT '1',
sort_order int(11) unsigned NOT NULL DEFAULT '100',
scheme _url varchar(255) NOT NULL DEFAULT '' COMMENT '关键词的跳转链接',
id int(11) NOT NULL AUTO_INCREMENT,
type int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (keyword,id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='热闹关键词表'
MySQL 返回: 文档

#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

商品详情页报错

按教程部署到SAE,测试接口发现获取对应商品报404,/api/goods/list等其他接口正常,/api/goods/goods?id=xxx报错。
logic deprecated logic's __after method is deprecated, it will be discarded in the next version node_modules/koa-compose/index.js:42:32 logic deprecated logic's __after method is deprecated, it will be discarded in the next version node_modules/koa-compose/index.js:42:32 { NotFoundError: url/api/goods/goodsnot found. at Object.throw (/var/www/nideshop/node_modules/koa/lib/context.js:97:11) at beforeTrace.then.then (/var/www/nideshop/node_modules/think-trace/lib/index.js:33:23) at process._tickCallback (internal/process/next_tick.js:68:7) message: 'url/api/goods/goodsnot found.' } { request: { method: 'GET', url: '/api/goods/goods?id=1181000', header: { 'x-forwarded-for': '58.213.91.10, 58.213.91.10', host: 'yizaohuadian2.applinzi.com', appname: 'yizaohuadian2', appversion: '1', accesskey: 'nxz33x2z4y', secretkey: '2mxi11xkz3hkmx1y34m0mmwzy4y2z03k03hz0m1w', apphash: '273', mysqlport: '0', appcookie: 'default_version=1;saedomain=8;', appmask: '1', appsrvc: '0000000000000000', ipid: '23024', 'x-real-ip': '58.213.91.10', 'x-proto': 'SSL', 'x-forwarded-proto': 'https', 'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36', accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'zh-CN,zh;q=0.9' } }, response: { status: 404, message: 'Not Found', header: [Object: null prototype] { vary: 'Origin', 'x-powered-by': 'thinkjs-3.2.10' } }, app: { subdomainOffset: 2, proxy: true, env: 'production' }, originalUrl: '/api/goods/goods?id=1181000', req: '<original node req>', res: '<original node res>', socket: '<original node socket>' }

在CentOS6.5上安装之后启动出现Error: Cannot find module 'think-logger3'

单独执行 npm install think-logger3 --no-optional成功之后启动,同样报错找不到模块

部分报错信息如下:

module.js:471
throw err;
^

Error: Cannot find module 'think-logger3'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/mnt/html/nideshop/node_modules/thinkjs/lib/loader.js:2:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

npm ERR! Linux 2.6.32-696.1.1.el6.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.11.3
npm ERR! npm v3.10.7
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: node development.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node development.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the thinkjs-application package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node development.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs thinkjs-application
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls thinkjs-application
npm ERR! There is likely additional logging output above.

新浪sae 小程序https验证证书无效

你好,我在新浪sae上配置部署好了服务器后,在小程序上设置了相应的域名,但是在真机调试的时候,请求接口报错访问接口的证书无效,这个是为什么呢? 如何解决还请赐教!

图片读取速度问题

我看商品的图片,大约一张是200k,测试版在手机微信里打开的时候,首页的图片普遍加载很慢。我看服务器是在北美,速度和DNS应该都是挺快的,加载慢是不是单纯因为图片都较大?

加入购物车时底部栏位不显示

这个问题在开发工具上不出现,在手机上会出现.
在物品详情页点击加入购物车后,跳转的下一个场景页面底部栏位不显示

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.