Foxtable(狐表)用户栏目专家坐堂 → 请教动态列表,代码在httprequset中写代码正常,但放到内部函数中调用就出不来下拉列表,请问是何原因。


  共有2751人关注过本帖树形打印复制链接

主题:请教动态列表,代码在httprequset中写代码正常,但放到内部函数中调用就出不来下拉列表,请问是何原因。

帅哥哟,离线,有人找我吗?
cxzhl
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:34 积分:443 威望:0 精华:0 注册:2020/3/23 23:20:00
请教动态列表,代码在httprequset中写代码正常,但放到内部函数中调用就出不来下拉列表,请问是何原因。  发帖心情 Post By:2020/8/19 10:33:00 [显示全部帖子]

Dim e As  RequestEventArgs = args(0)
'通用事件头,用于发送已经存在的常见文件
Dim fl As String = "d:\web\" & e.path
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
'以下是动态生成网页的代码

Select Case e.Path
    Case "wyyc.htm"
        Dim wb As New weui
 wb.AddPageTitle("","pageheader","众和出行","每公里1.5元+每分钟0.2元,日封顶150元")
If e.PostValues.Count = 0 Then
        wb.AddForm("","form1","wyyc.htm") '指定接收表单数据的的页面为handle.htm
        With wb.AddInputGroup("form1","ipg1","新增出行订单")
            With .AddInput("订单编号","订单编号","text")
                .Value = Functions.Execute("GetOrderID")
                .Readonly = True
            End With
            With .AddInput("用户手机","用户手机","text")
                .Value = e.Cookies("username")
                .Readonly = True
            End With
            With .AddInput("下单时间","下单时间","datetime")
                .Value = Date.now()
                .Readonly = True
            End With
        With wb.AddInputGroup("form1","ipg2","选择网点车辆")
            With .AddSelect("地区","地区","|" & DataTables("可用车辆").GetComboListString("地区"))
                .Attribute = """
            End With
            With .AddSelect("网点","网点","")
                .Attribute = """
            End With
            With .AddSelect("车牌","车牌","")
                .Attribute = """
            End With
            .AddSelect("车架","车架","")
End With
     End With
            With wb.AddButtonGroup("form1","btg1",True)
                .Add("btn1", "确定", "submit")
            End With
            e.WriteString(wb.Build)
        Else
            Dim nms() As String = {"订单编号","用户手机","下单时间"} '不能为空的列名数组 
            For Each nm As String In nms
                If e.PostValues.ContainsKey(nm) = False Then '生成错误提示页 
                    With wb.AddMsgPage("","msgpage","增加失败", nm & "列不能为空!") 
                        .icon = "Warn" '改变图标
                        .AddButton("btn2","返回").Attribute = ""
                    End With
                    e.WriteString(wb.Build)
                    Return""  '必须返回
                End If
            Next
            nms = New String() {"订单编号","用户手机","下单时间","地区","取车网点","车牌","车架"} '重新定义了nms数组,增加了两列. 
            Dim dr As DataRow = DataTables("订单").AddNew()
            For Each nm As String In nms
                If e.PostValues.ContainsKey(nm) Then
                    dr(nm) = e.PostValues(nm)
                End If
Next
  dr.save()
           With wb.AddMsgPage("","msgpage","下单成功!", "请在30分钟内自行取车,超过时间将收取5元退单费用") '生成成功提示页
                .AddButton("btn2","导航前往","http://www.99cgt.cn")
                .AddButton("btn3","寻车","http://www.99cgt.cn")
                .AddButton("btn4","开门").Attribute = """
                With wb.AddDialog("","dlg1", "","")
                    .AddButton("btnOK","确定用车")
                End With
                e.WriteString(wb.Build) '生成网页
            End With
            e.WriteString(wb.Build)
        End If

Case  "getProducts.htm"
    Dim vals As String
    If e.PostValues.Count = 1 Then
        vals  = "|" & DataTables("可用车辆").GetComboListString("网点","地区='" & e.PostValues("地区") & "'")
    ElseIf e.PostValues.Count = 2 Then
        Dim Filter As String = "地区='" & e.PostValues("地区") & "' And 网点='" & e.PostValues("网点") & "'"
        vals = "|" & DataTables("可用车辆").GetComboListString("车牌", Filter)
    ElseIf e.PostValues.Count = 3 Then
        Dim Filter1 As String = "网点='" & e.PostValues("网点") & "' And 车牌='" & e.PostValues("车牌") & "'"
       vals = "|" & DataTables("可用车辆").GetComboListString("车架", Filter1)
    End If
    e.WriteString(vals)
End Select

表格如下:
图片点击可在新窗口打开查看
如下图,二三级列表出不来,同样的代码复制到httpredet中是正常的

图片点击可在新窗口打开查看
[此贴子已经被作者于2020/8/19 10:36:40编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
cxzhl
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:34 积分:443 威望:0 精华:0 注册:2020/3/23 23:20:00
  发帖心情 Post By:2020/8/19 11:05:00 [显示全部帖子]

启动服务代码:
HttpServer.Prefixes.Add("http://*:8087/")
HttpServer.Prefixes.Add("http://127.0.0.1/")
HttpServer.Prefixes.Add("http://www.ynzhcx.cn/")
HttpServer.WebPath = "d:\web"  '指定静态文件存储位置
HttpServer.Start()

httprequest代码如下:
Select Case e.path
    Case "wefox"
        If e.Request.HttpMethod.ToUpper = "GET"
            If Functions.Execute("VerifySignature",e) Then
                e.WriteString(e.GetValues("echostr"))
            End If
        End If
End Select

Select Case e.Path
    Case "yhrz.htm"
        Functions.Execute("yhrz",e)
End Select
Select Case e.Path
    Case "wdgl.htm"
        Functions.Execute("wdgl",e)
End Select

Select Case e.Path
    Case "clgl.htm"
        Functions.Execute("clgl",e)
End Select

Select Case e.Path
    Case "yhzc.htm"
        Functions.Execute("yhzc",e)
End Select
Select Case e.Path
    Case "yhrz.htm"
        Functions.Execute("yhrz",e)
End Select

Select Case e.Path
    Case "grzx.htm"
        Functions.Execute("grzx",e)
End Select


Select Case e.Path
    Case "wyyc.htm"
        Functions.Execute("wyyc",e)
End Select

Select Case e.Path
    Case "wzbzj.htm"
        Functions.Execute("wzbzj",e)
End Select
Select Case e.Path
    Case "hysj.htm"
        Functions.Execute("hysj",e)
End Select
Select Case e.Path
    Case "wdlyj.htm"
        Functions.Execute("wdlyj",e)
End Select
Select Case e.Path
    Case "delete.htm"
        Functions.Execute("Delete",e)
End Select

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中获取用户密码
If e.Path = "logon.htm" '如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")   Then
        UserName = e.PostValues("username")
        Password = e.PostValues("password")
    End If
End If
Dim mmm As DataRow = DataTables("用户").find("手机号='" & UserName & "'")
If mmm IsNot Nothing AndAlso mmm("密码") = Password  Then
    Verified  = True
End If
If Verified AndAlso e.Path = "logon.htm"  Then '如果用户访问的是登录页,且身份验证成功
    wb.AppendCookie("username",UserName) '将用户名和密码写入cookie
    wb.AppendCookie("password",Password)
    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","众和出行","每公里1.5元+每分钟0.2元,日封顶150元")
        If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")   Then '判断是否是验证失败后的重新登录
            wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 '如果用户通过登录按钮 访问,则给用户一个2秒的提示.
        End If
        wb.AddForm("","form1","logon.htm")
        With wb.AddInputGroup("form1","ipg1")
            .AddInput("username","手机号","text")
            .AddInput("password","密码","password")
        End With
        With wb.AddButtonGroup("form1","btg1",False)
            .Add("btn1", "登录", "submit")
            .Add("btn2", "新用户注册", "button","yhzc.htm").kind = 1 '单击这个按钮可以打开注 册页
        End With
        With wb.AddPageFooter("","pf1","版权:属迈福铃汽车服务有限公司")
            .AddLink("技术支持楚雄海子科技:","http://www.99cgt.cn")
        End With
    Case "exit.htm" '退出登录
        wb.DeleteCookie("username") '清除cookie中原来的用户名和密码
        wb.DeleteCookie("password")
        wb.InsertHTML("<meta http-equiv='Refresh' c>") '那么直接跳 转到登录页面
        
    Case "", "default.htm" '首页
        wb.AddPageTitle("","pageheader1","众和出行","每公里1.5元+每分钟0.2元,日封顶150元")
        wb.AddForm("","form2","default.htm")
        ' Dim sb As New StringBuilder
        ' sb.AppendLine("<img src='/images/abc.jpg'>")
        ' wb.AppendHTML("<script src='./html/txdt.html'></script>",True)
        
        'With wb.AddButtonGroup("form2","btngrp1")
        '   .Add("btn3", "驾照认证", "button","yhrz.htm")
        '  .Add("btn4", "网点查询", "button","./html/gdwdcx.htm")
        ' .Add("btn5", "车辆管理", "button","clgl.htm")
        '.Add("btn6", "车辆测试", "button","clcs.htm")
        'End With
        With wb.AddGrid("","g1")
            .Add("c1","驾照认证", "./images/rz.png","yhrz.htm")  '.Attribute =  ""
            .Add("c2","违章保证金", "./images/wzb.png", "wzbzj.htm")
            .Add("c3","车辆分布", "./images/zc.png",  "https://maplab.amap.com/share/mapv/c67444713538e5271bb01968c3ea6563")
            .Add("c4","会员升级", "./images/cz.png", "hysj.htm")
            .Add("c4","网点查询", "./images/cz.png",  "https://maplab.amap.com/share/mapv/aae6e34a4ecef8d4978ffc3d84df886c")
            .Add("c5","网点申请", "./images/sq.png", "wdgl.htm")
            .Add("c5","网点履约金", "./images/sq.png", "wdlyj.htm")
            .Add("c6","车辆管理", "./images/clgl.png", "clgl.htm")
            .Add("c7","使用说明", "./images/wx.png", "help.htm")
            .Add("c8","个人中心", "./images/cz.png", "grzx.htm")
            .Add("c8","我要用车", "./images/cz.png", "wyyc.htm")
            .Add("c9","退出", "./images/exit.png", "exit.htm") '退出登录
        End With
End Select
e.WriteString(wb.Build) '生成网页

 回到顶部
帅哥哟,离线,有人找我吗?
cxzhl
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:34 积分:443 威望:0 精华:0 注册:2020/3/23 23:20:00
  发帖心情 Post By:2020/8/19 16:29:00 [显示全部帖子]

蓝老师你好!增加选择getProducts.htm这函数后动态列表问题解决。但我按你说的优化httpreuset代码后,放在登录页后面的页面就全都打不开,空白页。请问如何处理,已在登陆后进入主页测试
Select Case e.path
    Case "yhzc.htm"
        Functions.Execute("yhzc",e)
 Case "wyyc.htm","getProducts.htm"
        Functions.Execute("wyyc",e)
End Select

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中获取用户密码
If e.Path = "logon.htm" '如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")   Then
        UserName = e.PostValues("username")
        Password = e.PostValues("password")
    End If
End If
Dim mmm As DataRow = DataTables("用户").find("手机号='" & UserName & "'")
If mmm IsNot Nothing AndAlso mmm("密码") = Password  Then
    Verified  = True
End If
If Verified AndAlso e.Path = "logon.htm"  Then '如果用户访问的是登录页,且身份验证成功
    wb.AppendCookie("username",UserName) '将用户名和密码写入cookie
    wb.AppendCookie("password",Password)
    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","众和出行","每公里1.5元+每分钟0.2元,日封顶150元")
        If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")   Then '判断是否是验证失败后的重新登录
            wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 '如果用户通过登录按钮 访问,则给用户一个2秒的提示.
        End If
        wb.AddForm("","form1","logon.htm")
        With wb.AddInputGroup("form1","ipg1")
            .AddInput("username","手机号","text")
            .AddInput("password","密码","password")
        End With
        With wb.AddButtonGroup("form1","btg1",False)
            .Add("btn1", "登录", "submit")
            .Add("btn2", "新用户注册", "button","yhzc.htm").kind = 1 '单击这个按钮可以打开注 册页
        End With
        With wb.AddPageFooter("","pf1","版权属迈福铃汽车服务有限公司")
            .AddLink("技术支持楚雄海子科技:","http://www.99cgt.cn")
        End With
    Case "exit.htm" '退出登录
        wb.DeleteCookie("username") '清除cookie中原来的用户名和密码
        wb.DeleteCookie("password")
        wb.InsertHTML("<meta http-equiv='Refresh' c>") '那么直接跳 转到登录页面
        
    Case "", "default.htm" '首页
        wb.AddPageTitle("","pageheader1","众和出行","每公里1.5元+每分钟0.2元,日封顶150元")
        wb.AddForm("","form2","default.htm")
        ' Dim sb As New StringBuilder
        ' sb.AppendLine("<img src='/images/abc.jpg'>")
        ' wb.AppendHTML("<script src='./html/txdt.html'></script>",True)
        
        'With wb.AddButtonGroup("form2","btngrp1")
        '   .Add("btn3", "驾照认证", "button","yhrz.htm")
        '  .Add("btn4", "网点查询", "button","./html/gdwdcx.htm")
        ' .Add("btn5", "车辆管理", "button","clgl.htm")
        '.Add("btn6", "车辆测试", "button","clcs.htm")
        'End With
        With wb.AddGrid("form2","g1")
            .Add("c1","驾照认证", "./images/rz.png","yhrz.htm")  '.Attribute =  ""
            .Add("c2","违章保证金", "./images/wzb.png", "wzbzj.htm")
            .Add("c3","车辆分布", "./images/zc.png",  "https://maplab.amap.com/share/mapv/c67444713538e5271bb01968c3ea6563")
            .Add("c4","会员升级", "./images/cz.png", "hysj.htm")
            .Add("c4","网点查询", "./images/cz.png",  "https://maplab.amap.com/share/mapv/aae6e34a4ecef8d4978ffc3d84df886c")
            .Add("c5","网点申请", "./images/sq.png", "wdgl.htm")
            .Add("c5","网点履约金", "./images/sq.png", "wdlyj.htm")
            .Add("c6","车辆管理", "./images/clgl.png", "clgl.htm")
            .Add("c7","使用说明", "./images/wx.png", "help.htm")
            .Add("c8","个人中心", "./images/cz.png", "grzx.htm")
            .Add("c8","我要用车", "./images/cz.png", "wyyc.htm")
            .Add("c9","退出", "./images/exit.png", "exit.htm") '退出登录
        End With
With wb.AddButtonGroup("form2","btg2", False)  '水平排列
            .Add("btn6", "我要还车","button","/wyhc.htm").Kind = 2
        End With
End Select
e.WriteString(wb.Build) '生成网页


Select Case e.path
    Case "wefox"
        If e.Request.HttpMethod.ToUpper = "GET"
            If Functions.Execute("VerifySignature",e) Then
                e.WriteString(e.GetValues("echostr"))
            End If
        End If
    Case "yhrz.htm"
        Functions.Execute("yhrz",e)
    Case "wdgl.htm"
        Functions.Execute("wdgl",e)
       Case "clgl.htm"
        Functions.Execute("clgl",e)
    Case "yhzc.htm"
        Functions.Execute("yhzc",e)
       Case "grzx.htm"
        Functions.Execute("grzx",e)
       Case "wzbzj.htm"
        Functions.Execute("wzbzj",e)
    Case "hysj.htm"
        Functions.Execute("hysj",e)
    Case "wdlyj.htm"
        Functions.Execute("wdlyj",e)
    Case "delete.htm"
        Functions.Execute("Delete",e)
    Case "wyhc.htm"
        Functions.Execute("wyhc",e)
End Select
'Select Case e.Path
  '  Case "wyyc.htm","getProducts.htm"
   '     Functions.Execute("wyyc",e)
'End Select

 回到顶部
帅哥哟,离线,有人找我吗?
cxzhl
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:34 积分:443 威望:0 精华:0 注册:2020/3/23 23:20:00
  发帖心情 Post By:2020/8/19 16:52:00 [显示全部帖子]

蓝老师你好!麻烦你了,我查了代码没问题,重启一回电脑正常了,谢谢!注册页外(我放在前面),其它
页面登录后正常了

 回到顶部