paymentPage.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view class="payment_bg">
  3. <view class="payment_info">
  4. <image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/pay_scale_info.png"
  5. mode="widthFix">
  6. </image>
  7. <image class="pay_btn_sm" @click="createOrder"
  8. src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/pay_button.png"
  9. mode="widthFix"></image>
  10. </view>
  11. <view class="payment_desc">
  12. <image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/pay_scale_desc.png"
  13. mode="widthFix"></image>
  14. </view>
  15. <view class="pay_btn_lg" @click="createOrder">
  16. <image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/pay_button.png"
  17. mode="widthFix"></image>
  18. </view>
  19. <uni-popup ref="popup" type="center">
  20. <view class="pay_dialog">
  21. <view class="btn_area">
  22. <image style="margin-right: 89rpx;" @click="completeHandle"
  23. src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/complete_btn.png"
  24. mode="widthFix"></image>
  25. <image @click="uncompleteHandle"
  26. src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/uncomplete_btn.png"
  27. mode="widthFix"></image>
  28. </view>
  29. </view>
  30. </uni-popup>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. orderNo: '',
  38. orderInfo: {}
  39. }
  40. },
  41. onLoad(options) {},
  42. methods: {
  43. // 检查订单支付状态
  44. checkOrder() {
  45. let _this = this;
  46. _this.$request
  47. .get({
  48. url: `api/wx-pay/queryOrder/${_this.orderNo}`,
  49. loadingTip: "加载中...",
  50. data: {},
  51. })
  52. .then((res) => {
  53. uni.hideLoading();
  54. let resultInfo = JSON.parse(res.data.body)
  55. if (resultInfo.trade_state === 'SUCCESS') {
  56. uni.navigateTo({
  57. url: `/newScale/EQtest/paySuccess?resultId=${this.orderInfo.resultId}&userId=${this.orderInfo.userId}`
  58. });
  59. } else {
  60. return;
  61. }
  62. });
  63. },
  64. createOrder() {
  65. let _this = this;
  66. _this.orderInfo = uni.getStorageSync('orderInfo');
  67. let params = {
  68. resultId: _this.orderInfo.resultId,
  69. subject: _this.orderInfo.description,
  70. body: _this.orderInfo.description,
  71. total_amount: _this.orderInfo.total * 100,
  72. msgPage: "",
  73. }
  74. _this.$request
  75. .post({
  76. url: "api/douyin/createOrder",
  77. loadingTip: "加载中...",
  78. data: params
  79. })
  80. .then((res) => {
  81. _this.orderNo = res.data.orderNo;
  82. let imageUrl = 'https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/banner1.png';
  83. // _this.syncOrder({
  84. // resultId: params.resultId,
  85. // total_amount: params * 100,
  86. // subject: params.subject,
  87. // path: `/newScale/EQtest/testResult?resultId=${_this.orderInfo.resultId}&messageShare=1`,
  88. // orderNo: _this.orderNo,
  89. // openId: uni.getStorageSync("setUerInfo").openId,
  90. // orderStatus: "1",
  91. // imgPath: imageUrl,
  92. // });
  93. _this.payToutiao(
  94. res.data.orderId,
  95. res.data.orderToken,
  96. res.data.orderNo
  97. );
  98. });
  99. },
  100. payToutiao(orderId, orderToken, orderNo) {
  101. let _this = this;
  102. tt.pay({
  103. orderInfo: {
  104. order_id: orderId,
  105. order_token: orderToken,
  106. },
  107. service: 5,
  108. success: (response) => {
  109. _this.timer = setInterval(() => {
  110. _this.getQueryOrder(orderNo);
  111. }, 1000);
  112. },
  113. fail: (err) => {
  114. uni.showToast({
  115. icon: "none",
  116. name: "支付失败",
  117. });
  118. },
  119. });
  120. },
  121. // 订单状态
  122. getQueryOrder(orderNo) {
  123. let _this = this;
  124. _this.$request
  125. .get({
  126. url: `api/douyin/queryOrder/${orderNo}`,
  127. loadingTip: "加载中...",
  128. data: {},
  129. })
  130. .then((res) => {
  131. if (res.code == "200") {
  132. if (res.data.statusCode == "SUCCESS") {
  133. let imageUrl =
  134. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/banner1.png';
  135. // _this.syncOrder({
  136. // resultId: _this.orderInfo.resultId,
  137. // total_amount: _this.orderInfo.total * 100,
  138. // subject: _this.orderInfo.description.subject,
  139. // path: `/newScale/EQtest/testResult?resultId=${_this.orderInfo.resultId}&messageShare=1`,
  140. // orderNo: _this.orderNo,
  141. // openId: uni.getStorageSync("setUerInfo").openId,
  142. // orderStatus: "2",
  143. // imgPath: imageUrl,
  144. // });
  145. uni.navigateTo({
  146. url: `/newScale/EQtest/testResult?resultId=${_this.orderInfo.resultId}&messageShare=1`
  147. });
  148. clearInterval(_this.timer);
  149. uni.showToast({
  150. title: "支付成功",
  151. });
  152. } else if (res.data.statusCode == "CLOSED") {
  153. // console.log("订单支付回调成功===========CLOSED》", _this.trade_state_closed );
  154. } else {
  155. clearInterval(_this.timer);
  156. // console.log("订单支付回调成功CLOSED===========》", _this.trade_state_closed);
  157. }
  158. } else {
  159. uni.showToast({
  160. title: "支付失败",
  161. });
  162. }
  163. });
  164. },
  165. // 同步订单
  166. syncOrder(params) {
  167. this.$request
  168. .post({
  169. url: "api/douyin/pushOrder",
  170. loadingTip: "加载中...",
  171. data: params,
  172. })
  173. .then((res) => {
  174. console.log(res);
  175. })
  176. .catch((err) => {
  177. console.log(err);
  178. });
  179. }
  180. }
  181. }
  182. </script>
  183. <style scoped>
  184. .payment_bg {
  185. width: 100%;
  186. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/payment_bg.png) no-repeat top;
  187. background-size: 100% auto;
  188. overflow: hidden;
  189. }
  190. .payment_info {
  191. position: relative;
  192. }
  193. .payment_info image {
  194. width: 100%;
  195. height: auto;
  196. margin-top: 134rpx;
  197. }
  198. .payment_info .pay_btn_sm {
  199. width: 640rpx;
  200. height: auto;
  201. position: absolute;
  202. left: 55rpx;
  203. bottom: 73rpx;
  204. }
  205. .payment_desc image {
  206. width: 750rpx;
  207. }
  208. .pay_btn_lg {
  209. width: 640rpx;
  210. margin: 40rpx auto;
  211. }
  212. .pay_btn_lg image {
  213. width: 640rpx;
  214. height: auto;
  215. }
  216. .pay_dialog {
  217. width: 594rpx;
  218. height: 360rpx;
  219. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/dialog_bg.png) no-repeat top;
  220. background-size: cover;
  221. position: fixed;
  222. top: 540rpx;
  223. left: 50%;
  224. transform: translate(-50%, -50%);
  225. }
  226. .btn_area {
  227. margin: 240rpx 0 0 96rpx;
  228. }
  229. .btn_area image {
  230. width: 160rpx;
  231. }
  232. .btn_area image:active {
  233. border: 1rpx solid #999999;
  234. opacity: 0.8;
  235. border-radius: 28rpx;
  236. }
  237. </style>