productDetail.vue 36 KB

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