dfo-mall-sdk
v1.4.1
Published
开发者也可直接克隆当前仓库,使用微信开发者工具导入本项目后,执行以下步骤,快速浏览相关功能:
Downloads
35
Readme
dfo-mall-sdk微信小程序SDK使用指南
是DFO小程序SDK(本SDK)为小程序自定义组件形式,使用npm方式发布。本文引导开发者从零开始,一步一步搭建起DFO基本功能框架。如果开发者是在现有项目中集成本SDK,可直接从第2步开始阅读。
开发者也可直接克隆当前仓库,使用微信开发者工具导入本项目后,执行以下步骤,快速浏览相关功能:
- 点击IDE右上角的“详情”,修改AppID。
- 使用命令提示符或终端,进入当前项目所在本地目录,执行命令更新SDK:npm i dfo-mall-sdk@latest --production。
- 点击IDE菜单中的“工具”-“构建 npm”。
特别说明
1. 本项目所使用的AppId为接口测试号AppId,在终端上执行预览会提示错误信息,请更换为实际可用的AppId。
2. 本项目所使用token和channel为演示专用,无法应用到测试或生产环境。
通过本SDK可实现以下功能:
- 商品展示
- 商品购物
- 个人信息
项目搭建
1. 新建项目
- 启动IDE,选择小程序项目。
- 新建项目。
- 选择项目目录,输入AppID和项目名称,点击确定。
2. 修改项目设置
- 点击IDE右上角的“详情”,勾选“使用npm模块”和“不校验合法域名、web-view(业务域名)、TLS版本以及HTTPS证书”。
3. 加载SDK
- 使用命令提示符或终端,进入小程序项目所在根目录,执行命令初始化:
npm init --yes
- 初始化成功后,执行命令加载SDK:
npm i dfo-mall-sdk --production
4. npm构建
- 点击IDE菜单中的“工具”-“构建 npm”,如果构建成功,会提示“完成构建”。
5. 使用SDK创建页面
- 使用小程序IDE创建新的页面(以pages/index/index为例),编辑index.json文件,声明要使用的SDK组件。
- 编辑index.wxml文件,插入SDK组件标签。
- 编辑index.js文件,通过setData()给相应的变量赋值。
6. 如何更新SDK
- 使用命令提示符或终端,进入小程序项目所在根目录,执行命令更新:
npm i dfo-mall-sdk --production
。 - 打开小程序开发者IDE,点击IDE菜单中的“工具”-“构建 npm”。
小程序后台配置
1.登录微信小程序管理后台:https://mp.weixin.qq.com
2.点击【开发】-【开发设置】
3.在”服务器域名“中增加如下配置:
- request合法域名:
https://www.china-dfs.com
- socket合法域名:
wss://www.china-dfs.com
- uploadFile合法域名:
https://www.china-dfs.com
- downloadFile合法域名:
https://www.china-dfs.com
- UDP合法域名:
https://www.china-dfs.com
- web-view合法域名:
https://www.china-dfs.com
6. 在“设置”-“基本设置”下,将“基础库最低版本设置”设置为2.12.2或更高版本。
SDK说明
1.公共参数说明
- 说明 :以下参数为公共参数(必填),用于用户登录和身份验证,任何独立调用组件。
mobile
:Integer,需要登陆的手机号码。channel
:String,由DFO提供的第三方频道号。token
:String,由DFO提供的第三方频道加密码,加密方式请和DFO联系。isDev
:Boolen,是否是开发版本openid
:String,本地appid的openidindexPage
:String,sdk首页地址,本地系统的内页面/pages/XXX
2.可被独立调用的组件
index
: 首页cartList
: 购物车cateBrand
: 分类cateList
: 产品列表orderDetail
: 订单详情,需要设置id:orderDetail
orderList
: 订单列表,需要设置id:orderList
address
: 地址列表,需要设置id:address
userReal
: 实名认证