productDetail.vue 30 KB

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