productDetail.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  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. console.log(this.showPay,this.submitOk,this.cacelOk)
  588. // 正在支付
  589. if(this.cacelOk&&!this.submitOk){
  590. this.cacelOk = false
  591. this.cancelPay()
  592. }
  593. },
  594. // 关闭确定订单弹窗后
  595. closePopu(){
  596. this.showPopu = false
  597. // 刷新页面
  598. if(this.refashOk){
  599. this.qty = 1
  600. this.getDetail()
  601. }else{
  602. // 开通了支付
  603. if(this.hasPay){
  604. // 付款
  605. if(this.showPay){
  606. // 确定取消付款或付款失败
  607. if(this.cacelOk){
  608. this.cacelOk = false
  609. }
  610. // 确定付款成功
  611. if(this.submitOk){
  612. this.submitOk = false
  613. }
  614. // 去订单详情页
  615. this.toOrderDetial()
  616. }else{
  617. // 取消立即购买
  618. this.resetPage()
  619. }
  620. }else{
  621. // 未开通支付
  622. // 去订单详情页
  623. if(this.submitOk){
  624. this.submitOk = false
  625. this.toOrderDetial()
  626. }else{
  627. // 取消采购
  628. this.resetPage()
  629. }
  630. }
  631. }
  632. },
  633. // 确认付款
  634. confirmPay(){
  635. const _this = this
  636. // uni.showLoading({
  637. // title: '正在支付...',
  638. // mask: true
  639. // })
  640. // 确认付款
  641. const data = _this.payData
  642. uni.requestPayment({
  643. provider: 'wxpay',
  644. timeStamp: data.timeStamp,
  645. nonceStr: data.nonceStr,
  646. package: data.packageValue,
  647. signType: data.signType,
  648. paySign: data.paySign,
  649. success: (res) =>{
  650. console.log('success:', res);
  651. _this.payComplete(1,data)
  652. },
  653. fail: (err)=> {
  654. console.log('fail:',err);
  655. _this.payComplete(err.errMsg.indexOf("cancel")>=0 ? 2 : 0,data)
  656. }
  657. });
  658. },
  659. payComplete(type,data){
  660. uni.showToast({
  661. mask: true,
  662. title: data==1 ? '支付成功' : (type==2?'支付取消':'支付失败'),
  663. icon: 'none'
  664. })
  665. this.showPopu = false
  666. this.submitOk = true
  667. },
  668. // 确认取消付款弹框
  669. cancelPay(){
  670. const _this = this
  671. uni.showModal({
  672. title: '确定取消支付吗?',
  673. content: '您的订单在30分钟内未支付将被取消,请尽快完成支付。',
  674. confirmText: '继续支付',
  675. cancelText: '取消支付',
  676. success(ret) {
  677. // 确定取消,跳转到订单详情页
  678. if(ret.cancel){
  679. // 支付弹框打开中
  680. if(_this.showPopu){
  681. console.log(0)
  682. _this.showPopu = false
  683. _this.cacelOk = true
  684. }else{
  685. console.log(1)
  686. // 未打开直接跳转
  687. _this.toOrderDetial()
  688. }
  689. }
  690. if(ret.confirm){
  691. console.log(2)
  692. // 继续支付
  693. _this.showPopu = true
  694. _this.showPay = true
  695. _this.cacelOk = false
  696. }
  697. }
  698. })
  699. },
  700. // 重置页面
  701. resetPage(){
  702. this.qty = 1
  703. this.isAddCart = false
  704. this.showPopu = false
  705. this.showPay = false
  706. this.cacelOk = false
  707. this.submitOk = false
  708. setTimeout(()=>{
  709. uni.hideLoading()
  710. },300)
  711. },
  712. // 订单详情页
  713. toOrderDetial(){
  714. this.resetPage()
  715. // 跳转到订单详情页面
  716. uni.navigateTo({
  717. url: "/pagesB/procureOrder/orderDetail"
  718. })
  719. }
  720. }
  721. }
  722. </script>
  723. <style lang="less">
  724. .pages {
  725. height: 100vh;
  726. display: flex;
  727. flex-direction: column;
  728. .scrollPage-header{
  729. z-index: 1;
  730. width: 100%;
  731. position:fixed;
  732. left: 0;
  733. top: 0;
  734. .header-title{
  735. display: flex;
  736. align-items: center;
  737. justify-content: space-between;
  738. padding: 0 10px;
  739. height: 44px;
  740. .header-left{
  741. display: flex;
  742. align-items: center;
  743. text{
  744. font-size: 14px;
  745. color: #333333;
  746. }
  747. background-color: rgba(255,255,255,0.6);
  748. box-shadow: 0px 1px 0px 0px #E6E6E6;
  749. border-radius: 50px;
  750. padding: 3px 6px 3px;
  751. }
  752. .header-right{
  753. width: 50px;
  754. }
  755. }
  756. }
  757. .copyText{
  758. background-color: #efefef;
  759. border-radius: 100rpx;
  760. padding: 0 20rpx;
  761. color: #03A9F4;
  762. font-size: 20rpx;
  763. display: inline-block;
  764. margin-left: 20rpx;
  765. height: 44rpx;
  766. line-height: 44rpx;
  767. }
  768. .scrollPage-content{
  769. flex: 1;
  770. overflow-y: auto;
  771. .product-info{
  772. background:#fff;
  773. margin-bottom: 10px;
  774. .product-info-text{
  775. padding: 10px;
  776. .product-info-text-title{
  777. font-weight: bold;
  778. color: #333333;
  779. line-height: 22px;
  780. margin-bottom: 5px;
  781. }
  782. .product-info-text-attr{
  783. display: flex;
  784. align-items: center;
  785. justify-content: space-between;
  786. .product-info-price{
  787. color: red;
  788. display: flex;
  789. align-items: baseline;
  790. font-size: 12px;
  791. text{
  792. font-size: 38rpx;
  793. }
  794. }
  795. .product-info-nums{
  796. font-size: 12px;
  797. color: #999999;
  798. >view{
  799. display: flex;
  800. align-items: center;
  801. }
  802. .share{
  803. button{
  804. width: auto;
  805. padding: 0;
  806. border: 0;
  807. background: none;
  808. line-height: normal;
  809. margin: 0;
  810. display: inline;
  811. font-size: 12px;
  812. color: #999;
  813. &::after{
  814. border:none;
  815. }
  816. /deep/ .u-icon{
  817. margin-right: 3px;
  818. }
  819. }
  820. }
  821. }
  822. }
  823. }
  824. }
  825. .product-info-guige{
  826. display: flex;
  827. flex-wrap: wrap;
  828. justify-content: space-between;
  829. background:#fff;
  830. margin: 10px 0;
  831. padding: 10px;
  832. line-height: 28px;
  833. .row{
  834. width: 100%;
  835. }
  836. .row-ban{
  837. width: 50%;
  838. }
  839. >view{
  840. color: #999;
  841. text{
  842. color: #333333;
  843. }
  844. }
  845. }
  846. .product-info-content{
  847. background:#fff;
  848. margin-bottom: 10px;
  849. padding: 10px;
  850. line-height: 28px;
  851. }
  852. }
  853. .rebate-tag{
  854. background: #ffe7df;
  855. color: #E91E63;
  856. padding: 2px 5px;
  857. font-size: 10px;
  858. border-radius: 3px;
  859. margin-left: 6px;
  860. }
  861. .tejia-tag{
  862. color: #E91E63;
  863. margin-left: 6px;
  864. font-size: 12px;
  865. text{
  866. font-size: 12px;
  867. color: #999;
  868. margin-left: 5px;
  869. text-decoration: line-through;
  870. }
  871. }
  872. .scrollPage-footer{
  873. background-color: #FFFFFF;
  874. width: 100%;
  875. position: fixed;
  876. left: 0;
  877. bottom: 0;
  878. .scrollPage-footer-box{
  879. display: flex;
  880. align-items: center;
  881. justify-content: space-between;
  882. height: 45px;
  883. }
  884. .footer-left{
  885. display: flex;
  886. align-items: center;
  887. justify-content: space-between;
  888. width: 35%;
  889. .footer-left-item{
  890. display: flex;
  891. flex-direction: column;
  892. align-items: center;
  893. justify-content: center;
  894. padding: 0 15px;
  895. position: relative;
  896. .footer-left-item-text{
  897. font-size: 12px;
  898. color: #666666;
  899. }
  900. .badge{
  901. background: #f44336;
  902. color: #fff;
  903. position: absolute;
  904. right: 5px;
  905. top: -8px;
  906. font-size: 12px;
  907. display: flex;
  908. align-items: center;
  909. justify-content: center;
  910. border-radius: 50rpx;
  911. padding: 0 10rpx;
  912. }
  913. }
  914. }
  915. .footer-right{
  916. width: 60%;
  917. height: 80%;
  918. display: flex;
  919. align-items: center;
  920. border-radius: 50px;
  921. overflow: hidden;
  922. margin: 0 5px;
  923. .footer-right-item{
  924. height: 100%;
  925. display: flex;
  926. flex-direction: column;
  927. align-items: center;
  928. justify-content: center;
  929. width: 50%;
  930. font-size: 14px;
  931. color: #FFFFFF;
  932. }
  933. .footer-right-item:first-child{
  934. background-color: #FF9900;
  935. }
  936. .footer-right-item:last-child{
  937. background-color: #FF0000;
  938. }
  939. }
  940. }
  941. .popu-nums-content{
  942. background-color: #FFFFFF;
  943. border-radius: 10px;
  944. width: 300px;
  945. display: flex;
  946. flex-direction: column;
  947. align-items: center;
  948. padding: 10px 15px;
  949. .popu-close{
  950. padding: 10px;
  951. position: absolute;
  952. right: 0;
  953. top: 0;
  954. z-index: 1000;
  955. }
  956. .popu-content-title{
  957. padding: 10px;
  958. font-size: 16px;
  959. }
  960. .popu-content-num{
  961. font-size: 14px;
  962. color: #999999;
  963. padding: 10px 0;
  964. > text{
  965. margin-right: 10px;
  966. font-size: 10px;
  967. }
  968. }
  969. .popu-content-btn{
  970. width: 100%;
  971. display: flex;
  972. align-items: center;
  973. justify-content: space-around;
  974. margin: 20px 0 10px;
  975. .popu-content-btn-item{
  976. width: 40%;
  977. height: 32px;
  978. font-size: 14px;
  979. display: flex;
  980. align-items: center;
  981. justify-content: center;
  982. border-radius: 100px;
  983. }
  984. .cancelBtn{
  985. background-color: #f8f8f8;
  986. color: #666;
  987. }
  988. .okbtn{
  989. background-color: #f70000;
  990. color: #FFFFFF;
  991. }
  992. }
  993. }
  994. .popu-content{
  995. display: flex;
  996. flex-direction: column;
  997. align-items: center;
  998. padding: 10px 15px;
  999. .popu-close{
  1000. padding: 10px;
  1001. position: absolute;
  1002. right: 0;
  1003. top: 0;
  1004. z-index: 1000;
  1005. }
  1006. .qty-box{
  1007. display: flex;
  1008. .qty-btn{
  1009. display: flex;
  1010. align-items: center;
  1011. justify-content: center;
  1012. width: 22px;
  1013. height: 20px;
  1014. border-radius: 50px;
  1015. font-size: 18px;
  1016. color: #066cff;
  1017. &.qty-disabled{
  1018. color: #999;
  1019. }
  1020. }
  1021. .qty-num{
  1022. width: 24px;
  1023. height: 20px;
  1024. line-height: 20px;
  1025. text-align: center;
  1026. background-color: #efefef;
  1027. margin: 0 3px;
  1028. border-radius: 3px;
  1029. font-size: 12px;
  1030. input{
  1031. width: 100%;
  1032. height: 100%;
  1033. text-align: center;
  1034. color: #333;
  1035. }
  1036. }
  1037. }
  1038. .pupu-box{
  1039. display: flex;
  1040. justify-content: space-between;
  1041. margin-top: 35px;
  1042. width: 100%;
  1043. }
  1044. .popu-content-img{
  1045. border-radius: 6px;
  1046. border: 1px solid #eee;
  1047. overflow: hidden;
  1048. width: 80px;
  1049. height: 80px;
  1050. }
  1051. .popu-content-info{
  1052. padding: 0 0 0 10px;
  1053. flex-grow: 1;
  1054. overflow: hidden;
  1055. width: 50%;
  1056. .popu-content-info-title{
  1057. font-size: 14px;
  1058. }
  1059. }
  1060. .gift-box{
  1061. padding-left: 8%;
  1062. margin-top: 0;
  1063. border-top: 1px solid #eee;
  1064. padding-top: 10px;
  1065. .popu-content-img{
  1066. width: 58px;
  1067. height: 58px;
  1068. }
  1069. .popu-content-info-title{
  1070. font-size: 12px;
  1071. color: #666;
  1072. }
  1073. .popu-content-box{
  1074. margin-top: 0;
  1075. }
  1076. .popu-content-num{
  1077. padding:5px 0;
  1078. >text{
  1079. font-size: 10px;
  1080. }
  1081. }
  1082. .rebate-tag{
  1083. margin: 0 5px 0 0;
  1084. background: #ff0000;
  1085. color: #fff;
  1086. flex-grow: 1;
  1087. display: flex;
  1088. justify-content: center;
  1089. }
  1090. .ellipsis-two{
  1091. width: 80%;
  1092. flex-grow: 1;
  1093. }
  1094. }
  1095. .popu-content-box{
  1096. display: flex;
  1097. align-items: baseline;
  1098. margin-top: 5px;
  1099. .popu-content-price{
  1100. color: red;
  1101. display: flex;
  1102. align-items: baseline;
  1103. font-size: 12px;
  1104. text{
  1105. font-size: 38rpx;
  1106. }
  1107. }
  1108. }
  1109. .pupu-box-item,.pupu-box-pay-item{
  1110. width: 100%;
  1111. padding-top: 10px;
  1112. > view{
  1113. padding: 10px 0;
  1114. }
  1115. }
  1116. .pupu-box-pay-item{
  1117. > view{
  1118. padding: 6px 0;
  1119. }
  1120. .popu-content-amount{
  1121. font-size: 24px;
  1122. color: red;
  1123. }
  1124. .popu-content-title{
  1125. font-weight: bold;
  1126. }
  1127. }
  1128. .popu-content-num{
  1129. > text{
  1130. margin-right: 10px;
  1131. }
  1132. }
  1133. .popu-content-btn{
  1134. width: 100%;
  1135. display: flex;
  1136. align-items: center;
  1137. justify-content: space-around;
  1138. margin: 20px 0 10px;
  1139. .popu-content-btn-item{
  1140. width: 30%;
  1141. height: 34px;
  1142. font-size: 14px;
  1143. display: flex;
  1144. align-items: center;
  1145. justify-content: center;
  1146. border-radius: 100px;
  1147. }
  1148. .cancelBtn{
  1149. background-color: #f8f8f8;
  1150. color: #666;
  1151. }
  1152. .okbtn{
  1153. background-color: #f70000;
  1154. color: #FFFFFF;
  1155. width: 65%;
  1156. .payAmount{
  1157. margin-left: 5px;
  1158. }
  1159. }
  1160. .cartbtn{
  1161. background-color: #ffa60c;
  1162. color: #FFFFFF;
  1163. width: 65%;
  1164. }
  1165. }
  1166. }
  1167. }
  1168. </style>