home.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view>
  3. <cu-custom ref="Dustom"
  4. bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png">
  5. <view slot="head" class="head" :style="{ height: headHeight }">
  6. <view class="content">
  7. <navigator url="/pages/login/selectSite" class="sitename u-line-1"
  8. :style="{ 'width': usePort == 'wechat' ? '65vw' : '96vw' }">
  9. {{ sitename }}
  10. </navigator>
  11. <view class="location u-line-1" @click.stop="setLocation">
  12. <text class="iconfont icon-didian" />{{ place.address || '重新获取所在位置' }}
  13. </view>
  14. <view class="weather-forecast">
  15. <view class="tag">天气预报</view>
  16. <view class="text">{{ weather }}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </cu-custom>
  21. <!-- 滚动通知 -->
  22. <notice ref="notice" />
  23. <!-- 工作台 -->
  24. <workbench />
  25. <!-- 数据看板 -->
  26. <spectaculars ref="spectaculars" />
  27. <!-- 巡检计划 -->
  28. <patrolScheme ref="patrolScheme" />
  29. <workorder v-if="showWorkrder" :isHome="true" />
  30. <view style="height: calc(16.533vw + env(safe-area-inset-bottom) / 2);" />
  31. </view>
  32. </template>
  33. <script>
  34. import workbench from "./workbench.vue";
  35. import notice from "./notice.vue";
  36. import spectaculars from "./spectaculars.vue";
  37. import patrolScheme from "./patrolScheme.vue";
  38. import { getWeek, getYMD } from "../../../utils/getTime";
  39. import workorder from "./workorderList"
  40. const QQMapWX = require("../../../utils/qqmap-wx-jssdk.min.js");
  41. var qqmapsdk;
  42. export default {
  43. name: 'Home',
  44. components: {
  45. workbench,
  46. notice,
  47. spectaculars,
  48. patrolScheme,
  49. workorder
  50. },
  51. data() {
  52. return {
  53. uninitialized: false,
  54. usePort: this.usePort,
  55. sitename: "",
  56. place: {},
  57. headHeight: 0,
  58. weather: "",
  59. showWorkrder: false
  60. };
  61. },
  62. created() {
  63. this.getPlace();
  64. let userMsg = uni.getStorageSync("userMsg");
  65. this.sitename = `${userMsg.sitename} - ${userMsg.name}`
  66. try {
  67. this.showWorkrder = uni.getStorageSync('authList')['工单']['工单'].name == "workorder"
  68. } catch (error) {
  69. this.showWorkrder = false
  70. }
  71. },
  72. mounted() {
  73. this.getWeather();
  74. },
  75. methods: {
  76. renderData() {
  77. this.$refs.notice.getList();
  78. this.$refs.spectaculars.getDetail();
  79. this.$refs.patrolScheme.getDetail();
  80. },
  81. getWeather() {
  82. this.$Http.basic({
  83. id: "20231012093701",
  84. content: {}
  85. }).then(res => {
  86. console.log("获取天气信息", res)
  87. if (this.cutoff(res.msg)) {
  88. this.setCustomBar(0);
  89. } else {
  90. this.setCustomBar(66);
  91. let detail = res.data.predict.detail[0];
  92. this.weather = `${getWeek()} ${getYMD().split("年")[1]} | ${detail.day.weather.temperature == '9999' ? detail.night.weather.temperature : detail.night.weather.temperature + '~' + detail.day.weather.temperature}℃ ${res.data.real.weather.info}`
  93. }
  94. })
  95. },
  96. setLocation() {
  97. let that = this;
  98. uni.getSetting({
  99. success({ authSetting }) {
  100. if (authSetting['scope.userLocation']) {
  101. that.getLocation().then(s => {
  102. that.__proto__.location = s;
  103. that.getPlace();
  104. })
  105. } else {
  106. uni.showModal({
  107. title: '提示',
  108. content: '您未开启地理位置授权',
  109. cancelText: '下次再说',
  110. confirmText: '前去授权',
  111. success: ({ confirm }) => {
  112. if (confirm) uni.openSetting({
  113. success(res) {
  114. if (res.authSetting['scope.userLocation']) that.setLocation();
  115. }
  116. });
  117. }
  118. })
  119. }
  120. }
  121. })
  122. },
  123. async getPlace() {
  124. let res = this.location || await this.getLocation(),
  125. that = this;
  126. this.__proto__.location = res;
  127. qqmapsdk = new QQMapWX({
  128. key: 'UVVBZ-UOGWZ-ZUWXC-TJQMT-TUWLO-IVFTN'
  129. });
  130. qqmapsdk.reverseGeocoder({
  131. location: {
  132. latitude: res.latitude,
  133. longitude: res.longitude
  134. },
  135. success(res) {
  136. console.log("逆解析结果", res.result)
  137. that.place = res.result;
  138. },
  139. fail: res => console.error(res)
  140. });
  141. },
  142. setCustomBar(num) {
  143. const Dustom = this.$refs.Dustom;
  144. Dustom.CustomBar = Dustom.CustomBar + num;
  145. this.headHeight = Dustom.getHeight()
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .head {
  152. position: fixed;
  153. width: 100vw;
  154. top: 0;
  155. left: 0;
  156. z-index: 10000;
  157. .content {
  158. position: absolute;
  159. width: 100vw;
  160. padding: 0 10px;
  161. box-sizing: border-box;
  162. left: 0;
  163. bottom: 0;
  164. .sitename {
  165. line-height: 22px;
  166. font-size: 16px;
  167. font-family: PingFang SC-Medium, PingFang SC;
  168. font-weight: bold;
  169. color: #FFFFFF;
  170. }
  171. .location {
  172. line-height: 17px;
  173. font-size: 12px;
  174. font-family: PingFang SC-Regular, PingFang SC;
  175. color: rgba(255, 255, 255, 0.8);
  176. margin-top: 10px;
  177. .iconfont {
  178. margin-right: 5px;
  179. font-size: 12px;
  180. }
  181. }
  182. .weather-forecast {
  183. width: 100%;
  184. display: flex;
  185. align-items: center;
  186. height: 18px;
  187. margin-top: 22px;
  188. margin-bottom: 12px;
  189. .tag {
  190. width: 48px;
  191. height: 18px;
  192. line-height: 18px;
  193. text-align: center;
  194. background: #F29C37;
  195. border-radius: 2px;
  196. font-size: 10px;
  197. font-family: PingFang SC-Medium, PingFang SC;
  198. font-weight: bold;
  199. color: #FFFFFF;
  200. margin-right: 6px;
  201. }
  202. .text {
  203. height: 17px;
  204. font-size: 12px;
  205. font-family: PingFang SC-Regular, PingFang SC;
  206. color: rgba(255, 255, 255, 0.8);
  207. }
  208. }
  209. }
  210. }
  211. </style>