123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- let popupViewData = null
- export function coursePopup(options = {},callBack) {
- // 以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心
- const screenWidth = plus.screen.resolutionWidth;
- const screenHeight = plus.screen.resolutionHeight;
- //弹窗容器宽度
- const popupViewWidth = screenWidth * 0.8;
- // 弹窗容器的Padding
- const viewContentPadding = 12;
- // 弹窗容器的宽度
- const viewContentWidth = popupViewWidth - (viewContentPadding * 2);
-
- let iconWid=popupViewWidth/4.0;
- let icWidth=35;
-
- let imgWidth = viewContentWidth
- let imgHeight = viewContentWidth / 1.78
- // 弹窗容器高度
- let popupViewHeight = viewContentPadding * 2 + imgHeight + icWidth + 140;
-
- let elementList = [
- {
- tag: 'rect', //背景色
- color: '#fff',
- rectStyles:{
- radius: "8px"
- }
- },
- // 头像
- {
- src:'./static/images/ad/zsfw_icon40.png',
- id: "headimg",
- tag: "img",
- position: {
- top: viewContentPadding + 'px',
- left: viewContentPadding + "px",
- width: icWidth+"px",
- height: icWidth +"px",
- }
- },
- // 名称
- {
- tag: 'font',
- id: 'name',
- text: "标题标题标题标题标题标题标题标题标题标题标题标题",
- textStyles: {
- size: '14px',
- color: "#222",
- verticalAlign: "middle",
- whiteSpace: "normal",
- overflow: "ellipsis",
- align: 'left'
- },
- position: {
- top: '5px',
- left: icWidth + 24 + "px",
- height: "34px",
- width: imgWidth - icWidth - 36 + 'px',
- }
- },
- // 描述
- {
- tag: 'font',
- id: 'text1',
- text: "给你分享了一个课程",
- textStyles: {
- size: '13px',
- color: "#999",
- verticalAlign: "middle",
- whiteSpace: "normal",
- overflow: "ellipsis",
- align: 'left'
- },
- position: {
- top: viewContentPadding + 10 + 'px',
- left: icWidth + 24 + "px",
- height: "34px",
- width: imgWidth - icWidth - 36 + 'px',
- }
- },
- {
- src:'https://cos.his.cdwjyyh.com/fs/20241122/0d29517f595e428989017b49e28ea437.jpg',
- id: "logo",
- tag: "img",
- position: {
- top: viewContentPadding*2 + icWidth + 'px',
- left: viewContentPadding+ 'px',
- width: imgWidth + 'px',
- height: imgHeight + 'px',
- },
- },
- // 标题
- {
- tag: 'font',
- id: 'title',
- text: "标题标题标题标题标题标题标题标题标题标题标题标题",
- textStyles: {
- size: '16px',
- color: "#222",
- verticalAlign: "middle",
- whiteSpace: "normal",
- overflow: "ellipsis",
- align: 'left'
- },
- position: {
- top: imgHeight + icWidth + viewContentPadding*2 + 'px',
- left: "10px",
- right: "10px",
- height: "36px",
- width: imgWidth + 'px',
- }
- },
- // 描述
- {
- tag: 'font',
- id: 'desc',
- text: "描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述",
- textStyles: {
- size: '13px',
- color: "#999",
- verticalAlign: "middle",
- whiteSpace: "normal",
- overflow: "ellipsis",
- align: 'left'
- },
- position: {
- top: imgHeight + icWidth + viewContentPadding*2 + 26 + 'px',
- left: "10px",
- right: "10px",
- height: "50px",
- width: imgWidth + 'px',
- }
- },
- ];
- let detailbtnEle = [{
- tag: 'rect', //背景色
- id: 'button',
- color: '#FF5C03',
- rectStyles:{
- radius: "22px",
- },
- position:{
- left:"10%",
- top: 0,
- width:"80%",
- height:"44px",
- }
- },{
- tag: 'font',
- id: 'buttontxt',
- text: "查看详情",
- textStyles: {
- size: '16px',
- color: "#fff",
- verticalAlign: "middle",
- whiteSpace: "normal",
- overflow: "ellipsis",
- align: 'center'
- },
- position: {
- left:"10%",
- top: 0,
- width:"80%",
- height:"44px",
- }
- }]
- // 弹窗遮罩层
- let maskLayer = new plus.nativeObj.View("maskLayer", { //先创建遮罩层
- top: '0px',
- left: '0px',
- height: '100%',
- width: '100%',
- backgroundColor: 'rgba(0,0,0,0.5)',
- visible: false
- });
- // 弹窗内容
- let popupView = new plus.nativeObj.View("popupView", { //创建底部图标菜单
- tag: "rect",
- top: (screenHeight - popupViewHeight - 70) / 2.0 + "px",
- left: '10%',
- height: popupViewHeight,
- width: "80%",
- });
-
- // 弹窗查看详情按钮
- let detailBtn = new plus.nativeObj.View("detailBtn", {
- tag: "rect",
- top: (screenHeight - popupViewHeight - 70) / 2.0 + imgHeight + icWidth + viewContentPadding*2 + 80 + 'px',
- left: "10%",
- width:"80%",
- height:"44px",
- });
-
- // 弹窗关闭按钮
- let closeBtnData = closeBtnDrawing();
- let closeWid=40;
- let closeBtn = new plus.nativeObj.View("closeBtn", {
- tag: "rect",
- top: (screenHeight - (popupViewHeight+closeWid+30))*0.5 +(popupViewHeight+30) + "px",
- left: ((closeBtnData.screenWidth - closeWid) / 2) +"px",
- height: closeWid+"px",
- width: closeWid+"px",
- });
- popupView.draw(elementList);
- detailBtn.draw(detailbtnEle)
- closeBtn.draw(closeBtnData.elementList);
-
- maskLayer.show();
- popupView.show();
- detailBtn.show();
- closeBtn.show();
- detailBtn.addEventListener('click', (e) => {
- maskLayer.hide();
- popupView.hide();
- detailBtn.hide();
- closeBtn.hide();
- callBack(1);
- });
- closeBtn.addEventListener("click", function(e) {
- maskLayer.hide();
- popupView.hide();
- detailBtn.hide();
- closeBtn.hide();
- });
- }
- //关闭按钮绘图
- function closeBtnDrawing(){
- // 以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心
- const screenWidth = plus.screen.resolutionWidth;
- const screenHeight = plus.screen.resolutionHeight;
- //弹窗容器宽度
- const popupViewWidth = screenWidth * 0.8;
- // 弹窗容器的Padding
- const viewContentPadding = 12;
- // 弹窗容器的宽度
- const viewContentWidth = popupViewWidth - (viewContentPadding * 2);
- // 弹窗容器高度
- let closeY = viewContentPadding * 7 + 60+32;
- let elementList = [
- {
- tag: 'rect', //背景色
- color: 'rgba(255,255,255,0)',
- rectStyles:{
- radius: "0px"
- }
- },
- {
- src:'./static/images/ad/close_icon.png',
- id: "close",
- tag: "img",
- position: {
- top: '0px',
- left: "0px",
- width: "32px",
- height: "32px",
- }
- }
- ];
- return {
- popupViewHeight:32,
- popupViewWidth:popupViewWidth,
- screenWidth:screenWidth,
- screenHeight:screenHeight,
- elementList: elementList
- };
- }
|