CustomMenuCreate.cshtml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. @page
  2. @model CustomMenuCreateModel
  3. @{
  4. ViewData["Title"] = "自定义菜单创建";
  5. }
  6. <div class="row-fluid">
  7. <h3 class="page-title">@ViewData["Title"]</h3>
  8. </div>
  9. <div class="row-fluid">
  10. <div class="span12">
  11. <div class="span3">
  12. <ul class="ver-inline-menu tabbable margin-bottom-10">
  13. @*<li class="active">
  14. <a href="#tab_1" data-toggle="tab">
  15. </a>
  16. <span class="after"></span>
  17. </li>*@
  18. <li><a href="#tab_1" data-toggle="tab"><i class="icon-plus active"></i> 创建一个Click菜单</a></li>
  19. <li class=""><a href="#tab_2" data-toggle="tab"><i class="icon-plus"></i> 创建一个View菜单</a></li>
  20. <li class=""><a href="#tab_3" data-toggle="tab"><i class="icon-plus"></i> 创建一个扫一扫菜单</a></li>
  21. <li class=""><a href="#tab_4" data-toggle="tab"><i class="icon-plus"></i> 创建一个扫一扫等待菜单</a></li>
  22. <li class=""><a href="#tab_5" data-toggle="tab"><i class="icon-plus"></i> 创建一个拍照菜单</a></li>
  23. <li class=""><a href="#tab_6" data-toggle="tab"><i class="icon-plus"></i> 创建一个拍照或相册菜单</a></li>
  24. <li class=""><a href="#tab_7" data-toggle="tab"><i class="icon-plus"></i> 创建一个微信相册菜单</a></li>
  25. <li class=""><a href="#tab_8" data-toggle="tab"><i class="icon-plus"></i> 创建一个地理位置菜单</a></li>
  26. <li class=""><a href="#tab_9" data-toggle="tab"><i class="icon-plus"></i> 创建一个媒体素材菜单</a></li>
  27. <li class=""><a href="#tab_10" data-toggle="tab"><i class="icon-plus"></i> 创建一个图文消息菜单</a></li>
  28. <li class=""><a href="#tab_11" data-toggle="tab"><i class="icon-plus"></i> 创建一个小程序菜单</a></li>
  29. <li class=""><a href="#tab_12" data-toggle="tab"><i class="icon-plus"></i> 创建一个一组菜单</a></li>
  30. </ul>
  31. </div>
  32. <div class="span9">
  33. <div class="tab-content">
  34. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  35. {
  36. Index = 1,
  37. IsActive = true,
  38. Code = () =>
  39. {
  40. return @"
  41. var request = new MenuCreateRequest
  42. {
  43. AccessToken = AccessToken,
  44. Buttons = new List<ClickButton>
  45. {
  46. new ClickButton{
  47. Name = ""今日歌曲"",
  48. Key = ""V1001_TODAY_MUSIC"",
  49. Type = ClickButtonType.click
  50. }
  51. }
  52. };
  53. var response = _clientExecute(request);";
  54. }
  55. })
  56. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  57. {
  58. Index = 2,
  59. Code = () =>
  60. {
  61. return @"
  62. var request = new MenuCreateRequest
  63. {
  64. AccessToken = AccessToken,
  65. Buttons = new List<ClickButton>
  66. {
  67. new ClickButton{
  68. Name = ""我的博客"",
  69. Url = ""http://inday.cnblogs.com"",
  70. Type = ClickButtonType.view
  71. }
  72. }
  73. };
  74. var response = _clientExecute(request);";
  75. }
  76. })
  77. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  78. {
  79. Index = 3,
  80. Code = () =>
  81. {
  82. return @"
  83. var request = new MenuCreateRequest
  84. {
  85. AccessToken = AccessToken,
  86. Buttons = new List<ClickButton>
  87. {
  88. new ClickButton{
  89. Name = ""扫码推事件"",
  90. Key = ""rselfmenu_0_1"",
  91. Type = ClickButtonType.scancode_push
  92. }
  93. }
  94. };
  95. var response = _clientExecute(request);";
  96. }
  97. })
  98. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  99. {
  100. Index = 4,
  101. Code = () =>
  102. {
  103. return @"
  104. var request = new MenuCreateRequest
  105. {
  106. AccessToken = AccessToken,
  107. Buttons = new List<ClickButton>
  108. {
  109. new ClickButton{
  110. Name = ""扫码带提示"",
  111. Key = ""rselfmenu_0_0"",
  112. Type = ClickButtonType.scancode_waitmsg
  113. }
  114. }
  115. };
  116. var response = _clientExecute(request);";
  117. }
  118. })
  119. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  120. {
  121. Index = 5,
  122. Code = () =>
  123. {
  124. return @"
  125. var request = new MenuCreateRequest
  126. {
  127. AccessToken = AccessToken,
  128. Buttons = new List<ClickButton>
  129. {
  130. new ClickButton{
  131. Name = ""系统拍照发图"",
  132. Key = ""rselfmenu_1_0"",
  133. Type = ClickButtonType.pic_sysphoto
  134. }
  135. }
  136. };
  137. var response = _clientExecute(request);";
  138. }})
  139. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  140. {
  141. Index = 6,
  142. Code = () =>
  143. {
  144. return @"
  145. var request = new MenuCreateRequest
  146. {
  147. AccessToken = AccessToken,
  148. Buttons = new List<ClickButton>
  149. {
  150. new ClickButton{
  151. Name = ""拍照或者相册发图"",
  152. Key = ""rselfmenu_1_1"",
  153. Type = ClickButtonType.pic_photo_or_album
  154. }
  155. }
  156. };
  157. var response = _clientExecute(request);";
  158. }
  159. })
  160. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  161. {
  162. Index = 7,
  163. Code = () =>
  164. {
  165. return @"
  166. var request = new MenuCreateRequest
  167. {
  168. AccessToken = AccessToken,
  169. Buttons = new List<ClickButton>
  170. {
  171. new ClickButton{
  172. Name = ""微信相册发图"",
  173. Key = ""rselfmenu_1_2"",
  174. Type = ClickButtonType.pic_weixin
  175. }
  176. }
  177. };
  178. var response = _clientExecute(request);";
  179. }
  180. })
  181. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  182. {
  183. Index = 8,
  184. Code = () =>
  185. {
  186. return @"
  187. var request = new MenuCreateRequest
  188. {
  189. AccessToken = AccessToken,
  190. Buttons = new List<ClickButton>
  191. {
  192. new ClickButton{
  193. Name = ""发送位置"",
  194. Key = ""rselfmenu_2_0"",
  195. Type = ClickButtonType.location_select
  196. }
  197. }
  198. };
  199. var response = _clientExecute(request);";
  200. }
  201. })
  202. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  203. {
  204. Index = 9,
  205. Code = () =>
  206. {
  207. return @"
  208. var request = new MenuCreateRequest
  209. {
  210. AccessToken = AccessToken,
  211. Buttons = new List<ClickButton>
  212. {
  213. new ClickButton{
  214. Name = ""图片"",
  215. Media_Id = ""MEDIA_ID1"",
  216. Type = ClickButtonType.media_id
  217. }
  218. }
  219. };
  220. var response = _clientExecute(request);";
  221. }
  222. })
  223. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  224. {
  225. Index = 10,
  226. Code = () =>
  227. {
  228. return @"
  229. var request = new MenuCreateRequest
  230. {
  231. AccessToken = AccessToken,
  232. Buttons = new List<ClickButton>
  233. {
  234. new ClickButton{
  235. Name = ""图文消息"",
  236. Media_Id = ""MEDIA_ID2"",
  237. Type = ClickButtonType.view_limited
  238. }
  239. }
  240. };
  241. var response = _clientExecute(request);";
  242. }
  243. })
  244. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  245. {
  246. Index = 11,
  247. Code = () =>
  248. {
  249. return @"
  250. var request = new MenuCreateRequest
  251. {
  252. AccessToken = AccessToken,
  253. Buttons = new List<ClickButton>
  254. {
  255. new ClickButton{
  256. Name = ""小程序"",
  257. Url = ""http://mp.weixin.qq.com"",
  258. MiniProgramAppId = ""wx286b93c14bbf93aa"",
  259. MiniProgramPagePath = ""pages/lunar/index"",
  260. Type = ClickButtonType.miniprogram
  261. }
  262. }
  263. };
  264. var response = _clientExecute(request);";
  265. }
  266. })
  267. @Html.Partial("~/Pages/Partials/CodePartail.cshtml", new SupplierWeb.Pages.Partials.CodePartailModel
  268. {
  269. Index = 12,
  270. ShowTestButtons = true,
  271. Api = "/api/menucreate",
  272. Code = () =>
  273. {
  274. return @"
  275. var request = new MenuCreateRequest
  276. {
  277. AccessToken = AccessToken,
  278. Buttons = new List<ClickButton>
  279. {
  280. new ClickButton
  281. {
  282. Type = ClickButtonType.click,
  283. Name = ""关注我"",
  284. Key = ""Key_Follow_Me""
  285. },
  286. new ClickButton
  287. {
  288. Type = ClickButtonType.view,
  289. Url = ""http://inday.cnblogs.com"",
  290. Name = ""我的博客""
  291. },
  292. new ClickButton
  293. {
  294. Name=""主菜单"",
  295. SubButton = new List<ClickButton>
  296. {
  297. new ClickButton
  298. {
  299. Type = ClickButtonType.scancode_push,
  300. Name = ""扫一扫"",
  301. Key = ""Event_Scan""
  302. },
  303. new ClickButton
  304. {
  305. Type = ClickButtonType.pic_sysphoto,
  306. Name = ""系统拍照发图"",
  307. Key = ""Event_SysPhoto""
  308. },
  309. new ClickButton
  310. {
  311. Type = ClickButtonType.pic_weixin,
  312. Name = ""微信相册发图"",
  313. Key = ""Event_Pic_WeiXin""
  314. },
  315. new ClickButton
  316. {
  317. Type = ClickButtonType.location_select,
  318. Name = ""发送位置"",
  319. Key = ""Event_Location_Select""
  320. },
  321. new ClickButton
  322. {
  323. Type = ClickButtonType.miniprogram,
  324. Name = ""我的小程序"",
  325. Url =""http://inday.cnblogs.com"",
  326. MiniProgramAppId = ""wx286b93c14bbf93aa"",
  327. MiniProgramPagePath = ""pages/lunar/index""
  328. }
  329. }
  330. }
  331. }
  332. };
  333. var response = _clientExecute(request);";
  334. }
  335. })
  336. </div>
  337. </div>
  338. <!--end span9-->
  339. </div>
  340. </div>
  341. <div class="row-fluid">
  342. <div class="span12 ">
  343. <!-- BEGIN Portlet PORTLET-->
  344. <div class="portlet red box">
  345. <div class="portlet-title">
  346. <div class="caption"><i class="icon-reorder"></i>注意</div>
  347. </div>
  348. <div class="portlet-body">
  349. <div class="slimScrollDiv" style="position: relative; overflow: hidden; width: auto; height: 200px;">
  350. <div class="scroller" data-height="200px" style="overflow: hidden; width: auto; height: 200px;">
  351. <p>
  352. 1、自定义菜单最多包括3个一级菜单,每个一级菜单最多包含5个二级菜单。
  353. </p>
  354. <p>
  355. 2、一级菜单最多4个汉字,二级菜单最多7个汉字,多出来的部分将会以“...”代替。
  356. </p>
  357. <p>
  358. 3、创建自定义菜单后,菜单的刷新策略是,在用户进入公众号会话页或公众号profile页时,如果发现上一次拉取菜单的请求在5分钟以前,就会拉取一下菜单,如果菜单有更新,就会刷新客户端的菜单。测试时可以尝试取消关注公众账号后再次关注,则可以看到创建后的效果。
  359. </p>
  360. </div><div class="slimScrollBar ui-draggable" style="width: 7px; position: absolute; top: 0px; opacity: 0.4; display: none; border-radius: 7px; z-index: 99; right: 1px; height: 148.148px; background: rgb(161, 178, 189);"></div><div class="slimScrollRail" style="width: 7px; height: 100%; position: absolute; top: 0px; display: none; border-radius: 7px; opacity: 0.2; z-index: 90; right: 1px; background: rgb(51, 51, 51);"></div>
  361. </div>
  362. </div>
  363. </div>
  364. <!-- END Portlet PORTLET-->
  365. </div>
  366. </div>