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

559 lines
17 KiB

1 month ago
2 weeks ago
1 month 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. <!-- 客服组件 -->
  199. <CustomerService />
  200. </view>
  201. </template>
  202. <script setup>
  203. import {
  204. onMounted,
  205. reactive,
  206. ref,
  207. } from "vue";
  208. import {
  209. onLoad
  210. } from '@dcloudio/uni-app'
  211. import {
  212. ossUpload
  213. } from '@/utils/oss-upload/oss/index.js'
  214. import {
  215. appletOrderDateFrequencyById,
  216. appletOrderDateFrequencyCheck,
  217. } from "@/api/order/frequency.js"
  218. onLoad((options) => {
  219. checkId.value = options.id || null;
  220. GetByOrderId()
  221. });
  222. const checkId = ref(0)
  223. const orderId = ref(0)
  224. const itemOrderID = ref(0)
  225. const serviceId = ref(0)
  226. const isRead = ref(false)
  227. const content = ref('')
  228. const fileList = reactive({
  229. // glove: [],//手套
  230. // ShoeCover: [],//鞋套
  231. // food: [],//粮碗
  232. // water: [],//水碗
  233. // urinal: [],//猫砂盆、尿盆
  234. })
  235. const form = ref({})
  236. const petList = ref([
  237. // {
  238. // title: '小汪'
  239. // },
  240. // {
  241. // title: '大黄'
  242. // },
  243. ])
  244. //附加项目
  245. const projectList = ref([
  246. // {
  247. // title: '小汪'
  248. // },
  249. // {
  250. // title: '大黄'
  251. // },
  252. ])
  253. // 删除图片
  254. const deletePic = (event) => {
  255. if (fileList[event.name]) {
  256. fileList[event.name].splice(event.index, 1);
  257. }
  258. };
  259. // 新增图片
  260. const afterRead = (event) => {
  261. if (!fileList[event.name]) {
  262. fileList[event.name] = []
  263. }
  264. event.file.forEach(n => {
  265. ossUpload(n.url)
  266. .then(url => {
  267. console.log(url);
  268. fileList[event.name].push({
  269. url
  270. })
  271. })
  272. })
  273. };
  274. function submit() {
  275. // 参数效验
  276. if (!fileList.glove || fileList.glove.length == 0) {
  277. return msg('请上传鞋套照片')
  278. }
  279. if (!fileList.ShoeCover || fileList.ShoeCover.length == 0) {
  280. return msg('请上传鞋套照片')
  281. }
  282. for (let i = 0; i < petList.value.length; i++) {
  283. if (!fileList['pet' + i] || fileList['pet' + i].length < 2) {
  284. return msg(`请上传${petList.value[i].title}照片`)
  285. }
  286. }
  287. if (!fileList.foodA || fileList.foodA.length < 1 ||
  288. !fileList.foodB || fileList.foodB.length < 1) {
  289. return msg('请上传粮碗前后照片')
  290. }
  291. if (!fileList.waterA || fileList.waterA.length < 1 ||
  292. !fileList.waterB || fileList.waterB.length < 1) {
  293. return msg('请上传水碗前后照片')
  294. }
  295. if (!fileList.urinalA || fileList.urinalA.length < 1 ||
  296. !fileList.urinalB || fileList.urinalB.length < 1) {
  297. return msg('请上传猫砂盆、尿盆照片')
  298. }
  299. for (let i = 0; i < projectList.value.length; i++) {
  300. if (!fileList['project' + i] || fileList['project' + i].length < 2) {
  301. return msg(`请上传${projectList.value[i].title}照片`)
  302. }
  303. }
  304. if(!form.value.notes){
  305. return msg('请填写补充信息')
  306. }
  307. if(form.value.notes.length < 30){
  308. return msg('补充信息不少于30字')
  309. }
  310. saveDraft(true)
  311. }
  312. function GetByOrderId(){
  313. appletOrderDateFrequencyById(checkId.value)
  314. .then(res => {
  315. const data = res.data.check;
  316. const frequency = res.data.frequency;
  317. isRead.value = frequency.status == 2
  318. if(res.code == 200 && data) {
  319. form.value = data
  320. // 回显手套照片
  321. if(data.glovePhoto) {
  322. fileList.glove = data.glovePhoto.split(',').map(url => ({ url }));
  323. }
  324. // 回显鞋套照片
  325. if(data.shoeCoverPhoto) {
  326. fileList.ShoeCover = data.shoeCoverPhoto.split(',').map(url => ({ url }));
  327. }
  328. // 回显宠物照片
  329. if(data.petPhoto) {
  330. const pets = JSON.parse(data.petPhoto);
  331. petList.value = pets;
  332. pets.forEach((pet, index) => {
  333. if(pet.fileList) {
  334. fileList['pet' + index] = pet.fileList.split(',').map(url => ({ url }));
  335. }
  336. });
  337. }
  338. // 回显项目照片
  339. if(data.workDogImage) {
  340. const pList = JSON.parse(data.workDogImage);
  341. projectList.value = pList;
  342. pList.forEach((pet, index) => {
  343. if(pet.fileList) {
  344. fileList['project' + index] = pet.fileList.split(',').map(url => ({ url }));
  345. }
  346. });
  347. }
  348. // 回显粮碗照片
  349. if(data.grainBowlFront) fileList.foodA = data.grainBowlFront.split(',').map(url => ({ url }));
  350. if(data.grainBowlAfter) fileList.foodB = data.grainBowlAfter.split(',').map(url => ({ url }));
  351. // 回显水碗照片
  352. if(data.waterBowlFront) fileList.waterA = data.waterBowlFront.split(',').map(url => ({ url }));
  353. if(data.waterBowlAfter) fileList.waterB = data.waterBowlAfter.split(',').map(url => ({ url }));
  354. // 回显猫砂盆/尿垫照片
  355. if(data.basinFront) fileList.urinalA = data.basinFront.split(',').map(url => ({ url }));
  356. if(data.basinAfter) fileList.urinalB = data.basinAfter.split(',').map(url => ({ url }));
  357. // 回显定制服务照片
  358. // if(data.workDogImage) fileList.testa = data.workDogImage.split(',').map(url => ({ url }));
  359. // if(data.workPalyImage) fileList.testb = data.workPalyImage.split(',').map(url => ({ url }));
  360. }else{
  361. // getOrderPetByIdFN()
  362. let projectNameList = []
  363. frequency.pets.forEach((n, i) => {
  364. fileList['pet' + i] = []
  365. n.orderItemList.forEach((item, inde) => {
  366. fileList['project' + inde] = []
  367. })
  368. })
  369. frequency.pets.forEach((n, i) => {
  370. petList.value.push({
  371. title : n.name,
  372. id : n.id,
  373. })
  374. n.orderItemList.forEach((item, inde) => {
  375. if(item.isMainProduct == 1){
  376. return
  377. }
  378. if(!projectNameList.includes(item.productName)){
  379. projectNameList.push(item.productName)
  380. projectList.value.push({
  381. title : item.productName,
  382. ids : [item.id]
  383. })
  384. }else{
  385. projectList.value[projectNameList.indexOf(item.productName)].ids.push(item.id)
  386. }
  387. })
  388. })
  389. }
  390. })
  391. }
  392. function getOrderPetByIdFN(){
  393. getOrderPetById(orderId.value)
  394. .then(res => {
  395. if(res.code == 200){
  396. res.data.forEach((n, i) => {
  397. fileList['pet' + i] = []
  398. })
  399. res.data.forEach((n, i) => {
  400. petList.value.push({
  401. title : n.name,
  402. id : n.id,
  403. })
  404. })
  405. }
  406. })
  407. }
  408. function saveDraft(flag) {
  409. // 将所有图片数组转换为逗号分隔的字符串
  410. const params = {
  411. // orderId: orderId.value,
  412. // itemOrderId : itemOrderID.value,
  413. itemDateId : checkId.value,
  414. glovePhoto: fileList.glove?.map(item => item.url).join(',') || '',
  415. shoeCoverPhoto: fileList.ShoeCover?.map(item => item.url).join(',') || '',
  416. // 合并所有宠物照片
  417. petPhoto: JSON.stringify(
  418. petList.value.map((pet, index) => {
  419. return {
  420. id : pet.id,
  421. title : pet.title,
  422. fileList: fileList['pet' + index]?.map(item => item.url).join(',') || ''
  423. };
  424. })
  425. ),
  426. workDogImage: JSON.stringify(
  427. projectList.value.map((pet, index) => {
  428. return {
  429. id : pet.id,
  430. title : pet.title,
  431. fileList: fileList['project' + index]?.map(item => item.url).join(',') || ''
  432. };
  433. })
  434. ),
  435. // 粮碗照片
  436. grainBowlFront: fileList.foodA?.map(item => item.url).join(',') || '',
  437. grainBowlAfter: fileList.foodB?.map(item => item.url).join(',') || '',
  438. // 水碗照片
  439. waterBowlFront: fileList.waterA?.map(item => item.url).join(',') || '',
  440. waterBowlAfter: fileList.waterB?.map(item => item.url).join(',') || '',
  441. // 猫砂盆/尿垫照片
  442. basinFront: fileList.urinalA?.map(item => item.url).join(',') || '',
  443. basinAfter: fileList.urinalB?.map(item => item.url).join(',') || '',
  444. // 定制服务照片
  445. // workDogImage: fileList.testa?.map(item => item.url).join(',') || '',
  446. // workPalyImage: fileList.testb?.map(item => item.url).join(',') || '',
  447. // 备注信息
  448. notes: form.value.notes || '',
  449. submitFlag : 1,//草稿
  450. }
  451. if(form.value.id) {
  452. params.id = form.value.id
  453. }
  454. if(flag) {
  455. params.submitFlag = 2
  456. }
  457. appletOrderDateFrequencyCheck(params)
  458. .then(res => {
  459. if(res.code === 200) {
  460. uni.showToast({
  461. title: '提交成功',
  462. icon: 'success'
  463. })
  464. // 如果是确认提交(非草稿),则返回上一页
  465. setTimeout(() => {
  466. uni.navigateBack()
  467. }, 1500)
  468. } else {
  469. uni.showToast({
  470. title: res.msg || '提交失败',
  471. icon: 'none'
  472. })
  473. }
  474. })
  475. .catch(err => {
  476. uni.showToast({
  477. title: '提交失败',
  478. icon: 'none'
  479. })
  480. })
  481. }
  482. function msg(content) {
  483. uni.showToast({
  484. title: content,
  485. icon: 'none'
  486. })
  487. }
  488. </script>
  489. <style scoped lang="scss">
  490. @import"index.scss"
  491. </style>