create_diy_menu_for_moniApp.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. import sys
  4. from base import init_env, setup_logger, get_logger
  5. init_env(interactive = True)
  6. if len(sys.argv) < 2:
  7. logger = get_logger(__name__)
  8. else:
  9. logger = setup_logger(filename = sys.argv[1], namespace = __name__)
  10. from apps.web.core.models import WechatAuthApp
  11. from apps.web.core.bridge.wechat import WechatClientProxy
  12. appId = 'wxf5425406cad19690'
  13. secret = '133107adb7015e6bac5474fcd9dd98cc'
  14. grzx = {
  15. 'type': 'view',
  16. 'name': u'个人中心',
  17. 'url': "http://www.washpayer.com/user/moniUserAccess?moniAppId=%s&redirect=%s" % (appId,'gerenzhongxin')
  18. }
  19. dangqianfuwu = {
  20. 'type': 'view',
  21. 'name': u'当前服务',
  22. 'url': "http://www.washpayer.com/user/moniUserAccess?moniAppId=%s&redirect=%s" % (appId,'dangqianfuwu')
  23. }
  24. changjianwenti = {
  25. 'type': 'view',
  26. 'name': u'常见问题',
  27. 'url': "http://www.washpayer.com/user/moniUserAccess?moniAppId=%s&redirect=%s" % (appId,'changjianwenti')
  28. }
  29. baogaolaoban = {
  30. 'type': 'view',
  31. 'name': u'报告老板',
  32. 'url': "http://www.washpayer.com/user/moniUserAccess?moniAppId=%s&redirect=%s" % (appId,'baogaolaoban')
  33. }
  34. qitawenti = {
  35. 'type': 'view',
  36. 'name': u'其他问题',
  37. 'url': "http://www.washpayer.com/user/moniUserAccess?moniAppId=%s&redirect=%s" % (appId,'baogaolaoban')
  38. }
  39. zbsb = {
  40. 'type': 'view',
  41. 'name': u'周边设备',
  42. 'url': "http://www.washpayer.com/user/moniUserAccess?moniAppId=%s&redirect=%s" % (appId,'zhoubianshebei')
  43. }
  44. toushushouli = {
  45. 'type': 'view',
  46. 'name': u'投诉受理',
  47. 'url': "http://www.washpayer.com/user/moniUserAccess?moniAppId=%s&redirect=%s" % (appId,'toushushouli')
  48. }
  49. menu = {
  50. "button":
  51. [
  52. {
  53. "name": u"服务&投诉",
  54. "sub_button": [dangqianfuwu,changjianwenti,baogaolaoban,toushushouli]
  55. },
  56. {
  57. "type": "scancode_push",
  58. "name": u"扫一扫",
  59. "key": "rselfmenu_0_1",
  60. "sub_button": []
  61. },
  62. grzx
  63. ]
  64. }
  65. app = WechatAuthApp(appid = appId,secret = secret)
  66. proxy = WechatClientProxy(app)
  67. print proxy.client.menu.create(menu)