900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 微信小程序商城开发之动态API实现商品的详情页的代码(上)

微信小程序商城开发之动态API实现商品的详情页的代码(上)

时间:2023-12-09 19:56:26

相关推荐

微信小程序商城开发之动态API实现商品的详情页的代码(上)

微信小程序|小程序开发

微信小程序,商品详情

微信小程序-小程序开发

上门服务网页源码,vscode如何使用代理,ubuntu系统注销,tomcat记录项目日志,sqlite+qq聊天记录,爬虫不被限制的频率最好是多少,php 相册管理,邯郸线上营销seo优化,二手qq网站源码,微信如何做模板下载网站lzw

本篇文章给大家带来的内容是关于微信小程序商城开发之动态API实现商品的详情页的代码(上) ,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

vb日历控件源码,vscode怎么改成中文版,ubuntu隐藏挂载,tomcat 是反向代理吗,番剧爬虫,php解析url数据,nuxt动态链接不支持seolzw

看效果

糊涂建站系统源码,Ubuntu如何访问本地,tomcat中的o发什么音,爬虫同步京东时间,php留言板删除留言语句,西安seo知识lzw

开发计划

1、实现商品详情页面布局(这篇实现3个模块,头部商品图片轮播、商品价格和商品描述、商品详情展示)

2、根据用户点击不同的商品请求API动态加载数据

根据商品ID获取商品详情API数据模型

访问:/ 选择微商城案例,下图例:

下方还有详细的数据模型可以查看哦!

home.js 增加跳转商品详情事件

上一篇还记得我们做了商品点击查看详情的事件采集吗?那么再加上跳转商品详情页功能,下图例:

detail.wxml

{{goods.title}}

¥{{goods.price}}

原价¥{{goods.privilegePrice}}

商品详情

detail.wxss

page {display: flex;flex-direction: column;height: 100%;}/* 直接设置swiper属性 */swiper {/* height: 500rpx; */ height: 750rpx;}swiper-item image {width: 100%;height: 100%;}/**商品价格**/.product-price-wrap{display: flex;justify-content:space-between;/**两边对齐**/ flex-direction: row;flex-wrap: wrap;margin:5px 5px; /* border:1rpx solid red; */} .product-price-wrap .product-price-new{color: red;font-size: 40rpx;margin: 10rpx;}.product-price-wrap .product-price-old{color: #888;text-decoration: line-through;padding-left: 5px;font-size: 12px;line-height:30px;font-weight:300;}.product-name-wrap{margin: 0px 10px; font-size: 14px; color: #404040;}.details{ padding: 0 5px 0 5px; }.detail {display: flex;flex-direction: column;margin-top: 15rpx;margin-bottom: 0rpx; }.detail .title {font-size: 40rpx;margin: 10rpx;color: black;text-align: justify;height: 100rpx;}.detail .price {color: red;font-size: 40rpx;margin: 10rpx;}.line_flag {width: 80rpx;height: 1rpx;display: inline-block;margin: 20rpx auto;background-color: gainsboro;text-align: center;}.line {width: 100%;height: 2rpx;display: inline-block;margin: 20rpx 0rpx;background-color: gainsboro;text-align: center;}.detail-nav {display: flex;flex-direction: row;align-items: center;float: left;background-color: #fff;position: fixed;bottom: 0;right: 0;z-index: 1;width: 100%;height: 100rpx;}.button-green {background-color: #4caf50; /* Green */}.button-red {background-color: #f44336; /* 红色 */}.button-addCar {background-color: #f44336; /* 红色 */ width: 100%;}.image_detail {width: 100%; /* height: 750rpx; */}.detail-nav image {width: 70rpx;height: 50rpx;margin: 20rpx 40rpx;}.line_nav {width: 5rpx;height: 100%;background-color: gainsboro;}/* 占位 */.temp {height: 100rpx;}

detail.js

const ajax = require(../../utils/ajax.js);const utils = require(../../utils/util.js);var imgUrls = []; var detailImg = [];var goodsId = null;var goods = null;Page({ /** * 页面的初始数据 */ data: { isLike: true, showDialog: false, goods:null, indicatorDots: true, //是否显示面板指示点 autoplay: true, //是否自动切换 interval: 3000, //自动切换时间间隔,3s duration: 1000, // 滑动动画时长1s }, //预览图片 previewImage: function (e) { var current = e.target.dataset.src; wx.previewImage({ current: current, // 当前显示图片的http链接urls: this.data.imgUrls // 需要预览的图片http链接列表}) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; goodsId = options.goodsId; console.log(goodsId: + goodsId); //加载商品详情 that.goodsInfoShow(); }, goodsInfoShow: function (success) { var that = this; ajax.request({method: GET,url: goods/getGoodsInfo?key= + utils.key+&goodsId= + goodsId,success: data => {var goodsItem = data.result;for (var i = 0; i < goodsItem.shopGoodsImageList.length; i++) { imgUrls[i] = goodsItem.shopGoodsImageList[i].imgUrl;}var details = goodsItem.details.split(";");for (var j = 0; j < details.length; j++) { detailImg[j] = details[j]; } goods = { imgUrls: imgUrls, title: goodsItem.name, price: goodsItem.price, privilegePrice: goodsItem.privilegePrice, detailImg: detailImg, imgUrl: goodsItem.imgUrl, buyRate: goodsItem.buyRate, goodsId: goodsId, count:1, totalMoney: goodsItem.price, }that.setData({ goods : goods })console.log(goods.title)} }) },})

微信小程序商城开发之https框架的搭建以及顶部和底部导航的实现

微信小程序商城开发之商城首页福利场不限下拉刷新动态API数据的代码实现

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。