1 Star 0 Fork 0

Post_Malone/Xiaomi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
goodsList.js 3.81 KB
一键复制 编辑 原始数据 按行查看 历史
Post_Malone 提交于 2021-09-09 11:07 . 创建xiaomi项目
define(["jquery"],function($){
//数据下载
function download(){
$.ajax({
type:"get",
url:"../data/goodsList2.json",
success: function(arr){
//alert(arr);
//大图商品
$(`<div data-v-61428f58 class = 'section'>
<div data-v-61428f58 class = 'components-list-box'>
<div data-v-a2d6c756 class="channel-product-imgText">
<div data-v-a2d6c756 class = 'channel-product-top'>
<div data-v-a2d6c756 class = 'product-cell shadow product_with_tag product_tag_1'>
<div data-v-a2d6c756 class = 'figure'>
<a href="goodsDesc.html?product_id=${arr[0].product_id}">
<img data-v-a2d6c756 style = 'background-color: rgb(178, 184, 205);' src="${arr[0].image}" alt=""/>
</a>
</div>
<div data-v-a2d6c756 class = 'content'>
<h3 data-v-a2d6c756 class = 'title'>
<a data-v-a2d6c756 href="goodsDesc.html?product_id=${arr[0].product_id}">
${arr[0].name}
</a>
</h3>
<p data-v-a2d6c756 class = 'desc'>${arr[0].desc}</p>
<p data-v-a2d6c756 class = 'price'>
<strong data-v-a2d6c756>${arr[0].price}</strong>元
<span data-v-a2d6c756>起</span>
<del data-v-a2d6c756>${arr[0].del}</del>
</p>
<p data-v-a2d6c756 class = 'link'>
<a data-v-a2d6c756 href="#">立即购买</a>
</p>
</div>
</div>
</div>
</div>
</div>
</div> `).appendTo(".app-body");
//小图商品
for(var i = 1 ;i<arr.length;i++){
//每两个商品创建一行
if(i % 2 != 0){
var row =$(`<div data-v-61428f58 class = 'section'>
<div data-v-61428f58 class = 'components-list-box'>
<div data-v-45ef62b1 class = 'channel-product channel-product-two4'>
<div data-v-45ef62b1 class = 'row'>
</div>
</div>
</div>
</div>`).appendTo(".app-body")
}
$(`<div data-v-45ef62b1 class = 'span10 product-cell shadow'>
<div data-v-45ef62b1 class = 'figure'>
<a data-v-45ef62b1 href="goodsDesc.html?product_id=${arr[i].product_id}" class = 'exposure'>
<img data-v-45ef62b1 style = 'background-color: rgb(189, 193, 217);' src="${arr[i].image}" alt=""/>
</a>
</div>
<h3 data-v-45ef62b1 class = 'title'>
<a data-v-45ef62b1 href="goodsDesc.html?product_id=${arr[i].product_id}">${arr[i].name}</a>
</h3>
<p data-v-45ef62b1 class = 'desc'>${arr[i].desc}</p>
<p data-v-45ef62b1 class = 'price'>
<strong data-v-45ef62b1>${arr[i].price}</strong>元
<span data-v-45ef62b1>起</span>
<del data-v-45ef62b1>${arr[i].del}</del>
</p>
</div>`).appendTo(".row")
}
},
error: function(msg){
console.log(msg);
}
})
}
return {
download : download
}
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/I_DID_IT/xiaomi.git
git@gitee.com:I_DID_IT/xiaomi.git
I_DID_IT
xiaomi
Xiaomi
master

搜索帮助