LostandFoundadd.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="padding">
  3. <u-form labelPosition="top" :model="model1" :rules="rules" ref="uForm">
  4. <u-form-item label="订单号码" prop="ordersId" borderBottom ref="item1">
  5. <u-input v-model="model1.ordersId" border="none"></u-input>
  6. </u-form-item>
  7. <u-form-item label="联系人" prop="name" borderBottom ref="item1">
  8. <u-input v-model="model1.name" border="none"></u-input>
  9. </u-form-item>
  10. <u-form-item label="联系方式" prop="phone" borderBottom ref="item1">
  11. <u-input v-model="model1.phone" border="none"></u-input>
  12. </u-form-item>
  13. <u-form-item label="拾获时间" prop="foundTime" borderBottom ref="item1">
  14. <view class="flex align-center addboxs bg" style="padding: 0 30rpx; justify-content: space-between;" @click="openTime()">
  15. <view class="flex align-center">
  16. <image v-if="globalImages" :src="globalImages + 'imgs/static/upload/time.png'" style="width: 34rpx;height: 34rpx;"></image>
  17. <view class="add_tit margin-left-xs" v-if="!yuyueTime">选择预约时间</view>
  18. <view class="add_tit margin-left-xs" v-else>{{yuyueTime}}</view>
  19. </view>
  20. <view class="margin-left-xs">
  21. <image v-if="globalImages" :src="globalImages + 'imgs/static/image/right.png'" style="width: 12rpx;height: 20rpx;">
  22. </image>
  23. </view>
  24. </view>
  25. </u-form-item>
  26. <u-form-item label="其他信息" prop="description" borderBottom>
  27. <textarea placeholder="简要描述物品其他信息" v-model="model1.description"
  28. class="feedback-textare" />
  29. </u-form-item>
  30. </u-form>
  31. <u-picker v-model="Timeshow" mode="time" :params="params"
  32. @confirm="timeConfirm"></u-picker>
  33. <view class="">
  34. <view class="flex" style="justify-content: space-between;">
  35. <view>物品照片</view>
  36. <view>请上传丢失的物品照片</view>
  37. </view>
  38. <u-upload
  39. :action="uploadAction"
  40. :file-list="fileList"
  41. @on-success="handleUploadSuccess"
  42. @on-error="handleUploadError"
  43. :max-count="1"
  44. :multiple="false"
  45. ></u-upload>
  46. </view>
  47. <view class="pay_btns" @click="submit">发布信息</view>
  48. </view>
  49. </template>
  50. <script>
  51. import { waitForGlobalImages } from '@/utils/globalImageLoader'
  52. export default {
  53. data() {
  54. return {
  55. model1: {
  56. name: '',
  57. ordersId: '',
  58. phone: '',
  59. description: '',
  60. image: '',
  61. loss: 2,
  62. foundTime: ''
  63. },
  64. // 上传组件配置
  65. uploadAction: 'http://192.168.50.122:8179/sqx_fast/alioss/upload', // 上传接口地址
  66. fileList: [], // 已上传的文件列表
  67. Timeshow: false,
  68. params: {
  69. year: true,
  70. month: true,
  71. day: true,
  72. hour: true,
  73. minute: true,
  74. second: false
  75. },
  76. yuyueTime: '',
  77. globalImages: ''
  78. }
  79. },
  80. onLoad() {
  81. waitForGlobalImages().then((path) => {
  82. console.log('✅ 全局图片路径:', path)
  83. this.globalImages = path
  84. })
  85. },
  86. methods: {
  87. // 上传成功回调
  88. handleUploadSuccess(response) {
  89. console.log('上传成功', response.data);
  90. // 将上传成功的文件添加到 fileList
  91. this.model1.image = response.data; // 保存图片 URL
  92. this.fileList = response.data
  93. },
  94. // 上传失败回调
  95. handleUploadError(error) {
  96. console.error('上传失败', error);
  97. uni.showToast({
  98. title: '上传失败,请重试',
  99. icon: 'none',
  100. });
  101. },
  102. submit() {
  103. this.model1.foundTime = this.yuyueTime
  104. this.$Request.postT("/app/lostFound/insert", this.model1).then(res => {
  105. if (res.code === 0) {
  106. uni.showToast({
  107. title: '新增成功',
  108. icon: 'success',
  109. });
  110. uni.navigateBack(); // 返回上一页
  111. }
  112. });
  113. },
  114. timeConfirm(e) {
  115. console.log(e, e.year);
  116. this.yuyueTime = e.year + '/' + e.month + '/' + e.day + '/' + '' + e.hour + ':' + e.minute
  117. },
  118. openTime() {
  119. this.Timeshow = true
  120. console.log('123123123');
  121. }
  122. }
  123. }
  124. </script>
  125. <style scoped>
  126. .feedback-textare {
  127. height: 200upx;
  128. font-size: 24upx;
  129. line-height: 50upx;
  130. width: 100%;
  131. box-sizing: border-box;
  132. padding: 20upx 20upx 0;
  133. border: #e4e7ed 1rpx solid;
  134. background: #fff;
  135. border-radius: 15rpx;
  136. /* margin-top: 20rpx; */
  137. }
  138. .pay_btns {
  139. width: calc(100% - 60rpx);
  140. margin: 0 auto 40rpx;
  141. text-align: center;
  142. background: #00c18a;
  143. height: 80rpx;
  144. border-radius: 16rpx;
  145. color: #ffffff;
  146. line-height: 80rpx;
  147. margin-top: 20rpx;
  148. position: fixed;
  149. bottom: 0rpx;
  150. }
  151. /deep/ .u-flex {
  152. background: #fff !important;
  153. }
  154. </style>