⼩程序⽂章详情页跳转案例
index.html
<view class="container">
<view wx:for="{{cardTeams}}" wx:key="{{index}}" wx:for-item="cardTeam" class="item">
<image class="img" src="{{cardTeam.imgsrc}}" mode="scaleToFill"></image>
<view class="number-wrapper">
<text class="name">{{cardTeam.name}}</text>
<view class="count-wrapper">
<text class="count">{{unt}}</text>
</view>
<view class="details">
<navigator url="../details/details?goodsId={{index}}">查看详情</navigator>
</view>
</view>
</view>
</view>
index.wxss
.container {
padding-top: 0;
}
.item {
width: 100%;
height: 220rpx;
position: relative;
display: flex;
margin: 10rpx 10rpx;
border-bottom: 1px solid rgb(197, 199, 199);
}
.item:first-child {
margin-top: 0;
}
.item .remove {
width: 60px;
height: 100%;
background-color: red;
position: absolute;
position: absolute;
top: 0;
right: -60px;
display: flex;
justify-content: center;
align-items: center;
}
.item .number-wrapper {
padding-top: 25rpx;
flex-direction: column;
justify-content: space-between;
}
.item .ok {
width: 60px;
height: 100%;
padding-right: 20rpx;
display: flex;
justify-content: center;
align-items: center;
background-color: #98f5ff;
}
.item .img {
width: 150rpx;
height: 150rpx;
padding: 20rpx;
}
.number-wrapper .name {
margin: 10rpx 10rpx 10rpx 10rpx;
font-size: 39rpx;
overflow: hidden;
}
.number-wrapper .count-wrapper {
display: flex;
align-items: center;
margin-left: 10rpx;
font-size: 25rpx;
}
.number-wrapper .count-wrapper .decrease-btn { font-size: 30rpx;
}
.number-wrapper .count-wrapper .increase-btn { font-size: 30rpx;
}
.number-wrapper .count-wrapper .count {
margin: 0 1rpx 0 1rpx;
font-size: 30rpx;
}
.number-wrapper .price-wrapper .people {
margin-left: 250rpx;
font-size: 30rpx;
}
/* 搜索框样式 */
.view-search {
display: flex;
display: flex;
flex-direction: row;
height: 70rpx;
margin: 20rpx;
padding: 5rpx;
border: 1px #e4e2e2 solid; border-width: thin;
align-items: center;
}
.input {
flex: 1;
height: 60rpx;
}
.input-placeholder {
color: #999;
}
.button {
width: 60rpx;
height: 60rpx;
}
.details{
font-size: 36rpx;
color:red;
}
index.js
//获取应⽤实例
var app = getApp();
var cardTeams;
Page({
data: {
cardTeams: [{
"viewid": "1",
"imgsrc": "133********/image/1.png", "price": "¥1245",
"count": "为什么说 C 语⾔⽐ Java 难? ",
"name": "为什么说 C 语⾔⽐ Java 难? ",
}, {
"viewid": "2",
"imgsrc": "133********/image/1.png", "price": "¥2345",
"count": "⼩程序云开发⼊门实战总结 ",
"name": "⼩程序云开发⼊门实战总结 ",
}, {
"viewid": "3",
"imgsrc": "133********/image/3.png", "price": "¥2345",
"count": "node.js写⼀个⼩爬⾍ ",
"name": "node.js写⼀个⼩爬⾍ ",
}, {
"viewid": "4",
"imgsrc": "133********/image/3.png", "price": "¥2345",
"count": "推荐⼀个前端开源项⽬ ",
"name": "推荐⼀个前端开源项⽬ ",
}
]
},
onLoad: function () {
// console.log('onLoad:' + app.globalData.domain)
}
})
详情页⾯写文章的小程序
details.wxml
<web-view src="{{url}}"></web-view>
details.js
data: {
url:'',
//下⾯是先进⾏存储的不同产品数据;
productsList: [
{ showDesc: 'mp.weixin.qq/s?__biz=MzI2ODUxMzg4Nw==&mid=2247485838&idx=1&sn=1208bcca91141b2c16c2e844efb67a41&chksm=eaef2eb
{ showDesc: 'mp.weixin.qq/s?__biz=MzI2ODUxMzg4Nw==&mid=2247485869&idx=1&sn=7e4cedf5230c930cf18c9aa4683d1a43&chksm=eaef2e9d {showDesc: 'mp.weixin.qq/s?__biz=MzI2ODUxMzg4Nw==&mid=2247485900&idx=1&sn=5aa1e6028f6499a611fff1ec2a641bf6&chksm=eaef2efcdd { showDesc: 'mp.weixin.qq/s?__biz=MzI2ODUxMzg4Nw==&mid=2247485848&idx=1&sn=af73f05a22febcb4dfae60b197a6ca8e&chksm=eaef2ea8
]
},
/**
* ⽣命周期函数--监听页⾯加载
*/
onLoad: function (options) {
var goodsId = dsId;
console.log(goodsId)
this.setData({
url: this.data.productsList[goodsId].showDesc
});
}
})
样式可以⾃⼰进⾏优化,然后其中的道理就不⼀⼀细说了,根据index点击的列表的id判断所对应的url即可。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论