NurseStationApp/pages/CommodityDetails/CommodityDetails.vue

433 lines
14 KiB
Vue
Raw Normal View History

2022-10-13 16:02:25 +08:00
<template>
<view class="app">
2023-01-10 10:35:17 +08:00
<u-swiper :list="info" height="750" style='background-size: 100%;'></u-swiper>
2022-10-24 14:42:03 +08:00
<view class="Commodity common">
2023-01-10 10:35:17 +08:00
<view class="name" v-if="goodsDetailslist.goodsName">
2022-10-24 14:42:03 +08:00
{{goodsDetailslist.goodsName}}
2022-10-13 16:02:25 +08:00
</view>
2023-01-10 10:35:17 +08:00
<view class="name" v-else>
暂无
</view>
2022-10-13 16:02:25 +08:00
<view class="price">
2023-01-13 13:55:31 +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>
2023-03-08 09:46:11 +08:00
<image src="../../static/huijiantou.png" mode=""></image>
2022-10-13 16:02:25 +08:00
</view>
<view class="Discount common">
<view class="selected">
优惠
</view>
2022-11-10 14:20:16 +08:00
<!-- <view class="content">
2022-10-13 16:02:25 +08:00
购买最多可获得3积分
</view>
2023-03-08 09:46:11 +08:00
<image src="../../static/huijiantou.png" mode=""></image> -->
2022-10-13 16:02:25 +08:00
</view>
<view class="service common">
<view class="selected">
服务
</view>
<view class="content">
· 7天无理由退货
</view>
<view class="content" style="display: block;">
· 仅工作日发货
</view>
2023-03-08 09:46:11 +08:00
<!-- <image src="../../static/huijiantou.png" mode=""></image> -->
2022-10-13 16:02:25 +08:00
</view>
<view class="picture">
<view class="selected">
图文服务
</view>
2022-12-02 16:04:52 +08:00
<view class="textInfo" v-html="goodsDetailslist.goodsRemark">
</view>
2023-01-10 10:35:17 +08:00
<!-- <image v-for="(item,index) in info" :src="item.image" 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>
2023-01-10 10:35:17 +08:00
<view class="topcontent" style="width: 96%;">
2022-10-13 16:02:25 +08:00
<view class="image">
2023-01-10 10:35:17 +08:00
<image :src="updata.img" mode=""></image>
</view>
<view class="title" v-if="goodsDetailslist.goodsName">
{{goodsDetailslist.goodsName}}
2022-10-13 16:02:25 +08:00
</view>
2023-01-10 10:35:17 +08:00
<view class="title" v-else>
暂无
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>
2023-01-10 10:35:17 +08:00
<view>
<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
@scrolltolower="lower" @scroll="scroll">
<view class="bodys" @tap='upaddress()'>
<view class="addressinfo">
<image src="../../static/locatinsmall.png" mode=""></image>
2023-01-13 13:55:31 +08:00
<view class="namephone" v-if='userid'>
2023-01-10 10:35:17 +08:00
{{updata.receiver}},{{updata.phone}}
</view>
2023-01-13 13:55:31 +08:00
<view class="address" v-if='userid'>
{{updata.receiveAddress}}
</view>
<view class="namephone" v-else>
前往完善个人信息
</view>
2023-01-10 10:35:17 +08:00
<view class="picture2">
<u-icon name="arrow-right" color="black" size="28"></u-icon>
</view>
</view>
</view>
<view class="centercontent topcontent" v-show="goodshow">
<view class="header">
商品规格
</view>
<view class="" style="display: flex;justify-content: flex-start;flex-wrap: wrap;">
<view v-for="(item,index) in goodDetailsLists"
:class="item.isActive ? 'Productmodel':'productmodel'" @tap='isActivegoods(item)'>
<image :src="item.attributePitureUrl" mode=""></image>
<view class="">
{{item.attributeDetailsName}}
</view>
</view>
</view>
</view>
<!-- <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> -->
<view class="bottomcontent topcontent">
<view class="header">
数量
</view>
<view class="number">
<u-number-box :min="1" :max="updata.goodsStock" v-model="updata.goodsCount">
</u-number-box>
</view>
</view>
<view class="" style="height: 230rpx;">
<view class="bottomcontent topcontent" style="padding-bottom: 0;">
<view class="header">
支付方式
</view>
<view class="chat">
<image src="/static/chat.png" mode=""></image>
<span>微信支付</span>
</view>
</view>
</view>
</scroll-view>
2022-10-13 16:02:25 +08:00
</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'
2023-01-13 13:55:31 +08:00
import {
AppIdentification
} from '@/api/AppIdentification/index.js'
2022-11-09 16:38:05 +08:00
import {
goodPatientInfo
} from '@/api/modifyAddress/modifyAddress.js';
2022-10-20 19:39:57 +08:00
import baseurl from '@/api/baseurl.js'
2023-01-13 13:55:31 +08:00
import {
addStationGoodsOrder,
appletGoodsOrderPay
} from '@/api/confirmOrder/index.js'
2022-10-13 16:02:25 +08:00
export default {
data() {
return {
2023-01-10 10:35:17 +08:00
timer: null,
2022-11-14 12:31:02 +08:00
goodsInfoId: null, //商品id
2022-10-24 14:42:03 +08:00
baseurl: '', //url
2023-01-10 10:35:17 +08:00
image: null, //总图片
usershow: false, //完善信息开关
2022-10-24 14:42:03 +08:00
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
2023-01-10 10:35:17 +08:00
goodsAttributeId: null, //商品规格id
2022-10-31 09:04:45 +08:00
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,
2023-01-10 10:35:17 +08:00
patientId: null,
2022-10-31 09:04:45 +08:00
goodsStock: 0, //库存数量
goodsAttributeContent: '', //商品属性
giveIntegral: 0, //赠送积分
transportPrice: 0.00, //运费
discountPrice: 0.00, //优惠
buySource: '', //下单来源 '护理站NURSE_STATION商城SHOPPING_MALL'
2023-01-10 10:35:17 +08:00
orderChannel: 'WECHAT_APPLET', //下单方式 手机AppMOBILE_APP微信小程序WECHAT_APPLET支付宝小程序ALI_PAY_APPLET'
2022-10-31 09:04:45 +08:00
receiver: "", //收货人
receiveAddress: "", //收货地址
phone: '', //联系电话
attributeDetailsId: '', //商品属性明细表id
goodsAttributeId: '',
goodsAttributeDetailsId: '',
2023-01-10 10:35:17 +08:00
},
scrollTop: 0,
old: {
scrollTop: 0
},
userid: null,
2022-10-13 16:02:25 +08:00
};
},
methods: {
2023-01-10 10:35:17 +08:00
upper: function(e) {},
lower: function(e) {},
scroll: function(e) {
this.old.scrollTop = e.detail.scrollTop
},
2022-10-31 09:04:45 +08:00
//跳转完善页面
goinformation() {
2022-11-09 16:38:05 +08:00
this.usershow = false
2022-10-31 09:04:45 +08:00
uni.navigateTo({
url: '/pages/information/information'
})
},
2022-10-24 14:42:03 +08:00
//立即购买跳转确认订单页面
2023-01-13 13:55:31 +08:00
tapbuy() {},
2022-10-24 14:42:03 +08:00
//选择商品
isActivegoods(item) {
if (item.isActive == true) {
2023-01-13 13:55:31 +08:00
// this.updata.goodsPrice = 0
// this.updata.goodsAttributeName = ''
// this.goodDetailsLists.forEach(e => {
// e.isActive = false
// })
// this.updata.goodsAttributeName = ''
// this.updata.goodsPrice = 0
// this.updata.attributeDetailsId = ''
// this.updata.goodsStock = 0
// this.updata.img = this.image
2022-10-24 14:42:03 +08:00
} else {
this.goodDetailsLists.forEach(e => {
e.isActive = false
})
item.isActive = true
2023-01-13 13:55:31 +08:00
this.goodsAttributeId = item.goodsAttributeId
2022-11-10 14:20:16 +08:00
this.updata.img = item.attributePitureUrl
2022-10-24 14:42:03 +08:00
this.updata.goodsAttributeName = item.attributeDetailsName
this.updata.goodsPrice = item.goodsPrice
this.updata.goodsPrice = this.updata.goodsPrice.toFixed(2)
2023-01-13 13:55:31 +08:00
this.goodsPrice = this.updata.goodsPrice
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-10-24 14:42:03 +08:00
}
},
// 查询商品详细信息
goodsDetailsinfo(goodsInfoId) {
2023-01-10 10:35:17 +08:00
let that = this
2022-10-24 14:42:03 +08:00
goodsDetails(goodsInfoId).then(res => {
2023-01-10 10:35:17 +08:00
uni.removeStorageSync('Refresh');
2023-01-10 13:35:23 +08:00
if (res.data.goodsRemark) {
res.data.goodsRemark = res.data.goodsRemark.replace(/\<img/gi,
2022-12-27 09:21:01 +08:00
"<br/> <img class='richPic'")
}
2023-01-10 13:35:23 +08:00
res.data.goodsPictureUrl = this.baseurl + res.data.goodsPictureUrl
this.image = res.data.goodsPictureUrl
2022-11-10 14:20:16 +08:00
var obj = {
2023-01-10 13:35:23 +08:00
image: res.data.goodsPictureUrl,
2022-11-10 14:20:16 +08:00
}
this.info.push(obj)
2023-01-10 13:35:23 +08:00
if (res.data.goodAttributeDetailsLists == null) {
2022-10-31 09:04:45 +08:00
this.goodshow = false
2023-01-10 13:35:23 +08:00
} else if (res.data.goodAttributeDetailsLists.length == 0) {
2022-10-31 09:04:45 +08:00
this.goodshow = false
} else {
2023-01-10 13:35:23 +08:00
res.data.goodAttributeDetailsLists.forEach(e => {
2022-11-10 14:20:16 +08:00
e.attributePitureUrl = this.baseurl + e.attributePitureUrl
2022-10-31 09:04:45 +08:00
e.isActive = false
2022-11-10 14:20:16 +08:00
var objs = {
image: e.attributePitureUrl,
}
this.info.push(objs)
2022-10-31 09:04:45 +08:00
})
2023-01-10 13:35:23 +08:00
this.goodDetailsLists = res.data.goodAttributeDetailsLists
2022-10-31 09:04:45 +08:00
this.goodshow = true
}
2023-01-10 13:35:23 +08:00
this.goodsDetailslist = res.data
2022-10-24 14:42:03 +08:00
this.updata.goodsName = this.goodsDetailslist.goodsName
this.updata.nurseStationId = this.goodsDetailslist.nurseStationId
2023-01-10 10:35:17 +08:00
if (this.goodDetailsLists.length == 1) {
2023-01-10 15:26:26 +08:00
this.goodDetailsLists[0].isActive = true
this.updata.img = this.goodDetailsLists[0].attributePitureUrl
this.updata.goodsAttributeName = this.goodDetailsLists[0].attributeDetailsName
this.updata.goodsPrice = this.goodDetailsLists[0].goodsPrice
2023-01-10 10:35:17 +08:00
this.updata.goodsPrice = this.updata.goodsPrice.toFixed(2)
2023-01-10 15:26:26 +08:00
this.updata.attributeDetailsId = this.goodDetailsLists[0].attributeDetailsId
this.updata.goodsStock = this.goodDetailsLists[0].goodsStock
this.updata.goodsAttributeId = this.goodDetailsLists[0].goodsAttributeId
this.updata.goodsAttributeDetailsId = this.goodDetailsLists[0].attributeDetailsId
2023-01-13 13:55:31 +08:00
} else {
2023-01-10 10:35:17 +08:00
var list = {}
2023-01-10 13:35:23 +08:00
this.goodsDetailslist.goodAttributeDetailsLists.forEach(e => {
2023-01-10 10:35:17 +08:00
if (e.goodsAttributeId == this.goodsAttributeId) {
list = e
e.isActive = true
this.updata.goodsAttributeId = e.goodsAttributeId
this.updata.goodsAttributeDetailsId = e.attributeDetailsId
}
})
this.updata.img = list.attributePitureUrl
this.updata.goodsAttributeName = list.attributeDetailsName
this.updata.goodsPrice = list.goodsPrice
this.updata.attributeDetailsId = list.attributeDetailsId
this.updata.goodsStock = list.goodsStock
this.updata.img = list.attributePitureUrl
}
2022-10-24 14:42:03 +08:00
// this.updata.nurseStationId = this.goodsDetailslist.nurseStationId
2023-01-10 13:35:23 +08:00
// this.updata.img = res.data.goodsPictureUrl
2023-01-10 10:35:17 +08:00
// this.updata.goodsAttributeName = ''
// this.updata.goodsPrice = 0
// this.updata.attributeDetailsId = ''
// this.updata.goodsStock = 0
// this.updata.img = list.image
})
},
//跳转到全部收货地址
upaddress() {
2023-01-13 13:55:31 +08:00
if (this.updata.receiver) {
uni.navigateTo({
url: `/pages/modifyAddress/modifyAddress?updata=${JSON.stringify(this.updata)}`
})
} else {
uni.navigateTo({
url: '/pages/information/information'
})
}
2022-10-24 14:42:03 +08:00
},
2022-11-09 16:38:05 +08:00
// 收件人
goodsList() {
goodPatientInfo(this.updata.patientId).then(res => {
2023-01-13 13:55:31 +08:00
// res.data.forEach(e => {
// e.address = e.provinceName + e.cityName + e.regionName + e.streetName + e
// .receiveAddress
// })
var list = res.data.filter(e => e.defaultAddressFlag == 1)
if (list.length >= 1) {
this.updata.receiver = list[0].receiveName
this.updata.receiveAddress = list[0].areaName + list[0].receiveAddress
this.updata.phone = list[0].receivePhone
this.userid = list[0].id
} else {
this.updata.receiver = res.data[0].receiveName
this.updata.receiveAddress = res.data[0].areaName + res.data[0].receiveAddress
this.updata.phone = res.data[0].receivePhone
this.userid = res.data[0].id
}
2022-11-09 16:38:05 +08:00
})
},
2022-10-24 14:42:03 +08:00
},
onLoad(options) { //获取传值
2023-01-10 10:35:17 +08:00
var that = this
2023-01-13 13:55:31 +08:00
this.goodsPrice = options.goodsPrice //页面价格
2023-01-10 10:35:17 +08:00
this.goodsAttributeId = options.goodsAttributeId
2022-10-31 09:04:45 +08:00
this.updata.buySource = options.buySource
2022-11-14 12:31:02 +08:00
this.goodsInfoId = options.goodsInfoId
2023-01-13 13:55:31 +08:00
const value = uni.getStorageSync('patientId');
if (value) {
that.updata.patientId = value
that.goodsList()
} else {}
2023-01-10 10:35:17 +08:00
},
onShow() {
var that = this
this.baseurl = baseurl
this.usershow = false
this.goodsDetailsinfo(this.goodsInfoId)
goodPatientInfo(this.updata.patientId).then(res => {
var user = res.data.filter(e => e.id == this.userid)
2023-01-13 13:55:31 +08:00
if (user.length >= 1) {
// user[0].address = user[0].provinceName + user[0].cityName + user[0].regionName + user[0]
// .streetName + user[0].receiveAddress
this.updata.receiver = user[0].receiveName
this.updata.receiveAddress = user[0].areaName + user[0].receiveAddress
this.updata.phone = user[0].receivePhone
this.userid = user[0].id
} else {
// res.data.forEach(e => {
// e.address = e.provinceName + e.cityName + e.regionName + e.streetName + e
// .receiveAddress
// })
2023-01-10 10:35:17 +08:00
this.updata.receiver = res.data[0].receiveName
2023-01-13 13:55:31 +08:00
// this.updata.receiveAddress = res.data[0].address
this.updata.receiveAddress = res.data[0].areaName + res.data[0].receiveAddress
2023-01-10 10:35:17 +08:00
this.updata.phone = res.data[0].receivePhone
2023-01-13 13:55:31 +08:00
this.userid = res.data[0].id
2023-01-10 10:35:17 +08:00
}
})
let useritem = null
uni.$on('updata', function(data) {
that.updata = JSON.parse(data.updata)
if (data.useritem) {
useritem = JSON.parse(data.useritem)
that.updata.receiver = useritem.receiveName
that.updata.phone = useritem.receivePhone
2023-01-13 13:55:31 +08:00
// that.updata.receiveAddress = useritem.address
that.updata.receiveAddress = useritem.areaName + useritem.receiveAddress
2023-01-10 10:35:17 +08:00
that.userid = useritem.id
}
})
2022-11-09 16:38:05 +08:00
},
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>