123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281 |
- <template>
- <view class="pages">
- <!-- head -->
- <view class="scrollPage-header">
- <view :style="{height:statusBarHeight+'px'}"></view>
- <view class="header-title">
- <view class="header-left" @click="goBack">
- <uni-icons type="arrowleft" size="20"></uni-icons>
- <text>{{isShare?'首页':'返回'}}</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" img-mode="aspectFit" :interval="3000" :height="450" :list="imgList" @click="viewImg"></u-swiper>
- <view class="product-info-text">
- <view class="product-info-text-title">
- {{detail.productName}}
- <!-- <view class="copyText" @click="copy(detail.productName)">复制</view> -->
- <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-text-attr">
- <view class="product-info-price flex align_center" v-if="!hasLogin">
- ¥***
- </view>
- <view class="flex align_center" v-else>
- <view class="product-info-price">
- ¥<text>{{detail.priceStr[0]}}</text>.{{detail.priceStr[1]}}
- </view>
- <view class="flex align_center rebate-tag" v-if="detail.promoType=='BUY_PROD_GIVE_VALID'">
- 返<text>{{detail.resultValue}}</text>元
- </view>
- <view class="flex align_center rebate-tag" v-if="detail.promoType=='BUY_PROD_GIVE_PROD'">
- 买{{detail.conditionValue}}赠{{detail.resultValue}}
- </view>
- <view class="flex align_center tejia-tag" v-if="detail.promoType=='PROMO_PROD'">
- 特价<text>¥{{detail.orginPrice}}</text>
- </view>
- <view class="flex align_center tejia-tag" v-if="detail.shopProductSubsidy&&!detail.shopPromoProduct">
- 可抵扣<text>¥{{detail.shopProductSubsidy.subsidyAmount}}</text>
- </view>
- </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">商品尺寸:<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="flex align_center row-info">
- <view class="flex"><u-icon :size='24' name="checkbox-mark"></u-icon> <view class="txt">由汽配商发货</view></view>
- <view class="flex"><u-icon :size='24' name="checkbox-mark"></u-icon> <view class="txt">退换货及售后请联系汽配商</view></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 v-if="isShare" class="footer-left-item" @click="goBack">
- <u-icon :size='50' color="#666" name="home"></u-icon>
- <text class="footer-left-item-text">首页</text>
- </view>
- <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="toAddCart">
- <text>加入购物车</text>
- </view>
- <view class="footer-right-item" @click="toBuy">
- <text>立即购买</text>
- </view>
- </view>
- </view>
- <view :style="{height:safeAreaBottom+'px'}"></view>
- </view>
- <!-- 购物车动画 -->
- <uni-cart-animation ref="cartAnimation" @animationfinish="animationfinish"></uni-cart-animation>
- <!-- 立即购买和付款 -->
- <page-container
- :show="showPopu"
- :round="true"
- :z-index="100"
- position="bottom"
- customStyle="border-radius:15px 15px 0 0;"
- @beforeleave="beforeClosePopu"
- @afterleave="closePopu">
- <!-- 确认订单 -->
- <view class="popu-content" v-if="detail&&!showPay">
- <view class="popu-close" @click="cancelBuy">
- <uni-icons size="26" type="closeempty"></uni-icons>
- </view>
- <view class="pupu-box">
- <view class="popu-content-img">
- <image style="width: 80px; height: 80px;" mode="aspectFit" :src="detail.productMsg||'/static/def_imgs.png'"></image>
- </view>
- <view class="popu-content-info">
- <view class="popu-content-info-title">
- <text class="ellipsis-two">{{detail.productName}}</text>
- </view>
- <view class="popu-content-info-code">
- <text class="ellipsis-two">{{detail.product.code}}</text>
- </view>
- <view class="popu-content-box">
- <view class="popu-content-price" v-if="hasLogin">
- ¥<text>{{detail.priceStr[0]}}</text>.{{detail.priceStr[1]}}
- </view>
- <view class="popu-content-price" v-else>¥***</view>
- <view class="flex align_center rebate-tag" v-if="hasLogin&&detail.promoType=='BUY_PROD_GIVE_VALID'">
- 返<text>{{detail.resultValue}}</text>元
- </view>
- <view class="flex align_center rebate-tag" v-if="hasLogin&&detail.promoType=='BUY_PROD_GIVE_PROD'">
- 买{{detail.conditionValue}}赠{{detail.resultValue}}
- </view>
- <view class="flex align_center tejia-tag" v-if="hasLogin&&detail.promoType=='PROMO_PROD'">
- 特价<text>¥{{detail.orginPrice}}</text>
- </view>
- <view class="flex align_center rebate-tag"
- v-if="hasLogin&&detail.shopProductSubsidy&&detail.shopProductSubsidy.subsidyAmount<item.price&&!detail.shopPromoProduct">
- 可抵扣<text>¥{{detail.shopProductSubsidy.subsidyAmount}}</text>
- </view>
- </view>
- <view style="margin-top: 10px;" class="popu-content-num flex align_center justify_end">
- <text>数量</text>
- <view class="flex align_center qty-box">
- <view class="qty-btn" @click="changeQty(qty-1)" :class="(qty <= 1)?'qty-disabled':''">-</view>
- <view class="qty-num" @click="$refs.showPopu.open()" :style="{width:Number(qty).toString().length*8+10+'px'}">
- {{qty}}
- </view>
- <view class="qty-btn" @click="changeQty(qty+1)" :class="(qty >= 999)?'qty-disabled':''">+</view>
- </view>
- </view>
- </view>
- </view>
- <view class="pupu-box gift-box" v-if="giftNum">
- <view class="popu-content-img">
- <image style="width: 58px; height: 58px;" mode="aspectFit" :src="detail.productMsg||'/static/def_imgs.png'"></image>
- </view>
- <view class="popu-content-info">
- <view class="popu-content-info-title flex align_center">
- <view class="flex align_center rebate-tag">
- 赠品
- </view>
- <view class="ellipsis-two">{{detail.productName}}</view>
- </view>
- <view class="popu-content-box">
- <view class="popu-content-num flex align_center">
- <text>X</text> {{giftNum}}
- </view>
- </view>
- </view>
- </view>
- <view class="pupu-box-item">
- <view class="flex align_center justify_between" v-if="shelfInfo">
- <text>配送商:{{shelfInfo.dealerName}}</text>
- <view @click="callPhone()"><uni-icons size="18" type="phone" color="dodgerblue"></uni-icons><text style="font-size:12px;">拨打</text></view>
- </view>
- <view v-if="hasBalancePay&&storeAccount.giveBalance&&!isAddCart">
- <view class="totalBar-box">
- <view class="flex align_center justify_between">
- <view>总金额</view>
- <view><text class="pf">¥</text>{{totalAmount}}</view>
- </view>
- <view class="flex align_center justify_between">
- <view v-if="storeAccount">抵扣(余额:<text class="pf">¥</text>{{storeAccount.giveBalance}})</view>
- <view class="flex align_center" v-if="detail.shopProductSubsidy" @click="hasKdk=!hasKdk">
- <uni-icons size="18" :type="hasKdk?'checkbox-filled':'checkbox'" color="#2196f3"></uni-icons>
- <text class="pf">¥</text>{{detail.shopProductSubsidy.subsidyAmount}}
- </view>
- </view>
- <view class="flex align_center justify_between" v-if="detail.shopProductSubsidy">
- <view>合计</view>
- <view><text class="pf">¥</text>{{Number(totalAmount-detail.shopProductSubsidy.subsidyAmount).toFixed(2)}}</view>
- </view>
- </view>
- <payOptions v-model="payType" :balance="storeAccount?storeAccount.rechargeBalance:0"></payOptions>
- </view>
- </view>
- <view class="popu-content-btn">
- <view class="popu-content-btn-item cartbtn" v-if="isAddCart" @click="submitCart($event)">加入购物车</view>
- <view class="popu-content-btn-item okbtn" v-if="!isAddCart" @click="toBuy">
- {{hasPay?'立即支付':'确定采购'}}
- <text class="payAmount">¥{{payAmount}}</text>
- </view>
- </view>
- </view>
- <!-- 确认付款 -->
- <view class="popu-content" v-if="payInfo&&showPay">
- <view class="popu-close" @click="cancelPay">
- <uni-icons size="26" type="closeempty"></uni-icons>
- </view>
- <view class="pupu-box-pay-item">
- <view class="popu-content-amount flex align_center justify_center">
- <view>¥{{payInfo.totalAmount}}</view>
- </view>
- <view class="flex align_center justify_between" v-if="payInfo.totalSpecialGiveAmount>0">
- <text>总优惠</text>
- <view class="popu-content-price">¥{{payInfo.totalSpecialGiveAmount}}</view>
- </view>
- <view class="flex align_center justify_between" v-if="payInfo.totalTicketGiveAmount>0">
- <text>代金券</text>
- <view class="popu-content-price">¥{{payInfo.totalTicketGiveAmount}}</view>
- </view>
- <view style="height: 10px;"></view>
- <view class="popu-content-title flex align_center justify_between">
- <text>付款方式</text>
- <view></view>
- </view>
- <view class="popu-content-pay flex align_center justify_between">
- <view class="flex align_center"><uni-icons size="20" type="weixin" color="#4CAF50"></uni-icons> <text style="margin-left: 5px;">微信支付</text></view>
- <view><uni-icons size="22" type="checkbox-filled" color="red"></uni-icons></view>
- </view>
- </view>
- <view class="popu-content-btn">
- <view class="popu-content-btn-item okbtn" @click="confirmPay">确定付款</view>
- </view>
- </view>
- </page-container>
- <!-- 修改数量弹框 -->
- <uni-popup ref="showPopu" type="center" style="z-index: 1500;" :maskClick="false">
- <view class="popu-nums-content">
- <view class="popu-close" @click="$refs.showPopu.close()">
- <uni-icons size="26" type="closeempty"></uni-icons>
- </view>
- <view class="popu-content-title flex align_center justify_center"><text>修改商品数量</text></view>
- <view class="popu-content-num flex align_center justify_center">
- <uni-number-box v-model="qty" :size="28" :input-width="280" :input-height="70" :min="1" :max="999"></uni-number-box>
- </view>
- <view class="popu-content-btn">
- <view class="popu-content-btn-item okbtn" @click="$refs.showPopu.close()">确定</view>
- </view>
- </view>
- </uni-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, purchasePay } from '@/api/purchase.js'
- import { toAuthStore, toLogin } from "@/utils/index.js"
- import payOptions from '../components/payOptions.vue'
- export default {
- components: {
- payOptions
- },
- data() {
- return {
- loading: false,
- showPopu: false, // 弹框
- statusBarHeight: 0, // 状态栏高度
- safeAreaBottom: 0, // 底部安全区域高度
- imgList: [],
- shopProductSn: null,
- detail: null,
- qty: 1,// 数量
- isShare: false ,// 是否从分享打开的
- busPos:{
- x: 10,
- y:uni.getSystemInfoSync().windowHeight - 30
- },
- submitOk: false, // 是否成功
- cacelOk: false, // 是否取消
- refashOk: false, // 是否刷新页面
- showPay: false, // 是否显示付款信息
- isAddCart: false, // 是否加入购物车
- payData: null, // 支付参数
- payType: 0, // 支付方式,抵扣、还是微信
- hasKdk: false,
- disKdk: false,
- }
- },
- onLoad(option) {
- this.isShare = !!option.share
- // 计算安全区域
- this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
- this.safeAreaBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
- this.shopProductSn = option.sn
- // 获取产品详情
- this.getDetail()
- },
- // 分享
- onShareAppMessage(e){
- return {
- title: this.detail ? this.detail.productName : '商品名称',
- path: '/pagesB/shopiing/productDetail?sn='+this.shopProductSn+'&share=1',
- imageUrl:this.detail ? this.detail.productMsg : '',
- type: '1'
- }
- },
- computed: {
- ...mapState(['hasLogin']),
- // 登录用户信息
- userInfo(){
- return this.$store.state.vuex_userInfo
- },
- // 货架经销商信息
- shelfInfo(){
- return this.$store.state.vuex_storeShelf
- },
- //是否开启线上支付
- hasPay(){
- const shelfInfo = this.shelfInfo
- return shelfInfo&&shelfInfo.payOnlineFlag&&shelfInfo.payOnlineFlag=='1'
- },
- // 最小支付金额
- minPayAmount(){
- const shelfInfo = this.shelfInfo
- return shelfInfo&&shelfInfo.minAmount ? shelfInfo.minAmount : 0
- },
- // 抵扣余额支付是否可用,有【余额支付权限】且该产品有抵扣金额
- hasBalancePay(){
- return this.$store.state.vuex_showBalanceAuth
- },
- storeAccount(){
- return this.$store.state.vuex_storeAccount
- },
- // 经销商电话
- dealerPhone(){
- const shelfInfo = this.shelfInfo
- return shelfInfo&&shelfInfo.contactMobile ? shelfInfo.contactMobile : ''
- },
- totalNum(){
- return this.hasLogin&&this.userInfo.sysUserFlag == '1' ? this.$store.state.vuex_cartTotal : 0
- },
- // 总金额
- totalAmount(){
- return this.hasLogin&&this.detail&&this.detail.price * this.qty
- },
- // 赠品数量
- giftNum(){
- return this.detail && this.detail.promoType=='BUY_PROD_GIVE_PROD' ? Math.floor(this.qty / this.detail.conditionValue)*this.detail.resultValue : 0
- },
- // 支付总金额
- payAmount(){
- const price = this.detail && this.detail.priceStr ? this.detail.priceStr.join('.') : 0
- return price ? Number(price*this.qty).toFixed(2) : 0
- },
- // 付款信息
- payInfo(){
- return this.$store.state.vuex_tempOrderData
- }
- },
- methods: {
- // 返回
- goBack(){
- if(this.isShare){
- uni.reLaunch({
- url: '/pages/index/index'
- })
- }else{
- uni.navigateBack()
- }
- },
- // 复制
- copy(text){
- uni.setClipboardData({
- data: text,
- success: function () {
- uni.showToast({
- title: '复制成功'
- })
- }
- })
- },
- viewImg(index){
- uni.previewImage({
- urls: this.imgList
- })
- },
- // 联系经销商
- callPhone() {
- if(this.dealerPhone!=''){
- uni.makePhoneCall({
- phoneNumber: this.dealerPhone
- })
- }
- },
- // 产品详情
- 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){
- if(res.data.productPicList){
- res.data.productPicList.forEach(item => {
- this.imgList.push(item.imageUrl||'/static/def_imgs.png')
- })
- }else{
- this.imgList.push(res.data.productMsg||'/static/def_imgs.png')
- }
- const a = res.data.shopPromoProduct
- let bprice = res.data.price
- if(a){
- res.data.promoType = a.promoType
- res.data.resultValue = a.resultValue
- res.data.conditionValue = a.conditionValue
- res.data.discountType = a.discountType
- res.data.promoProductSn = a.promoProductSn
- res.data.promoSn = a.promoSn
- res.data.orginPrice = res.data.price
- // 特价
- if(res.data.promoType=='PROMO_PROD'){
- bprice =res.data.conditionValue
- }
- }
- res.data.priceStr = Number(bprice).toFixed(2).toString().split('.')
- // 可抵扣金额小于抵扣金额且大于0
- const kdk = res.data.shopProductSubsidy.subsidyAmount>0&&res.data.shopProductSubsidy.subsidyAmount<this.storeAccount.giveBalance
- this.hasKdk = kdk
- this.disKdk = !kdk
- }
- }
- uni.hideLoading()
- })
- },
- animationfinish(){
- this.loading = false
- },
- changeQty(value) {
- const max = 999
- const v = value > max ? max : (value==''||value==0?1:value)
- this.qty = v
- },
- // 加入购物车
- toAddCart(){
- // 未登录
- if(this.hasLogin){
- // 游客未认证
- if(this.userInfo.sysUserFlag == '0'){
- toAuthStore()
- }else{
- // 打开确认数量弹框
- this.isAddCart = true
- this.showPopu = true
- }
- }else{
- toLogin()
- }
- },
- // 确定加入购物车
- submitCart(event){
- if(this.loading){
- return
- }
- this.loading = true
- this.$refs.cartAnimation.touchOnGoods(event,this.busPos);
- // 加入购物车
- addCart({
- qty: this.qty,
- price: this.detail.price,
- productSn: this.detail.productSn
- }).then(res => {
- if(res.status == 200){
- uni.$emit('refashCart')
- this.showPopu = false
- }
- })
- },
- // 打开购物车页面
- toCart(){
- if(this.hasLogin){
- // 游客未认证
- if(this.userInfo.sysUserFlag == '0'){
- toAuthStore()
- }else{
- uni.navigateTo({
- url: '/pagesB/cart/index'
- })
- }
- }else{
- toLogin()
- }
- },
- // 立即购买
- toBuy(){
- if(this.hasLogin){
- // 游客未认证
- if(this.userInfo.sysUserFlag == '0'){
- toAuthStore()
- }else{
- if(this.detail.status==0 || this.detail.dealerScopeFlag==0){
- uni.showModal({
- content: '此商品已'+(this.detail.status==0?'下架':'售罄'),
- showCancel:false,
- confirmText:'知道了'
- })
- }else{
- // 打开数量选择弹框
- if(!this.showPopu){
- this.showPopu = true
- }else{
- if(this.hasPay && this.minPayAmount>this.payAmount){
- uni.showModal({
- content: '支付金额不能小于'+this.minPayAmount+'元!',
- showCancel:false,
- confirmText:'知道了'
- })
- }else{
- // 去结算生产订单
- this.creatOrder()
- }
- }
- }
- }
- }else{
- toLogin()
- }
- },
- // 取消立即购买
- cancelBuy(){
- this.resetPage()
- },
- // 去结算
- creatOrder(){
- 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,
- promoSn: this.detail.promoSn
- }]}).then(res => {
- uni.hideLoading()
- if(res.status == 200){
- const successList = res.data.successList ? res.data.successList.map(item => {
- return {
- productSn:item.productSn,
- productCode: item.productCode,
- qty: item.qty,
- price:item.price,
- promoSn: item.promoSn
- }
- }) : []
- const removeList = res.data.removeList ? res.data.removeList.map(item => item.productCode) : []
- const selloutList = res.data.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) {
- if(ret.confirm && successList.length){
- _this.submitForm(successList)
- }
- }
- })
- }else{
- const promoChangeFlag = res.data.promoChangeFlag
- // 活动变更
- if(promoChangeFlag){
- uni.showModal({
- title: '提示',
- content: '促销活动已变更,请刷新?',
- confirmText:'确定刷新',
- success(ret) {
- if(ret.confirm){
- _this.showPopu = false
- _this.refashOk = true
- }
- }
- })
- return
- }
- // 直接提交
- _this.submitForm(successList)
- }
- }else{
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- })
- },
- // 创建订单
- submitForm(detailList){
- uni.showLoading({
- title: '提交中...',
- mask: true
- })
- purchaseSave({
- detailList: detailList
- }).then(res => {
- if(res.status == 200){
- res.data.detailList = []
- this.$store.state.vuex_tempOrderData = res.data
- // 这里判断是否开通支付,如果开通打开确认付款弹框
- if(this.hasPay){
- // 计算待付款剩余倒计时
- res.data.timestamp = (new Date(res.data.createDate.replace(/-/g,'/')).getTime() + 1800000 - new Date().getTime())/1000
- purchasePay({
- bizSn:res.data.purchaseSn,
- bizNo:res.data.purchaseNo,
- bizType:'SETTLE_BILL',
- payUserOpenId: this.$store.state.vuex_openid || uni.getStorageSync('openid'),
- settleType: this.payType == 0 ? 'RECHARGE_BALANCE' : 'WXPAY_ONLINE'
- }).then(res=>{
- // 微信支付
- if(this.payType == 1){
- this.showPay = true
- this.payData = res.data?res.data.payRequestRest:null
- }else{
- // 余额支付
- this.showPay = true
- this.showPopu = false
- this.submitOk = true
- }
- uni.hideLoading()
- })
- }else{
- // 未开通支付,创建成功,跳转到订单详情页
- this.showPopu = false
- this.submitOk = true
- uni.hideLoading()
- }
- }else{
- uni.hideLoading()
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- })
- },
- // 关闭之前
- beforeClosePopu(){
- console.log(this.showPay,this.submitOk,this.cacelOk)
- // 正在支付
- if(this.showPay&&!this.submitOk&&!this.cacelOk){
- this.showPay = false
- this.cancelPay()
- }
- },
- // 关闭确定订单弹窗后
- closePopu(){
- this.showPopu = false
- // 刷新页面
- if(this.refashOk){
- this.qty = 1
- this.getDetail()
- }else{
- // 开通了支付
- if(this.hasPay){
- // 付款
- if(this.showPay){
- // 确定取消付款或付款失败
- if(this.cacelOk){
- this.cacelOk = false
- }
- // 确定付款成功
- if(this.submitOk){
- this.submitOk = false
- }
- // 去订单详情页
- this.toOrderDetial()
- }else{
- // 取消立即购买
- this.resetPage()
- }
- }else{
- // 未开通支付
- // 去订单详情页
- if(this.submitOk){
- this.submitOk = false
- this.toOrderDetial()
- }else{
- // 取消采购
- this.resetPage()
- }
- }
- }
- },
- // 确认付款
- confirmPay(){
- const _this = this
- // 确认付款
- const data = _this.payData
- console.log(data)
- if(data){
- uni.requestPayment({
- provider: 'wxpay',
- timeStamp: data.timeStamp,
- nonceStr: data.nonceStr,
- package: data.package,
- signType: data.signType,
- paySign: data.paySign,
- success: (res) =>{
- _this.payComplete(1,true)
- },
- fail: (err)=> {
- console.log('fail:',err);
- _this.payComplete(err.errMsg.indexOf("cancel")>=0 ? 2 : 0,false)
- }
- });
- }else{
- _this.payComplete(0,false)
- }
- },
- payComplete(type,data){
- uni.showToast({
- mask: true,
- title: type==1 ? '支付成功' : (type==2?'支付取消':'支付失败'),
- icon: 'none'
- })
- this.showPopu = false
- this.submitOk = true
- },
- // 确认取消付款弹框
- cancelPay(){
- const _this = this
- uni.showModal({
- title: '确定取消支付吗?',
- content: '您的订单在30分钟内未支付将被取消,请尽快完成支付。',
- confirmText: '继续支付',
- cancelText: '取消支付',
- success(ret) {
- // 确定取消,跳转到订单详情页
- if(ret.cancel){
- // 支付弹框打开中
- if(_this.showPopu){
- console.log(0)
- _this.showPopu = false
- _this.cacelOk = true
- }else{
- console.log(1)
- // 未打开直接跳转
- _this.toOrderDetial()
- }
- }
- if(ret.confirm){
- console.log(2)
- // 继续支付
- _this.showPopu = true
- _this.showPay = true
- _this.cacelOk = false
- }
- }
- })
- },
- // 重置页面
- resetPage(){
- this.qty = 1
- this.isAddCart = false
- this.showPopu = false
- this.showPay = false
- this.cacelOk = false
- this.submitOk = false
- setTimeout(()=>{
- uni.hideLoading()
- },300)
- },
- // 订单详情页
- toOrderDetial(){
- this.resetPage()
- // 跳转到订单详情页面
- uni.navigateTo({
- url: "/pagesB/procureOrder/orderDetail?purchaseSn="+this.$store.state.vuex_tempOrderData.purchaseSn
- })
- }
- }
- }
- </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{
- color: red;
- display: flex;
- align-items: baseline;
- font-size: 12px;
- text{
- font-size: 38rpx;
- }
- }
- .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;
- }
- ::v-deep .u-icon{
- margin-right: 3px;
- }
- }
- }
- }
- }
- }
- }
- .product-info-guige{
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- background:#fff;
- margin: 10px 0 0;
- padding: 10px;
- line-height: 28px;
- .row{
- width: 100%;
- }
- .row-ban{
- width: 50%;
- }
- >view{
- color: #999;
- text{
- color: #333333;
- }
- }
- }
- .row-info{
- width: 100%;
- background: #fff;
- font-size: 24rpx;
- text-align: center;
- margin: 20rpx 0;
- padding: 15rpx;
- .txt{
- margin-left: 10rpx;
- color: #666;
- font-weight: bold;
- }
- > view{
- padding: 0 10px;
- }
- }
- .product-info-content{
- background:#fff;
- margin-bottom: 10px;
- padding: 10px;
- line-height: 28px;
- }
- }
- .rebate-tag{
- background: #ffe7df;
- color: #E91E63;
- padding: 2px 5px;
- font-size: 10px;
- border-radius: 3px;
- margin-left: 6px;
- }
- .tejia-tag{
- color: #E91E63;
- margin-left: 6px;
- font-size: 12px;
- text{
- font-size: 12px;
- color: #999;
- margin-left: 5px;
- text-decoration: line-through;
- }
- }
- .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: 45px;
- }
- .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: 5px;
- top: -8px;
- font-size: 12px;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 50rpx;
- padding: 0 10rpx;
- }
- }
- }
- .footer-right{
- width: 60%;
- height: 80%;
- display: flex;
- align-items: center;
- border-radius: 50px;
- overflow: hidden;
- margin: 0 5px;
- .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-nums-content{
- background-color: #FFFFFF;
- border-radius: 10px;
- width: 300px;
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 10px 15px;
- .popu-close{
- padding: 10px;
- position: absolute;
- right: 0;
- top: 0;
- z-index: 1000;
- }
- .popu-content-title{
- padding: 10px;
- font-size: 16px;
- }
- .popu-content-num{
- font-size: 24rpx;
- color: #999999;
- padding: 10px 0;
- > text{
- margin-right: 10px;
- font-size: 10px;
- }
- }
- .popu-content-btn{
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-around;
- margin: 20px 0 10px;
- .popu-content-btn-item{
- width: 40%;
- height: 32px;
- font-size: 14px;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 100px;
- }
- .cancelBtn{
- background-color: #f8f8f8;
- color: #666;
- }
- .okbtn{
- background-color: #f70000;
- color: #FFFFFF;
- }
- }
- }
- .popu-content{
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 10px 15px;
- .popu-close{
- padding: 10px;
- position: absolute;
- right: 0;
- top: 0;
- z-index: 1000;
- }
- .qty-box{
- display: flex;
- .qty-btn{
- display: flex;
- align-items: center;
- justify-content: center;
- width: 22px;
- height: 20px;
- border-radius: 50px;
- font-size: 18px;
- color: #066cff;
- &.qty-disabled{
- color: #999;
- }
- }
- .qty-num{
- width: 24px;
- height: 20px;
- line-height: 20px;
- text-align: center;
- background-color: #efefef;
- margin: 0 3px;
- border-radius: 3px;
- font-size: 12px;
- input{
- width: 100%;
- height: 100%;
- text-align: center;
- color: #333;
- }
- }
- }
- .pupu-box{
- display: flex;
- justify-content: space-between;
- margin-top: 35px;
- width: 100%;
- }
- .popu-content-img{
- border-radius: 6px;
- border: 1px solid #eee;
- overflow: hidden;
- width: 80px;
- height: 80px;
- }
- .popu-content-info{
- padding: 0 0 0 10px;
- flex-grow: 1;
- overflow: hidden;
- width: 50%;
- .popu-content-info-title{
- font-size: 14px;
- }
- .popu-content-info-code{
- font-size: 12px;
- color: #00aaff;
- margin-top: 5px;
- }
- }
- .gift-box{
- padding-left: 8%;
- margin-top: 10px;
- border-top: 1px solid #eee;
- padding-top: 10px;
- .popu-content-img{
- width: 58px;
- height: 58px;
- }
- .popu-content-info-title{
- font-size: 12px;
- color: #666;
- }
- .popu-content-box{
- margin-top: 0;
- }
- .popu-content-num{
- padding:5px 15px;
- >text{
- font-size: 10px;
- }
- }
- .rebate-tag{
- margin: 0 5px 0 0;
- background: #ff0000;
- color: #fff;
- flex-grow: 1;
- display: flex;
- justify-content: center;
- }
- .ellipsis-two{
- width: 80%;
- flex-grow: 1;
- }
- }
- .popu-content-box{
- display: flex;
- align-items: baseline;
- margin-top: 5px;
- .popu-content-price{
- color: red;
- display: flex;
- align-items: baseline;
- font-size: 12px;
- text{
- font-size: 38rpx;
- }
- }
- }
- .pupu-box-item,.pupu-box-pay-item{
- width: 100%;
- padding-top: 20px;
- > view{
- padding: 5px 0;
- }
- .totalBar-box{
- margin-bottom: 20rpx;
- > view{
- padding: 5px 0;
- }
- .pf{
- font-size: 20rpx;
- }
- }
- }
- .pupu-box-pay-item{
- > view{
- padding: 6px 0;
- }
- .popu-content-amount{
- font-size: 28px;
- color: red;
- }
- .popu-content-title{
- font-weight: bold;
- }
- }
- .popu-content-num{
- > text{
- margin-right: 10px;
- }
- }
- .popu-content-btn{
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-around;
- margin: 30px 0 20px;
- .popu-content-btn-item{
- width: 30%;
- height: 34px;
- font-size: 14px;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 100px;
- }
- .cancelBtn{
- background-color: #f8f8f8;
- color: #666;
- }
- .okbtn{
- background-color: #f70000;
- color: #FFFFFF;
- width: 65%;
- .payAmount{
- margin-left: 5px;
- }
- }
- .cartbtn{
- background-color: #ffa60c;
- color: #FFFFFF;
- width: 65%;
- }
- }
- }
- }
- </style>
|