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

337 lines
8.6 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" />
  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" />
  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" />
  28. <view class="delete-icon" @tap="deleteImage(index)">
  29. <uv-icon name="close" color="#fff" size="24rpx" />
  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" />
  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" />
  43. <text>联系方式</text>
  44. </view>
  45. <view class="contact-info">
  46. <input class="contact-tip" placeholder="留下联系方式,方便我们向您回复" v-model="contactInfo" placeholder-style="color: #999;" />
  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: '', // 默认联系方式,实际应该从用户信息中获取
  68. orderDetail: null,
  69. idObject:{}
  70. }
  71. },
  72. onLoad(options) {
  73. if (options.id) {
  74. this.orderId = options.id
  75. // 获取订单详情
  76. this.getOrderDetail(options.id)
  77. }
  78. },
  79. methods: {
  80. // 返回上一页
  81. navigateBack() {
  82. uni.navigateBack()
  83. },
  84. // // 获取订单详情
  85. // getOrderDetail(id) {
  86. // // 从上一页获取订单信息
  87. // const pages = getCurrentPages()
  88. // const prevPage = pages[pages.length - 2]
  89. // if (prevPage && prevPage.route.includes('order')) {
  90. // // 查找匹配ID的订单
  91. // const foundOrder = prevPage.$vm.orderList.find(order => order.id === id)
  92. // if (foundOrder) {
  93. // this.orderDetail = foundOrder
  94. // }
  95. // }
  96. // },
  97. // 选择图片
  98. chooseImage() {
  99. // uni.chooseImage({
  100. // count: 9 - this.uploadedImages.length,
  101. // sizeType: ['compressed'], // 压缩图
  102. // sourceType: ['album', 'camera'], // 相册和相机
  103. // success: (res) => {
  104. // console.log('图片上传',res);
  105. // 预览图片
  106. // this.uploadedImages = [...this.uploadedImages, ...res.tempFilePaths]
  107. this.$Oss.ossUploadImage({
  108. key: '', // 不传则自动生成
  109. folder: '', // 不传则使用日期作为文件夹
  110. compressed: true,
  111. success: (url) => {
  112. this.uploadedImages.push(url)
  113. },
  114. fail: (err) => {
  115. uni.showToast({
  116. title: `上传失败${err}`,
  117. icon: 'error'
  118. })
  119. }
  120. })
  121. // }
  122. // })
  123. },
  124. // 删除图片
  125. deleteImage(index) {
  126. this.uploadedImages.splice(index, 1)
  127. },
  128. // 提交售后申请
  129. submitAfterSale() {
  130. // 表单验证
  131. if (!this.problemDescription.trim()) {
  132. uni.showToast({
  133. title: '请描述您的问题',
  134. icon: 'error'
  135. })
  136. return
  137. }
  138. // 显示提交中提示
  139. uni.showLoading({
  140. title: '正在提交...'
  141. })
  142. this.$api('addAfterService', {
  143. ...this.idObject,
  144. phone: this.contactInfo,
  145. content: this.problemDescription,
  146. images: this.uploadedImages
  147. }, res => {
  148. uni.hideLoading()
  149. if (res.code == 200) {
  150. uni.showModal({
  151. title: '提交成功',
  152. content: '您的售后申请已提交,请等待审核',
  153. confirmColor: '#019245',
  154. showCancel: false,
  155. success: () => {
  156. uni.navigateBack()
  157. }
  158. })
  159. } else {
  160. uni.showToast({
  161. title: res.msg,
  162. icon: 'error'
  163. })
  164. }
  165. })
  166. },
  167. },
  168. onLoad(arg) {
  169. if (arg.orderId && arg.userId && arg.id){
  170. this.idObject = {
  171. ...arg
  172. }
  173. }else {
  174. uni.showToast({
  175. title: '数据不足',
  176. icon: 'error'
  177. })
  178. this.$util.navigateBack()
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .page {
  185. background-color: #f5f5f5;
  186. min-height: 100vh;
  187. padding-bottom: 150rpx;
  188. }
  189. .after-sale-form {
  190. margin: 20rpx;
  191. }
  192. .form-section {
  193. // background-color: #fff;
  194. border-radius: 10rpx;
  195. padding: 30rpx;
  196. margin-bottom: 20rpx;
  197. .section-title {
  198. display: flex;
  199. align-items: center;
  200. margin-bottom: 30rpx;
  201. .title-indicator {
  202. width: 8rpx;
  203. height: 30rpx;
  204. background-color: #019245;
  205. border-radius: 4rpx;
  206. margin-right: 16rpx;
  207. }
  208. text {
  209. font-size: 30rpx;
  210. font-weight: 500;
  211. }
  212. }
  213. }
  214. .text-area-container {
  215. background-color: #fff;
  216. border-radius: 8rpx;
  217. .problem-textarea {
  218. width: 100%;
  219. height: 200rpx;
  220. font-size: 28rpx;
  221. padding: 20rpx;
  222. }
  223. }
  224. .upload-area {
  225. background-color: #fff;
  226. padding: 30rpx;
  227. .image-grid {
  228. display: flex;
  229. flex-wrap: wrap;
  230. gap: 30rpx;
  231. }
  232. .image-item {
  233. width: 160rpx;
  234. height: 160rpx;
  235. position: relative;
  236. .preview-image {
  237. width: 100%;
  238. height: 100%;
  239. border-radius: 8rpx;
  240. }
  241. .delete-icon {
  242. position: absolute;
  243. top: -20rpx;
  244. right: -20rpx;
  245. width: 40rpx;
  246. height: 40rpx;
  247. background-color: rgba(0,0,0,0.6);
  248. border-radius: 50%;
  249. display: flex;
  250. align-items: center;
  251. justify-content: center;
  252. }
  253. }
  254. .upload-button {
  255. width: 160rpx;
  256. height: 160rpx;
  257. color: $uni-color;
  258. border: 4rpx dashed $uni-color;
  259. border-radius: 8rpx;
  260. display: flex;
  261. flex-direction: column;
  262. align-items: center;
  263. justify-content: center;
  264. // margin-right: 20rpx;
  265. // margin-bottom: 20rpx;
  266. font-size: 24rpx;
  267. gap: 10rpx;
  268. }
  269. }
  270. .contact-info {
  271. background-color: #fff;
  272. border-radius: 8rpx;
  273. padding: 30rpx;
  274. .contact-tip {
  275. font-size: 26rpx;
  276. color: #999;
  277. color: black ;
  278. // margin-bottom: 10rpx;
  279. display: block;
  280. }
  281. .contact-placeholder {
  282. color: #999;
  283. }
  284. .contact-value {
  285. font-size: 28rpx;
  286. color: #333;
  287. }
  288. }
  289. .submit-button {
  290. position: fixed;
  291. bottom: 30rpx;
  292. left: 50%;
  293. transform: translateX(-50%);
  294. width: 90%;
  295. height: 90rpx;
  296. background-color: #019245;
  297. color: #fff;
  298. font-size: 32rpx;
  299. border-radius: 45rpx;
  300. display: flex;
  301. align-items: center;
  302. justify-content: center;
  303. }
  304. </style>