本地开发

环境介绍

  • 操作系统 Windows 10 64位
  • Node.js 8.9.0 (x64)
  • MySQL 5.7
  • 最新版微信开发者工具 windows 64

开始使用

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

    注意数据库字符编码为utf8mb4

  • 更改数据库配置 src/common/config/database.js
  1. const mysql = require('think-model-mysql');
  2. module.exports = {
  3. handle: mysql,
  4. database: 'nideshop',
  5. prefix: 'nideshop_',
  6. encoding: 'utf8mb4',
  7. host: '127.0.0.1',
  8. port: '3306',
  9. user: 'root',
  10. password: '你的密码',
  11. dateStrings: true
  12. };
  • 填写微信登录和微信支付配置 src/common/config/config.js

    1. // default config
    2. module.exports = {
    3. default_module: 'api',
    4. weixin: {
    5. appid: '', // 小程序 appid
    6. secret: '', // 小程序密钥
    7. mch_id: '', // 商户帐号ID
    8. partner_key: '', // 微信支付密钥
    9. notify_url: '' // 微信异步通知,例:https://www.nideshop.com/api/pay/notify
    10. }
    11. };
  • 安装依赖并启动

    1. npm install
    2. npm start

    访问http://127.0.0.1:8360/