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

268 lines
6.0 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="productList" :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 productList" :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. productList: [],
  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. productList: [],
  84. },
  85. rules: {
  86. 'type': {
  87. type: 'number',
  88. required: true,
  89. message: '请选择售后类型',
  90. },
  91. 'productList': {
  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. productList,
  105. } = data
  106. this.id = id
  107. this.productList = productList.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.productList[index].selected = selected
  119. this.form.productList = this.productList.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. productList,
  128. } = this.form
  129. // todo: submit
  130. this.$store.commit('setApplyServiceProduct', productList)
  131. this.$utils.navigateTo(`/pages_order/applyService/index?id=${this.id}&type=${type}`)
  132. this.close()
  133. } catch (err) {
  134. console.log('onNext err', err)
  135. }
  136. },
  137. },
  138. }
  139. </script>
  140. <style scoped lang="scss">
  141. .popup__view {
  142. width: 100vw;
  143. display: flex;
  144. flex-direction: column;
  145. box-sizing: border-box;
  146. background: #FFFFFF;
  147. border-top-left-radius: 32rpx;
  148. border-top-right-radius: 32rpx;
  149. }
  150. .header {
  151. position: relative;
  152. width: 100%;
  153. padding: 24rpx 0;
  154. box-sizing: border-box;
  155. border-bottom: 2rpx solid #EEEEEE;
  156. .title {
  157. font-family: PingFang SC;
  158. font-weight: 500;
  159. font-size: 34rpx;
  160. line-height: 1.4;
  161. color: #181818;
  162. }
  163. .btn {
  164. font-family: PingFang SC;
  165. font-weight: 500;
  166. font-size: 32rpx;
  167. line-height: 1.4;
  168. color: #8B8B8B;
  169. position: absolute;
  170. top: 26rpx;
  171. left: 40rpx;
  172. }
  173. }
  174. .form {
  175. &-item {
  176. & + & {
  177. border-top: 2rpx solid #EEEEEE;
  178. }
  179. &-label {
  180. padding: 24rpx 40rpx;
  181. font-family: PingFang SC;
  182. font-weight: 400;
  183. font-size: 28rpx;
  184. line-height: 1.4;
  185. color: #181818;
  186. }
  187. }
  188. }
  189. .tags {
  190. padding: 12rpx 44rpx 44rpx 44rpx;
  191. column-gap: 24rpx;
  192. .tag {
  193. flex: 1;
  194. padding: 18rpx 0;
  195. font-family: PingFang SC;
  196. font-weight: 400;
  197. font-size: 28rpx;
  198. line-height: 1.4;
  199. color: #181818;
  200. background: #F9F9F9;
  201. border: 2rpx solid #F9F9F9;
  202. border-radius: 16rpx;
  203. box-sizing: border-box;
  204. &.is-active {
  205. color: #7451DE;
  206. background: #F2EEFF;
  207. border-color: #7451DE;
  208. }
  209. }
  210. }
  211. .products {
  212. padding: 0 32rpx;
  213. }
  214. .product {
  215. & + & {
  216. margin-top: 32rpx;
  217. }
  218. }
  219. .footer {
  220. width: 100%;
  221. // todo:check
  222. // height: 214rpx;
  223. padding: 32rpx 40rpx;
  224. box-sizing: border-box;
  225. border-top: 2rpx solid #F1F1F1;
  226. .btn {
  227. width: 100%;
  228. padding: 16rpx 0;
  229. font-family: PingFang SC;
  230. font-weight: 500;
  231. font-size: 36rpx;
  232. line-height: 1.4;
  233. color: #FFFFFF;
  234. background-image: linear-gradient(to right, #4B348F, #845CFA);
  235. border-radius: 41rpx;
  236. }
  237. }
  238. </style>