From b545679dad364a0ccc954405a793981a7110b10b Mon Sep 17 00:00:00 2001 From: asd <374367073@qq.com> Date: Thu, 19 Dec 2019 14:29:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B4=AD=E7=89=A9=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/index/list/commodity/index.js | 8 +++-- components/index/list/commodity/index.wxml | 3 +- components/index/list/index.wxml | 2 +- pages/product/product.js | 36 +++++++++++++++++++--- pages/product/product.wxml | 22 ++++++------- 5 files changed, 50 insertions(+), 21 deletions(-) diff --git a/components/index/list/commodity/index.js b/components/index/list/commodity/index.js index 60d2ac3..24cbade 100644 --- a/components/index/list/commodity/index.js +++ b/components/index/list/commodity/index.js @@ -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 }) } } diff --git a/components/index/list/commodity/index.wxml b/components/index/list/commodity/index.wxml index 0edd8bd..8890d91 100644 --- a/components/index/list/commodity/index.wxml +++ b/components/index/list/commodity/index.wxml @@ -1,8 +1,9 @@ - + {{title}} + ¥{{price}} 加入购物车 diff --git a/components/index/list/index.wxml b/components/index/list/index.wxml index 8f1ac02..e4ff091 100644 --- a/components/index/list/index.wxml +++ b/components/index/list/index.wxml @@ -1,4 +1,4 @@ 热门商品 - + \ No newline at end of file diff --git a/pages/product/product.js b/pages/product/product.js index 14f3d71..1ca6965 100644 --- a/pages/product/product.js +++ b/pages/product/product.js @@ -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) { - wx.switchTab({ - url: '/pages/shopping/shopping' - }) + 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' + }) + }) + }, /** * 生命周期函数--监听页面初次渲染完成 diff --git a/pages/product/product.wxml b/pages/product/product.wxml index c623400..d1cd287 100644 --- a/pages/product/product.wxml +++ b/pages/product/product.wxml @@ -1,6 +1,11 @@ - + + + + + + - 产品名称产品名称产品名称 - $140,000 - - 加入购物车 + {{info.goods.goods_name}} + $ {{info.goods.shop_price}} + + 加入购物车 \ No newline at end of file -- 2.47.2