popup.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view>
  3. <!-- <view class="example">
  4. <view class="example-title">基本用法</view>
  5. <button type="button" @click="togglePopup('top')">顶部弹出 popup</button>
  6. <uniPopup :show="type === 'top'" position="top" mode="fixed" msg="顶部弹出popup" @hidePopup="togglePopup('')" />
  7. <button type="button" @click="togglePopup('middle')">居中弹出 popup</button>
  8. <uniPopup :show="type === 'middle'" position="middle" mode="fixed" msg="居中弹出popup" @hidePopup="togglePopup('')" />
  9. <button type="button" @click="togglePopup('bottom')">底部部弹出 popup</button>
  10. <uniPopup :show="type === 'bottom'" position="bottom" mode="fixed" msg="底部弹出popup" @hidePopup="togglePopup('')" />
  11. </view> -->
  12. <view class="example">
  13. <!-- <view class="example-title">slot用法</view> -->
  14. <!-- <button type="button" @click="togglePopup('middle-img')">居中弹出(插屏广告)</button> -->
  15. <uniPopup :show="type" position="middle" mode="insert" @hidePopup="togglePopup('')">
  16. <view class="uni-center center-box">
  17. <image class="image" src="" style="background-color: #007AFF;" />
  18. </view>
  19. </uniPopup>
  20. <!-- <button type="button" @click="togglePopup('middle-list')">居中弹出(滚动列表)</button>
  21. <uniPopup :show="type === 'middle-list'" position="middle" mode="fixed" @hidePopup="togglePopup('')">
  22. <scroll-view :scroll-y="true" class="uni-center center-box">
  23. <view v-for="(item, index) in list" :key="index" class="uni-list-item">滚动列表数据 {{ item }}</view>
  24. </scroll-view>
  25. </uniPopup> -->
  26. <!-- <button type="button" data-position="bottom" @click="togglePopup('bottom-share')">底部弹出(分享界面)</button>
  27. <uniPopup :show="type === 'bottom-share'" position="bottom" @hidePopup="togglePopup('')">
  28. <view style="display: block;">
  29. <view class="bottom-title">分享到</view>
  30. <view class="bottom-content">
  31. <view v-for="(item, index) in bottomData" :key="index" class="bottom-content-box">
  32. <view :class="item.name" class="bottom-content-image">
  33. <text class="icon">{{ item.icon }}</text>
  34. </view>
  35. <view class="bottom-content-text">{{ item.text }}</view>
  36. </view>
  37. </view>
  38. <view class="bottom-btn" @click="togglePopup('')">取消分享</view>
  39. </view>
  40. </uniPopup> -->
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import uniPopup from './uni-popup.vue'
  46. export default {
  47. props: {
  48. ishow: {
  49. default: false,
  50. type: Boolean
  51. }
  52. },
  53. components: {
  54. uniPopup
  55. },
  56. // watch: {
  57. // 'ishow':function(val) {
  58. // if(val) {
  59. // this.type = true;
  60. // }else {
  61. // this.type = false;
  62. // }
  63. // },
  64. // },
  65. data() {
  66. return {
  67. type: true,
  68. list: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
  69. bottomData: [{
  70. text: '微信',
  71. icon: '\ue6a4',
  72. name: 'wx'
  73. },
  74. {
  75. text: '朋友圈',
  76. icon: '\ue646',
  77. name: 'wx'
  78. },
  79. {
  80. text: 'QQ',
  81. icon: '\ue66b',
  82. name: 'qq'
  83. },
  84. {
  85. text: '新浪',
  86. icon: '\ue600',
  87. name: 'sina'
  88. },
  89. {
  90. text: '复制',
  91. icon: '\ue632',
  92. name: 'copy'
  93. },
  94. {
  95. text: '更多',
  96. icon: '\ue618',
  97. name: 'more'
  98. }
  99. ]
  100. };
  101. },
  102. onBackPress() {
  103. if (this.type !== '') {
  104. this.type = '';
  105. return true;
  106. }
  107. },
  108. methods: {
  109. togglePopup() {
  110. this.type = false;
  111. }
  112. }
  113. };
  114. </script>
  115. <style>
  116. page {
  117. display: flex;
  118. flex-direction: column;
  119. box-sizing: border-box;
  120. background-color: #fff
  121. }
  122. view {
  123. font-size: 28upx;
  124. line-height: inherit
  125. }
  126. .example {
  127. padding: 0 30upx 30upx
  128. }
  129. .example-title {
  130. font-size: 32upx;
  131. line-height: 32upx;
  132. color: #777;
  133. margin: 40upx 25upx;
  134. position: relative
  135. }
  136. .example .example-title {
  137. margin: 40upx 0
  138. }
  139. .example-body {
  140. padding: 0 40upx
  141. }
  142. .uni-padding-wrap {
  143. padding: 0 30upx;
  144. }
  145. button {
  146. margin: 20upx 0;
  147. }
  148. .uni-helllo-text {
  149. height: 100upx;
  150. line-height: 100upx;
  151. text-align: center;
  152. }
  153. .center-box {
  154. width: 500upx;
  155. height: 500upx;
  156. }
  157. .uni-list-item {
  158. text-align: left;
  159. line-height: 80upx;
  160. border-bottom: 1px #f5f5f5 solid;
  161. }
  162. .uni-list-item:last-child {
  163. border: none;
  164. }
  165. .center-box .image {
  166. width: 100%;
  167. height: 100%;
  168. }
  169. .bottom-title {
  170. line-height: 60upx;
  171. font-size: 24upx;
  172. padding: 15upx 0;
  173. }
  174. .bottom-content {
  175. display: flex;
  176. flex-wrap: wrap;
  177. padding: 0 35upx;
  178. }
  179. .bottom-content-box {
  180. display: flex;
  181. flex-direction: column;
  182. align-items: center;
  183. margin-bottom: 15upx;
  184. width: 25%;
  185. box-sizing: border-box;
  186. }
  187. .bottom-content-image {
  188. display: flex;
  189. justify-content: center;
  190. align-items: center;
  191. width: 90upx;
  192. height: 90upx;
  193. overflow: hidden;
  194. background: #007aff;
  195. border-radius: 10upx;
  196. }
  197. .bottom-content-text {
  198. font-size: 26upx;
  199. color: #333;
  200. margin-top: 10upx;
  201. }
  202. .bottom-btn {
  203. height: 90upx;
  204. line-height: 90upx;
  205. border-top: 1px #f5f5f5 solid;
  206. }
  207. .bottom-content-image.wx {
  208. background: #00ce47;
  209. }
  210. .bottom-content-image.qq {
  211. background: #00b6f6;
  212. }
  213. .bottom-content-image.sina {
  214. background: #ff766a;
  215. }
  216. .bottom-content-image.copy {
  217. background: #07ccd0;
  218. }
  219. @font-face {
  220. font-family: 'iconfont';
  221. /* project id 1028200 */
  222. src: url('https://at.alicdn.com/t/font_1028200_47ewtwy4t04.ttf') format('truetype');
  223. }
  224. .icon {
  225. font-family: 'iconfont';
  226. font-size: 40upx;
  227. color: #fff;
  228. }
  229. </style>