This commit is contained in:
pplokijuhyg 2019-12-19 14:30:34 +08:00
commit 918a827280
10 changed files with 127 additions and 80 deletions

View File

@ -1,5 +1,7 @@
Component({ Component({
properties: {}, properties: {
},
data: {}, data: {},
methods: { methods: {
todetail() { todetail() {

View File

@ -1,11 +1,13 @@
Component({ Component({
properties: { properties: {
types: Array
}, },
data: { data: {
id: 0 id: 0
}, },
methods: { methods: {
select(a) { select(a) {
// console.log(this.data.a.target.dataset.id)
// console.log(a.target.dataset.id) // console.log(a.target.dataset.id)
this.setData({ this.setData({
id: a.target.dataset.id id: a.target.dataset.id

View File

@ -1,10 +1,11 @@
<scroll-view class="navigation" scroll-y="{{true}}" bind:tap="select" > <scroll-view class="navigation" scroll-y="{{true}}" bind:tap="select" >
<view data-id="0" class="{{id == 0?'on' : ''}}">热门商品</view> <view wx:for="{{types}}" data-id="{{index}}" class="{{id == index?'on' : ''}}">{{item.name}}</view>
<!-- <view data-id="0" class="{{id == 0?'on' : ''}}">热门商品</view>
<view data-id="1" class="{{id == 1?'on' : ''}}">美容健身</view> <view data-id="1" class="{{id == 1?'on' : ''}}">美容健身</view>
<view data-id="2" class="{{id == 2?'on' : ''}}">美容健身</view> <view data-id="2" class="{{id == 2?'on' : ''}}">美容健身</view>
<view data-id="3" class="{{id == 3?'on' : ''}}">美容健身</view> <view data-id="3" class="{{id == 3?'on' : ''}}">美容健身</view>
<view data-id="4" class="{{id == 4?'on' : ''}}">美容健身</view> <view data-id="4" class="{{id == 4?'on' : ''}}">美容健身</view>
<view data-id="5" class="{{id == 5?'on' : ''}}">美容健身</view> <view data-id="5" class="{{id == 5?'on' : ''}}">美容健身</view>
<view data-id="6" class="{{id == 6?'on' : ''}}">美容健身</view> <view data-id="6" class="{{id == 6?'on' : ''}}">美容健身</view>
<view data-id="7" class="{{id == 7?'on' : ''}}">美容健身</view> <view data-id="7" class="{{id == 7?'on' : ''}}">美容健身</view> -->
</scroll-view> </scroll-view>

View File

@ -3,13 +3,15 @@ Component({
img:String, img:String,
title:String, title:String,
id:String, id:String,
price:String price:String,
shopid:String
}, },
data: {}, data: {},
methods: { methods: {
gotodetail() { gotodetail(e) {
console.log(e.currentTarget.dataset.id)
wx.navigateTo({ wx.navigateTo({
url: "/pages/product/product" url: "/pages/product/product?shopid="+e.currentTarget.dataset.id
}) })
} }
} }

View File

@ -1,8 +1,9 @@
<view class="commodity" bindtap="gotodetail"> <view class="commodity" bindtap="gotodetail" data-id="{{shopid}}">
<view class="content"> <view class="content">
<image class="imgthumb " src="{{img}}"></image> <image class="imgthumb " src="{{img}}"></image>
<view class="introduce"> <view class="introduce">
<text class="towline">{{title}}</text> <text class="towline">{{title}}</text>
<view> <view>
<text>¥{{price}}</text> <text>¥{{price}}</text>
<text>加入购物车</text> <text>加入购物车</text>

View File

@ -1,4 +1,4 @@
<view class="list"> <view class="list">
<text class="title">热门商品</text> <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> </view>

View File

@ -1,17 +1,30 @@
// pages/classify/classify.js // pages/classify/classify.js
import { request } from "../../utils/bin"
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
type: []
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function(options) { onLoad: function(options) {
request({
url: "Goods/goodsCategoryList",
data: {
parent_id: 2
}
}).then((res) => {
// console.log(res)
this.setData({
type: res.data.result
})
console.log(this.data.type, 150)
})
}, },

View File

@ -1,4 +1,4 @@
<view class="box"> <view class="box">
<navigation></navigation> <navigation types="{{type}}"></navigation>
<list ></list> <list ></list>
</view> </view>

View File

@ -1,4 +1,5 @@
// pages/product/product.js // pages/product/product.js'
import { request } from "../../utils/bin"
Page({ Page({
/** /**
@ -12,15 +13,40 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function(options) { 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() { // goshop() {
// }, // },
bindPickerChange(e) { 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({ wx.switchTab({
url: '/pages/shopping/shopping' url: '/pages/shopping/shopping'
}) })
})
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成

View File

@ -1,6 +1,11 @@
<view class="box"> <view class="box">
<swiper indicator-dots="{{true}}" circular="{{true}}" autoplay="{{true}}" interval="{{2000}}" class="swiper"> <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> <swiper-item>
<image class="image"> </image> <image class="image"> </image>
</swiper-item> </swiper-item>
@ -9,16 +14,11 @@
<swiper-item> <swiper-item>
<image class="image"> </image> <image class="image"> </image>
</swiper-item> </swiper-item>
</block> </block> -->
<block>
<swiper-item>
<image class="image"> </image>
</swiper-item>
</block>
</swiper> </swiper>
<text class="title">产品名称产品名称产品名称</text> <text class="title">{{info.goods.goods_name}}</text>
<text class="menery">$140,000</text> <text class="menery">$ {{info.goods.shop_price}}</text>
<picker bindchange="bindPickerChange" value="{{index}}" range="{{array}}"> <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> <view class="add">加入购物车</view>
</picker> </picker>
</view> </view>