step1.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false" ><view class="div container">
  3. <view class="div common-header-wrap">
  4. <view :style="'height:'+navHeight+'px'"></view>
  5. <view class="common-header-holder"></view>
  6. <view class="common-header-fixed">
  7. <title-header />
  8. <uni-nav-bar title="确认订单" class="common-header" left-icon="back" @clickLeft="goBack()">
  9. </uni-nav-bar>
  10. </view>
  11. </view>
  12. <view class="div body" v-if="store_final_total_list">
  13. <view class="div block-wrapper">
  14. <checkout-address v-if="addAddress" class="address" v-on:onclick="goAddress" :item="store_final_total_list.address_info"></checkout-address>
  15. <view class="div" v-if="store_final_total_list.if_presell" @click="showPopup('togglePresell')">
  16. <flex-line class="menu-item" :is-link="true" :show-border="true">
  17. <view class="div">
  18. <text class="span left-icon iconfont">&#xe664;</text>
  19. <text class="span">支付金额</text>
  20. </view>
  21. <text class="span" slot="right">{{presell_pay=='1'?'全额支付':'先付定金'}}</text>
  22. </flex-line>
  23. </view>
  24. <!--付款方式-->
  25. <view class="div" v-if="store_final_total_list.address_api.allow_offpay==1 && store_final_total_list.ifshow_offpay" @click="showPopup('togglePay')">
  26. <flex-line class="menu-item" :is-link="true" :show-border="true">
  27. <view class="div">
  28. <text class="span left-icon iconfont">&#xe664;</text>
  29. <text class="span">付款方式</text>
  30. </view>
  31. <text class="span" slot="right">{{pay_name}}</text>
  32. </flex-line>
  33. </view>
  34. <!--发票-->
  35. <view class="div" @click="goNavigate('/pages/member/invoice/InvoiceList',{isFromCheckout:true,goBackLevel:1,invoice_id:invoice_id,vat_deny:store_final_total_list.vat_deny,params:JSON.stringify(option)})">
  36. <flex-line class="menu-item" :is-link="true" :show-border="true">
  37. <view class="div">
  38. <text class="span left-icon iconfont">&#xe664;</text>
  39. <text class="span">发票</text>
  40. </view>
  41. <text class="span" slot="right">{{invoice_content}}</text>
  42. </flex-line>
  43. </view>
  44. <!--平台代金券-->
  45. <view v-if="myMallVoucher != ''" @click="showPopup('mallvoucherVisible')">
  46. <flex-line class="menu-item" :is-link="true" :show-border="true">
  47. <view>
  48. <text class="left-icon iconfont">&#xe664;</text>
  49. <text>平台代金券</text>
  50. </view>
  51. <text slot="right">{{myMallVoucherprice}}</text>
  52. </flex-line>
  53. </view>
  54. </view>
  55. <checkout-store class="section-header" :addressInfo="store_final_total_list.address_info" :payGoodsList="store_final_total_list.pay_goods_list" :finalTotalList="store_final_total_list.store_final_total_list" :addressApi="store_final_total_list.address_api" :storeCartList="store_final_total_list.store_cart_list" :ifshowOffpay="store_final_total_list.ifshow_offpay" @selectVoucher="selectVoucher" @selectChain="selectChain" @changeMessage="changeMessage"></checkout-store>
  56. </view>
  57. <view class="div bottom-wrapper" v-if="store_final_total_list && store_final_total_list.limit == false">
  58. <flex-line v-if="!f_code_check && store_final_total_list.store_cart_list_api[0].goods_list[0].is_goodsfcode==1" class="field-line"><text class="span field-name">F码</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="f_code" placeholder="请填写F码" /><view class="div common-btn ds-button-small" @click="checkfcode">使用</view></view></flex-line>
  59. <view v-else class="div amount-wrapper">
  60. <view class="div common-btn ds-button-large" @click="checkout">提交订单</view>
  61. </view>
  62. </view>
  63. <view class="div bottom-wrapper" v-else>
  64. <view class="div amount-wrapper">
  65. <view class="div common-btn ds-button-large" >该地区不可购买,请更换收货地区</view>
  66. </view>
  67. </view>
  68. <uni-popup background-color="#fff" ref="togglePay" type="right" >
  69. <view :style="'width:'+screenWidth+'px'" class="common-popup-wrapper">
  70. <view class="div common-header-wrap">
  71. <view :style="'height:'+navHeight+'px'"></view>
  72. <view class="common-header-holder"></view>
  73. <view class="common-header-fixed">
  74. <title-header />
  75. <uni-nav-bar title="付款方式" class="common-header" left-icon="back" @clickLeft="hidePopup('togglePay')">
  76. </uni-nav-bar>
  77. </view>
  78. </view>
  79. <view class="div common-popup-content">
  80. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" scroll-y="true">
  81. <radio-group @change="radioChange(1,$event)" class='radio-wrapper'>
  82. <view class='radio-item' v-for="(item, index) in pay_options" :key="index">
  83. <radio :value="item.value" :checked="pay_code==item.value" />
  84. <text>{{item.label}}</text>
  85. </view>
  86. </radio-group>
  87. </scroll-view>
  88. </view>
  89. </view>
  90. </uni-popup>
  91. <uni-popup background-color="#fff" ref="togglePresell" type="right" >
  92. <view :style="'width:'+screenWidth+'px'" class="common-popup-wrapper">
  93. <view class="div common-header-wrap">
  94. <view :style="'height:'+navHeight+'px'"></view>
  95. <view class="common-header-holder"></view>
  96. <view class="common-header-fixed">
  97. <title-header />
  98. <uni-nav-bar title="支付金额" class="common-header" left-icon="back" @clickLeft="hidePopup('togglePresell')">
  99. </uni-nav-bar>
  100. </view>
  101. </view>
  102. <view class="div common-popup-content">
  103. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" scroll-y="true">
  104. <radio-group @change="radioChange(2,$event)" class='radio-wrapper'>
  105. <view class='radio-item' v-for="(item, index) in presell_options" :key="index">
  106. <radio :value="item.value" :checked="presell_pay==item.value" />
  107. <text>{{item.label}}</text>
  108. </view>
  109. </radio-group>
  110. <view class="div desc-text">定金下单后,若非商城或商家责任,定金恕不退还</view>
  111. </scroll-view>
  112. </view>
  113. </view>
  114. </uni-popup>
  115. <uni-popup background-color="#fff" ref="mallvoucherVisible" type="right" >
  116. <view :style="'width:'+screenWidth+'px'" class="common-popup-wrapper">
  117. <view class="div common-header-wrap">
  118. <view :style="'height:'+navHeight+'px'"></view>
  119. <view class="common-header-holder"></view>
  120. <view class="common-header-fixed">
  121. <title-header />
  122. <uni-nav-bar title="平台代金券" class="common-header" left-icon="back" @clickLeft="hidePopup('mallvoucherVisible')">
  123. <view class="div common-btn btn" slot="right" @click="selectMallVoucher('')">不使用</view>
  124. </uni-nav-bar>
  125. </view>
  126. </view>
  127. <view class="div common-popup-content">
  128. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" scroll-y="true">
  129. <view class="div common-voucher common-voucher02" v-for="(item,index) in myMallVoucher" :key="item.mallvoucheruser_id" @click="selectMallVoucher(item)">
  130. <view class="div par"><view class="p">订单满{{item.mallvoucheruser_limit}}元</view><text class="sub sign">¥</text><text class="span">{{item.mallvoucheruser_price}}</text></view>
  131. <view class="div copy">有效期至<view class="p"><br>{{$moment.unix(item.mallvoucheruser_enddate).format('YYYY.MM.DD')}}</view></view>
  132. <text class="i"></text>
  133. </view>
  134. </scroll-view>
  135. </view>
  136. </view>
  137. </uni-popup>
  138. </view>
  139. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  140. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  141. </uni-popup>
  142. </member-base>
  143. </template>
  144. <script>
  145. import {getFontSize} from '@/util/common'
  146. import TitleHeader from '../../TitleHeader'
  147. import { urlencode } from '@/util/common'
  148. import MemberBase from '../MemberBase'
  149. import { buyStep1, buyStep2, checkFCode } from '../../../api/memberBuy'
  150. import CheckoutAddress from './child/CheckoutAddress'
  151. import CheckoutStore from './child/CheckoutStore'
  152. import flexLine from '../../flexLine'
  153. export default {
  154. name: 'Step1',
  155. components:{
  156. TitleHeader,
  157. MemberBase,
  158. flexLine,
  159. CheckoutAddress,
  160. CheckoutStore
  161. },
  162. computed:{
  163. fontSize(){
  164. return getFontSize()
  165. },
  166. },
  167. data(){
  168. return {
  169. addAddress:false,
  170. navHeight: 0,
  171. dialog:{},
  172. option:{},
  173. buy_now:0,
  174. pintuan_id:0,
  175. pintuangroup_id:0,
  176. bargainorder_id:0,
  177. screenWidth:0,
  178. presell_pay: '1',
  179. pay_name: '在线付款',
  180. pay_code: 'online',
  181. pay_options: [{
  182. label: '在线付款',
  183. value: 'online'
  184. }, {
  185. label: '货到付款',
  186. value: 'offline'
  187. }],
  188. presell_options: [{
  189. label: '全额支付',
  190. value: '1'
  191. }, {
  192. label: '先付定金',
  193. value: '2'
  194. }],
  195. pay_list: { online: '在线付款', offline: '货到付款' },
  196. hidePay: false,
  197. f_code: '',
  198. invoice_id: 0,
  199. invoice_content: '',
  200. f_code_check: false,
  201. cart_id: '',
  202. store_final_total_list: null,
  203. message: [],
  204. chain_goods: [],
  205. myMallVoucher: [],
  206. myMallVoucherprice:'不使用',
  207. mall_voucher_info:'',
  208. }
  209. },
  210. watch: {
  211. pay_code: function (pay_code) {
  212. this.pay_name = this.pay_list[pay_code]
  213. this.hidePopup('togglePay')
  214. if (pay_code == 'offline' && !this.store_final_total_list.pay_goods_list.online) {
  215. this.hidePay = true
  216. } else {
  217. this.hidePay = false
  218. }
  219. }
  220. },
  221. onLoad: function (option) {
  222. this.invoice_id=option.invoice_id ? option.invoice_id : 0
  223. this.invoice_content=option.invoice_content ? option.invoice_content : ''
  224. this.cart_id=option.cart_id ? option.cart_id : ''
  225. this.bargainorder_id=option.bargainorder_id
  226. this.buy_now=option.buy_now
  227. this.pintuan_id=option.pintuan_id
  228. this.pintuangroup_id=option.pintuangroup_id
  229. this.option=option
  230. },
  231. onShow(){
  232. this.getBuyInfo()
  233. },
  234. mounted(){
  235. // #ifdef MP-WEIXIN
  236. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  237. // #endif
  238. this.screenWidth=uni.getSystemInfoSync().screenWidth
  239. },
  240. methods:{
  241. radioChange(i,e){
  242. switch(i){
  243. case 1:
  244. this.pay_code=e.detail.value
  245. break
  246. case 2:
  247. this.presell_pay=e.detail.value
  248. break
  249. }
  250. },
  251. closeDialog(){
  252. },
  253. confirmDialog(value){
  254. },
  255. goNavigate(path,query=false){
  256. uni.navigateTo({url:path+(query?('?'+urlencode(query)):'')})
  257. },
  258. showPopup(id){
  259. this.$refs[id].open()
  260. },
  261. hidePopup(id){
  262. this.$refs[id].close()
  263. },
  264. checkfcode () {
  265. checkFCode(this.store_final_total_list.store_cart_list_api[0].goods_list[0].goods_commonid, this.f_code).then(res => {
  266. this.f_code_check = true
  267. }).catch(function (error) {
  268. uni.showToast({icon:'none',title: error.message})
  269. })
  270. },
  271. // 获取订单信息
  272. getBuyInfo () {
  273. let extra = {}
  274. if (this.bargainorder_id) {
  275. extra['bargainorder_id'] = this.bargainorder_id
  276. }
  277. buyStep1(
  278. this.cart_id, this.buy_now ? 0 : 1, this.pintuan_id, this.pintuangroup_id, extra
  279. ).then((res) => {
  280. if (res.code === 10000) {
  281. this.store_final_total_list = res.result
  282. this.myMallVoucher = res.result.mall_voucher_list
  283. this.addAddress=true
  284. if (this.invoice_content) {
  285. if (!this.store_final_total_list.inv_info.invoice_id) {
  286. this.invoice_id = 0
  287. this.invoice_content = this.store_final_total_list.inv_info.invoice_title
  288. }
  289. } else {
  290. this.invoice_content = this.store_final_total_list.inv_info.invoice_title
  291. if (this.store_final_total_list.inv_info.invoice_id) {
  292. this.invoice_id = this.store_final_total_list.inv_info.invoice_id
  293. }
  294. }
  295. } else {
  296. }
  297. }).catch(function (error) {
  298. uni.showToast({icon:'none',title: error.message})
  299. })
  300. },
  301. goBack () {
  302. uni.navigateBack({delta:1})
  303. },
  304. selectVoucher (voucherInfo, store_id) {
  305. this.store_final_total_list.store_cart_list[store_id].store_voucher_info = voucherInfo
  306. },
  307. selectMallVoucher (voucherInfo) {
  308. this.hidePopup('mallvoucherVisible')
  309. this.mall_voucher_info = voucherInfo
  310. if(this.mall_voucher_info){
  311. this.myMallVoucherprice = this.mall_voucher_info.mallvoucheruser_price + '元'
  312. }else{
  313. this.myMallVoucherprice = '不使用'
  314. }
  315. },
  316. selectChain (chain,store_id) {
  317. this.store_final_total_list.store_cart_list[store_id].chain_goods = chain[store_id]
  318. },
  319. goAddress () {
  320. if (this.store_final_total_list.address_info) {
  321. uni.navigateTo({ url: '/pages/member/address/AddressList' })
  322. } else {
  323. this.addAddress=false
  324. uni.navigateTo({ url: '/pages/member/address/AddressForm'+'?'+urlencode( { action: 'add',isFromCheckout: true,goBackLevel: 2 })})
  325. }
  326. },
  327. changeMessage (message, store_id) {
  328. this.message[store_id] = message
  329. },
  330. // 提交订单
  331. checkout () {
  332. let ifcart = this.buy_now ? 0 : 1
  333. let pintuan_id = this.pintuan_id
  334. let pintuangroup_id = this.pintuangroup_id
  335. let cart_id = this.cart_id
  336. let address_id = this.store_final_total_list.address_info ? this.store_final_total_list.address_info.address_id : 0
  337. let vat_hash = this.store_final_total_list.vat_hash
  338. let offpay_hash = this.store_final_total_list.address_api.offpay_hash
  339. let offpay_hash_batch = this.store_final_total_list.address_api.offpay_hash_batch
  340. let invoice_id = this.invoice_id
  341. let voucher = null
  342. let mallvoucher = null
  343. let chaininfo= null
  344. let pay_message_temp = []
  345. let f_code = this.f_code
  346. let pay_code = this.pay_code
  347. if (!address_id) {
  348. this.dialog={content:'您需要先去添加收货地址'}
  349. this.$refs.confirm.open()
  350. return
  351. }
  352. // 处理格式
  353. voucher = ''
  354. let voucher_temp = []
  355. for (var t in this.store_final_total_list.store_cart_list) {
  356. voucher_temp.push([this.store_final_total_list.store_cart_list[t].store_voucher_info.vouchertemplate_id + '|' + t + '|' + this.store_final_total_list.store_cart_list[t].store_voucher_info.voucher_price])
  357. }
  358. voucher = voucher_temp.join(',')
  359. mallvoucher = '|0.00'
  360. if(this.mall_voucher_info != ''){
  361. mallvoucher = this.mall_voucher_info.mallvouchertemplate_id +'|'+this.mall_voucher_info.mallvoucheruser_price
  362. }
  363. chaininfo = ''
  364. let chain_temp = []
  365. for (var t in this.store_final_total_list.store_cart_list) {
  366. if(this.store_final_total_list.store_cart_list[t].chain_goods){
  367. chain_temp.push([t + '|' + this.store_final_total_list.store_cart_list[t].chain_goods.chain_id])
  368. }
  369. }
  370. chaininfo = chain_temp.join(',')
  371. let i
  372. for (i in this.store_final_total_list.store_cart_list) {
  373. let message = this.message[this.store_final_total_list.store_cart_list[i].store_id]
  374. if (typeof (message) === 'undefined') {
  375. message = ''
  376. }
  377. pay_message_temp.push(this.store_final_total_list.store_cart_list[i].store_id + '|' + message)
  378. }
  379. let pay_message = pay_message_temp.join(',')
  380. let extra = {}
  381. if (this.bargainorder_id) {
  382. extra['bargainorder_id'] = this.bargainorder_id
  383. }
  384. extra['chain_goods'] = chaininfo
  385. extra['presell_pay'] = this.presell_pay
  386. buyStep2(
  387. ifcart,
  388. cart_id,
  389. address_id,
  390. vat_hash,
  391. offpay_hash,
  392. offpay_hash_batch,
  393. invoice_id,
  394. voucher,
  395. mallvoucher,
  396. pay_message,
  397. pintuan_id,
  398. pintuangroup_id,
  399. f_code,
  400. pay_code,
  401. extra
  402. ).then((res) => {
  403. // 跳转到支付界面
  404. let pay_sn = res.result.pay_sn
  405. uni.redirectTo({ url: '/pages/member/buy/pay'+'?'+urlencode( { pay_sn: pay_sn, pay_type: 'pay_new' } )})
  406. }).catch(error => {
  407. this.password = ''
  408. uni.showToast({icon:'none',title: error.message})
  409. })
  410. }
  411. }
  412. }
  413. </script>
  414. <style scoped lang="scss">
  415. .common-header{
  416. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  417. }
  418. .block-wrapper{background: #fff;padding:0 $pageSpace}
  419. .container {
  420. display: flex;
  421. flex-direction: column;
  422. justify-content: flex-start;
  423. align-items: stretch;
  424. }
  425. .header {
  426. height: 2.2rem;
  427. color: #48505d;
  428. font-size:$h1;
  429. background-color: #fff;
  430. padding: 0.1rem 0;
  431. border-bottom: 1px solid #e8eaed;
  432. }
  433. .body {
  434. display: flex;
  435. flex-direction: column;
  436. justify-content: flex-start;
  437. align-items: stretch;
  438. margin-bottom:4rem;
  439. }
  440. .address {
  441. }
  442. .goods {
  443. height: 4.5rem;
  444. }
  445. .item {
  446. height: 2.5rem;
  447. }
  448. .section-header {
  449. margin-top: 0.4rem;
  450. }
  451. .section-footer {
  452. margin-bottom: 0.4rem;
  453. }
  454. .comment {
  455. height: 7.25rem;
  456. }
  457. .desc {
  458. background-color: #fff;
  459. display: flex;
  460. flex-direction: column;
  461. justify-content: flex-start;
  462. align-items: stretch;
  463. padding-top: 0.5rem;
  464. padding-bottom: 0.5rem;
  465. }
  466. .desc-item {
  467. height: 1.5rem;
  468. }
  469. .bottom-wrapper {
  470. z-index: 1;
  471. background: #fff;
  472. position: fixed;
  473. left: 0;
  474. right: 0;
  475. bottom: 0;
  476. padding:.5rem 0;
  477. display: flex;
  478. flex-direction: row;
  479. justify-content: flex-start;
  480. align-items: stretch;
  481. }
  482. .amount-wrapper {
  483. flex: 1;
  484. background-color: #fff;
  485. margin:0 $pageSpace;
  486. }
  487. .amount {
  488. flex: 1;
  489. font-size:$h2;
  490. color: $primaryColor;
  491. text-align: right;
  492. padding-right: 0.75rem;
  493. }
  494. .submit {
  495. width: 7.5rem;
  496. height: 2.5rem;
  497. border-radius: 0;
  498. }
  499. .left-icon{float:left;font-size:$h1;margin-right:0.2rem;}
  500. .desc-text{font-size:$subFontSize;color: #999;padding:1rem}
  501. .radio-wrapper{
  502. display: block;
  503. padding: 0 $pageSpace;
  504. .radio-item{
  505. padding: .5rem 0;
  506. border-bottom: 1px dashed #f5f5f5;
  507. }
  508. }
  509. .common-voucher{margin:0.5rem auto}
  510. </style>