Browse Source

feat: api

main
wally 2 years ago
parent
commit
61f96dc77f
  1. 14
      .vscode/settings.json
  2. 9
      App.vue
  3. 37
      api/base.ts
  4. 7
      api/modules/user.ts
  5. 42
      manifest.json
  6. 1
      pages/loading/loading.vue
  7. 45
      pages/patient-list/patient-list.vue
  8. 2
      store/modules/service.ts
  9. 49
      store/modules/user.ts
  10. 2
      utils/http.ts

14
.vscode/settings.json

@ -1,3 +1,15 @@
{
"cSpell.words": ["dcloudio", "easyinput", "FILESYSTEMS", "localdata", "NIHSS", "nvue", "splashscreen", "uview", "vueuse"]
"cSpell.words": [
"dcloudio",
"easyinput",
"FILESYSTEMS",
"localdata",
"NIHSS",
"nvue",
"plusempty",
"splashscreen",
"uniui",
"uview",
"vueuse"
]
}

9
App.vue

@ -1,14 +1,23 @@
<script>
import { useUserStoreWidthOut } from './store/modules/user'
const userStore = useUserStoreWidthOut()
export default {
onLaunch: function () {
console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
console.log('App Launch')
this.login()
},
onShow: function () {
console.log('App Show')
},
onHide: function () {
console.log('App Hide')
},
methods: {
login() {
userStore.login('P000001')
}
}
}
</script>

37
api/base.ts

@ -0,0 +1,37 @@
const baseUrl = ''
export interface IParam {
pageNum?: number
pageSize?: number
sort?: string
param: object
}
export const post = (path: string, params: IParam) => {
let url = baseUrl + path
console.log('post: ', url)
// #ifdef APP-PLUS
if (!uni.host) {
const host = uni.getStorageSync(uni.$u.LOCAL_KEY.HOST)
if (!host) {
uni.showModal({
title: '提示',
content: '请先配置服务地址',
showCancel: true,
success: ({ confirm }) => {
if (confirm) {
// 跳转到配置地址的地方
}
},
})
return
}
uni.host = host
}
url = `${uni.host}${baseUrl}`
// #endif
console.log(params)
return uni.$u.post(url, params)
}

7
api/modules/user.ts

@ -1,7 +1,6 @@
import { post } from '@/api/base'
export const userApi = {
// 登录
login: async query => {
console.log(query)
return null
},
login: async (padNo: string) => post('/pad/login', { param: { padNo } }),
}

42
manifest.json

@ -36,8 +36,44 @@
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
"ios" : {},
"sdkConfigs" : {}
"ios" : {
"dSYMs" : false
},
"sdkConfigs" : {
"ad" : {}
},
"icons" : {
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
},
"ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
}
}
}
}
},
"vueVersion" : "3",
@ -46,7 +82,7 @@
"open" : false,
"proxy" : {
"/service" : {
"target" : "http://110.178.211.221:38818/cyjg-webapp",
"target" : "http://test.tall.wiki:9002",
"changeOrigin" : true,
"pathRewrite" : {
"^/service" : ""

1
pages/loading/loading.vue

@ -23,6 +23,7 @@ import { ref } from 'vue';
import { useServiceStore } from '@/store/modules/service';
const service = useServiceStore()
const leftTime = ref(6)
const popupRef = ref()
let timer: number | undefined

45
pages/patient-list/patient-list.vue

@ -4,8 +4,15 @@
<uni-section title="患者列表" type="line" class="uni-my-5" titleFontSize="16px"></uni-section>
<uni-grid :column="4" :highlight="true" :square="false" :show-border="false" @change="onClickItem">
<uni-grid-item v-for="(item, index) in data" :index="index" :key="index" class="u-p-20">
<view class="list-item flex">
<uni-grid-item :index="0" class="u-p-20 ">
<view class="list-item flex justify-center">
<view class="icon-plus bg-main"><uni-icons type="plusempty" color="#fff" size="14" /></view>
<text class="font-bold primary">创建患者</text>
</view>
</uni-grid-item>
<uni-grid-item v-for="(item, index) in data" :index="index + 1" :key="index + 1" class="u-p-20">
<view class="list-item flex active">
<view class="flex-1">
<view class="text-title">
<text>{{ item.name }}</text>
@ -25,7 +32,7 @@
</uni-grid-item>
</uni-grid>
<image class="create-user" src="@/static/images/create-user.png" mode="scaleToFill" />
<image class="create-user" src="@/static/images/bed.png" mode="scaleToFill" />
</view>
</template>
@ -50,18 +57,37 @@ const data: IPatient[] = [
function onClickItem(event) {
const item = data[event.detail.index]
serviceStore.setCurrentPatient(item)
uni.$u.openPage('detail1')
uni.$u.openPage('detail2')
}
</script>
<style lang="scss" scoped>
@import "@/uni.scss";
.list-item {
width: 100%;
background-color: #fff;
border-radius: 6px;
padding: 1.5em 1em;
margin-right: 1.2em;
height: 220rpx;
&.active {
@extend .bg-main-v;
.text-title {
color: #fff
}
.text-summary {
color: #fff
}
:deep(.uniui-forward) {
color: #fff !important;
}
}
.text-title {
font-size: 15px;
@ -84,6 +110,17 @@ function onClickItem(event) {
}
}
.icon-plus {
width: 1.5em;
height: 1.5em;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
margin-right: 0.5em;
font-weight: bold;
}
.create-user {
position: absolute;
right: 10px;

2
store/modules/service.ts

@ -1,5 +1,3 @@
import type { ICarPerson, IListItem, IOutCheckArea, IPicArea } from '@/types/service'
import { defineStore } from 'pinia'
import { store } from '@/store'

49
store/modules/user.ts

@ -1,37 +1,27 @@
import type { IStationInfo, IUser } from '@/types/user'
import type { IUser } from '@/types/user'
import { defineStore } from 'pinia'
import { store } from '@/store'
interface UserState {
user: null | IUser // 用户信息
stationInfo: null | IStationInfo // 检测站信息
}
export const useUserStore = defineStore({
id: 'user',
state: (): UserState => ({
user: null,
stationInfo: null,
}),
getters: {
// 用户姓名
getUserRealName: ({ user }) => user?.xm || '',
// 检测站编号
getStationNo: ({ user }) => user?.jczbh || '',
// 身份证号码
getIdCard: ({ user }) => user?.sfzmhm || '',
// 获取检测站名称
getStationName: ({ stationInfo }) => stationInfo?.jczmc || '',
},
getters: {},
actions: {
// 登录
async login(query) {
async login(padNo: string) {
console.log('store: login')
try {
const res = await uni.$u.api.login(query)
const res = await uni.$u.api.login(padNo)
console.log(res)
if (res?.length) {
uni.setStorageSync('user', JSON.stringify(res[0]))
@ -39,11 +29,11 @@ export const useUserStore = defineStore({
uni.$u.toast('登录成功')
this.getStationInfo(this.user!.jczbh)
// this.getStationInfo(this.user!.jczbh)
setTimeout(() => {
uni.switchTab({ url: '/pages/index/index' })
}, 1500)
// setTimeout(() => {
// uni.switchTab({ url: '/pages/index/index' })
// }, 1500)
return
}
@ -55,23 +45,6 @@ export const useUserStore = defineStore({
}
},
// 获取检测站信息
async getStationInfo(stationNo: string) {
try {
const res = await uni.$u.api.getStationInfo(stationNo)
this.stationInfo = res?.length ? res[0] : null
if (res?.length) {
this.stationInfo = res[0]
uni.setStorageSync('station', JSON.stringify(this.stationInfo))
} else {
uni.removeStorageSync('station')
}
} catch (error: any) {
this.stationInfo = null
uni.removeStorageSync('station')
}
},
setUser(data) {
this.user = data || null
},

2
utils/http.ts

@ -6,7 +6,7 @@ export function setupHttp() {
loadingText: '努力加载中~',
loadingTime: 800,
header: {
'Content-Type': 'text/xml;charset=utf-8',
'Content-Type': 'application/json;charset=utf-8',
'Access-Control-Allow-Origin': '*',
},
})

Loading…
Cancel
Save