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

265 lines
6.1 KiB

  1. <template>
  2. <view>
  3. <uv-popup ref="popup" mode="bottom" bgColor="none" >
  4. <view class="popup__view">
  5. <view class="flex header">
  6. <view class="title">选择售后类型</view>
  7. <button class="btn" @click="close">关闭</button>
  8. </view>
  9. <view class="form">
  10. <uv-form
  11. ref="form"
  12. :model="form"
  13. :rules="rules"
  14. errorType="toast"
  15. >
  16. <view class="form-item">
  17. <uv-form-item prop="type" :customStyle="formItemStyle">
  18. <view class="form-item-label">请选择售后类型</view>
  19. <view class="form-item-content flex tags">
  20. <view
  21. v-for="item in typeOptions"
  22. :key="item.id"
  23. :class="['flex', 'tag', item.value === form.type ? 'is-active' : '']"
  24. @click="onSelectType(item.value)"
  25. >
  26. {{ item.label }}
  27. </view>
  28. </view>
  29. </uv-form-item>
  30. </view>
  31. <view class="form-item">
  32. <uv-form-item prop="appletOrderProductList" :customStyle="formItemStyle">
  33. <view class="form-item-label">选择需要售后的商品</view>
  34. <view class="form-item-content products">
  35. <view class="product" v-for="(item, index) in appletOrderProductList" :key="item.id">
  36. <productCard
  37. mode="edit"
  38. :data="item"
  39. @select="onSelectProduct(index, $event)"
  40. ></productCard>
  41. </view>
  42. </view>
  43. </uv-form-item>
  44. </view>
  45. </uv-form>
  46. </view>
  47. <view class="footer">
  48. <button class="flex btn" @click="onNext">下一步</button>
  49. </view>
  50. </view>
  51. </uv-popup>
  52. </view>
  53. </template>
  54. <script>
  55. import productCard from './productCard.vue'
  56. export default {
  57. components: {
  58. productCard,
  59. },
  60. data() {
  61. return {
  62. id: null,
  63. appletOrderProductList: [],
  64. typeOptions: [
  65. {
  66. id: '001',
  67. label: '退货退款',
  68. value: 0,
  69. },
  70. {
  71. id: '002',
  72. label: '换货',
  73. value: 1,
  74. },
  75. {
  76. id: '003',
  77. label: '其他',
  78. value: 2,
  79. },
  80. ],
  81. form: {
  82. type: null,
  83. appletOrderProductList: [],
  84. },
  85. rules: {
  86. 'type': {
  87. type: 'number',
  88. required: true,
  89. message: '请选择售后类型',
  90. },
  91. 'appletOrderProductList': {
  92. type: 'array',
  93. required: true,
  94. message: '请选择售后商品',
  95. },
  96. },
  97. formItemStyle: { padding: 0 },
  98. }
  99. },
  100. methods: {
  101. open(data) {
  102. const {
  103. id,
  104. appletOrderProductList,
  105. } = data
  106. this.id = id
  107. this.appletOrderProductList = appletOrderProductList.map(item => ({ ...item, selected: false }))
  108. this.$refs.popup.open()
  109. },
  110. close() {
  111. this.$refs.popup.close()
  112. },
  113. onSelectType(type) {
  114. this.form.type = type
  115. },
  116. onSelectProduct(index, selected) {
  117. console.log('onSelectProduct', index, selected)
  118. this.appletOrderProductList[index].selected = selected
  119. this.form.appletOrderProductList = this.appletOrderProductList.filter(item => item.selected)
  120. },
  121. async onNext() {
  122. try {
  123. const res = await this.$refs.form.validate()
  124. console.log('onNext res', res)
  125. const {
  126. type,
  127. appletOrderProductList,
  128. } = this.form
  129. this.$store.commit('setApplyServiceProduct', appletOrderProductList)
  130. this.$utils.navigateTo(`/pages_order/applyService/index?id=${this.id}&type=${type}`)
  131. this.close()
  132. } catch (err) {
  133. console.log('onNext err', err)
  134. }
  135. },
  136. },
  137. }
  138. </script>
  139. <style scoped lang="scss">
  140. .popup__view {
  141. width: 100vw;
  142. display: flex;
  143. flex-direction: column;
  144. box-sizing: border-box;
  145. background: #FFFFFF;
  146. border-top-left-radius: 32rpx;
  147. border-top-right-radius: 32rpx;
  148. }
  149. .header {
  150. position: relative;
  151. width: 100%;
  152. padding: 24rpx 0;
  153. box-sizing: border-box;
  154. border-bottom: 2rpx solid #EEEEEE;
  155. .title {
  156. font-family: PingFang SC;
  157. font-weight: 500;
  158. font-size: 34rpx;
  159. line-height: 1.4;
  160. color: #181818;
  161. }
  162. .btn {
  163. font-family: PingFang SC;
  164. font-weight: 500;
  165. font-size: 32rpx;
  166. line-height: 1.4;
  167. color: #8B8B8B;
  168. position: absolute;
  169. top: 26rpx;
  170. left: 40rpx;
  171. }
  172. }
  173. .form {
  174. &-item {
  175. & + & {
  176. border-top: 2rpx solid #EEEEEE;
  177. }
  178. &-label {
  179. padding: 24rpx 40rpx;
  180. font-family: PingFang SC;
  181. font-weight: 400;
  182. font-size: 28rpx;
  183. line-height: 1.4;
  184. color: #181818;
  185. }
  186. }
  187. }
  188. .tags {
  189. padding: 12rpx 44rpx 44rpx 44rpx;
  190. column-gap: 24rpx;
  191. .tag {
  192. flex: 1;
  193. padding: 18rpx 0;
  194. font-family: PingFang SC;
  195. font-weight: 400;
  196. font-size: 28rpx;
  197. line-height: 1.4;
  198. color: #181818;
  199. background: #F9F9F9;
  200. border: 2rpx solid #F9F9F9;
  201. border-radius: 16rpx;
  202. box-sizing: border-box;
  203. &.is-active {
  204. color: #7451DE;
  205. background: #F2EEFF;
  206. border-color: #7451DE;
  207. }
  208. }
  209. }
  210. .products {
  211. padding: 0 32rpx;
  212. }
  213. .product {
  214. & + & {
  215. margin-top: 32rpx;
  216. }
  217. }
  218. .footer {
  219. width: 100%;
  220. padding: 32rpx 40rpx;
  221. box-sizing: border-box;
  222. border-top: 2rpx solid #F1F1F1;
  223. .btn {
  224. width: 100%;
  225. padding: 16rpx 0;
  226. font-family: PingFang SC;
  227. font-weight: 500;
  228. font-size: 36rpx;
  229. line-height: 1.4;
  230. color: #FFFFFF;
  231. background-image: linear-gradient(to right, #4B348F, #845CFA);
  232. border-radius: 41rpx;
  233. }
  234. }
  235. </style>