敢为人鲜小程序前端代码仓库
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.

295 lines
7.5 KiB

  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="订单售后" leftClick @leftClick="navigateBack" bgColor="#019245" color="#fff" />
  5. <!-- 售后表单 -->
  6. <view class="after-sale-form">
  7. <!-- 问题描述区域 -->
  8. <view class="form-section">
  9. <view class="section-title">
  10. <view class="title-indicator"></view>
  11. <text>请描述具体问题</text>
  12. </view>
  13. <view class="text-area-container">
  14. <textarea class="problem-textarea" v-model="problemDescription" placeholder="请在此输入详细问题或意见"
  15. placeholder-style="color: #999; font-size: 28rpx;" maxlength="500" />
  16. </view>
  17. </view>
  18. <!-- 图片上传区域 -->
  19. <view class="form-section">
  20. <view class="section-title">
  21. <view class="title-indicator"></view>
  22. <text>请提供相关问题的截图或图片</text>
  23. </view>
  24. <view class="upload-area">
  25. <view class="image-grid">
  26. <view class="image-item" v-for="(image, index) in uploadedImages" :key="'img-'+index">
  27. <image :src="image" mode="aspectFill" class="preview-image"></image>
  28. <view class="delete-icon" @tap="deleteImage(index)">
  29. <uv-icon name="close" color="#fff" size="24rpx"></uv-icon>
  30. </view>
  31. </view>
  32. <view class="upload-button" @tap="chooseImage" v-if="uploadedImages.length < 9">
  33. <uv-icon name="plus" size="60rpx" color="#019245"></uv-icon>
  34. <text>添加图片</text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <!-- 联系方式 -->
  40. <view class="form-section">
  41. <view class="section-title">
  42. <view class="title-indicator"></view>
  43. <text>联系方式</text>
  44. </view>
  45. <view class="contact-info">
  46. <input class="contact-tip" placeholder="留下联系方式,方便我们向您回复" />
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 提交按钮 -->
  51. <view class="submit-button" @tap="submitAfterSale">
  52. 提交
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import navbar from '@/components/base/navbar.vue'
  58. export default {
  59. components: {
  60. navbar
  61. },
  62. data() {
  63. return {
  64. orderId: '',
  65. problemDescription: '',
  66. uploadedImages: [],
  67. contactInfo: '15070023168', // 默认联系方式,实际应该从用户信息中获取
  68. orderDetail: null
  69. }
  70. },
  71. onLoad(options) {
  72. if (options.id) {
  73. this.orderId = options.id
  74. // 获取订单详情
  75. this.getOrderDetail(options.id)
  76. }
  77. },
  78. methods: {
  79. // 返回上一页
  80. navigateBack() {
  81. uni.navigateBack()
  82. },
  83. // 获取订单详情
  84. getOrderDetail(id) {
  85. // 从上一页获取订单信息
  86. const pages = getCurrentPages()
  87. const prevPage = pages[pages.length - 2]
  88. if (prevPage && prevPage.route.includes('order')) {
  89. // 查找匹配ID的订单
  90. const foundOrder = prevPage.$vm.orderList.find(order => order.id === id)
  91. if (foundOrder) {
  92. this.orderDetail = foundOrder
  93. }
  94. }
  95. },
  96. // 选择图片
  97. chooseImage() {
  98. uni.chooseImage({
  99. count: 9 - this.uploadedImages.length,
  100. sizeType: ['compressed'],
  101. sourceType: ['album', 'camera'],
  102. success: (res) => {
  103. // 预览图片
  104. this.uploadedImages = [...this.uploadedImages, ...res.tempFilePaths]
  105. }
  106. })
  107. },
  108. // 删除图片
  109. deleteImage(index) {
  110. this.uploadedImages.splice(index, 1)
  111. },
  112. // 提交售后申请
  113. submitAfterSale() {
  114. // 表单验证
  115. if (!this.problemDescription.trim()) {
  116. uni.showToast({
  117. title: '请描述您的问题',
  118. icon: 'none'
  119. })
  120. return
  121. }
  122. // 显示提交中提示
  123. uni.showLoading({
  124. title: '正在提交...'
  125. })
  126. // 模拟上传图片
  127. setTimeout(() => {
  128. // 模拟表单提交
  129. setTimeout(() => {
  130. uni.hideLoading()
  131. uni.showToast({
  132. title: '提交成功',
  133. icon: 'success',
  134. duration: 2000
  135. })
  136. // 延迟后返回
  137. setTimeout(() => {
  138. this.navigateBack()
  139. }, 1500)
  140. }, 1000)
  141. }, 1000)
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. .page {
  148. background-color: #f5f5f5;
  149. min-height: 100vh;
  150. padding-bottom: 150rpx;
  151. }
  152. .after-sale-form {
  153. margin: 20rpx;
  154. }
  155. .form-section {
  156. // background-color: #fff;
  157. border-radius: 10rpx;
  158. padding: 30rpx;
  159. margin-bottom: 20rpx;
  160. .section-title {
  161. display: flex;
  162. align-items: center;
  163. margin-bottom: 30rpx;
  164. .title-indicator {
  165. width: 8rpx;
  166. height: 30rpx;
  167. background-color: #019245;
  168. border-radius: 4rpx;
  169. margin-right: 16rpx;
  170. }
  171. text {
  172. font-size: 30rpx;
  173. font-weight: 500;
  174. }
  175. }
  176. }
  177. .text-area-container {
  178. background-color: #fff;
  179. border-radius: 8rpx;
  180. .problem-textarea {
  181. width: 100%;
  182. height: 200rpx;
  183. font-size: 28rpx;
  184. padding: 20rpx;
  185. }
  186. }
  187. .upload-area {
  188. background-color: #fff;
  189. padding: 30rpx;
  190. .image-grid {
  191. display: flex;
  192. flex-wrap: wrap;
  193. gap: 30rpx;
  194. }
  195. .image-item {
  196. width: 160rpx;
  197. height: 160rpx;
  198. position: relative;
  199. .preview-image {
  200. width: 100%;
  201. height: 100%;
  202. border-radius: 8rpx;
  203. }
  204. .delete-icon {
  205. position: absolute;
  206. top: -20rpx;
  207. right: -20rpx;
  208. width: 40rpx;
  209. height: 40rpx;
  210. background-color: rgba(0,0,0,0.6);
  211. border-radius: 50%;
  212. display: flex;
  213. align-items: center;
  214. justify-content: center;
  215. }
  216. }
  217. .upload-button {
  218. width: 160rpx;
  219. height: 160rpx;
  220. color: $uni-color;
  221. border: 4rpx dashed $uni-color;
  222. border-radius: 8rpx;
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. justify-content: center;
  227. // margin-right: 20rpx;
  228. // margin-bottom: 20rpx;
  229. font-size: 24rpx;
  230. gap: 10rpx;
  231. }
  232. }
  233. .contact-info {
  234. background-color: #fff;
  235. border-radius: 8rpx;
  236. padding: 30rpx;
  237. .contact-tip {
  238. font-size: 26rpx;
  239. color: #999;
  240. // margin-bottom: 10rpx;
  241. display: block;
  242. }
  243. .contact-value {
  244. font-size: 28rpx;
  245. color: #333;
  246. }
  247. }
  248. .submit-button {
  249. position: fixed;
  250. bottom: 30rpx;
  251. left: 50%;
  252. transform: translateX(-50%);
  253. width: 90%;
  254. height: 90rpx;
  255. background-color: #019245;
  256. color: #fff;
  257. font-size: 32rpx;
  258. border-radius: 45rpx;
  259. display: flex;
  260. align-items: center;
  261. justify-content: center;
  262. }
  263. </style>