group-pay-page.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. onHide() {},
  85. onUnload() {
  86. this.goBack()
  87. // console.log('onUnload-----------------');
  88. },
  89. mounted() {},
  90. methods: {
  91. groupPayInfo() {
  92. groupPayInfo({
  93. order_id: this.order_id
  94. }).then((res) => {
  95. if (res.code === 1) {
  96. this.payData = res.data
  97. let createDate = new Date(res.data.created_at); //格式化订单创建时候的时间
  98. createDate.setMinutes(createDate.getMinutes() + 10)
  99. this.setCountDown(createDate)
  100. }
  101. })
  102. },
  103. setCountDown(sTime) {
  104. let end = new Date(sTime).getTime();
  105. let now = new Date().getTime();
  106. let msec = end - now;
  107. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  108. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  109. let m = parseInt(msec / 1000 / 60 % 60);
  110. let s = parseInt(msec / 1000 % 60);
  111. this.time.h = h > 9 ? h : '0' + h;
  112. this.time.m = m > 9 ? m : '0' + m;
  113. this.time.s = s > 9 ? s : '0' + s;
  114. msec -= 1000;
  115. if (this.time.day >= 1) {
  116. this.showTime = true;
  117. } else {
  118. this.showTime = false;
  119. };
  120. if (msec >= 0) {
  121. setTimeout(() => {
  122. this.setCountDown(sTime);
  123. }, 1000);
  124. } else {
  125. this.isTimeEnd = true;
  126. this.bText = '活动结束';
  127. this.time.h = '--';
  128. this.time.m = '--';
  129. this.time.s = '--';
  130. };
  131. },
  132. setPayType(payType) {
  133. this.payType = payType
  134. if (payType === 3) {
  135. if (Number(this.payData.member_money) < Number(this.payData.pay_money)) {
  136. this.butType = 2
  137. } else {
  138. this.butType = 1
  139. }
  140. } else {
  141. this.butType = 1
  142. }
  143. },
  144. goBack() {
  145. uni.setStorageSync('orderPayType', 3)
  146. setTimeout(() => {
  147. uni.switchTab({
  148. url: "/pages/order/index"
  149. })
  150. }, 1000)
  151. },
  152. paySure() {
  153. if (this.butType === 2) {
  154. return
  155. }
  156. groupPay({
  157. order_id: this.order_id,
  158. pay_type: this.payType
  159. }).then((ret) => {
  160. if (ret.code === 1) {
  161. // if (this.payType === 1) {}else if (this.payType === 3) {}
  162. if (this.payType === 1) {
  163. uni.requestPayment({
  164. provider: "wxpay", //支付类型-固定值
  165. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  166. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  167. package: ret.data.wx_pay.package, // 固定值
  168. signType: ret.data.wx_pay.signType, //固定值
  169. paySign: ret.data.wx_pay.paySign, //签名
  170. success: (ren) => {
  171. this.isAJAX = false;
  172. tools.success("支付成功");
  173. uni.setStorageSync('orderPayType', 3)
  174. setTimeout(() => {
  175. uni.switchTab({
  176. url: "/pages/order/index"
  177. })
  178. }, 1000)
  179. },
  180. fail: (err) => {
  181. this.isAJAX = false;
  182. tools.error("支付失败");
  183. uni.setStorageSync('orderPayType', 3)
  184. setTimeout(() => {
  185. uni.switchTab({
  186. url: "/pages/order/index"
  187. })
  188. }, 1000)
  189. },
  190. });
  191. } else if (this.payType === 3) {
  192. this.isAJAX = false;
  193. tools.success("支付成功");
  194. uni.setStorageSync('orderPayType', 3)
  195. setTimeout(() => {
  196. uni.switchTab({
  197. url: "/pages/order/index"
  198. })
  199. }, 1000)
  200. }
  201. } else {
  202. this.isAJAX = false;
  203. tools.error("支付失败");
  204. uni.setStorageSync('orderPayType', 3)
  205. setTimeout(() => {
  206. uni.switchTab({
  207. url: "/pages/order/index"
  208. })
  209. }, 1000)
  210. }
  211. })
  212. }
  213. },
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. .pop-box {
  218. width: 80vw;
  219. height: 30vh;
  220. }
  221. .p-t-40 {
  222. padding: 40rpx 0 0;
  223. }
  224. .p-12-30 {
  225. padding: 12rpx 30rpx;
  226. }
  227. .p-23-16 {
  228. padding: 23rpx 16rpx;
  229. }
  230. .plr-16 {
  231. padding: 0 16rpx;
  232. }
  233. .p-26-0 {
  234. padding: 26rpx 0;
  235. }
  236. .icon-img {
  237. width: 40rpx;
  238. height: 40rpx;
  239. }
  240. .w-h-36 {
  241. width: 36rpx;
  242. height: 36rpx;
  243. }
  244. .pay-but {
  245. width: 100%;
  246. height: 80rpx;
  247. line-height: 80rpx;
  248. margin: 30rpx auto;
  249. }
  250. .pop-but {
  251. width: 80%;
  252. padding: 24rpx 0;
  253. margin: auto;
  254. .add-card {
  255. width: 40rpx;
  256. height: 40rpx;
  257. }
  258. }
  259. </style>