labels.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="container">
  3. <TopBar id="topbar" :icon="'back'"></TopBar>
  4. <view class="title font44 fw600" id='title'>
  5. 选择你{{type==='wants'?'喜欢':'个性'}}标签
  6. </view>
  7. <view class="tip font28 fw400" id="tip">
  8. {{type==='wants'?'添加你喜欢的特质,让推荐更加精准':'增加自己的的个性标签,让大家更了解你'}}
  9. </view>
  10. <view class="choose-list flex-start" id="chooselist">
  11. <view class="choose-tag flex-center" v-for="(item,index) in chooseLabels" :key="index">
  12. <text class="tag-text font28 fw600">{{item.name}}</text>
  13. <image :src="`${assetsUrl}info-figure-close.png`" mode="aspectFill" class="tag-img" @click="deleteTag(index)"></image>
  14. </view>
  15. </view>
  16. <scroll-view scroll-y="true" class="citys" :style="{'height':`${scollHeight}px`}">
  17. <view class="city-tags" v-for="(item,index) in labelsList" :key="index">
  18. <view class="c-label font28 fw700">
  19. {{item.name}}
  20. </view>
  21. <view class="c-tags flex-start">
  22. <view class="c-tag font28 fw400" :class="sitem.choose?'tag-choose':''" v-for="(sitem,sindex) in item.list" :key="sindex" @click="chooseTag(index,sindex)">
  23. {{sitem.name}}
  24. </view>
  25. </view>
  26. </view>
  27. </scroll-view>
  28. <cover-view class="btn font32 fw600" @click="sure">
  29. 完成
  30. </cover-view>
  31. </view>
  32. </template>
  33. <script>
  34. import TopBar from '@/components/TopBar/TopBar.vue';
  35. export default {
  36. components:{TopBar},
  37. data() {
  38. return {
  39. assetsUrl:this.$util.assetsUrl,
  40. chooseLabels:[],
  41. labelsList:[],
  42. scollHeight:0,
  43. type:''
  44. };
  45. },
  46. onLoad(option) {
  47. let pages = getCurrentPages();
  48. let prevPage = pages[pages.length - 2];
  49. console.log(option)
  50. if(option.type&&option.type==='wants'){
  51. this.type=option.type;
  52. this.chooseLabels=prevPage.$vm.myWants;
  53. }
  54. else if(option.type&&option.type==='labels'){
  55. this.type=option.type;
  56. this.chooseLabels=prevPage.$vm.myLabels;
  57. }
  58. this.computedScollviewHeight();
  59. this.getLabels();
  60. },
  61. methods:{
  62. computedScollviewHeight(){
  63. let query = uni.createSelectorQuery();
  64. let heightLeaf=0;
  65. let str='#topbar,#title,#tip,#chooselist'
  66. query.selectAll(str).boundingClientRect(data => {
  67. data.forEach(item=>{
  68. heightLeaf+=item.height;
  69. })
  70. }).exec(()=>{
  71. let sysInfo=uni.getSystemInfoSync();
  72. this.scollHeight=sysInfo.windowHeight-heightLeaf-145;
  73. console.log(this.scollHeight)
  74. });
  75. },
  76. sure(){
  77. let pages = getCurrentPages();
  78. let prevPage = pages[pages.length - 2];
  79. let arr=[],ids=[];
  80. for(let i=0;i<this.chooseLabels.length;i++){
  81. arr.push(this.chooseLabels[i]);
  82. ids.push(`${this.chooseLabels[i].id}`);
  83. }
  84. console.log(ids)
  85. if(this.type==="wants"){
  86. prevPage.$vm.myWants=arr;
  87. prevPage.$vm.saveOptions.wantedLabelIds=ids;
  88. }
  89. else{
  90. prevPage.$vm.myLabels=arr;
  91. prevPage.$vm.saveOptions.myLabelIds=ids;
  92. }
  93. uni.navigateBack({
  94. delta:1
  95. })
  96. },
  97. deleteTag(index){
  98. this.chooseLabels.splice(index,1);
  99. setTimeout(()=>{
  100. this.computedScollviewHeight();
  101. },10)
  102. },
  103. chooseTag(index,sindex){
  104. this.labelsList[index].list[sindex].choose=!this.labelsList[index].list[sindex].choose;
  105. if(this.labelsList[index].list[sindex].choose&&!this.chooseLabels.includes({name:this.labelsList[index].list[sindex].name,id:this.labelsList[index].list[sindex].id})){
  106. this.chooseLabels.push({name:this.labelsList[index].list[sindex].name,id:this.labelsList[index].list[sindex].id})
  107. }
  108. setTimeout(()=>{
  109. this.computedScollviewHeight();
  110. },10)
  111. setTimeout(()=>{
  112. this.labelsList[index].list[sindex].choose=false;
  113. },500)
  114. },
  115. getLabels(){
  116. this.$api.login.labelsConfig({
  117. isSpLabel:this.type==='labels'?true:false,
  118. pageNum:1,
  119. pageSize:20,
  120. //type:['Looks','Character','Trait','Hobby']
  121. }).then(res=>{
  122. this.labelsList=res.data;
  123. }).catch(err=>{
  124. console.log(err)
  125. })
  126. },
  127. bindClick(e){
  128. console.log(e)
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .container{
  135. width: 100vw;
  136. min-height: 100vh;
  137. background-color: $bgcolor1;
  138. .line-bar{
  139. margin: 0 60rpx;
  140. margin-top: 30rpx;
  141. .span{
  142. width: 120rpx;
  143. height: 8rpx;
  144. border-radius: 4rpx 0rpx 0rpx 4rpx;
  145. background-color: $bgcolor4;
  146. }
  147. .active{
  148. background-color: $primary;
  149. }
  150. }
  151. .title{
  152. color: $fontcolor5;
  153. padding-left: 60rpx;
  154. margin-top: 108rpx;
  155. }
  156. .tip{
  157. color: $fontcolor3;
  158. padding-left: 60rpx;
  159. margin-top: 8rpx;
  160. }
  161. .choose-list{
  162. padding: 72rpx 60rpx 8rpx 60rpx;
  163. flex-wrap: wrap;
  164. .choose-tag{
  165. background-color: $bgcolor4;
  166. border-radius: 38rpx;
  167. padding: 0 20rpx;
  168. height: 72rpx;
  169. margin-right: 32rpx;
  170. margin-bottom: 32rpx;
  171. .tag-text{
  172. color: $fontcolor4;
  173. text-align: center;
  174. line-height: 72rpx;
  175. }
  176. .tag-img{
  177. width: 24rpx;
  178. height: 24rpx;
  179. padding-left: 16rpx;
  180. }
  181. }
  182. }
  183. .citys{
  184. height: 700rpx;
  185. padding: 0 60rpx;
  186. box-sizing: border-box;
  187. .city-tags{
  188. .c-label{
  189. color: $fontcolor3;
  190. margin-bottom: 24rpx;
  191. margin-top: 16rpx;
  192. }
  193. .c-tags{
  194. flex-wrap: wrap;
  195. .c-tag{
  196. background-color: $bgcolor3;
  197. color: $fontcolor3;
  198. padding: 0 20rpx;
  199. height: 72rpx;
  200. line-height: 72rpx;
  201. text-align: center;
  202. border-radius: 38rpx;
  203. margin-right: 24rpx;
  204. margin-bottom: 24rpx;
  205. transition: all .3s;
  206. }
  207. }
  208. .tag-choose{
  209. background: $primary !important;
  210. color: $fontcolor5 !important;
  211. }
  212. }
  213. }
  214. .btn{
  215. position: fixed;
  216. z-index: 999;
  217. left: 0;
  218. right: 0;
  219. bottom: 44rpx;
  220. margin: auto;
  221. width: 630rpx;
  222. height: 104rpx;
  223. border-radius: 52rpx;
  224. background-color: $primary;
  225. color: $fontcolor5;
  226. text-align: center;
  227. line-height: 104rpx;
  228. }
  229. }
  230. </style>