home.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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.formatted_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 ref="workroder" 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(true);
  78. this.$refs.spectaculars.getDetail();
  79. this.$refs.patrolScheme.getDetail();
  80. if (this.showWorkrder) this.$refs.workroder.getlist(true);
  81. },
  82. getWeather() {
  83. this.$Http.basic({
  84. id: "20231012093701",
  85. content: {}
  86. }).then(res => {
  87. console.log("获取天气信息", res)
  88. if (this.cutoff(res.msg)) {
  89. this.setCustomBar(0);
  90. } else {
  91. this.setCustomBar(66);
  92. let detail = res.data.predict.detail[0];
  93. 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}`
  94. }
  95. })
  96. },
  97. setLocation() {
  98. let that = this;
  99. uni.getSetting({
  100. success({ authSetting }) {
  101. if (authSetting['scope.userLocation']) {
  102. that.getLocation().then(s => {
  103. that.__proto__.location = s;
  104. that.getPlace();
  105. })
  106. } else {
  107. uni.showModal({
  108. title: '提示',
  109. content: '您未开启地理位置授权',
  110. cancelText: '下次再说',
  111. confirmText: '前去授权',
  112. success: ({ confirm }) => {
  113. if (confirm) uni.openSetting({
  114. success(res) {
  115. if (res.authSetting['scope.userLocation']) that.setLocation();
  116. }
  117. });
  118. }
  119. })
  120. }
  121. }
  122. })
  123. },
  124. async getPlace() {
  125. let res = this.location || await this.getLocation();
  126. this.__proto__.location = res;
  127. this.$Http.basic({
  128. "id": "10027201",
  129. "content": {
  130. "lon": res.longitude,
  131. "lat": res.latitude
  132. }
  133. }).then(s => {
  134. console.log("定位", s)
  135. this.place = s.data.result;
  136. })
  137. /* qqmapsdk = new QQMapWX({
  138. key: 'UVVBZ-UOGWZ-ZUWXC-TJQMT-TUWLO-IVFTN'
  139. });
  140. qqmapsdk.reverseGeocoder({
  141. location: {
  142. latitude: res.latitude,
  143. longitude: res.longitude
  144. },
  145. success(res) {
  146. console.log("逆解析结果", res.result)
  147. that.place = res.result;
  148. },
  149. fail: res => console.error(res)
  150. }); */
  151. },
  152. setCustomBar(num) {
  153. const Dustom = this.$refs.Dustom;
  154. Dustom.CustomBar = Dustom.CustomBar + num;
  155. this.headHeight = Dustom.getHeight()
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .head {
  162. position: fixed;
  163. width: 100vw;
  164. top: 0;
  165. left: 0;
  166. z-index: 10000;
  167. .content {
  168. position: absolute;
  169. width: 100vw;
  170. padding: 0 10px;
  171. box-sizing: border-box;
  172. left: 0;
  173. bottom: 0;
  174. .sitename {
  175. line-height: 22px;
  176. font-size: 16px;
  177. font-family: PingFang SC-Medium, PingFang SC;
  178. font-weight: bold;
  179. color: #FFFFFF;
  180. }
  181. .location {
  182. line-height: 17px;
  183. font-size: 12px;
  184. font-family: PingFang SC-Regular, PingFang SC;
  185. color: rgba(255, 255, 255, 0.8);
  186. margin-top: 10px;
  187. .iconfont {
  188. margin-right: 5px;
  189. font-size: 12px;
  190. }
  191. }
  192. .weather-forecast {
  193. width: 100%;
  194. display: flex;
  195. align-items: center;
  196. height: 18px;
  197. margin-top: 22px;
  198. margin-bottom: 12px;
  199. .tag {
  200. width: 48px;
  201. height: 18px;
  202. line-height: 18px;
  203. text-align: center;
  204. background: #F29C37;
  205. border-radius: 2px;
  206. font-size: 10px;
  207. font-family: PingFang SC-Medium, PingFang SC;
  208. font-weight: bold;
  209. color: #FFFFFF;
  210. margin-right: 6px;
  211. }
  212. .text {
  213. height: 17px;
  214. font-size: 12px;
  215. font-family: PingFang SC-Regular, PingFang SC;
  216. color: rgba(255, 255, 255, 0.8);
  217. }
  218. }
  219. }
  220. }
  221. </style>