普兆健康管家前端代码仓库
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.

371 lines
9.5 KiB

  1. <template>
  2. <view class="page__view">
  3. <navbar title="申请售后" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="#F3F2F7" />
  4. <view class="main">
  5. <view v-if="form.type != 2">
  6. <view class="product" v-for="item in applyServiceProduct" :key="item.id">
  7. <productCard :data="item" ></productCard>
  8. </view>
  9. </view>
  10. <uv-form
  11. ref="form"
  12. :model="form"
  13. :rules="rules"
  14. errorType="toast"
  15. >
  16. <view class="card info">
  17. <view class="card-header">申请信息</view>
  18. <!-- 其他 -->
  19. <template v-if="form.type == 2">
  20. <view class="form-item">
  21. <uv-form-item prop="remark" :customStyle="formItemStyle">
  22. <view class="form-item-label">备注</view>
  23. <view class="form-item-content">
  24. <formTextarea v-model="form.remark" height="436rpx"></formTextarea>
  25. </view>
  26. </uv-form-item>
  27. </view>
  28. </template>
  29. <!-- 退货退款, 换货 -->
  30. <template v-else>
  31. <view class="form-item">
  32. <uv-form-item prop="type" :customStyle="formItemStyle">
  33. <view class="form-item-label light">申请类型</view>
  34. <view class="form-item-content input type">
  35. {{ typeDesc }}
  36. </view>
  37. </uv-form-item>
  38. </view>
  39. <view class="form-item">
  40. <uv-form-item prop="reason" :customStyle="formItemStyle">
  41. <view class="form-item-label">申请原因</view>
  42. <view class="form-item-content input">
  43. <formInput v-model="form.reason" placeholder="请输入内容"></formInput>
  44. </view>
  45. </uv-form-item>
  46. </view>
  47. <view class="form-item">
  48. <uv-form-item prop="num" :customStyle="formItemStyle">
  49. <view class="flex row">
  50. <view class="form-item-label">退货数量</view>
  51. <view class="form-item-content count">
  52. <uv-number-box
  53. v-model="form.num"
  54. bgColor="transparent"
  55. :iconStyle="{
  56. background: '#FFFFFF',
  57. fontSize: '20rpx',
  58. lineHeight: 1,
  59. padding: '9px',
  60. borderRadius: '50%',
  61. }"
  62. ></uv-number-box>
  63. </view>
  64. </view>
  65. </uv-form-item>
  66. </view>
  67. <view class="form-item">
  68. <uv-form-item prop="price" :customStyle="formItemStyle">
  69. <view class="form-item-label">申请金额</view>
  70. <view class="form-item-content input">
  71. <formInput v-model="form.price" placeholder="请输入内容" type="number"></formInput>
  72. </view>
  73. </uv-form-item>
  74. </view>
  75. </template>
  76. <view class="form-item">
  77. <uv-form-item prop="images" :customStyle="formItemStyle">
  78. <view class="form-item-label">上传图片/视频选填</view>
  79. <view class="form-item-content upload">
  80. <formUpload v-model="form.images"></formUpload>
  81. </view>
  82. </uv-form-item>
  83. </view>
  84. </view>
  85. <view class="card phone">
  86. <view class="form-item">
  87. <uv-form-item prop="phone" :customStyle="formItemStyle">
  88. <view class="flex row">
  89. <view class="form-item-label">联系电话</view>
  90. <view class="form-item-content">
  91. <formInput v-model="form.phone" inputAlign="right"></formInput>
  92. </view>
  93. </view>
  94. </uv-form-item>
  95. </view>
  96. </view>
  97. </uv-form>
  98. </view>
  99. <view class="bottom">
  100. <button class="btn" @click="onSubmit">提交申请</button>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. import { mapState } from 'vuex'
  106. import productCard from './productCard.vue'
  107. import formInput from '@/pages_order/components/formInput.vue'
  108. import formTextarea from '@/pages_order/components/formTextarea.vue'
  109. import formUpload from '@/pages_order/components/formUpload.vue'
  110. export default {
  111. components: {
  112. productCard,
  113. formInput,
  114. formTextarea,
  115. formUpload,
  116. },
  117. data() {
  118. return {
  119. id: null,
  120. typeOptions: [
  121. {
  122. id: '001',
  123. label: '退货退款',
  124. value: 0,
  125. },
  126. {
  127. id: '002',
  128. label: '换货',
  129. value: 1,
  130. },
  131. {
  132. id: '003',
  133. label: '其他',
  134. value: 2,
  135. },
  136. ],
  137. form: {
  138. type: null,
  139. reason: null,
  140. num: 1,
  141. price: null,
  142. images: [],
  143. phone: null,
  144. remark: null,
  145. },
  146. rules: {
  147. 'reason': {
  148. type: 'string',
  149. required: true,
  150. message: '请输入申请原因',
  151. },
  152. 'num': {
  153. type: 'number',
  154. required: true,
  155. message: '请输入退货数量',
  156. },
  157. 'amount': {
  158. type: 'number',
  159. required: true,
  160. message: '请输入申请金额(元)',
  161. },
  162. 'phone': {
  163. type: 'string',
  164. required: true,
  165. message: '联系电话',
  166. },
  167. 'remark': {
  168. type: 'string',
  169. required: true,
  170. message: '请输入备注',
  171. },
  172. },
  173. formItemStyle: { padding: 0 },
  174. }
  175. },
  176. computed: {
  177. ...mapState(['configList', 'userInfo', 'applyServiceProduct']),
  178. typeDesc() {
  179. const type = this.form.type
  180. return this.typeOptions.find(item => item.value === type)?.label
  181. },
  182. },
  183. onLoad(arg) {
  184. const { id, type } = arg
  185. this.id = id
  186. this.form.num = this.applyServiceProduct.length
  187. this.form.type = this.typeOptions.find(item => item.value == type)?.value
  188. },
  189. methods: {
  190. async onSubmit() {
  191. try {
  192. await this.$refs.form.validate()
  193. const {
  194. type,
  195. reason,
  196. num,
  197. price,
  198. images,
  199. phone,
  200. remark,
  201. } = this.form
  202. let params = {
  203. orderId: this.id,
  204. productId: this.applyServiceProduct.map(item => item.productId).join(','),
  205. type,
  206. }
  207. if (type == 2) { // 其他
  208. params.remark = remark
  209. } else { // 退货退款, 换货
  210. params.reason = reason
  211. params.num = num
  212. params.price = price
  213. params.image = images.join(',')
  214. params.phone = phone
  215. }
  216. await this.$fetch('afterSaleOrder', params)
  217. uni.showToast({
  218. icon: 'success',
  219. title: '提交成功',
  220. });
  221. setTimeout(() => {
  222. this.$utils.navigateBack()
  223. }, 800)
  224. } catch (err) {
  225. console.log('onSubmit err', err)
  226. }
  227. },
  228. },
  229. }
  230. </script>
  231. <style scoped lang="scss">
  232. .page__view {
  233. width: 100vw;
  234. min-height: 100vh;
  235. background-color: $uni-bg-color;
  236. position: relative;
  237. /deep/ .nav-bar__view {
  238. position: fixed;
  239. top: 0;
  240. left: 0;
  241. }
  242. }
  243. .main {
  244. padding: calc(var(--status-bar-height) + 144rpx) 32rpx 242rpx 32rpx;
  245. }
  246. .product {
  247. & + & {
  248. margin-top: 32rpx;
  249. }
  250. }
  251. .card {
  252. margin-top: 40rpx;
  253. padding: 32rpx;
  254. background: #FAFAFF;
  255. border: 2rpx solid #FFFFFF;
  256. border-radius: 32rpx;
  257. &-header {
  258. font-family: PingFang SC;
  259. font-weight: 500;
  260. font-size: 36rpx;
  261. line-height: 1.4;
  262. color: #252545;
  263. margin-bottom: 32rpx;
  264. }
  265. &.phone {
  266. padding-top: 28rpx;
  267. padding-bottom: 28rpx;
  268. }
  269. }
  270. .form {
  271. &-item {
  272. border-bottom: 2rpx solid #EEEEEE;
  273. &:last-child {
  274. border: none;
  275. }
  276. & + & {
  277. margin-top: 32rpx;
  278. }
  279. &-label {
  280. padding: 8rpx 0;
  281. font-family: PingFang SC;
  282. font-weight: 400;
  283. font-size: 26rpx;
  284. line-height: 1.4;
  285. color: #181818;
  286. &.light {
  287. color: #8B8B8B;
  288. }
  289. }
  290. &-content {
  291. &.input {
  292. padding: 6rpx 0;
  293. }
  294. &.upload,
  295. &.count {
  296. padding: 8rpx 0;
  297. }
  298. }
  299. .type {
  300. font-family: PingFang SC;
  301. font-weight: 400;
  302. font-size: 32rpx;
  303. line-height: 1.4;
  304. color: #393939;
  305. }
  306. }
  307. }
  308. .row {
  309. justify-content: space-between;
  310. }
  311. .bottom {
  312. position: fixed;
  313. left: 0;
  314. bottom: 0;
  315. z-index: 2;
  316. width: 100vw;
  317. // height: 200rpx;
  318. padding: 24rpx 40rpx;
  319. padding-bottom: calc(env(safe-area-inset-bottom) + 24rpx);
  320. background: #FFFFFF;
  321. box-sizing: border-box;
  322. .btn {
  323. width: 100%;
  324. padding: 16rpx 0;
  325. box-sizing: border-box;
  326. font-family: PingFang SC;
  327. font-weight: 500;
  328. font-size: 36rpx;
  329. line-height: 1;
  330. color: #FFFFFF;
  331. background-image: linear-gradient(to right, #4B348F, #845CFA);
  332. border-radius: 41rpx;
  333. }
  334. }
  335. </style>