productDetail.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  1. <template>
  2. <view class="pages">
  3. <!-- head -->
  4. <view class="scrollPage-header">
  5. <view :style="{height:statusBarHeight+'px'}"></view>
  6. <view class="header-title">
  7. <view class="header-left" @click="goBack">
  8. <uni-icons type="arrowleft" size="20"></uni-icons>
  9. <text>{{isShare?'首页':'返回'}}</text>
  10. </view>
  11. <view class="header-right"></view>
  12. </view>
  13. </view>
  14. <!-- 内容 -->
  15. <view class="scrollPage-content">
  16. <view class="product-info" v-if="detail">
  17. <view :style="{height:statusBarHeight+'px'}"></view>
  18. <u-swiper mode="number" :border-radius="0" img-mode="aspectFit" :interval="3000" :height="450" :list="imgList" @click="viewImg"></u-swiper>
  19. <view class="product-info-text">
  20. <view class="product-info-text-title">
  21. {{detail.productName}}
  22. <!-- <view class="copyText" @click="copy(detail.productName)">复制</view> -->
  23. <uni-tag style="margin-left: 10px;" size="mini" :circle="true" v-if="detail.status==0 || detail.dealerScopeFlag==0" :text="detail.status==0?'已下架':'已售罄'"></uni-tag>
  24. </view>
  25. <view class="product-info-text-attr">
  26. <view class="product-info-price flex align_center" v-if="!hasLogin">
  27. ¥***
  28. </view>
  29. <view class="flex align_center" v-else>
  30. <view class="product-info-price">
  31. ¥<text>{{detail.priceStr[0]}}</text>.{{detail.priceStr[1]}}
  32. </view>
  33. <view class="flex align_center rebate-tag" v-if="detail.promoType=='BUY_PROD_GIVE_VALID'">
  34. 返<text>{{detail.resultValue}}</text>元
  35. </view>
  36. <view class="flex align_center rebate-tag" v-if="detail.promoType=='BUY_PROD_GIVE_PROD'">
  37. 买{{detail.conditionValue}}赠{{detail.resultValue}}
  38. </view>
  39. <view class="flex align_center tejia-tag" v-if="detail.promoType=='PROMO_PROD'">
  40. 特价<text>¥{{detail.orginPrice}}</text>
  41. </view>
  42. </view>
  43. <view class="product-info-nums">
  44. <view class="share">
  45. <button open-type="share"><u-icon :size='24' name="zhuanfa"></u-icon> 分享</button>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <u-divider bg-color="">商品详情</u-divider>
  52. <view class="product-info-guige" v-if="detail&&detail.product">
  53. <view class="row">品牌:<text>{{detail.product.productBrandName||'--'}}</text></view>
  54. <view class="row">原厂编码:<text>{{detail.product.origCode||'--'}} </text> <view class="copyText" v-if="detail.product.origCode" @click="copy(detail.product.origCode)">复制</view></view>
  55. <view class="row">产品编码:<text>{{detail.product.code||'--'}}</text> <view class="copyText" v-if="detail.product.code" @click="copy(detail.product.code)">复制</view></view>
  56. <view class="row">条形码:<text>{{detail.product.qrCode||'--'}}</text> <view class="copyText" v-if="detail.product.qrCode" @click="copy(detail.product.qrCode)">复制</view></view>
  57. <view class="row-ban">商品尺寸:<text>{{detail.product.size||'--'}}</text></view>
  58. <view class="row-ban">计量单位:<text>{{detail.product.unit||'--'}}</text></view>
  59. <view class="row-ban">重量:<text>{{detail.product.weight||'--'}}</text></view>
  60. <view class="row-ban">包装数:<text>{{ (detail.product.packQty) || '--' }}{{ detail.product.packQty ? detail.product.unit : '' }}/{{ detail.product.packQtyUnit||'--' }}</text></view>
  61. </view>
  62. <view class="product-info-content">
  63. <rich-text v-if="detail && detail.product && detail.product.description" :nodes="detail.product.description"></rich-text>
  64. <view v-else style="font-size: 12px;color: #999;text-align: center;">暂无产品介绍</view>
  65. </view>
  66. </view>
  67. <!-- 底部栏 -->
  68. <view class="scrollPage-footer">
  69. <view class="scrollPage-footer-box">
  70. <view class="footer-left">
  71. <view v-if="isShare" class="footer-left-item" @click="goBack">
  72. <u-icon :size='50' color="#666" name="home"></u-icon>
  73. <text class="footer-left-item-text">首页</text>
  74. </view>
  75. <view class="footer-left-item" @click="toCart">
  76. <u-icon :size='50' color="#666" name="shopping-cart"></u-icon>
  77. <text class="footer-left-item-text">购物车</text>
  78. <text class="badge" v-if="totalNum">{{totalNum>99?'99+':totalNum}}</text>
  79. </view>
  80. </view>
  81. <view class="footer-right">
  82. <view class="footer-right-item" @click="toAddCart">
  83. <text>加入购物车</text>
  84. </view>
  85. <view class="footer-right-item" @click="toBuy">
  86. <text>立即购买</text>
  87. </view>
  88. </view>
  89. </view>
  90. <view :style="{height:safeAreaBottom+'px'}"></view>
  91. </view>
  92. <!-- 购物车动画 -->
  93. <uni-cart-animation ref="cartAnimation" @animationfinish="animationfinish"></uni-cart-animation>
  94. <!-- 立即购买和付款 -->
  95. <page-container
  96. :show="showPopu"
  97. :round="true"
  98. :z-index="100"
  99. position="bottom"
  100. customStyle="border-radius:15px 15px 0 0;"
  101. @beforeleave="beforeClosePopu"
  102. @afterleave="closePopu">
  103. <!-- 确认订单 -->
  104. <view class="popu-content" v-if="detail&&!showPay">
  105. <view class="popu-close" @click="cancelBuy">
  106. <uni-icons size="26" type="closeempty"></uni-icons>
  107. </view>
  108. <view class="pupu-box">
  109. <view class="popu-content-img">
  110. <image style="width: 80px; height: 80px;" mode="aspectFit" :src="detail.productMsg||'/static/def_imgs.png'"></image>
  111. </view>
  112. <view class="popu-content-info">
  113. <view class="popu-content-info-title">
  114. <text class="ellipsis-two">{{detail.productName}}</text>
  115. </view>
  116. <view class="popu-content-box">
  117. <view class="popu-content-price" v-if="hasLogin">
  118. ¥<text>{{detail.priceStr[0]}}</text>.{{detail.priceStr[1]}}
  119. </view>
  120. <view class="popu-content-price" v-else>¥***</view>
  121. <view class="flex align_center rebate-tag" v-if="hasLogin&&detail.promoType=='BUY_PROD_GIVE_VALID'">
  122. 返<text>{{detail.resultValue}}</text>元
  123. </view>
  124. <view class="flex align_center rebate-tag" v-if="hasLogin&&detail.promoType=='BUY_PROD_GIVE_PROD'">
  125. 买{{detail.conditionValue}}赠{{detail.resultValue}}
  126. </view>
  127. <view class="flex align_center tejia-tag" v-if="hasLogin&&detail.promoType=='PROMO_PROD'">
  128. 特价<text>¥{{detail.orginPrice}}</text>
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. <view class="pupu-box gift-box" v-if="giftNum">
  134. <view class="popu-content-img">
  135. <image style="width: 58px; height: 58px;" mode="aspectFit" :src="detail.productMsg||'/static/def_imgs.png'"></image>
  136. </view>
  137. <view class="popu-content-info">
  138. <view class="popu-content-info-title flex align_center">
  139. <view class="flex align_center rebate-tag">
  140. 赠品
  141. </view>
  142. <view class="ellipsis-two">{{detail.productName}}</view>
  143. </view>
  144. <view class="popu-content-box justify_between">
  145. <view></view>
  146. <view class="popu-content-num flex align_center">
  147. <text>X</text> {{giftNum}}
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. <view class="pupu-box-item">
  153. <view class="popu-content-num flex align_center justify_between">
  154. <text>数量</text>
  155. <!-- <uni-number-box v-model="qty" :input-width="60" :input-height="40" :min="1" :max="999"></uni-number-box> -->
  156. <view class="flex align_center qty-box">
  157. <view class="qty-btn" @click="changeQty(qty-1)" :class="(qty <= 1)?'qty-disabled':''">-</view>
  158. <view class="qty-num" @click="$refs.showPopu.open()" :style="{width:Number(qty).toString().length*8+10+'px'}">
  159. {{qty}}
  160. </view>
  161. <view class="qty-btn" @click="changeQty(qty+1)" :class="(qty >= 999)?'qty-disabled':''">+</view>
  162. </view>
  163. </view>
  164. <view class="flex align_center justify_between" v-if="shelfInfo">
  165. <text>配送商:{{shelfInfo.dealerName}}</text>
  166. <view @click="callPhone()"><uni-icons size="18" type="phone" color="dodgerblue"></uni-icons><text style="font-size:12px;">拨打</text></view>
  167. </view>
  168. <!-- <view class="flex align_center justify_between" v-if="shelfInfo">
  169. <text>支付方式:在线支付</text>
  170. <view><uni-icons size="18" type="right" color="dodgerblue"></uni-icons></view>
  171. </view> -->
  172. </view>
  173. <view class="popu-content-btn">
  174. <view class="popu-content-btn-item cartbtn" v-if="isAddCart" @click="submitCart($event)">加入购物车</view>
  175. <view class="popu-content-btn-item okbtn" v-if="!isAddCart" @click="toBuy">
  176. {{hasPay?'立即支付':'确定采购'}}
  177. <text class="payAmount" v-if="payAmount&&hasPay">¥{{payAmount}}</text>
  178. </view>
  179. </view>
  180. </view>
  181. <!-- 确认付款 -->
  182. <view class="popu-content" v-if="payInfo&&showPay">
  183. <view class="popu-close" @click="cancelPay">
  184. <uni-icons size="26" type="closeempty"></uni-icons>
  185. </view>
  186. <view class="pupu-box-pay-item">
  187. <view class="popu-content-amount flex align_center justify_center">
  188. <view>¥{{payInfo.totalAmount}}</view>
  189. </view>
  190. <view class="flex align_center justify_between" v-if="payInfo.totalSpecialGiveAmount>0">
  191. <text>总优惠</text>
  192. <view class="popu-content-price">¥{{payInfo.totalSpecialGiveAmount}}</view>
  193. </view>
  194. <view class="flex align_center justify_between" v-if="payInfo.totalTicketGiveAmount>0">
  195. <text>代金券</text>
  196. <view class="popu-content-price">¥{{payInfo.totalTicketGiveAmount}}</view>
  197. </view>
  198. <view style="height: 5px;"></view>
  199. <view class="popu-content-title flex align_center justify_between">
  200. <text>付款方式</text>
  201. <view></view>
  202. </view>
  203. <view class="popu-content-pay flex align_center justify_between">
  204. <view class="flex align_center"><uni-icons size="20" type="weixin" color="#4CAF50"></uni-icons> <text style="margin-left: 5px;">微信支付</text></view>
  205. <view><uni-icons size="22" type="checkbox-filled" color="red"></uni-icons></view>
  206. </view>
  207. </view>
  208. <view class="popu-content-btn">
  209. <view class="popu-content-btn-item okbtn" @click="confirmPay">确定付款</view>
  210. </view>
  211. </view>
  212. </page-container>
  213. <!-- 修改数量弹框 -->
  214. <uni-popup ref="showPopu" type="center" style="z-index: 1500;" :maskClick="false">
  215. <view class="popu-nums-content">
  216. <view class="popu-close" @click="$refs.showPopu.close()">
  217. <uni-icons size="26" type="closeempty"></uni-icons>
  218. </view>
  219. <view class="popu-content-title flex align_center justify_center"><text>修改商品数量</text></view>
  220. <view class="popu-content-num flex align_center justify_center">
  221. <uni-number-box v-model="qty" :size="28" :input-width="280" :input-height="70" :min="1" :max="999"></uni-number-box>
  222. </view>
  223. <view class="popu-content-btn">
  224. <view class="popu-content-btn-item okbtn" @click="$refs.showPopu.close()">确定</view>
  225. </view>
  226. </view>
  227. </uni-popup>
  228. </view>
  229. </template>
  230. <script>
  231. import {
  232. mapState,
  233. mapMutations,
  234. } from 'vuex'
  235. import { addCart, getCartCount } from '@/api/cart.js'
  236. import { getShopDetail } from '@/api/shop.js'
  237. import { purchaseSave, purchaseCheck, purchasePay } from '@/api/purchase.js'
  238. import { toAuthStore, toLogin } from "@/utils/index.js"
  239. export default {
  240. data() {
  241. return {
  242. loading: false,
  243. showPopu: false, // 弹框
  244. statusBarHeight: 0, // 状态栏高度
  245. safeAreaBottom: 0, // 底部安全区域高度
  246. imgList: [],
  247. shopProductSn: null,
  248. detail: null,
  249. qty: 1,// 数量
  250. isShare: false ,// 是否从分享打开的
  251. busPos:{
  252. x: 10,
  253. y:uni.getSystemInfoSync().windowHeight - 30
  254. },
  255. submitOk: false, // 是否成功
  256. cacelOk: false, // 是否取消
  257. refashOk: false, // 是否刷新页面
  258. showPay: false, // 是否显示付款信息
  259. isAddCart: false, // 是否加入购物车
  260. payData: null, // 支付参数
  261. }
  262. },
  263. onLoad(option) {
  264. this.isShare = !!option.share
  265. // 计算安全区域
  266. this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
  267. this.safeAreaBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
  268. this.shopProductSn = option.sn
  269. // 获取产品详情
  270. this.getDetail()
  271. },
  272. // 分享
  273. onShareAppMessage(e){
  274. return {
  275. title: this.detail ? this.detail.productName : '商品名称',
  276. path: '/pagesB/shopiing/productDetail?sn='+this.shopProductSn+'&share=1',
  277. imageUrl:this.detail ? this.detail.productMsg : '',
  278. type: '1'
  279. }
  280. },
  281. computed: {
  282. ...mapState(['hasLogin']),
  283. // 登录用户信息
  284. userInfo(){
  285. return this.$store.state.vuex_userInfo
  286. },
  287. // 货架经销商信息
  288. shelfInfo(){
  289. return this.$store.state.vuex_storeShelf
  290. },
  291. //是否开启线上支付
  292. hasPay(){
  293. const shelfInfo = this.shelfInfo
  294. return shelfInfo&&shelfInfo.payOnlineFlag&&shelfInfo.payOnlineFlag=='1'
  295. },
  296. // 经销商电话
  297. dealerPhone(){
  298. const shelfInfo = this.shelfInfo
  299. return shelfInfo&&shelfInfo.contactMobile ? shelfInfo.contactMobile : ''
  300. },
  301. totalNum(){
  302. return this.hasLogin&&this.userInfo.sysUserFlag == '1' ? this.$store.state.vuex_cartTotal : 0
  303. },
  304. // 赠品数量
  305. giftNum(){
  306. return this.detail && this.detail.promoType=='BUY_PROD_GIVE_PROD' ? Math.floor(this.qty / this.detail.conditionValue)*this.detail.resultValue : 0
  307. },
  308. // 支付总金额
  309. payAmount(){
  310. const price = this.detail && this.detail.priceStr ? this.detail.priceStr.join('.') : 0
  311. return price ? Number(price*this.qty).toFixed(2) : 0
  312. },
  313. // 付款信息
  314. payInfo(){
  315. return this.$store.state.vuex_tempOrderData
  316. }
  317. },
  318. methods: {
  319. // 返回
  320. goBack(){
  321. if(this.isShare){
  322. uni.reLaunch({
  323. url: '/pages/index/index'
  324. })
  325. }else{
  326. uni.navigateBack()
  327. }
  328. },
  329. // 复制
  330. copy(text){
  331. uni.setClipboardData({
  332. data: text,
  333. })
  334. },
  335. viewImg(index){
  336. uni.previewImage({
  337. urls: this.imgList
  338. })
  339. },
  340. // 联系经销商
  341. callPhone() {
  342. if(this.dealerPhone!=''){
  343. uni.makePhoneCall({
  344. phoneNumber: this.dealerPhone
  345. })
  346. }
  347. },
  348. // 产品详情
  349. getDetail(){
  350. uni.showLoading({
  351. title: '加载中'
  352. })
  353. const storeShelf = this.$store.state.vuex_storeShelf
  354. const dealerSn = this.hasLogin && this.userInfo && this.userInfo.sysUserFlag == '1'&&storeShelf ? storeShelf.dealerSn : ''
  355. // 获取产品详情
  356. getShopDetail({
  357. shopProductSn: this.shopProductSn,
  358. dealerSn: dealerSn
  359. }).then(res => {
  360. if(res.status == 200){
  361. this.detail = res.data
  362. if(res.data){
  363. if(res.data.productPicList){
  364. res.data.productPicList.forEach(item => {
  365. this.imgList.push(item.imageUrl||'/static/def_imgs.png')
  366. })
  367. }else{
  368. this.imgList.push(res.data.productMsg||'/static/def_imgs.png')
  369. }
  370. const a = res.data.shopPromoProduct
  371. let bprice = res.data.price
  372. if(a){
  373. res.data.promoType = a.promoType
  374. res.data.resultValue = a.resultValue
  375. res.data.conditionValue = a.conditionValue
  376. res.data.discountType = a.discountType
  377. res.data.promoProductSn = a.promoProductSn
  378. res.data.promoSn = a.promoSn
  379. res.data.orginPrice = res.data.price
  380. // 特价
  381. if(res.data.promoType=='PROMO_PROD'){
  382. bprice =res.data.conditionValue
  383. }
  384. }
  385. res.data.priceStr = Number(bprice).toFixed(2).toString().split('.')
  386. }
  387. }
  388. uni.hideLoading()
  389. })
  390. },
  391. animationfinish(){
  392. this.loading = false
  393. },
  394. changeQty(value) {
  395. const max = 999
  396. const v = value > max ? max : (value==''||value==0?1:value)
  397. this.qty = v
  398. },
  399. // 加入购物车
  400. toAddCart(){
  401. // 未登录
  402. if(this.hasLogin){
  403. // 游客未认证
  404. if(this.userInfo.sysUserFlag == '0'){
  405. toAuthStore()
  406. }else{
  407. // 打开确认数量弹框
  408. this.isAddCart = true
  409. this.showPopu = true
  410. }
  411. }else{
  412. toLogin()
  413. }
  414. },
  415. // 确定加入购物车
  416. submitCart(event){
  417. if(this.loading){
  418. return
  419. }
  420. this.loading = true
  421. this.$refs.cartAnimation.touchOnGoods(event,this.busPos);
  422. // 加入购物车
  423. addCart({
  424. qty: this.qty,
  425. price: this.detail.price,
  426. productSn: this.detail.productSn
  427. }).then(res => {
  428. if(res.status == 200){
  429. uni.$emit('refashCart')
  430. this.showPopu = false
  431. }
  432. })
  433. },
  434. // 打开购物车页面
  435. toCart(){
  436. if(this.hasLogin){
  437. // 游客未认证
  438. if(this.userInfo.sysUserFlag == '0'){
  439. toAuthStore()
  440. }else{
  441. uni.navigateTo({
  442. url: '/pagesB/cart/index'
  443. })
  444. }
  445. }else{
  446. toLogin()
  447. }
  448. },
  449. // 立即购买
  450. toBuy(){
  451. if(this.hasLogin){
  452. // 游客未认证
  453. if(this.userInfo.sysUserFlag == '0'){
  454. toAuthStore()
  455. }else{
  456. if(this.detail.status==0 || this.detail.dealerScopeFlag==0){
  457. uni.showToast({
  458. title: '此商品已'+(this.detail.status==0?'下架':'售罄'),
  459. icon: 'none'
  460. })
  461. }else{
  462. // 打开数量选择弹框
  463. if(!this.showPopu){
  464. this.showPopu = true
  465. }else{
  466. // 去结算生产订单
  467. this.creatOrder()
  468. }
  469. }
  470. }
  471. }else{
  472. toLogin()
  473. }
  474. },
  475. // 取消立即购买
  476. cancelBuy(){
  477. this.resetPage()
  478. },
  479. // 去结算
  480. creatOrder(){
  481. uni.showLoading({
  482. title: '提交中...',
  483. mask: true
  484. })
  485. const _this = this
  486. purchaseCheck({detailList: [{
  487. productSn:this.detail.productSn,
  488. productCode:this.detail.productCode,
  489. qty: this.qty,
  490. price:this.detail.price,
  491. promoSn: this.detail.promoSn
  492. }]}).then(res => {
  493. uni.hideLoading()
  494. if(res.status == 200){
  495. const successList = res.data.successList ? res.data.successList.map(item => {
  496. return {
  497. productSn:item.productSn,
  498. productCode: item.productCode,
  499. qty: item.qty,
  500. price:item.price,
  501. promoSn: item.promoSn
  502. }
  503. }) : []
  504. const removeList = res.data.removeList ? res.data.removeList.map(item => item.productCode) : []
  505. const selloutList = res.data.selloutList ? res.data.selloutList.map(item => item.productCode) : []
  506. // 有已下架或已售罄产品提示
  507. if(removeList.length || selloutList.length){
  508. uni.showModal({
  509. title: '提示',
  510. content: (removeList.length ? `产品${removeList.join(',')}已下架,`:'')+(selloutList.length?`产品${selloutList.join(',')}已售罄,`:'')+`不可采购。`+(successList.length?'是否继续采购其他产品?':''),
  511. showCancel: successList.length,
  512. confirmText: successList.length?'确定':'知道了',
  513. success(ret) {
  514. if(ret.confirm && successList.length){
  515. _this.submitForm(successList)
  516. }
  517. }
  518. })
  519. }else{
  520. const promoChangeFlag = res.data.promoChangeFlag
  521. // 活动变更
  522. if(promoChangeFlag){
  523. uni.showModal({
  524. title: '提示',
  525. content: '促销活动已变更,请刷新?',
  526. confirmText:'确定刷新',
  527. success(ret) {
  528. if(ret.confirm){
  529. _this.showPopu = false
  530. _this.refashOk = true
  531. }
  532. }
  533. })
  534. return
  535. }
  536. // 直接提交
  537. _this.submitForm(successList)
  538. }
  539. }else{
  540. uni.showToast({
  541. title: res.message,
  542. icon: 'none'
  543. })
  544. }
  545. })
  546. },
  547. // 创建订单
  548. submitForm(detailList){
  549. uni.showLoading({
  550. title: '提交中...',
  551. mask: true
  552. })
  553. purchaseSave({
  554. detailList: detailList
  555. }).then(res => {
  556. if(res.status == 200){
  557. res.data.detailList = []
  558. this.$store.state.vuex_tempOrderData = res.data
  559. // 打开确认付款弹框,这里判断是否开通支付,如果开通
  560. if(this.hasPay){
  561. purchasePay({
  562. bizSn:res.data.purchaseSn,
  563. bizNo:res.data.purchaseNo,
  564. bizType:'PURCHASE',
  565. }).then(res=>{
  566. this.showPay = true
  567. this.payData = res.data
  568. uni.hideLoading()
  569. })
  570. }else{
  571. // 创建成功,跳转到订单详情页
  572. this.showPopu = false
  573. this.submitOk = true
  574. uni.hideLoading()
  575. }
  576. }else{
  577. uni.hideLoading()
  578. uni.showToast({
  579. title: res.message,
  580. icon: 'none'
  581. })
  582. }
  583. })
  584. },
  585. // 关闭之前
  586. beforeClosePopu(){
  587. // 正在支付
  588. if(this.showPay&&!this.submitOk){
  589. this.showPay = false
  590. this.cancelPay()
  591. }
  592. },
  593. // 关闭确定订单弹窗后
  594. closePopu(){
  595. this.showPopu = false
  596. // 刷新页面
  597. if(this.refashOk){
  598. this.qty = 1
  599. this.getDetail()
  600. }else{
  601. // 开通了支付
  602. if(this.hasPay){
  603. // 付款
  604. if(this.showPay){
  605. // 确定取消付款或付款失败
  606. if(this.cacelOk){
  607. this.cacelOk = false
  608. }
  609. // 确定付款成功
  610. if(this.submitOk){
  611. this.submitOk = false
  612. }
  613. // 去订单详情页
  614. this.toOrderDetial()
  615. }else{
  616. // 取消立即购买
  617. this.resetPage()
  618. }
  619. }else{
  620. // 未开通支付
  621. // 去订单详情页
  622. if(this.submitOk){
  623. this.submitOk = false
  624. this.toOrderDetial()
  625. }else{
  626. // 取消采购
  627. this.resetPage()
  628. }
  629. }
  630. }
  631. },
  632. // 确认付款
  633. confirmPay(){
  634. const _this = this
  635. // uni.showLoading({
  636. // title: '正在支付...',
  637. // mask: true
  638. // })
  639. // 确认付款
  640. const data = _this.payData
  641. uni.showToast({
  642. mask: true,
  643. title: data ? '支付成功' : '支付失败',
  644. icon: 'none'
  645. })
  646. _this.showPopu = false
  647. _this.submitOk = true
  648. },
  649. // 确认取消付款弹框
  650. cancelPay(){
  651. const _this = this
  652. uni.showModal({
  653. title: '确定取消支付吗?',
  654. content: '您的订单在30分钟内未支付将被取消,请尽快完成支付。',
  655. confirmText: '继续支付',
  656. cancelText: '取消支付',
  657. success(ret) {
  658. // 确定取消,跳转到订单详情页
  659. if(!ret.confirm){
  660. // 支付弹框打开中
  661. if(_this.showPopu){
  662. _this.showPopu = false
  663. _this.cacelOk = true
  664. }else{
  665. // 未打开直接跳转
  666. _this.toOrderDetial()
  667. }
  668. }else{
  669. // 继续支付
  670. _this.showPopu = true
  671. _this.showPay = true
  672. _this.cacelOk = false
  673. }
  674. }
  675. })
  676. },
  677. // 重置页面
  678. resetPage(){
  679. this.qty = 1
  680. this.isAddCart = false
  681. this.showPopu = false
  682. this.showPay = false
  683. this.cacelOk = false
  684. this.submitOk = false
  685. setTimeout(()=>{
  686. uni.hideLoading()
  687. },300)
  688. },
  689. // 订单详情页
  690. toOrderDetial(){
  691. this.resetPage()
  692. // 跳转到订单详情页面
  693. uni.navigateTo({
  694. url: "/pagesB/procureOrder/orderDetail"
  695. })
  696. }
  697. }
  698. }
  699. </script>
  700. <style lang="less">
  701. .pages {
  702. height: 100vh;
  703. display: flex;
  704. flex-direction: column;
  705. .scrollPage-header{
  706. z-index: 1;
  707. width: 100%;
  708. position:fixed;
  709. left: 0;
  710. top: 0;
  711. .header-title{
  712. display: flex;
  713. align-items: center;
  714. justify-content: space-between;
  715. padding: 0 10px;
  716. height: 44px;
  717. .header-left{
  718. display: flex;
  719. align-items: center;
  720. text{
  721. font-size: 14px;
  722. color: #333333;
  723. }
  724. background-color: rgba(255,255,255,0.6);
  725. box-shadow: 0px 1px 0px 0px #E6E6E6;
  726. border-radius: 50px;
  727. padding: 3px 6px 3px;
  728. }
  729. .header-right{
  730. width: 50px;
  731. }
  732. }
  733. }
  734. .copyText{
  735. background-color: #efefef;
  736. border-radius: 100rpx;
  737. padding: 0 20rpx;
  738. color: #03A9F4;
  739. font-size: 20rpx;
  740. display: inline-block;
  741. margin-left: 20rpx;
  742. height: 44rpx;
  743. line-height: 44rpx;
  744. }
  745. .scrollPage-content{
  746. flex: 1;
  747. overflow-y: auto;
  748. .product-info{
  749. background:#fff;
  750. margin-bottom: 10px;
  751. .product-info-text{
  752. padding: 10px;
  753. .product-info-text-title{
  754. font-weight: bold;
  755. color: #333333;
  756. line-height: 22px;
  757. margin-bottom: 5px;
  758. }
  759. .product-info-text-attr{
  760. display: flex;
  761. align-items: center;
  762. justify-content: space-between;
  763. .product-info-price{
  764. color: red;
  765. display: flex;
  766. align-items: baseline;
  767. font-size: 12px;
  768. text{
  769. font-size: 38rpx;
  770. }
  771. }
  772. .product-info-nums{
  773. font-size: 12px;
  774. color: #999999;
  775. >view{
  776. display: flex;
  777. align-items: center;
  778. }
  779. .share{
  780. button{
  781. width: auto;
  782. padding: 0;
  783. border: 0;
  784. background: none;
  785. line-height: normal;
  786. margin: 0;
  787. display: inline;
  788. font-size: 12px;
  789. color: #999;
  790. &::after{
  791. border:none;
  792. }
  793. /deep/ .u-icon{
  794. margin-right: 3px;
  795. }
  796. }
  797. }
  798. }
  799. }
  800. }
  801. }
  802. .product-info-guige{
  803. display: flex;
  804. flex-wrap: wrap;
  805. justify-content: space-between;
  806. background:#fff;
  807. margin: 10px 0;
  808. padding: 10px;
  809. line-height: 28px;
  810. .row{
  811. width: 100%;
  812. }
  813. .row-ban{
  814. width: 50%;
  815. }
  816. >view{
  817. color: #999;
  818. text{
  819. color: #333333;
  820. }
  821. }
  822. }
  823. .product-info-content{
  824. background:#fff;
  825. margin-bottom: 10px;
  826. padding: 10px;
  827. line-height: 28px;
  828. }
  829. }
  830. .rebate-tag{
  831. background: #ffe7df;
  832. color: #E91E63;
  833. padding: 2px 5px;
  834. font-size: 10px;
  835. border-radius: 3px;
  836. margin-left: 6px;
  837. }
  838. .tejia-tag{
  839. color: #E91E63;
  840. margin-left: 6px;
  841. font-size: 12px;
  842. text{
  843. font-size: 12px;
  844. color: #999;
  845. margin-left: 5px;
  846. text-decoration: line-through;
  847. }
  848. }
  849. .scrollPage-footer{
  850. background-color: #FFFFFF;
  851. width: 100%;
  852. position: fixed;
  853. left: 0;
  854. bottom: 0;
  855. .scrollPage-footer-box{
  856. display: flex;
  857. align-items: center;
  858. justify-content: space-between;
  859. height: 45px;
  860. }
  861. .footer-left{
  862. display: flex;
  863. align-items: center;
  864. justify-content: space-between;
  865. width: 35%;
  866. .footer-left-item{
  867. display: flex;
  868. flex-direction: column;
  869. align-items: center;
  870. justify-content: center;
  871. padding: 0 15px;
  872. position: relative;
  873. .footer-left-item-text{
  874. font-size: 12px;
  875. color: #666666;
  876. }
  877. .badge{
  878. background: #f44336;
  879. color: #fff;
  880. position: absolute;
  881. right: 5px;
  882. top: -8px;
  883. font-size: 12px;
  884. display: flex;
  885. align-items: center;
  886. justify-content: center;
  887. border-radius: 50rpx;
  888. padding: 0 10rpx;
  889. }
  890. }
  891. }
  892. .footer-right{
  893. width: 60%;
  894. height: 80%;
  895. display: flex;
  896. align-items: center;
  897. border-radius: 50px;
  898. overflow: hidden;
  899. margin: 0 5px;
  900. .footer-right-item{
  901. height: 100%;
  902. display: flex;
  903. flex-direction: column;
  904. align-items: center;
  905. justify-content: center;
  906. width: 50%;
  907. font-size: 14px;
  908. color: #FFFFFF;
  909. }
  910. .footer-right-item:first-child{
  911. background-color: #FF9900;
  912. }
  913. .footer-right-item:last-child{
  914. background-color: #FF0000;
  915. }
  916. }
  917. }
  918. .popu-nums-content{
  919. background-color: #FFFFFF;
  920. border-radius: 10px;
  921. width: 300px;
  922. display: flex;
  923. flex-direction: column;
  924. align-items: center;
  925. padding: 10px 15px;
  926. .popu-close{
  927. padding: 10px;
  928. position: absolute;
  929. right: 0;
  930. top: 0;
  931. z-index: 1000;
  932. }
  933. .popu-content-title{
  934. padding: 10px;
  935. font-size: 16px;
  936. }
  937. .popu-content-num{
  938. font-size: 14px;
  939. color: #999999;
  940. padding: 10px 0;
  941. > text{
  942. margin-right: 10px;
  943. font-size: 10px;
  944. }
  945. }
  946. .popu-content-btn{
  947. width: 100%;
  948. display: flex;
  949. align-items: center;
  950. justify-content: space-around;
  951. margin: 20px 0 10px;
  952. .popu-content-btn-item{
  953. width: 40%;
  954. height: 32px;
  955. font-size: 14px;
  956. display: flex;
  957. align-items: center;
  958. justify-content: center;
  959. border-radius: 100px;
  960. }
  961. .cancelBtn{
  962. background-color: #f8f8f8;
  963. color: #666;
  964. }
  965. .okbtn{
  966. background-color: #f70000;
  967. color: #FFFFFF;
  968. }
  969. }
  970. }
  971. .popu-content{
  972. display: flex;
  973. flex-direction: column;
  974. align-items: center;
  975. padding: 10px 15px;
  976. .popu-close{
  977. padding: 10px;
  978. position: absolute;
  979. right: 0;
  980. top: 0;
  981. z-index: 1000;
  982. }
  983. .qty-box{
  984. display: flex;
  985. .qty-btn{
  986. display: flex;
  987. align-items: center;
  988. justify-content: center;
  989. width: 22px;
  990. height: 20px;
  991. border-radius: 50px;
  992. font-size: 18px;
  993. color: #066cff;
  994. &.qty-disabled{
  995. color: #999;
  996. }
  997. }
  998. .qty-num{
  999. width: 24px;
  1000. height: 20px;
  1001. line-height: 20px;
  1002. text-align: center;
  1003. background-color: #efefef;
  1004. margin: 0 3px;
  1005. border-radius: 3px;
  1006. font-size: 12px;
  1007. input{
  1008. width: 100%;
  1009. height: 100%;
  1010. text-align: center;
  1011. color: #333;
  1012. }
  1013. }
  1014. }
  1015. .pupu-box{
  1016. display: flex;
  1017. justify-content: space-between;
  1018. margin-top: 35px;
  1019. width: 100%;
  1020. }
  1021. .popu-content-img{
  1022. border-radius: 6px;
  1023. border: 1px solid #eee;
  1024. overflow: hidden;
  1025. width: 80px;
  1026. height: 80px;
  1027. }
  1028. .popu-content-info{
  1029. padding: 0 0 0 10px;
  1030. flex-grow: 1;
  1031. overflow: hidden;
  1032. width: 50%;
  1033. .popu-content-info-title{
  1034. font-size: 14px;
  1035. }
  1036. }
  1037. .gift-box{
  1038. padding-left: 8%;
  1039. margin-top: 0;
  1040. border-top: 1px solid #eee;
  1041. padding-top: 10px;
  1042. .popu-content-img{
  1043. width: 58px;
  1044. height: 58px;
  1045. }
  1046. .popu-content-info-title{
  1047. font-size: 12px;
  1048. color: #666;
  1049. }
  1050. .popu-content-box{
  1051. margin-top: 0;
  1052. }
  1053. .popu-content-num{
  1054. padding:5px 0;
  1055. >text{
  1056. font-size: 10px;
  1057. }
  1058. }
  1059. .rebate-tag{
  1060. margin: 0 5px 0 0;
  1061. background: #ff0000;
  1062. color: #fff;
  1063. flex-grow: 1;
  1064. display: flex;
  1065. justify-content: center;
  1066. }
  1067. .ellipsis-two{
  1068. width: 80%;
  1069. flex-grow: 1;
  1070. }
  1071. }
  1072. .popu-content-box{
  1073. display: flex;
  1074. align-items: baseline;
  1075. margin-top: 5px;
  1076. .popu-content-price{
  1077. color: red;
  1078. display: flex;
  1079. align-items: baseline;
  1080. font-size: 12px;
  1081. text{
  1082. font-size: 38rpx;
  1083. }
  1084. }
  1085. }
  1086. .pupu-box-item,.pupu-box-pay-item{
  1087. width: 100%;
  1088. padding-top: 10px;
  1089. > view{
  1090. padding: 10px 0;
  1091. }
  1092. }
  1093. .pupu-box-pay-item{
  1094. > view{
  1095. padding: 6px 0;
  1096. }
  1097. .popu-content-amount{
  1098. font-size: 24px;
  1099. color: red;
  1100. }
  1101. .popu-content-title{
  1102. font-weight: bold;
  1103. }
  1104. }
  1105. .popu-content-num{
  1106. > text{
  1107. margin-right: 10px;
  1108. }
  1109. }
  1110. .popu-content-btn{
  1111. width: 100%;
  1112. display: flex;
  1113. align-items: center;
  1114. justify-content: space-around;
  1115. margin: 20px 0 10px;
  1116. .popu-content-btn-item{
  1117. width: 30%;
  1118. height: 34px;
  1119. font-size: 14px;
  1120. display: flex;
  1121. align-items: center;
  1122. justify-content: center;
  1123. border-radius: 100px;
  1124. }
  1125. .cancelBtn{
  1126. background-color: #f8f8f8;
  1127. color: #666;
  1128. }
  1129. .okbtn{
  1130. background-color: #f70000;
  1131. color: #FFFFFF;
  1132. width: 65%;
  1133. .payAmount{
  1134. margin-left: 5px;
  1135. }
  1136. }
  1137. .cartbtn{
  1138. background-color: #ffa60c;
  1139. color: #FFFFFF;
  1140. width: 65%;
  1141. }
  1142. }
  1143. }
  1144. }
  1145. </style>