index.uvue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <uni-navbar-lite :showLeft=false title="首页"></uni-navbar-lite>
  3. <view class="page-container">
  4. <!-- 背景图 -->
  5. <!-- <image class="bg-image" src="/static/images/index/1.png" mode="widthFix"></image> -->
  6. <!-- <view class="bg-color"></view> -->
  7. <scroll-view class="page-content">
  8. <view class="db-view">
  9. <view class="db-box">
  10. <view class="db-block">
  11. <view class="db-center-1">
  12. <image class="db-image" src="/static/images/map/1.png"></image>
  13. </view>
  14. </view>
  15. <text class="db-text">待处理工单</text>
  16. </view>
  17. <view class="db-box">
  18. <view class="db-block">
  19. <view class="db-center-2">
  20. <image class="db-image" src="/static/images/map/2.png"></image>
  21. </view>
  22. </view>
  23. <text class="db-text">评分工单</text>
  24. </view>
  25. <view class="db-box">
  26. <view class="db-block">
  27. <view class="db-center-3">
  28. <image class="db-image" src="/static/images/map/2.png"></image>
  29. </view>
  30. </view>
  31. <text class="db-text">超时工单</text>
  32. </view>
  33. </view>
  34. <!-- 支流出库流量图表 -->
  35. <!-- <view class="chart-section">
  36. <text class="section-title">支流出库流量 (m³/s)</text>
  37. <flow-chart />
  38. </view> -->
  39. <view>
  40. <button @click="handlePush">通知</button>
  41. </view>
  42. </scroll-view>
  43. <!-- 底部 TabBar -->
  44. <custom-tabbar :current="0" />
  45. </view>
  46. </template>
  47. <script setup lang="uts">
  48. import { ref, onMounted } from 'vue'
  49. import { getUserInfo } from '../../utils/storage'
  50. import FlowChart from '../../components/index/flow-chart/flow-chart.uvue'
  51. // 用户名
  52. const userName = ref<string>('用户')
  53. const handleCreateChannel = (showToast : boolean) => {
  54. // #ifdef APP-ANDROID
  55. const manager = uni.getPushChannelManager()
  56. manager.setPushChannel({
  57. channelId: "msg-pass",
  58. channelDesc: "留言审核通过",
  59. soundName: "#填写配置的声音文件名#",
  60. enableLights: true,
  61. enableVibration: true,
  62. importance: 4,
  63. lockscreenVisibility: 1
  64. } as SetPushChannelOptions)
  65. if (showToast) {
  66. uni.showToast({
  67. title: "设置渠道成功"
  68. })
  69. }
  70. // #endif
  71. }
  72. const handleCreateLocalNotification = () => {
  73. if (uni.getAppAuthorizeSetting().notificationAuthorized == "authorized") {
  74. handleCreateChannel(false)
  75. const date = new Date();
  76. const hour = date.getHours()
  77. const minute = date.getMinutes()
  78. const second = date.getSeconds()
  79. const formateTime = (target : number) : string => {
  80. return target < 10 ? `0${target}` : `${target}`
  81. }
  82. uni.createPushMessage({
  83. title: "主标题(title)",
  84. content: `内容(content),创建时间: ${formateTime(hour)}:${formateTime(minute)}:${formateTime(second)}`,
  85. cover: false,
  86. channelId: "msg-pass",
  87. when: Date.now() + 10000,
  88. icon: "/static/uni.png",
  89. sound: "system",
  90. delay: 1,
  91. payload: {
  92. pkey: "pvalue1"
  93. },
  94. // #ifdef APP-HARMONY
  95. category: "SOCIAL_COMMUNICATION",
  96. // #endif
  97. // #ifndef APP-HARMONY
  98. category: "IM",
  99. // #endif
  100. success(res) {
  101. console.log("res: " + res);
  102. uni.hideToast()
  103. uni.showToast({
  104. title: "创建本地通知消息成功"
  105. })
  106. },
  107. fail(e) {
  108. console.log("fail :" + e);
  109. uni.hideToast()
  110. uni.showToast({
  111. title: "创建本地通知消息失败",
  112. icon: "error"
  113. })
  114. }
  115. })
  116. } else {
  117. uni.showToast({
  118. title: "请在设置中开启通知权限",
  119. icon: "error"
  120. })
  121. }
  122. }
  123. const handlePush = () => {
  124. // uni.navigateTo({
  125. // url: '/pages/push/index',
  126. // fail: (err: any) => {
  127. // console.log('导航失败', err)
  128. // }
  129. // })
  130. handleCreateLocalNotification();
  131. };
  132. // 初始化
  133. onMounted(() => {
  134. const userInfo = getUserInfo()
  135. if (userInfo != null) {
  136. const realName = userInfo['nickName'] as string | null
  137. userName.value = realName ?? '用户'
  138. }
  139. })
  140. </script>
  141. <style lang="scss">
  142. .page-container {
  143. position: relative;
  144. flex: 1;
  145. padding-top: env(safe-area-inset-top);
  146. background-color: #e8f0f9;
  147. }
  148. .bg-image {
  149. position: absolute;
  150. top: 0;
  151. left: 0;
  152. width: 100%;
  153. height: 100%;
  154. z-index: 0;
  155. }
  156. .bg-color {
  157. position: absolute;
  158. top: 0;
  159. left: 0;
  160. width: 100%;
  161. height: 100%;
  162. z-index: -1;
  163. background: #71a6e4;
  164. }
  165. .page-content {
  166. position: relative;
  167. flex: 1;
  168. margin-bottom: 150rpx;
  169. padding: 20rpx;
  170. z-index: 10;
  171. }
  172. .header {
  173. flex-direction: row;
  174. height: 40px;
  175. &-title {
  176. font-size: 40rpx;
  177. color: #ffffff;
  178. font-weight: bold;
  179. margin-bottom: 15rpx;
  180. }
  181. &-greeting {
  182. font-size: 28rpx;
  183. color: rgba(255, 255, 255, 0.9);
  184. }
  185. }
  186. .section-title {
  187. font-size: 32rpx;
  188. color: #333333;
  189. font-weight: bold;
  190. margin-bottom: 20rpx;
  191. }
  192. /* 图表区域 */
  193. .chart-section {
  194. padding: 30rpx;
  195. margin-bottom: 20rpx;
  196. background: linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.9) 100%);
  197. box-shadow: 0 0 16rpx 0 rgba(0, 0, 0, 0.1);
  198. border-radius: 16rpx;
  199. }
  200. .db-view{
  201. flex-direction: row;
  202. justify-content: space-between;
  203. margin-bottom: 5px;
  204. .db-box{
  205. background-color: #fff;
  206. width:80px;
  207. height: 80px;
  208. justify-content: center;
  209. align-items: center;
  210. margin-left: 3px;
  211. border-radius: 5px;
  212. .db-text{
  213. font-size:10px;
  214. }
  215. .db-center-1{
  216. justify-content: center;
  217. align-items: center;
  218. background-color: #DBEAFE;
  219. border-radius: 100px;
  220. width:50px;
  221. height:50px;
  222. }
  223. .db-center-2{
  224. justify-content: center;
  225. align-items: center;
  226. background-color: #DCFCE7;
  227. border-radius: 100px;
  228. width:50px;
  229. height:50px;
  230. }
  231. .db-center-3{
  232. justify-content: center;
  233. align-items: center;
  234. background-color: #F3E8FF;
  235. border-radius: 100px;
  236. width:50px;
  237. height:50px;
  238. }
  239. }
  240. .db-image{
  241. width:20px;
  242. height:20px;
  243. }
  244. }
  245. </style>