popupBottom.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <view :class="['popup',{'popup-show':show}]" @mousewheel.prevent.stop @touchmove.stop.prevent
  3. :style="{'z-index':zindex}">
  4. <view class="mask" :style="{'z-index':maskZindex,bottom:bottom+'rpx'}" v-show="show" @click.stop="onClose"
  5. @touchmove.prevent.stop></view>
  6. <view :class="['content',{show}]" @click.stop @touchmove.prevent.stop :style="{height:`${height}px`,maxHeight:show ? cotMaxHeight:0,'border-top-right-radius':cotRadius,
  7. 'border-top-left-radius':cotRadius,transition: `all ${animaTime}s ease-in`,bottom:bottom+'rpx','z-index':zindex}">
  8. <view id="title-bar" class="title-bar" v-show="title">
  9. <view class="title" :style="{fontWeight:fontweight}">{{title}}</view>
  10. <view class="close-wrap" @click.stop="onClose">
  11. <image class="close-icon" :src="closeIcon" mode="widthFix"></image>
  12. </view>
  13. </view>
  14. <view class="scroll-wrap">
  15. <scroll-view :class="{'scroll-view':isAnimaStart}" scroll-y="true" style="height:100%;"
  16. @scrolltolower="onScrollToLower">
  17. <view id="popup_content" class="popup_content" :style="{height:`${PopHeight}px`}">
  18. <mescroll-item v-if="type==0" ref="mescrollItem" :videoId="cmdId"></mescroll-item>
  19. <course-comment-item v-if="type==1" ref="mescrollItem" :courseId="cmdId"></course-comment-item>
  20. </view>
  21. </scroll-view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- <view :style="{'z-index':zindex,height:`${PopHeight}px`}" style="position: absolute;left: 0;right: 0;bottom: 0;">
  26. <mescroll-item ref="mescrollItem" :videoId="videoId"></mescroll-item>
  27. </view> -->
  28. </template>
  29. <script>
  30. import iconClose from '@/static/images/close40.png'
  31. import MescrollItem from "@/pages_course/video/comment.vue"
  32. import CourseCommentItem from "@/pages_course/components/comment.vue"
  33. // 第二步: 引入mescroll-comp.js
  34. import MescrollCompMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-comp.js";
  35. export default {
  36. mixins: [MescrollCompMixin],
  37. components: {
  38. MescrollItem,
  39. CourseCommentItem
  40. },
  41. props: {
  42. title: { //标题
  43. type: String,
  44. default: ''
  45. },
  46. fontweight: {
  47. type: [String, Number],
  48. default: 'normal'
  49. },
  50. visible: { //隐藏显示标识
  51. type: Boolean,
  52. default: false
  53. },
  54. maxHeight: { //内容区域最大高度
  55. type: [String, Number],
  56. default: '75%'
  57. },
  58. radius: { //顶部圆角
  59. type: [String, Number],
  60. default: '0'
  61. },
  62. animaTime: { //弹窗动画时间
  63. type: Number,
  64. default: 0.2
  65. },
  66. bottom: { //离底部距离
  67. type: [String, Number],
  68. default: 0
  69. },
  70. zindex: {
  71. type: [String, Number],
  72. default: 1000
  73. },
  74. maskZindex: {
  75. type: [String, Number],
  76. default: 999
  77. },
  78. always: { //是否每次打开都重新计算内容高度
  79. type: Boolean,
  80. default: false
  81. },
  82. cmdId: { //
  83. type: [String, Number],
  84. default:0
  85. },
  86. smsNum: { //
  87. type: [String, Number],
  88. default:0
  89. },
  90. type: { //
  91. type: [String, Number],
  92. default:0
  93. }
  94. },
  95. data() {
  96. return {
  97. show: false,
  98. height: 0,
  99. PopHeight: 0,
  100. cotMaxHeight: '',
  101. isAnimaStart: false,
  102. rpxRate: "",
  103. cotRadius: 0,
  104. closeIcon: iconClose
  105. }
  106. },
  107. watch: {
  108. visible(newval) {
  109. this.isAnimaStart = true;
  110. setTimeout(() => {
  111. this.isAnimaStart = false;
  112. }, this.animaTime * 1000);
  113. if (newval && this.height === 0) {
  114. if (this.PopHeight === 0 || this.always) {
  115. this.setContViewHeight();
  116. } else {
  117. this.height = this.PopHeight
  118. }
  119. // #ifdef H5
  120. //this.setBodyOverFlow('hidden') //阻止滚动穿透
  121. //#endif
  122. this.$emit('open')
  123. } else {
  124. this.height = 0;
  125. // #ifdef H5
  126. this.setBodyOverFlow('visible')
  127. //#endif
  128. }
  129. this.show = newval
  130. if(newval){
  131. this.$refs.mescrollItem.showBotBar(this.smsNum);
  132. }
  133. },
  134. maxHeight: {
  135. handler(newval) {
  136. this.cotMaxHeight = this.unitCheck(newval);
  137. },
  138. immediate: true
  139. },
  140. radius: {
  141. handler(newval) {
  142. this.cotRadius = this.unitCheck(newval);
  143. },
  144. immediate: true
  145. }
  146. },
  147. created() {
  148. this.rpxRate = this.getRpxRate()
  149. },
  150. mounted() {
  151. // this.$nextTick(() => {
  152. // // #ifdef H5
  153. // this.preventTouch(document.querySelector(
  154. // '.scroll-wrap .uni-scroll-view .uni-scroll-view')); //防止浏览器报错
  155. // //#endif
  156. // })
  157. },
  158. methods: {
  159. onClose() {
  160. this.$emit("update:visible", false);
  161. this.$emit('close');
  162. this.$refs.mescrollItem.hideBotBar();
  163. },
  164. // //触底
  165. onScrollToLower(e) {
  166. console.log("qxj onScrollToLower");
  167. // this.$emit("reachBottom");
  168. uni.$emit('reachBottom');
  169. },
  170. getRpxRate() {
  171. let res = uni.getSystemInfoSync();
  172. let width = res.windowWidth;
  173. let rate = 750.00 / width;
  174. return rate
  175. },
  176. unitCheck(value) {
  177. const val = String(value);
  178. if (!val.includes('px') && !val.includes('%')) {
  179. return `${val}rpx`;
  180. }
  181. return val;
  182. },
  183. preventTouch(el) {
  184. el.addEventListener('touchmove', function(e) {
  185. e.stopPropagation();
  186. },{
  187. passive: false
  188. });
  189. },
  190. setBodyOverFlow(val) {
  191. document.body.style.overflow = val
  192. },
  193. //设置内容区域高度
  194. async setContViewHeight() {
  195. const systemInfo = uni.getSystemInfoSync();
  196. let viewHeight=systemInfo.screenHeight;
  197. this.height =viewHeight*0.7;
  198. console.log("qxj viewHeight:"+this.height);
  199. this.PopHeight = this.height;
  200. },
  201. //计算内容区域高度
  202. computeHeight() {
  203. return new Promise(resolve => {
  204. this.$nextTick(() => {
  205. const query = uni.createSelectorQuery().in(this);
  206. query.select('#popup_content').boundingClientRect(data => {
  207. resolve(data)
  208. }).exec();
  209. })
  210. })
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. .popup {
  217. &.popup-show {
  218. position: fixed;
  219. top: 0;
  220. right: 0;
  221. left: 0;
  222. bottom: 0;
  223. overflow: hidden;
  224. z-index: 999;
  225. }
  226. .mask {
  227. position: fixed;
  228. top: 0;
  229. right: 0;
  230. bottom: 0;
  231. left: 0;
  232. background-color: rgba($color: #000000, $alpha: 0.5);
  233. z-index: 999;
  234. }
  235. .content {
  236. position: fixed;
  237. bottom: 0;
  238. left: 0;
  239. right: 0;
  240. height: 0;
  241. height: auto;
  242. background-color: white;
  243. transition: all 0.2s ease-in;
  244. z-index: 1000;
  245. display: flex;
  246. flex-direction: column;
  247. align-items: center;
  248. overflow: hidden;
  249. .title-bar {
  250. width: 100%;
  251. flex-shrink: 0;
  252. text-align: center;
  253. position: relative;
  254. padding: 15rpx 70rpx 0;
  255. padding-top: 30rpx;
  256. box-sizing: border-box;
  257. height: 80rpx;
  258. .title {
  259. font-size: 26rpx;
  260. font-family: PingFang SC;
  261. font-weight: normal !important;
  262. color: #111111;
  263. width: 100%;
  264. overflow: hidden;
  265. text-overflow: ellipsis;
  266. white-space: nowrap;
  267. }
  268. .close-wrap {
  269. position: absolute;
  270. top: 20rpx;
  271. right: 10rpx;
  272. padding: 10rpx 20rpx;
  273. box-sizing: border-box;
  274. }
  275. .close-icon {
  276. width: 40rpx;
  277. height: 40rpx;
  278. }
  279. }
  280. .scroll-wrap {
  281. flex: 1;
  282. height: 0;
  283. width: 100%;
  284. }
  285. &.visible {
  286. max-height: 75%;
  287. overflow-y: hidden;
  288. height: auto;
  289. }
  290. }
  291. }
  292. .scroll-view ::-webkit-scrollbar {
  293. display: none !important;
  294. width: 0 !important;
  295. height: 0 !important;
  296. -webkit-appearance: none;
  297. background: transparent;
  298. }
  299. .popup_content {
  300. width: 100%;
  301. padding: 30rpx;
  302. padding-top: 0;
  303. box-sizing: border-box;
  304. &::after {
  305. display: block;
  306. width: 100%;
  307. content: "\00A0";
  308. overflow: hidden;
  309. opacity: 0;
  310. height: 1rpx;
  311. }
  312. }
  313. </style>