zoukankan      html  css  js  c++  java
  • 微信jssdk批量展示卡包中的卡券

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport"
        content="width=device-width, user-scalable=0, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
    <c:set var="ctx" value="${pageContext.request.contextPath }" />
    <link rel="stylesheet" href="${ctx }/jsp/xte/level/static/css/load.css" />
    <title>TITLE</title>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="${ctx }/js/hideOptionMenu.js"></script>
    </head>
    <body>
        <input type="hidden" name="userId" id="userId" value="${userId }">
        <input type="hidden" id="redirect_uri" name="redirect_uri"
            value="${redirect_uri}" />
    
        <input type="hidden" id="componentAppId" name="componentAppId"
            value="${componentAppId }">
        <input type="hidden" id="appId" name="appId" value="${appId }" />
        <input type="hidden" id="code" name="code" value="${code }" />
        <input type="hidden" id="openid" name="openid" value="${openid }" />
        <c:forEach var="cardlog" items="${ wxCardPackageCodes}">
            <input type="hidden" class="cardId" name="c" 
                value="${cardlog.card_id }" />
            </br>
            <input type="hidden" class="code" name="" value="${cardlog.code }">
        </c:forEach>
        <div id="front" style="display: block; opacity: 1">
            <div class="tips">
                <div class="icon loading"></div>
                <p>加载中...</p>
            </div>
        </div>
    </body>
    <script type="text/javascript"
        src="${ctx }/js/jquery1.6/jquery-1.6.1.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script type="text/javascript">
        $(function() {
            var cardId = $(".cardId");
            var code = $(".code");
            var l = {};
            var a = [];
            var b;
            for ( var i in code) {
                if (code[i].value !== undefined) {
                    b = new Object();
                    b = {
                        cardId : "" + cardId[i].value + "",
                        code : "" + code[i].value + ""
                    };
                    a.push(b)
                }
            }
    
            var url = location.href.split('#')[0];
            var userId = $("#userId").val();
            $.post("http://www.quanqiuyouhui.com/kabao-api/getShareData.do", {
                'url' : url,
                'userId' : userId
            }, function(data) {
                data = eval("(" + data + ")");
                wx.config({
                    debug : false,
                    appId : data.map.appId,
                    timestamp : data.map.timestamp,
                    nonceStr : data.map.nonceStr,
                    signature : data.map.signature,
                    jsApiList : [ 'checkJsApi', 'onMenuShareTimeline',
                            'onMenuShareAppMessage', 'openCard' ]
                });
                wx.ready(function() {
                    wx.openCard({
                        cardList : a
                    });
    
                });
                wx.hideMenuItems({
                    menuList : [ 'menuItem:share:qq', 'menuItem:share:weiboApp',
                            'menuItem:share:email', 'menuItem:share:facebook',
                            'menuItem:share:QZone' ]
                // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
                });
    
            })
        });
    </script>
    </html>

     注:代码中标黄的部分

    cardId[i].value

    应该使用value,如果使用val()不成功

  • 相关阅读:
    appium 3-4-1034等待、日志、性能数据、xpath定位、web driver协议
    appium 3-31626 toast识别
    appium 3-31603调试分析方法
    java-appium-527 WebDriver协议&针对控件的操作
    java-appium-527进阶-1 UiAutomator1&2区别和封装
    python-appium520-2初步使用
    python-appium520-3引入unittest,编写自动化用例
    Android手机卸载第三方应用
    grub名词理解
    基于ubuntu和windows连接
  • 原文地址:https://www.cnblogs.com/dashuai01/p/4837536.html
Copyright © 2011-2022 走看看