添加购物车
This commit is contained in:
parent
a42c9a1ba3
commit
b545679dad
@ -3,13 +3,15 @@ Component({
|
||||
img:String,
|
||||
title:String,
|
||||
id:String,
|
||||
price:String
|
||||
price:String,
|
||||
shopid:String
|
||||
},
|
||||
data: {},
|
||||
methods: {
|
||||
gotodetail() {
|
||||
gotodetail(e) {
|
||||
console.log(e.currentTarget.dataset.id)
|
||||
wx.navigateTo({
|
||||
url: "/pages/product/product"
|
||||
url: "/pages/product/product?shopid="+e.currentTarget.dataset.id
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
<view class="commodity" bindtap="gotodetail">
|
||||
<view class="commodity" bindtap="gotodetail" data-id="{{shopid}}">
|
||||
<view class="content">
|
||||
<image class="imgthumb " src="{{img}}"></image>
|
||||
<view class="introduce">
|
||||
<text class="towline">{{title}}</text>
|
||||
|
||||
<view>
|
||||
<text>¥{{price}}</text>
|
||||
<text>加入购物车</text>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<view class="list">
|
||||
<text class="title">热门商品</text>
|
||||
<commodity wx:for="{{list}}" title="{{item.goods_name}}" price="{{item.shop_price}}" img="{{item.image}}"></commodity>
|
||||
<commodity wx:for="{{list}}" title="{{item.goods_name}}" price="{{item.shop_price}}" img="{{item.image}}" shopid="{{item.goods_id}}"></commodity>
|
||||
</view>
|
@ -1,4 +1,5 @@
|
||||
// pages/product/product.js
|
||||
// pages/product/product.js'
|
||||
import { request } from "../../utils/bin"
|
||||
Page({
|
||||
|
||||
/**
|
||||
@ -12,15 +13,40 @@ Page({
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function(options) {
|
||||
|
||||
console.log(options)
|
||||
request({
|
||||
url: "Goods/goodsInfo",
|
||||
data: {
|
||||
id: options.shopid
|
||||
}
|
||||
}).then((res) => {
|
||||
// console.log(res)
|
||||
this.setData({
|
||||
info: res.data.result,
|
||||
shopid:options.shopid,
|
||||
})
|
||||
// console.log(this.data.type, 150)
|
||||
})
|
||||
},
|
||||
// goshop() {
|
||||
|
||||
// },
|
||||
bindPickerChange(e) {
|
||||
console.log(e.detail.value)
|
||||
request({
|
||||
url: "Cart/addCart",
|
||||
data: {
|
||||
goods_id: this.data.shopid,
|
||||
goods_num: 1,
|
||||
goods_spec:e.detail.value
|
||||
}
|
||||
}).then((res)=>{
|
||||
console.log(res)
|
||||
wx.switchTab({
|
||||
url: '/pages/shopping/shopping'
|
||||
})
|
||||
})
|
||||
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
|
@ -1,6 +1,11 @@
|
||||
<view class="box">
|
||||
<swiper indicator-dots="{{true}}" circular="{{true}}" autoplay="{{true}}" interval="{{2000}}" class="swiper">
|
||||
<block>
|
||||
<block wx:for="{{info.gallery}}">
|
||||
<swiper-item>
|
||||
<image class="image" src="{{item.image_url}}"> </image>
|
||||
</swiper-item>
|
||||
</block>
|
||||
<!-- <block>
|
||||
<swiper-item>
|
||||
<image class="image"> </image>
|
||||
</swiper-item>
|
||||
@ -9,16 +14,11 @@
|
||||
<swiper-item>
|
||||
<image class="image"> </image>
|
||||
</swiper-item>
|
||||
</block>
|
||||
<block>
|
||||
<swiper-item>
|
||||
<image class="image"> </image>
|
||||
</swiper-item>
|
||||
</block>
|
||||
</block> -->
|
||||
</swiper>
|
||||
<text class="title">产品名称产品名称产品名称</text>
|
||||
<text class="menery">$140,000</text>
|
||||
<picker bindchange="bindPickerChange" value="{{index}}" range="{{array}}">
|
||||
<text class="title">{{info.goods.goods_name}}</text>
|
||||
<text class="menery">$ {{info.goods.shop_price}}</text>
|
||||
<picker bindchange="bindPickerChange" value="{{item.item_id?item.item_id:0}}" range="{{info.goods.goods_spec_list?info.goods.goods_spec_list:['默认规格']}}">
|
||||
<view class="add">加入购物车</view>
|
||||
</picker>
|
||||
</view>
|
Loading…
Reference in New Issue
Block a user