NurseStationApp/pages/CommodityDetails/CommodityDetails.vue

326 lines
9.8 KiB
Vue
Raw Normal View History

2022-10-13 16:02:25 +08:00
<template>
<view class="app">
2022-11-01 16:26:34 +08:00
<u-swiper :list="info" height="750"></u-swiper>
2022-10-24 14:42:03 +08:00
<view class="Commodity common">
2022-10-13 16:02:25 +08:00
<view class="name">
2022-10-24 14:42:03 +08:00
{{goodsDetailslist.goodsName}}
2022-10-13 16:02:25 +08:00
</view>
<view class="price">
2022-10-24 14:42:03 +08:00
{{goodsPrice}}
2022-10-13 16:02:25 +08:00
</view>
</view>
2022-10-24 14:42:03 +08:00
<view class="choice common" @tap="buyshow=true">
2022-10-13 16:02:25 +08:00
<view class="selected">
已选
</view>
<view class="content">
2022-10-24 14:42:03 +08:00
{{updata.goodsAttributeName}}
2022-10-13 16:02:25 +08:00
</view>
<image src="../../static/jiantou.png" mode=""></image>
</view>
<view class="Discount common">
<view class="selected">
优惠
</view>
<view class="content">
购买最多可获得3积分
</view>
<image src="../../static/jiantou.png" mode=""></image>
</view>
<view class="service common">
<view class="selected">
服务
</view>
<view class="content">
· 7天无理由退货
</view>
<view class="content" style="display: block;">
· 仅工作日发货
</view>
<image src="../../static/jiantou.png" mode=""></image>
</view>
<view class="picture">
<view class="selected">
图文服务
</view>
2022-11-01 16:26:34 +08:00
<image :src="goodsDetailslist.goodsPictureUrl" mode=""></image>
2022-10-13 16:02:25 +08:00
</view>
<view class="Purchasecolumn">
<view class="buy" @tap="buyshow=true">
立即购买
</view>
</view>
<u-mask :show="buyshow" @click="buyshow = false" class='mask'>
<view class="PurchasePage" @click.stop=''>
<image class="close" src="../../static/gb.png" mode="" @tap='buyshow=false'></image>
2022-10-24 14:42:03 +08:00
</image>
2022-10-13 16:02:25 +08:00
<view class="topcontent">
<view class="image">
2022-11-01 16:26:34 +08:00
<image :src="goodsDetailslist.goodsPictureUrl" mode=""></image>
2022-10-13 16:02:25 +08:00
</view>
<view class="title">
2022-10-24 14:42:03 +08:00
<span>{{goodsDetailslist.goodsName}}</span>
2022-10-13 16:02:25 +08:00
</view>
<view class="price">
2022-10-24 14:42:03 +08:00
{{updata.goodsPrice}}
2022-10-13 16:02:25 +08:00
</view>
2022-10-31 09:04:45 +08:00
<view class="goodsStock" v-show="goodshow">
库存数量:{{updata.goodsStock}}
</view>
2022-10-13 16:02:25 +08:00
</view>
2022-10-31 09:04:45 +08:00
<view class="centercontent topcontent" v-show="goodshow">
2022-10-13 16:02:25 +08:00
<view class="header">
2022-10-24 14:42:03 +08:00
商品规格
2022-10-13 16:02:25 +08:00
</view>
2022-10-24 14:42:03 +08:00
<view v-for="(item,index) in goodDetailsLists"
:class="item.isActive ? 'Productmodel':'productmodel'" @tap='isActivegoods(item)'>
{{item.attributeDetailsName}}
2022-10-13 16:02:25 +08:00
</view>
</view>
2022-10-24 14:42:03 +08:00
<!-- <view class="centercontent topcontent" v-for="(item,index) in goodDetailsLists">
<view class="header">
{{item.attributeName}}
</view>
<view v-for="bitem in item.goodAttributeDetailsLists" :key="bitem.attributeDetailsId"
:class="bitem.isActive ? 'Productmodel':'productmodel'" @tap='isActivegoods(item,bitem)'>
{{bitem.attributeDetailsName}}
</view>
</view> -->
2022-10-13 16:02:25 +08:00
<view class="bottomcontent topcontent">
<view class="header">
数量
</view>
<view class="number">
2022-10-31 09:04:45 +08:00
<u-number-box :min="1" :max="updata.goodsStock" v-model="updata.goodsCount"></u-number-box>
2022-10-13 16:02:25 +08:00
</view>
</view>
2022-10-24 14:42:03 +08:00
<view class="buy" @tap="tapbuy">
2022-10-13 16:02:25 +08:00
立即购买
</view>
</view>
</u-mask>
2022-10-31 09:04:45 +08:00
<u-toast ref="uToast" />
<u-mask :show="usershow" class='mask'>
<view class="information">
<image src="../../static/information.png" mode=""></image>
<view class="title">
请完善个人信息
</view>
<view class="cancel" @tap='usershow=false'>
取消
</view>
<view class="determine" @tap='goinformation'>
去完善
</view>
</view>
</u-mask>
2022-10-13 16:02:25 +08:00
</view>
</template>
<script>
2022-10-20 19:39:57 +08:00
import {
goodsDetails
} from '@/api/CommodityDetails/CommodityDetails.js'
2022-10-31 09:04:45 +08:00
import {
AppIdentification
} from '@/api/AppIdentification/index.js'
2022-10-20 19:39:57 +08:00
import baseurl from '@/api/baseurl.js'
2022-10-13 16:02:25 +08:00
export default {
data() {
return {
2022-10-31 09:04:45 +08:00
usershow: false, //完善信息开关
2022-10-24 14:42:03 +08:00
baseurl: '', //url
goodsPrice: '', //页面价格
goodsDetailslist: [], //商品list
goodDetailsLists: [], //提前预备商品规格数组
2022-10-31 09:04:45 +08:00
goodshow: true, //商品规格开关
2022-10-13 16:02:25 +08:00
buyshow: false, //立即购买遮罩层开关
2022-10-31 09:04:45 +08:00
info: [], //轮播list
updata: { //订单表
2022-10-24 14:42:03 +08:00
goodsPrice: 0.00,
goodsName: "",
goodsAttributeName: '',
goodsCount: 1,
nurseStationId: '',
img: '',
2022-10-31 09:04:45 +08:00
totalPrice: null,
patientId: '',
goodsStock: 0, //库存数量
goodsAttributeContent: '', //商品属性
giveIntegral: 0, //赠送积分
transportPrice: 0.00, //运费
discountPrice: 0.00, //优惠
buySource: '', //下单来源 '护理站NURSE_STATION商城SHOPPING_MALL'
orderChannel: 'MOBILE_APP', //下单方式 手机AppMOBILE_APP微信小程序WECHAT_APPLET支付宝小程序ALI_PAY_APPLET'
receiver: "", //收货人
receiveAddress: "", //收货地址
phone: '', //联系电话
attributeDetailsId: '', //商品属性明细表id
goodsAttributeId: '',
goodsAttributeDetailsId: '',
2022-10-24 14:42:03 +08:00
}
2022-10-13 16:02:25 +08:00
};
},
methods: {
2022-10-31 09:04:45 +08:00
//跳转完善页面
goinformation() {
uni.navigateTo({
url: '/pages/information/information'
})
},
2022-10-24 14:42:03 +08:00
//立即购买跳转确认订单页面
tapbuy() {
2022-10-31 09:04:45 +08:00
AppIdentification(this.updata.patientId).then(res => {
console.log(res)
if (res.data.loginFlag) {
if (this.goodshow == true) {
if (this.updata.goodsAttributeName == '') {
this.$refs.uToast.show({
title: '未选择商品',
type: 'error'
})
} else if (this.updata.goodsStock == 0) {
this.$refs.uToast.show({
title: '库存数量不足,无法购买',
type: 'error'
})
} else {
this.updata.totalPrice = (this.updata.goodsPrice * this.updata.goodsCount).toFixed(
2)
uni.navigateTo({
url: `/pages/confirmOrder/confirmOrder?updata=${JSON.stringify(this.updata)}`
})
}
} else {
uni.navigateTo({
url: `/pages/confirmOrder/confirmOrder?updata=${JSON.stringify(this.updata)}`
})
}
} else {
this.buyshow = false
this.usershow = true
}
})
2022-10-24 14:42:03 +08:00
},
// tapbuy() {
// this.goodsDetailslist.goodDetailsLists.forEach(e => {
// e.goodAttributeDetailsLists.forEach(el => {
// if (el.isActive == true) {
// this.updata.goodsAttributeName += el.attributeDetailsName + ' '
2022-10-31 09:04:45 +08:00
// this.updata.totalPrice = (this.updata.goodsPrice * this.updata.goodsCount)
2022-10-24 14:42:03 +08:00
// .toFixed(2)
// }
// })
// })
// },
//选择商品
isActivegoods(item) {
this.updata.goodsPrice = 0
this.updata.goodsAttributeName = ''
if (item.isActive == true) {
this.goodDetailsLists.forEach(e => {
e.isActive = false
})
2022-10-31 09:04:45 +08:00
this.updata.goodsAttributeName = ''
this.updata.goodsPrice = 0
this.updata.attributeDetailsId = ''
this.updata.goodsStock = 0
2022-10-24 14:42:03 +08:00
} else {
this.goodDetailsLists.forEach(e => {
e.isActive = false
})
item.isActive = true
this.updata.goodsAttributeName = item.attributeDetailsName
this.updata.goodsPrice = item.goodsPrice
this.updata.goodsPrice = this.updata.goodsPrice.toFixed(2)
2022-10-31 09:04:45 +08:00
this.updata.attributeDetailsId = item.attributeDetailsId
this.updata.goodsStock = item.goodsStock
this.updata.goodsAttributeId = item.goodsAttributeId
this.updata.goodsAttributeDetailsId = item.attributeDetailsId
2022-11-01 16:26:34 +08:00
this.updata.img = this.baseurl + item.attributePitureUrl
2022-10-24 14:42:03 +08:00
}
},
// isActivegoods(item, bitem) {
// if (item.attributeName.includes('服务')) {} else {
// if (bitem.isActive == true) {
// item.goodAttributeDetailsLists.forEach(e => {
// e.isActive = false
// })
// } else {
// item.goodAttributeDetailsLists.forEach(e => {
// e.isActive = false
// })
// bitem.isActive = true
// }
// }
// this.updata.goodsPrice = 0
// this.updata.goodsAttributeName = ''
// this.goodsDetailslist.goodDetailsLists.forEach(e => {
// e.goodAttributeDetailsLists.forEach(el => {
// if (el.isActive == true) {
// this.updata.goodsPrice += el.goodsPrice
// this.updata.goodsAttributeName += el.attributeDetailsName + ' '
// }
// })
// })
// this.updata.goodsPrice = this.updata.goodsPrice.toFixed(2)
// },
// 查询商品详细信息
goodsDetailsinfo(goodsInfoId) {
goodsDetails(goodsInfoId).then(res => {
2022-10-31 09:04:45 +08:00
res.data[0].goodsPictureUrl = this.baseurl + res.data[0].goodsPictureUrl
if (res.data[0].goodDetailsLists == null) {
this.goodshow = false
} else if (res.data[0].goodDetailsLists.length == 0) {
this.goodshow = false
} else {
res.data[0].goodDetailsLists.forEach(e => {
e.isActive = false
})
this.goodshow = true
}
var obj = {
image: res.data[0].goodsPictureUrl
}
this.info.push(obj)
2022-10-24 14:42:03 +08:00
this.goodsDetailslist = res.data[0]
this.updata.goodsName = this.goodsDetailslist.goodsName
this.updata.nurseStationId = this.goodsDetailslist.nurseStationId
this.goodDetailsLists = res.data[0].goodDetailsLists
// res.data[0].goodDetailsLists.forEach(e => {
// e.goodAttributeDetailsLists.forEach(el => {
// el.isActive = false
// el.goodsPrice = Number(el.goodsPrice)
// })
// })
// this.goodsDetailslist = res.data[0]
// this.updata.goodsName = this.goodsDetailslist.goodsName
// this.updata.nurseStationId = this.goodsDetailslist.nurseStationId
// this.updata.img = this.goodsDetailslist.goodsPictureUrl
// this.goodDetailsLists = res.data[0].goodDetailsLists
})
},
},
onLoad(options) { //获取传值
2022-10-31 09:04:45 +08:00
this.updata.buySource = options.buySource
this.usershow = false
let that = this
uni.getStorage({
key: 'patientId',
success: function(res) {
that.updata.patientId = res.data
console.log(that.updata)
}
});
2022-10-24 14:42:03 +08:00
this.goodsPrice = options.goodsPrice //页面价格
this.baseurl = baseurl;
this.goodsDetailsinfo(options.goodsInfoId)
},
2022-10-13 16:02:25 +08:00
}
</script>
<style lang="scss">
2022-10-24 14:42:03 +08:00
@import "./CommodityDetailsstyle.scss";
2022-10-13 16:02:25 +08:00
</style>