pick-up-pay.vue 7.0 KB

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