serviceProject.uvue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <view class="page-container">
  3. <scroll-view style="flex:1">
  4. <!-- 服务列表容器 -->
  5. <view class="service-list" v-for="service in servicesList" :key="service.id">
  6. <!-- 中式推拿项(带路费设置) -->
  7. <view class="service-item">
  8. <!-- 左侧图片+信息区(核心:显式设置flex-direction: row) -->
  9. <view class="item-left" style="flex-direction: row;">
  10. <image class="service-img" :src="service.img" mode="aspectFill">
  11. </image>
  12. <view class="service-info">
  13. <text class="service-title">
  14. {{ service.title }}
  15. </text>
  16. <text class="service-desc">
  17. {{ service.desc }}
  18. </text>
  19. <text class="service-price">
  20. ¥{{ service.price }}
  21. </text>
  22. </view>
  23. </view>
  24. <!-- 右侧开关 -->
  25. <switch class="service-switch" :checked="service.hasFare" color="#FFCC00">
  26. </switch>
  27. <!-- 路费设置(仅中式推拿展示) -->
  28. <view class="fare-setting" style="flex-direction: row;">
  29. <text class="fare-label">
  30. 路费设置
  31. </text>
  32. <view class="fare-options" style="flex-direction: row;">
  33. <button class="fare-btn">
  34. 免路费
  35. </button>
  36. <button class="fare-btn">
  37. 单程
  38. </button>
  39. <button class="fare-btn active">
  40. 双程
  41. </button>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </scroll-view>
  47. <!-- 底部保存按钮 -->
  48. <view class="footer-box" @click="handleSave">
  49. <text class="footer-text">
  50. 保存设置
  51. </text>
  52. </view>
  53. </view>
  54. </template>
  55. <script setup lang="uts">
  56. import { ref } from 'vue';
  57. import { editWorkTimeSetting } from '@/utils/api/workbenches.uts'
  58. type ServiceItem = {
  59. id : number
  60. title : string
  61. desc : string
  62. price : number
  63. img : string
  64. hasFare : boolean
  65. }
  66. const fareType = ref<string>('roundtrip');
  67. const servicesList = ref<ServiceItem[]>([
  68. {
  69. id: 1,
  70. title: '中式推拿',
  71. desc: '服务时长:60分钟',
  72. price: 199,
  73. img: '/static/imagesInfo/anmo.png',
  74. hasFare: true
  75. },
  76. {
  77. id: 2,
  78. title: '足疗按摩',
  79. desc: '服务时长:45分钟',
  80. price: 149,
  81. img: '/static/imagesInfo/anmo.png',
  82. hasFare: false
  83. },
  84. {
  85. id: 3,
  86. title: '肩颈按摩',
  87. desc: '服务时长:30分钟',
  88. price: 99,
  89. img: '/static/imagesInfo/anmo.png',
  90. hasFare: false
  91. }
  92. ])
  93. const handleSave = async () => {
  94. // console.log(timeArr.value, 'timeArr')
  95. // // 1. 声明选中时间数组(类型固定)
  96. // const kjTime : TimeItem[] = []
  97. // // 2. 遍历获取选中的时间段
  98. // for (let i = 0; i < timeArr.value.length; i++) {
  99. // const item : TimeItem = timeArr.value[i]
  100. // if (item.isSelect) {
  101. // kjTime.push(item)
  102. // }
  103. // }
  104. // // 3. 校验:未选择时间段
  105. // if (kjTime.length === 0) {
  106. // uni.showToast({
  107. // title: '请至少选择一个可接单时间段',
  108. // icon: 'none',
  109. // duration: 2000
  110. // })
  111. // return
  112. // }
  113. try {
  114. // const scheduleData = {
  115. // time_ranges: kjTime.filter((range : TimeItem) => range.isSelect).map((range : TimeItem) => ({
  116. // start_time: range.start_time,
  117. // end_time: range.end_time
  118. // }))
  119. // }
  120. // 调用接口保存
  121. const res = await editWorkTimeSetting({})
  122. console.log(res);
  123. // if ((res.code as number) === 200) {
  124. // uni.showToast({
  125. // title: '保存成功',
  126. // icon: 'success',
  127. // duration: 2000
  128. // })
  129. // uni.reLaunch({
  130. // url: '/pages/index/console'
  131. // })
  132. // }
  133. } catch (error) {
  134. uni.showToast({
  135. title: '保存失败,请重试',
  136. icon: 'none'
  137. })
  138. console.error('保存报错:', error)
  139. }
  140. }
  141. </script>
  142. <style>
  143. /* 页面根容器:利用默认flex + column,全屏适配 + 基础背景 */
  144. .page-container {
  145. min-height: 100%;
  146. height: 100%;
  147. background-color: #f5f5f5;
  148. padding-bottom: 40rpx;
  149. /* 给保存按钮留间距 */
  150. }
  151. /* 顶部导航栏:显式设置flex-direction: row,保证横向排版 */
  152. .nav-bar {
  153. display: flex;
  154. flex-direction: row;
  155. align-items: center;
  156. justify-content: space-between;
  157. padding: 20rpx 20rpx;
  158. background-color: #fff;
  159. border-bottom: 1px solid #eee;
  160. }
  161. /* 关闭图标 */
  162. .close-icon {
  163. width: 40rpx;
  164. height: 40rpx;
  165. }
  166. /* 导航标题 */
  167. .nav-title {
  168. font-size: 36rpx;
  169. font-weight: 700;
  170. /* 替换600,兼容uni app x */
  171. color: #333;
  172. }
  173. /* 占位空盒 */
  174. .empty-box {
  175. width: 40rpx;
  176. height: 40rpx;
  177. }
  178. /* 服务列表容器:纵向排列,替代gap用margin */
  179. .service-list {
  180. display: flex;
  181. flex-direction: column;
  182. padding: 20rpx;
  183. }
  184. /* 服务项间距:替代gap:15rpx */
  185. .service-item {
  186. margin-bottom: 15rpx;
  187. background-color: #fff;
  188. border-radius: 12rpx;
  189. padding: 20rpx;
  190. display: flex;
  191. flex-direction: row;
  192. /* 核心:显式设置横向排版 */
  193. align-items: center;
  194. justify-content: space-between;
  195. flex-wrap: wrap;
  196. /* 小屏幕路费设置换行 */
  197. }
  198. /* 最后一个服务项去掉底部间距 */
  199. .service-list .service-item:last-child {
  200. margin-bottom: 0;
  201. }
  202. /* 左侧图片+信息区:横向排版 */
  203. .item-left {
  204. display: flex;
  205. align-items: center;
  206. flex: 1;
  207. }
  208. /* 服务图片 */
  209. .service-img {
  210. width: 120rpx;
  211. height: 120rpx;
  212. border-radius: 8rpx;
  213. margin-right: 20rpx;
  214. /* 替代gap:20rpx */
  215. }
  216. /* 服务信息区:纵向排列 */
  217. .service-info {
  218. display: flex;
  219. flex-direction: column;
  220. }
  221. /* 服务描述/价格:顶部间距,替代gap:8rpx */
  222. .service-desc {
  223. margin-top: 8rpx;
  224. }
  225. .service-price {
  226. margin-top: 8rpx;
  227. }
  228. /* 服务标题:替换font-weight:600为700 */
  229. .service-title {
  230. font-size: 32rpx;
  231. font-weight: 700;
  232. color: #333;
  233. }
  234. /* 服务描述:替换font-weight:500为400 */
  235. .service-desc {
  236. font-size: 24rpx;
  237. color: #666;
  238. font-weight: 400;
  239. }
  240. /* 服务价格:替换font-weight:500为400 */
  241. .service-price {
  242. font-size: 28rpx;
  243. color: #ff6700;
  244. font-weight: 400;
  245. }
  246. /* 开关样式 */
  247. .service-switch {
  248. transform: scale(0.9);
  249. }
  250. /* 路费设置区域:横向排版 */
  251. .fare-setting {
  252. display: flex;
  253. align-items: center;
  254. width: 100%;
  255. margin-top: 15rpx;
  256. padding-top: 15rpx;
  257. border-top: 1px solid #eee;
  258. }
  259. /* 路费标签 */
  260. .fare-label {
  261. font-size: 26rpx;
  262. color: #666;
  263. white-space: nowrap;
  264. margin-right: 20rpx;
  265. /* 替代gap:20rpx */
  266. }
  267. /* 路费选项容器:横向排版 */
  268. .fare-options {
  269. display: flex;
  270. flex: 1;
  271. }
  272. /* 路费按钮:替代gap:10rpx用margin-left */
  273. .fare-btn {
  274. flex: 1;
  275. height: 60rpx;
  276. line-height: 60rpx;
  277. text-align: center;
  278. font-size: 24rpx;
  279. border-radius: 8rpx;
  280. border: 1px solid #ddd;
  281. background-color: #fff;
  282. }
  283. /* 路费按钮:非首个按钮左侧间距 */
  284. .fare-btn:not(:first-child) {
  285. margin-left: 10rpx;
  286. }
  287. /* 选中状态样式 */
  288. .fare-btn.active {
  289. background-color: #FFCC00;
  290. color: #fff;
  291. border-color: #FFCC00;
  292. }
  293. /* 底部保存按钮 */
  294. .footer-box {
  295. /* bottom: 40rpx; */
  296. /* 距离底部距离 */
  297. transform: translateX(-50%);
  298. left: 50%;
  299. width: 78%;
  300. height: 100rpx;
  301. background-color: #FFDA59;
  302. border-radius: 24rpx;
  303. display: flex;
  304. align-items: center;
  305. justify-content: center;
  306. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  307. .footer-text {
  308. color: #3A3330;
  309. font-size: 34rpx;
  310. font-weight: 700;
  311. letter-spacing: 3rpx;
  312. }
  313. }
  314. </style>