home.vue 4.6 KB

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