js动态添加

大家先看看页面效果吧,当当当当“““““““““““`

在PB实现支付宝当面付的功能,需要先在支付宝进行商户签约,并设置相关的公钥信息(具体参考支付宝文档)。

一、背景

betway必威亚洲官网 1

betway必威亚洲官网,然后使用对应的私钥文件对参数进RSAWithSha1前面计算。具体代码如下:

json是一种轻量级数据交换格式,非常利于java服务与js的交互,本文将介绍json的简单定义和js如何解析json。

图中第二个选题是小颖点击了”新增选题”按钮,然后出来的,当你点击了”删除选项”或”删除选题”按钮,就会删除相应的选项和选题.

string ls_pubFileName,ls_priFileName
n_pbfunc_cryp lnv_cryp
ls_priFileName ="D:\pbfunclib_pri.pem"//私钥文件
string ls_str
string ls_appId,ls_secret,ls_biz_content
ls_appId ="3434343"//改成你的appid
ls_biz_content='{"out_trade_no": "2015020011","scene": "bar_code","auth_code": "'+sle_1.Text+'","subject": "当面付条码支付","total_amount": "0.01"}'
ls_str ="app_id="+ls_appId
ls_str +='&biz_content='+ls_biz_content
ls_str +='&charset=utf-8'
ls_str +='&method=alipay.trade.pay'
ls_str +='&sign_type=RSA'
ls_str +='&timestamp=2016-05-08 11:27:15'
ls_str +='&version=1.0'
string ls_sigStr
blob utf8R
utf8R =lnv_cryp.of_str2utf8(ls_str)
if lnv_cryp.of_sha1withRsa(ls_priFileName,utf8R,lnv_cryp.HASH_RESULT_DEFAULT,ls_sigStr) then
  MessageBox("提示","签名成功:"+ls_sigStr)
Else
  MessageBox("提示","签名失败")
end if
/*验证签名可以不需要调用*/
ls_pubFileName ="D:\pbfunclib_pub.pem"//在D盘生成公钥文件pbfunclib_pub.pem
IF Not lnv_cryp.of_RSAVerifyFileSHA1(ls_pubFileName,utf8R,ls_sigStr,lnv_cryp.HASH_RESULT_DEFAULT) Then
  MessageBox("提示","验证签名失败")
else
  messagebox("","验证签名成功")
End IF
//ls_str +=''
n_pbfunc_http lnv_http
lnv_http.of_clear()//清空参数
string ls_data
ls_data = "app_id="+wf_alipay_urlencode(ls_appId)
ls_data += "&biz_content="+wf_alipay_urlencode(ls_biz_content)
ls_data += "&charset="+wf_alipay_urlencode("utf-8")
ls_data += "&method="+wf_alipay_urlencode("alipay.trade.pay")
ls_data += "&sign_type="+wf_alipay_urlencode("RSA")
ls_data += "&sign="+wf_alipay_urlencode(ls_sigStr)
ls_data += "&timestamp="+wf_alipay_urlencode("2016-05-08 11:27:15")
ls_data += "&version="+wf_alipay_urlencode("1.0")
lnv_http.of_set_URL("https://openapi.alipay.com/gateway.do?"+ls_data)
Blob lblb_data
string ls_error
IF lnv_http.of_post(lblb_data,ls_error) Then
  string gbkData
  gbkData = lnv_cryp.of_utf8ToGbk(lblb_data)//由于返回来的是utf-8编码,直接显示会乱码
  MessageBox("提示",gbkData+" "+string(lblb_data))
Else
  MessageBox("提示","执行失败")
End IF

二、内容

html代码

  其中wf_alipay_urlencode函数代码如下:

1、json定义:

<template>
<div class="main-container">
<div class="form-horizontal">
<template v-for='(subjectIndex,subject) in question'>
<div class="form-group">
<label class="col-sm-1 control-label">选题:</label>
<label class="col-sm-2 control-label red remove-pad" v-if='$index>0' @click='deleteSubjectFun(subjectIndex)'>删除选题</label>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">标题:</label>
<div class="col-sm-2">
<input type="text" class="form-control" placeholder="未填写" v-model='subject.title'>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">正确答案:</label>
<div class="col-sm-1">
<input type="text" class="form-control answer" placeholder="未填写" readonly="true" v-model='subject.answer'>
</div>
请在以下选项中,勾选出正确答案
</div>
<div class="form-group">
<label class="col-sm-1 control-label">分值:</label>
<div class="col-sm-1">
<input type="number" min="1" max="100" class="form-control" v-model='subject.score' @keyup='scoreFun(subjectIndex)'>
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">选项:</label>
</div>
<div class="form-group">
<div class="col-sm-3 mg1">
<ul class="upper-latin">
<template v-for='(opdtIndex,opdt) in subject.optionsData'>
<li>
<input type="checkbox" class="checkbox-answer" v-model='subject.answer' value='{{opdt.id}}'>
<div class="options-div">
<input type="text" class="form-control options-input" placeholder="未填写" v-model='opdt.options'>
<label class="control-label blue remove-pad" v-if='opdtIndex==subject.optionsData.length-1' @click='addNewOptionsFun(subjectIndex,opdtIndex)'>新增选项</label>
<label class="control-label red remove-pad" v-if='opdtIndex>0' @click='deleteOptionsFun(subjectIndex,opdtIndex)'>删除选项</label>
</div>
</li>
</template>
</ul>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-4">
<button class="blue boder" @click='addNewSubjectFun(subjectIndex)'>新增选题</button>
</div>
</div>
<div class='split-line'></div>
</template>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-4">
<button class="btn btn-primary" @click='saveQuestionFun'>提交</button>
</div>
</div>
</div>
</div>
</template>
//ls_str为参数
n_pbfunc_encode lnv_encode
string ls_content,ls_reserved//指明不需要编码的字符
ls_reserved =""//都需要编码
string ls_sigStr
blob utf8R
utf8R =lnv_encode.of_str2utf8(ls_str)
lnv_encode.of_URIEncode2(utf8R,ls_content)
return ls_content

简单的json格式为[{“key1″:”value1”},{“key2″:”value2”}],

js代码

以上所述是小编给大家介绍的使用PBFunc在Powerbuilder中支付宝当面付款功能,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复的。

[]代表数组,{}代表数组中的数据对象,key1,key2是一个json对象中的key,一个json中key值唯一,value1,value2,是key键对应的值。

<script>
export default {
components: {
},
props: {},
methods: {
// 新增选题
addNewSubjectFun: function(index) {
var subjectDataMes = {};
subjectDataMes.id = index+2;
subjectDataMes.title = '';
subjectDataMes.answer =[];
subjectDataMes.score = 10;
subjectDataMes.optionsData = [{
id: 'A',
options: ''
}];
this.question.push(subjectDataMes);
},
// 判断每个题目的分值不能小于零且不能大于一百
scoreFun:function(index){
if(this.question[index].score<0){
this.question[index].score=10;
this.$root.tipStr = '选题"'+this.question[index].title+'"的分值不能小于零';
}else if(this.question[index].score>100){
this.question[index].score=10;
this.$root.tipStr = '选题"'+this.question[index].title+'"的分值不能大于一百';
}
},
// 删除选题
deleteSubjectFun: function(index) {
this.question.splice(index, 1);
},
// 新增选项
addNewOptionsFun: function(subjectIndex, opdtIndex) {
var optionsDataMes = {};
optionsDataMes.id =String.fromCharCode(64 + (opdtIndex+2)); //将id从数字转换成大写字母.
optionsDataMes.options = '';
var subjectDataMes = this.question[subjectIndex].optionsData;
subjectDataMes.push(optionsDataMes);
},
// 删除选项
deleteOptionsFun: function(subjectIndex, opdtIndex) {
var subjectDataMes = this.question[subjectIndex].optionsData;
subjectDataMes.splice(opdtIndex, 1);
},
saveQuestionFun:function(){
this.question;debugger;
}
},
ready: function() {
},
data() {
return {
question: [{
id: 1,
title: '',
answer: [],
score:10,
optionsData: [{
id: 'A',
options: ''
}],
}],
}
}
}
</script>

您可能感兴趣的文章:

  • powerbuilder(pb)中
    xml的应用一例

定义方式:

css代码

1)直接拼写json串,例:String变量,内容为[{“attchName”:”附件0″,”attchId”:0},{“attchName”:”附件1″,”attchId”:1},{“attchName”:”附件2″,”attchId”:2}]。

<style scoped>
.mg1 {
padding: 8px 0 0 113px;
}
.upper-latin {
list-style-type: upper-latin;
}
input.form-control.options-input {
display: inline-block; /*width: 499.16px;*/
width: 100%;
}
.boder {
border: 1px solid;
background-color: #fff;
border-radius: 4px;
line-height: 34px;
padding: 0 15px;
}
.blue {
color: #2689cd;
text-align: center;
}
label.red {
color: #c9302c;
}
label.remove-pad {
/*padding: 10px 20px 10px 15px;*/
line-height: 34px;
text-align: left;
}
.split-line {
height: 10px;
border-top: 2px dashed #E7E8EC;
width: 900px;
}
.prompting-message {
line-height: 34px;
}
.options-div {
margin-left: 26px;
margin-top: -25px;
padding-bottom: 25px;
}
</style>

2)引入json-lib.jar开源jar包,定义JSONObject对象,例:

发表评论

电子邮件地址不会被公开。 必填项已用*标注

标签:

相关文章

网站地图xml地图