paymentPage.vue 8.0 KB

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