政企超链接开始集成

This commit is contained in:
hoteas 2022-02-28 08:53:38 +08:00
parent d8d9afa4d2
commit 9283b8c284
9 changed files with 158 additions and 58 deletions

View File

@ -95,7 +95,7 @@ func getCompany(name, path string) Map {
func Weixin(this *Context) *wechat.Wechat {
if weixin == nil {
cache1 := cache.Cache(WechatCache{this.CacheIns})
config := wechat.Config{Cache: cache1, AppID: this.Config.GetString("wechatAppid"), AppSecret: this.Config.GetString("wechatAppscript")}
config := wechat.Config{Cache: cache1, AppID: this.Config.GetString("wechatAppID"), AppSecret: this.Config.GetString("wechatAppSecret")}
weixin = wechat.NewWechat(&config)
}
@ -105,7 +105,7 @@ func Weixin(this *Context) *wechat.Wechat {
//微信获取个人信息
func WxPayClient(this *Context, sn string, money int64, openid string) Map {
if wxpayClient == nil {
wxpayClient = core.NewClient(this.Config.GetString("wechatAppid"), this.Config.GetString("wechatChid"), this.Config.GetString("wechatChkey"), nil)
wxpayClient = core.NewClient(this.Config.GetString("wechatAppID"), this.Config.GetString("wechatChid"), this.Config.GetString("wechatChkey"), nil)
}
res, err := pay.UnifiedOrder2(wxpayClient, &pay.UnifiedOrderRequest{
@ -141,13 +141,13 @@ func WxPayClient(this *Context, sn string, money int64, openid string) Map {
return nil
}
wcpay := Map{
"appId": this.Config.Get("wechatAppid"),
"appId": this.Config.Get("wechatAppID"),
"timeStamp": ObjToStr(time.Now().Unix()),
"nonceStr": getSn(),
"package": "prepay_id=" + res.PrepayId,
"signType": "MD5",
}
wcpay["paySign"] = core.JsapiSign(this.Config.GetString("wechatAppid"), wcpay.GetString("timeStamp"), wcpay.GetString("nonceStr"), wcpay.GetString("package"), "MD5", this.Config.GetString("wechatChkey"))
wcpay["paySign"] = core.JsapiSign(this.Config.GetString("wechatAppID"), wcpay.GetString("timeStamp"), wcpay.GetString("nonceStr"), wcpay.GetString("package"), "MD5", this.Config.GetString("wechatChkey"))
return wcpay
}

View File

@ -3,6 +3,7 @@ package app
import (
. "../../../hotime"
. "../../../hotime/common"
"fmt"
"time"
//"strings"
)
@ -21,7 +22,7 @@ var Question = Ctr{
this.Display(3, "参数错误")
return
}
data := this.Req.FormValue("data")
data := this.Req.FormValue("question_data")
if data == "" {
this.Display(3, "没有上传数据")
@ -31,8 +32,9 @@ var Question = Ctr{
status := ObjToInt(this.Req.FormValue("status"))
re := this.Db.Update("question_company", Map{"question_data": data, "status": status}, Map{"id": questionCompanyId})
if re == 0 {
this.Display(4, "没有更新信息!")
return
//this.Display(4, "没有更新信息!")
fmt.Println(4, "没有更新信息!")
//return
}
this.Display(0, "更新成功")
@ -76,10 +78,9 @@ var Question = Ctr{
delete(v, "question")
questionCompany["question"] = v
re = append(re, questionCompany)
}
//user["questions"]=re
this.Display(0, re)
},

View File

@ -3,11 +3,11 @@ package app
import (
. "../../../hotime"
. "../../../hotime/common"
"../../../hotime/dri/download"
"encoding/base64"
"io/ioutil"
"os"
"../../../hotime/dri/download"
"strings"
"time"
//"strings"
)
@ -24,17 +24,63 @@ var User = Ctr{
this.Display(2, "还没有登录")
return
}
if this.Session("user_id").Data == nil {
this.Display(2, "还没有登录")
return
}
user := this.Db.Get("user", "*", Map{"id": this.Session("user_id").Data})
if user == nil {
this.Display(4, "找不到该用户")
return
}
company := this.Db.Get("company", "id,name,status", Map{"id": user.GetCeilInt("company_id")})
user["company"] = company
t := time.Now().Unix()
questions := this.Db.Select("question", "*", Map{"AND": Map{"org_id": user.GetCeilInt("org_id"), "start_time[<=]": t, "end_time[>=]": t, "state": 0}})
re := []Map{}
for _, v := range questions {
questionCompany := this.Db.Get("question_company", "*", Map{"AND": Map{"question_id": v.GetCeilInt("id"), "company_id": user.GetCeilInt("company_id")}})
if questionCompany == nil {
questionCompany = Map{
"name": v.GetString("name"),
"question_data": v.GetString("question_data"),
"org_id": v.GetString("org_id"),
"question_id": v.GetString("id"),
"company_id": user.GetCeilInt("company_id"),
"user_id": user.GetString("id"),
"create_time": t,
"modify_time": t,
"status": 0,
"state": 0,
}
questionCompany["id"] = this.Db.Insert("question_company", questionCompany)
if questionCompany.GetCeilInt("id") == 0 {
this.Display(4, "无法创建调查数据")
return
}
}
delete(v, "question_data")
questionCompany["question"] = v
questionCompany["question_data"] = questionCompany.GetSlice("question_data")
re = append(re, questionCompany)
}
user["questions"] = re
this.Display(0, user)
},
//身份认证
"auth": func(this *Context) {
if this.Session("wechatInfo").Data == nil {
this.Display(2, "尚未登录")
return
}
//if this.Session("wechatInfo").Data == nil {
// this.Display(2, "尚未登录")
// return
//}
//if this.Session("code").Data == nil {
// this.Display(8, "验证码没有获取")
@ -85,7 +131,8 @@ var User = Ctr{
company["modify_time"] = t
company["img"] = companyImg
company["org_id"] = orgId
company["name"] = companyName
//company["img"] = companyImg
re := this.Db.Update("company", company, Map{"id": company.GetCeilInt("id")})
if re == 0 {
this.Display(4, "无法更新企业")
@ -114,14 +161,16 @@ var User = Ctr{
return
}
} else {
data["nickname"] = userInfo.GetString("nickname")
data["create_time"] = t
path := time.Now().Format(this.Config.GetString("uimgPath"))
if userInfo != nil {
data["nickname"] = userInfo.GetString("nickname")
path := time.Now().Format(this.Config.GetString("imgPath"))
filename := Md5(ObjToStr(t)) + ".jpg"
down := download.Down(userInfo.GetString("avatar"), this.Config.GetString("tpt")+"/"+path, filename)
if down {
data["avatar"] = path + filename
}
}
user = data
user["id"] = this.Db.Insert("user", data)
if user.GetCeilInt("id") == 0 {
@ -129,7 +178,7 @@ var User = Ctr{
return
}
}
if userInfo != nil {
delete(userInfo, "avatar")
delete(userInfo, "nickname")
userInfo["modify_time"] = t
@ -145,9 +194,9 @@ var User = Ctr{
userInfo["create_time"] = t
userInfo["id"] = this.Db.Insert("wechat", userInfo)
}
}
this.Session("user_id", user.GetCeilInt("id"))
this.Display(0, "认证成功!")
this.Display(0, this.SessionId)
},
@ -191,15 +240,15 @@ var User = Ctr{
return
}
//fmt.Println(uimg)
btes, e := base64.StdEncoding.DecodeString(file) //成图片文件并把文件写入到buffer
btes, e := base64.StdEncoding.DecodeString(file[strings.Index(file, ",")+1:]) //成图片文件并把文件写入到buffer
//btes, e := base64.StdEncoding.DecodeString(file) //成图片文件并把文件写入到buffer
if e != nil {
this.Display(3, "无法解析图片")
return
}
//uimgPath:=time.Now().Format(this.Config.GetString("uimgPath"))
path := time.Now().Format(this.Config.GetString("imgPath"))
path := time.Now().Format(this.Config.GetString("wxFilePath"))
os.MkdirAll(this.Config.GetString("tpt")+"/"+path, os.ModeDir)
filePath := path + Md5(ObjToStr(time.Now().Unix())) + ".jpg"
@ -211,7 +260,52 @@ var User = Ctr{
}
this.Display(0, filePath)
},
//"upload": func(this *Context) {
//
// //读取网络文件
// fi, fheader, err := this.Req.FormFile("file")
// if err != nil {
// this.Display(3, err)
// return
//
// }
// filePath := this.Config.GetString("wxFilePath")
// if filePath == "" {
// filePath = "file/2006/01/02/"
// }
//
// path := time.Now().Format(filePath)
// e := os.MkdirAll(this.Config.GetString("tpt")+"/"+path, os.ModeDir)
//
// if e != nil {
// this.Display(3, e)
// return
// }
//
// filePath = path + Md5(ObjToStr(RandX(100000, 9999999))) + fheader.Filename[strings.LastIndex(fheader.Filename, "."):]
// newFile, e := os.Create(this.Config.GetString("tpt") + "/" + filePath)
//
// if e != nil {
// this.Display(3, e)
// return
// }
//
// _, e = io.Copy(newFile, fi)
//
// if e != nil {
// this.Display(3, e)
// return
// }
//
// //this.Display(0, filePath)
//
// //读取excel
// //fmt.Println(Org[orgId],OrgId)
//
//
// this.Display(0, filePath)
//
//},
//更新个人资料
//"update": func(this *Context) {
// if this.Req.Form["unickname"] == nil ||

View File

@ -90,7 +90,7 @@ var Wechat = Ctr{
auth := wx.GetOauth(this.Req, this.Resp)
resToken, err := auth.GetUserAccessToken(this.Req.FormValue("code"))
if err != nil {
this.Display(6, "code错误")
this.Display(5, "code错误")
return
}
@ -98,7 +98,7 @@ var Wechat = Ctr{
user := this.Db.Get("wechat", Map{"[><]user": "wechat.user_id=user.id"}, "user.id,user.state", Map{"openid": resToken.OpenID})
if user != nil && user.GetCeilInt("state") == 0 {
this.Session("user_id", user.Get("id"))
this.Display(0, 0)
this.Display(0, Map{"type": 0, "token": this.SessionId})
return
}
//getUserInfo
@ -139,7 +139,8 @@ var Wechat = Ctr{
this.Session("wechatInfo", wechatInfo)
this.Display(0, 1)
//this.Display(0, 1)
this.Display(0, Map{"type": 1, "token": this.SessionId})
},
//网页签名
"sign": func(this *Context) {

View File

@ -49,5 +49,6 @@
"sessionName": "HOTIME",
"tpt": "tpt",
"wechatAppID": "wx2edb802f5c3ae1ae",
"wechatAppSecret": "4ff97e523c3de6bad47051b568522386"
"wechatAppSecret": "4ff97e523c3de6bad47051b568522386",
"wxFilePath": "wxfile/2006/01/02/"
}

Binary file not shown.

View File

@ -23,7 +23,8 @@ func main() {
notNeedLogin := []string{"login", "test", "auth", "upload"} //不需要登录的操作
//RESTfull接口适配
appIns.SetConnectListener(func(context *hotime.Context) bool {
if context.RouterString[0] == "admin" {
if len(context.RouterString) > 0 && context.RouterString[0] == "admin" {
return true
}
//判断是否需要登录不需要登录则直接执行mtd

View File

@ -1,3 +1,3 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title></title><style>body{
margin: 0px;
}</style><link href="css/chunk-2b8aef56.7087d841.css" rel="prefetch"><link href="css/chunk-38db7d04.2b6ce0ac.css" rel="prefetch"><link href="css/chunk-5c99f384.31e35517.css" rel="prefetch"><link href="css/chunk-60f282ff.83752cba.css" rel="prefetch"><link href="css/chunk-a74869b6.c460e209.css" rel="prefetch"><link href="css/chunk-d1a9ebe6.5cc24c46.css" rel="prefetch"><link href="js/chunk-28c289a1.0ed6fefe.js" rel="prefetch"><link href="js/chunk-2b8aef56.8330998b.js" rel="prefetch"><link href="js/chunk-2c065dd6.d9c3e429.js" rel="prefetch"><link href="js/chunk-38db7d04.18ee879a.js" rel="prefetch"><link href="js/chunk-58db4e7f.c298e695.js" rel="prefetch"><link href="js/chunk-5c99f384.be52d852.js" rel="prefetch"><link href="js/chunk-60f282ff.cbb91cc0.js" rel="prefetch"><link href="js/chunk-78ba61e2.520b239c.js" rel="prefetch"><link href="js/chunk-a74869b6.01e5db7b.js" rel="prefetch"><link href="js/chunk-d1a9ebe6.fba0f501.js" rel="prefetch"><link href="css/app.5e2eb449.css" rel="preload" as="style"><link href="js/app.c87636c4.js" rel="preload" as="script"><link href="css/app.5e2eb449.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but hotime doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/app.c87636c4.js"></script></body></html>
}</style><link href="css/chunk-04e35d82.5cc24c46.css" rel="prefetch"><link href="css/chunk-10a72523.993d1e17.css" rel="prefetch"><link href="css/chunk-1968ce68.26f55e87.css" rel="prefetch"><link href="css/chunk-2c0b72c6.f9cf649c.css" rel="prefetch"><link href="css/chunk-3d8462ce.26cbd584.css" rel="prefetch"><link href="css/chunk-6feafdad.c460e209.css" rel="prefetch"><link href="js/chunk-04e35d82.054c5f8b.js" rel="prefetch"><link href="js/chunk-10a72523.f9d2509e.js" rel="prefetch"><link href="js/chunk-1968ce68.99a1cb89.js" rel="prefetch"><link href="js/chunk-2c0b72c6.fa1690a2.js" rel="prefetch"><link href="js/chunk-3d8462ce.ac9d69b2.js" rel="prefetch"><link href="js/chunk-6feafdad.545f8201.js" rel="prefetch"><link href="js/chunk-78ba61e2.520b239c.js" rel="prefetch"><link href="js/chunk-a2efa204.7909c937.js" rel="prefetch"><link href="js/chunk-d83135a2.4680b3b0.js" rel="prefetch"><link href="css/app.5e2eb449.css" rel="preload" as="style"><link href="js/app.a381d207.js" rel="preload" as="script"><link href="css/app.5e2eb449.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but hotime doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/app.a381d207.js"></script></body></html>

View File

@ -3,23 +3,25 @@
<head>
<meta charset="UTF-8">
<title>微信登录</title>
<script type="text/javascript" src="js/hotime.js" ></script>
<script type="text/javascript" src="js/hotime.js"></script>
</head>
<body>
<script>
H.post("app/wechat/code",{"code":H.getParam("code")},function (res) {
if(res.statu==0){
if(res.result==0){
H.upUrl("wx/index.html");
}else {
H.upUrl("wx/register.html");
H.post("app/wechat/code", {"code": H.getParam("code")}, function (res) {
if (res.status != 0) {
alert(res.result.msg)
return
}
return;
localStorage.setItem("token", res.result.token)
if (res.result.type == 0) {
H.upUrl("wx/");
} else {
H.upUrl("wx/#/companyone");
}
alert(res.result.type)
})
</script>
</body>
</html>