productDetail.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  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 } 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. hasPay: true ,// 是否开通支付
  260. isAddCart: false, // 是否加入购物车
  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. dealerPhone(){
  293. const shelfInfo = this.shelfInfo
  294. return shelfInfo&&shelfInfo.contactMobile ? shelfInfo.contactMobile : ''
  295. },
  296. totalNum(){
  297. return this.hasLogin&&this.userInfo.sysUserFlag == '1' ? this.$store.state.vuex_cartTotal : 0
  298. },
  299. // 赠品数量
  300. giftNum(){
  301. return this.detail && this.detail.promoType=='BUY_PROD_GIVE_PROD' ? Math.floor(this.qty / this.detail.conditionValue)*this.detail.resultValue : 0
  302. },
  303. // 支付总金额
  304. payAmount(){
  305. const price = this.detail && this.detail.priceStr ? this.detail.priceStr.join('.') : 0
  306. return price ? Number(price*this.qty).toFixed(2) : 0
  307. },
  308. // 付款信息
  309. payInfo(){
  310. return this.$store.state.vuex_tempOrderData
  311. }
  312. },
  313. methods: {
  314. // 返回
  315. goBack(){
  316. if(this.isShare){
  317. uni.reLaunch({
  318. url: '/pages/index/index'
  319. })
  320. }else{
  321. uni.navigateBack()
  322. }
  323. },
  324. // 复制
  325. copy(text){
  326. uni.setClipboardData({
  327. data: text,
  328. })
  329. },
  330. viewImg(index){
  331. uni.previewImage({
  332. urls: this.imgList
  333. })
  334. },
  335. // 联系经销商
  336. callPhone() {
  337. if(this.dealerPhone!=''){
  338. uni.makePhoneCall({
  339. phoneNumber: this.dealerPhone
  340. })
  341. }
  342. },
  343. // 产品详情
  344. getDetail(){
  345. uni.showLoading({
  346. title: '加载中'
  347. })
  348. const storeShelf = this.$store.state.vuex_storeShelf
  349. const dealerSn = this.hasLogin && this.userInfo && this.userInfo.sysUserFlag == '1'&&storeShelf ? storeShelf.dealerSn : ''
  350. // 获取产品详情
  351. getShopDetail({
  352. shopProductSn: this.shopProductSn,
  353. dealerSn: dealerSn
  354. }).then(res => {
  355. if(res.status == 200){
  356. this.detail = res.data
  357. if(res.data){
  358. if(res.data.productPicList){
  359. res.data.productPicList.forEach(item => {
  360. this.imgList.push(item.imageUrl||'/static/def_imgs.png')
  361. })
  362. }else{
  363. this.imgList.push(res.data.productMsg||'/static/def_imgs.png')
  364. }
  365. const a = res.data.shopPromoProduct
  366. let bprice = res.data.price
  367. if(a){
  368. res.data.promoType = a.promoType
  369. res.data.resultValue = a.resultValue
  370. res.data.conditionValue = a.conditionValue
  371. res.data.discountType = a.discountType
  372. res.data.promoProductSn = a.promoProductSn
  373. res.data.promoSn = a.promoSn
  374. res.data.orginPrice = res.data.price
  375. // 特价
  376. if(res.data.promoType=='PROMO_PROD'){
  377. bprice =res.data.conditionValue
  378. }
  379. }
  380. res.data.priceStr = Number(bprice).toFixed(2).toString().split('.')
  381. }
  382. }
  383. uni.hideLoading()
  384. })
  385. },
  386. animationfinish(){
  387. this.loading = false
  388. },
  389. changeQty(value) {
  390. const max = 999
  391. const v = value > max ? max : (value==''||value==0?1:value)
  392. this.qty = v
  393. },
  394. // 加入购物车
  395. toAddCart(){
  396. // 未登录
  397. if(this.hasLogin){
  398. // 游客未认证
  399. if(this.userInfo.sysUserFlag == '0'){
  400. toAuthStore()
  401. }else{
  402. // 打开确认数量弹框
  403. this.isAddCart = true
  404. this.showPopu = true
  405. }
  406. }else{
  407. toLogin()
  408. }
  409. },
  410. // 确定加入购物车
  411. submitCart(event){
  412. if(this.loading){
  413. return
  414. }
  415. this.loading = true
  416. this.$refs.cartAnimation.touchOnGoods(event,this.busPos);
  417. // 加入购物车
  418. addCart({
  419. qty: this.qty,
  420. price: this.detail.price,
  421. productSn: this.detail.productSn
  422. }).then(res => {
  423. if(res.status == 200){
  424. uni.$emit('refashCart')
  425. this.showPopu = false
  426. }
  427. })
  428. },
  429. // 打开购物车页面
  430. toCart(){
  431. if(this.hasLogin){
  432. // 游客未认证
  433. if(this.userInfo.sysUserFlag == '0'){
  434. toAuthStore()
  435. }else{
  436. uni.navigateTo({
  437. url: '/pagesB/cart/index'
  438. })
  439. }
  440. }else{
  441. toLogin()
  442. }
  443. },
  444. // 立即购买
  445. toBuy(){
  446. if(this.hasLogin){
  447. // 游客未认证
  448. if(this.userInfo.sysUserFlag == '0'){
  449. toAuthStore()
  450. }else{
  451. if(this.detail.status==0 || this.detail.dealerScopeFlag==0){
  452. uni.showToast({
  453. title: '此商品已'+(this.detail.status==0?'下架':'售罄'),
  454. icon: 'none'
  455. })
  456. }else{
  457. // 打开数量选择弹框
  458. if(!this.showPopu){
  459. this.showPopu = true
  460. }else{
  461. // 去结算生产订单
  462. this.creatOrder()
  463. }
  464. }
  465. }
  466. }else{
  467. toLogin()
  468. }
  469. },
  470. // 取消立即购买
  471. cancelBuy(){
  472. this.resetPage()
  473. },
  474. // 去结算
  475. creatOrder(){
  476. uni.showLoading({
  477. title: '提交中...',
  478. mask: true
  479. })
  480. const _this = this
  481. purchaseCheck({detailList: [{
  482. productSn:this.detail.productSn,
  483. productCode:this.detail.productCode,
  484. qty: this.qty,
  485. price:this.detail.price,
  486. promoSn: this.detail.promoSn
  487. }]}).then(res => {
  488. uni.hideLoading()
  489. if(res.status == 200){
  490. const successList = res.data.successList ? res.data.successList.map(item => {
  491. return {
  492. productSn:item.productSn,
  493. productCode: item.productCode,
  494. qty: item.qty,
  495. price:item.price,
  496. promoSn: item.promoSn
  497. }
  498. }) : []
  499. const removeList = res.data.removeList ? res.data.removeList.map(item => item.productCode) : []
  500. const selloutList = res.data.selloutList ? res.data.selloutList.map(item => item.productCode) : []
  501. // 有已下架或已售罄产品提示
  502. if(removeList.length || selloutList.length){
  503. uni.showModal({
  504. title: '提示',
  505. content: (removeList.length ? `产品${removeList.join(',')}已下架,`:'')+(selloutList.length?`产品${selloutList.join(',')}已售罄,`:'')+`不可采购。`+(successList.length?'是否继续采购其他产品?':''),
  506. showCancel: successList.length,
  507. confirmText: successList.length?'确定':'知道了',
  508. success(ret) {
  509. if(ret.confirm && successList.length){
  510. _this.submitForm(successList)
  511. }
  512. }
  513. })
  514. }else{
  515. const promoChangeFlag = res.data.promoChangeFlag
  516. // 活动变更
  517. if(promoChangeFlag){
  518. uni.showModal({
  519. title: '提示',
  520. content: '促销活动已变更,请刷新?',
  521. confirmText:'确定刷新',
  522. success(ret) {
  523. if(ret.confirm){
  524. _this.showPopu = false
  525. _this.refashOk = true
  526. }
  527. }
  528. })
  529. return
  530. }
  531. // 直接提交
  532. _this.submitForm(successList)
  533. }
  534. }else{
  535. uni.showToast({
  536. title: res.message,
  537. icon: 'none'
  538. })
  539. }
  540. })
  541. },
  542. // 创建订单
  543. submitForm(detailList){
  544. uni.showLoading({
  545. title: '提交中...',
  546. mask: true
  547. })
  548. purchaseSave({
  549. detailList: detailList
  550. }).then(res => {
  551. if(res.status == 200){
  552. res.data.detailList = []
  553. this.$store.state.vuex_tempOrderData = res.data
  554. // 打开确认付款弹框,这里判断是否开通支付,如果开通
  555. if(this.hasPay){
  556. this.showPay = true
  557. }else{
  558. // 创建成功,跳转到订单详情页
  559. this.showPopu = false
  560. this.submitOk = true
  561. }
  562. uni.hideLoading()
  563. }else{
  564. uni.hideLoading()
  565. uni.showToast({
  566. title: res.message,
  567. icon: 'none'
  568. })
  569. }
  570. })
  571. },
  572. // 关闭之前
  573. beforeClosePopu(){
  574. // 正在支付
  575. if(this.showPay){
  576. this.showPay = false
  577. this.cancelPay()
  578. }
  579. },
  580. // 关闭确定订单弹窗后
  581. closePopu(){
  582. this.showPopu = false
  583. // 刷新页面
  584. if(this.refashOk){
  585. this.qty = 1
  586. this.getDetail()
  587. }else{
  588. // 开通了支付
  589. if(this.hasPay){
  590. // 付款
  591. if(this.showPay){
  592. // 确定取消付款或付款失败
  593. if(this.cacelOk){
  594. this.cacelOk = false
  595. }
  596. // 确定付款成功
  597. if(this.submitOk){
  598. this.submitOk = false
  599. }
  600. // 去订单详情页
  601. this.toOrderDetial()
  602. }else{
  603. // 取消立即购买
  604. this.resetPage()
  605. }
  606. }else{
  607. // 未开通支付
  608. // 去订单详情页
  609. if(this.submitOk){
  610. this.submitOk = false
  611. this.toOrderDetial()
  612. }else{
  613. // 取消采购
  614. this.resetPage()
  615. }
  616. }
  617. }
  618. },
  619. // 确认付款
  620. confirmPay(){
  621. this.showPopu = false
  622. this.submitOk = true
  623. },
  624. // 确认取消付款弹框
  625. cancelPay(){
  626. const _this = this
  627. uni.showModal({
  628. title: '确定取消支付吗?',
  629. content: '您的订单在30分钟内未支付将被取消,请尽快完成支付。',
  630. confirmText: '继续支付',
  631. cancelText: '取消支付',
  632. success(ret) {
  633. // 确定取消,跳转到订单详情页
  634. if(!ret.confirm){
  635. // 支付弹框打开中
  636. if(_this.showPopu){
  637. _this.showPopu = false
  638. _this.cacelOk = true
  639. }else{
  640. // 未打开直接跳转
  641. _this.toOrderDetial()
  642. }
  643. }else{
  644. // 继续支付
  645. _this.showPopu = true
  646. _this.showPay = true
  647. _this.cacelOk = false
  648. }
  649. }
  650. })
  651. },
  652. // 重置页面
  653. resetPage(){
  654. this.qty = 1
  655. this.isAddCart = false
  656. this.showPopu = false
  657. this.showPay = false
  658. this.cacelOk = false
  659. this.submitOk = false
  660. setTimeout(()=>{
  661. uni.hideLoading()
  662. },300)
  663. },
  664. // 订单详情页
  665. toOrderDetial(){
  666. this.resetPage()
  667. // 跳转到订单详情页面
  668. uni.navigateTo({
  669. url: "/pagesB/procureOrder/orderDetail"
  670. })
  671. }
  672. }
  673. }
  674. </script>
  675. <style lang="less">
  676. .pages {
  677. height: 100vh;
  678. display: flex;
  679. flex-direction: column;
  680. .scrollPage-header{
  681. z-index: 1;
  682. width: 100%;
  683. position:fixed;
  684. left: 0;
  685. top: 0;
  686. .header-title{
  687. display: flex;
  688. align-items: center;
  689. justify-content: space-between;
  690. padding: 0 10px;
  691. height: 44px;
  692. .header-left{
  693. display: flex;
  694. align-items: center;
  695. text{
  696. font-size: 14px;
  697. color: #333333;
  698. }
  699. background-color: rgba(255,255,255,0.6);
  700. box-shadow: 0px 1px 0px 0px #E6E6E6;
  701. border-radius: 50px;
  702. padding: 3px 6px 3px;
  703. }
  704. .header-right{
  705. width: 50px;
  706. }
  707. }
  708. }
  709. .copyText{
  710. background-color: #efefef;
  711. border-radius: 100rpx;
  712. padding: 0 20rpx;
  713. color: #03A9F4;
  714. font-size: 20rpx;
  715. display: inline-block;
  716. margin-left: 20rpx;
  717. height: 44rpx;
  718. line-height: 44rpx;
  719. }
  720. .scrollPage-content{
  721. flex: 1;
  722. overflow-y: auto;
  723. .product-info{
  724. background:#fff;
  725. margin-bottom: 10px;
  726. .product-info-text{
  727. padding: 10px;
  728. .product-info-text-title{
  729. font-weight: bold;
  730. color: #333333;
  731. line-height: 22px;
  732. margin-bottom: 5px;
  733. }
  734. .product-info-text-attr{
  735. display: flex;
  736. align-items: center;
  737. justify-content: space-between;
  738. .product-info-price{
  739. color: red;
  740. display: flex;
  741. align-items: baseline;
  742. font-size: 12px;
  743. text{
  744. font-size: 38rpx;
  745. }
  746. }
  747. .product-info-nums{
  748. font-size: 12px;
  749. color: #999999;
  750. >view{
  751. display: flex;
  752. align-items: center;
  753. }
  754. .share{
  755. button{
  756. width: auto;
  757. padding: 0;
  758. border: 0;
  759. background: none;
  760. line-height: normal;
  761. margin: 0;
  762. display: inline;
  763. font-size: 12px;
  764. color: #999;
  765. &::after{
  766. border:none;
  767. }
  768. /deep/ .u-icon{
  769. margin-right: 3px;
  770. }
  771. }
  772. }
  773. }
  774. }
  775. }
  776. }
  777. .product-info-guige{
  778. display: flex;
  779. flex-wrap: wrap;
  780. justify-content: space-between;
  781. background:#fff;
  782. margin: 10px 0;
  783. padding: 10px;
  784. line-height: 28px;
  785. .row{
  786. width: 100%;
  787. }
  788. .row-ban{
  789. width: 50%;
  790. }
  791. >view{
  792. color: #999;
  793. text{
  794. color: #333333;
  795. }
  796. }
  797. }
  798. .product-info-content{
  799. background:#fff;
  800. margin-bottom: 10px;
  801. padding: 10px;
  802. line-height: 28px;
  803. }
  804. }
  805. .rebate-tag{
  806. background: #ffe7df;
  807. color: #E91E63;
  808. padding: 2px 5px;
  809. font-size: 10px;
  810. border-radius: 3px;
  811. margin-left: 6px;
  812. }
  813. .tejia-tag{
  814. color: #E91E63;
  815. margin-left: 6px;
  816. font-size: 12px;
  817. text{
  818. font-size: 12px;
  819. color: #999;
  820. margin-left: 5px;
  821. text-decoration: line-through;
  822. }
  823. }
  824. .scrollPage-footer{
  825. background-color: #FFFFFF;
  826. width: 100%;
  827. position: fixed;
  828. left: 0;
  829. bottom: 0;
  830. .scrollPage-footer-box{
  831. display: flex;
  832. align-items: center;
  833. justify-content: space-between;
  834. height: 45px;
  835. }
  836. .footer-left{
  837. display: flex;
  838. align-items: center;
  839. justify-content: space-between;
  840. width: 35%;
  841. .footer-left-item{
  842. display: flex;
  843. flex-direction: column;
  844. align-items: center;
  845. justify-content: center;
  846. padding: 0 15px;
  847. position: relative;
  848. .footer-left-item-text{
  849. font-size: 12px;
  850. color: #666666;
  851. }
  852. .badge{
  853. background: #f44336;
  854. color: #fff;
  855. position: absolute;
  856. right: 5px;
  857. top: -8px;
  858. font-size: 12px;
  859. display: flex;
  860. align-items: center;
  861. justify-content: center;
  862. border-radius: 50rpx;
  863. padding: 0 10rpx;
  864. }
  865. }
  866. }
  867. .footer-right{
  868. width: 60%;
  869. height: 80%;
  870. display: flex;
  871. align-items: center;
  872. border-radius: 50px;
  873. overflow: hidden;
  874. margin: 0 5px;
  875. .footer-right-item{
  876. height: 100%;
  877. display: flex;
  878. flex-direction: column;
  879. align-items: center;
  880. justify-content: center;
  881. width: 50%;
  882. font-size: 14px;
  883. color: #FFFFFF;
  884. }
  885. .footer-right-item:first-child{
  886. background-color: #FF9900;
  887. }
  888. .footer-right-item:last-child{
  889. background-color: #FF0000;
  890. }
  891. }
  892. }
  893. .popu-nums-content{
  894. background-color: #FFFFFF;
  895. border-radius: 10px;
  896. width: 300px;
  897. display: flex;
  898. flex-direction: column;
  899. align-items: center;
  900. padding: 10px 15px;
  901. .popu-close{
  902. padding: 10px;
  903. position: absolute;
  904. right: 0;
  905. top: 0;
  906. z-index: 1000;
  907. }
  908. .popu-content-title{
  909. padding: 10px;
  910. font-size: 16px;
  911. }
  912. .popu-content-num{
  913. font-size: 14px;
  914. color: #999999;
  915. padding: 10px 0;
  916. > text{
  917. margin-right: 10px;
  918. font-size: 10px;
  919. }
  920. }
  921. .popu-content-btn{
  922. width: 100%;
  923. display: flex;
  924. align-items: center;
  925. justify-content: space-around;
  926. margin: 20px 0 10px;
  927. .popu-content-btn-item{
  928. width: 40%;
  929. height: 32px;
  930. font-size: 14px;
  931. display: flex;
  932. align-items: center;
  933. justify-content: center;
  934. border-radius: 100px;
  935. }
  936. .cancelBtn{
  937. background-color: #f8f8f8;
  938. color: #666;
  939. }
  940. .okbtn{
  941. background-color: #f70000;
  942. color: #FFFFFF;
  943. }
  944. }
  945. }
  946. .popu-content{
  947. display: flex;
  948. flex-direction: column;
  949. align-items: center;
  950. padding: 10px 15px;
  951. .popu-close{
  952. padding: 10px;
  953. position: absolute;
  954. right: 0;
  955. top: 0;
  956. z-index: 1000;
  957. }
  958. .qty-box{
  959. display: flex;
  960. .qty-btn{
  961. display: flex;
  962. align-items: center;
  963. justify-content: center;
  964. width: 22px;
  965. height: 20px;
  966. border-radius: 50px;
  967. font-size: 18px;
  968. color: #066cff;
  969. &.qty-disabled{
  970. color: #999;
  971. }
  972. }
  973. .qty-num{
  974. width: 24px;
  975. height: 20px;
  976. line-height: 20px;
  977. text-align: center;
  978. background-color: #efefef;
  979. margin: 0 3px;
  980. border-radius: 3px;
  981. font-size: 12px;
  982. input{
  983. width: 100%;
  984. height: 100%;
  985. text-align: center;
  986. color: #333;
  987. }
  988. }
  989. }
  990. .pupu-box{
  991. display: flex;
  992. justify-content: space-between;
  993. margin-top: 35px;
  994. width: 100%;
  995. }
  996. .popu-content-img{
  997. border-radius: 6px;
  998. border: 1px solid #eee;
  999. overflow: hidden;
  1000. width: 80px;
  1001. height: 80px;
  1002. }
  1003. .popu-content-info{
  1004. padding: 0 0 0 10px;
  1005. flex-grow: 1;
  1006. overflow: hidden;
  1007. width: 50%;
  1008. .popu-content-info-title{
  1009. font-size: 14px;
  1010. }
  1011. }
  1012. .gift-box{
  1013. padding-left: 8%;
  1014. margin-top: 0;
  1015. border-top: 1px solid #eee;
  1016. padding-top: 10px;
  1017. .popu-content-img{
  1018. width: 58px;
  1019. height: 58px;
  1020. }
  1021. .popu-content-info-title{
  1022. font-size: 12px;
  1023. color: #666;
  1024. }
  1025. .popu-content-box{
  1026. margin-top: 0;
  1027. }
  1028. .popu-content-num{
  1029. padding:5px 0;
  1030. >text{
  1031. font-size: 10px;
  1032. }
  1033. }
  1034. .rebate-tag{
  1035. margin: 0 5px 0 0;
  1036. background: #ff0000;
  1037. color: #fff;
  1038. flex-grow: 1;
  1039. display: flex;
  1040. justify-content: center;
  1041. }
  1042. .ellipsis-two{
  1043. width: 80%;
  1044. flex-grow: 1;
  1045. }
  1046. }
  1047. .popu-content-box{
  1048. display: flex;
  1049. align-items: baseline;
  1050. margin-top: 5px;
  1051. .popu-content-price{
  1052. color: red;
  1053. display: flex;
  1054. align-items: baseline;
  1055. font-size: 12px;
  1056. text{
  1057. font-size: 38rpx;
  1058. }
  1059. }
  1060. }
  1061. .pupu-box-item,.pupu-box-pay-item{
  1062. width: 100%;
  1063. padding-top: 10px;
  1064. > view{
  1065. padding: 10px 0;
  1066. }
  1067. }
  1068. .pupu-box-pay-item{
  1069. > view{
  1070. padding: 6px 0;
  1071. }
  1072. .popu-content-amount{
  1073. font-size: 24px;
  1074. color: red;
  1075. }
  1076. .popu-content-title{
  1077. font-weight: bold;
  1078. }
  1079. }
  1080. .popu-content-num{
  1081. > text{
  1082. margin-right: 10px;
  1083. }
  1084. }
  1085. .popu-content-btn{
  1086. width: 100%;
  1087. display: flex;
  1088. align-items: center;
  1089. justify-content: space-around;
  1090. margin: 20px 0 10px;
  1091. .popu-content-btn-item{
  1092. width: 30%;
  1093. height: 34px;
  1094. font-size: 14px;
  1095. display: flex;
  1096. align-items: center;
  1097. justify-content: center;
  1098. border-radius: 100px;
  1099. }
  1100. .cancelBtn{
  1101. background-color: #f8f8f8;
  1102. color: #666;
  1103. }
  1104. .okbtn{
  1105. background-color: #f70000;
  1106. color: #FFFFFF;
  1107. width: 65%;
  1108. .payAmount{
  1109. margin-left: 5px;
  1110. }
  1111. }
  1112. .cartbtn{
  1113. background-color: #ffa60c;
  1114. color: #FFFFFF;
  1115. width: 65%;
  1116. }
  1117. }
  1118. }
  1119. }
  1120. </style>