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

557 lines
17 KiB

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