yujian
2020-05-09 7e7db2fa55a9a3af46d4fd8ede0dee147f101d64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.yeshi.fanli.service.impl.config;
 
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.service.inter.config.WXGZService;
import com.yeshi.fanli.util.Constant;
import org.yeshi.utils.wx.WXUtil;
 
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
 
@Service
public class WXGZServiceImpl implements WXGZService {
    @Override
    public void initMenu() {
        String appId = Constant.systemCommonConfig.getWxGZAppId();
        String appSecret = Constant.systemCommonConfig.getWxGZAppSecret();
        String accessToken = WXUtil.getAcessToken(appId, appSecret);
        JSONObject root = new JSONObject();
        JSONArray items = new JSONArray();
        JSONObject data1 = new JSONObject();
        data1.put("type", "view");
        data1.put("name", "下载" + Constant.systemCommonConfig.getProjectChineseName());
        data1.put("url", Constant.wxGZConfig.getAppDownloadLink());
        items.add(data1);
 
        data1 = new JSONObject();
        data1.put("type", "view");
        data1.put("name", "领取优惠券");
        data1.put("url", Constant.wxGZConfig.getH5Url());
        items.add(data1);
 
        data1 = new JSONObject();
        data1.put("type", "view");
        data1.put("name", "帮助中心");
        data1.put("url", Constant.wxGZConfig.getHelpUrl());
        items.add(data1);
 
        root.put("button", items);
        WXUtil.createMenu(accessToken, root);
    }
 
}