paymentPage.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view class="payment_bg">
  3. <view class="payment_info">
  4. <view class="people_num"><text>{{peopleNum}}人已测</text></view>
  5. <view class="price_num"><text>¥{{orderInfo.total}}</text></view>
  6. <view class="pay_btn_sm" @click="payHandle">{{orderInfo.total}}元解锁专属测试报告</view>
  7. </view>
  8. <view class="payment_desc">
  9. <image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Family/pay_scale_desc.png"
  10. mode="widthFix"></image>
  11. </view>
  12. <view class="pay_btn_lg" @click="payHandle">
  13. {{orderInfo.total}}元解锁专属测试报告
  14. </view>
  15. <uni-popup ref="popup" type="center">
  16. <view class="pay_dialog">
  17. <view class="btn_area">
  18. <image style="margin-right: 89rpx;" @click="completeHandle"
  19. src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/complete_btn.png"
  20. mode="widthFix"></image>
  21. <image @click="uncompleteHandle"
  22. src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/uncomplete_btn.png"
  23. mode="widthFix"></image>
  24. </view>
  25. </view>
  26. </uni-popup>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. orderNo: '',
  34. orderInfo: {},
  35. peopleNum: 0
  36. }
  37. },
  38. onLoad(options) {
  39. if (options.orderNo) {
  40. this.orderNo = options.orderNo;
  41. setTimeout(() => {
  42. this.payEnsure();
  43. }, 200)
  44. }
  45. this.orderInfo = uni.getStorageSync('orderInfo');
  46. this.getPeople();
  47. },
  48. methods: {
  49. payHandle() {
  50. // #ifdef H5
  51. this.getH5Pay();
  52. // #endif
  53. // #ifdef MP-TOUTIAO
  54. this.createOrder();
  55. // #endif
  56. },
  57. // 检查订单支付状态
  58. checkOrder() {
  59. let _this = this;
  60. _this.$request
  61. .get({
  62. url: `api/wx-pay/queryOrder/${_this.orderNo}`,
  63. loadingTip: "加载中...",
  64. data: {},
  65. })
  66. .then((res) => {
  67. uni.hideLoading();
  68. let resultInfo = JSON.parse(res.data.body)
  69. if (resultInfo.trade_state === 'SUCCESS') {
  70. uni.navigateTo({
  71. url: `/newScale/Family/testResult?resultId=${this.orderInfo.resultId}&messageShare=1`
  72. });
  73. } else {
  74. return;
  75. }
  76. });
  77. },
  78. // 拉起微信支付
  79. getH5Pay(params) {
  80. let _this = this;
  81. _this.$request
  82. .get({
  83. url: `api/orderInfo/queryOrderByResultIdAndUserId/${this.orderInfo.userId}/${this.orderInfo.resultId}`,
  84. loadingTip: "加载中...",
  85. data: {},
  86. })
  87. .then((res) => {
  88. uni.hideLoading();
  89. if (res.data && res.data.orderStatus === '支付成功') {
  90. uni.navigateTo({
  91. url: `/newScale/Family/testResult?resultId=${this.orderInfo.resultId}&messageShare=1`
  92. });
  93. } else {
  94. // _this.orderInfo.total = _this.hasDiscount ? _this.promotionPrice : _this.price;
  95. _this.$request
  96. .post({
  97. url: "api/wx-pay/h5Pay",
  98. loadingTip: "加载中...",
  99. data: _this.orderInfo
  100. })
  101. .then((res) => {
  102. let redirect_url = encodeURI(
  103. `http://hnhong-duo.com/webo/newScale/Family/paymentPage?orderNo=${res.data.orderNo}`
  104. )
  105. window.location.href = `${res.data.codeUrl}&redirect_url=${redirect_url}`;
  106. });
  107. }
  108. });
  109. },
  110. createOrder() {
  111. let _this = this;
  112. let params = {
  113. resultId: _this.orderInfo.resultId,
  114. subject: _this.orderInfo.description,
  115. body: _this.orderInfo.description,
  116. total_amount: _this.orderInfo.total * 100,
  117. msgPage: "",
  118. }
  119. _this.$request
  120. .post({
  121. url: "api/douyin/createOrder",
  122. loadingTip: "加载中...",
  123. data: params
  124. })
  125. .then((res) => {
  126. _this.orderNo = res.data.orderNo;
  127. let imageUrl = 'https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/banner1.png';
  128. _this.payToutiao(
  129. res.data.orderId,
  130. res.data.orderToken,
  131. res.data.orderNo
  132. );
  133. });
  134. },
  135. payToutiao(orderId, orderToken, orderNo) {
  136. let _this = this;
  137. tt.pay({
  138. orderInfo: {
  139. order_id: orderId,
  140. order_token: orderToken,
  141. },
  142. service: 5,
  143. success: (response) => {
  144. _this.timer = setInterval(() => {
  145. _this.getQueryOrder(orderNo);
  146. }, 1000);
  147. },
  148. fail: (err) => {
  149. uni.showToast({
  150. icon: "none",
  151. name: "支付失败",
  152. });
  153. },
  154. });
  155. },
  156. // 订单状态
  157. getQueryOrder(orderNo) {
  158. let _this = this;
  159. _this.$request
  160. .get({
  161. url: `api/douyin/queryOrder/${orderNo}`,
  162. loadingTip: "加载中...",
  163. data: {},
  164. })
  165. .then((res) => {
  166. if (res.code == "200") {
  167. if (res.data.statusCode == "SUCCESS") {
  168. let imageUrl =
  169. 'https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/banner1.png';
  170. uni.navigateTo({
  171. url: `/newScale/Family/testResult?resultId=${_this.orderInfo.resultId}&messageShare=1`
  172. });
  173. clearInterval(_this.timer);
  174. uni.showToast({
  175. title: "支付成功",
  176. });
  177. } else if (res.data.statusCode == "CLOSED") {
  178. // console.log("订单支付回调成功===========CLOSED》", _this.trade_state_closed );
  179. } else {
  180. clearInterval(_this.timer);
  181. // console.log("订单支付回调成功CLOSED===========》", _this.trade_state_closed);
  182. }
  183. } else {
  184. uni.showToast({
  185. title: "支付失败",
  186. });
  187. }
  188. });
  189. },
  190. // 查询测试人数
  191. getPeople() {
  192. let _this = this;
  193. _this.$request
  194. .get({
  195. url: "record/countByFlag?flag=20210622214416",
  196. loadingTip: "加载中..."
  197. })
  198. .then((res) => {
  199. _this.peopleNum = res.data + 57000
  200. });
  201. },
  202. payEnsure() {
  203. // console.log(11111)
  204. this.$refs.popup.open();
  205. },
  206. uncompleteHandle() {
  207. this.$refs.popup.close();
  208. },
  209. completeHandle() {
  210. uni.showLoading({
  211. title: ''
  212. });
  213. this.checkOrder();
  214. }
  215. }
  216. }
  217. </script>
  218. <style scoped>
  219. .payment_bg {
  220. width: 100%;
  221. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/payment_bg.png) no-repeat top;
  222. background-size: 100% auto;
  223. overflow: hidden;
  224. }
  225. .payment_info {
  226. width: 750rpx;
  227. height: 531rpx;
  228. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Family/pay_scale_info.png) no-repeat center;
  229. background-size: cover;
  230. position: relative;
  231. margin-top: 143rpx;
  232. overflow: hidden;
  233. }
  234. .payment_info image {
  235. width: 100%;
  236. height: auto;
  237. margin-top: 134rpx;
  238. }
  239. .payment_info .pay_btn_sm {
  240. width: 640rpx;
  241. height: 73rpx;
  242. line-height: 73rpx;
  243. position: absolute;
  244. left: 55rpx;
  245. bottom: 73rpx;
  246. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/pay_button.png) no-repeat center;
  247. background-size: 100% auto;
  248. font-family: 'Alibaba PuHuiTi 2.0';
  249. font-weight: bold;
  250. font-size: 36rpx;
  251. color: #FFFFFF;
  252. text-shadow: 0rpx 0rpx 5rpx rgba(168, 63, 90, 0.5);
  253. text-align: center;
  254. }
  255. .payment_desc image {
  256. width: 750rpx;
  257. }
  258. .pay_btn_lg {
  259. width: 640rpx;
  260. height: 73rpx;
  261. line-height: 73rpx;
  262. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/pay_button.png) no-repeat center;
  263. background-size: 100% auto;
  264. font-family: 'Alibaba PuHuiTi 2.0';
  265. font-weight: bold;
  266. font-size: 36rpx;
  267. color: #FFFFFF;
  268. text-shadow: 0rpx 0rpx 5rpx rgba(168, 63, 90, 0.5);
  269. text-align: center;
  270. margin: 20rpx auto 60rpx;
  271. }
  272. .pay_dialog {
  273. width: 594rpx;
  274. height: 360rpx;
  275. background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/dialog_bg.png) no-repeat top;
  276. background-size: cover;
  277. position: fixed;
  278. top: 540rpx;
  279. left: 50%;
  280. transform: translate(-50%, -50%);
  281. }
  282. .btn_area {
  283. margin: 240rpx 0 0 96rpx;
  284. }
  285. .btn_area image {
  286. width: 160rpx;
  287. }
  288. .btn_area image:active {
  289. border: 1rpx solid #999999;
  290. opacity: 0.8;
  291. border-radius: 28rpx;
  292. }
  293. .people_num {
  294. margin-top: 177rpx;
  295. }
  296. .people_num text {
  297. min-width: 157rpx;
  298. height: 44rpx;
  299. padding: 0 10rpx;
  300. background: #FFEDF1;
  301. border-radius: 22rpx;
  302. font-family: 'Alibaba PuHuiTi 2.0';
  303. font-size: 28rpx;
  304. color: #FC716D;
  305. line-height: 44rpx;
  306. text-align: center;
  307. margin-left: 373rpx;
  308. }
  309. .price_num {
  310. margin-top: 72rpx;
  311. }
  312. .price_num text {
  313. min-width: 74rpx;
  314. font-family: 'Alibaba PuHuiTi 2.0';
  315. font-weight: normal;
  316. font-size: 32rpx;
  317. color: #FC716D;
  318. line-height: 24rpx;
  319. margin-left: 374rpx;
  320. }
  321. </style>