group-pay-page.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="flex-common-css iPhone-bottom flex-common-css box-border-box">
  3. <Nav title="订单支付" bgckgroundBox='transparent' :letTap='true' @goBack='goBack'></Nav>
  4. <scroll-view :scroll-y="true" class="box-sizing-border scroll-view-css plr-30 box-border-box">
  5. <view class="fs-28 fc-121212 mb-20 p-t-40 text-align-center">
  6. 剩余时间 {{time.m}}:{{time.s}}
  7. </view>
  8. <view class="align-items-baseline flex-justify-center mb-40">
  9. <view class="fs-40 fw-500 fc-FB3D03">
  10. ¥
  11. </view>
  12. <view class="fs-64 fw-500 fc-FB3D03">
  13. {{Number(payData.pay_money).toFixed(2) || '0.00'}}
  14. </view>
  15. </view>
  16. <view class="mb-40 text-align-center">
  17. 订单编号: {{payData.order_sn}}
  18. </view>
  19. <view class="fs-32 fw-500 fc-3 mb-22">
  20. 支付方式
  21. </view>
  22. <view class="plr-16 box-border-box b-rad-20 bgc-f">
  23. <view class="align-items-center flex-justify-space p-26-0 b-t-F4" @click="setPayType(3)">
  24. <view class="align-items-center">
  25. <image class="icon-img mr-16" src="static/ye.png" mode=""></image>
  26. <view class="fs-28 fc-333">
  27. 余额支付
  28. </view>
  29. <view class="fs-28 fc-707070">
  30. (可用{{Number(payData.member_money).toFixed(2) || '0.00'}})
  31. </view>
  32. </view>
  33. <image v-if="payType === 3" class="w-h-36 mr-10" src="@/static/img/common/y-select.png" mode="">
  34. </image>
  35. <image v-else class="w-h-36 mr-10" src="@/static/img/common/n-select.png" mode=""></image>
  36. </view>
  37. <view class="align-items-center flex-justify-space p-26-0 b-t-F4" @click="setPayType(1)">
  38. <view class="align-items-center">
  39. <image class="icon-img mr-16" src="@/static/img/common/wx-zf.png" mode="scaleToFill"></image>
  40. <view class="fs-28 fc-333">
  41. 微信支付
  42. </view>
  43. </view>
  44. <image v-if="payType === 1" class="w-h-36 mr-10" src="@/static/img/common/y-select.png" mode="">
  45. </image>
  46. <image v-else class="w-h-36 mr-10" src="@/static/img/common/n-select.png" mode=""></image>
  47. </view>
  48. </view>
  49. <view class="fs-32 fw-500 fc-f text-align-center pay-but b-rad-200" @click="paySure"
  50. :class="butType === 1?'bgc-4FB3EF':'bgc-9'">
  51. 立即支付¥{{Number(payData.pay_money).toFixed(2) || '0.00'}}
  52. </view>
  53. </scroll-view>
  54. </view>
  55. </template>
  56. <script>
  57. import {
  58. groupPay,
  59. groupPayInfo
  60. } from '@/api/groupOrder.js';
  61. import tools from "@/service/tools.js"
  62. export default {
  63. data() {
  64. return {
  65. payType: 1,
  66. order_id: 0,
  67. isAJAX: false,
  68. payData: {},
  69. butType: 1,
  70. time: {
  71. day: '',
  72. h: "",
  73. m: '',
  74. s: '',
  75. },
  76. }
  77. },
  78. onLoad(data) {
  79. if (data) {
  80. this.order_id = data.orderId
  81. this.groupPayInfo()
  82. }
  83. },
  84. mounted() {},
  85. methods: {
  86. groupPayInfo() {
  87. groupPayInfo({
  88. order_id: this.order_id
  89. }).then((res) => {
  90. if (res.code === 1) {
  91. this.payData = res.data
  92. let createDate = new Date(res.data.created_at); //格式化订单创建时候的时间
  93. createDate.setMinutes(createDate.getMinutes() + 10)
  94. this.setCountDown(createDate)
  95. }
  96. })
  97. },
  98. setCountDown(sTime) {
  99. let end = new Date(sTime).getTime();
  100. let now = new Date().getTime();
  101. let msec = end - now;
  102. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  103. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  104. let m = parseInt(msec / 1000 / 60 % 60);
  105. let s = parseInt(msec / 1000 % 60);
  106. this.time.h = h > 9 ? h : '0' + h;
  107. this.time.m = m > 9 ? m : '0' + m;
  108. this.time.s = s > 9 ? s : '0' + s;
  109. msec -= 1000;
  110. if (this.time.day >= 1) {
  111. this.showTime = true;
  112. } else {
  113. this.showTime = false;
  114. };
  115. if (msec >= 0) {
  116. setTimeout(() => {
  117. this.setCountDown(sTime);
  118. }, 1000);
  119. } else {
  120. this.isTimeEnd = true;
  121. this.bText = '活动结束';
  122. this.time.h = '--';
  123. this.time.m = '--';
  124. this.time.s = '--';
  125. };
  126. },
  127. setPayType(payType) {
  128. this.payType = payType
  129. if (payType === 3) {
  130. if (Number(this.payData.member_money) < Number(this.payData.pay_money)) {
  131. this.butType = 2
  132. } else {
  133. this.butType = 1
  134. }
  135. } else {
  136. this.butType = 1
  137. }
  138. },
  139. goBack() {
  140. uni.setStorageSync('orderPayType', 3)
  141. setTimeout(() => {
  142. uni.switchTab({
  143. url: "/pages/order/index"
  144. })
  145. }, 1000)
  146. },
  147. paySure() {
  148. if (this.butType === 2) {
  149. return
  150. }
  151. groupPay({
  152. order_id: this.order_id,
  153. pay_type: this.payType
  154. }).then((ret) => {
  155. if (ret.code === 1) {
  156. // if (this.payType === 1) {}else if (this.payType === 3) {}
  157. if (this.payType === 1) {
  158. uni.requestPayment({
  159. provider: "wxpay", //支付类型-固定值
  160. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  161. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  162. package: ret.data.wx_pay.package, // 固定值
  163. signType: ret.data.wx_pay.signType, //固定值
  164. paySign: ret.data.wx_pay.paySign, //签名
  165. success: (ren) => {
  166. this.isAJAX = false;
  167. tools.success("支付成功");
  168. uni.setStorageSync('orderPayType', 3)
  169. setTimeout(() => {
  170. uni.switchTab({
  171. url: "/pages/order/index"
  172. })
  173. }, 1000)
  174. },
  175. fail: (err) => {
  176. this.isAJAX = false;
  177. tools.error("支付失败");
  178. uni.setStorageSync('orderPayType', 3)
  179. setTimeout(() => {
  180. uni.switchTab({
  181. url: "/pages/order/index"
  182. })
  183. }, 1000)
  184. },
  185. });
  186. } else if (this.payType === 3) {
  187. this.isAJAX = false;
  188. tools.success("支付成功");
  189. uni.setStorageSync('orderPayType', 3)
  190. setTimeout(() => {
  191. uni.switchTab({
  192. url: "/pages/order/index"
  193. })
  194. }, 1000)
  195. }
  196. } else {
  197. this.isAJAX = false;
  198. tools.error("支付失败");
  199. uni.setStorageSync('orderPayType', 3)
  200. setTimeout(() => {
  201. uni.switchTab({
  202. url: "/pages/order/index"
  203. })
  204. }, 1000)
  205. }
  206. })
  207. }
  208. },
  209. }
  210. </script>
  211. <style lang="scss" scoped>
  212. .pop-box {
  213. width: 80vw;
  214. height: 30vh;
  215. }
  216. .p-t-40 {
  217. padding: 40rpx 0 0;
  218. }
  219. .p-12-30 {
  220. padding: 12rpx 30rpx;
  221. }
  222. .p-23-16 {
  223. padding: 23rpx 16rpx;
  224. }
  225. .plr-16 {
  226. padding: 0 16rpx;
  227. }
  228. .p-26-0 {
  229. padding: 26rpx 0;
  230. }
  231. .icon-img {
  232. width: 40rpx;
  233. height: 40rpx;
  234. }
  235. .w-h-36 {
  236. width: 36rpx;
  237. height: 36rpx;
  238. }
  239. .pay-but {
  240. width: 100%;
  241. height: 80rpx;
  242. line-height: 80rpx;
  243. margin: 30rpx auto;
  244. }
  245. .pop-but {
  246. width: 80%;
  247. padding: 24rpx 0;
  248. margin: auto;
  249. .add-card {
  250. width: 40rpx;
  251. height: 40rpx;
  252. }
  253. }
  254. </style>