index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <!-- 使用 type="home" 属性设置首页,其他页面不需要设置,默认为page;推荐使用json5,更强大,且允许注释 -->
  2. <route lang="json5" type="home">
  3. {
  4. style: {
  5. navigationBarTitleText: '首页',
  6. navigationStyle: 'custom',
  7. },
  8. }
  9. </route>
  10. <template>
  11. <view class="my-page">
  12. <!-- 自定义导航栏 -->
  13. <pyh-nv ref="nvRef" :config="nvConfig">
  14. <wd-img :src="logoSrc" height="30" mode="heightFix"></wd-img>
  15. </pyh-nv>
  16. <view class="px-4">
  17. <!-- 主图轮播 1:1 height="calc(100vw - 60rpx)" -->
  18. <wd-swiper
  19. v-model:current="current"
  20. :list="swiperList"
  21. :indicator="{ type: 'dots-bar' }"
  22. value-key="url"
  23. height="calc(66.6vw - 20rpx)"
  24. imageMode="widthFix"
  25. :duration="500"
  26. custom-class="my-swiper shadow-class"
  27. ></wd-swiper>
  28. <!-- 功能区 -->
  29. <view class="guide-box shadow-class">
  30. <view class="guide-item" @click="toUserHub()">
  31. <wd-img :src="deviceImgSrc" width="100" mode="widthFix"></wd-img>
  32. <view class="item-title">打印助手</view>
  33. <view class="item-desc">我的打印助手</view>
  34. </view>
  35. <view class="guide-item" @click="toPrint()">
  36. <wd-img :src="fileImgSrc" width="100" mode="widthFix"></wd-img>
  37. <view class="item-title">远程打印</view>
  38. <view class="item-desc">无需驱动 隔空打印</view>
  39. </view>
  40. </view>
  41. <!-- 补充入口 -->
  42. <view class="content">
  43. <view class="section">
  44. <view class="item" @click="toConnect()">
  45. <view class="title">
  46. <wd-img :src="connectSrc" width="40" mode="widthFix"></wd-img>
  47. <view class="title-text">设备配网</view>
  48. </view>
  49. </view>
  50. <view class="item" @click="developing()">
  51. <view class="title">
  52. <wd-img :src="pictureSrc" width="40" mode="widthFix"></wd-img>
  53. <view class="title-text">相册图片</view>
  54. </view>
  55. </view>
  56. <view class="item">
  57. <view class="title" @click="developing()">
  58. <wd-img :src="wechatFileSrc" width="40" mode="widthFix"></wd-img>
  59. <view class="title-text">微信图片</view>
  60. </view>
  61. </view>
  62. <view class="item">
  63. <view class="title" @click="developing()">
  64. <wd-img :src="wechatInvoiceSrc" width="40" mode="widthFix"></wd-img>
  65. <view class="title-text">微信发票</view>
  66. </view>
  67. </view>
  68. <!-- <view class="item">
  69. <view class="title">
  70. <image :src="settingSrc"></image>
  71. <view class="title-text">预留入口</view>
  72. </view>
  73. <view class="tips">描述信息</view>
  74. </view> -->
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script lang="ts" setup>
  81. import { useUserStore } from '@/store'
  82. import { useToast } from 'wot-design-uni'
  83. import { toLogin } from '@/utils'
  84. defineOptions({
  85. name: 'Home',
  86. })
  87. const toast = useToast()
  88. const isLogined = computed(() => !!useUserStore().token)
  89. const nvRef: any = ref()
  90. const nvConfig = ref({
  91. title: '首页',
  92. type: 'slot', // default slot logo
  93. back: {
  94. hide: true,
  95. },
  96. bgColor: '#ffffff',
  97. color: '#000000',
  98. transparent: {
  99. type: 'type',
  100. initColor: '#000000',
  101. },
  102. })
  103. const logoSrc = ref('/static/images/logo_temp.png')
  104. const deviceImgSrc = ref('/static/images/device.png')
  105. const fileImgSrc = ref('/static/images/file.png')
  106. const connectSrc = ref('/static/images/connect.png')
  107. const pictureSrc = ref('/static/images/picture.png')
  108. const wechatFileSrc = ref('/static/images/wechat_file.png')
  109. const wechatInvoiceSrc = ref('/static/images/wechat_invoice.png')
  110. const swiperList = ref([])
  111. const current = ref(0)
  112. // 初始化 swiperList 数组
  113. function initSwiperList() {
  114. swiperList.value = [
  115. { id: '3', url: '/static/images/banner3.jpg' },
  116. { id: '2', url: '/static/images/banner2.jpg' },
  117. { id: '1', url: '/static/images/banner1.jpg' },
  118. ]
  119. }
  120. // 跳转
  121. // uni.reLaunch({
  122. // url: `/pages/personal/index`,
  123. // })
  124. // uni.navigateTo({
  125. // url: `/pages/map/index`,
  126. // })
  127. function toUserHub() {
  128. if (isLogined.value) {
  129. uni.navigateTo({
  130. url: `/pages/assistant/index`,
  131. })
  132. } else {
  133. toast.warning('请先前往登录')
  134. toLogin(1500)
  135. }
  136. }
  137. function toPrint() {
  138. if (isLogined.value) {
  139. uni.navigateTo({
  140. url: `/pages/print/index`,
  141. })
  142. } else {
  143. toast.warning('请先前往登录')
  144. toLogin(1500)
  145. }
  146. }
  147. function developing() {
  148. toast.warning('该功能开发中...')
  149. }
  150. function toConnect() {
  151. uni.navigateTo({
  152. url: `/pages/connect/index`,
  153. })
  154. }
  155. onLoad((option: any) => {
  156. initSwiperList()
  157. })
  158. // 监听滚动
  159. onPageScroll((e) => {
  160. nvRef.value.pageScroll(e)
  161. })
  162. </script>
  163. <style lang="scss" scoped>
  164. .my-page {
  165. background-color: #eeeeee;
  166. background-size: 100% auto;
  167. background-position: top;
  168. background-repeat: no-repeat;
  169. width: 100%;
  170. min-height: calc(100vh - 60rpx);
  171. padding: 30rpx 0;
  172. overflow-y: auto;
  173. }
  174. :deep(.my-swiper) {
  175. border-radius: 40rpx !important;
  176. swiper {
  177. border-radius: 40rpx !important;
  178. }
  179. }
  180. .guide-box {
  181. display: flex;
  182. padding: 20rpx 0 20rpx;
  183. margin-top: 30rpx;
  184. border-radius: 40rpx;
  185. background-color: #fff;
  186. .guide-item {
  187. flex: 1;
  188. text-align: center;
  189. .item-title {
  190. font-size: 32rpx;
  191. font-weight: bold;
  192. margin-top: 4rpx;
  193. }
  194. .item-desc {
  195. font-size: 24rpx;
  196. margin-top: 4rpx;
  197. margin-bottom: 20rpx;
  198. }
  199. }
  200. .guide-item + .guide-item {
  201. border-left: 1px solid transparent; /* 设置透明边框以便于渐变可见 */
  202. border-image: linear-gradient(to bottom, white, #b8b8b8, white) 10 10; /* 使用渐变作为边框图片 */
  203. }
  204. }
  205. .content {
  206. width: 100%;
  207. position: relative;
  208. margin-top: 30rpx;
  209. .section {
  210. display: flex;
  211. flex-wrap: wrap;
  212. justify-content: center;
  213. align-items: center;
  214. margin-left: -20rpx;
  215. .item {
  216. flex: 1 1 calc(50% - 20px);
  217. // background-color: #e1e1e1;
  218. background-color: #ffffff;
  219. padding: $uni-spacing-row-lg 0;
  220. margin: 0 0 20rpx 20rpx;
  221. display: flex;
  222. flex-direction: column;
  223. align-items: center;
  224. justify-content: center;
  225. border-radius: 30rpx;
  226. .title {
  227. width: 100%;
  228. display: flex;
  229. align-items: center;
  230. justify-content: center;
  231. font-size: $uni-font-size-lg;
  232. .title-text {
  233. margin-left: 20rpx;
  234. }
  235. }
  236. .tips {
  237. color: $uni-text-color-grey;
  238. font-size: $uni-font-size-base;
  239. }
  240. }
  241. }
  242. }
  243. </style>