index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view class="">
  3. <!-- #ifdef MP-WEIXIN-->
  4. <view class="">
  5. <u-navbar title="收银台"></u-navbar>
  6. </view>
  7. <!-- #endif -->
  8. <view class="check-panel flex-direction">
  9. <image :src="shopDetail.cover" class="buyer-logo"></image>
  10. <view class="title center">{{shopDetail.name}}</view>
  11. <view class="input-content">
  12. <view class="tips">交易金额</view>
  13. <view class="input-bar center" @tap="show=true">
  14. <view class="icon center">¥</view>
  15. <view class="input center">
  16. <view :style="!$isEmpty(orderAmount)?'margin-left: -15%;':''">{{orderAmount}}</view>
  17. <view class="cusor" :style="$isEmpty(orderAmount)?'margin-left: -15%;':''"></view>
  18. </view>
  19. </view>
  20. <view style="height: 50rpx;"></view>
  21. <view class="" style="z-index: 99;">
  22. <u-button throttle-time="1200" class="button" type="warning" @click="pay">付款</u-button>
  23. </view>
  24. </view>
  25. <view class="bottom-line center"> -- 联兑通提供技术支持 --</view>
  26. <u-keyboard z-index="9" ref="uKeyboard" :show-tips="false" :safe-area-inset-bottom="true" :mask="false"
  27. v-model="show" @change="handleInput" @confirm="pay" @backspace="handleDelete"></u-keyboard>
  28. </view>
  29. <u-modal v-model="payModalShow" :showCancelButton="true" confirm-color="#FF9447">
  30. <view class="center flex-direction text-df" style="padding: 30rpx 40rpx;">
  31. <view>您的积分可足额抵扣支付</view>
  32. <view class="padding-top-10">本次支付不会扣除您的现金</view>
  33. </view>
  34. </u-modal>
  35. <u-modal v-model="modalShow" :showCancelButton="true" @cancel="payOfh5" @confirm="jumpLDT" cancel-text="直接付款" confirm-color="#FF9447"
  36. confirmText="去联兑通支付" content="去联兑通小程序付款会有更多优惠哟~"></u-modal>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. onLoad(option) {},
  42. data() {
  43. return {
  44. payModalShow:false,
  45. modalShow: false,
  46. show: false,
  47. logo: "/static/bank/CMBCHINA.png",
  48. buyer: "联兑通",
  49. orderAmount: '',
  50. shopId: '',
  51. shopDetail: {}
  52. }
  53. },
  54. onLoad(options) {
  55. this.shopId = options.id
  56. if (this.$isEmpty(this.shopId)) {
  57. this.$dialog.showModal('商户id不能为空', false).then(() => {
  58. uni.navigateBack()
  59. })
  60. return
  61. }
  62. this.fetchShopDetail()
  63. },
  64. methods: {
  65. fetchShopDetail() {
  66. this.$api.shop.detail({
  67. id: this.shopId
  68. }).then(res => {
  69. if (this.$isEmpty(res.data)) {
  70. this.$dialog.showModal('获取不到商户信息', false).then(() => {
  71. this.show = false
  72. uni.navigateBack({
  73. delta: 1
  74. })
  75. })
  76. } else {
  77. this.show = true
  78. this.shopDetail = res.data
  79. }
  80. }).catch(err => {
  81. this.$dialog.showModal('获取不到商户信息', false).then(() => {
  82. uni.navigateBack({
  83. delta: 1
  84. })
  85. })
  86. })
  87. },
  88. handleInput(num) {
  89. if (this.orderAmount.length > 12) {
  90. return
  91. }
  92. this.orderAmount = this.orderAmount + num
  93. },
  94. handleDelete() {
  95. if (this.$isEmpty(this.orderAmount)) {
  96. return
  97. }
  98. this.orderAmount = this.orderAmount.substr(0, this.orderAmount.length - 1)
  99. },
  100. jumpLDT() {
  101. location.href = "weixin://dl/business/?t=X2CyIQDbgtm"
  102. },
  103. async payOfh5() {
  104. let expireTime=this.$dateTime.getExpireTime(5)
  105. let params={
  106. money:this.orderAmount,
  107. shopId:this.shopId,
  108. billsTitle:'用户微信扫码支付',
  109. expireTime
  110. }
  111. let resp=await this.$api.loginUser.payBeforeForNormal(params)
  112. let payObj={
  113. orderType:this.$global.orderType.USER_PAY,
  114. orderId:resp.data.id
  115. }
  116. let res=await this.$api.pay.payOrderOfscanCode(payObj)
  117. if (!this.$isEmpty(res.data.qrCodeUrl)) {
  118. location.href=res.data.qrCodeUrl
  119. }
  120. this.$u.toast('支付失败')
  121. },
  122. async pay() {
  123. if (this.$isEmpty(this.orderAmount)) {
  124. this.$u.toast('请输入交易金额')
  125. return
  126. }
  127. // #ifdef H5
  128. this.modalShow = true
  129. // #endif
  130. // #ifdef MP-WEIXIN
  131. let flag=false
  132. if (flag) {
  133. //可以足额支付
  134. this.payModalShow=true
  135. }else{
  136. //积分不足额支付,调易宝支付
  137. this.toWXPay()
  138. }
  139. // #endif
  140. },
  141. async toWXPay(){
  142. let expireTime = this.$dateTime.getExpireTime(5)
  143. let params = {
  144. shopId: this.shopId,
  145. loginUserId: this.vuex_userId,
  146. money: this.orderAmount,
  147. billsTitle: '用户支付',
  148. expireTime,
  149. appId: this.$global.wxParams.APPID,
  150. openId: this.$cache.get('userInfo').openId,
  151. type: 1 //type: 1-用户扫商户收款码支付 2-商户扫用户付款码支付
  152. }
  153. let resp = await this.$api.loginUser.payBefore(params)
  154. let obj = {
  155. orderType: this.$global.orderType.USER_PAY,
  156. orderId: resp.data.id,
  157. payStatus: this.$global.payStatus.IS_WAIT
  158. }
  159. let res = await this.$api.pay.payOrder(obj)
  160. let prePayTn = JSON.parse(res.data.prePayTn)
  161. await this.$mpi.requestPayment(prePayTn)
  162. uni.navigateTo({
  163. url: "/pages/checkstand/order-res?orderId=" + resp.data.id
  164. })
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .check-panel {
  171. .buyer-logo {
  172. width: 130rpx;
  173. height: 130rpx;
  174. margin-top: 50rpx;
  175. margin-left: calc(50% - 65rpx);
  176. border-radius: 50%;
  177. }
  178. .title {
  179. font-weight: 800;
  180. height: 70rpx;
  181. letter-spacing: 3rpx;
  182. color: #5D5D5D;
  183. }
  184. .input-content {
  185. margin-top: 50rpx;
  186. padding: 50rpx;
  187. background-color: #FFFFFF;
  188. width: 100%;
  189. border-radius: 25rpx 25rpx 0 0;
  190. .tips {
  191. height: 100rpx;
  192. font-size: 30rpx;
  193. display: flex;
  194. justify-content: left;
  195. align-items: center;
  196. }
  197. .input-bar {
  198. height: 150rpx;
  199. border-bottom: 1rpx solid #DDDDDD;
  200. .icon {
  201. width: 15%;
  202. font-size: 70rpx;
  203. font-weight: 900;
  204. height: 100%;
  205. }
  206. .input {
  207. width: 85%;
  208. height: 100%;
  209. overflow: hidden;
  210. font-size: 70rpx;
  211. }
  212. .cusor {
  213. width: 2rpx;
  214. height: 80%;
  215. background-color: #FD711B;
  216. animation: blink 1500ms infinite ease-in-out;
  217. }
  218. }
  219. }
  220. }
  221. .bottom-line {
  222. position: absolute;
  223. bottom: 50rpx;
  224. left: 0;
  225. width: 100%;
  226. color: #dddddd;
  227. }
  228. @keyframes blink {
  229. from {
  230. opacity: 0;
  231. }
  232. }
  233. </style>