step1.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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" v-if="store_final_total_list.goods_info.virtual_type==0"><flex-line class="field-line" :show-border="true"><text class="span field-name">手机号</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="buyer_phone" placeholder="请填写手机号" /></view></flex-line></view>
  14. <checkout-store class="section-header" :storeCartList="store_final_total_list.goods_info" @selectVoucher="selectVoucher" @changeMessage="changeMessage"></checkout-store>
  15. </view>
  16. <view class="div bottom-wrapper" v-if="store_final_total_list">
  17. <view class="div amount-wrapper">
  18. <view class="div common-btn ds-button-large" @click="checkout">提交订单</view>
  19. </view>
  20. </view>
  21. </view>
  22. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  23. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  24. </uni-popup>
  25. </member-base>
  26. </template>
  27. <script>
  28. import {getFontSize} from '@/util/common'
  29. import TitleHeader from '../../TitleHeader'
  30. import { urlencode } from '@/util/common'
  31. import MemberBase from '../MemberBase'
  32. import { buyStep1, buyStep2 } from '../../../api/memberVrBuy'
  33. import CheckoutStore from './child/CheckoutStore'
  34. import flexLine from '../../flexLine'
  35. export default {
  36. name: 'Step1',
  37. components:{
  38. TitleHeader,
  39. MemberBase,
  40. flexLine,
  41. CheckoutStore
  42. },
  43. mounted(){
  44. // #ifdef MP-WEIXIN
  45. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  46. // #endif
  47. },
  48. computed:{
  49. fontSize(){
  50. return getFontSize()
  51. },
  52. },
  53. data(){
  54. return {
  55. navHeight: 0,
  56. dialog:{},
  57. pintuan_id:0,
  58. pintuangroup_id:0,
  59. goods_id: '',
  60. quantity: '',
  61. buyer_phone: '',
  62. store_final_total_list: null,
  63. message: ''
  64. }
  65. },
  66. onLoad: function (option) {
  67. this.goods_id=option.goods_id ? option.goods_id : ''
  68. this.quantity=option.quantity ? option.quantity : ''
  69. this.pintuan_id=option.pintuan_id
  70. this.pintuangroup_id=option.pintuangroup_id
  71. this.getBuyInfo()
  72. },
  73. methods:{
  74. closeDialog(){
  75. },
  76. confirmDialog(value){
  77. },
  78. // 获取订单信息
  79. getBuyInfo () {
  80. let extra = {}
  81. if (this.pintuan_id) {
  82. extra['pintuan_id'] = this.pintuan_id
  83. extra['pintuangroup_id'] = this.pintuangroup_id
  84. }
  85. buyStep1(
  86. this.goods_id, this.quantity, extra
  87. ).then((res) => {
  88. if (res.code === 10000) {
  89. this.store_final_total_list = res.result
  90. } else {
  91. }
  92. }).catch(function (error) {
  93. uni.showToast({icon:'none',title: error.message})
  94. })
  95. },
  96. goBack () {
  97. uni.navigateBack({delta:1})
  98. },
  99. selectVoucher (voucherInfo) {
  100. this.store_final_total_list.goods_info.store_voucher_info = voucherInfo
  101. },
  102. goAddress () {
  103. if (this.store_final_total_list.address_info) {
  104. uni.navigateTo({ url: '/pages/member/address/AddressList' })
  105. } else {
  106. uni.navigateTo({ url: '/pages/member/address/AddressForm'+'?'+urlencode( { action: 'add',isFromCheckout: true,goBackLevel: 1 })})
  107. }
  108. },
  109. changeMessage (message, store_id) {
  110. this.message = message
  111. },
  112. // 提交订单
  113. checkout () {
  114. let goods_id = this.goods_id
  115. let quantity = this.quantity
  116. let buyer_phone = this.buyer_phone
  117. let buyer_msg = this.message
  118. if (this.store_final_total_list.goods_info.virtual_type==0 && !buyer_phone) {
  119. this.dialog={content:'您需要先去填写手机号'}
  120. this.$refs.confirm.open()
  121. return
  122. }
  123. let extra = {}
  124. if (this.pintuan_id) {
  125. extra['pintuan_id'] = this.pintuan_id
  126. extra['pintuangroup_id'] = this.pintuangroup_id
  127. }
  128. // 处理格式
  129. let voucher = this.store_final_total_list.goods_info.store_voucher_info.vouchertemplate_id + '|' + this.store_final_total_list.goods_info.store_id + '|' + this.store_final_total_list.goods_info.store_voucher_info.voucher_price
  130. extra['voucher'] = voucher
  131. buyStep2(goods_id, quantity, buyer_phone, buyer_msg, extra
  132. ).then((res) => {
  133. // 跳转到支付界面
  134. let pay_sn = res.result.order_sn
  135. uni.redirectTo({ url: '/pages/member/buy/pay'+'?'+urlencode( { pay_sn: pay_sn, pay_type: 'vr_pay_new' })})
  136. }).catch(function (error) {
  137. uni.showToast({icon:'none',title: error.message})
  138. })
  139. }
  140. }
  141. }
  142. </script>
  143. <style scoped lang="scss">
  144. .block-wrapper{background: #fff;padding:0 $pageSpace}
  145. .container {
  146. display: flex;
  147. flex-direction: column;
  148. justify-content: flex-start;
  149. align-items: stretch;
  150. }
  151. .header {
  152. height: 2.2rem;
  153. color: #48505d;
  154. font-size:$h1;
  155. background-color: #fff;
  156. padding: 0.1rem 0;
  157. border-bottom: 1px solid #e8eaed;
  158. }
  159. .body {
  160. display: flex;
  161. flex-direction: column;
  162. justify-content: flex-start;
  163. align-items: stretch;
  164. margin-bottom:4rem;
  165. }
  166. .address {
  167. height: 5rem;
  168. }
  169. .goods {
  170. height: 4.5rem;
  171. }
  172. .item {
  173. height: 2.5rem;
  174. }
  175. .section-header {
  176. margin-top: 0.4rem;
  177. }
  178. .section-footer {
  179. margin-bottom: 0.4rem;
  180. }
  181. .comment {
  182. height: 7.25rem;
  183. }
  184. .desc {
  185. background-color: #fff;
  186. display: flex;
  187. flex-direction: column;
  188. justify-content: flex-start;
  189. align-items: stretch;
  190. padding-top: 0.4rem;
  191. padding-bottom: 0.4rem;
  192. }
  193. .desc-item {
  194. height: 1.5rem;
  195. }
  196. .bottom-wrapper {
  197. z-index: 1;
  198. background: #fff;
  199. position: fixed;
  200. left: 0;
  201. right: 0;
  202. bottom: 0;
  203. padding:.5rem 0;
  204. display: flex;
  205. flex-direction: row;
  206. justify-content: flex-start;
  207. align-items: stretch;
  208. }
  209. .amount-wrapper {
  210. flex: 1;
  211. background-color: #fff;
  212. margin:0 $pageSpace;
  213. }
  214. .amount {
  215. flex: 1;
  216. font-size:$h2;
  217. color: $primaryColor;
  218. text-align: right;
  219. padding-right: 0.75rem;
  220. }
  221. .submit {
  222. width: 7.5rem;
  223. height: 2.5rem;
  224. border-radius: 0;
  225. }
  226. </style>