123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import {
- createAndroidOrder,
- payQrCode,
- pollingOrder
- } from '~/api/global'
- let polling
- Component({
- data: {
- qrCode: '',
- product: {}
- },
- lifetimes: {
- attached() {
- /* this.selectComponent("#popUp").showModal()
- this.getTabBar().setData({
- show: false
- }) */
- },
- },
- methods: {
- async open(product) {
- let orderId = await createAndroidOrder({
- productId: product.id
- })
- let qrCode = await payQrCode({
- orderId,
- productId: product.id,
- channel: wx.getStorageSync('channelCode')
- })
- if (typeof this.getTabBar === 'function' && this.getTabBar()) {
- this.getTabBar().setData({
- show: false
- })
- }
- this.setData({
- product,
- qrCode
- })
- this.selectComponent("#popUp").showModal()
- polling = setInterval(async () => {
- let res = await pollingOrder(orderId)
- if (res.payStatus == 'SUCCESS') {
- this.triggerEvent('paySuccess')
- this.close()
- }
- }, 2000);
- },
- closeEvent() {
- if (typeof this.getTabBar === 'function' && this.getTabBar()) {
- this.getTabBar().setData({
- show: true
- })
- }
- clearInterval(polling)
- },
- close() {
- this.selectComponent("#popUp").hideModal()
- clearInterval(polling)
- if (typeof this.getTabBar === 'function' && this.getTabBar()) {
- this.getTabBar().setData({
- show: true
- })
- }
- }
- }
- })
|