猫妈狗爸伴宠师小程序前端代码
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.

545 lines
17 KiB

  1. <template>
  2. <!-- <view>打卡</view> -->
  3. <view class="box box-size">
  4. <view class="top box-size" :style="{borderRadius:'16rpx'}">
  5. <view class="form-title">
  6. 个人准备
  7. </view>
  8. <view class="mt32 ml10">
  9. <span :style="{fontSize:'30rpx',fontWeight:'400'}">手套照片</span>
  10. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(至少1张)</span>
  11. </view>
  12. <view class="level">
  13. <view class="mt20 ml10">
  14. <up-upload :fileList="fileList.glove" @afterRead="afterRead" @delete="deletePic" name="glove"
  15. multiple :maxCount="2" width="131rpx" height="131rpx" :disabled="isRead">
  16. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  17. </image>
  18. </up-upload>
  19. </view>
  20. </view>
  21. <view class="mt32 ml10">
  22. <span :style="{fontSize:'30rpx',fontWeight:'400'}">鞋套照片</span>
  23. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(至少1张)</span>
  24. </view>
  25. <view class="level">
  26. <view class="mt20 ml10">
  27. <up-upload :fileList="fileList.ShoeCover" @afterRead="afterRead" @delete="deletePic"
  28. name="ShoeCover" multiple :maxCount="2" width="131rpx" height="131rpx" :disabled="isRead">
  29. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  30. </image>
  31. </up-upload>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="top mt24 box-size" :style="{borderRadius:'16rpx'}">
  36. <view class="form-title">
  37. 宠物状态记录
  38. </view>
  39. <view v-for="(pet, index) in petList" :key="index">
  40. <view class="mt32 ml10">
  41. <span :style="{fontSize:'30rpx',fontWeight:'400'}">{{ pet.title }}照片</span>
  42. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(至少2张)</span>
  43. </view>
  44. <view class="level">
  45. <view class="mt20 ml10 mr20">
  46. <up-upload :fileList="fileList['pet' + index]" @afterRead="afterRead" @delete="deletePic"
  47. :name="'pet' + index" multiple :maxCount="2" width="131rpx" height="131rpx" :disabled="isRead">
  48. <image src="/static/images/ydd/add_photo.png" mode=""
  49. :style="{width:'131rpx',height:'131rpx'}">
  50. </image>
  51. </up-upload>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="top mt24 box-size" :style="{borderRadius:'16rpx'}">
  57. <view class="form-title">
  58. 基础服务记录
  59. </view>
  60. <view class="mt32 ml10" :style="{fontSize:'30rpx',fontWeight:'400'}">粮碗前后对比 </view>
  61. <view class="level">
  62. <view class="mt20 ml10">
  63. <up-upload :fileList="fileList.foodA" @afterRead="afterRead" @delete="deletePic" name="foodA"
  64. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  65. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  66. </image>
  67. </up-upload>
  68. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}"></view>
  69. </view>
  70. <view class="mt20 ml10 ml28">
  71. <up-upload :fileList="fileList.foodB" @afterRead="afterRead" @delete="deletePic" name="foodB"
  72. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  73. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  74. </image>
  75. </up-upload>
  76. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}"></view>
  77. </view>
  78. </view>
  79. <view class="mt32 ml10" :style="{fontSize:'30rpx',fontWeight:'400'}">水碗前后对比 </view>
  80. <view class="level">
  81. <view class="mt20 ml10">
  82. <up-upload :fileList="fileList.waterA" @afterRead="afterRead" @delete="deletePic" name="waterA"
  83. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  84. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  85. </image>
  86. </up-upload>
  87. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}"></view>
  88. </view>
  89. <view class="mt20 ml10 ml28">
  90. <up-upload :fileList="fileList.waterB" @afterRead="afterRead" @delete="deletePic" name="waterB"
  91. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  92. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  93. </image>
  94. </up-upload>
  95. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}"></view>
  96. </view>
  97. </view>
  98. <view class="mt32 ml10" :style="{fontSize:'30rpx',fontWeight:'400'}">猫砂盆尿垫前后对比 </view>
  99. <view class="level">
  100. <view class="mt20 ml10">
  101. <up-upload :fileList="fileList.urinalA" @afterRead="afterRead" @delete="deletePic" name="urinalA"
  102. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  103. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  104. </image>
  105. </up-upload>
  106. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}"></view>
  107. </view>
  108. <view class="mt20 ml10 ml28">
  109. <up-upload :fileList="fileList.urinalB" @afterRead="afterRead" @delete="deletePic" name="urinalB"
  110. multiple :maxCount="1" width="131rpx" height="131rpx" :disabled="isRead">
  111. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  112. </image>
  113. </up-upload>
  114. <view class="jus-center level" :style="{color:'#999999',fontSize:'22rpx',width:'131rpx'}"></view>
  115. </view>
  116. </view>
  117. </view>
  118. <view class="top mt24 box-size" :style="{borderRadius:'16rpx'}">
  119. <view class="form-title">
  120. 定制服务记录
  121. </view>
  122. <view v-for="(product, pindex) in projectList"
  123. :key="pindex">
  124. <view class="mt32 ml10">
  125. <span :style="{fontSize:'30rpx',fontWeight:'400'}">{{ product.title }}</span>
  126. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(2-3)</span>
  127. </view>
  128. <view class="level">
  129. <view class="mt20 ml10 mr20">
  130. <up-upload :fileList="fileList['project' + pindex]" @afterRead="afterRead" @delete="deletePic"
  131. :name="'project' + pindex"
  132. multiple :maxCount="3" width="131rpx" height="131rpx" :disabled="isRead">
  133. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  134. </image>
  135. </up-upload>
  136. </view>
  137. </view>
  138. </view>
  139. <!-- <view class="mt32 ml10">
  140. <span :style="{fontSize:'30rpx',fontWeight:'400'}">遛狗</span>
  141. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(2-3)</span>
  142. </view>
  143. <view class="level">
  144. <view class="mt20 ml10 mr20">
  145. <up-upload :fileList="fileList.testa" @afterRead="afterRead" @delete="deletePic" name="testa"
  146. multiple :maxCount="3" width="131rpx" height="131rpx" :disabled="isRead">
  147. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  148. </image>
  149. </up-upload>
  150. </view>
  151. </view> -->
  152. <!-- <view class="mt32 ml10">
  153. <span :style="{fontSize:'30rpx',fontWeight:'400'}">陪玩</span>
  154. <span :style="{fontSize:'26rpx',color:'#C7C7C7'}">(2-3)</span>
  155. </view>
  156. <view class="level">
  157. <view class="mt20 ml10 mr20">
  158. <up-upload :fileList="fileList.testb" @afterRead="afterRead" @delete="deletePic" name="testb"
  159. multiple :maxCount="3" width="131rpx" height="131rpx" :disabled="isRead">
  160. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  161. </image>
  162. </up-upload>
  163. </view>
  164. </view> -->
  165. </view>
  166. <view class="top mt24 box-size" :style="{borderRadius:'16rpx'}">
  167. <view class="form-title">
  168. 其他补充信息(必填)
  169. </view>
  170. <view class="mt32 ml10" :style="{color:'#999999',fontSize:'30rpx'}">
  171. 可记录一下今日趣事宠物状况提醒事项等
  172. </view>
  173. <view class="mt24">
  174. <textarea cols="30" rows="10"
  175. placeholder="请输入内容"
  176. v-model="form.notes"
  177. :style="{color:'#999999',fontSize:'30rpx',backgroundColor:'#F5F5F5',borderRadius:'16rpx',width:'681rpx',height:'180rpx'}"
  178. class="pd20 box-size" :disabled="isRead"></textarea>
  179. </view>
  180. </view>
  181. <view class="buttom mt60 box-size"
  182. v-if="!isRead"
  183. style="display: flex;gap: 20rpx;"
  184. >
  185. <view class="buttom-item buttom-item-2 level size-30"
  186. @click="saveDraft(false)"
  187. :style="{borderRadius:'41rpx',color:'#ff842c'}">
  188. 保存草稿
  189. </view>
  190. <view class="buttom-item level size-30"
  191. @click="submit"
  192. :style="{borderRadius:'41rpx',color:'#fff'}">
  193. 确定提交
  194. </view>
  195. </view>
  196. </view>
  197. </template>
  198. <script setup>
  199. import {
  200. onMounted,
  201. reactive,
  202. ref,
  203. } from "vue";
  204. import {
  205. onLoad
  206. } from '@dcloudio/uni-app'
  207. import {
  208. ossUpload
  209. } from '@/utils/oss-upload/oss/index.js'
  210. import {
  211. appletOrderDateFrequencyById,
  212. appletOrderDateFrequencyCheck,
  213. } from "@/api/order/frequency.js"
  214. onLoad((options) => {
  215. checkId.value = options.id || null;
  216. GetByOrderId()
  217. });
  218. const checkId = ref(0)
  219. const orderId = ref(0)
  220. const itemOrderID = ref(0)
  221. const serviceId = ref(0)
  222. const isRead = ref(false)
  223. const content = ref('')
  224. const fileList = reactive({
  225. // glove: [],//手套
  226. // ShoeCover: [],//鞋套
  227. // food: [],//粮碗
  228. // water: [],//水碗
  229. // urinal: [],//猫砂盆、尿盆
  230. })
  231. const form = ref({})
  232. const petList = ref([
  233. // {
  234. // title: '小汪'
  235. // },
  236. // {
  237. // title: '大黄'
  238. // },
  239. ])
  240. //附加项目
  241. const projectList = ref([
  242. // {
  243. // title: '小汪'
  244. // },
  245. // {
  246. // title: '大黄'
  247. // },
  248. ])
  249. // 删除图片
  250. const deletePic = (event) => {
  251. if (fileList[event.name]) {
  252. fileList[event.name].splice(event.index, 1);
  253. }
  254. };
  255. // 新增图片
  256. const afterRead = (event) => {
  257. if (!fileList[event.name]) {
  258. fileList[event.name] = []
  259. }
  260. event.file.forEach(n => {
  261. ossUpload(n.url)
  262. .then(url => {
  263. fileList[event.name].push({
  264. url
  265. })
  266. })
  267. })
  268. };
  269. function submit() {
  270. // 参数效验
  271. if (!fileList.glove || fileList.glove.length == 0) {
  272. return msg('请上传鞋套照片')
  273. }
  274. if (!fileList.ShoeCover || fileList.ShoeCover.length == 0) {
  275. return msg('请上传鞋套照片')
  276. }
  277. for (let i = 0; i < petList.value.length; i++) {
  278. if (!fileList['pet' + i] || fileList['pet' + i].length < 2) {
  279. return msg(`请上传${petList.value[i].title}照片`)
  280. }
  281. }
  282. if (!fileList.foodA || fileList.foodA.length < 1 ||
  283. !fileList.foodB || fileList.foodB.length < 1) {
  284. return msg('请上传粮碗前后照片')
  285. }
  286. if (!fileList.waterA || fileList.waterA.length < 1 ||
  287. !fileList.waterB || fileList.waterB.length < 1) {
  288. return msg('请上传水碗前后照片')
  289. }
  290. if (!fileList.urinalA || fileList.urinalA.length < 1 ||
  291. !fileList.urinalB || fileList.urinalB.length < 1) {
  292. return msg('请上传猫砂盆、尿盆照片')
  293. }
  294. for (let i = 0; i < projectList.value.length; i++) {
  295. if (!fileList['project' + i] || fileList['project' + i].length < 2) {
  296. return msg(`请上传${projectList.value[i].title}照片`)
  297. }
  298. }
  299. if(!form.value.notes){
  300. return msg('请填写补充信息')
  301. }
  302. saveDraft(true)
  303. }
  304. function GetByOrderId(){
  305. appletOrderDateFrequencyById(checkId.value)
  306. .then(res => {
  307. const data = res.data.check;
  308. const frequency = res.data.frequency;
  309. isRead.value = frequency.status == 2
  310. if(res.code == 200 && data) {
  311. form.value = data
  312. // 回显手套照片
  313. if(data.glovePhoto) {
  314. fileList.glove = data.glovePhoto.split(',').map(url => ({ url }));
  315. }
  316. // 回显鞋套照片
  317. if(data.shoeCoverPhoto) {
  318. fileList.ShoeCover = data.shoeCoverPhoto.split(',').map(url => ({ url }));
  319. }
  320. // 回显宠物照片
  321. if(data.petPhoto) {
  322. const pets = JSON.parse(data.petPhoto);
  323. petList.value = pets;
  324. pets.forEach((pet, index) => {
  325. if(pet.fileList) {
  326. fileList['pet' + index] = pet.fileList.split(',').map(url => ({ url }));
  327. }
  328. });
  329. }
  330. // 回显项目照片
  331. if(data.workDogImage) {
  332. const pList = JSON.parse(data.workDogImage);
  333. projectList.value = pList;
  334. pList.forEach((pet, index) => {
  335. if(pet.fileList) {
  336. fileList['project' + index] = pet.fileList.split(',').map(url => ({ url }));
  337. }
  338. });
  339. }
  340. // 回显粮碗照片
  341. if(data.grainBowlFront) fileList.foodA = data.grainBowlFront.split(',').map(url => ({ url }));
  342. if(data.grainBowlAfter) fileList.foodB = data.grainBowlAfter.split(',').map(url => ({ url }));
  343. // 回显水碗照片
  344. if(data.waterBowlFront) fileList.waterA = data.waterBowlFront.split(',').map(url => ({ url }));
  345. if(data.waterBowlAfter) fileList.waterB = data.waterBowlAfter.split(',').map(url => ({ url }));
  346. // 回显猫砂盆/尿垫照片
  347. if(data.basinFront) fileList.urinalA = data.basinFront.split(',').map(url => ({ url }));
  348. if(data.basinAfter) fileList.urinalB = data.basinAfter.split(',').map(url => ({ url }));
  349. // 回显定制服务照片
  350. // if(data.workDogImage) fileList.testa = data.workDogImage.split(',').map(url => ({ url }));
  351. // if(data.workPalyImage) fileList.testb = data.workPalyImage.split(',').map(url => ({ url }));
  352. }else{
  353. // getOrderPetByIdFN()
  354. let projectNameList = []
  355. frequency.pets.forEach((n, i) => {
  356. fileList['pet' + i] = []
  357. n.orderItemList.forEach((item, inde) => {
  358. fileList['project' + inde] = []
  359. })
  360. })
  361. frequency.pets.forEach((n, i) => {
  362. petList.value.push({
  363. title : n.name,
  364. id : n.id,
  365. })
  366. n.orderItemList.forEach((item, inde) => {
  367. if(!projectNameList.includes(item.productName)){
  368. projectNameList.push(item.productName)
  369. projectList.value.push({
  370. title : item.productName,
  371. ids : [item.id]
  372. })
  373. }else{
  374. projectList.value[projectNameList.indexOf(item.productName)].ids.push(item.id)
  375. }
  376. })
  377. })
  378. }
  379. })
  380. }
  381. function getOrderPetByIdFN(){
  382. getOrderPetById(orderId.value)
  383. .then(res => {
  384. if(res.code == 200){
  385. res.data.forEach((n, i) => {
  386. fileList['pet' + i] = []
  387. })
  388. res.data.forEach((n, i) => {
  389. petList.value.push({
  390. title : n.name,
  391. id : n.id,
  392. })
  393. })
  394. }
  395. })
  396. }
  397. function saveDraft(flag) {
  398. // 将所有图片数组转换为逗号分隔的字符串
  399. const params = {
  400. // orderId: orderId.value,
  401. // itemOrderId : itemOrderID.value,
  402. itemDateId : checkId.value,
  403. glovePhoto: fileList.glove?.map(item => item.url).join(',') || '',
  404. shoeCoverPhoto: fileList.ShoeCover?.map(item => item.url).join(',') || '',
  405. // 合并所有宠物照片
  406. petPhoto: JSON.stringify(
  407. petList.value.map((pet, index) => {
  408. return {
  409. id : pet.id,
  410. title : pet.title,
  411. fileList: fileList['pet' + index]?.map(item => item.url).join(',') || ''
  412. };
  413. })
  414. ),
  415. workDogImage: JSON.stringify(
  416. projectList.value.map((pet, index) => {
  417. return {
  418. id : pet.id,
  419. title : pet.title,
  420. fileList: fileList['project' + index]?.map(item => item.url).join(',') || ''
  421. };
  422. })
  423. ),
  424. // 粮碗照片
  425. grainBowlFront: fileList.foodA?.map(item => item.url).join(',') || '',
  426. grainBowlAfter: fileList.foodB?.map(item => item.url).join(',') || '',
  427. // 水碗照片
  428. waterBowlFront: fileList.waterA?.map(item => item.url).join(',') || '',
  429. waterBowlAfter: fileList.waterB?.map(item => item.url).join(',') || '',
  430. // 猫砂盆/尿垫照片
  431. basinFront: fileList.urinalA?.map(item => item.url).join(',') || '',
  432. basinAfter: fileList.urinalB?.map(item => item.url).join(',') || '',
  433. // 定制服务照片
  434. // workDogImage: fileList.testa?.map(item => item.url).join(',') || '',
  435. // workPalyImage: fileList.testb?.map(item => item.url).join(',') || '',
  436. // 备注信息
  437. notes: form.value.notes || '',
  438. submitFlag : 1,//草稿
  439. }
  440. if(form.value.id) {
  441. params.id = form.value.id
  442. }
  443. if(flag) {
  444. params.submitFlag = 2
  445. }
  446. appletOrderDateFrequencyCheck(params)
  447. .then(res => {
  448. if(res.code === 200) {
  449. uni.showToast({
  450. title: '提交成功',
  451. icon: 'success'
  452. })
  453. // 如果是确认提交(非草稿),则返回上一页
  454. setTimeout(() => {
  455. uni.navigateBack()
  456. }, 1500)
  457. } else {
  458. uni.showToast({
  459. title: res.msg || '提交失败',
  460. icon: 'none'
  461. })
  462. }
  463. })
  464. .catch(err => {
  465. uni.showToast({
  466. title: '提交失败',
  467. icon: 'none'
  468. })
  469. })
  470. }
  471. function msg(content) {
  472. uni.showToast({
  473. title: content,
  474. icon: 'none'
  475. })
  476. }
  477. </script>
  478. <style scoped lang="scss">
  479. @import"index.scss"
  480. </style>