You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

364 lines
8.0 KiB

  1. <template>
  2. <view>
  3. </view>
  4. </template>
  5. <script>
  6. //app.js
  7. var config = require("./config");
  8. export default {
  9. onLaunch: function(options) {
  10. if (wx.canIUse('getUpdateManager')) {
  11. const updateManager = wx.getUpdateManager()
  12. updateManager.onCheckForUpdate(function(res) {
  13. if (res.hasUpdate) {
  14. updateManager.onUpdateReady(function() {
  15. uni.showModal({
  16. title: '更新提示',
  17. cancelColor: "#999999",
  18. content: '新版本已经准备好,是否重启应用?',
  19. success: function(res) {
  20. if (res.confirm) {
  21. updateManager.applyUpdate()
  22. }
  23. }
  24. })
  25. })
  26. updateManager.onUpdateFailed(function() {
  27. uni.showModal({
  28. title: '已经有新版本了哟~',
  29. cancelColor: "#999999",
  30. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  31. })
  32. })
  33. }
  34. })
  35. } else {
  36. uni.showModal({
  37. title: '提示',
  38. cancelColor: "#999999",
  39. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  40. })
  41. }
  42. const token = uni.getStorageSync("weapp_session_login_data")
  43. if (typeof token.token != "string") {
  44. return
  45. }
  46. uni.request({
  47. url: config.service.getUser,
  48. method: "GET",
  49. header: {
  50. 'content-type': 'application/json',
  51. 'Authorization': 'Bearer ' + uni.getStorageSync('weapp_session_login_data').token
  52. },
  53. success: (res) => {
  54. let rescor = res.data.data;
  55. console.log(res,'数据',rescor)
  56. // return
  57. if(res.statusCode==401){
  58. uni.showToast({
  59. title:'登陆过期请重新登陆',
  60. icon:"none",
  61. duration: 2000,
  62. })
  63. uni.navigateTo({
  64. url: `/pages/login/index`
  65. })
  66. return
  67. }
  68. if (rescor.user.total==0) {
  69. uni.showToast({
  70. title: '暂无绑定楼盘',
  71. duration: 2000,
  72. icon:"none"
  73. });
  74. return
  75. } else {
  76. let lopan = {
  77. id: rescor.houseList[0].id,
  78. name: rescor.houseList[0].propertyName
  79. }
  80. let users=rescor.user
  81. users.zkProperties=rescor.houseList
  82. console.log(users,'角色数据')
  83. uni.setStorageSync("weapp_session_userInfo_data",users); //写入缓存
  84. }
  85. }
  86. })
  87. // this.$u.get("/user/getUser")
  88. // .then(data => {
  89. // if (data.user.total==0) {
  90. // uni.showToast({
  91. // title: '暂无绑定楼盘',
  92. // duration: 2000,
  93. // icon:"none"
  94. // });
  95. // return
  96. // } else {
  97. // let lopan = {
  98. // id: data.houseList[0].id,
  99. // name: data.houseList[0].propertyName
  100. // }
  101. // let users=data.user
  102. // users.zkProperties=data.houseList
  103. // uni.setStorageSync("weapp_session_userInfo_data",users); //写入缓存
  104. // }
  105. // })
  106. wx.setInnerAudioOption({
  107. obeyMuteSwitch: false
  108. });
  109. },
  110. onShow(options) {
  111. const token = uni.getStorageSync("weapp_session_login_data")
  112. if (typeof token.token != "string") {
  113. console.log("没有")
  114. return
  115. }else{
  116. // this.infoscoket()
  117. }
  118. },
  119. onHide() {},
  120. methods: {
  121. infoscoket(){
  122. let pushon=uni.getStorageSync('weapp_session_userInfo_data').loginName
  123. uni.connectSocket({
  124. url: 'wss://hfju.com/ws?uid='+pushon+'_applets',
  125. header: {
  126. "content-type": "application/json",
  127. 'Authorization': 'Bearer '+uni.getStorageSync('weapp_session_login_data').token
  128. }
  129. });
  130. uni.onSocketOpen(function (res) {
  131. console.log('WebSocket连接已打开!');
  132. });
  133. uni.onSocketError(function (res) {
  134. console.log('WebSocket连接打开失败,请检查!');
  135. });
  136. uni.onSocketMessage(function (res) {
  137. console.log('收到服务器内容:' + res.data);
  138. let cedata=JSON.stringify(res);
  139. let data=JSON.parse(cedata);
  140. let zdata=JSON.parse(data.data)
  141. if(zdata.to=="recCmd"){
  142. uni.$emit('update',{msg:'页面更新'})
  143. return
  144. }
  145. uni.showModal({
  146. title: '提示',
  147. content: zdata.to+'的设备电量过低请检查!',
  148. cancelText: "取消", // 取消按钮的文字
  149. confirmText: "查看", // 确认按钮文字
  150. success: function (res) {
  151. if (res.confirm) {
  152. console.log('用户点击确定');
  153. uni.navigateTo({
  154. url: `/pages/main/toviewtherecording/index?jump=`+"jump"
  155. })
  156. } else if (res.cancel) {
  157. console.log('用户点击取消');
  158. }
  159. }
  160. });
  161. });
  162. },
  163. Closewebsocke(){
  164. uni.closeSocket();
  165. uni.onSocketClose(function (res) {
  166. console.log('WebSocket 已关闭!');
  167. });
  168. },
  169. }
  170. };
  171. </script>
  172. <style>
  173. @import "./app.css";
  174. </style>
  175. <style lang="scss">
  176. @import "uview-ui/index.scss";
  177. /*每个页面公共css */
  178. //图表样式等
  179. .single{
  180. width: 100%;
  181. background: #FFFFFF;
  182. .title{
  183. width: 100%;
  184. height: 90rpx;
  185. border-bottom: 1rpx solid #E0E0E0;
  186. display: flex;
  187. .title1{
  188. flex: 2;
  189. font-size: 30rpx;
  190. font-weight: 600;
  191. color: #333333;
  192. line-height: 90rpx;
  193. text-indent: 30rpx;
  194. }
  195. .title3{
  196. flex: 3;
  197. height: 90rpx;
  198. display: flex;
  199. align-items: center;
  200. justify-content: flex-end;
  201. .title3-box{
  202. display: flex;
  203. align-items: center;
  204. width: 25%;
  205. justify-content: center;
  206. .activecltab{
  207. border-bottom: 2px solid #2671E2;
  208. }
  209. }
  210. }
  211. .title2{
  212. flex: 3;
  213. height: 90rpx;
  214. display: flex;
  215. align-items: center;
  216. .title2-che{
  217. width: 178rpx;
  218. height: 48rpx;
  219. background: #FFFFFF;
  220. border-radius: 6rpx;
  221. border: 1px solid #E0E0E0;
  222. line-height: 48rpx;
  223. font-size: 28rpx;
  224. font-weight: 400;
  225. color: #666666;
  226. text-indent: 12rpx;
  227. margin-left: 35rpx;
  228. position: relative;
  229. .righttochoose{
  230. width: 18rpx;
  231. height: 24rpx;
  232. position: absolute;
  233. top: 12rpx;
  234. right: 12rpx;
  235. }
  236. }
  237. }
  238. }
  239. .swiper-box{
  240. width: 97%;
  241. margin: 0 auto;
  242. }
  243. .hejibox{
  244. width: 100%;
  245. height: 80rpx;
  246. display: flex;
  247. .heji{
  248. width: 50%;
  249. height: 100%;
  250. font-size: 28rpx;
  251. font-weight: 400;
  252. color: #666666;
  253. line-height: 80rpx;
  254. text-indent: 30rpx;
  255. }
  256. }
  257. .danwei{
  258. width: 100%;
  259. height: 40rpx;
  260. font-size: 24rpx;
  261. font-weight: 400;
  262. color: #999999;
  263. line-height: 40rpx;
  264. text-indent: 30rpx;
  265. }
  266. .uchaserbox{
  267. width: 95%;
  268. height: 470rpx;
  269. }
  270. .jindu{
  271. width: 100%;
  272. height: 300rpx;
  273. .jindu-box{
  274. width: 100%;
  275. padding-left: 30rpx;
  276. padding-right: 30rpx;
  277. .jindu-boxche{
  278. width: 100%;
  279. height: 46rpx;
  280. display: flex;
  281. align-items: center;
  282. height: 50rpx;
  283. .jindu-name{
  284. width: 120rpx;
  285. font-size: 28rpx;
  286. color: #666666;
  287. }
  288. .jindu-zxl{
  289. width: 120rpx;
  290. font-size: 26rpx;
  291. margin-left: 16rpx;
  292. color: #666666;
  293. text-align: center;
  294. }
  295. }
  296. }
  297. }
  298. }
  299. //时间切换的样式
  300. .boxtittab {
  301. width: 100;
  302. height: 92rpx;
  303. background: #FFFFFF;
  304. border: 1px solid #E0E0E0;
  305. display: flex;
  306. align-items: center;
  307. .tabbox {
  308. flex: 1;
  309. height: 100%;
  310. text-align: center;
  311. line-height: 92rpx;
  312. color: #666666;
  313. font-size: 28rpx;
  314. display: flex;
  315. justify-content: center;
  316. .activecllasscet {
  317. width: 96rpx;
  318. border-bottom: 2px solid #2671E2;
  319. }
  320. }
  321. }
  322. //多个格子的样式
  323. .boxzonglan {
  324. width: 100%;
  325. min-height: 496rpx;
  326. background: #FFFFFF;
  327. padding: 30rpx 30rpx 30rpx 30rpx;
  328. .zonglantit {
  329. font-size: 30rpx;
  330. color: #333333;
  331. font-family: PingFangSC-Semibold, PingFang SC;
  332. font-weight: 600;
  333. }
  334. .zonglanbox {
  335. width: 100%;
  336. display: flex;
  337. flex-wrap: wrap;
  338. margin-top: 24rpx;
  339. .grid {
  340. width: 50%;
  341. height: 128rpx;
  342. border: 1px solid #E0E0E0;
  343. .audonum {
  344. color: #666666;
  345. text-indent: 40rpx;
  346. font-size: 26rpx;
  347. margin-top: 20rpx;
  348. }
  349. .num {
  350. color: #333333;
  351. text-indent: 40rpx;
  352. font-size: 32rpx;
  353. font-weight: 600;
  354. margin-top: 10rpx;
  355. }
  356. }
  357. }
  358. }
  359. </style>