vipPop.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. export function vipPop(options = {}, callBack) {
  2. // 以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心
  3. const screenWidth = plus.screen.resolutionWidth;
  4. const screenHeight = plus.screen.resolutionHeight;
  5. //弹窗容器宽度
  6. const popupViewWidth = uni.upx2px(590);
  7. // 弹窗容器的Padding
  8. const viewContentPadding = 12;
  9. // 弹窗容器的宽度
  10. const viewContentWidth = popupViewWidth - (viewContentPadding * 2);
  11. let iconWid = popupViewWidth / 4.0;
  12. let icWidth = 35;
  13. let imgWidth = viewContentWidth
  14. let imgHeight = viewContentWidth / 1.78
  15. // 弹窗容器高度
  16. let popupViewHeight = uni.upx2px(636);
  17. let elementList = [{
  18. tag: 'rect', //背景色
  19. color: 'rgba(0,0,0,0)',
  20. rectStyles: {
  21. radius: "8px"
  22. }
  23. },
  24. // 背景
  25. {
  26. src: './static/images/ad/vip_bg.png',
  27. id: "vip_bg",
  28. tag: "img",
  29. position: {
  30. top: uni.upx2px(80) + "px",
  31. left: "0px",
  32. width: "100%",
  33. height: uni.upx2px(556) + "px",
  34. }
  35. },
  36. {
  37. src: './static/images/ad/vip_img.png',
  38. id: "vip_img",
  39. tag: "img",
  40. position: {
  41. top: - uni.upx2px(0) + "px",
  42. left: (popupViewWidth - uni.upx2px(256)) / 2 + "px",
  43. width: uni.upx2px(256) + "px",
  44. height: uni.upx2px(210) + "px",
  45. }
  46. },
  47. {
  48. src: './static/images/ad/vip_title.png',
  49. id: "vip_title",
  50. tag: "img",
  51. position: {
  52. top: uni.upx2px(204) + "px",
  53. left: (popupViewWidth - uni.upx2px(264)) / 2 + "px",
  54. width: uni.upx2px(264) + "px",
  55. height: uni.upx2px(68) + "px",
  56. }
  57. },
  58. {
  59. tag: 'font',
  60. id: 'text1',
  61. text: options.alert,
  62. textStyles: {
  63. size: uni.upx2px(72) + "px",
  64. color: "#EB772A",
  65. whiteSpace: "normal",
  66. overflow: "ellipsis",
  67. align: 'center',
  68. weight: 'bold'
  69. },
  70. position: {
  71. top: uni.upx2px(6) + "px"
  72. }
  73. },
  74. {
  75. tag: 'font',
  76. id: options.alert1,
  77. text: "有效期至2025-07-27",
  78. textStyles: {
  79. size: uni.upx2px(28) + "px",
  80. color: "#757575",
  81. whiteSpace: "normal",
  82. overflow: "ellipsis",
  83. align: 'center',
  84. },
  85. position: {
  86. top: uni.upx2px(96) + "px",
  87. }
  88. },
  89. ];
  90. let detailbtnEle = [{
  91. tag: 'rect', //背景色
  92. color: 'rgba(0,0,0,0)'
  93. },{
  94. src: './static/images/ad/watch_class_button.png',
  95. id: "watch_class_button",
  96. tag: "img",
  97. position: {
  98. top: "0px",
  99. left: "0px",
  100. width: '100%',
  101. height: '100%',
  102. }
  103. }]
  104. // 弹窗遮罩层
  105. let maskLayer = new plus.nativeObj.View("maskLayer", { //先创建遮罩层
  106. top: '0px',
  107. left: '0px',
  108. height: '100%',
  109. width: '100%',
  110. backgroundColor: 'rgba(0,0,0,0.5)',
  111. visible: false
  112. });
  113. // 弹窗内容
  114. let popupView = new plus.nativeObj.View("popupView", { //创建底部图标菜单
  115. tag: "rect",
  116. top: (screenHeight - popupViewHeight - 70) / 2.0 + "px",
  117. left: '10%',
  118. height: popupViewHeight,
  119. width: "80%",
  120. });
  121. // 去问诊按钮
  122. let detailBtn = new plus.nativeObj.View("detailBtn", {
  123. tag: "rect",
  124. top: (screenHeight - popupViewHeight - 70) / 2.0 + uni.upx2px(484) + "px",
  125. left: (screenWidth - uni.upx2px(414)) / 2 + "px",
  126. width: uni.upx2px(414) + "px",
  127. height: uni.upx2px(119) + "px",
  128. });
  129. // 弹窗关闭按钮
  130. let closeBtnData = closeBtnDrawing();
  131. let closeWid = 40;
  132. let closeBtn = new plus.nativeObj.View("closeBtn", {
  133. tag: "rect",
  134. top: (screenHeight - (popupViewHeight + closeWid + 30)) * 0.5 + (popupViewHeight + 30) + "px",
  135. left: ((closeBtnData.screenWidth - closeWid) / 2) + "px",
  136. height: closeWid + "px",
  137. width: closeWid + "px",
  138. });
  139. popupView.draw(elementList);
  140. detailBtn.draw(detailbtnEle)
  141. closeBtn.draw(closeBtnData.elementList);
  142. maskLayer.show();
  143. popupView.show();
  144. detailBtn.show();
  145. detailBtn.addEventListener('click', (e) => {
  146. maskLayer.hide();
  147. popupView.hide();
  148. detailBtn.hide();
  149. closeBtn.hide();
  150. callBack(1);
  151. });
  152. closeBtn.show();
  153. closeBtn.addEventListener("click", function(e) {
  154. maskLayer.hide();
  155. popupView.hide();
  156. detailBtn.hide();
  157. closeBtn.hide();
  158. });
  159. setTimeout(function(){
  160. maskLayer.hide();
  161. popupView.hide();
  162. detailBtn.hide();
  163. closeBtn.hide();
  164. },3000)
  165. }
  166. //关闭按钮绘图
  167. function closeBtnDrawing() {
  168. // 以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心
  169. const screenWidth = plus.screen.resolutionWidth;
  170. const screenHeight = plus.screen.resolutionHeight;
  171. //弹窗容器宽度
  172. const popupViewWidth = screenWidth * 0.8;
  173. // 弹窗容器的Padding
  174. const viewContentPadding = 12;
  175. // 弹窗容器的宽度
  176. const viewContentWidth = popupViewWidth - (viewContentPadding * 2);
  177. // 弹窗容器高度
  178. let closeY = viewContentPadding * 7 + 60 + 32;
  179. let elementList = [{
  180. tag: 'rect', //背景色
  181. color: 'rgba(255,255,255,0)',
  182. rectStyles: {
  183. radius: "0px"
  184. }
  185. },
  186. {
  187. src: './static/images/ad/close_icon.png',
  188. id: "close",
  189. tag: "img",
  190. position: {
  191. top: '0px',
  192. left: "0px",
  193. width: "32px",
  194. height: "32px",
  195. }
  196. }
  197. ];
  198. return {
  199. popupViewHeight: 32,
  200. popupViewWidth: popupViewWidth,
  201. screenWidth: screenWidth,
  202. screenHeight: screenHeight,
  203. elementList: elementList
  204. };
  205. }