portrait.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <uni-popup ref="popup" :is-mask-click="true" borderRadius="10px 10px 0 0" background-color="#fff" >
  3. <view class="popup-content">
  4. <view class="popup-content-close">
  5. <view class="icon" @tap="handleClose">
  6. <uni-icons
  7. type="closeempty"
  8. color="#999"
  9. size="20"
  10. />
  11. </view>
  12. </view>
  13. <view class="popup-content-main">
  14. <view class="box">
  15. <!-- 已选中 -->
  16. <view class="chose borderLine">
  17. <view class="choseTitle">已选中关键字:</view>
  18. <view class="tags">
  19. <view
  20. v-for="tag in select"
  21. :key="tag"
  22. class="tag"
  23. style="color: orange; border: 2rpx solid orange;"
  24. @tap="handleCancelSelect(tag)"
  25. >
  26. {{ tag }}
  27. <uni-icons type="clear" size="16" color="#ea8d03"></uni-icons>
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 选择项 -->
  32. <view v-if="showTagList && tagList?.length" class="list">
  33. <uni-collapse v-model="collapseOpen">
  34. <uni-collapse-item
  35. v-for="val in tagList" :key="val.id"
  36. :name="val.id"
  37. :title="val?.nameCn || '--'"
  38. >
  39. <view v-if="val?.children?.length" class="tags">
  40. <view v-for="k in val.children" :key="k.id">
  41. <view v-if="select.includes(k.nameCn)" class="tag" style="color: grey; border: 2rpx solid grey;">
  42. <uni-icons type="plusempty" size="14" color="#00B760"></uni-icons>
  43. {{ k?.nameCn || '--' }}
  44. </view>
  45. <view v-else class="tag" style="color: #00B760; border: 2rpx solid #00B760;" @tap="handleSelect(k.nameCn)">
  46. <uni-icons type="plusempty" size="14" color="#00B760"></uni-icons>
  47. {{ k?.nameCn || '--' }}
  48. </view>
  49. </view>
  50. </view>
  51. </uni-collapse-item>
  52. </uni-collapse>
  53. </view>
  54. <view class="f-horizon-center">
  55. <button type="primary" size="default" class="send-button" @click="submit">提 交</button>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </uni-popup>
  61. </template>
  62. <script setup>
  63. import { ref, computed } from 'vue'
  64. import { getTagTreeDataApi } from '@/api/user'
  65. const emit = defineEmits(['submit'])
  66. const popup = ref()
  67. const handleClose = () => {
  68. popup.value.close()
  69. }
  70. const handleOpen = () => {
  71. popup.value.open('bottom')
  72. }
  73. // 选择
  74. const handleSelect = (nameCn) => {
  75. const result = select.value.includes(nameCn)
  76. if (!result) return select.value.push(nameCn)
  77. else select.value = select.value.filter(e => e !== nameCn)
  78. }
  79. // 删除
  80. const handleCancelSelect = (nameCn) => {
  81. select.value = select.value.filter(e => e !== nameCn)
  82. }
  83. // // 获取基础信息
  84. // function getBaseInfo () {
  85. // const baseInfo = useUserStore.baseInfo
  86. // select.value = baseInfo.tagList && baseInfo.tagList?.length ? baseInfo.tagList : []
  87. // }
  88. // getBaseInfo()
  89. const select = ref([])
  90. const tagList = ref([])
  91. const collapseOpen = ref([])
  92. const showTagList = ref(false)
  93. // 获取标签字典数据
  94. const getTagList = async () => {
  95. showTagList.value = false
  96. const res = await getTagTreeDataApi({ type: 2 })
  97. const data = res?.data?.length ? res.data : []
  98. // collapseOpen.value = data.map(e => e.id)
  99. tagList.value = data
  100. showTagList.value = true
  101. }
  102. getTagList()
  103. // 提交
  104. const submit = () => {
  105. emit('submit', select.value)
  106. handleClose()
  107. }
  108. defineExpose({
  109. handleOpen
  110. })
  111. </script>
  112. <style lang="scss" scoped>
  113. $px: 30rpx;
  114. .borderLine {
  115. border-bottom: 2rpx solid #f5f5f5;
  116. }
  117. .box {
  118. padding: 20rpx $px;
  119. .chose {
  120. margin-bottom: $px;
  121. .choseTitle {
  122. margin-bottom: $px;
  123. }
  124. }
  125. .tags {
  126. padding: $px 0;
  127. display: flex;
  128. flex-wrap: wrap;
  129. .tag {
  130. margin: 0 15rpx 12rpx 0;
  131. border: 2rpx 15rpx #00B760;
  132. color: #00B760;
  133. white-space: nowrap;
  134. padding: 4rpx 10rpx;
  135. border-radius: 10rpx;
  136. font-size: 24rpx;
  137. }
  138. }
  139. }
  140. .popup-content {
  141. z-index: 999;
  142. max-height: 500px;
  143. display: flex;
  144. flex-direction: column;
  145. &-close {
  146. display: flex;
  147. padding: 10px;
  148. justify-content: flex-end;
  149. .icon {
  150. width: 30px;
  151. height: 30px;
  152. background: #ccc;
  153. border-radius: 30px;
  154. display: flex;
  155. align-items: center;
  156. justify-content: center;
  157. }
  158. }
  159. &-main {
  160. flex: 1;
  161. height: 0;
  162. overflow-y: auto;
  163. &-count {
  164. margin-bottom: 20px;
  165. text-align: center;
  166. .title {
  167. font-size: 28rpx;
  168. color: #666
  169. }
  170. .pay {
  171. font-size: 52rpx;
  172. color: #000;
  173. font-weight: 600;
  174. display: flex;
  175. align-items: center;
  176. justify-content: center;
  177. padding: 10px 0;
  178. }
  179. }
  180. &-type {
  181. width: 100%;
  182. padding: 0 20px;
  183. box-sizing: border-box;
  184. .card {
  185. border-radius: 10px;
  186. margin: 0 auto;
  187. background: #FFF;
  188. padding: 10px;
  189. &-label {
  190. padding: 15px 0;
  191. box-sizing: border-box;
  192. display: flex;
  193. justify-content: space-between;
  194. border-bottom: 1px solid #eee;
  195. &:last-of-type {
  196. border-bottom: none;
  197. }
  198. .name {
  199. display: flex;
  200. align-items: center;
  201. color: #333;
  202. }
  203. }
  204. }
  205. }
  206. }
  207. &-btn {
  208. height: 70px;
  209. width: 100%;
  210. margin-top: 10px;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. &-s {
  215. height: 40px;
  216. width: 75%;
  217. line-height: 40px;
  218. color: #FFF;
  219. // color: #724d2b;
  220. background: #00B760;
  221. // background: linear-gradient(121deg,#fde2c2 29.02%,#c19164 104.03%);
  222. border-radius: 90px;
  223. }
  224. }
  225. }
  226. </style>