index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="">
  3. <!-- header -->
  4. <view class="headers">
  5. <view class="body" v-for="(item, index) in headerList" :key="index" @tap="routerTo(item)">
  6. <image :src="item.url" style="width:103 rpx;height:105rpx">
  7. <view class="title">
  8. {{item.name}}
  9. </view>
  10. </view>
  11. </view>
  12. <!-- 预约服务 -->
  13. <view class="serve">
  14. <view class="headers">
  15. <image :src="require('../../static/left.png')">
  16. 预约服务
  17. <image :src="require('../../static/right.png')">
  18. </view>
  19. <view class="body">
  20. <view class="card" v-for="(item, index) in serveList" :key="index" @click="toServe(item)">
  21. <image :src="baseImagePath + item.imgUrl">
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 推荐套餐 -->
  26. <view class="setMeal">
  27. <view class="headers">
  28. <image :src="require('../../static/left.png')">
  29. 推荐套餐
  30. <image :src="require('../../static/right.png')">
  31. </view>
  32. <SetMeal :set-meal-list="setMealList"></SetMeal>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import SetMeal from '@/components/SetMeal';
  38. import {
  39. getRepairServiceOne,
  40. packageList
  41. } from "@/api/maintain.js"
  42. const app = getApp();
  43. export default {
  44. components: {
  45. SetMeal
  46. },
  47. data() {
  48. return {
  49. requestData: {},
  50. headerLists: "",
  51. baseImagePath: this.baseImagePath,
  52. // 这里url使用的本地图片,使用require后会造成路由跳转传参失败,所以暂时不使用require
  53. setMealList: [],
  54. serveList: [],
  55. headerList: [{
  56. name: "在线预约",
  57. url: require("../../static/kefu.png"),
  58. path: "/pages/maintenance/onlineReservation/index?page=index"
  59. },
  60. {
  61. name: "附近门店",
  62. url: require("../../static/mendian.png"),
  63. path: "/pages/preCarWash/chooseShop/index?page=index"
  64. },
  65. {
  66. name: "维修估价",
  67. url: require("../../static/gujia.png"),
  68. path: "/pages/maintenance/evaluate/index"
  69. },
  70. {
  71. name: "套餐服务",
  72. url: require("../../static/taocan.png"),
  73. path: "/pages/maintenance/setMeal/index"
  74. },
  75. ],
  76. pageNo: 1,
  77. pageSize: 10,
  78. loadmore: true,
  79. };
  80. },
  81. onBackPress(options) {
  82. // 这里可以自定义返回逻辑,比如下面跳转其他页面
  83. // #ifdef APP-PLUS
  84. if (plus.os.name.toLowerCase() === 'android') {
  85. plus.runtime.quit();
  86. } else {
  87. plus.runtime.quit();
  88. }
  89. // #endif
  90. // return true 表示禁止默认返回
  91. return true;
  92. },
  93. onReachBottom() {
  94. if (this.loadmore) {
  95. this.packageList();
  96. }
  97. },
  98. onLoad(e) {
  99. app.globalData.requestToken = e.token;
  100. uni.setStorageSync('token', e.token)
  101. let _this = this;
  102. this.packageList();
  103. getRepairServiceOne().then((res) => {
  104. _this.serveList = res.data
  105. })
  106. },
  107. methods: {
  108. packageList() {
  109. packageList({
  110. pageNo: this.pageNo,
  111. pageSize: this.pageSize,
  112. recommend: 1,
  113. }).then((res) => {
  114. this.setMealList = res.data.rows;
  115. if (this.setMealList.length < this.pageSize) {
  116. this.loadmore = false
  117. }
  118. this.pageNo++
  119. })
  120. },
  121. // 路由跳转
  122. routerTo(item) {
  123. uni.removeStorageSync('chooseCar')
  124. uni.removeStorageSync('chooseShop')
  125. if (item.path) {
  126. this.$yrouter.push({
  127. path: item.path
  128. });
  129. }
  130. },
  131. toServe(item) {
  132. this.$yrouter.push({
  133. path: "/pages/maintenance/servicesAvailable/index?item=" + encodeURIComponent(JSON.stringify(
  134. item))
  135. });
  136. }
  137. },
  138. }
  139. </script>
  140. <style lang="less">
  141. .headers {
  142. width: 750rpx;
  143. height: 208rpx;
  144. display: flex;
  145. justify-content: space-around;
  146. align-items: center;
  147. .body {
  148. width: 110rpx;
  149. display: flex;
  150. flex-direction: column;
  151. align-items: center;
  152. image {
  153. width: 103rpx;
  154. height: 104rpx;
  155. }
  156. .title {
  157. height: 23rpx;
  158. font-size: 24rpx;
  159. font-weight: 500;
  160. color: #333333;
  161. }
  162. }
  163. }
  164. .serve {
  165. width: 100%;
  166. height: 354rpx;
  167. background-image: url(../../static/yuyue-bg.png);
  168. background-size: 100% 100%;
  169. padding-top: 36rpx;
  170. .headers {
  171. width: 227rpx;
  172. height: 31rpx;
  173. font-size: 32rpx;
  174. font-family: PingFang SC;
  175. font-weight: bold;
  176. color: #333333;
  177. line-height: 36rpx;
  178. margin: auto;
  179. image {
  180. width: 31rpx;
  181. height: 31rpx;
  182. }
  183. }
  184. .body {
  185. display: flex;
  186. flex-wrap: wrap;
  187. justify-content: space-around;
  188. margin-top: 30rpx;
  189. .card {
  190. width: 220rpx;
  191. height: 107rpx;
  192. margin-top: 16rpx;
  193. image {
  194. width: 100%;
  195. height: 100%;
  196. }
  197. }
  198. }
  199. }
  200. .setMeal {
  201. padding-top: 36rpx;
  202. .headers {
  203. width: 227rpx;
  204. height: 31rpx;
  205. font-size: 32rpx;
  206. font-family: PingFang SC;
  207. font-weight: bold;
  208. color: #333333;
  209. line-height: 36rpx;
  210. margin: auto;
  211. image {
  212. width: 31rpx;
  213. height: 31rpx;
  214. }
  215. }
  216. }
  217. </style>