jjj 4 years ago
parent eda1f8b57f
commit 08b0f69005

@ -0,0 +1,353 @@
<template>
<view>
<u-popup v-model="showPop" mode="bottom" border-radius="20" :closeable="true">
<view class="spec-box">
<view class="spec-top flex">
<view class="goods-pic">
<u-lazy-load threshold="-100" :image="IMAGE_URL+checkedSkuMsg.picUrl" :index="index" height="200" border-radius="10"
:loading-img="IMAGE_URL + '/null05.png'" :error-img="IMAGE_URL + '/null05.png'" img-mode="aspectFill"></u-lazy-load>
</view>
<view class="goods-msg flex-sub">
<view class="text-black">
<text><text style="font-size: 36rpx;font-weight: 700;">{{checkedSkuMsg.discountPrice}}</text></text>
<text style="padding:0 5rpx;" v-if="roleLevel!=500">/</text>
<text class="text-red" style="font-size: 24rpx;" v-if="roleLevel!=500">{{checkedSkuMsg.commission}}</text>
</view>
<view style="font-size: 24rpx;color: #AAAAAA;margin: 10rpx 0;">库存 {{checkedSkuMsg.inventory}}</view>
<view style="font-size: 24rpx;">已选择:{{checkedSku}}</view>
</view>
</view>
<view class="spec-con">
<view v-for="(attr,index1) in goodsDetail.attributes" :key="index1">
<view class="spec-title text-black">{{attr.name}}</view>
<view class="flex flex-wrap">
<view class="spec-item" v-for="(item,index2) in attr.children" :key="index2" :class="[item.isShow?'':'noneActive',subIndex[index1]==index2?'spec-checked':'']"
@tap="chooseAttr(index1,index2,item.id,item.value)">{{item.value}}</view>
</view>
</view>
</view>
<view class="goods-num-box flex align-center justify-between">
<view class="">数量</view>
<u-number-box v-model="buyNum" :min="1" :input-width="72" :size="24" @change="changeNum"></u-number-box>
</view>
</view>
<view class="spec-btn-box flex justify-center text-white text-center">
<template v-if="goodsDetail.inventory==0">
<view class="flex-sub cannot-buy">该商品已售罄</view>
</template>
<template v-else>
<view class="flex-sub buy-now" @tap="$u.throttle(createOrder,1000)"></view>
</template>
</view>
</u-popup>
</view>
</template>
<script>
export default {
name: 'choose',
props: {
showSpecs: Boolean,
goodsId: Number
},
data () {
return {
showPop: false,
isLogin: false,
parameterShow: false,
swiperImgList: [],
roleLevel: 500,
STATIC_URL: this.STATIC_URL,
IMAGE_URL: this.IMAGE_URL,
showLoading: true,
showTip: false,
id: null,
current: 0,
goodsDetail: null,
pictures: [],
buyNum: 1, //
selectArr: [], //
selectName: [], //
shopItemInfo: {}, //
subIndex: [], //
checkedSkuMsg: {}, //
checkedSku: "", //
sku_id: 0,
type: null,
containerIndex: 0,
dynamics: [], //,
showBtn: false, //
addressList: [],
address: null,
brandFirstImg:'',//
brandLastImg:'',//
}
},
created () {
this.showPop = this.showSpecs
this.getGoodsDetail()
},
watch: {
showPop (val) {
if (val === false) {
this.$emit('closed')
}
}
},
methods: {
//
getGoodsDetail() {
this.$u.post('/api/v1/goods/detail/summary', {
userID: uni.getStorageSync("userInfo").id,
GoodsID: this.goodsId
}).then(res => {
console.log(res.data);
this.showLoading = false
if (res.data.code == "FAIL") {
this.$u.toast(res.data.msg);
return
}
this.goodsDetail = res.data.data
// type
if(res.data.data.notice.type === 1){
this.brandFirstImg = res.data.data.notice.img
this.brandLastImg = ''
}else if(res.data.data.notice.type === 2){
this.brandFirstImg = ''
this.brandLastImg = res.data.data.notice.img
}else{
this.brandFirstImg = res.data.data.notice.img
this.brandLastImg = res.data.data.notice.img
}
//
if (this.goodsDetail.attributes.length === 1 && this.goodsDetail.attributes[0].children.length === 1) {
this.selectName[0] = this.goodsDetail.attributes[0].children[0].name
this.selectArr[0] = this.goodsDetail.attributes[0].children[0].id
this.subIndex[0] = 0
}
if (this.goodsDetail.attributes.length > 1) {
let arr = []
if (this.goodsDetail.attributes[0].children[0].id < this.goodsDetail.attributes[1].children[0].id) {
this.goodsDetail.attributes.forEach((item) => {
arr.unshift(item)
})
this.$set(this.goodsDetail, 'attributes', arr)
}
}
console.log(res.data.data)
this.swiperImgList = res.data.data.mainPhotos
//sku
this.initData()
})
},
//sku
initData() {
// console.log(this.goodsDetail)
this.checkedSkuMsg = this.goodsDetail.sku[0]
this.skuPrice = this.goodsDetail.sku[0].discountPrice || ''
this.skuPhoto = this.IMAGE_URL + this.goodsDetail.sku[0].picUrl
this.skuStoreCount = this.goodsDetail.sku[0].inventory
this.checkedSku = "请选择规格"
if (this.goodsDetail.sku.length === 1) {
this.checkedSku = this.goodsDetail.sku[0].name
this.sku_id = this.goodsDetail.sku[0].id
console.log(this.sku_id)
}
for (let i in this.goodsDetail.sku) {
this.shopItemInfo[this.goodsDetail.sku[i].combineId.split(",").reverse().join(",")] = this.goodsDetail.sku[i]; //便
}
// console.log(this.shopItemInfo)
this.checkItem();
},
//
chooseAttr(i1, i2, id, name) {
if (this.selectArr[i1] != id) {
this.selectName[i1] = name
this.selectArr[i1] = id
this.subIndex[i1] = i2
} else {
this.selectName[i1] = ""
this.selectArr[i1] = ""
this.subIndex[i1] = -1 //
}
// console.log(this.selectArr,this.subIndex,this.selectName)
this.checkedSku = this.selectName.join(",")
this.checkItem();
},
checkItem() {
let option = this.goodsDetail.attributes
let result = [] //
for (let i in option) {
result[i] = this.selectArr[i] ? this.selectArr[i] : '';
}
console.log(option)
for (let i in option) {
let last = result[i]; //last
for (let k in option[i].children) {
result[i] = option[i].children[k].id; //id
option[i].children[k].isShow = this.isMay(result); //isShow
}
result[i] = last; //
}
// console.log(result)
if (this.shopItemInfo[result]) {
this.checkedSkuMsg = this.shopItemInfo[result]
this.sku_id = this.shopItemInfo[result].id
} else {
this.sku_id = 0
}
this.$forceUpdate(); //
},
isMay(result) {
console.log(this.shopItemInfo, result)
for (var i in result) {
if (result[i] == '') {
return true; //true
}
}
console.log(this.shopItemInfo[result])
return this.shopItemInfo[result].inventory == 0 ? false : true; //truefalse
},
createOrder() {
console.log(this.sku_id)
console.log(this.checkedSku)
if (!this.sku_id) {
this.$u.toast("请选择商品规格")
return
}
let sendData = {
UserID: uni.getStorageSync("userInfo").id,
SkuID: this.sku_id,
SkuName: this.selectName.join('+'),
Quantity: this.buyNum
}
if (uni.getStorageSync("auth").token) {
if (this.parentId) {
sendData.ParentID = this.parentId
}
//
this.$u.post('/api/v1/order_preview/create', sendData).then(res => {
console.log(res);
if (res.data.code == "FAIL") {
this.$u.toast(res.data.msg);
return
}
let preViewMsg = res.data.data
preViewMsg.isImport = this.goodsDetail.isImport
this.$store.commit('updatePreOrderMsg', preViewMsg);
console.log(res.data.data)
// return
uni.navigateTo({
url: "/pages/confirmOrder/confirmOrder"
})
this.specModel(false)
});
} else {
this.$u.toast("游客无法使用该功能,请登录");
let pages = getCurrentPages();
let currPage = null;
if (pages.length) {
currPage = pages[pages.length - 1];
}
console.log(currPage)
let url = '/' + currPage.route + '?id=' +currPage.options.id + '&type=share'
this.$store.commit('setUrl', url)
console.log(url)
setTimeout(() => {
uni.navigateTo({
url: "../login/login"
})
}, 1000)
return false;
}
},
}
}
</script>
<style lang="scss" scoped>
.spec-box {
padding: 30rpx;
.spec-top {
padding-bottom: 30rpx;
border-bottom: 1rpx solid #f1f1f1;
.goods-pic {
width: 200rpx;
height: 200rpx;
border-radius: 10rpx;
margin-right: 20rpx;
}
}
.spec-con {
.spec-title {
line-height: 80rpx;
}
.spec-item {
border: 2rpx solid transparent;
background-color: #f1f1f1;
color: #000;
border-radius: 8rpx;
margin: 10rpx 0;
margin-right: 20rpx;
padding: 0 25rpx;
font-size: 26rpx;
line-height: 50rpx;
}
.spec-checked {
background-color: rgba(201, 34, 25, 0.05);
color: red;
border: 2rpx solid red;
}
.noneActive {
background-color: #f9f9f9;
color: #ddd;
border: 2rpx solid transparent;
pointer-events: none;
}
}
.goods-num-box {
height: 100rpx;
margin-top: 50rpx;
}
}
.spec-btn-box {
padding: 20rpx 30rpx;
font-size: 32rpx;
view {
height: 80rpx;
line-height: 80rpx;
&:first-child {
border-top-left-radius: 40rpx;
border-bottom-left-radius: 40rpx;
background-image: linear-gradient(to right, #787978, #5d5e5d);
}
&:last-child {
border-top-right-radius: 40rpx;
border-bottom-right-radius: 40rpx;
background-image: linear-gradient(to right, #c6193d, #ff3456);
}
}
}
</style>

@ -149,7 +149,7 @@
judgeCover (val) {
let arr = val.split('/')
if (arr[0] === 'http:') {
if (arr[0] === 'http:' || arr[0] === 'https:') {
return val
}
return this.IMAGE_URL + val

File diff suppressed because it is too large Load Diff

@ -180,13 +180,6 @@
"enablePullDownRefresh": false
}
},
{
"path": "pages/writelogistics/writelogistics",
"style": {
"navigationBarTitleText": "单号提交",
"enablePullDownRefresh": false
}
},
{
"path": "pages/afterSaleDetail/afterSaleDetail",
"style": {
@ -325,13 +318,6 @@
"navigationStyle": "custom"
}
},
{
"path": "pages/whiteInfo/whiteInfo",
"style": {
"navigationBarTitleText": "填写资料",
"enablePullDownRefresh": false
}
},
{
"path": "pages/withdrawRecord/withdrawRecord",
"style": {
@ -369,13 +355,6 @@
"enablePullDownRefresh": false
}
},
{
"path": "pages/logisticsDetail/logisticsDetail",
"style": {
"navigationBarTitleText": "物流详情",
"enablePullDownRefresh": false
}
},
{
"path": "pages/withdrawResult/withdrawResult",
"style": {
@ -625,6 +604,20 @@
"navigationBarTitleText": "实名认证",
"enablePullDownRefresh": false
}
},
{
"path": "whiteInfo/whiteInfo",
"style": {
"navigationBarTitleText": "填写资料",
"enablePullDownRefresh": false
}
},
{
"path": "writelogistics/writelogistics",
"style": {
"navigationBarTitleText": "单号提交",
"enablePullDownRefresh": false
}
},
// {
// "path": "myIncome/guide",
@ -754,6 +747,13 @@
"navigationBarTitleText": "会员邀请店主",
"enablePullDownRefresh": false
}
},
{
"path": "logisticsDetail/logisticsDetail",
"style": {
"navigationBarTitleText": "物流详情",
"enablePullDownRefresh": false
}
}
]
}],

@ -163,7 +163,7 @@
</view>
</view>
<!-- 要求用户寄回时显示 -->
<navigator :url="'../writelogistics/writelogistics?asId='+asId" v-if="message.returnStatus==3" class="bottom-btn text-white text-center"></navigator>
<navigator :url="'/packageA/writelogistics/writelogistics?asId='+asId" v-if="message.returnStatus==3" class="bottom-btn text-white text-center"></navigator>
</view>
</template>

@ -13,9 +13,9 @@
</view>
<!-- https://h5.reecook.cn/app/autoopen.html -->
<!-- <u-popup v-model="show" mode="center">
<!-- <u-popup v-model="show" mode="center">
<view>
<image src="../../static/wx.png" mode="widthFix" style="width: 400rpx;"></image>
<image :src="IMAGE_URL + '/wx.png'" mode="widthFix" style="width: 400rpx;"></image>
</view>
</u-popup> -->
<button class="btn" @click="toWebview">

@ -622,21 +622,21 @@
url: url
})
} else {
// switch (idx) {
// case 0:
// this.$u.toast("~");
// return;
// case 1:
// this.isShow = true
// break;
// case 2:
// uni.switchTab({
// url: "../shop/shop"
// })
// return;
// default:
// break;
// }
switch (idx) {
case 0:
this.$u.toast("功能暂未开放,敬请期待~");
return;
case 1:
this.isShow = true
break;
case 2:
uni.navigateTo({
url: "../shop/shop"
})
return;
default:
break;
}
uni.navigateTo({
url: url
})

@ -49,7 +49,7 @@
toDetail(data){
this.$store.commit('setLogisticsDetail',data);
uni.navigateTo({
url:"../logisticsDetail/logisticsDetail"
url:"/packageA/logisticsDetail/logisticsDetail"
})
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Loading…
Cancel
Save