123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- <template>
- <view class="payment_bg">
- <view class="payment_info">
- <view class="people_num"><text>{{peopleNum}}人已测</text></view>
- <view class="price_num"><text>¥{{orderInfo.total}}</text></view>
- <view class="pay_btn_sm" @click="payHandle">{{orderInfo.total}}元解锁专属测试报告</view>
- </view>
- <view class="payment_desc">
- <image src="https://test.jue-ming.com:8849/api/show?filePath=./webo/Senile/paymentPage/pay_scale_desc.png"
- mode="widthFix"></image>
- </view>
- <view class="pay_btn_lg" @click="payHandle">
- {{orderInfo.total}}元解锁专属测试报告
- </view>
- <uni-popup ref="popup" type="center">
- <view class="pay_dialog">
- <view class="btn_area">
- <image style="margin-right: 89rpx;" @click="completeHandle"
- src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/complete_btn.png"
- mode="widthFix"></image>
- <image @click="uncompleteHandle"
- src="https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/uncomplete_btn.png"
- mode="widthFix"></image>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- orderNo: '',
- orderInfo: {},
- peopleNum: 0
- }
- },
- onLoad(options) {
- if (options.orderNo) {
- this.orderNo = options.orderNo;
- setTimeout(() => {
- this.payEnsure();
- }, 200)
- }
- this.orderInfo = uni.getStorageSync('orderInfo');
- this.getPeople();
- },
- methods: {
- payHandle() {
- // #ifdef H5
- this.getH5Pay();
- // #endif
- // #ifdef MP-TOUTIAO
- this.createOrder();
- // #endif
- },
- // 检查订单支付状态
- checkOrder() {
- let _this = this;
- _this.$request
- .get({
- url: `api/wx-pay/queryOrder/${_this.orderNo}`,
- loadingTip: "加载中...",
- data: {},
- })
- .then((res) => {
- uni.hideLoading();
- let resultInfo = JSON.parse(res.data.body)
- if (resultInfo.trade_state === 'SUCCESS') {
- uni.navigateTo({
- url: `/newScale/Senile/testResult?resultId=${this.orderInfo.resultId}&messageShare=1`
- });
- } else {
- return;
- }
- });
- },
- // 拉起微信支付
- getH5Pay(params) {
- let _this = this;
- _this.$request
- .get({
- url: `api/orderInfo/queryOrderByResultIdAndUserId/${this.orderInfo.userId}/${this.orderInfo.resultId}`,
- loadingTip: "加载中...",
- data: {},
- })
- .then((res) => {
- uni.hideLoading();
- if (res.data && res.data.orderStatus === '支付成功') {
- uni.navigateTo({
- url: `/newScale/Senile/testResult?resultId=${this.orderInfo.resultId}&messageShare=1`
- });
- } else {
- // _this.orderInfo.total = _this.hasDiscount ? _this.promotionPrice : _this.price;
- _this.$request
- .post({
- url: "api/wx-pay/h5Pay",
- loadingTip: "加载中...",
- data: _this.orderInfo
- })
- .then((res) => {
- let redirect_url = encodeURI(
- `http://hnhong-duo.com/webo/newScale/Senile/paymentPage?orderNo=${res.data.orderNo}`
- )
- window.location.href = `${res.data.codeUrl}&redirect_url=${redirect_url}`;
- });
- }
- });
- },
- createOrder() {
- let _this = this;
- let params = {
- resultId: _this.orderInfo.resultId,
- subject: _this.orderInfo.description,
- body: _this.orderInfo.description,
- total_amount: _this.orderInfo.total * 100,
- msgPage: "",
- }
- _this.$request
- .post({
- url: "api/douyin/createOrder",
- loadingTip: "加载中...",
- data: params
- })
- .then((res) => {
- _this.orderNo = res.data.orderNo;
- let imageUrl = 'https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/banner1.png';
- _this.payToutiao(
- res.data.orderId,
- res.data.orderToken,
- res.data.orderNo
- );
- });
- },
- payToutiao(orderId, orderToken, orderNo) {
- let _this = this;
- tt.pay({
- orderInfo: {
- order_id: orderId,
- order_token: orderToken,
- },
- service: 5,
- success: (response) => {
- _this.timer = setInterval(() => {
- _this.getQueryOrder(orderNo);
- }, 1000);
- },
- fail: (err) => {
- uni.showToast({
- icon: "none",
- name: "支付失败",
- });
- },
- });
- },
- // 订单状态
- getQueryOrder(orderNo) {
- let _this = this;
- _this.$request
- .get({
- url: `api/douyin/queryOrder/${orderNo}`,
- loadingTip: "加载中...",
- data: {},
- })
- .then((res) => {
- if (res.code == "200") {
- if (res.data.statusCode == "SUCCESS") {
- let imageUrl =
- 'https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/banner1.png';
- uni.navigateTo({
- url: `/newScale/Senile/testResult?resultId=${_this.orderInfo.resultId}&messageShare=1`
- });
- clearInterval(_this.timer);
- uni.showToast({
- title: "支付成功",
- });
- } else if (res.data.statusCode == "CLOSED") {
- // console.log("订单支付回调成功===========CLOSED》", _this.trade_state_closed );
- } else {
- clearInterval(_this.timer);
- // console.log("订单支付回调成功CLOSED===========》", _this.trade_state_closed);
- }
- } else {
- uni.showToast({
- title: "支付失败",
- });
- }
- });
- },
- // 查询测试人数
- getPeople() {
- let _this = this;
- _this.$request
- .get({
- url: "record/countByFlag?flag=20210804165314",
- loadingTip: "加载中..."
- })
- .then((res) => {
- _this.peopleNum = res.data + 57000
- });
- },
- payEnsure() {
- // console.log(11111)
- this.$refs.popup.open();
- },
- uncompleteHandle() {
- this.$refs.popup.close();
- },
- completeHandle() {
- uni.showLoading({
- title: ''
- });
- this.checkOrder();
- }
- }
- }
- </script>
- <style scoped>
- .payment_bg {
- width: 100%;
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/payment_bg.png) no-repeat top;
- background-size: 100% auto;
- overflow: hidden;
- }
- .payment_info {
- width: 750rpx;
- height: 531rpx;
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/Senile/paymentPage/pay_scale_info.png) no-repeat center;
- background-size: cover;
- position: relative;
- margin-top: 143rpx;
- overflow: hidden;
- }
- .payment_info image {
- width: 100%;
- height: auto;
- margin-top: 134rpx;
- }
- .payment_info .pay_btn_sm {
- width: 640rpx;
- height: 73rpx;
- line-height: 73rpx;
- position: absolute;
- left: 55rpx;
- bottom: 73rpx;
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/pay_button.png) no-repeat center;
- background-size: 100% auto;
- font-family: 'Alibaba PuHuiTi 2.0';
- font-weight: bold;
- font-size: 36rpx;
- color: #FFFFFF;
- text-shadow: 0rpx 0rpx 5rpx rgba(168, 63, 90, 0.5);
- text-align: center;
- }
- .payment_desc image {
- width: 750rpx;
- }
- .pay_btn_lg {
- width: 640rpx;
- height: 73rpx;
- line-height: 73rpx;
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/pay_button.png) no-repeat center;
- background-size: 100% auto;
- font-family: 'Alibaba PuHuiTi 2.0';
- font-weight: bold;
- font-size: 36rpx;
- color: #FFFFFF;
- text-shadow: 0rpx 0rpx 5rpx rgba(168, 63, 90, 0.5);
- text-align: center;
- margin: 20rpx auto 60rpx;
- }
- .pay_dialog {
- width: 594rpx;
- height: 360rpx;
- background: url(https://test.jue-ming.com:8849/api/show?filePath=./webo/EQtest/paymentPage/dialog_bg.png) no-repeat top;
- background-size: cover;
- position: fixed;
- top: 540rpx;
- left: 50%;
- transform: translate(-50%, -50%);
- }
- .btn_area {
- margin: 240rpx 0 0 96rpx;
- }
- .btn_area image {
- width: 160rpx;
- }
- .btn_area image:active {
- border: 1rpx solid #999999;
- opacity: 0.8;
- border-radius: 28rpx;
- }
- .people_num {
- margin-top: 177rpx;
- }
- .people_num text {
- min-width: 157rpx;
- height: 44rpx;
- padding: 0 10rpx;
- background: #FFEDF1;
- border-radius: 22rpx;
- font-family: 'Alibaba PuHuiTi 2.0';
- font-size: 28rpx;
- color: #FC716D;
- line-height: 44rpx;
- text-align: center;
- margin-left: 373rpx;
- }
- .price_num {
- margin-top: 72rpx;
- }
- .price_num text {
- min-width: 74rpx;
- font-family: 'Alibaba PuHuiTi 2.0';
- font-weight: normal;
- font-size: 32rpx;
- color: #FC716D;
- line-height: 24rpx;
- margin-left: 374rpx;
- }
- </style>
|