|
@@ -24,22 +24,27 @@ type Share struct {
|
|
|
shareLogs xweb.Mapper `xweb:"/share/shareLogs"` //分享记录日志
|
|
|
}
|
|
|
|
|
|
+//1000:请求方式有误;1001:需要登录;1002:缺失参数;1003:无效参数;1004:没有权限
|
|
|
+var error_code = []int{1000, 1001, 1002, 1003, 1004}
|
|
|
+var error_msg = []string{"请求方式有误", "需要登录", "缺失参数", "无效参数", "没有权限"}
|
|
|
+
|
|
|
//
|
|
|
func init() {
|
|
|
xweb.AddAction(&Share{})
|
|
|
}
|
|
|
|
|
|
-var METHOD = "POST"
|
|
|
+var METHOD = "GET"
|
|
|
|
|
|
//所有产品信息 和 所属产品得个人分销统计
|
|
|
func (this *Share) ProductInfo() error {
|
|
|
defer util.Catch()
|
|
|
res := map[string]interface{}{
|
|
|
- "flag": false,
|
|
|
- "msg": "请求方式有误",
|
|
|
+ "error_code": error_code[0],
|
|
|
+ "error_msg": error_msg[0],
|
|
|
}
|
|
|
if this.Method() == METHOD {
|
|
|
- res["msg"] = "未登录"
|
|
|
+ res["error_msg"] = error_msg[1]
|
|
|
+ res["error_code"] = error_code[1]
|
|
|
userId, _ := this.Session().Get("userId").(string)
|
|
|
if userId != "" {
|
|
|
if p_data, ok := MQFW.Find("dis_product", nil, `{"l_createdate":1}`, nil, false, -1, -1); ok && p_data != nil {
|
|
@@ -60,11 +65,11 @@ func (this *Share) ProductInfo() error {
|
|
|
}
|
|
|
}
|
|
|
res["data"] = *p_data
|
|
|
- res["msg"] = ""
|
|
|
- res["flag"] = true
|
|
|
} else {
|
|
|
log.Println("查询产品信息报错")
|
|
|
}
|
|
|
+ res["error_msg"] = ""
|
|
|
+ res["error_code"] = 0
|
|
|
}
|
|
|
}
|
|
|
this.ServeJson(res)
|
|
@@ -107,9 +112,11 @@ func analyseWord(discored string) (name, url, appUrl, shareNickname string) {
|
|
|
func (this *Share) GetWordInfo() {
|
|
|
defer util.Catch()
|
|
|
res := map[string]interface{}{
|
|
|
- "flag": false,
|
|
|
- "msg": "请求方式有误",
|
|
|
- "isLogin": false,
|
|
|
+ "error_code": error_msg[0],
|
|
|
+ "error_msg": error_msg[0],
|
|
|
+ "data": map[string]interface{}{
|
|
|
+ "isLogin": false,
|
|
|
+ },
|
|
|
}
|
|
|
if this.Method() == METHOD {
|
|
|
isLogin := false
|
|
@@ -122,13 +129,16 @@ func (this *Share) GetWordInfo() {
|
|
|
ct_one := strings.Split(copyTxt, ":")[1]
|
|
|
discored := strings.Split(ct_one, ",")[0]
|
|
|
if discored != "" {
|
|
|
- res = CopyInfo(discored)
|
|
|
- res["isLogin"] = isLogin
|
|
|
+ res_ := CopyInfo(discored)
|
|
|
+ res_["isLogin"] = isLogin
|
|
|
+ res["data"] = res_
|
|
|
+ res["error_code"] = 0
|
|
|
+ res["error_msg"] = ""
|
|
|
} else {
|
|
|
- res["msg"] = "口令有误"
|
|
|
+ res["error_msg"] = error_msg[2]
|
|
|
}
|
|
|
} else {
|
|
|
- res["msg"] = "接受内容有误"
|
|
|
+ res["error_msg"] = error_msg[2]
|
|
|
}
|
|
|
}
|
|
|
this.ServeJson(res)
|
|
@@ -148,13 +158,10 @@ func CopyInfo(discored string) (res map[string]interface{}) {
|
|
|
}
|
|
|
}
|
|
|
res = map[string]interface{}{
|
|
|
- "flag": true,
|
|
|
- "msg": map[string]interface{}{
|
|
|
- "shareNickname": shareNickname, //昵称
|
|
|
- "modular": name, //产品名称
|
|
|
- "appUrl": appUrl, //跳转链接
|
|
|
- "imgUrl": imgUrl + "?v=" + strconv.FormatInt(time.Now().Unix(), 10), //产品图片
|
|
|
- },
|
|
|
+ "shareNickname": shareNickname, //昵称
|
|
|
+ "modular": name, //产品名称
|
|
|
+ "appUrl": appUrl, //跳转链接
|
|
|
+ "imgUrl": imgUrl + "?v=" + strconv.FormatInt(time.Now().Unix(), 10), //产品图片
|
|
|
}
|
|
|
}
|
|
|
return
|
|
@@ -164,8 +171,8 @@ func CopyInfo(discored string) (res map[string]interface{}) {
|
|
|
func (this *Share) GetWordShare() {
|
|
|
defer util.Catch()
|
|
|
res := map[string]interface{}{
|
|
|
- "flag": false,
|
|
|
- "msg": "请求方式有误",
|
|
|
+ "error_code": error_code[0],
|
|
|
+ "error_msg": error_msg[0],
|
|
|
}
|
|
|
if this.Method() == METHOD {
|
|
|
//模块 A:超级订阅 B:数据导出 C:数据报告等
|
|
@@ -173,28 +180,30 @@ func (this *Share) GetWordShare() {
|
|
|
if modular != "" {
|
|
|
userId, _ := this.GetSession("userId").(string)
|
|
|
if userId != "" {
|
|
|
+ s_nickname, _ := this.GetSession("s_nickname").(string)
|
|
|
word := redis.GetStr("other", "DIS_"+userId)
|
|
|
- if word != "" {
|
|
|
- res["msg"] = word
|
|
|
- } else {
|
|
|
- s_nickname, _ := this.GetSession("s_nickname").(string)
|
|
|
- v := VarLSCPool.GetJob()
|
|
|
- res["msg"] = map[string]interface{}{
|
|
|
- "disWord": modular + v, //口令
|
|
|
- "shareLink": Sysconfig.Webdomain + "/F/" + modular + v, //微信分享链接
|
|
|
- "erUrl": Sysconfig.Webdomain + "/wx/yjmstr/DIS_" + modular + v, //二维码地址
|
|
|
- }
|
|
|
+ if word == "" {
|
|
|
+ word = VarLSCPool.GetJob()
|
|
|
//用户昵称存redis app粘贴时备用
|
|
|
- redis.Put("other", "DIS_"+v, s_nickname+"##"+userId, -1)
|
|
|
+ redis.Put("other", "DIS_"+word, s_nickname+"##"+userId, -1)
|
|
|
//用户信息绑定分享口令
|
|
|
- redis.Put("other", "DIS_"+userId, modular+v, -1)
|
|
|
+ redis.Put("other", "DIS_"+userId, modular+word, -1)
|
|
|
+ word = modular + word
|
|
|
+ }
|
|
|
+ res["data"] = map[string]interface{}{
|
|
|
+ "disWord": word, //口令
|
|
|
+ "shareLink": Sysconfig.Webdomain + "/F/" + word, //微信分享链接
|
|
|
+ "erUrl": Sysconfig.Webdomain + "/wx/yjmstr/DIS_" + word, //二维码地址
|
|
|
}
|
|
|
- res["flag"] = true
|
|
|
+ res["error_code"] = 0
|
|
|
+ res["error_msg"] = ""
|
|
|
} else {
|
|
|
- res["msg"] = "未登录"
|
|
|
+ res["error_msg"] = error_msg[1]
|
|
|
+ res["error_code"] = error_code[1]
|
|
|
}
|
|
|
} else {
|
|
|
- res["msg"] = "缺少参数"
|
|
|
+ res["error_msg"] = error_msg[2]
|
|
|
+ res["error_code"] = error_code[2]
|
|
|
}
|
|
|
}
|
|
|
this.ServeJson(res)
|