index1.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. if (!resp.success) {
  155. this.$u.toast(resp.msg)
  156. return
  157. }
  158. let obj = {
  159. orderType: this.$global.orderType.USER_PAY,
  160. orderId: resp.data.id,
  161. payStatus: this.$global.payStatus.IS_WAIT
  162. }
  163. let res = await this.$api.pay.payOrder(obj)
  164. let prePayTn = JSON.parse(res.data.prePayTn)
  165. await this.$mpi.requestPayment(prePayTn)
  166. uni.navigateTo({
  167. url: "/pages/checkstand/order-res?orderId=" + resp.data.id
  168. })
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss" scoped>
  174. .check-panel {
  175. .buyer-logo {
  176. width: 130rpx;
  177. height: 130rpx;
  178. margin-top: 50rpx;
  179. margin-left: calc(50% - 65rpx);
  180. border-radius: 50%;
  181. }
  182. .title {
  183. font-weight: 800;
  184. height: 70rpx;
  185. letter-spacing: 3rpx;
  186. color: #5D5D5D;
  187. }
  188. .input-content {
  189. margin-top: 50rpx;
  190. padding: 50rpx;
  191. background-color: #FFFFFF;
  192. width: 100%;
  193. border-radius: 25rpx 25rpx 0 0;
  194. .tips {
  195. height: 100rpx;
  196. font-size: 30rpx;
  197. display: flex;
  198. justify-content: left;
  199. align-items: center;
  200. }
  201. .input-bar {
  202. height: 150rpx;
  203. border-bottom: 1rpx solid #DDDDDD;
  204. .icon {
  205. width: 15%;
  206. font-size: 70rpx;
  207. font-weight: 900;
  208. height: 100%;
  209. }
  210. .input {
  211. width: 85%;
  212. height: 100%;
  213. overflow: hidden;
  214. font-size: 70rpx;
  215. }
  216. .cusor {
  217. width: 2rpx;
  218. height: 80%;
  219. background-color: #FD711B;
  220. animation: blink 1500ms infinite ease-in-out;
  221. }
  222. }
  223. }
  224. }
  225. .bottom-line {
  226. position: absolute;
  227. bottom: 50rpx;
  228. left: 0;
  229. width: 100%;
  230. color: #dddddd;
  231. }
  232. @keyframes blink {
  233. from {
  234. opacity: 0;
  235. }
  236. }
  237. </style>