index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view>
  3. <view class="flex-col flex-center py-80">
  4. <baseMoney :money="payPriceShow" symbolSize="48" integerSize="64" decimalSize="48" color="#333" weight></baseMoney>
  5. <view class="flex-y-center mt-20">
  6. <text class="fs-24 text--w111-333 lh-36rpx pr-10">支付剩余时间</text>
  7. <countDown
  8. :is-day="false"
  9. tip-text=" "
  10. day-text=" "
  11. hour-text=":"
  12. minute-text=":"
  13. second-text=" "
  14. bgColor="#FFFFFF"
  15. colors="#FF7E00"
  16. dotColor="#FF7E00"
  17. :datatime="invalidTime"></countDown>
  18. </view>
  19. </view>
  20. <view class="px-20">
  21. <view class="bg--w111-fff rd-24rpx px-24">
  22. <view class="pt-60 flex-center fs-30 lh-42rpx fw-500">
  23. <text>方式一:</text>
  24. <view class="flex-y-center pl-30" @tap="checkType('weixin')">
  25. <text class="iconfont" :class="paytype == 'weixin' ? 'icon-ic_Selected' : 'icon-ic_unselect'"></text>
  26. <text class="pl-10">微信扫码</text>
  27. </view>
  28. <view class="flex-y-center ml-50" @tap="checkType('alipay')">
  29. <text class="iconfont" :class="paytype == 'alipay' ? 'icon-ic_Selected' : 'icon-ic_unselect'"></text>
  30. <text class="pl-10">支付宝扫码</text>
  31. </view>
  32. </view>
  33. <view class="flex-center mt-40 pb-50 border-b" v-show="config.code">
  34. <w-qrcode :options="config"></w-qrcode>
  35. </view>
  36. <view class="pt-50 flex-center fs-30 lh-42rpx fw-500">方式二:用户进入商城支付订单</view>
  37. <view class="py-60 flex-center">
  38. <image class="guide" :src="imgHost + '/statics/images/pay_guide.png'"></image>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="h-200"></view>
  43. <view class="fixed-lb w-full pb-safe">
  44. <view class="w-full h-128 flex-center">
  45. <view class="w-710 h-80 flex-center rd-40rpx fs-28 bg-primary text--w111-fff" @tap="backPage">返回</view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import countDown from '@/components/countDown';
  52. import { getCashierApi, getPayStatusApi } from "@/api/admin.js";
  53. import {HTTP_REQUEST_URL} from '@/config/app';
  54. export default {
  55. data() {
  56. return {
  57. imgHost:HTTP_REQUEST_URL,
  58. payPriceShow:0,
  59. invalidTime:0,
  60. orderId: '',
  61. paytype:'weixin',
  62. userId:0,
  63. qrcode:'',
  64. config: {
  65. code: '',
  66. size: 280, // 二维码大小
  67. level: 3, //等级 0~4
  68. bgColor: '#FFFFFF',
  69. color: ['#333', '#333'], //边框颜色支持渐变色
  70. },
  71. timer: null
  72. }
  73. },
  74. components: {
  75. countDown,
  76. },
  77. onLoad(options) {
  78. this.userId = options.uid || 0;
  79. if (options.order_id) {
  80. this.orderId = options.order_id;
  81. this.getCashierOrder();
  82. }
  83. },
  84. onUnload() {
  85. this.stopSetInterval();
  86. },
  87. methods: {
  88. getCashierOrder(){
  89. let data = {
  90. uni: this.orderId,
  91. paytype: this.paytype,
  92. quitUrl: '/pages/behalf/cashier/index'
  93. };
  94. getCashierApi(this.userId,data).then(res=>{
  95. if(res.data.status == 'SUCCESS'){
  96. return this.$util.Tips({
  97. title: '支付成功'
  98. }, {
  99. tab: 5,
  100. url: '/pages/behalf/record/index'
  101. });
  102. }
  103. this.payPriceShow = res.data.result.pay_price;
  104. this.invalidTime = res.data.result.jsConfig.invalid;
  105. this.config.code = this.paytype == 'weixin' ? res.data.result.jsConfig.code_url : res.data.result.jsConfig.qrCode;
  106. this.createSetInterval(res.data.result.order_id);
  107. }).catch(err=>{
  108. return this.$util.Tips({
  109. title: err
  110. })
  111. })
  112. },
  113. checkType(val){
  114. this.paytype = val;
  115. this.getCashierOrder();
  116. },
  117. createSetInterval(order_id) {
  118. this.stopSetInterval();
  119. this.timer = setInterval(() => {
  120. this.getOrderResult(order_id);
  121. }, 2000);
  122. },
  123. stopSetInterval() {
  124. if (this.timer) {
  125. clearInterval(this.timer);
  126. this.timer = null;
  127. }
  128. },
  129. getOrderResult(id){
  130. //接口响应成功以后销毁定时器
  131. getPayStatusApi({
  132. order_id:id,
  133. end_time:this.invalidTime
  134. }).then(res=>{
  135. if(res.data.time == 0){
  136. this.stopSetInterval();
  137. this.getCashierOrder();
  138. }
  139. if(res.data.status || res.data.time == 0){
  140. this.stopSetInterval();
  141. uni.reLaunch({
  142. url:'/pages/behalf/record/index'
  143. })
  144. }
  145. }).catch(err=>{
  146. return this.$util.Tips({
  147. title: err
  148. })
  149. })
  150. },
  151. backPage(){
  152. uni.reLaunch({
  153. url:'/pages/admin/work/index'
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang="scss">
  160. /deep/ .styleAll{
  161. padding: 0 6rpx;
  162. border: 1rpx solid #DDDDDD;
  163. border-radius: 8rpx;
  164. font-family: Regular;
  165. line-height: 40rpx;
  166. }
  167. .border-b{
  168. border-bottom: 1px dashed #ccc;
  169. }
  170. .icon-ic_Selected{
  171. color: $primary-admin;
  172. }
  173. .bg-primary{
  174. background-color: $primary-admin;
  175. }
  176. .guide{
  177. width: 570rpx;
  178. height: 214rpx;
  179. }
  180. </style>