Browse Source

feat ; loading pad-setting

main
wally 2 years ago
parent
commit
b43f27b4ec
  1. 4
      .gitignore
  2. 16
      .hbuilderx/launch.json
  3. 3
      .vscode/settings.json
  4. 0
      App.vue
  5. 59
      components/SettingPad/SettingPad.vue
  6. 2
      config/local.ts
  7. 0
      index.html
  8. 0
      main.js
  9. 0
      manifest.json
  10. 0
      package.json
  11. 0
      pages.json
  12. 14
      pages/detail1/detail1.vue
  13. 49
      pages/loading/loading.vue
  14. 0
      pnpm-lock.yaml
  15. 33
      store/modules/service.ts
  16. 0
      tsconfig.json
  17. 0
      uni-webview-js.js
  18. 0
      uni.scss
  19. 10
      utils/common.ts

4
.gitignore

@ -144,6 +144,4 @@ dist/
unpackage/ unpackage/
unpackage/* unpackage/*
.history .history
.idea .DS_Store
.vscode
.hbuilderx

16
.hbuilderx/launch.json

@ -0,0 +1,16 @@
{ // launch.json configurations app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtypelocalremote, localremote
"version": "0.0",
"configurations": [{
"app-plus" :
{
"launchtype" : "local"
},
"default" :
{
"launchtype" : "local"
},
"type" : "uniCloud"
}
]
}

3
.vscode/settings.json

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

0
App.vue

59
components/SettingPad/SettingPad.vue

@ -0,0 +1,59 @@
<template>
<uni-card :is-shadow="false" :border="false" style="width: 40vw" padding="10px">
<template v-slot:title>
<view class="text-center u-font-16 font-bold uni-mt-10 uni-mb-10">平板设置</view>
</template>
<uni-forms ref="formRef" :modelValue="formData" :label-width="90" :rules="rules">
<uni-forms-item label="平板编号" name="SS_DEVICE_NO">
<uni-easyinput type="text" v-model="formData.SS_DEVICE_NO" placeholder="请输入编号" />
</uni-forms-item>
<uni-forms-item label="访问域名" name="SS_ACCESS_HOST">
<uni-easyinput type="text" v-model="formData.SS_ACCESS_HOST" placeholder="请输入域名" />
</uni-forms-item>
</uni-forms>
<template v-slot:actions>
<view class="flex justify-between uni-mb-16">
<u-button size="medium" shape="circle" @click="onCancel">取消</u-button>
<u-button size="medium" type="primary" shape="circle" class="bg-main" @click="onConfirm">确定</u-button>
</view>
</template>
</uni-card>
</template>
<script lang="ts" setup>
import { reactive, ref } from 'vue';
import { useServiceStore } from '@/store/modules/service';
const emits = defineEmits(['on-cancel', 'on-confirm'])
const service = useServiceStore()
const formData = reactive({ SS_DEVICE_NO: '', SS_ACCESS_HOST: '' })
const rules = {
SS_DEVICE_NO: { rules: [{ required: true, errorMessage: '请输入平板编号' }] },
SS_ACCESS_HOST: { rules: [{ required: true, errorMessage: '请输入域名' },] },
}
const formRef = ref()
// cancel
function onCancel() { emits('on-cancel') }
// confirm
function onConfirm() {
if (!formRef.value) return
formRef.value.validate().then(() => {
// localStorage
service.setDevice({ deviceNo: formData.SS_DEVICE_NO, host: formData.SS_ACCESS_HOST })
emits('on-confirm', formData)
}).catch(error => {
console.error(error);
})
}
</script>
<style lang="scss" scoped>
</style>

2
config/local.ts

@ -1,3 +1,5 @@
export const LOCAL_KEY = { export const LOCAL_KEY = {
LOADED: 'loaded', // 用来显示启动页 有本地数据不显示启动页 没有才显示 LOADED: 'loaded', // 用来显示启动页 有本地数据不显示启动页 没有才显示
DEVICE_NO: 'SS_DEVICE_NO', // 平板编号
HOST: 'SS_ACCESS_HOST', // 域名
} }

0
index.html

0
main.js

0
manifest.json

0
package.json

0
pages.json

14
pages/detail1/detail1.vue

@ -135,6 +135,9 @@
</view> </view>
</view> </view>
<!-- 创建患者 -->
<!-- <CreatePatient @on-scan="uploadImage" @on-cancel="onCancel" @on-confirm="onConfirm" /> -->
<!-- float button --> <!-- float button -->
<FloatButton /> <FloatButton />
</view> </view>
@ -150,6 +153,17 @@ function onClickLeft() {
function onClickRight() { function onClickRight() {
uni.$u.openPage('detail2') uni.$u.openPage('detail2')
} }
function uploadImage() {
uni.chooseImage({
count: 1,
sizeType: ['original'], //
sourceType: ['album', 'camera'], //
success: function (res) {
console.log(JSON.stringify(res.tempFilePaths));
}
});
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

49
pages/loading/loading.vue

@ -6,27 +6,33 @@
<image class="loading-img" src="@/static/images/loading-img.png" mode="scaleToFill" /> <image class="loading-img" src="@/static/images/loading-img.png" mode="scaleToFill" />
<u-button class="bg-main u-m-t-50 btn-create" shape="circle" type="primary" @click="handleCreate">创建患者</u-button> <u-button v-show="showCreateBtn" class="bg-main u-m-t-50 btn-create" shape="circle" type="primary" @click="openPage('detail1')">
创建患者
</u-button>
<uni-icons type="gear-filled" color="#e9f0ff" size="32" class="icon-setting" @click="openSetting" />
<uni-popup ref="popupRef" background-color="transparent"> <uni-popup ref="popupRef" background-color="transparent">
<CreatePatient @on-scan="uploadImage" @on-cancel="onCancel" @on-confirm="onConfirm" /> <SettingPad @on-confirm="onSettingCancel" @on-cancel="onSettingCancel" />
</uni-popup> </uni-popup>
</view> </view>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { useServiceStore } from '@/store/modules/service';
const service = useServiceStore()
const leftTime = ref(6) const leftTime = ref(6)
const popupRef = ref() const popupRef = ref()
let timer: number | undefined let timer: number | undefined
const showCreateBtn = ref(true)
function init() { function init() {
service.syncDevice()
const localFirst = uni.getStorageSync(uni.$u.LOCAL_KEY.LOADED) const localFirst = uni.getStorageSync(uni.$u.LOCAL_KEY.LOADED)
if (localFirst) { if (localFirst) { showCreateBtn.value = false }
openPage('patient-list')
return
}
uni.setStorageSync(uni.$u.LOCAL_KEY.LOADED, 'true') uni.setStorageSync(uni.$u.LOCAL_KEY.LOADED, 'true')
@ -42,7 +48,7 @@ function init() {
} }
// //
function handleCreate() { function openSetting() {
if (timer) { if (timer) {
clearInterval(timer) clearInterval(timer)
timer = undefined timer = undefined
@ -50,27 +56,10 @@ function handleCreate() {
popupRef.value.open() popupRef.value.open()
} }
// 退loading
function uploadImage() { function onSettingCancel() {
uni.chooseImage({
count: 1,
sizeType: ['original'], //
sourceType: ['album', 'camera'], //
success: function (res) {
console.log(JSON.stringify(res.tempFilePaths));
}
});
}
function onCancel() {
popupRef.value.close() popupRef.value.close()
} openPage('patient-list')
function onConfirm() {
// TODO:
openPage('detail1')
onCancel()
} }
// //
@ -98,4 +87,10 @@ init()
width: 560rpx; width: 560rpx;
height: 100rpx; height: 100rpx;
} }
.icon-setting {
position: fixed;
right: 40px;
bottom: 30px;
}
</style> </style>

0
pnpm-lock.yaml

33
store/modules/service.ts

@ -15,20 +15,49 @@ export interface IPatient {
export interface ServiceState { export interface ServiceState {
currentPatient: null | IPatient currentPatient: null | IPatient
device: null | { deviceNo: string; host: string }
} }
export const useServiceStore = defineStore({ export const useServiceStore = defineStore({
id: 'service', id: 'service',
state: (): ServiceState => ({ state: (): ServiceState => ({
currentPatient: null, currentPatient: null, // 当前病友的信息
device: null, // 当前设备的信息
}), }),
getters: {}, getters: {
deviceNo: ({ device }) => device?.deviceNo || '',
host: ({ device }) => device?.host || '',
},
actions: { actions: {
setCurrentPatient(patient: IPatient) { setCurrentPatient(patient: IPatient) {
this.currentPatient = patient this.currentPatient = patient
}, },
// 设置设备信息
setDevice(device: null | { deviceNo: string; host: string }) {
this.device = device
if (device?.deviceNo) {
uni.setStorageSync(uni.$u.LOCAL_KEY.DEVICE_NO, device.deviceNo)
}
if (device?.host) {
uni.setStorageSync(uni.$u.LOCAL_KEY.HOST, device.host)
}
},
// sync local device info 2 store
// 应用启动的时候调用一次 loading页调用了
syncDevice() {
const localDeviceNo = uni.getStorageSync(uni.$u.LOCAL_KEY.DEVICE_NO)
const localDeviceHost = uni.getStorageSync(uni.$u.LOCAL_KEY.HOST)
if (localDeviceNo && localDeviceHost) {
this.device = { deviceNo: localDeviceNo, host: localDeviceHost }
} else {
this.device = null
}
},
}, },
}) })

0
tsconfig.json

0
uni-webview-js.js

0
uni.scss

10
utils/common.ts

@ -1,5 +1,5 @@
/** /**
* * timeout 1s执行
* @param {string} pageName * @param {string} pageName
* @param {boolean} isRedirect * @param {boolean} isRedirect
* @param {string} query ? name=wally&age=17 * @param {string} query ? name=wally&age=17
@ -7,8 +7,12 @@
export function openPage(pageName: string, isRedirect = false, query?: string) { export function openPage(pageName: string, isRedirect = false, query?: string) {
const path = query ? `/pages/${pageName}/${pageName}?${query}` : `/pages/${pageName}/${pageName}` const path = query ? `/pages/${pageName}/${pageName}?${query}` : `/pages/${pageName}/${pageName}`
if (isRedirect) { if (isRedirect) {
uni.redirectTo({ url: path }) setTimeout(() => {
uni.redirectTo({ url: path })
}, 1000)
} else { } else {
uni.navigateTo({ url: path }) setTimeout(() => {
uni.navigateTo({ url: path })
}, 1000)
} }
} }

Loading…
Cancel
Save