xiuxingItem.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view>
  3. <view class="sticky-nav">
  4. <view class="nav-box">
  5. <image src="../../../static/index/answer/trun_left_black.png" class="answer_back" @click="backHome">
  6. </image>
  7. <text class="answer-text">修行项目</text>
  8. </view>
  9. </view>
  10. <view v-for="(item,index) in deleteItems" :key="index" class="home-nav-box">
  11. <image :src="item.imgUrl" class="nav-img"></image>
  12. <view class="nav-name" :class="item.name == '修心日志'||item.name == '日行一善'? 'right-distance':' '">{{item.name}}
  13. </view>
  14. <view class="nav-status" @tap="addItem(item,index)">添加</view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. items: [],
  23. deleteItems:[]
  24. }
  25. },
  26. onLoad(option) {
  27. this.deleteItems = JSON.parse(option.deleteItems);
  28. this.items = JSON.parse(option.items);
  29. console.log(this.items.length);
  30. for (let i = 0; i < this.deleteItems.length; i++) {
  31. this.deleteItems[i].imgUrl = "../" + this.deleteItems[i].imgUrl;
  32. }
  33. },
  34. methods: {
  35. backHome() {
  36. uni.navigateBack({
  37. delta: 1
  38. });
  39. },
  40. addItem(item,index) {
  41. //删除此项,添加到首页的数组里并跳转到首页
  42. this.deleteItems.splice(index,1);
  43. console.log("deleteLength:"+this.deleteItems.length);
  44. //获取此项目的index
  45. let itemIndex = item.index;
  46. //处理图片路径
  47. item.imgUrl = item.imgUrl.substring(3);
  48. //添加此项到首页
  49. this.items.splice(itemIndex,1,item);
  50. this.items = [...new Set(this.items)];
  51. uni.setStorageSync('items', this.items);
  52. //跳转到首页
  53. uni.switchTab({
  54. url: '/pages/index/index'
  55. });
  56. }
  57. }
  58. }
  59. </script>
  60. <style>
  61. page {
  62. background-color: rgb(247, 246, 242);
  63. }
  64. </style>
  65. <style lang="less" scoped>
  66. .sticky-nav {
  67. position: sticky;
  68. width: 100%;
  69. top: 0;
  70. z-index: 1;
  71. }
  72. .nav-box {
  73. width: 100%;
  74. display: flex;
  75. align-items: center;
  76. background: #fff;
  77. height: 95rpx;
  78. .answer_back {
  79. width: 45rpx;
  80. height: 45rpx;
  81. padding-left: 20rpx;
  82. padding-right: 215rpx;
  83. }
  84. .answer-text {
  85. font-size: 38rpx;
  86. color: #000;
  87. }
  88. }
  89. .home-nav-box {
  90. display: flex;
  91. flex-direction: row;
  92. align-items: center;
  93. background-color: #fff;
  94. width: 95%;
  95. height: 130rpx;
  96. margin: 25rpx 0 15rpx 20rpx;
  97. border-radius: 20rpx;
  98. .nav-img {
  99. width: 95rpx;
  100. height: 95rpx;
  101. margin: 0 20rpx;
  102. }
  103. .nav-name {
  104. font-size: 30rpx;
  105. margin-right: 355rpx;
  106. font-weight: bold;
  107. }
  108. .right-distance {
  109. margin-right: 9rpx;
  110. }
  111. .nav-status {
  112. color: #fff;
  113. background-color: rgb(209, 177, 90);
  114. width: 155rpx;
  115. height: 60rpx;
  116. line-height: 60rpx;
  117. text-align: center;
  118. border-radius: 60rpx;
  119. }
  120. }
  121. </style>