Dim e As RequestEventArgs = args(0)
Dim path As String = "foxtableAppTest"
Dim wb As New weui
wb.InsertHTML("<!DOCTYPE html>")
wb.InsertHTML("<html>")
wb.InsertHTML("<head>")
wb.InsertHTML("<meta charset='utf-8'>")
wb.InsertHTML("<meta name='viewport' c />")
wb.InsertHTML("<title></title>")
wb.InsertHTML("<script src='../mui/js/mui.min.js'></script>")
wb.InsertHTML("<link href='../mui/css/mui.css' rel='stylesheet'/>")
wb.InsertHTML("<script Type='text/javascript' charset='utf-8'>mui.init();</script>")
wb.InsertHTML("</head>")
wb.InsertHTML("<body>")
wb.InsertHTML("<header class='mui-bar mui-bar-nav mui-bar-nav-bg'>")
wb.InsertHTML("<a id='icon-menu' class='mui-action-back mui-icon mui-icon-left-nav mui-pull-left'></a>")
'wb.InsertHTML ("<a class='mui-action-back mui-icon mui-icon-home mui-pull-right mui-a-color'></a>")
wb.InsertHTML("<h1 class='mui-title'>我的照片</h1>")
wb.InsertHTML("</header>")
wb.InsertHTML("<div class='mui-content'>")
wb.InsertHTML("<br>")
wb.InsertHTML("<br>")
wb.AddForm("","form1","xpcj.htm")
If e.PostValues.Count = 0 Then
wb.InsertHTML("form1","<div style='height: 150px;'><span style='position:absolute;margin-top:60px;margin-left:20px;'>我的照片:</span><img alt='你还没有照片' src='./xp/" & e.Cookies("username") & ".jpg' style='height: 150px;width:120px;margin-left:120px;max-height:100%'></div><br>")
If ReadSex(e.Cookies("username"))= "女"
wb.InsertHTML("form1","<div style='height: 170px'><span style='position:absolute;margin-top:70px;margin-left:20px;'>样板照片:</span><div id='imgs'><img src='./xp/yb.jpg' style='height:150px;width:120px;margin-top:20px;margin-left:120px;max-height:100%;'></div></div><br/>")
End If
If ReadSex(e.Cookies("username"))= "男"
wb.InsertHTML("form1","<div style='height:150px'><span style='position:absolute;margin-top:70px;margin-left:20px;'>样板照片:</span><div id='imgs' style='widht:120px;height:150px;'><img src='./xp/yb1.jpg' style='height:150px;width:120px;margin-left:120px;max-height:100%;'></div></div><br/>")
End If
With wb.AddPageFooter("form1","pf1","")
With wb.AddButtonGroup("form1","btg1",False)
Dim bt1= .Add("btn1", "拍照", "button")
bt1.Attribute = "onclick=getImageByCamera('imgs') style='border:1px solid black;border-radius:40px;padding:0px;'"
bt1.kind=1
'Dim bt2= .Add("btn2", "相册", "button")
' bt2.Attribute = "style='border:1px solid black;border-radius:40px;padding:0px;"
' bt2.kind=1
Dim bt3=.Add("btn3", "上传")
bt3.kind=1
bt3.attribute="style='border:1px solid black;border-radius:40px;padding:0px;'onclick=javascript:mui.toast('正在上传,请等待');"
End With
End With
wb.InsertHTML("<input Type='file' accept='image/*' style='border:1px solid black;border-radius:40px;padding:0px;' value='相册'> ")
Else
For Each key As String In e.PostValues.Keys
If key.Contains("imgs_") Then
Dim bs As Byte() = Convert.FromBase64String(e.PostValues(key).split(",")(1))
Dim stream As System.IO.Stream = New System.IO.MemoryStream(bs)
Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(stream)
bmp.Save("c:\web\xp\" & e.Cookies("username") & ".jpg", ImageFormat.Jpeg)
Dim slt As String ="c:\web\xp\" & e.Cookies("username") & ".jpg"
Dim img1 As image = getImage(slt)
Dim bmp1 As bitmap
If img1.width > 800 Then
If 800 * (img1.height / img1.width) > 600 Then
bmp1 = new bitmap(img1, 800*(600/(800*(img1.height/img1.width))), 600)
Else
bmp1 = new bitmap(img1, 600, 600 * (img1.height / img1.width))
End If
End If
bmp1.save(slt, ImageFormat.Jpeg)
bmp1.Dispose
End If
Next
With wb.AddMsgPage("","msgpage","上传成功", "") '生成成功提示页
Dim bt1=.AddButton("btn1","确定","xpcj.htm")
bt1.kind=1
bt1.Attribute = "style='border:1px solid black;border-radius:20px;padding:0px;width:50%'"
End With
End If
wb.AppendHTML("<script type='text/javascript' src='/" & path & "/js/common.js'></script>", True)
wb.AppendHTML("<script type='text/javascript' src='/" & path & "/js/camera.js'></script>")
e.WriteString(wb.Build)
老师请问两个问题,
1.现在这个页面做了调用摄像头照像,并压缩上传是可以了,现在想加一个打开相册将选定图片显示在imgs中,这个红色部分如何改,或者加一个按钮调用相册并将选定图片显示在imgs中
2.为了将上传成功的图片在本页中显出来, 用了 Dim bt1=.AddButton("btn1","确定","xpcj.htm"),但如果用顶部返回键要按两次才退出本页,有什么办法可以按顶部返回一次退出