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

348 lines
8.9 KiB

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