开始

image.png

image.png
最外层加一个view
image.png
image.png

css也复制进来
image.png

  1. .paper-left-popup{
  2. position: fixed;
  3. right: 0;
  4. top: 10upx;
  5. background: #FFFFFF;
  6. z-index: 2000;
  7. width: 55%;
  8. box-shadow: 1upx 1upx 20upx 2upx #CCCCCC;
  9. }
  10. .paper-left-popup>view{
  11. padding: 20upx;
  12. font-size: 35upx;
  13. }
  14. .paper-left-popup>view>view{
  15. margin-left: 10upx;
  16. font-weight: bold;
  17. }
  18. .paper-left-popup-h{
  19. background: #EEEEEE;
  20. }
  21. .paper-left-popup-mask{
  22. position: fixed;
  23. right: 0;
  24. left: 0;
  25. top: 0;
  26. bottom: 0;
  27. /* background: #333333; */
  28. z-index: 1999;
  29. }

外部传入的参数

image.png

image.png
引入组件
image.png

  1. import paperLeftPopup from '@/components/paper/paper-left-popup.vue';
  2. paperLeftPopup

image.png

  1. <paper-left-popup
  2. :show="show"
  3. @hide="hidepopup"
  4. @addfriend="addfriend"
  5. @clear="clear">
  6. </paper-left-popup>

image.png

image.png

本节代码

paper-left-popup.vue组件

  1. <template>
  2. <view>
  3. <!-- 操作菜单 -->
  4. <view class="papar-left-popup-mask" v-show="show" @tap="hidepopup"></view>
  5. <view class="papar-left-popup" v-show="show">
  6. <view class="u-f-ac" hover-class="papar-left-popup-h" @tap="addfriend">
  7. <view class="icon iconfont icon-sousuo"></view>
  8. 加糗友
  9. </view>
  10. <view class="u-f-ac" hover-class="papar-left-popup-h" @tap="clear">
  11. <view class="icon iconfont icon-qingchu"></view>
  12. 清除缓存
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. props:{
  20. show:Boolean
  21. },
  22. methods:{
  23. hidepopup(){
  24. this.$emit('hide');
  25. },
  26. addfriend(){
  27. this.$emit('addfriend');
  28. },
  29. clear(){
  30. this.$emit('clear');
  31. }
  32. }
  33. }
  34. </script>
  35. <style>
  36. .papar-left-popup-mask{
  37. position: fixed;
  38. right: 0;
  39. left: 0;
  40. top: 0;
  41. bottom: 0;
  42. z-index: 1999;
  43. }
  44. .papar-left-popup{
  45. position: fixed;
  46. right: 0;
  47. top: 10upx;
  48. background: #FFFFFF;
  49. z-index: 2000;
  50. width: 55%;
  51. box-shadow: 1upx 1upx 20upx 2upx #CCCCCC;
  52. }
  53. .papar-left-popup>view{
  54. padding: 20upx;
  55. font-size: 35upx;
  56. }
  57. .papar-left-popup>view>view{
  58. margin-right: 10upx;
  59. font-weight: bold;
  60. }
  61. .papar-left-popup-h{
  62. background: #EEEEEE;
  63. }
  64. </style>

paper.vue页面

  1. <template>
  2. <view class="body">
  3. <paper-left-popup :show="show" @hide="hidepopup" @addfriend="addfriend" @clear="clear">
  4. </paper-left-popup>
  5. <!-- 小纸条列表 -->
  6. <block v-for="(item,index) in list" :key="index">
  7. <paper-list :item="item" :index="index"></paper-list>
  8. </block>
  9. <!-- 上拉加载 -->
  10. <load-more :loadtext="loadtext"></load-more>
  11. </view>
  12. </template>
  13. <script>
  14. import paperList from '@/components/paper/paper-list.vue';
  15. import loadMore from '@/components/common/load-more.vue';
  16. import paperLeftPopup from '@/components/paper/paper-left-popup.vue';
  17. export default {
  18. components: {
  19. paperList,
  20. loadMore,
  21. paperLeftPopup
  22. },
  23. data() {
  24. return {
  25. show: false,
  26. loadtext: "上拉加载更多",
  27. list: [{
  28. userpic: "../../static/demo/userpic/12.jpg",
  29. username: "昵称",
  30. time: "10:21",
  31. data: "我是信息",
  32. noreadnum: 2
  33. },
  34. {
  35. userpic: "../../static/demo/userpic/12.jpg",
  36. username: "昵称",
  37. time: "10:21",
  38. data: "我是信息",
  39. noreadnum: 0
  40. },
  41. {
  42. userpic: "../../static/demo/userpic/12.jpg",
  43. username: "昵称",
  44. time: "10:21",
  45. data: "我是信息",
  46. noreadnum: 0
  47. },
  48. {
  49. userpic: "../../static/demo/userpic/12.jpg",
  50. username: "昵称",
  51. time: "10:21",
  52. data: "我是信息",
  53. noreadnum: 11
  54. },
  55. {
  56. userpic: "../../static/demo/userpic/12.jpg",
  57. username: "昵称",
  58. time: "10:21",
  59. data: "我是信息",
  60. noreadnum: 2
  61. },
  62. {
  63. userpic: "../../static/demo/userpic/12.jpg",
  64. username: "昵称",
  65. time: "10:21",
  66. data: "我是信息",
  67. noreadnum: 0
  68. },
  69. {
  70. userpic: "../../static/demo/userpic/12.jpg",
  71. username: "昵称",
  72. time: "10:21",
  73. data: "我是信息",
  74. noreadnum: 0
  75. },
  76. {
  77. userpic: "../../static/demo/userpic/12.jpg",
  78. username: "昵称",
  79. time: "10:21",
  80. data: "我是信息",
  81. noreadnum: 11
  82. }
  83. ]
  84. }
  85. },
  86. // 监听下拉刷新
  87. onPullDownRefresh() {
  88. this.getdata()
  89. },
  90. onReachBottom() {
  91. this.loadmore();
  92. },
  93. onNavigationBarButtonTap(e) {
  94. switch (e.index) {
  95. case 0:
  96. console.log('点击了左边按钮');
  97. this.hidepopup();
  98. break;
  99. case 1:
  100. this.showpopup();
  101. break;
  102. }
  103. },
  104. methods: {
  105. // 上拉加载
  106. loadmore() {
  107. if (this.loadtext != "上拉加载更多") {
  108. return;
  109. }
  110. // 修改状态
  111. this.loadtext = "加载中...";
  112. // 获取数据
  113. setTimeout(() => {
  114. //获取完成
  115. let obj = {
  116. userpic: "../../static/demo/userpic/12.jpg",
  117. username: "昵称",
  118. time: "10:21",
  119. data: "我是信息",
  120. noreadnum: 11
  121. };
  122. this.list.push(obj);
  123. this.loadtext = "上拉加载更多";
  124. }, 1000);
  125. //this.loadtext="没有更多数据了";
  126. },
  127. // 获取数据
  128. getdata() {
  129. setTimeout(() => {
  130. // 服务器获取数据
  131. let arr = [{
  132. userpic: "../../static/demo/userpic/12.jpg",
  133. username: "昵称1111",
  134. time: "10:21",
  135. data: "我是信息",
  136. noreadnum: 2
  137. },
  138. {
  139. userpic: "../../static/demo/userpic/12.jpg",
  140. username: "昵称222",
  141. time: "10:21",
  142. data: "我是信息",
  143. noreadnum: 0
  144. },
  145. {
  146. userpic: "../../static/demo/userpic/12.jpg",
  147. username: "昵称333",
  148. time: "10:21",
  149. data: "我是信息",
  150. noreadnum: 0
  151. },
  152. {
  153. userpic: "../../static/demo/userpic/12.jpg",
  154. username: "昵称444",
  155. time: "10:21",
  156. data: "我是信息",
  157. noreadnum: 11
  158. }
  159. ];
  160. // 赋值
  161. this.list = arr;
  162. // 关闭下拉刷新
  163. uni.stopPullDownRefresh();
  164. }, 2000);
  165. },
  166. addfriend() {
  167. console.log('加糗友');
  168. this.hidepopup();
  169. },
  170. clear() {
  171. console.log('清楚缓存');
  172. this.hidepopup();
  173. },
  174. hidepopup() {
  175. this.show = false;
  176. },
  177. showpopup() {
  178. this.show = true;
  179. }
  180. }
  181. }
  182. </script>
  183. <style>
  184. .body {
  185. padding: 0 20upx;
  186. }
  187. </style>

结束