w-ui-v1 1.0.83 → 1.0.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts CHANGED
@@ -15,6 +15,8 @@ import WFormMessageBox from './w-form-message-box/w-form-message-box.vue'
15
15
  import WAudio from './w-audio/w-audio.vue'
16
16
  import WReportTable from './w-report-table/w-report-table.vue'
17
17
  import WFormControlVue from './w-form-control/w-form-control.vue'
18
+ import WScanBindingSensor from './w-scan-binding-sensor/w-scan-binding-sensor.vue'
19
+ import WUpdateVersion from './w-update-version/w-update-version.vue'
18
20
  import {menu} from './utils/apis/menu'
19
21
  import request from './utils/http'
20
22
  import nfc from './utils/nfc'
@@ -35,7 +37,9 @@ const coms: any[] = [
35
37
  WFormMessageBox,
36
38
  WAudio,
37
39
  WReportTable,
38
- WFormControlVue
40
+ WFormControlVue,
41
+ WScanBindingSensor,
42
+ WUpdateVersion
39
43
  ]
40
44
  // 批量组件注册
41
45
  function install(Vue: App) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w-ui-v1",
3
- "version": "1.0.83",
3
+ "version": "1.0.85",
4
4
  "description": "w-ui",
5
5
  "author": "wgxshh",
6
6
  "license": "ISC",
@@ -0,0 +1,149 @@
1
+ <template>
2
+ <view class="user">
3
+ <view class="top-box">
4
+ <!-- 用户头部信息 -->
5
+ <view class="user-header">
6
+ <view class="user-info">
7
+ <!-- <img src="user.avatar" class="avatar" alt="用户头像"> -->
8
+ <image class="avatar" src="./user-avatar-fill.png" mode=""></image>
9
+ <view class="user-text">
10
+ <view class="user-name">{{ userInfo.name }}</view>
11
+ <view class="user-nickname">
12
+ 昵称:{{ userInfo.nickName }}
13
+ </view>
14
+ </view>
15
+ </view>
16
+ </view>
17
+ </view>
18
+
19
+ <wd-cell-group>
20
+ <wd-cell title="个人信息" icon="user" v-if="userInfo.viewPersonalInfoable" :is-link="true" :clickable="true"
21
+ @click="goUserInfo" />
22
+ <!-- <wd-cell title="修改密码" icon="keywords" :is-link="true" :clickable="true" /> -->
23
+ <wd-cell title="退出登录" icon="logout" :is-link="true" :clickable="true" @click="quit" />
24
+ </wd-cell-group>
25
+ <wd-message-box />
26
+ </view>
27
+ </template>
28
+
29
+ <script setup lang="ts">
30
+ import { ref } from 'vue';
31
+ import {
32
+ useMessage
33
+ } from 'wot-design-uni'
34
+ defineOptions({
35
+ name: 'WUser'
36
+ })
37
+ const message = useMessage()
38
+ const userInfo = ref({
39
+ name: uni.getStorageSync('userInfo').name,
40
+ nickName: uni.getStorageSync('userInfo').nickName,
41
+ viewPersonalInfoable: uni.getStorageSync('userInfo').viewPersonalInfoable
42
+ })
43
+
44
+ //退出登录
45
+ const quit = () => {
46
+ message
47
+ .confirm({
48
+ // msg: '提示文案',
49
+ title: '退出登录'
50
+ })
51
+ .then(() => {
52
+ uni.removeStorageSync('token')
53
+ uni.reLaunch({
54
+ url: '/pages/login/login'
55
+ })
56
+ })
57
+ .catch(() => {
58
+ console.log('点击了取消按钮')
59
+ })
60
+
61
+ }
62
+
63
+ //查看用户信息
64
+ const goUserInfo = () => {
65
+ uni.navigateTo({
66
+ url: `/pages/detail/detail?sourceId=${uni.getStorageSync('userInfo').gtmplSourceId}&code=${uni.getStorageSync('userInfo').id}`
67
+ })
68
+ }
69
+ </script>
70
+
71
+ <style scoped lang="scss">
72
+ .user {
73
+ background-color: #f5f5f5;
74
+ // height: 100vh;
75
+
76
+ .top-box {
77
+ padding: 15px;
78
+ .user-header {
79
+ border-radius: 10px;
80
+ margin: auto;
81
+ background: linear-gradient(135deg, #4a6cf7 0%, #2541b2 100%);
82
+ color: white;
83
+ padding: 30px 20px;
84
+ box-shadow: 0 4px 12px rgba(74, 108, 247, 0.2);
85
+ position: relative;
86
+ overflow: hidden;
87
+ }
88
+
89
+ .user-header::before {
90
+ content: "";
91
+ position: absolute;
92
+ top: -50px;
93
+ right: -50px;
94
+ width: 150px;
95
+ height: 150px;
96
+ background: rgba(255, 255, 255, 0.1);
97
+ border-radius: 50%;
98
+ }
99
+
100
+ .user-header::after {
101
+ content: "";
102
+ position: absolute;
103
+ bottom: -80px;
104
+ left: -30px;
105
+ width: 200px;
106
+ height: 200px;
107
+ background: rgba(255, 255, 255, 0.05);
108
+ border-radius: 50%;
109
+ }
110
+
111
+ .user-info {
112
+ display: flex;
113
+ align-items: center;
114
+ position: relative;
115
+ z-index: 1;
116
+ }
117
+
118
+ .avatar {
119
+ width: 140rpx;
120
+ height: 140rpx;
121
+ border-radius: 50%;
122
+ border: 3px solid rgba(255, 255, 255, 0.3);
123
+ margin-right: 15px;
124
+ object-fit: cover;
125
+ // background-color: #fff;
126
+ }
127
+
128
+ .user-text {
129
+ flex: 1;
130
+ }
131
+
132
+ .user-name {
133
+ font-size: 20px;
134
+ font-weight: 600;
135
+ margin-bottom: 5px;
136
+ }
137
+
138
+ .user-nickname {
139
+ font-size: 14px;
140
+ opacity: 0.9;
141
+ display: flex;
142
+ align-items: center;
143
+ }
144
+ }
145
+
146
+
147
+
148
+ }
149
+ </style>
@@ -0,0 +1,69 @@
1
+ <template>
2
+ <view class="bindBox">
3
+ <view class="iconBox">
4
+ <wd-icon name="scan" size="150rpx" @click="scan"></wd-icon>
5
+ </view>
6
+ <wd-input v-model="code" placeholder="请输入传感器编号" />
7
+ <wd-button @click="enter">确认</wd-button>
8
+ </view>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import { ref ,computed} from 'vue'
13
+ import { onShow, onLoad, onHide } from '@dcloudio/uni-app'
14
+ defineOptions({
15
+ name: 'WScanBindingSensor',
16
+ })
17
+ // 传感器编号
18
+ const code =ref("")
19
+ onShow(()=>{
20
+ code.value=uni.getStorageSync('sensorCode')
21
+ })
22
+ // 扫码
23
+ const scan = () => {
24
+ uni.scanCode({
25
+ fail: (e) => {
26
+ uni.showToast({
27
+ title: '扫码失败',
28
+ icon: 'error',
29
+ })
30
+ },
31
+ success: (e) => {
32
+ if (!e.result) {
33
+ return uni.showToast({
34
+ title: '扫码结果为空',
35
+ icon: 'error',
36
+ })
37
+ }
38
+ // 判断扫码结果与当前保存的传感器编号是否一致
39
+ if (e.result !== uni.getStorageSync('SENSORCODE')) {
40
+ uni.showToast({
41
+ title: '更新设备成功',
42
+ })
43
+ }
44
+ code.value = e.result // 扫码结果
45
+ uni.setStorageSync('sensorCode',e.result)
46
+ enter()
47
+ },
48
+ })
49
+ }
50
+ const enter = () => {
51
+
52
+ uni.navigateBack()
53
+ }
54
+ </script>
55
+
56
+ <style lang="scss" scoped>
57
+ .bindBox {
58
+ background-color: #fff;
59
+ display: flex;
60
+ flex-direction: column;
61
+ gap: 20rpx;
62
+ justify-content: center;
63
+ padding: 32rpx;
64
+ .iconBox {
65
+ display: flex;
66
+ justify-content: center;
67
+ }
68
+ }
69
+ </style>
@@ -45,10 +45,9 @@ const pageData = ref<{
45
45
  buttons: string[]
46
46
  }>({ criterias: [], buttons: [] })
47
47
  onLoad((option: any) => {
48
- console.log(option.query,'jjj')
49
48
  sourceId.value = props.sourceId || option.sourceId
50
49
  mainCode.value = props.mainCode ||option.mainCode
51
- query.value=props.query || option.query
50
+ query.value=props.query || (option.query?JSON.parse(option.query).join('&'):'')
52
51
 
53
52
  uni.setNavigationBarTitle({ title: option.pageTitle })
54
53
  getPageConfig()
@@ -0,0 +1,207 @@
1
+ <template>
2
+ <!-- 更新app组件 -->
3
+ <wd-popup
4
+ v-model="show"
5
+ custom-style="border-radius:32rpx;"
6
+ @close="handleClose"
7
+ @before-enter="beforeEnter"
8
+ :z-index="99999999"
9
+ :close-on-click-modal="false"
10
+ :closable="closable"
11
+ >
12
+ <view class="loadingBox" v-if="loading">
13
+ <wd-loading />
14
+ </view>
15
+ <view class="updateBox" v-else>
16
+ <wd-text text="更新提示" :bold="true" color="#333" />
17
+ <wd-text :text="'当前版本:' + currentVersion + ' 最新版本:' + latestVersion" color="#333" />
18
+ <wd-text v-if="isUpdate > 0" :text="updateContent" lineHeight="20px" :lines="4"></wd-text>
19
+ <wd-button v-if="isUpdate !== 0" @click="actionUpdate" style="margin-top: auto">更新</wd-button>
20
+ <view class="calc" v-if="enterUpdate">
21
+ <wd-progress :percentage="percentage" />
22
+ <!-- <wd-button @click="calce">取消</wd-button> -->
23
+ </view>
24
+ </view>
25
+ </wd-popup>
26
+ </template>
27
+
28
+ <script setup lang="ts">
29
+ import { ref, computed, defineEmits } from 'vue'
30
+ defineOptions({
31
+ name:'WUpdateVersion'
32
+ })
33
+ const emit = defineEmits(['close'])
34
+ const closable = ref(true)
35
+ const loading = ref(false)
36
+ const percentage = ref(0) // 进度条数字
37
+ const entities = ref([])
38
+ // 更新内容
39
+ const updateContent = ref('')
40
+
41
+ const prop = defineProps({
42
+ show: {
43
+ type: Boolean,
44
+ default: false,
45
+ },
46
+ hydrocarbonProgramToken:{
47
+ type: String,
48
+ default: '',
49
+ },
50
+ baseUrl:{
51
+ type: String,
52
+ default: '',
53
+ }
54
+ })
55
+ // 计算属性,弹窗开关
56
+ const show = computed({
57
+ get() {
58
+ return prop.show
59
+ },
60
+
61
+ set(value) {
62
+ emit('close', value)
63
+ },
64
+ })
65
+ const enterUpdate = ref(false)
66
+ const isUpdate = ref(0)
67
+ // 当前版本
68
+ const currentVersion = ref('')
69
+
70
+ // 最新版本
71
+ const latestVersion = ref('')
72
+
73
+ // 关闭弹窗
74
+ const handleClose = () => {
75
+ show.value = false
76
+ }
77
+
78
+ // 弹框进入时检查更新
79
+ const beforeEnter = async () => {
80
+ loading.value = true
81
+ // 获取当前应用版本号
82
+ const v1 = await new Promise<string>((resolve, reject) => {
83
+ plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
84
+ resolve(widgetInfo.version)
85
+ })
86
+ })
87
+ currentVersion.value = v1
88
+ // 获取接口最新版本号
89
+ uni.request({
90
+ url:
91
+ prop.baseUrl +
92
+ '/v3/mstruc/data?sourceId=x6PQag0EbU&depth=1&sortColIds=创建时间_DESC&pageNo=1&pageSize=1&c_app编码_equals=418907889311981574&c_标记删除_equals=否',
93
+ method: 'GET',
94
+ header: {
95
+ 'hydrocarbon-program-token': prop.hydrocarbonProgramToken,
96
+ },
97
+ success: (res: any) => {
98
+ if (res.statusCode === 200) {
99
+ if (res.data.entities.length > 0) {
100
+ latestVersion.value = res.data.entities[0]['版本号'] // 最新版本号
101
+ isUpdate.value = compareVersions(currentVersion.value, latestVersion.value) // 比较版本号
102
+ entities.value = res.data.entities // 获取接口数据
103
+ updateContent.value = res.data.entities[0]['更新内容'] // 更新内容
104
+ }
105
+ }
106
+
107
+ loading.value = false
108
+ },
109
+ fail: (err) => {
110
+ loading.value = false
111
+ console.log('接口版本err:', err)
112
+ },
113
+ })
114
+ }
115
+
116
+ // 下载安装包
117
+ const downloadApk = (code, name) => {
118
+ // 发起下载请求
119
+ const downloadTask = uni.downloadFile({
120
+ url:prop.baseUrl + '/v3/files/hwane27308/' + code + '/' + name,
121
+ success: (res) => {
122
+ if (res.statusCode === 200) {
123
+ if (!res.tempFilePath) return
124
+ // 下载完成后安装 APK
125
+ plus.runtime.install(
126
+ res.tempFilePath,
127
+ {
128
+ force: true, // 强制安装
129
+ },
130
+ () => {
131
+ // 重启应用
132
+ // plus.runtime.restart()
133
+ // 关闭更新弹框
134
+ show.value = false
135
+ percentage.value = 0
136
+ enterUpdate.value = false
137
+ closable.value = true
138
+ },
139
+ )
140
+ }
141
+ },
142
+ })
143
+
144
+ // 监听下载进度变化
145
+ downloadTask.onProgressUpdate((res) => {
146
+ console.log('当前进度:', res.progress + '%')
147
+ // 更新 UI(例如进度条)
148
+ percentage.value = res.progress // 假设 this.progress 是绑定的数据
149
+ })
150
+ }
151
+
152
+ // 版本号比对 1:大于当前版本,-1:小于当前版本,0:版本号相同
153
+ const compareVersions = (v1, v2) => {
154
+ // 接口版本
155
+ const v2Parts = v2.split('.').map(Number)
156
+ // 本地版本
157
+ const v1Parts = v1.split('.').map(Number)
158
+ for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
159
+ const part1 = v1Parts[i] || 0
160
+ const part2 = v2Parts[i] || 0
161
+ if (part1 !== part2) return part1 < part2 ? 1 : -1
162
+ }
163
+ return 0
164
+ }
165
+
166
+ // 更新按钮点击事件
167
+ const actionUpdate = () => {
168
+ enterUpdate.value = true
169
+ closable.value = false
170
+ isUpdate.value = 0
171
+ // 获取最新安装包
172
+ downloadApk(entities.value[0]['安装包唯一编码'], entities.value[0]['安装包名称'])
173
+ }
174
+ // 取消更新按钮点击事件
175
+ const calce = () => {
176
+ enterUpdate.value = false
177
+ closable.value = true
178
+ }
179
+ </script>
180
+
181
+ <style lang="scss" scoped>
182
+ .updateBox {
183
+ display: flex;
184
+ flex-direction: column;
185
+ align-items: center;
186
+ width: 600rpx;
187
+ min-height: 200rpx;
188
+ padding: 32rpx;
189
+ background-color: #fff;
190
+ border-radius: 32rpx;
191
+ .calc {
192
+ width: 550rpx;
193
+ margin-top: 40rpx;
194
+ text-align: center;
195
+ }
196
+ }
197
+ .loadingBox {
198
+ display: flex;
199
+ align-items: center;
200
+ justify-content: center;
201
+ width: 600rpx;
202
+ height: 200rpx;
203
+ padding: 32rpx;
204
+ background-color: #fff;
205
+ border-radius: 32rpx;
206
+ }
207
+ </style>