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

216 lines
4.7 KiB

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