123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644 |
- <template>
- <view class="pages">
-
- <view class="scrollPage-header">
- <view :style="{height:statusBarHeight+'px'}"></view>
- <view class="header-title">
- <view class="header-left" @click="goBack">
- <image style="width: 16px; height: 16px;margin-right:3px;" mode="aspectFit" src="../static/arrow-left.png"></image>
- <text>返回</text>
- </view>
- <view class="header-right"></view>
- </view>
- </view>
-
- <view class="scrollPage-content">
- <view class="product-info" v-if="detail">
- <view :style="{height:statusBarHeight+'px'}"></view>
- <u-swiper mode="number" :border-radius="0" bg-color="#000" img-mode="widthFix" :interval="3000" :height="450" :list="imgList"></u-swiper>
- <view class="product-info-text">
- <view class="product-info-text-title">
- {{detail.productName}}
- <view class="copyText" @click="copy(detail.product.origCode)">复制</view>
- </view>
- <view class="product-info-text-attr">
- <view class="product-info-price flex align_center">
- ¥<text class="price-red">{{hasLogin ? detail.price : '***'}}</text>
- <uni-tag style="margin-left: 10px;" size="mini" :circle="true" v-if="detail.status==0 || detail.dealerScopeFlag==0" :text="detail.status==0?'已下架':'已售罄'"></uni-tag>
- </view>
- <view class="product-info-nums">
- <view class="share">
- <button open-type="share"><u-icon :size='24' name="zhuanfa"></u-icon> 分享</button>
- </view>
- </view>
- </view>
- </view>
- </view>
- <u-divider bg-color="">商品详情</u-divider>
- <view class="product-info-guige" v-if="detail&&detail.product">
- <view class="row">品牌:<text>{{detail.product.productBrandName||'--'}}</text></view>
- <view class="row">原厂编码:<text>{{detail.product.origCode||'--'}} </text> <view class="copyText" v-if="detail.product.origCode" @click="copy(detail.product.origCode)">复制</view></view>
- <view class="row">产品编码:<text>{{detail.product.code||'--'}}</text> <view class="copyText" v-if="detail.product.code" @click="copy(detail.product.code)">复制</view></view>
- <view class="row">条形码:<text>{{detail.product.qrCode||'--'}}</text> <view class="copyText" v-if="detail.product.qrCode" @click="copy(detail.product.qrCode)">复制</view></view>
- <view class="row-ban">商品尺寸:<text>{{detail.product.size||'--'}}</text></view>
- <view class="row-ban">计量单位:<text>{{detail.product.unit||'--'}}</text></view>
- <view class="row-ban">重量:<text>{{detail.product.weight||'--'}}</text></view>
- <view class="row-ban">包装数:<text>{{ (detail.product.packQty) || '--' }}{{ detail.product.packQty ? detail.product.unit : '' }}/{{ detail.product.packQtyUnit||'--' }}</text></view>
- </view>
- <view class="product-info-content">
- <rich-text v-if="detail && detail.product && detail.product.description" :nodes="detail.product.description"></rich-text>
- <view v-else style="font-size: 12px;color: #999;text-align: center;">暂无产品介绍</view>
- </view>
- </view>
-
- <view class="scrollPage-footer">
- <view class="scrollPage-footer-box">
- <view class="footer-left">
- <view class="footer-left-item" @click="toCart">
- <u-icon :size='50' color="#666" name="shopping-cart"></u-icon>
- <text class="footer-left-item-text">购物车</text>
- <text class="badge" v-if="totalNum">{{totalNum>99?'99+':totalNum}}</text>
- </view>
- </view>
- <view class="footer-right">
- <view class="footer-right-item" @click="addCart">
- <text>加入购物车</text>
- </view>
- <view class="footer-right-item" @click="toBuy">
- <text>立即购买</text>
- </view>
- </view>
- </view>
- <view :style="{height:safeAreaBottom+'px'}"></view>
- </view>
-
- <page-container
- :show="showPopu"
- :round="true"
- :z-index="100"
- position="bottom"
- custom-style="height:30%"
- @afterleave="closePopu">
- <view class="popu-content" v-if="detail">
- <view class="popu-close" @click="showPopu=false">
- <uni-icons size="26" type="closeempty"></uni-icons>
- </view>
- <view class="pupu-box">
- <view class="popu-content-img">
- <image style="width: 100px; height: 100px;" mode="aspectFit" :src="detail.productMsg"></image>
- </view>
- <view class="popu-content-info">
- <view class="popu-content-info-title">{{detail.productName}}</view>
- <view class="popu-content-box">
- <view class="popu-content-price">¥<text class="price-red">{{hasLogin?detail.price:'***'}}</text></view>
- <view class="popu-content-num flex align_center">
- <text style="margin-right: 10px;">数量</text>
- <uni-number-box v-model="qty" :min="1" :max="999999"></uni-number-box>
- </view>
- </view>
- </view>
- </view>
- <view class="popu-content-btn">
- <view class="popu-content-btn-item" @click="toBuy">确定采购</view>
- </view>
- <view :style="{height:safeAreaBottom+'px'}"></view>
- </view>
- </page-container>
-
-
- <u-popup v-model="showPopup" mode="center" :border-radius="20" closeable>
- <view style="background-color: #fff;padding: 1rem;">
- <u-image width="533" height="415" src="/static/authimg.jpg"></u-image>
- <view style="padding-top:1rem;" class="flex justify_center">
- <u-button @click="toAuthStore()" shape="circle" :custom-style="{background:'#066cff',color:'#fff',width:'350rpx'}">开始认证</u-button>
- </view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import {
- mapState,
- mapMutations,
- } from 'vuex'
- import { addCart, getCartCount } from '@/api/cart.js'
- import { getShopDetail } from '@/api/shop.js'
- import { purchaseSave, purchaseCheck } from '@/api/purchase.js'
- export default {
- data() {
- return {
- showPopu: false,
- showPopup: false,
- statusBarHeight: 0,
- safeAreaBottom: 0,
- imgList: [],
- totalNum: 0 ,
- shopProductSn: null,
- detail: null,
- qty: 1,
- }
- },
- onLoad(option) {
-
- this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
- this.safeAreaBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
- this.shopProductSn = option.sn
-
- this.getDetail()
- },
- onShow(){
-
- if(this.hasLogin&&this.userInfo.sysUserFlag == '1'){
-
- this.cartCount()
- }
- },
-
- onShareAppMessage(e){
- return {
- title: this.detail ? this.detail.productName : '商品名称',
- path: '/pagesB/shopiing/productDetail?sn='+this.shopProductSn,
- imageUrl:this.detail ? this.detail.productMsg : '',
- type: '1'
- }
- },
- computed: {
- ...mapState(['hasLogin']),
-
- userInfo(){
- return this.$store.state.vuex_userInfo
- },
- },
- methods: {
-
- goBack(){
- uni.navigateBack()
- },
-
- copy(text){
- uni.setClipboardData({
- data: text,
- })
- },
-
- toAuthStore(){
- this.showPopup = false
- uni.navigateTo({
- url: '/pages/storeManage/storeAuth'
- })
- },
-
- getDetail(){
- uni.showLoading({
- title: '加载中'
- })
- const storeShelf = this.$store.state.vuex_storeShelf
- const dealerSn = this.hasLogin && this.userInfo && this.userInfo.sysUserFlag == '1'&&storeShelf ? storeShelf.dealerSn : ''
-
- getShopDetail({
- shopProductSn: this.shopProductSn,
- dealerSn: dealerSn
- }).then(res => {
- if(res.status == 200){
- this.detail = res.data
- if(res.data && res.data.productPicList){
- res.data.productPicList.forEach(item => {
- this.imgList.push(item.imageUrl)
- })
- }else{
- this.imgList.push(res.data.productMsg)
- }
- }
- uni.hideLoading()
- })
- },
-
- cartCount(){
- getCartCount({}).then(res => {
- if(res.status == 200){
- this.totalNum = res.data?res.data.qty:0
- }
- })
- },
-
- addCart(){
- if(this.hasLogin){
-
- if(this.userInfo.sysUserFlag == '0'){
- this.showPopup = true
- }else{
- uni.showLoading({
- title: '加入中...',
- mask: true
- })
-
- addCart({
- qty: 1,
- price: this.detail.price,
- productSn: this.detail.productSn
- }).then(res => {
- if(res.status == 200){
- this.cartCount()
- uni.hideLoading()
- }
- })
- }
- }else{
- uni.navigateTo({
- url: '/pages/login/login'
- })
- }
- },
-
- toCart(){
- if(this.hasLogin){
-
- if(this.userInfo.sysUserFlag == '0'){
- this.showPopup = true
- }else{
- uni.navigateTo({
- url: '/pagesB/cart/index'
- })
- }
- }else{
- uni.navigateTo({
- url: '/pages/login/login'
- })
- }
- },
-
- toBuy(){
- if(this.hasLogin){
-
- if(this.userInfo.sysUserFlag == '0'){
- this.showPopup = true
- }else{
- if(this.detail.status==0 || this.detail.dealerScopeFlag==0){
- uni.showToast({
- title: '此商品已'+(this.detail.status==0?'下架':'售罄'),
- icon: 'none'
- })
- }else{
-
- if(!this.showPopu){
- this.showPopu = true
- }else{
-
- this.submitOrder()
- }
- }
- }
- }else{
- uni.navigateTo({
- url: '/pages/login/login'
- })
- }
- },
-
- submitOrder(){
- uni.showLoading({
- title: '提交中...',
- mask: true
- })
- const _this = this
- purchaseCheck({detailList: [{
- productSn:this.detail.productSn,
- productCode:this.detail.productCode,
- qty: this.qty,
- price:this.detail.price,
- }]}).then(res => {
- if(res.status == 200){
- const successList = res.data.successList.map(item => {
- return {
- productSn:item.productSn,
- productCode: item.productCode,
- qty: item.qty,
- price:item.price
- }
- })
- const removeList = res.data.removeList.map(item => item.productCode)
- const selloutList = res.data.selloutList.map(item => item.productCode)
-
- if(removeList.length || selloutList.length){
- uni.showModal({
- title: '提示',
- content: (removeList.length ? `产品${removeList.join(',')}已下架,`:'')+(selloutList.length?`产品${selloutList.join(',')}已售罄,`:'')+`不可采购。`+(successList.length?'是否继续采购其他产品?':''),
- showCancel: successList.length,
- confirmText: successList.length?'确定':'只知道了',
- success(ret) {
- uni.hideLoading()
- if(ret.confirm && successList.length){
- _this.submitForm(successList)
- }
- }
- })
- }else{
-
- _this.submitForm(successList)
- }
- }else{
- uni.hideLoading()
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- })
- },
- submitForm(detailList){
- purchaseSave({
- detailList: detailList
- }).then(res => {
- uni.hideLoading()
- if(res.status == 200){
- res.data.detailList = []
- this.$store.state.vuex_tempData = res.data
- this.showPopu = false
- this.submitOk = true
- }else{
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- })
- },
-
- closePopu(){
- this.showPopu = false
- this.qty = 1
- uni.hideLoading()
-
- if(this.submitOk){
- uni.navigateTo({
- url: "/pagesB/procureOrder"
- })
- }
- },
- }
- }
- </script>
- <style lang="less">
- .pages {
- height: 100vh;
- display: flex;
- flex-direction: column;
- .scrollPage-header{
- z-index: 1;
- width: 100%;
- position:fixed;
- left: 0;
- top: 0;
- .header-title{
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 10px;
- height: 44px;
- .header-left{
- display: flex;
- align-items: center;
- text{
- font-size: 14px;
- color: #333333;
- }
- background-color: rgba(255,255,255,0.6);
- box-shadow: 0px 1px 0px 0px #E6E6E6;
- border-radius: 50px;
- padding: 3px 6px 3px;
- }
- .header-right{
- width: 50px;
- }
- }
- }
- .copyText{
- background-color: #efefef;
- border-radius: 100rpx;
- padding: 0 20rpx;
- color: #03A9F4;
- font-size: 20rpx;
- display: inline-block;
- margin-left: 20rpx;
- height: 44rpx;
- line-height: 44rpx;
- }
- .scrollPage-content{
- flex: 1;
- overflow-y: auto;
- .product-info{
- background:#fff;
- margin-bottom: 10px;
- .product-info-text{
- padding: 10px;
- .product-info-text-title{
- font-weight: bold;
- color: #333333;
- line-height: 22px;
- margin-bottom: 5px;
- }
- .product-info-text-attr{
- display: flex;
- align-items: center;
- justify-content: space-between;
- .product-info-price{
- font-size: 14px;
- color: #FF0000;
- .price-red{
- font-size: 24px;
- }
- }
- .product-info-nums{
- font-size: 12px;
- color: #999999;
- >view{
- display: flex;
- align-items: center;
- }
- .share{
- button{
- width: auto;
- padding: 0;
- border: 0;
- background: none;
- line-height: normal;
- margin: 0;
- display: inline;
- font-size: 12px;
- color: #999;
- &::after{
- border:none;
- }
- /deep/ .u-icon{
- margin-right: 3px;
- }
- }
- }
- }
- }
- }
- }
- .product-info-guige{
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- background:#fff;
- margin: 10px 0;
- padding: 10px;
- line-height: 28px;
- .row{
- width: 100%;
- }
- .row-ban{
- width: 50%;
- }
- >view{
- color: #999;
- text{
- color: #333333;
- }
- }
- }
- .product-info-content{
- background:#fff;
- margin-bottom: 10px;
- padding: 10px;
- line-height: 28px;
- }
- }
- .scrollPage-footer{
- background-color: #FFFFFF;
- width: 100%;
- position: fixed;
- left: 0;
- bottom: 0;
- .scrollPage-footer-box{
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 50px;
- }
- .footer-left{
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 35%;
- .footer-left-item{
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 0 15px;
- position: relative;
- .footer-left-item-text{
- font-size: 12px;
- color: #666666;
- }
- .badge{
- background: #f44336;
- color: #fff;
- position: absolute;
- right: 0;
- top: -8px;
- font-size: 12px;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 50rpx;
- padding: 0 10rpx;
- }
- }
- }
- .footer-right{
- width: 60%;
- height: 100%;
- display: flex;
- align-items: center;
- .footer-right-item{
- height: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width: 50%;
- font-size: 14px;
- color: #FFFFFF;
- }
- .footer-right-item:first-child{
- background-color: #FF9900;
- }
- .footer-right-item:last-child{
- background-color: #FF0000;
- }
- }
- }
-
- .popu-content{
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 10px;
- .popu-close{
- padding: 10px;
- position: absolute;
- right: 0;
- top: 0;
- }
- .pupu-box{
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-top: 25px;
- }
- .popu-content-img{
- border-radius: 10px;
- border: 1px solid #eee;
- }
- .popu-content-info{
- padding: 0 0 0 10px;
- .popu-content-info-title{
- font-size: 14px;
- font-weight: bold;
- }
- }
- .popu-content-box{
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-top: 10px;
- .popu-content-price{
- font-size: 14px;
- color: #d50e0e;
- .price-red{
- font-size: 24px;
- }
- }
- .popu-content-num{
- font-size: 12px;
- color: #999999;
- padding: 0 10px;
- }
- }
- .popu-content-btn{
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-top: 20px;
- .popu-content-btn-item{
- width: 60%;
- height: 40px;
- background-color: #f70000;
- color: #FFFFFF;
- font-size: 14px;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 100px;
- }
- }
- }
- }
- </style>
|