zh
liuyongli 3 years ago
parent 60cf65d4e6
commit 68c711e1e4

@ -60,8 +60,13 @@
console.log(options) console.log(options)
if (options && options.fromPage) { if (options && options.fromPage) {
this.fromPage = options.fromPage this.fromPage = options.fromPage
} }
this.getAddresslist();
this.getAddresslist();
// if (this.siteList == 0) {
// this.$u.toast("")
// return
// }
}, },
methods: { methods: {
// //
@ -173,7 +178,11 @@
} }
}); });
}, },
getAddresslist() { getAddresslist() {
// if (this.siteList.length == 0) {
// this.$u.toast("")
// return
// }
this.$u.post('/api/v1/users/address/list', { this.$u.post('/api/v1/users/address/list', {
UserID: uni.getStorageSync("userInfo").id UserID: uni.getStorageSync("userInfo").id
}).then(res => { }).then(res => {
@ -183,7 +192,7 @@
return return
} }
this.siteList = res.data.data this.siteList = res.data.data
console.log(this.siteList) console.log('ll',this.siteList)
if (this.siteList.length == 0) { if (this.siteList.length == 0) {
this.isNull = true this.isNull = true
} else { } else {

@ -29,7 +29,7 @@
<text :class="goods.goodsChecked?'cuIcon-roundcheckfill text-red':'cuIcon-round text-gray'" @tap="checkGoods(shopIndex,goodsIndex)"></text> <text :class="goods.goodsChecked?'cuIcon-roundcheckfill text-red':'cuIcon-round text-gray'" @tap="checkGoods(shopIndex,goodsIndex)"></text>
</view> </view>
<navigator :url="'/pages/goodsDetail/goodsDetail?id='+goods.goodsId" class="cart-goods-pic"> <navigator :url="'/pages/goodsDetail/goodsDetail?id='+goods.goodsId" class="cart-goods-pic">
<u-lazy-load threshold="-100" :image="judgeCover(goods.mainPhotoUrl)" :index="index" :loading-img="IMAGE_URL + '/wxapp/null05.png'" height="200" border-radius="10" :error-img="IMAGE_URL + '/wxapp/null05.png'" img-mode="aspectFill"></u-lazy-load> <u-lazy-load threshold="-100" :image="goods.img" :index="index" :loading-img="IMAGE_URL + '/wxapp/null05.png'" height="200" border-radius="10" :error-img="IMAGE_URL + '/wxapp/null05.png'" img-mode="aspectFill"></u-lazy-load>
</navigator> </navigator>
<view class="cart-goods-msg flex-sub"> <view class="cart-goods-msg flex-sub">
<view class="msg-top flex flex-direction justify-between clear align-start"> <view class="msg-top flex flex-direction justify-between clear align-start">
@ -97,6 +97,9 @@
}, },
onShow() { onShow() {
this.getCartGoods() this.getCartGoods()
console.log('商品数量',this.cartGoods.length);
var num = this.cartGoods.length
uni.setStorageSync('num',num)
}, },
methods: { methods: {
// //
@ -144,7 +147,8 @@
for (let i = 0; i < this.cartGoods.length; i++) { for (let i = 0; i < this.cartGoods.length; i++) {
this.cartGoods[i].shopChecked = false this.cartGoods[i].shopChecked = false
for (let j = 0; j < this.cartGoods[i].children.length; j++) { for (let j = 0; j < this.cartGoods[i].children.length; j++) {
this.cartGoods[i].children[j].goodsChecked = false this.cartGoods[i].children[j].goodsChecked = false;
this.cartGoods[i].children[j].img = this.judgeCover(this.cartGoods[i].children[j].mainPhotoUrl);
} }
} }
} }

@ -36,10 +36,15 @@
</view> </view>
<navigator :url="'/pages/goodsDetail/goodsDetail?id='+goods.goodsId" <navigator :url="'/pages/goodsDetail/goodsDetail?id='+goods.goodsId"
class="cart-goods-pic"> class="cart-goods-pic">
<u-lazy-load threshold="-100" :image="judgeCover(goods.mainPhotoUrl)" :index="index" <!-- <u-lazy-load threshold="-100" :image="((goods.mainPhotoUrl.split('/'))[0] === 'http:'||(goods.mainPhotoUrl.split('/'))[0] === 'https:')?goods.mainPhotoUrl:(IMAGE_URL+goods.mainPhotoUrl)"
:index="index"
:loading-img="IMAGE_URL + '/wxapp/null05.png'" height="200" border-radius="10" :loading-img="IMAGE_URL + '/wxapp/null05.png'" height="200" border-radius="10"
:error-img="IMAGE_URL + '/wxapp/null05.png'" img-mode="aspectFill"> :error-img="IMAGE_URL + '/wxapp/null05.png'" img-mode="aspectFill">
</u-lazy-load> </u-lazy-load> -->
<u-lazy-load threshold="-100" :image="goods.img" :index="index"
:loading-img="IMAGE_URL + '/wxapp/null05.png'" height="200" border-radius="10"
:error-img="IMAGE_URL + '/wxapp/null05.png'" img-mode="aspectFill">
</u-lazy-load>
</navigator> </navigator>
<view class="cart-goods-msg flex-sub"> <view class="cart-goods-msg flex-sub">
<view class="msg-top flex flex-direction justify-between clear align-start"> <view class="msg-top flex flex-direction justify-between clear align-start">
@ -57,9 +62,9 @@
style="text-decoration: line-through;font-size: 20rpx;margin-left: 5rpx;color: #898989;">¥{{goods.originalPrice}}</text> style="text-decoration: line-through;font-size: 20rpx;margin-left: 5rpx;color: #898989;">¥{{goods.originalPrice}}</text>
</view> </view>
<!-- 用change事件初次加载会请求多次 --> <!-- 用change事件初次加载会请求多次 -->
<uni-number-box v-model="goods.quantity" :min="1" :max="50" :input-width="72" <u-number-box v-model="goods.quantity" :min="1" :max="50" :input-width="72"
:size="24" @change="changeNum(goods.shoppingTrolleyId,goods.quantity)"> :size="24" @change="changeNum(goods.shoppingTrolleyId,goods.quantity)">
</uni-number-box> </u-number-box>
</view> </view>
</view> </view>
@ -126,7 +131,7 @@
this.getGoodsList() this.getGoodsList()
}, },
methods: { methods: {
// //
judgeCover(val) { judgeCover(val) {
if (!val) { if (!val) {
return return
@ -181,13 +186,13 @@
this.cartGoods[i].shopChecked = false this.cartGoods[i].shopChecked = false
for (let j = 0; j < this.cartGoods[i].children.length; j++) { for (let j = 0; j < this.cartGoods[i].children.length; j++) {
this.cartGoods[i].children[j].goodsChecked = false; this.cartGoods[i].children[j].goodsChecked = false;
this.cartGoods[i].children[j].img = this.judgeCover(this.cartGoods[i].children[j].mainPhotoUrl);
} }
} }
} }
this.getSelectedGoods() this.getSelectedGoods()
this.$forceUpdate() this.$forceUpdate()
console.log(this.cartGoods) console.log('列表',this.cartGoods.length)
}); });
}, },
// //
@ -277,6 +282,7 @@
this.totalCommission = totalCommission.toFixed(2) this.totalCommission = totalCommission.toFixed(2)
// console.log(selectGoodsIds) // console.log(selectGoodsIds)
}, },
delGoods() { delGoods() {
if (this.selectGoodsIds.length == 0) { if (this.selectGoodsIds.length == 0) {
this.$u.toast("至少选择一件商品"); this.$u.toast("至少选择一件商品");

@ -54,29 +54,29 @@
JDCateList: null, JDCateList: null,
parentId: null, parentId: null,
keyword: "", keyword: "",
topPic: "", topPic: "",
pageId:0 pageId: 0
} }
}, },
onLoad(options) { onLoad(options) {
console.log(options) console.log(options)
this.pageId=options.id this.pageId = options.id
// if (options.index==0) { // if (options.index==0) {
// this.current = 3 // this.current = 3
// }else if(options.index==1){ // }else if(options.index==1){
// this.current=10 // this.current=10
// }else if(options.index==2){ // }else if(options.index==2){
// this.current=index-2 // this.current=index-2
// }else{ // }else{
// this.current=options.index // this.current=options.index
// } // }
if (options.channel && options.channel == 'jingdong') { if (options.channel && options.channel == 'jingdong') {
this.getJDCateList() this.getJDCateList()
} else { } else {
this.getCateList() this.getCateList()
} }
}, },
methods: { methods: {
// //
@ -87,11 +87,11 @@
return return
} }
this.JDCateList = res.data.data this.JDCateList = res.data.data
this.cateList = res.data.data this.cateList = res.data.data
this.cateList.forEach((item,index)=>{ this.cateList.forEach((item, index) => {
if(item.id==this.pageId){ if (item.id == this.pageId) {
this.current=index this.current = index
} }
}) })
this.subCateList = res.data.data[0].sub this.subCateList = res.data.data[0].sub
}) })
@ -104,11 +104,11 @@
this.$u.toast(res.data.msg); this.$u.toast(res.data.msg);
return return
} }
this.cateList = res.data.data this.cateList = res.data.data
this.cateList.forEach((item,index)=>{ this.cateList.forEach((item, index) => {
if(item.id==this.pageId){ if (item.id == this.pageId) {
this.current=index this.current = index
} }
}) })
this.parentId = this.cateList[this.current].id this.parentId = this.cateList[this.current].id
this.topPic = this.cateList[this.current].logoUrl this.topPic = this.cateList[this.current].logoUrl
@ -135,21 +135,34 @@
toSearch(id) { toSearch(id) {
// id, // id,
// canneljingdong // canneljingdong
let url = null
if (id) { if (id) {
url = "/pages/search/search?cate_id=" + id +(this.JDCateList?'&channel=jingdong':'')
uni.navigateTo({ uni.navigateTo({
url url: "/pages/search/search?cate_id=" + id
}) })
} else { } else {
url: "/pages/search/search?keyword=" + this.keyword +(this.JDCateList?'&channel=jingdong':'') uni.navigateTo({
uni.navigateTo({ url: "/pages/search/search?keyword=" + this.keyword,
url,
success: () => { success: () => {
this.keyword = "" this.keyword = ""
} }
}) })
} }
// let url = url
// if (id) {
// url = "/pages/search/search?cate_id=" + id +(this.JDCateList?'&channel=jingdong':'')
// uni.navigateTo({
// url
// })
// } else {
// url: "/pages/search/search?keyword=" + this.keyword +(this.JDCateList?'&channel=jingdong':'')
// uni.navigateTo({
// url,
// success: () => {
// this.keyword = ""
// }
// })
// console.log("")
// }
}, },
// //
async swichMenu(index, id) { async swichMenu(index, id) {

@ -255,7 +255,7 @@
// } // }
// }) // })
let orderId = res.data.data.id let orderId = res.data.data.id
this.$u.post('/api/v1/pay/wxpay/order/create', { this.$u.post('/api/v1/pay/wxminipay/order/create', {
userId: uni.getStorageSync("userInfo").id, userId: uni.getStorageSync("userInfo").id,
orderId orderId
// wxType:"recook-weapp" // wxType:"recook-weapp"

@ -321,7 +321,7 @@
</view> </view>
<scroll-view scroll-x="true"> <scroll-view scroll-x="true">
<view class="rec-con flex"> <view class="rec-con flex">
<view class="rec-item" v-for="(item,index) in goodsDetail.recommend" <view class="rec-item" v-for="(item,index) in goodsDetail.recommends"
:key="index"> :key="index">
<!-- <image :src="item.mainPhotoUrl" mode=""></image> --> <!-- <image :src="item.mainPhotoUrl" mode=""></image> -->
<navigator class="item-image" <navigator class="item-image"
@ -375,8 +375,9 @@
<view class="flex text-center flex-sub justify-around"> <view class="flex text-center flex-sub justify-around">
<navigator url="../../packageA/goodsCart/index" <navigator url="../../packageA/goodsCart/index"
style="width: 100rpx;text-align: center;"> style="width: 100rpx;text-align: center;">
<text class="cuIcon-cart" style="font-size: 48rpx;"></text> <text class="cuIcon-cart" style="font-size: 48rpx;"></text>
<text class="cuIcon-badge">{{salesVolumeInc}}</text> <text class="cuIcon-badge"
v-if="shoppingTrolleyCount>0">{{shoppingTrolleyCount}}</text>
<view style="font-size: 20rpx;">购物车</view> <view style="font-size: 20rpx;">购物车</view>
</navigator> </navigator>
<template v-if="goodsDetail.isFavorite"> <template v-if="goodsDetail.isFavorite">
@ -557,7 +558,7 @@
</template> </template>
<template v-else> <template v-else>
<view class="flex-sub" style="margin-right: 3rpx;" @tap="addcart"></view> <view class="flex-sub" style="margin-right: 3rpx;" @tap="addcart"></view>
<view class="flex-sub buy-now" @tap="createOrder"></view> <view class="flex-sub buy-now" @tap="createOrder"></view>
<!-- <view class="flex-sub buy-now" @tap="$u.throttle(createOrder,1000)"></view> --> <!-- <view class="flex-sub buy-now" @tap="$u.throttle(createOrder,1000)"></view> -->
</template> </template>
</view> </view>
@ -670,14 +671,17 @@
mobile: "", mobile: "",
address: "", address: "",
detail: "", detail: "",
}, },
badgeCount:0 shoppingTrolleyCount: 0,
} }
}, },
components: { components: {
dynamics dynamics
}, },
onLoad(options) { onLoad(options) {
// var num = uni.getStorageSync('num');
// console.log('',num)
console.log('goodsDetail页面参数', options); console.log('goodsDetail页面参数', options);
var pages = getCurrentPages(); var pages = getCurrentPages();
// //
@ -735,7 +739,7 @@
}, },
mounted() { mounted() {
// this.getRegions() // this.getRegions()
console.log(uni.getStorageSync("userInfo").id) // console.log(uni.getStorageSync("userInfo").id)
}, },
methods: { methods: {
// //
@ -1012,6 +1016,7 @@
return return
} }
this.goodsDetail = res.data.data this.goodsDetail = res.data.data
this.shoppingTrolleyCount = res.data.data.shoppingTrolleyCount
// type // type
if (res.data.data.notice.type === 1) { if (res.data.data.notice.type === 1) {
this.brandFirstImg = res.data.data.notice.img this.brandFirstImg = res.data.data.notice.img
@ -1103,9 +1108,7 @@
this.pictures = res.data.data.list this.pictures = res.data.data.list
}); });
}, },
setBadge(cartArray){},
// //
addcart() { addcart() {
if (uni.getStorageSync("auth").token) { if (uni.getStorageSync("auth").token) {
@ -1128,6 +1131,7 @@
uni.showToast({ uni.showToast({
title: "已加入购物车" title: "已加入购物车"
}) })
this.shoppingTrolleyCount += this.buyNum
this.specModel(false) this.specModel(false)
}) })
} else { } else {
@ -1152,15 +1156,39 @@
}, },
// //
createOrder() { createOrder() {
console.log(this.sku_id) console.log('qq',this.sku_id)
console.log(this.checkedSku) console.log('aa',this.checkedSku)
if (!this.sku_id) { // console.log('qq',this.sku_id)
this.$u.toast("请选择商品规格") // console.log('aa',this.checkedSku)
return console.log('aaddd',this.addressList.length)
} else if (this.jcookStockState != 1) {
this.$u.toast("当前无货") // if (this.addressList.length === 0 ) {
if (this.sku_id != '' && !this.selectedAddress) {
// this.$u.toast('');
uni.navigateTo({
url: '/packageA/address/index?fromPage=goodsDetail'
})
return return
} }
// else{
if (!this.sku_id) {
this.$u.toast("请选择商品规格")
return
}
// else if(this.sku_id != '' && !this.selectedAddress){
// uni.navigateTo({
// url: '/packageA/address/index?fromPage=goodsDetail'
// })
// return
// }
else if (this.jcookStockState != 1) {
this.$u.toast("当前无货")
return
}
// }
let sendData = { let sendData = {
UserID: uni.getStorageSync("userInfo").id, UserID: uni.getStorageSync("userInfo").id,
SkuID: this.sku_id, SkuID: this.sku_id,
@ -1378,23 +1406,25 @@
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.cuIcon-badge{ .cuIcon-badge {
position: absolute; position: absolute;
top: 0; top: 0;
left: 80rpx; left: 80rpx;
border-radius: 20rpx; border-radius: 50rpx;
color: #f56c6c; color: #ffffff;
display: inline-block; background-color: #f71b1b;
font-size: 22rpx; display: inline-block;
height: 30rpx; font-size: 24rpx;
line-height: 30rpx; height: 30rpx;
padding: 0 10rpx; line-height: 30rpx;
text-align: center; padding: 0 10rpx;
white-space: nowrap; text-align: center;
border: 2rpx solid #f56c6c; white-space: nowrap;
border: 2rpx solid #f56c6c;
}
}
.parameter-box { .parameter-box {
.parameter-list { .parameter-list {
display: flex; display: flex;

Loading…
Cancel
Save