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/*
.history
.idea
.vscode
.hbuilderx
.DS_Store

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 = {
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>
<!-- 创建患者 -->
<!-- <CreatePatient @on-scan="uploadImage" @on-cancel="onCancel" @on-confirm="onConfirm" /> -->
<!-- float button -->
<FloatButton />
</view>
@ -150,6 +153,17 @@ function onClickLeft() {
function onClickRight() {
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>
<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" />
<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">
<CreatePatient @on-scan="uploadImage" @on-cancel="onCancel" @on-confirm="onConfirm" />
<SettingPad @on-confirm="onSettingCancel" @on-cancel="onSettingCancel" />
</uni-popup>
</view>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { useServiceStore } from '@/store/modules/service';
const service = useServiceStore()
const leftTime = ref(6)
const popupRef = ref()
let timer: number | undefined
const showCreateBtn = ref(true)
function init() {
service.syncDevice()
const localFirst = uni.getStorageSync(uni.$u.LOCAL_KEY.LOADED)
if (localFirst) {
openPage('patient-list')
return
}
if (localFirst) { showCreateBtn.value = false }
uni.setStorageSync(uni.$u.LOCAL_KEY.LOADED, 'true')
@ -42,7 +48,7 @@ function init() {
}
//
function handleCreate() {
function openSetting() {
if (timer) {
clearInterval(timer)
timer = undefined
@ -50,27 +56,10 @@ function handleCreate() {
popupRef.value.open()
}
function uploadImage() {
uni.chooseImage({
count: 1,
sizeType: ['original'], //
sourceType: ['album', 'camera'], //
success: function (res) {
console.log(JSON.stringify(res.tempFilePaths));
}
});
}
function onCancel() {
// 退loading
function onSettingCancel() {
popupRef.value.close()
}
function onConfirm() {
// TODO:
openPage('detail1')
onCancel()
openPage('patient-list')
}
//
@ -98,4 +87,10 @@ init()
width: 560rpx;
height: 100rpx;
}
.icon-setting {
position: fixed;
right: 40px;
bottom: 30px;
}
</style>

0
pnpm-lock.yaml

33
store/modules/service.ts

@ -15,20 +15,49 @@ export interface IPatient {
export interface ServiceState {
currentPatient: null | IPatient
device: null | { deviceNo: string; host: string }
}
export const useServiceStore = defineStore({
id: 'service',
state: (): ServiceState => ({
currentPatient: null,
currentPatient: null, // 当前病友的信息
device: null, // 当前设备的信息
}),
getters: {},
getters: {
deviceNo: ({ device }) => device?.deviceNo || '',
host: ({ device }) => device?.host || '',
},
actions: {
setCurrentPatient(patient: IPatient) {
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 {boolean} isRedirect
* @param {string} query ? name=wally&age=17
@ -7,8 +7,12 @@
export function openPage(pageName: string, isRedirect = false, query?: string) {
const path = query ? `/pages/${pageName}/${pageName}?${query}` : `/pages/${pageName}/${pageName}`
if (isRedirect) {
uni.redirectTo({ url: path })
setTimeout(() => {
uni.redirectTo({ url: path })
}, 1000)
} else {
uni.navigateTo({ url: path })
setTimeout(() => {
uni.navigateTo({ url: path })
}, 1000)
}
}

Loading…
Cancel
Save