diff --git a/.eslintrc b/.eslintrc
index 80fc0b5..9c1db0f 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,3 +1,17 @@
{
+ "env": {
+ "browser": true,
+ "node": true
+ },
+ "parserOptions": {
+ "parser": "@typescript-eslint/parser"
+ },
+ "globals": {
+ "defineProps": "readonly",
+ "defineEmits": "readonly",
+ "defineExpose": "readonly",
+ "withDefaults": "readonly"
+ },
+ "plugins": ["@typescript-eslint"],
"extends": ["taro/vue3"]
}
diff --git a/babel.config.js b/babel.config.js
index dc20faf..44ea29a 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -6,5 +6,25 @@ module.exports = {
framework: 'vue3',
ts: true
}]
- ]
+ ],
+ plugins: [
+ [
+ 'import',
+ {
+ libraryName: '@nutui/nutui',
+ libraryDirectory: 'dist/packages/_es',
+ camel2DashComponentName: false,
+ },
+ 'nutui3-vue',
+ ],
+ [
+ 'import',
+ {
+ libraryName: '@nutui/nutui-taro',
+ libraryDirectory: 'dist/packages/_es',
+ camel2DashComponentName: false,
+ },
+ 'nutui3-taro',
+ ],
+ ],
}
diff --git a/config/index.js b/config/index.js
index 1c69a6c..31653cf 100644
--- a/config/index.js
+++ b/config/index.js
@@ -21,7 +21,7 @@ const config = {
pxtransform: {
enable: true,
config: {
-
+ selectorBlackList: [/nut-/],
}
},
url: {
@@ -55,7 +55,8 @@ const config = {
}
}
}
- }
+ },
+ plugins: ['@tarojs/plugin-html'],
}
module.exports = function(merge) {
diff --git a/package.json b/package.json
index 9e696f7..4450682 100644
--- a/package.json
+++ b/package.json
@@ -36,22 +36,24 @@
"author": "",
"dependencies": {
"@babel/runtime": "^7.7.7",
+ "@nutui/nutui-taro": "^3.1.11",
"@tarojs/components": "3.3.11",
"@tarojs/runtime": "3.3.11",
"@tarojs/taro": "3.3.11",
"hairline": "^1.0.0",
- "taro-ui-vue3": "^1.0.0-alpha.21",
"vue": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@tarojs/mini-runner": "3.3.11",
+ "@tarojs/plugin-html": "3.3.11",
"@tarojs/plugin-less": "^2.2.10",
"@tarojs/webpack-runner": "3.3.11",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1",
"@vue/compiler-sfc": "^3.0.0",
+ "babel-plugin-import": "^1.13.3",
"babel-preset-taro": "3.3.11",
"eslint": "^6.8.0",
"eslint-config-taro": "3.3.11",
diff --git a/src/app.config.ts b/src/app.config.ts
index 1417747..d61584a 100644
--- a/src/app.config.ts
+++ b/src/app.config.ts
@@ -34,14 +34,5 @@ export default {
"text": "我的"
}]
},
- "quickMenu": {
- "share": true,
- "favorite": true,
- "sendToDesktop": true
- },
"debug": false,
- "pageAlias": {
- "index": "pages/index/index",
- "me": "pages/me/index"
- }
}
diff --git a/src/app.ts b/src/app.ts
index 67faf53..9d2e00e 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -7,13 +7,18 @@
* @FilePath: /mp-bbhj/src/app.ts
*/
import { createApp } from 'vue'
-import { createUI } from 'taro-ui-vue3'
-import { NavBar, Contact, ListContent, ShowArticle, ListRescueCard } from './components/index'
+import {
+ Icon,
+ SearchBar,
+ Cell,
+ CellGroup,
+ Button,
+ Collapse,
+ CollapseItem,
+} from '@nutui/nutui-taro'
import { mpAutoUpdate } from './common/utils.js'
+import "@nutui/nutui-taro/dist/style.css";
import './app.less'
-// import 'taro-ui-vue3/dist/style/index.scss'
-
-
const App = createApp({
onShow(options) {
@@ -23,13 +28,13 @@ const App = createApp({
// 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
})
-const tuv3 = createUI()
-App.use(tuv3)
-
-App.component(NavBar.name, NavBar)
-App.component(Contact.name, Contact)
-App.component(ListContent.name, ListContent)
-App.component(ListRescueCard.name, ListRescueCard)
-App.component(ShowArticle.name, ShowArticle)
+App
+ .use(Icon)
+ .use(SearchBar)
+ .use(Cell)
+ .use(CellGroup)
+ .use(Button)
+ .use(Collapse)
+ .use(CollapseItem)
export default App
diff --git a/src/components/Contact.vue b/src/components/Contact.vue
index 2406845..da3b6b1 100644
--- a/src/components/Contact.vue
+++ b/src/components/Contact.vue
@@ -1,20 +1,15 @@
-
+
+
-
+
+
diff --git a/src/components/ListContent.vue b/src/components/ListContent.vue
deleted file mode 100644
index fa0c133..0000000
--- a/src/components/ListContent.vue
+++ /dev/null
@@ -1,291 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- {{ item.nickname }}
-
- {{ item.title }}
-
-
-
- 失踪时间: {{item.missed_at}}
- 失踪地点: {{item.missed_address}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/components/ListRescueCard.vue b/src/components/ListRescueCard.vue
deleted file mode 100644
index 65526e9..0000000
--- a/src/components/ListRescueCard.vue
+++ /dev/null
@@ -1,313 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- {{ item.name }}
- {{ item.city }}
-
-
-
- {{
- item.district
- }}
-
-
-
-
-
-
- 上班时间:
-
- 10:00
-
-
-
-
- 下班时间:
-
- 18:00~20:00不等
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue
index a1a7aad..ab961e4 100644
--- a/src/components/NavBar.vue
+++ b/src/components/NavBar.vue
@@ -1,11 +1,11 @@
@@ -22,16 +22,8 @@
+
+
diff --git a/src/components/Search.vue b/src/components/Search.vue
deleted file mode 100644
index f0046c9..0000000
--- a/src/components/Search.vue
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/components/index.ts b/src/components/index.ts
deleted file mode 100644
index eadbb1a..0000000
--- a/src/components/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export { default as Contact } from "./Contact.vue"
-export { default as ListContent } from "./ListContent.vue"
-export { default as ListRescueCard } from "./ListRescueCard.vue"
-export { default as NavBar } from "./NavBar.vue"
-export { default as ShowArticle } from "./article/ShowArticle.vue"
\ No newline at end of file
diff --git a/src/composables/index.ts b/src/composables/index.ts
new file mode 100644
index 0000000..c1edf1e
--- /dev/null
+++ b/src/composables/index.ts
@@ -0,0 +1 @@
+export * from './list'
diff --git a/src/composables/list.ts b/src/composables/list.ts
new file mode 100644
index 0000000..d6e40f4
--- /dev/null
+++ b/src/composables/list.ts
@@ -0,0 +1,83 @@
+import { isFunction } from '@tarojs/shared'
+import { computed, Ref, ref, unref } from 'vue'
+import HTTPREQUEST from '../utils/http'
+import type { StringObject, MaybeRef } from '../types/index'
+
+interface ListAttr {
+ url: MaybeRef
+ transform?: (form: T) => T
+ immediate?: boolean
+ limit?: number
+}
+
+/**
+ * 封装获取列表
+ * @param url 请求地址
+ * @param transform 转换搜索
+ * @param immediate 是否在初始化时加载,默认: `true`
+ * @param limit 单次请求获取数据的条数,默认: `10`
+ */
+export function useList- ({
+ url,
+ transform,
+ immediate = true,
+ limit = 10,
+}: ListAttr): {
+ query: Ref
+ isFetching: Ref
+ isRefresh: Ref
+ isEnd: Ref
+ list: Ref
-
+ loadList: () => Promise
+ refreshList: () => void
+} {
+ const page = ref(1)
+ const isEnd = ref(false)
+ const isFetching = ref(false)
+ const isRefresh = ref(false)
+ const query = ref({} as Serach) as Ref
+ const list = ref
- ([]) as Ref
-
+ const payload = computed(() => {
+ const _query = transform ? transform(unref(query)) : query.value
+ return Object.assign({}, _query, { pageNo: page.value, pageSize: limit })
+ })
+
+ immediate && loadList()
+
+ async function loadList() {
+ if (isFetching.value) return
+ isFetching.value = true
+ const res = await HTTPREQUEST.get(unref(url), unref(payload)) as { data?: Item[] }
+
+ if (res?.data) {
+ list.value = list.value.concat(res.data)
+ page.value++
+ if (res.data.length < limit) {
+ isEnd.value = true
+ }
+ } else {
+ isEnd.value = true
+ }
+ isFetching.value = false
+ }
+
+ async function refreshList(done?: () => void) {
+ isRefresh.value = true
+ page.value = 1
+ isEnd.value = false
+ list.value = []
+ await loadList()
+ isRefresh.value = false
+ isFunction(done) && done()
+ }
+
+ return {
+ query,
+ isFetching,
+ isRefresh,
+ isEnd,
+ list,
+ loadList,
+ refreshList,
+ }
+}
diff --git a/src/pages/index/index.config.ts b/src/pages/index/index.config.ts
index f4b3636..b6f7c81 100644
--- a/src/pages/index/index.config.ts
+++ b/src/pages/index/index.config.ts
@@ -1,5 +1,5 @@
export default {
navigationBarTitleText: '宝贝回家',
enableShareAppMessage: true,
- enablePullDownRefresh: true
+ enablePullDownRefresh: true,
}
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index e750e20..fcc589a 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -15,21 +15,21 @@
-
-
+
-
@@ -37,50 +37,37 @@
-
diff --git a/src/pages/rescue/index.config.ts b/src/pages/rescue/index.config.ts
index aa3821c..5a9ce26 100644
--- a/src/pages/rescue/index.config.ts
+++ b/src/pages/rescue/index.config.ts
@@ -1,4 +1,5 @@
export default {
navigationBarTitleText: '救助站',
- enableShareAppMessage: true
+ enableShareAppMessage: true,
+ enablePullDownRefresh: true,
}
diff --git a/src/pages/rescue/index.vue b/src/pages/rescue/index.vue
index 726b53d..e507463 100644
--- a/src/pages/rescue/index.vue
+++ b/src/pages/rescue/index.vue
@@ -1,22 +1,45 @@
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/types/index.ts b/src/types/index.ts
new file mode 100644
index 0000000..aa72f48
--- /dev/null
+++ b/src/types/index.ts
@@ -0,0 +1 @@
+export * from './pubilc'
diff --git a/src/types/pubilc.ts b/src/types/pubilc.ts
new file mode 100644
index 0000000..a9a7783
--- /dev/null
+++ b/src/types/pubilc.ts
@@ -0,0 +1,5 @@
+import type { Ref } from 'vue'
+
+export type StringObject = Record
+
+export type MaybeRef = T | Ref
diff --git a/src/utils/api.js b/src/utils/api.js
index b38b049..8702369 100644
--- a/src/utils/api.js
+++ b/src/utils/api.js
@@ -3,6 +3,11 @@ import HTTPREQUEST from "./http"
// Use standard REST APIs, swagger:
// https://airdb.dev/redoc/?url=https://service-iw6drlfr-1251018873.sh.apigw.tencentcs.com/test/mina/docs/swagger.json
+export const API_LIST = {
+ lost: '/mina/v1/lost',
+ rescue: '/mina/v1/rescue',
+}
+
export function login(params) {
/**
* @description 登录
diff --git a/src/utils/http.js b/src/utils/http.js
index 80f0934..4020dad 100644
--- a/src/utils/http.js
+++ b/src/utils/http.js
@@ -55,7 +55,7 @@ class httpRequest {
return Taro.request(option);
}
- get(url, data = "") {
+ get(url, data) {
let option = { url, data };
return this.baseOptions(option);
}
@@ -65,12 +65,12 @@ class httpRequest {
return this.baseOptions(params, "POST");
}
- put(url, data = "") {
+ put(url, data) {
let option = { url, data };
return this.baseOptions(option, "PUT");
}
- delete(url, data = "") {
+ delete(url, data) {
let option = { url, data };
return this.baseOptions(option, "DELETE");
}
diff --git a/yarn.lock b/yarn.lock
index 1af5bea..ee69c0e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1177,6 +1177,13 @@
dependencies:
regenerator-runtime "^0.13.4"
+"@babel/runtime@^7.0.0":
+ version "7.16.3"
+ resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.3.tgz#b86f0db02a04187a3c17caa77de69840165d42d5"
+ integrity sha512-WBwekcqacdY2e9AF/Q7WLFUWmdJGJTkbjqTjoMDgXkVZ3ZRUvOPsLb5KdwISoQVsbP+DQzVZW4Zhci0DvpbNTQ==
+ dependencies:
+ regenerator-runtime "^0.13.4"
+
"@babel/runtime@^7.11.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.7.7", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
version "7.16.0"
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.0.tgz"
@@ -1311,6 +1318,14 @@
mkdirp "^1.0.4"
rimraf "^3.0.2"
+"@nutui/nutui-taro@^3.1.11":
+ version "3.1.11"
+ resolved "https://registry.yarnpkg.com/@nutui/nutui-taro/-/nutui-taro-3.1.11.tgz#7fe61c51a849565e743112275f7c5319585afec7"
+ integrity sha512-e8g6KYbNQh+U+RWuFd5m+Bq5NLgTe9aSpoLUv3CKgslL7gGXB1n+LBZP4r5ut6IrpFifuL3lVx0pmLkm5WB5+Q==
+ dependencies:
+ sass "^1.34.0"
+ vue-router "^4.0.11"
+
"@pmmmwh/react-refresh-webpack-plugin@0.4.3":
version "0.4.3"
resolved "https://registry.npmjs.org/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.4.3.tgz"
@@ -1463,6 +1478,13 @@
webpack-format-messages "^2.0.5"
yauzl "2.10.0"
+"@tarojs/plugin-html@3.3.11":
+ version "3.3.11"
+ resolved "https://registry.yarnpkg.com/@tarojs/plugin-html/-/plugin-html-3.3.11.tgz#a2a05d7217663f218ab35c8cbeef07453b559ecf"
+ integrity sha512-3qVkxKRwetVM9GWCR4s/MR1QiLlFr/azWBLFXaFKc4Cq8MwC9eMOjxCnJ11q2GGXXHO7NZAHC6MYWjj3O/bKjg==
+ dependencies:
+ "@tarojs/shared" "3.3.11"
+
"@tarojs/plugin-less@^2.2.10":
version "2.2.10"
resolved "https://registry.npmjs.org/@tarojs/plugin-less/-/plugin-less-2.2.10.tgz"
@@ -1973,6 +1995,11 @@
"@vue/compiler-dom" "3.2.21"
"@vue/shared" "3.2.21"
+"@vue/devtools-api@^6.0.0-beta.18":
+ version "6.0.0-beta.20.1"
+ resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.0.0-beta.20.1.tgz#5b499647e929c35baf2a66a399578f9aa4601142"
+ integrity sha512-R2rfiRY+kZugzWh9ZyITaovx+jpU4vgivAEAiz80kvh3yviiTU3CBuGuyWpSwGz9/C7TkSWVM/FtQRGlZ16n8Q==
+
"@vue/reactivity@3.2.21":
version "3.2.21"
resolved "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.2.21.tgz"
@@ -2595,6 +2622,14 @@ babel-plugin-global-define@^1.0.3:
resolved "https://registry.npmjs.org/babel-plugin-global-define/-/babel-plugin-global-define-1.0.3.tgz"
integrity sha512-M8Sby4wRLuLr+9UB8V31knVRf/rl0xkk51A7um6hUCvVPyOvLtI0u0k1OPiMgE2d7CwmeSa33NzGpaALHPQCPg==
+babel-plugin-import@^1.13.3:
+ version "1.13.3"
+ resolved "https://registry.yarnpkg.com/babel-plugin-import/-/babel-plugin-import-1.13.3.tgz#9dbbba7d1ac72bd412917a830d445e00941d26d7"
+ integrity sha512-1qCWdljJOrDRH/ybaCZuDgySii4yYrtQ8OJQwrcDqdt0y67N30ng3X3nABg6j7gR7qUJgcMa9OMhc4AGViDwWw==
+ dependencies:
+ "@babel/helper-module-imports" "^7.0.0"
+ "@babel/runtime" "^7.0.0"
+
babel-plugin-jsx-attributes-array-to-object@^0.3.0:
version "0.3.0"
resolved "https://registry.npmjs.org/babel-plugin-jsx-attributes-array-to-object/-/babel-plugin-jsx-attributes-array-to-object-0.3.0.tgz"
@@ -3939,11 +3974,6 @@ data-urls@^1.1.0:
whatwg-mimetype "^2.2.0"
whatwg-url "^7.0.0"
-dayjs@^1.8.29:
- version "1.10.7"
- resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.10.7.tgz"
- integrity sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig==
-
debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0:
version "2.6.9"
resolved "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz"
@@ -6659,7 +6689,7 @@ locate-path@^5.0.0:
dependencies:
p-locate "^4.1.0"
-lodash-es@4.17.15, lodash-es@^4.17.15:
+lodash-es@4.17.15:
version "4.17.15"
resolved "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.15.tgz"
integrity sha512-rlrc3yU3+JNOpZ9zj5pQtxnx2THmvRykwL4Xlxoa8I9lHBlVbbyPhgyPMioxVZ4NqyxaVVtaJnzsyOidQIhyyQ==
@@ -8980,6 +9010,13 @@ sass@1.32.11, sass@^1.23.7:
dependencies:
chokidar ">=3.0.0 <4.0.0"
+sass@^1.34.0:
+ version "1.43.4"
+ resolved "https://registry.yarnpkg.com/sass/-/sass-1.43.4.tgz#68c7d6a1b004bef49af0d9caf750e9b252105d1f"
+ integrity sha512-/ptG7KE9lxpGSYiXn7Ar+lKOv37xfWsZRtFYal2QHNigyVQDx685VFT/h7ejVr+R8w7H4tmUgtulsKl5YpveOg==
+ dependencies:
+ chokidar ">=3.0.0 <4.0.0"
+
sax@1.2.4, sax@^1.2.4, sax@~1.2.4:
version "1.2.4"
resolved "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz"
@@ -9851,14 +9888,6 @@ taro-css-to-react-native@3.3.11:
css-mediaquery "^0.1.2"
postcss-value-parser "^3.3.0"
-taro-ui-vue3@^1.0.0-alpha.21:
- version "1.0.0-alpha.21"
- resolved "https://registry.yarnpkg.com/taro-ui-vue3/-/taro-ui-vue3-1.0.0-alpha.21.tgz#68037625ad0ea4a0e5d080bc82b131309e3ec254"
- integrity sha512-3//e9gnd8VhG9913ifVZP1wwlE9i1iJwwaYkHhSFgD1RhZomHqN+nRBuzNmV+aYZzjpAYqLSpt0v7CHaIyQwdA==
- dependencies:
- dayjs "^1.8.29"
- lodash-es "^4.17.15"
-
terser-webpack-plugin@^1.4.3:
version "1.4.5"
resolved "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.5.tgz"
@@ -10455,6 +10484,13 @@ vue-loader@^16.0.0-beta.8:
hash-sum "^2.0.0"
loader-utils "^2.0.0"
+vue-router@^4.0.11:
+ version "4.0.12"
+ resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.0.12.tgz#8dc792cddf5bb1abcc3908f9064136de7e13c460"
+ integrity sha512-CPXvfqe+mZLB1kBWssssTiWg4EQERyqJZes7USiqfW9B5N2x+nHlnsM1D3b5CaJ6qgCvMmYJnz+G0iWjNCvXrg==
+ dependencies:
+ "@vue/devtools-api" "^6.0.0-beta.18"
+
vue@^3.0.0:
version "3.2.21"
resolved "https://registry.npmjs.org/vue/-/vue-3.2.21.tgz"