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

292 lines
9.2 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:'22rpx',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">
  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:'22rpx',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">
  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:'22rpx',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">
  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">
  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">
  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">
  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">
  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">
  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">
  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 class="mt32 ml10">
  123. <span :style="{fontSize:'30rpx',fontWeight:'400'}">遛狗</span>
  124. <span :style="{fontSize:'22rpx',color:'#C7C7C7'}">(2-3)</span>
  125. </view>
  126. <view class="level">
  127. <view class="mt20 ml10 mr20">
  128. <up-upload :fileList="fileList.testa" @afterRead="afterRead" @delete="deletePic" name="testa"
  129. multiple :maxCount="3" width="131rpx" height="131rpx">
  130. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  131. </image>
  132. </up-upload>
  133. </view>
  134. </view>
  135. <view class="mt32 ml10">
  136. <span :style="{fontSize:'30rpx',fontWeight:'400'}">陪玩</span>
  137. <span :style="{fontSize:'22rpx',color:'#C7C7C7'}">(2-3)</span>
  138. </view>
  139. <view class="level">
  140. <view class="mt20 ml10 mr20">
  141. <up-upload :fileList="fileList.testb" @afterRead="afterRead" @delete="deletePic" name="testb"
  142. multiple :maxCount="3" width="131rpx" height="131rpx">
  143. <image src="/static/images/ydd/add_photo.png" mode="" :style="{width:'131rpx',height:'131rpx'}">
  144. </image>
  145. </up-upload>
  146. </view>
  147. </view>
  148. </view>
  149. <view class="top mt24 box-size" :style="{borderRadius:'16rpx'}">
  150. <view class="form-title">
  151. 其他补充信息(非必填)
  152. </view>
  153. <view class="mt32 ml10" :style="{color:'#999999',fontSize:'30rpx'}">
  154. 可记录一下今日趣事宠物状况提醒事项等
  155. </view>
  156. <view class="mt24">
  157. <textarea name="" id="" cols="30" rows="10" placeholder="请输入内容"
  158. :style="{color:'#999999',fontSize:'30rpx',backgroundColor:'#F5F5F5',borderRadius:'16rpx',width:'681rpx',height:'180rpx'}"
  159. class="pd20 box-size"></textarea>
  160. </view>
  161. </view>
  162. <view class="buttom mt60 box-size" @click="submit">
  163. <view class="buttom-item level size-30" :style="{borderRadius:'41rpx',color:'#fff'}">
  164. 确定提交
  165. </view>
  166. </view>
  167. </view>
  168. </template>
  169. <script setup>
  170. import {
  171. onMounted,
  172. reactive,
  173. ref
  174. } from "vue";
  175. import {
  176. ossUpload
  177. } from '@/utils/oss-upload/oss/index.js'
  178. const fileList = reactive({
  179. // glove: [],//手套
  180. // ShoeCover: [],//鞋套
  181. // food: [],//粮碗
  182. // water: [],//水碗
  183. // urinal: [],//猫砂盆、尿盆
  184. })
  185. const form = ref({})
  186. const petList = ref([{
  187. title: '小汪'
  188. },
  189. {
  190. title: '大黄'
  191. },
  192. ])
  193. petList.value.forEach((n, i) => {
  194. fileList['pet' + i] = []
  195. })
  196. // 删除图片
  197. const deletePic = (event) => {
  198. if (fileList[event.name]) {
  199. fileList[event.name].splice(event.index, 1);
  200. }
  201. };
  202. // 新增图片
  203. const afterRead = (event) => {
  204. if (!fileList[event.name]) {
  205. fileList[event.name] = []
  206. }
  207. event.file.forEach(n => {
  208. ossUpload(n.url)
  209. .then(url => {
  210. fileList[event.name].push({
  211. url
  212. })
  213. })
  214. })
  215. };
  216. function submit() {
  217. // 参数效验
  218. if (!fileList.glove || fileList.glove.length == 0) {
  219. return msg('请上传鞋套照片')
  220. }
  221. if (!fileList.ShoeCover || fileList.ShoeCover.length == 0) {
  222. return msg('请上传鞋套照片')
  223. }
  224. for (let i = 0; i < petList.value.length; i++) {
  225. if (!fileList['pet' + i] || fileList['pet' + i].length < 2) {
  226. return msg(`请上传${petList.value[i].title}照片`)
  227. }
  228. }
  229. if (!fileList.foodA || fileList.foodA.length < 2 ||
  230. !fileList.foodB || fileList.foodB.length < 2) {
  231. return msg('请上传粮碗前后照片')
  232. }
  233. if (!fileList.waterA || fileList.waterA.length < 2 ||
  234. !fileList.waterB || fileList.waterB.length < 2) {
  235. return msg('请上传水碗前后照片')
  236. }
  237. if (!fileList.urinalA || fileList.urinalA.length < 2 ||
  238. !fileList.urinalB || fileList.urinalB.length < 2) {
  239. return msg('请上传猫砂盆、尿盆照片')
  240. }
  241. }
  242. function msg(content) {
  243. uni.showToast({
  244. title: content,
  245. icon: 'none'
  246. })
  247. }
  248. </script>
  249. <style scoped lang="scss">
  250. @import"index.scss"
  251. </style>