home.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <up-swiper height='115' :list="banner" indicator keyName="imageUrl" :autoplay="false" circular radius="0"
  3. @click="onClickSwiper" />
  4. <view class="main">
  5. <view class="serve">
  6. {{ enterprisename }}
  7. </view>
  8. <view class="name">
  9. {{ welcomeText }}
  10. </view>
  11. <view class="list">
  12. <navigator :url="item.path" class="item" v-for="item in itemList" :key="item.label">
  13. <view class="icon">
  14. <image class="image" :src="item.icon" />
  15. </view>
  16. <view class="label">
  17. {{ item.label }}
  18. </view>
  19. <view class="text">
  20. {{ item.text }}
  21. </view>
  22. <view class="badge" v-if="item.badge">
  23. <up-badge type="error" max="999" :value="item.badge"></up-badge>
  24. </view>
  25. </navigator>
  26. </view>
  27. </view>
  28. </template>
  29. <script setup>
  30. import { ref, getCurrentInstance, computed } from 'vue'
  31. import { onLoad } from '@dcloudio/uni-app';
  32. const { $Http } = getCurrentInstance().proxy;
  33. const banner = ref([]);
  34. const enterprisename = ref('');
  35. const welcomeText = computed(() => {
  36. return getTimeGreeting() + ',' + (uni.getStorageSync('userMsg').name);
  37. });
  38. function getTimeGreeting() {
  39. const hour = new Date().getHours();
  40. if (hour >= 5 && hour < 12) {
  41. return '早上好';
  42. } else if (hour >= 12 && hour < 14) {
  43. return '中午好';
  44. } else if (hour >= 14 && hour < 18) {
  45. return '下午好';
  46. } else {
  47. return '晚上好';
  48. }
  49. }
  50. onLoad(() => {
  51. $Http.basic({
  52. "classname": "common.adspace.adspace",
  53. "method": "query_adspacelist", //查询轮播图
  54. content: {
  55. nocache: true
  56. }
  57. }).then(res => {
  58. if (res.code !== 0 && res.data.length) {
  59. uni.removeStorageSync('banner')
  60. uni.setStorageSync('banner', res.data);
  61. banner.value = res.data.find(v => v.location == "index_top").ads.map(v => {
  62. v.imageUrl = v.attinfos[0].url;
  63. return v
  64. }) || [];
  65. } else {
  66. const list = uni.getStorageSync('banner') || [];
  67. if (list.length) banner.value = list.find(v => v.location == "index_top").ads.map(v => {
  68. v.imageUrl = v.attinfos[0].url;
  69. return v
  70. }) || [];
  71. }
  72. })
  73. $Http.basic({
  74. id: "2025073015312903",
  75. content: {}
  76. }).then(res => {
  77. if (res.code == 1) {
  78. enterprisename.value = res.data.enterprisename;
  79. }
  80. })
  81. uploadNumber()
  82. $Http.uploadNumber = uploadNumber;
  83. });
  84. function uploadNumber() {
  85. itemList.value.forEach((item) => {
  86. $Http.basic({ "id": "20230208140203", "content": { "pageNumber": 1, "pageSize": 0, "where": { "status": item.label, "condition": "" } } }).then(res => {
  87. if (res.code !== 0) {
  88. item.badge = res.total;
  89. } else {
  90. item.badge = 0;
  91. }
  92. })
  93. });
  94. welcomeText.getter()
  95. }
  96. function onClickSwiper(e) {
  97. let item = banner.value[e]
  98. if (item.hyperlink) {
  99. uni.navigateTo({
  100. url: item.hyperlink,
  101. success: (result) => { },
  102. fail: () => {
  103. uni.previewImage({
  104. current: e,
  105. urls: banner.value.map(v => v.imageUrl)
  106. })
  107. },
  108. })
  109. } else {
  110. uni.previewImage({
  111. current: e,
  112. urls: banner.value.map(v => v.imageUrl)
  113. })
  114. }
  115. }
  116. const itemList = ref([{
  117. label: '待接单',
  118. icon: '/static/image/djd.png',
  119. text: "故障维修排除",
  120. path: "/pages/workOrder/index?type=待接单",
  121. }, {
  122. label: '进行中',
  123. icon: '/static/image/jxz.png',
  124. text: "专业上门安装",
  125. path: "/pages/workOrder/index?type=进行中",
  126. }, {
  127. label: '已完结',
  128. icon: '/static/image/ywj.png',
  129. text: "精心维护保养",
  130. path: "/pages/workOrder/index?type=已完结",
  131. }]);
  132. </script>
  133. <style lang="scss" scoped>
  134. .main {
  135. padding: 40rpx 30rpx;
  136. box-sizing: border-box;
  137. .serve {
  138. line-height: 32rpx;
  139. font-family: Microsoft YaHei, Microsoft YaHei;
  140. font-size: 24rpx;
  141. color: #999999;
  142. }
  143. .name {
  144. line-height: 48rpx;
  145. font-family: Microsoft YaHei, Microsoft YaHei;
  146. font-weight: bold;
  147. font-size: 36rpx;
  148. color: #333333;
  149. margin-top: 10rpx;
  150. }
  151. .list {
  152. display: flex;
  153. justify-content: space-between;
  154. flex-wrap: wrap;
  155. margin-top: 40rpx;
  156. .item {
  157. position: relative;
  158. width: 334rpx;
  159. height: 260rpx;
  160. background: #FFFFFF;
  161. box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
  162. border-radius: 20rpx;
  163. margin-bottom: 20rpx;
  164. box-sizing: border-box;
  165. padding: 40rpx;
  166. .image {
  167. height: 70rpx;
  168. width: 70rpx;
  169. }
  170. .label {
  171. line-height: 42rpx;
  172. font-family: Microsoft YaHei, Microsoft YaHei;
  173. font-weight: bold;
  174. font-size: 32rpx;
  175. color: #333333;
  176. margin-top: 20rpx;
  177. }
  178. .text {
  179. line-height: 38rpx;
  180. font-family: Microsoft YaHei, Microsoft YaHei;
  181. font-size: 28rpx;
  182. color: #999999;
  183. margin-top: 10rpx;
  184. }
  185. .badge {
  186. position: absolute;
  187. top: 20rpx;
  188. right: 20rpx;
  189. transform: scale(1.3);
  190. }
  191. }
  192. }
  193. }
  194. </style>