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

270 lines
6.2 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. // todo: check type value
  65. typeOptions: [
  66. {
  67. id: '001',
  68. label: '退货退款',
  69. value: 0,
  70. },
  71. {
  72. id: '002',
  73. label: '换货',
  74. value: 1,
  75. },
  76. {
  77. id: '003',
  78. label: '其他',
  79. value: 2,
  80. },
  81. ],
  82. form: {
  83. type: null,
  84. // todo: check key
  85. appletOrderProductList: [],
  86. },
  87. rules: {
  88. 'type': {
  89. type: 'number',
  90. required: true,
  91. message: '请选择售后类型',
  92. },
  93. 'appletOrderProductList': {
  94. type: 'array',
  95. required: true,
  96. message: '请选择售后商品',
  97. },
  98. },
  99. formItemStyle: { padding: 0 },
  100. }
  101. },
  102. methods: {
  103. open(data) {
  104. const {
  105. id,
  106. appletOrderProductList,
  107. } = data
  108. this.id = id
  109. this.appletOrderProductList = appletOrderProductList.map(item => ({ ...item, selected: false }))
  110. this.$refs.popup.open()
  111. },
  112. close() {
  113. this.$refs.popup.close()
  114. },
  115. onSelectType(type) {
  116. this.form.type = type
  117. },
  118. onSelectProduct(index, selected) {
  119. console.log('onSelectProduct', index, selected)
  120. this.appletOrderProductList[index].selected = selected
  121. this.form.appletOrderProductList = this.appletOrderProductList.filter(item => item.selected)
  122. },
  123. async onNext() {
  124. try {
  125. const res = await this.$refs.form.validate()
  126. console.log('onNext res', res)
  127. const {
  128. type,
  129. appletOrderProductList,
  130. } = this.form
  131. // todo: submit
  132. this.$store.commit('setApplyServiceProduct', appletOrderProductList)
  133. this.$utils.navigateTo(`/pages_order/applyService/index?id=${this.id}&type=${type}`)
  134. this.close()
  135. } catch (err) {
  136. console.log('onNext err', err)
  137. }
  138. },
  139. },
  140. }
  141. </script>
  142. <style scoped lang="scss">
  143. .popup__view {
  144. width: 100vw;
  145. display: flex;
  146. flex-direction: column;
  147. box-sizing: border-box;
  148. background: #FFFFFF;
  149. border-top-left-radius: 32rpx;
  150. border-top-right-radius: 32rpx;
  151. }
  152. .header {
  153. position: relative;
  154. width: 100%;
  155. padding: 24rpx 0;
  156. box-sizing: border-box;
  157. border-bottom: 2rpx solid #EEEEEE;
  158. .title {
  159. font-family: PingFang SC;
  160. font-weight: 500;
  161. font-size: 34rpx;
  162. line-height: 1.4;
  163. color: #181818;
  164. }
  165. .btn {
  166. font-family: PingFang SC;
  167. font-weight: 500;
  168. font-size: 32rpx;
  169. line-height: 1.4;
  170. color: #8B8B8B;
  171. position: absolute;
  172. top: 26rpx;
  173. left: 40rpx;
  174. }
  175. }
  176. .form {
  177. &-item {
  178. & + & {
  179. border-top: 2rpx solid #EEEEEE;
  180. }
  181. &-label {
  182. padding: 24rpx 40rpx;
  183. font-family: PingFang SC;
  184. font-weight: 400;
  185. font-size: 28rpx;
  186. line-height: 1.4;
  187. color: #181818;
  188. }
  189. }
  190. }
  191. .tags {
  192. padding: 12rpx 44rpx 44rpx 44rpx;
  193. column-gap: 24rpx;
  194. .tag {
  195. flex: 1;
  196. padding: 18rpx 0;
  197. font-family: PingFang SC;
  198. font-weight: 400;
  199. font-size: 28rpx;
  200. line-height: 1.4;
  201. color: #181818;
  202. background: #F9F9F9;
  203. border: 2rpx solid #F9F9F9;
  204. border-radius: 16rpx;
  205. box-sizing: border-box;
  206. &.is-active {
  207. color: #7451DE;
  208. background: #F2EEFF;
  209. border-color: #7451DE;
  210. }
  211. }
  212. }
  213. .products {
  214. padding: 0 32rpx;
  215. }
  216. .product {
  217. & + & {
  218. margin-top: 32rpx;
  219. }
  220. }
  221. .footer {
  222. width: 100%;
  223. // todo:check
  224. // height: 214rpx;
  225. padding: 32rpx 40rpx;
  226. box-sizing: border-box;
  227. border-top: 2rpx solid #F1F1F1;
  228. .btn {
  229. width: 100%;
  230. padding: 16rpx 0;
  231. font-family: PingFang SC;
  232. font-weight: 500;
  233. font-size: 36rpx;
  234. line-height: 1.4;
  235. color: #FFFFFF;
  236. background-image: linear-gradient(to right, #4B348F, #845CFA);
  237. border-radius: 41rpx;
  238. }
  239. }
  240. </style>