作者 宋国杰

init

正在显示 100 个修改的文件 包含 1722 行增加0 行删除

要显示太多修改。

为保证性能只显示 100 of 100+ 个文件。

# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
<serverData>
<paths name="6">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
<paths name="7">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
<paths name="8">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
</component>
</project>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/wxapp.iml" filepath="$PROJECT_DIR$/.idea/wxapp.iml" />
</modules>
</component>
</project>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
... ...
//app.js
App({
onLaunch: function () {
let that = this
that.init();
wx.login({
success(res){
that.login(res.code)
},
})
},
post(url, data, showLoad){
wx.showNavigationBarLoading()
var promise = new Promise((resolve, reject) => {
let that = this;
//网络请求
wx.request({
url: this.globalData.baseUrl + url,
data: data,
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
'token': wx.getStorageSync('token') || ''
},
success: function (res) { //返回取得的数据
wx.hideNavigationBarLoading()
if (res.statusCode == '200') {
if (showLoad && res.data.code == 0) {
wx.showToast({
title: res.data.msg,
icon: 'none',
duration: 300
})
}
resolve(res.data);
} else if (res.statusCode == '401') {
wx.showToast({
title: '您还没登录,请先登录~',
icon: 'none',
duration: 500,
success() {
setTimeout(function () {
wx.navigateTo({
url: '/pages/index/start/start',
})
}, 500)
}
})
}else {
reject(res)
}
},
fail: function (e) {
wx.hideNavigationBarLoading()
}
})
})
return promise
},
post1(url, data, showLoad) {
wx.showNavigationBarLoading()
var promise = new Promise((resolve, reject) => {
let that = this;
//网络请求
wx.request({
url: this.globalData.baseUrl + url,
data: data,
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
'token': wx.getStorageSync('token') || ''
},
success: function (res) { //返回取得的数据
console.log(res)
wx.hideNavigationBarLoading()
if (res.statusCode == '200') {
if (showLoad && res.data.code == 0) {
wx.showToast({
title: res.data.msg,
icon: 'none',
duration: 300
})
}
resolve(res.data);
} else if (res.statusCode == '401') {
wx.showToast({
title: '您还没登录,请先登录~',
icon: 'none',
duration: 500,
success() {
setTimeout(function () {
wx.navigateTo({
url: '/pages/index/start/start',
})
}, 500)
}
})
} else {
reject(res)
}
},
fail: function (e) {
wx.hideNavigationBarLoading()
}
})
})
return promise
},
//button登录
buttonLogin(userInfo,callback){
let that = this
wx.login({
success(res){
let url = 'common/login'
let params = {
userInfo:userInfo,
code: res.code,
store_id: wx.getStorageSync('store_id') ? wx.getStorageSync('store_id') : 0
}
that.post(url,params,true).then(r1=>{
if(r1.code==1){
wx.setStorageSync('token', r1.data.userInfo.token)
callback()
}
})
},
})
},
//登录
login(code){
let url = 'common/codeToToken'
let params = {
code: code
}
this.post(url,params,false).then(r=>{
if (r.code == 1) {
console.log('尝试登录成功')
wx.setStorageSync('token', r.data.userInfo.token)
wx.setStorageSync('session_key', r.data.sessionKey.session_key)
wx.setStorageSync('openid', r.data.sessionKey.openid)
}else{
wx.setStorageSync('session_key', r.data.sessionKey.session_key)
wx.setStorageSync('openid', r.data.sessionKey.openid)
}
})
},
//初始化
init(){
let that=this;
this.post('common/init',{},false).then(r=>{
if (r.code == 1) {
wx.setStorageSync('initData',r.data);
//that.globalData.site_name=r.data.site_name;
that.globalData.site_name='';
wx.setNavigationBarTitle({
title: ''
})
}
})
},
globalData: {
userInfo: null,
site_name: '',
imgUrl: '/img/',
baseUrl: 'https://www.meinavioce.com/api/'
}
})
\ No newline at end of file
... ...
{
"pages": [
"pages/index/index",
"pages/person/person",
"pages/category/category",
"pages/cart/cart",
"pages/index/search/search",
"pages/index/searchResult/searchResult",
"pages/index/active/active",
"pages/index/goodsDetail/goodsDetail",
"pages/index/confirmOrder/confirmOrder",
"pages/index/start/start",
"pages/person/score/score",
"pages/person/scoreDetail/scoreDetail",
"pages/person/petsManage/petsManage",
"pages/person/collection/collection",
"pages/person/orderDetail/orderDetail",
"pages/person/myOrder/myOrder",
"pages/person/refundRule/refundRule",
"pages/person/refundMoney/refundMoney",
"pages/person/contactCustomService/contactCustomService",
"pages/person/editAddress/editAddress",
"pages/person/addressList/addressList",
"pages/person/coupon/coupon",
"pages/person/shopVoucher/shopVoucher",
"pages/person/chooseCoupon/chooseCoupon"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#151515",
"navigationBarTitleText": "",
"navigationBarTextStyle": "white"
},
"tabBar": {
"color": "#BDC4CE",
"selectedColor": "#151515",
"list": [
{
"selectedIconPath": "/img/tab/tabbar_home1.png",
"iconPath": "/img/tab/tabbar_home.png",
"pagePath": "pages/index/index",
"text": "首页"
},
{
"selectedIconPath": "/img/tab/tabbar_category1.png",
"iconPath": "/img/tab/tabbar_category.png",
"pagePath": "pages/category/category",
"text": "精选推荐"
},
{
"selectedIconPath": "/img/tab/tabbar_cart1.png",
"iconPath": "/img/tab/tabbar_cart.png",
"pagePath": "pages/cart/cart",
"text": "购物车"
},
{
"selectedIconPath": "/img/tab/tabbar_personal1.png",
"iconPath": "/img/tab/tabbar_personal.png",
"pagePath": "pages/person/person",
"text": "我的"
}
]
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
\ No newline at end of file
... ...
/* 阿里巴巴矢量图标库 */
@font-face {
font-family: 'iconfont'; /* project id 1595016 */
src: url('//at.alicdn.com/t/font_1595016_m0i971ksx1e.eot');
src: url('//at.alicdn.com/t/font_1595016_m0i971ksx1e.eot?#iefix') format('embedded-opentype'),
url('//at.alicdn.com/t/font_1595016_m0i971ksx1e.woff2') format('woff2'),
url('//at.alicdn.com/t/font_1595016_m0i971ksx1e.woff') format('woff'),
url('//at.alicdn.com/t/font_1595016_m0i971ksx1e.ttf') format('truetype'),
url('//at.alicdn.com/t/font_1595016_m0i971ksx1e.svg#iconfont') format('svg');
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-sousuo::after{
content: '\e613'
}
page {
width: 100%;
height: 100%;
}
image {
width: 100%;
height: 100%;
}
::-webkit-scrollbar {
display: none;
}
/* 灰色色块 */
.line {
height: 16rpx;
width: 100vw;
background: rgba(245, 245, 245, 1);
margin-left: -32rpx;
}
input, textarea {
background: transparent;
border: 0 none;
outline: 0 none;
}
/* 暂无样式 */
.noData {
width: 100%;
line-height: 80vh;
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 400;
color: #8c9198;
text-align: center;
}
.wxParse-img{
width: 100%!important;
margin: 16rpx 0
}
button{
padding: 0;
margin: 0;
border: 0 none!important;
display: flex;
align-items: center;
width: auto!important
}
.border{
border-bottom: 2rpx solid #eee;
}
.border.active{
border: 0 none
}
\ No newline at end of file
... ...
const app = getApp()
Component({
/**
* 组件的属性列表
*/
properties: {
showCount: Boolean,
width: String,
height: String,
right: String,
height1: String,
width1: String,
showCart: Boolean,
flag: Boolean,
attr: Boolean,
item: Object,
imgUrl: String,
},
/**
* 组件的初始数据
*/
data: {
showCart: false,
flag: null
},
/**
* 组件的方法列表
*/
methods: {
ready() {
this.setData({
showCount: this.properties.showCount,
width: this.properties.width,
height: this.properties.height,
right: this.properties.right,
width1: this.properties.width1,
height1: this.properties.height1,
showCart: this.properties.showCart,
attr: this.properties.attr,
item: this.properties.item,
flag: this.properties.flag,
imgUrl: this.properties.imgUrl
})
console.log(wx.getStorageSync('token'))
},
//点击加购
addCart(e) {
let item = e.currentTarget.dataset.item
let url = 'cart/add'
if (item.spec_type == '10') {
let params = {
goods_id: item.id,
num: 1,
goods_spec_id: item.spec[0].goods_spec_id
}
if (item.spec[0].stock_num >= 1) {
app.post(url, params, true).then(r => {
if (r.code == 1) {
wx.showToast({
title: r.msg,
icon: 'none'
})
}
})
} else {
wx.showToast({
title: '该商品库存不足~',
icon: 'none'
})
}
}else{
wx.navigateTo({
url: '/pages/index/goodsDetail/goodsDetail?id=' + item.id,
})
}
},
//未登录点击加购
getUserInfo(e){
let that = this
// let eq = e.detail.errMsg.indexOf('ok')
wx.getUserProfile({
desc: '用户登录',
success(e) {
app.buttonLogin(e.rawData, function () {
that.setData({
flag: true
})
let item = e.currentTarget.dataset.item
let url = 'cart/add'
if (item.spec_type == '10') {
let params = {
goods_id: item.id,
num: 1,
goods_spec_id: item.spec[0].goods_spec_id
}
if (item.spec[0].stock_num >= 1) {
app.post(url, params, true).then(r => {
if (r.code == 1) {
wx.showToast({
title: r.msg,
icon: 'none'
})
}
})
} else {
wx.showToast({
title: '该商品库存不足~',
icon: 'none'
})
}
} else {
wx.navigateTo({
url: '/pages/index/goodsDetail/goodsDetail?id=' + item.id,
})
}
})
},
fail(e) {
that.setData({
flag: false
})
}
})
// if(eq>-1){
// let iv = e.detail.iv
// let encryptedData = e.detail.encryptedData
// app.buttonLogin(iv, encryptedData, function () {
// that.setData({
// flag: true
// })
// let item = e.currentTarget.dataset.item
// let url = 'cart/add'
// if (item.spec_type == '10') {
// let params = {
// goods_id: item.id,
// num: 1,
// goods_spec_id: item.spec[0].goods_spec_id
// }
// if (item.spec[0].stock_num >= 1) {
// app.post(url, params, true).then(r => {
// if (r.code == 1) {
// wx.showToast({
// title: r.msg,
// icon: 'none'
// })
// }
// })
// } else {
// wx.showToast({
// title: '该商品库存不足~',
// icon: 'none'
// })
// }
// } else {
// wx.navigateTo({
// url: '/pages/index/goodsDetail/goodsDetail?id=' + item.id,
// })
// }
// })
// }else{
// }
},
//阻止冒泡
catch(){},
//点击进入详情
goGoodsDetail(e) {
wx.navigateTo({
url: '/pages/index/goodsDetail/goodsDetail?id='+e.currentTarget.dataset.id,
})
},
//点击购物车的选择规格的弹框
openAttrBox(e){
let item = e.currentTarget.dataset.item
var checkeddata = { openAttr: true,item: item };
this.triggerEvent("chooseAttr", checkeddata)
},
//点击进入分类详情
goActiveDetail(e){
wx.navigateTo({
url: '/pages/index/active/active?id='+e.currentTarget.dataset.id,
})
},
}
})
\ No newline at end of file
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="good" catchtap="goGoodsDetail" data-id='{{item.id}}'>
<view class="good_left" style='width: {{width}}rpx;height: {{height}}rpx'>
<image src="{{item.image}}"></image>
</view>
<view class="good_right" style="width: calc(100% - {{width}}rpx)">
<view class="good_title">{{item.name}}</view>
<!-- <view class="good_description">{{item.describe}}</view> -->
<view class="good_active">
<view class="good_real_active" wx:for='{{item.active}}' wx:key='index' wx:for-item='cell' data-id='{{cell.id}}' catchtap="goActiveDetail">{{cell.name}}</view>
<view class="good_count" wx:if='{{showCount}}'>×{{item.total_num}}</view>
</view>
<view class="attr_box" data-item='{{item}}' catchtap="openAttrBox" wx:if='{{attr}}'>
<view class="attr">
<view>{{item.spec_type=="20"?item.goods_sku.goods_attr:'单规格'}}</view>
<image src="{{imgUrl}}xiaoxiala.png"></image>
</view>
</view>
<view class="good_price">
<view class="good_new_price" style="margin-right:{{right}}rpx">
<view class="good_new_price_label">¥</view>
<view class="good_new_price_real">{{attr?item.goods_sku.goods_price:item.spec[0].goods_price}}</view>
</view>
<!-- <view class="good_old_price">¥{{attr?item.goods_sku.line_price:item.spec[0].line_price}}</view> -->
<view catchtap="catch">
<view class="add_cart" catchtap="addCart" data-item='{{item}}' wx:if='{{!showCart&&flag}}'>
<image src="{{imgUrl}}add_cart.png" style='width: {{width1}}rpx;height: {{height1}}rpx'></image>
</view>
<button class="add_cart" wx:if='{{!showCart&&!flag}}' bindtap='getUserInfo' data-item='{{item}}' style='width: {{width1}}+20rpx!important;height: {{height1}}+20rpx!important'>
<image src="{{imgUrl}}add_cart.png" style='width: {{width1}}rpx;height: {{height1}}rpx'></image>
</button>
</view>
</view>
</view>
</view>
\ No newline at end of file
... ...
.good {
padding: 34rpx 0;
box-sizing: border-box;
/* border-bottom: 1rpx solid rgba(189, 196, 206, 1); */
display: flex;
}
button{
min-height: 10rpx!important
}
.good_left {
/* width: 246rpx;
height: 226rpx; */
}
.good_left image {
display: block;
}
.good_right {
/* width: calc(100% - 246rpx); */
/* height: 226rpx; */
height: 100%;
padding-left: 32rpx;
box-sizing: border-box;
}
.good_title {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-clamp: 2;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
line-height: 40rpx;
color: rgba(6, 18, 30, 1);
}
.good_description {
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 34rpx;
color: rgba(140, 145, 152, 1);
margin-top: 4rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.good_active {
display: flex;
align-items: center;
margin-top: 14rpx;
}
.good_real_active {
padding: 0 14rpx;
box-sizing: border-box;
height: 36rpx;
border: 1rpx solid rgba(21,21,21,1);
border-radius: 8rpx;
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 34rpx;
color: rgba(21,21,21,1);
max-width: 80%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 16rpx;
}
.good_count {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
color: rgba(140, 145, 152, 1);
line-height: 36rpx;
}
.good_price {
width: 100%;
margin-top: 12rpx;
display: flex;
position: relative;
}
.good_new_price {
display: flex;
/* margin-right: 38rpx; */
}
.good_new_price_label {
height: 44rpx;
padding: 6rpx 0 2rpx;
box-sizing: border-box;
line-height: 36rpx;
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 400;
color: rgba(209, 35, 36, 1);
}
.good_new_price_real {
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 44rpx;
color: rgba(209, 35, 36, 1);
}
.good_old_price {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
line-height: 44rpx;
color: rgba(140, 145, 152, 1);
text-decoration: line-through;
}
.add_cart {
position: absolute!important;
right: -10rpx!important;
bottom: -6rpx!important;
padding: 10rpx!important;
box-sizing: border-box!important;
background: transparent;
width: auto!important
}
.add_cart image {
display: block;
}
.attr_box{
display: inline-block;
max-width: 100%;
overflow: hidden;
}
.attr {
margin-top: 18rpx;
height: 32rpx;
background: rgba(238, 238, 238, 1);
display: flex;
flex-wrap: nowrap;
padding: 0 12rpx;
box-sizing: border-box;
font-size: 22rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 32rpx;
color: rgba(189, 196, 206, 1);
}
.attr image {
width: 14rpx;
height: 8rpx;
display: block;
margin-left: 40rpx;
margin-top: 12rpx;
}
.attr view{
flex: 1;
overflow:hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
... ...
// component/good/good.js
Component({
/**
* 组件的属性列表
*/
properties: {
item: Object,name: Boolean
},
/**
* 组件的初始数据
*/
data: {
showCart: false
},
/**
* 组件的方法列表
*/
methods: {
ready() {
this.setData({
item: this.properties.item,
name: this.properties.name
})
},
//点击进入详情
goGoodsDetail(e) {
wx.navigateTo({
url: '/pages/index/goodsDetail/goodsDetail?id='+e.currentTarget.dataset.id,
})
},
}
})
\ No newline at end of file
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="good" catchtap="goGoodsDetail" data-id='{{item.goods_id}}' style="">
<view class="good_left">
<image src="{{item.image}}"></image>
</view>
<view class="good_right" style="width: calc(100% - {{width}}rpx)">
<view class="good_title">{{name?item.goods_name:item.name}}</view>
<!-- <view class="good_description">{{item.describe}}</view> -->
<view class="good_price">
<view class="good_new_price">
<view class="good_new_price_label">¥</view>
<view class="good_new_price_real" wx:if='{{item.is_gift==0}}'>{{item.goods_price}}</view>
<view class="good_new_price_real" wx:if='{{item.is_gift==1}}'>赠品</view>
</view>
<view class="good_count">×{{item.total_num}}</view>
</view>
</view>
</view>
\ No newline at end of file
... ...
.good {
padding: 34rpx 0;
box-sizing: border-box;
display: flex;
}
.good_left {
width: 246rpx;
height: 226rpx;
}
.good_left image {
display: block;
}
.good_right {
width: calc(100% - 246rpx);
height: 226rpx;
padding-left: 32rpx;
box-sizing: border-box;
}
.good_title {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-clamp: 2;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
line-height: 40rpx;
color: rgba(6, 18, 30, 1);
}
.good_description {
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 34rpx;
color: rgba(140, 145, 152, 1);
margin-top: 4rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.good_price {
width: 100%;
margin-top: 60rpx;
display: flex;
justify-content: space-between
}
.good_new_price {
display: flex;
}
.good_new_price_label {
height: 44rpx;
padding: 6rpx 0 2rpx;
box-sizing: border-box;
line-height: 36rpx;
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 400;
color: rgba(209, 35, 36, 1);
}
.good_new_price_real {
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 44rpx;
color: rgba(209, 35, 36, 1);
}
.good_count {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
line-height: 44rpx;
color: rgba(140, 145, 152, 1);
}
... ...
const app = getApp()
Component({
/**
* 组件的属性列表
*/
properties: {
showCount: Boolean,
width: String,
height: String,
right: String,
height1: String,
width1: String,
showCart: Boolean,
flag: Boolean,
attr: Boolean,
item: Object,
imgUrl: String,
},
/**
* 组件的初始数据
*/
data: {
showCart: false,
flag: null
},
/**
* 组件的方法列表
*/
methods: {
ready() {
this.setData({
showCount: this.properties.showCount,
width: this.properties.width,
height: this.properties.height,
right: this.properties.right,
width1: this.properties.width1,
height1: this.properties.height1,
showCart: this.properties.showCart,
attr: this.properties.attr,
item: this.properties.item,
flag: this.properties.flag,
imgUrl: this.properties.imgUrl
})
console.log(wx.getStorageSync('token'))
},
//点击加购
addCart(e) {
let item = e.currentTarget.dataset.item
let url = 'cart/add'
if (item.spec_type == '10') {
let params = {
goods_id: item.id,
num: 1,
goods_spec_id: item.spec[0].goods_spec_id
}
if (item.spec[0].stock_num >= 1) {
app.post(url, params, true).then(r => {
if (r.code == 1) {
wx.showToast({
title: r.msg,
icon: 'none'
})
}
})
} else {
wx.showToast({
title: '该商品库存不足~',
icon: 'none'
})
}
}else{
wx.navigateTo({
url: '/pages/index/goodsDetail/goodsDetail?id=' + item.id,
})
}
},
//未登录点击加购
getUserInfo(e){
let that = this
// let eq = e.detail.errMsg.indexOf('ok')
wx.getUserProfile({
desc: '用户登录',
success(e) {
app.buttonLogin(e.rawData, function () {
that.setData({
flag: true
})
let item = e.currentTarget.dataset.item
let url = 'cart/add'
if (item.spec_type == '10') {
let params = {
goods_id: item.id,
num: 1,
goods_spec_id: item.spec[0].goods_spec_id
}
if (item.spec[0].stock_num >= 1) {
app.post(url, params, true).then(r => {
if (r.code == 1) {
wx.showToast({
title: r.msg,
icon: 'none'
})
}
})
} else {
wx.showToast({
title: '该商品库存不足~',
icon: 'none'
})
}
} else {
wx.navigateTo({
url: '/pages/index/goodsDetail/goodsDetail?id=' + item.id,
})
}
})
},
fail(e) {
that.setData({
flag: false
})
}
})
// if(eq>-1){
// let iv = e.detail.iv
// let encryptedData = e.detail.encryptedData
// app.buttonLogin(iv, encryptedData, function () {
// that.setData({
// flag: true
// })
// let item = e.currentTarget.dataset.item
// let url = 'cart/add'
// if (item.spec_type == '10') {
// let params = {
// goods_id: item.id,
// num: 1,
// goods_spec_id: item.spec[0].goods_spec_id
// }
// if (item.spec[0].stock_num >= 1) {
// app.post(url, params, true).then(r => {
// if (r.code == 1) {
// wx.showToast({
// title: r.msg,
// icon: 'none'
// })
// }
// })
// } else {
// wx.showToast({
// title: '该商品库存不足~',
// icon: 'none'
// })
// }
// } else {
// wx.navigateTo({
// url: '/pages/index/goodsDetail/goodsDetail?id=' + item.id,
// })
// }
// })
// }else{
// }
},
//阻止冒泡
catch(){},
//点击进入详情
goGoodsDetail(e) {
wx.navigateTo({
url: '/pages/index/goodsDetail/goodsDetail?id='+e.currentTarget.dataset.id,
})
},
//点击购物车的选择规格的弹框
openAttrBox(e){
let item = e.currentTarget.dataset.item
var checkeddata = { openAttr: true,item: item };
this.triggerEvent("chooseAttr", checkeddata)
},
//点击进入分类详情
goActiveDetail(e){
wx.navigateTo({
url: '/pages/index/active/active?id='+e.currentTarget.dataset.id,
})
},
}
})
\ No newline at end of file
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="good" catchtap="goGoodsDetail" data-id='{{item.id}}'>
<view class="good_left" style='width: {{width}}rpx;height: {{height}}rpx'>
<image src="{{item.image}}"></image>
</view>
<view class="good_right" style="width: calc(100% - {{width}}rpx)">
<view class="good_title">{{item.name}}</view>
<!-- <view class="good_description">{{item.describe}}</view> -->
<view class="good_active">
<view class="good_real_active" wx:for='{{item.active}}' wx:key='index' wx:for-item='cell' data-id='{{cell.id}}' catchtap="goActiveDetail">{{cell.name}}</view>
<view class="good_count" wx:if='{{showCount}}'>×{{item.total_num}}</view>
</view>
<view class="attr_box" data-item='{{item}}' catchtap="openAttrBox" wx:if='{{attr}}'>
<view class="attr">
<view>{{item.spec_type=="20"?item.goods_sku.goods_attr:'单规格'}}</view>
<image src="{{imgUrl}}xiaoxiala.png"></image>
</view>
</view>
<view class="good_price">
<view class="good_new_price" style="margin-right:{{right}}rpx">
<view class="good_new_price_label">¥</view>
<view class="good_new_price_real">{{attr?item.goods_sku.goods_price:item.spec[0].goods_price}}</view>
</view>
<!-- <view class="good_old_price">¥{{attr?item.goods_sku.line_price:item.spec[0].line_price}}</view> -->
<view catchtap="catch">
<view class="add_cart" catchtap="addCart" data-item='{{item}}' wx:if='{{!showCart&&flag}}'>
<image src="{{imgUrl}}add_cart.png" style='width: {{width1}}rpx;height: {{height1}}rpx'></image>
</view>
<button class="add_cart" wx:if='{{!showCart&&!flag}}' bindtap='getUserInfo' data-item='{{item}}' style='width: {{width1}}+20rpx!important;height: {{height1}}+20rpx!important'>
<image src="{{imgUrl}}add_cart.png" style='width: {{width1}}rpx;height: {{height1}}rpx'></image>
</button>
</view>
</view>
</view>
</view>
\ No newline at end of file
... ...
.good {
padding: 34rpx 0;
box-sizing: border-box;
/* border-bottom: 1rpx solid rgba(189, 196, 206, 1); */
display: flex;
}
button{
min-height: 10rpx!important
}
.good_left {
/* width: 246rpx;
height: 226rpx; */
}
.good_left image {
display: block;
}
.good_right {
/* width: calc(100% - 246rpx); */
/* height: 226rpx; */
height: 100%;
padding-left: 32rpx;
box-sizing: border-box;
}
.good_title {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-clamp: 2;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
line-height: 40rpx;
color: rgba(6, 18, 30, 1);
}
.good_description {
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 34rpx;
color: rgba(140, 145, 152, 1);
margin-top: 4rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.good_active {
display: flex;
align-items: center;
margin-top: 14rpx;
}
.good_real_active {
padding: 0 14rpx;
box-sizing: border-box;
height: 36rpx;
border: 1rpx solid rgba(21,21,21,1);
border-radius: 8rpx;
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 34rpx;
color: rgba(21,21,21,1);
max-width: 80%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 16rpx;
}
.good_count {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
color: rgba(140, 145, 152, 1);
line-height: 36rpx;
}
.good_price {
width: 100%;
margin-top: 12rpx;
display: flex;
position: relative;
}
.good_new_price {
display: flex;
/* margin-right: 38rpx; */
}
.good_new_price_label {
height: 44rpx;
padding: 6rpx 0 2rpx;
box-sizing: border-box;
line-height: 36rpx;
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 400;
color: rgba(209, 35, 36, 1);
}
.good_new_price_real {
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 44rpx;
color: rgba(209, 35, 36, 1);
}
.good_old_price {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
line-height: 44rpx;
color: rgba(140, 145, 152, 1);
text-decoration: line-through;
}
.add_cart {
position: absolute!important;
right: -10rpx!important;
bottom: -6rpx!important;
padding: 10rpx!important;
box-sizing: border-box!important;
background: transparent;
width: auto!important
}
.add_cart image {
display: block;
}
.attr_box{
display: inline-block;
max-width: 100%;
overflow: hidden;
}
.attr {
margin-top: 18rpx;
height: 32rpx;
background: rgba(238, 238, 238, 1);
display: flex;
flex-wrap: nowrap;
padding: 0 12rpx;
box-sizing: border-box;
font-size: 22rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 32rpx;
color: rgba(189, 196, 206, 1);
}
.attr image {
width: 14rpx;
height: 8rpx;
display: block;
margin-left: 40rpx;
margin-top: 12rpx;
}
.attr view{
flex: 1;
overflow:hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
... ...
const app = getApp()
Component({
/**
* 组件的属性列表
*/
properties: {
showCount: Boolean,
width: String,
height: String,
right: String,
height1: String,
width1: String,
showCart: Boolean,
flag: Boolean,
attr: Boolean,
item: Object,
imgUrl: String,
},
/**
* 组件的初始数据
*/
data: {
showCart: false,
flag: null
},
/**
* 组件的方法列表
*/
methods: {
ready() {
this.setData({
showCount: this.properties.showCount,
width: this.properties.width,
height: this.properties.height,
right: this.properties.right,
width1: this.properties.width1,
height1: this.properties.height1,
showCart: this.properties.showCart,
attr: this.properties.attr,
item: this.properties.item,
flag: this.properties.flag,
imgUrl: this.properties.imgUrl
})
console.log(wx.getStorageSync('token'))
},
//点击加购
addCart(e) {
let item = e.currentTarget.dataset.item
let url = 'cart/add'
if (item.spec_type == '10') {
let params = {
goods_id: item.id,
num: 1,
goods_spec_id: item.spec[0].goods_spec_id
}
if (item.spec[0].stock_num >= 1) {
app.post(url, params, true).then(r => {
if (r.code == 1) {
wx.showToast({
title: r.msg,
icon: 'none'
})
}
})
} else {
wx.showToast({
title: '该商品库存不足~',
icon: 'none'
})
}
}else{
wx.navigateTo({
url: '/pages/index/goodsDetail/goodsDetail?id=' + item.id,
})
}
},
//未登录点击加购
getUserInfo(e){
let that = this
// let eq = e.detail.errMsg.indexOf('ok')
wx.getUserProfile({
desc: '用户登录',
success(e) {
app.buttonLogin(e.rawData, function () {
that.setData({
flag: true
})
let item = e.currentTarget.dataset.item
let url = 'cart/add'
if (item.spec_type == '10') {
let params = {
goods_id: item.id,
num: 1,
goods_spec_id: item.spec[0].goods_spec_id
}
if (item.spec[0].stock_num >= 1) {
app.post(url, params, true).then(r => {
if (r.code == 1) {
wx.showToast({
title: r.msg,
icon: 'none'
})
}
})
} else {
wx.showToast({
title: '该商品库存不足~',
icon: 'none'
})
}
} else {
wx.navigateTo({
url: '/pages/index/goodsDetail/goodsDetail?id=' + item.id,
})
}
})
},
fail(e) {
that.setData({
flag: false
})
}
})
// if(eq>-1){
// let iv = e.detail.iv
// let encryptedData = e.detail.encryptedData
// app.buttonLogin(iv, encryptedData, function () {
// that.setData({
// flag: true
// })
// let item = e.currentTarget.dataset.item
// let url = 'cart/add'
// if (item.spec_type == '10') {
// let params = {
// goods_id: item.id,
// num: 1,
// goods_spec_id: item.spec[0].goods_spec_id
// }
// if (item.spec[0].stock_num >= 1) {
// app.post(url, params, true).then(r => {
// if (r.code == 1) {
// wx.showToast({
// title: r.msg,
// icon: 'none'
// })
// }
// })
// } else {
// wx.showToast({
// title: '该商品库存不足~',
// icon: 'none'
// })
// }
// } else {
// wx.navigateTo({
// url: '/pages/index/goodsDetail/goodsDetail?id=' + item.id,
// })
// }
// })
// }else{
// }
},
//阻止冒泡
catch(){},
//点击进入详情
goGoodsDetail(e) {
wx.navigateTo({
url: '/pages/index/goodsDetail/goodsDetail?id='+e.currentTarget.dataset.id,
})
},
//点击购物车的选择规格的弹框
openAttrBox(e){
let item = e.currentTarget.dataset.item
var checkeddata = { openAttr: true,item: item };
this.triggerEvent("chooseAttr", checkeddata)
},
//点击进入分类详情
goActiveDetail(e){
wx.navigateTo({
url: '/pages/index/active/active?id='+e.currentTarget.dataset.id,
})
},
}
})
\ No newline at end of file
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="good" catchtap="goGoodsDetail" data-id='{{item.id}}'>
<view class="good_left" style='width: 300rpx;height: 300rpx'>
<image src="{{item.image}}"></image>
</view>
<view class="good_right" >
<view class="good_title">{{item.name}}</view>
<!-- <view class="good_description">{{item.describe}}</view> -->
<view class="good_active">
<view class="good_real_active" wx:for='{{item.active}}' wx:key='index' wx:for-item='cell' data-id='{{cell.id}}' catchtap="goActiveDetail">{{cell.name}}</view>
<view class="good_count" wx:if='{{showCount}}'>×{{item.total_num}}</view>
</view>
<view class="attr_box" data-item='{{item}}' catchtap="openAttrBox" wx:if='{{attr}}'>
<view class="attr">
<view>{{item.spec_type=="20"?item.goods_sku.goods_attr:'单规格'}}</view>
<image src="{{imgUrl}}xiaoxiala.png"></image>
</view>
</view>
<view class="good_price">
<view class="good_new_price" style="margin-right:{{right}}rpx">
<view class="good_new_price_label">¥</view>
<view class="good_new_price_real">{{attr?item.goods_sku.goods_price:item.spec[0].goods_price}}</view>
</view>
<!-- <view class="good_old_price">¥{{attr?item.goods_sku.line_price:item.spec[0].line_price}}</view> -->
<view catchtap="catch">
<view class="add_cart" catchtap="addCart" data-item='{{item}}' wx:if='{{!showCart&&flag}}'>
<image src="{{imgUrl}}add_cart.png" style='width: {{width1}}rpx;height: {{height1}}rpx'></image>
</view>
<button class="add_cart" wx:if='{{!showCart&&!flag}}' bindtap='getUserInfo' data-item='{{item}}' style='width: {{width1}}+20rpx!important;height: {{height1}}+20rpx!important'>
<image src="{{imgUrl}}add_cart.png" style='width: {{width1}}rpx;height: {{height1}}rpx'></image>
</button>
</view>
</view>
</view>
</view>
\ No newline at end of file
... ...
.good {
padding: 34rpx 0;
box-sizing: border-box;
/* border-bottom: 1rpx solid rgba(189, 196, 206, 1); */
display: flex;
width: 345rpx;
flex-wrap: wrap;
}
button{
min-height: 10rpx!important
}
.good_left {
/* width: 246rpx;
height: 226rpx; */
}
.good_left image {
display: block;
}
.good_right {
/* width: calc(100% - 246rpx); */
/* height: 226rpx; */
display: flex;
height: 100%;
box-sizing: border-box;
flex-wrap: wrap;
}
.good_title {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-clamp: 2;
min-height: 100rpx;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
line-height: 40rpx;
width: 300rpx;
color: rgba(6, 18, 30, 1);
}
.good_description {
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 34rpx;
color: rgba(140, 145, 152, 1);
margin-top: 4rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.good_active {
display: flex;
align-items: center;
margin-top: 14rpx;
}
.good_real_active {
padding: 0 14rpx;
box-sizing: border-box;
height: 36rpx;
border: 1rpx solid rgba(21,21,21,1);
border-radius: 8rpx;
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 34rpx;
color: rgba(21,21,21,1);
max-width: 80%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 16rpx;
}
.good_count {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
color: rgba(140, 145, 152, 1);
line-height: 36rpx;
}
.good_price {
width: 100%;
margin-top: 12rpx;
display: flex;
position: relative;
}
.good_new_price {
display: flex;
/* margin-right: 38rpx; */
}
.good_new_price_label {
height: 44rpx;
padding: 6rpx 0 2rpx;
box-sizing: border-box;
line-height: 36rpx;
font-size: 26rpx;
font-family: PingFang SC;
font-weight: 400;
color: rgba(209, 35, 36, 1);
}
.good_new_price_real {
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 44rpx;
color: rgba(209, 35, 36, 1);
}
.good_old_price {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
line-height: 44rpx;
color: rgba(140, 145, 152, 1);
text-decoration: line-through;
}
.add_cart {
position: absolute!important;
right: 29rpx!important;
bottom: -12rpx!important;
padding: 10rpx!important;
box-sizing: border-box!important;
background: transparent;
width: auto!important
}
.add_cart image {
display: block;
}
.attr_box{
display: inline-block;
max-width: 100%;
overflow: hidden;
}
.attr {
margin-top: 18rpx;
height: 32rpx;
background: rgba(238, 238, 238, 1);
display: flex;
flex-wrap: nowrap;
padding: 0 12rpx;
box-sizing: border-box;
font-size: 22rpx;
font-family: PingFang SC;
font-weight: 400;
line-height: 32rpx;
color: rgba(189, 196, 206, 1);
}
.attr image {
width: 14rpx;
height: 8rpx;
display: block;
margin-left: 40rpx;
margin-top: 12rpx;
}
.attr view{
flex: 1;
overflow:hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
... ...

858 字节

1007 字节

512 字节

941 字节

840 字节

698 字节

1018 字节