鸿宇研学生前端代码
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.

193 lines
4.1 KiB

  1. <template>
  2. <view class="card">
  3. <view class="flex top">
  4. <view>
  5. <uv-checkbox
  6. size="36rpx"
  7. icon-size="36rpx"
  8. activeColor="#00A9FF"
  9. :name="data.id"
  10. ></uv-checkbox>
  11. </view>
  12. <view class="info">
  13. <view class="flex name">
  14. <view>{{ data.name }}</view>
  15. <!-- todo: transform periodId to desc -->
  16. <view :class="['tag', `tag-${data.type}`]">{{ typeDesc }}</view>
  17. </view>
  18. <view class="id">{{ data.cerNo }}</view>
  19. </view>
  20. </view>
  21. <view class="flex bottom">
  22. <view class="flex col">
  23. <view>
  24. <uv-checkbox-group
  25. v-model="defaultCheckboxValue"
  26. @change="onDefaultChange"
  27. >
  28. <uv-checkbox
  29. size="36rpx"
  30. icon-size="36rpx"
  31. activeColor="#00A9FF"
  32. :name="1"
  33. ></uv-checkbox>
  34. </uv-checkbox-group>
  35. </view>
  36. <view>默认出行人</view>
  37. </view>
  38. <button class="flex col btn" @click="onEdit">
  39. <image class="icon" src="@/pages_order/static/traveler/icon-edit.png" mode="scaleToFill"></image>
  40. <view>编辑</view>
  41. </button>
  42. <button class="flex col btn" @click="onDelete">
  43. <image class="icon" src="@/pages_order/static/traveler/icon-delete.png" mode="scaleToFill"></image>
  44. <view>删除</view>
  45. </button>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. const MEMBER_TYPE_AND_DESC_MAPPING = {
  51. 0: '成人',
  52. 1: '青少年',
  53. 2: '儿童',
  54. }
  55. export default {
  56. props: {
  57. data: {
  58. type: Object,
  59. default() {
  60. return {}
  61. }
  62. },
  63. },
  64. data() {
  65. return {
  66. defaultCheckboxValue: [],
  67. }
  68. },
  69. computed: {
  70. isDefault: {
  71. set(val) {
  72. this.defaultCheckboxValue = val ? [1]: []
  73. if (this.data.isDefault == val) {
  74. return
  75. }
  76. this.$emit('defaultChange', val)
  77. },
  78. get() {
  79. return this.defaultCheckboxValue.length ? true : false
  80. }
  81. },
  82. typeDesc() {
  83. return MEMBER_TYPE_AND_DESC_MAPPING[this.data.type]
  84. },
  85. },
  86. watch: {
  87. data: {
  88. handler(val) {
  89. this.isDefault = val.isDefault
  90. },
  91. immediate: true,
  92. deep: true,
  93. }
  94. },
  95. methods: {
  96. onDefaultChange(val) {
  97. this.isDefault = val.length ? true : false
  98. },
  99. onEdit() {
  100. // todo
  101. this.$emit('edit')
  102. },
  103. onDelete() {
  104. uni.showModal({
  105. title: '确认删除?',
  106. success : e => {
  107. if(e.confirm){
  108. // todo
  109. this.$emit('delete')
  110. }
  111. }
  112. })
  113. },
  114. }
  115. }
  116. </script>
  117. <style scoped lang="scss">
  118. .card {
  119. padding: 24rpx 32rpx;
  120. background: #FFFFFF;
  121. border-radius: 24rpx;
  122. .top {
  123. padding-bottom: 24rpx;
  124. justify-content: flex-start;
  125. column-gap: 24rpx;
  126. .info {
  127. .name {
  128. justify-content: flex-start;
  129. column-gap: 24rpx;
  130. font-size: 32rpx;
  131. color: #181818;
  132. .tag {
  133. padding: 2rpx 14rpx;
  134. font-size: 24rpx;
  135. color: #00A9FF;
  136. background: #E9F8FF;
  137. border: 2rpx solid #00A9FF;
  138. border-radius: 8rpx;
  139. &-1 {
  140. color: #03C25C;
  141. background: #E9FFF5;
  142. border-color: #03C25C;
  143. }
  144. &-2 {
  145. color: #EE6E05;
  146. background: #FFEFE9;
  147. border-color: #EE6E05;
  148. }
  149. }
  150. }
  151. .id {
  152. margin-top: 8rpx;
  153. font-size: 28rpx;
  154. color: #9B9B9B;
  155. }
  156. }
  157. }
  158. .bottom {
  159. padding-top: 24rpx;
  160. column-gap: 24rpx;
  161. border-top: 2rpx dashed #DADADA;
  162. .col {
  163. flex: 1;
  164. column-gap: 8rpx;
  165. font-family: PingFang SC;
  166. font-weight: 400;
  167. font-size: 24rpx;
  168. line-height: 1.4;
  169. color: #9B9B9B;
  170. .icon {
  171. width: 36rpx;
  172. height: 36rpx;
  173. }
  174. }
  175. }
  176. }
  177. </style>