'通用事件头
Dim fl As String = "D:\web\" & e.path
Dim path As String = fl.replace("D:\web\", "")
If FileSys.FileExists(path) Then
e.WriteFile(path)
End If
If filesys.FileExists(fl)
Dim idx As Integer = fl.LastIndexOf(".")
Dim ext As String = fl.SubString(idx)
Select Case ext
Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"
e.WriteFile(fl)
Return '这里必须返回
End Select
End If
Dim wb As New weui
'身份验证
Dim Verified As Boolean '用于标记用户是否通过了身份验证
Dim UserName As String = e.Cookies("username") '从cookie中获取用户名
Dim Password As String = e.Cookies("password") '从cookie中获取用户密码
Dim dianming As String = e.Cookies("dianming")
If e.Path = "logon.htm" '如果是通过登录页面访问,从PostValues即可中提取用户名和密码
If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password") AndAlso e.PostValues.ContainsKey("dianming") Then
UserName = e.PostValues("username")
Password = e.PostValues("password")
dianming = e.PostValues("dianming")
End If
End If
For Each a As DataRow In DataTables("权限设置").DataRows
If UserName = a("账号名") AndAlso Password = a("密码") AndAlso dianming = a("店名") Then '实际使用的时候,请改为从数据库读取用户名和密码进行比较
Verified = True
End If
Next
If Verified AndAlso e.Path = "logon.htm" Then '如果用户访问的是登录页,且身份验证成功
wb.AppendCookie("username",UserName) '将用户名和密码写入cookie
wb.AppendCookie("password",Password)
wb.AppendCookie("dianming",dianming)
wb.InsertHTML("<meta http-equiv='Refresh' c>") '直接跳转到首页
e.WriteString(wb.Build) '生成网页
Return '必须的
ElseIf Verified = False AndAlso e.Path <> "logon.htm" Then '如果用户身份验证失败,且访问的不是登录页面
wb.InsertHTML("<meta http-equiv='Refresh' c>") '那么直接跳转到登录页面
e.WriteString(wb.Build) '生成网页
Return '必须的
End If
'开始生成网页
Select Case e.path
Case "logon.htm" '登录页面
wb.AddPageTitle("","pageheader","会员管理系统","由家家优购基于Foxtable开发")
If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password") AndAlso e.PostValues.ContainsKey("dianming") Then '判断是否是验证失败后的重新登录
wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 '如果用户通过登录按钮访问,则给用户一个2秒的提示.
End If
wb.AddForm("","form1","logon.htm")
Dim gjs As List(of String) = DataTables("权限设置").GetValues("店名")
With wb.AddInputGroup("form1","ipg1","动态列表")
.AddSelect("dianming","店名","|" & String.Join("|",gjs.ToArray)).Attribute = "" '调用js函数
.AddSelect("username","账号名","")
.AddInput("password","密码","password")
End With
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1", "登录", "submit")
End With
For Each gj As String In gjs
'插入一些隐藏段落,用于存储各个国家的汽车品牌
wb.InsertHTML("<p hidden id='" & gj & "'>" & DataTables("权限设置").GetComboListString("账号名","店名='" & gj & "'") & "</p>")
Next
wb.AppendHTML("<script src='./lib/brands.js'></script>") '引入脚本文件
Case "exit.htm" '退出登录
wb.DeleteCookie("username") '清除cookie中原来的用户名和密码
wb.DeleteCookie("password")
wb.DeleteCookie("dianming")
wb.InsertHTML("<meta http-equiv='Refresh' c>") '那么直接跳转到登录页面
Case "", "default.htm" '首页
wb.AddPageTitle("","pageheader","会员信息管理系统","由家家优购基于Foxtable开发")
With wb.AddGrid("","g1")
.Add("c1","会员信息", "./images/cell.png", "findorder.htm")
.Add("c2","商品信息", "./images/cell.png", "http://www.foxtable.com")
.Add("c3","销售统计", "./images/toast.png", "http://www.foxtable.com")
.Add("c4","Dialog", "./images/dialog.png", "http://www.foxtable.com")
.Add("c5","Progress", "./images/progress.png", "http://www.foxtable.com")
.Add("c6","Msg", "./images/msg.png", "http://www.foxtable.com")
.Add("c7","Article", "./images/article.png", "http://www.foxtable.com")
.Add("c8","ActionSheet", "./images/actionSheet.png", "http://www.foxtable.com")
.Add("c9","Icons", "./images/icons.png", "http://www.foxtable.com")
.Add("c10","Panel", "./images/panel.png", "http://www.foxtable.com")
.Add("c11","Tab", "./images/tab.png", "http://www.foxtable.com")
.Add("c12","退出", "./images/exit.png", "exit.htm") '退出登录
End With
Case "findorder.htm" '会员信息查询界面
Functions.Execute("Order_Act_View",wb,e)
End Select
e.WriteString(wb.Build) '生成网页