Files
smartParsePro/smartWeChat/README.md

75 lines
2.0 KiB
Markdown
Raw Normal View History

2020-04-26 17:34:44 +08:00
<!--
* @Author: wangzhichiao<https://github.com/wzc570738205>
* @Date: 2020-04-21 14:24:59
* @LastEditors: wangzhichiao<https://github.com/wzc570738205>
2020-05-22 10:24:14 +08:00
* @LastEditTime: 2020-05-22 10:24:03
2020-04-26 17:34:44 +08:00
-->
2020-04-15 11:26:54 +08:00
2021-06-21 09:47:52 +08:00
# 建议使用api接口此方法暂不推荐
2020-04-22 13:24:51 +08:00
## demo
2020-04-26 17:34:44 +08:00
详见```demo```文件夹
![](https://gitee.com/Wzhichao/img/raw/master/uPic/HiovfR25%20.png)
2020-04-15 11:26:54 +08:00
## 小程序引入
2020-04-20 19:01:59 +08:00
务必勾选不检验域名等等
![](https://gitee.com/Wzhichao/img/raw/master/uPic/q50LEr14%20.png)
2020-04-15 11:26:54 +08:00
将仓库中的```smartWeChat```文件夹拷贝到项目中```app.js```的同级目录
2020-04-15 11:29:33 +08:00
2020-04-15 11:29:08 +08:00
![image.png](https://gitee.com/Wzhichao/img/raw/master/uPic/P2DFuD45%20.png)
2020-04-15 11:26:54 +08:00
2020-05-22 10:15:45 +08:00
> smartWeChat/js/address_parse.js自建后台
如需要自行构建后台json文件在demo/后台json/database_export-sw0HKSJkxA1j.json
2020-05-22 09:16:55 +08:00
2020-08-10 09:21:40 +08:00
这里需要将demo里的接口替换为后台提供的接口接口格式返回可以参考https://wangzc.wang/addressJson/1
2020-05-22 09:16:55 +08:00
后台json文件···demo/后台json/database_export-sw0HKSJkxA1j.json```
> app.js
2020-04-15 11:26:54 +08:00
```
var address_parse = require("./smartWeChat/js/address_parse");
...
...
...
App({
....
smart: function (val){
return address_parse.method(val || '')
2020-04-22 11:36:03 +08:00
},
getAddressData:function(){//手动重新挂载数据
address_parse.getData()
2020-04-15 11:26:54 +08:00
}
})
```
2020-05-22 09:16:55 +08:00
> 调用.js
2020-04-15 11:26:54 +08:00
```
const app = getApp()
2020-04-20 18:56:50 +08:00
//注意!!省市区文件加载时间可能略长
//需要识别调用
2020-04-15 11:26:54 +08:00
app.smart('新疆阿克苏温宿县博孜墩柯尔克孜族乡吾斯塘博村一组306号 150-3569-6956 马云')
//ex
2020-04-20 18:56:50 +08:00
//这里改为事件触发即可
2020-04-22 11:36:03 +08:00
onLoad: function() {
2020-04-20 18:56:50 +08:00
setTimeout(function(){
2020-04-22 11:36:03 +08:00
app.getAddressData()//保险起见,手动挂载数据
var address = app.smart('广东省珠海市香洲区盘山路28号幸福茶庄,陈景勇13593464918')
console.log(address)
},10000)
}
2020-04-15 11:26:54 +08:00
```
### 数据源跟换
2020-05-19 09:47:20 +08:00
由于小程序限制文件大小不能超过2MB所以数据以接口返回若需要更新请加群联系作者
2020-04-21 12:21:20 +08:00
2020-04-22 11:36:03 +08:00
### 注,初次加载会调用接口请求数据,后续会从缓存中读取
2020-05-22 10:24:14 +08:00
### 接口地址 https://wangzc.wang/addressJson/x