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

290 lines
5.7 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view class="page">
  3. <view class="flex-rowl tab">
  4. <view class="size-28 color-ffb fw700 tab-item">
  5. 全部记录
  6. </view>
  7. </view>
  8. <view v-if="list.length">
  9. <view class="box" v-for="item in list" :key="item.id">
  10. <view class="flex-rowl box-top">
  11. <up-avatar :src="userInfo.userImage" size="126rpx"></up-avatar>
  12. <view class="box-info">
  13. <view class="row highlight">{{ userInfo.userName }}</view>
  14. <view class="row">{{ `服务时间:${dayjs(item.createTime).format('YYYY-MM-DD')}` }}</view>
  15. <view class="row">{{ `宠物:${getTypeDesc(item.typeIds)}` }}</view>
  16. </view>
  17. <view class="box-address">
  18. <text>{{ item.serviceSpot }}</text>
  19. </view>
  20. </view>
  21. <view class="box-text">
  22. {{ item.text }}
  23. </view>
  24. <view class="box-img">
  25. <view
  26. class="box-img-item"
  27. v-for="(url, imgIdx) in item.images"
  28. :key="`${item.id}-img-${imgIdx}`"
  29. >
  30. <up-image
  31. :src="url"
  32. :show-loading="true"
  33. width="154rpx"
  34. height="164rpx"
  35. ></up-image>
  36. </view>
  37. </view>
  38. <view class="flex-rowr box-tools">
  39. <button plain class="box-btn" @click="onEdit(item.id)">
  40. <view class="flex-rowc">
  41. <up-icon name="edit-pen" color="#707070" size="22rpx"></up-icon>
  42. <text>编辑</text>
  43. </view>
  44. </button>
  45. <button plain class="box-btn" @click="onDelete(item.id)">
  46. <view class="flex-rowc">
  47. <up-icon name="trash" color="#707070" size="22rpx"></up-icon>
  48. <text>删除</text>
  49. </view>
  50. </button>
  51. </view>
  52. </view>
  53. </view>
  54. <view v-else class="flex-rowc">
  55. <image class="img-empty" src="@/static/images/ydd/empy.png" mode="widthFix"></image>
  56. </view>
  57. <up-modal
  58. :show="deleteModal.show"
  59. :showConfirmButton="false"
  60. :showCancelButton="false"
  61. >
  62. <view class="modal">
  63. <view class="modal-content">确定要删除该条服务信息吗</view>
  64. <view>
  65. <button plain class="modal-btn modal-btn-cancel" @click="onCancelDelete">取消</button>
  66. <button plain class="modal-btn modal-btn-confirm" @click="onConfirmDelete">确定</button>
  67. </view>
  68. </view>
  69. </up-modal>
  70. <view class="footer-btn">
  71. <view class="btn" @click="toUp">
  72. 立即上传
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <script setup>
  78. import { ref, reactive, computed } from 'vue'
  79. import { useStore } from 'vuex'
  80. import { onShow, onLoad } from '@dcloudio/uni-app'
  81. import { serviceLogList, deleteServiceLog } from '@/api/serviceLog'
  82. import dayjs from 'dayjs'
  83. const store = useStore()
  84. const userInfo = computed(() => {
  85. return store.getters.userInfo
  86. })
  87. const petTypeOptions = computed(() => {
  88. return store.getters.petTypeOptions
  89. })
  90. const getTypeDesc = (typeIds) => {
  91. if (!typeIds.length) {
  92. return ''
  93. }
  94. let descArr = typeIds.map(typeId => {
  95. return petTypeOptions.value.find(item => item.id == typeId)?.title || typeId
  96. })
  97. return descArr.join('、')
  98. }
  99. const list = ref([])
  100. const fetchLogList = async () => {
  101. try {
  102. list.value = await serviceLogList({ userId: store.getters.userInfo.userId })
  103. } catch (err) {
  104. }
  105. }
  106. const onEdit = (id) => {
  107. uni.setStorageSync('serviceLogData', list.value.find(item => item.id === id))
  108. uni.navigateTo({
  109. url: `/otherPages/authentication/serve/upload?id=${id}`
  110. })
  111. }
  112. const deleteModal = reactive({
  113. show: false,
  114. id: null,
  115. })
  116. const onDelete = (id) => {
  117. deleteModal.id = id
  118. deleteModal.show = true
  119. }
  120. const onCancelDelete = () => {
  121. deleteModal.show = false
  122. }
  123. const onConfirmDelete = async () => {
  124. try {
  125. await deleteServiceLog({ id: deleteModal.id })
  126. fetchLogList()
  127. deleteModal.show = false
  128. } catch (err) {
  129. }
  130. }
  131. const toUp = () => {
  132. uni.navigateTo({
  133. url: "/otherPages/authentication/serve/upload"
  134. })
  135. }
  136. onShow(async () => {
  137. await store.dispatch('fetchPetTypeOptions')
  138. fetchLogList()
  139. })
  140. </script>
  141. <style lang="scss" scoped>
  142. .page {
  143. min-height: 100vh;
  144. background-color: #F5F5F5;
  145. }
  146. .tab {
  147. padding: 9rpx 28rpx 16rpx 28rpx;
  148. background-color: #fff;
  149. &-item {
  150. padding-bottom: 9rpx;
  151. border-bottom: 4rpx solid #FFBF60;
  152. }
  153. }
  154. .box {
  155. margin-top: 6rpx;
  156. padding: 34rpx 43rpx 16rpx 28rpx;
  157. background-color: #fff;
  158. .img__view {
  159. flex-wrap: wrap;
  160. }
  161. &-top {
  162. align-items: start;
  163. }
  164. &-info {
  165. flex: 1;
  166. padding: 0 20rpx;
  167. color: rgba($color: #000000, $alpha: 0.5);
  168. font-size: 28rpx;
  169. line-height: 37rpx;
  170. .highlight {
  171. color: #000000;
  172. font-size: 30rpx;
  173. font-weight: 700;
  174. line-height: 40rpx;
  175. }
  176. .row + .row {
  177. margin-top: 6rpx;
  178. }
  179. }
  180. &-address {
  181. max-width: 200rpx;
  182. text-align: right;
  183. color: #FFBF60;
  184. font-size: 28rpx;
  185. line-height: 37rpx;
  186. }
  187. &-text {
  188. padding: 21rpx 32rpx 18rpx 16rpx;
  189. color: #000000;
  190. font-size: 30rpx;
  191. line-height: 40rpx;
  192. }
  193. &-img {
  194. &-item {
  195. display: inline-block;
  196. border-radius: 20rpx;
  197. overflow: hidden;
  198. margin-bottom: 16rpx;
  199. margin-left: 16rpx;
  200. }
  201. }
  202. &-btn {
  203. display: inline-block;
  204. border: none;
  205. padding: 0;
  206. margin: 0;
  207. color: #707070;
  208. font-size: 22rpx;
  209. line-height: 29rpx;
  210. & + & {
  211. margin-left: 44rpx;
  212. }
  213. }
  214. }
  215. .img-empty {
  216. width: 250rpx;
  217. margin-top: 20vh;
  218. }
  219. .modal {
  220. &-content {
  221. text-align: center;
  222. color: #000000;
  223. font-size: 30rpx;
  224. line-height: 40rpx;
  225. margin-bottom: 35rpx;
  226. }
  227. &-btn {
  228. display: inline-block;
  229. padding: 20rpx 89rpx;
  230. border: none;
  231. margin: 0;
  232. width: auto;
  233. height: auto;
  234. font-size: 30rpx;
  235. line-height: 40rpx;
  236. border-radius: 40rpx;
  237. & + & {
  238. margin-left: 25rpx;
  239. }
  240. &-cancel {
  241. background-color: #FFF4E6;
  242. color: #FFBF60;
  243. }
  244. &-confirm {
  245. background-color: #FFBF60;
  246. color: #FFFFFF;
  247. }
  248. }
  249. }
  250. </style>