猫妈狗爸伴宠师小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

370 lines
13 KiB

  1. <template>
  2. <view class="box box-size">
  3. <view style="margin: 32rpx 0;">
  4. <up-steps :current="currentStep" activeColor="#FFA042" inactiveColor="#999999" class="up-steps-custom">
  5. <up-steps-item title="喂养要求" :titleStyle="{fontSize: '32rpx', fontWeight: 'bold', color: currentStep === 0 ? '#FFA042' : '#999999'}"></up-steps-item>
  6. <up-steps-item title="清洁要求" :titleStyle="{fontSize: '32rpx', fontWeight: 'bold', color: currentStep === 1 ? '#FFA042' : '#999999'}"></up-steps-item>
  7. <up-steps-item title="附加服务" :titleStyle="{fontSize: '32rpx', fontWeight: 'bold', color: currentStep === 2 ? '#FFA042' : '#999999'}"></up-steps-item>
  8. </up-steps>
  9. </view>
  10. <view class="top box-size" :style="{borderRadius:'16rpx'}">
  11. <view class="form-title">
  12. 您需要的附加服务
  13. </view>
  14. <!-- 陪玩服务 -->
  15. <view class="mt32 ml10" v-if="form.playtimeService">
  16. <view class="color-A55 size-30 fw400">
  17. 陪玩
  18. </view>
  19. <view class="size-30 mt32 fw400">
  20. 陪玩用具摆放位置
  21. </view>
  22. <view class="img mt20">
  23. <u-image class="img" :src="item" mode="aspectFill" width="173rpx" height="230rpx" @click="previewImage(item)" v-for="(item, index) in handleImageUrl(form.playtimeToolsLocation)" :key="index"></u-image>
  24. <view class="upload-btn" @click="uploadImage('playtimeToolsLocation')">
  25. <up-icon name="camera-fill" size="40rpx" color="#FFBF60"></up-icon>
  26. </view>
  27. </view>
  28. <view class="size-30 mt24" :style="{color:'#999999'}">
  29. 您希望的互动方式和要求
  30. </view>
  31. <view class="notes mt16 box-size ml--15" :style="{borderRadius:'16rpx'}">
  32. <input type="text" v-model="form.playtimeRequirements" :style="{height:'50rpx',fontSize:'30rpx'}">
  33. </view>
  34. </view>
  35. <view class="line" :style="{borderRadius:'1rpx'}" v-if="form.playtimeService"></view>
  36. <!-- 活动区吸毛 -->
  37. <view class="mt32 ml10" v-if="form.furCleaningService">
  38. <view class="color-A55 size-30 fw400">
  39. 活动区吸毛
  40. </view>
  41. <view class="size-30 mt32 fw400">
  42. 吸毛用品摆放位置
  43. </view>
  44. <view class="img mt20">
  45. <u-image class="img" :src="item" mode="aspectFill" width="173rpx" height="230rpx" @click="previewImage(item)" v-for="(item, index) in handleImageUrl(form.furCleaningToolsLocation)" :key="index"></u-image>
  46. <view class="upload-btn" @click="uploadImage('furCleaningToolsLocation')">
  47. <up-icon name="camera-fill" size="40rpx" color="#FFBF60"></up-icon>
  48. </view>
  49. </view>
  50. <view class="size-30 mt24" :style="{color:'#999999'}">
  51. 请说明吸毛区域及要求
  52. </view>
  53. <view class="notes mt16 box-size ml--15" :style="{borderRadius:'16rpx'}">
  54. <input type="text" v-model="form.furCleaningRequirements" :style="{height:'50rpx',fontSize:'30rpx'}">
  55. </view>
  56. </view>
  57. <view class="line" :style="{borderRadius:'1rpx'}" v-if="form.furCleaningService"></view>
  58. <!-- 毛发梳理 -->
  59. <view class="mt32 ml10" v-if="form.groomingService">
  60. <view class="color-A55 size-30 fw400">
  61. 毛发梳理
  62. </view>
  63. <view class="size-30 mt32 fw400">
  64. 毛发梳理用品摆放位置
  65. </view>
  66. <view class="img mt20">
  67. <u-image class="img" :src="item" mode="aspectFill" width="173rpx" height="230rpx" @click="previewImage(item)" v-for="(item, index) in handleImageUrl(form.groomingToolsLocation)" :key="index"></u-image>
  68. <view class="upload-btn" @click="uploadImage('groomingToolsLocation')">
  69. <up-icon name="camera-fill" size="40rpx" color="#FFBF60"></up-icon>
  70. </view>
  71. </view>
  72. <view class="size-30 mt24" :style="{color:'#999999'}">
  73. 请说明毛发梳理要求(: 天数,次数等)
  74. </view>
  75. <view class="notes mt16 box-size ml--15" :style="{borderRadius:'16rpx'}">
  76. <input type="text" v-model="form.groomingRequirements" :style="{height:'50rpx',fontSize:'30rpx'}">
  77. </view>
  78. </view>
  79. <view class="line" :style="{borderRadius:'1rpx'}" v-if="form.groomingService"></view>
  80. <!-- 食具深度清洁 -->
  81. <view class="mt32 ml10" v-if="form.deepCleaningService">
  82. <view class="color-A55 size-30 fw400">
  83. 食具深度清洁
  84. </view>
  85. <view class="size-30 mt32 fw400">
  86. 需深度清洁的用具及消毒剂摆放位置
  87. </view>
  88. <view class="img mt20">
  89. <u-image class="img" :src="item" mode="aspectFill" width="173rpx" height="230rpx" @click="previewImage(item)" v-for="(item, index) in handleImageUrl(form.deepCleaningToolsLocation)" :key="index"></u-image>
  90. <view class="upload-btn" @click="uploadImage('deepCleaningToolsLocation')">
  91. <up-icon name="camera-fill" size="40rpx" color="#FFBF60"></up-icon>
  92. </view>
  93. </view>
  94. <view class="size-30 mt24" :style="{color:'#999999'}">
  95. 请说明食具/饮水机深度清洁要求(如清洁方式消毒剂使用方式频率等)
  96. </view>
  97. <view class="notes mt16 box-size ml--15" :style="{borderRadius:'16rpx'}">
  98. <input type="text" v-model="form.deepCleaningRemarks" :style="{height:'50rpx',fontSize:'30rpx'}">
  99. </view>
  100. </view>
  101. <view class="line" :style="{borderRadius:'1rpx'}" v-if="form.deepCleaningService"></view>
  102. <!-- 喂药上药 -->
  103. <view class="mt32 ml10" v-if="form.administerMedication">
  104. <view class="color-A55 size-30 fw400">
  105. 喂药上药
  106. </view>
  107. <view class="size-30 mt32 fw400">
  108. 药品摆放位置
  109. </view>
  110. <view class="img mt20">
  111. <u-image class="img" :src="item" mode="aspectFill" width="173rpx" height="230rpx" @click="previewImage(item)" v-for="(item, index) in handleImageUrl(form.administerMedicationLocation)" :key="index"></u-image>
  112. <view class="upload-btn" @click="uploadImage('administerMedicationLocation')">
  113. <up-icon name="camera-fill" size="40rpx" color="#FFBF60"></up-icon>
  114. </view>
  115. </view>
  116. <view class="size-30 mt24" :style="{color:'#999999'}">
  117. 请说明药品使用方式
  118. </view>
  119. <view class="notes mt16 box-size ml--15" :style="{borderRadius:'16rpx'}">
  120. <input type="text" v-model="form.administerMedicationRemarks" :style="{height:'50rpx',fontSize:'30rpx'}">
  121. </view>
  122. </view>
  123. <!-- 遛狗服务 -->
  124. <view class="mt32 ml10" v-if="form.walkDog">
  125. <view class="color-A55 size-30 fw400">
  126. 遛狗服务
  127. </view>
  128. <view class="size-30 mt32 fw400">
  129. 遛狗用品摆放位置
  130. </view>
  131. <view class="img mt20">
  132. <u-image class="img" :src="item" mode="aspectFill" width="173rpx" height="230rpx" @click="previewImage(item)" v-for="(item, index) in handleImageUrl(form.walkDogToolsLocation)" :key="index"></u-image>
  133. <view class="upload-btn" @click="uploadImage('walkDogToolsLocation')">
  134. <up-icon name="camera-fill" size="40rpx" color="#FFBF60"></up-icon>
  135. </view>
  136. </view>
  137. <!-- 雨天遛狗 -->
  138. <view v-if="form.walkDogRainyDay">
  139. <view class="size-30 mt32 fw400">
  140. 狗狗雨具位置
  141. </view>
  142. <view class="img mt20">
  143. <u-image class="img" :src="item" mode="aspectFill" width="173rpx" height="230rpx" @click="previewImage(item)" v-for="(item, index) in handleImageUrl(form.dogRainGearLocation)" :key="index"></u-image>
  144. <view class="upload-btn" @click="uploadImage('dogRainGearLocation')">
  145. <up-icon name="camera-fill" size="40rpx" color="#FFBF60"></up-icon>
  146. </view>
  147. </view>
  148. <view class="size-30 mt24" :style="{color:'#999999'}">
  149. 下雨天遛狗要求
  150. </view>
  151. <view class="notes mt16 box-size ml--15" :style="{borderRadius:'16rpx'}">
  152. <input type="text" v-model="form.walkDogRainRemark" :style="{height:'50rpx',fontSize:'30rpx'}">
  153. </view>
  154. </view>
  155. <!-- 遛狗时长 -->
  156. <view v-if="form.isWalkDogDuration">
  157. <view class="size-30 mt24" :style="{color:'#999999'}">
  158. 遛狗时长
  159. </view>
  160. <view class="notes mt16 box-size ml--15" :style="{borderRadius:'16rpx'}">
  161. <input type="text" v-model="form.walkDogDuration" :style="{height:'50rpx',fontSize:'30rpx'}">
  162. </view>
  163. </view>
  164. <!-- 狗狗行为 -->
  165. <view v-if="form.isDogBehavior">
  166. <view class="size-30 mt24" :style="{color:'#999999'}">
  167. 狗狗行为
  168. </view>
  169. <view class="notes mt16 box-size ml--15" :style="{borderRadius:'16rpx'}">
  170. <input type="text" v-model="form.dogBehavior" :style="{height:'50rpx',fontSize:'30rpx'}">
  171. </view>
  172. </view>
  173. <!-- 偏好区域 -->
  174. <view v-if="form.isFavoriteRegion">
  175. <view class="size-30 mt24" :style="{color:'#999999'}">
  176. 偏好区域
  177. </view>
  178. <view class="notes mt16 box-size ml--15" :style="{borderRadius:'16rpx'}">
  179. <input type="text" v-model="form.favoriteRegion" :style="{height:'50rpx',fontSize:'30rpx'}">
  180. </view>
  181. </view>
  182. <!-- 偏好路线 -->
  183. <view v-if="form.isFavoriteRoute">
  184. <view class="size-30 mt24" :style="{color:'#999999'}">
  185. 偏好路线
  186. </view>
  187. <view class="notes mt16 box-size ml--15" :style="{borderRadius:'16rpx'}">
  188. <input type="text" v-model="form.favoriteRoute" :style="{height:'50rpx',fontSize:'30rpx'}">
  189. </view>
  190. </view>
  191. </view>
  192. <!-- 附加服务备注 -->
  193. <view class="mt32 ml10" v-if="form.additionalService">
  194. <view class="size-30 mt24" :style="{color:'#999999'}">
  195. 附加服务备注
  196. </view>
  197. <view class="notes mt16 box-size ml--15" :style="{borderRadius:'16rpx'}">
  198. <input type="text" v-model="form.additionalServicesRemarks" :style="{height:'50rpx',fontSize:'30rpx'}">
  199. </view>
  200. </view>
  201. </view>
  202. <view class="buttom_ mt60 box-size level">
  203. <view class="buttom_item level size-30" :style="{borderRadius:'41rpx',color:'#fff'}" @click="prevStep">
  204. 上一页
  205. </view>
  206. <view class="buttom_item level size-30" :style="{borderRadius:'41rpx',color:'#fff'}" @click="nextStep">
  207. 完成
  208. </view>
  209. </view>
  210. </view>
  211. </template>
  212. <script>
  213. import { getPetCareByPetId, savePetCare } from "@/api/order/order.js";
  214. export default {
  215. data() {
  216. return {
  217. form: {
  218. // 附加服务相关字段
  219. additionalService: false,
  220. playtimeService: false,
  221. playtimeToolsLocation: '',
  222. playtimeRequirements: '',
  223. furCleaningService: false,
  224. furCleaningToolsLocation: '',
  225. furCleaningRequirements: '',
  226. groomingService: false,
  227. groomingToolsLocation: '',
  228. groomingRequirements: '',
  229. deepCleaningService: false,
  230. deepCleaningToolsLocation: '',
  231. deepCleaningRemarks: '',
  232. administerMedication: false,
  233. administerMedicationLocation: '',
  234. administerMedicationRemarks: '',
  235. additionalServicesPlacement: '',
  236. additionalServicesPlacementRemark: '',
  237. additionalServicesRemarks: '',
  238. // 遛狗相关字段
  239. walkDog: false,
  240. walkDogToolsLocation: '',
  241. walkDogRainyDay: false,
  242. dogRainGearLocation: '',
  243. walkDogRainRemark: '',
  244. isWalkDogDuration: false,
  245. walkDogDuration: '',
  246. isDogBehavior: false,
  247. dogBehavior: '',
  248. isFavoriteRegion: false,
  249. favoriteRegion: '',
  250. isFavoriteRoute: false,
  251. favoriteRoute: ''
  252. },
  253. currentStep: 2, // 当前步骤,固定为附加服务页面
  254. petId: 0,
  255. imageField: '' // 当前操作的图片字段
  256. }
  257. },
  258. onLoad(options) {
  259. this.petId = options.petId;
  260. if (this.petId) {
  261. this.getPetCareData();
  262. }
  263. },
  264. methods: {
  265. // 获取宠物服务档案数据
  266. getPetCareData() {
  267. getPetCareByPetId(this.petId).then(res => {
  268. if (res.data) {
  269. this.form = { ...this.form, ...res.data };
  270. }
  271. }).catch(err => {
  272. console.error('获取宠物服务档案失败', err);
  273. });
  274. },
  275. // 处理图片URL
  276. handleImageUrl(url) {
  277. if (!url) return [];
  278. return url.split(',');
  279. },
  280. // 预览图片
  281. previewImage(url) {
  282. uni.previewImage({
  283. urls: [url]
  284. });
  285. },
  286. // 上传图片
  287. uploadImage(field) {
  288. this.imageField = field;
  289. uni.chooseImage({
  290. count: 1,
  291. sizeType: ['original', 'compressed'],
  292. sourceType: ['album', 'camera'],
  293. success: (res) => {
  294. const tempFilePaths = res.tempFilePaths;
  295. // 这里应该有上传图片到服务器的逻辑
  296. // 模拟上传成功后设置图片URL
  297. this.form[this.imageField] = tempFilePaths[0];
  298. }
  299. });
  300. },
  301. // 上一步
  302. prevStep() {
  303. uni.navigateBack();
  304. },
  305. // 下一步/完成
  306. nextStep() {
  307. // 保存数据
  308. this.saveData();
  309. },
  310. // 保存数据
  311. saveData() {
  312. // 这里应该有保存数据到服务器的逻辑
  313. // 模拟保存成功后返回上一页
  314. uni.showToast({
  315. title: '保存成功',
  316. icon: 'success',
  317. duration: 2000,
  318. success: () => {
  319. setTimeout(() => {
  320. uni.navigateBack({
  321. delta: 2 // 返回上两级页面
  322. });
  323. }, 2000);
  324. }
  325. });
  326. }
  327. }
  328. }
  329. </script>
  330. <style scoped lang="scss">
  331. @import "detail.scss";
  332. @import "steps-custom.scss";
  333. .upload-btn {
  334. width: 173rpx;
  335. height: 230rpx;
  336. background-color: #f5f5f5;
  337. display: flex;
  338. align-items: center;
  339. justify-content: center;
  340. margin-right: 10rpx;
  341. }
  342. .form-title {
  343. font-size: 32rpx;
  344. font-weight: bold;
  345. color: #333;
  346. padding: 30rpx 0 10rpx 0;
  347. }
  348. .fw400 {
  349. font-weight: 400;
  350. }
  351. </style>