跳转传值
- 先看数据传递 *
<radio class='clickeds' value="{{item}}***{{index}}***{{hotList[index].id}}" checked="{{item.checked}}"/>
radioChange: function (e) {
console.log('radio发生change事件,携带value值为:', e.detail.value)
this.checkCard = e.detail.value;
var that = this;
that.setData({
botCardPrize: e.detail.value.split("&")[0]
});
},
topay:function(){
var that = this;
console.log( "选中的会员卡金额为: " + that.data.botCardPrize);
wx.navigateTo({ url: "../../pages/buyCard/buyCard?price=" + this.checkCard.split("&")[0] + "&name=" + this.checkCard.split("&")[1] + "&productId=" + this.checkCard.split("&")[2] + "&type=" + this.giftCard })
}
在这里radio先选中,然后赋值给data中的checkCard,然后点击付款按钮的时候进行传值并且跳转到付款页
在新页面接收数据
onLoad: function (options) {
let thisPrice = options.price*100;
let productName = options.name;
let id = options.productId;
let type = options.type;
let toPay = {
thisPrice: thisPrice,
productName: productName,
id: id,
type: type
};
this.payInfo = toPay;
},
option后面跟链接中的对应键解出值,组合成新的数据对象