1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import {
- createAndroidOrder,
- payQrCode,
- pollingOrder
- } from '~/api/global'
- let polling
- Component({
- properties: {
- },
- 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')
- })
- 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() {
- this.getTabBar().setData({
- show: true
- })
- clearInterval(polling)
- },
- close() {
- this.selectComponent("#popUp").hideModal()
- this.getTabBar().setData({
- show: true
- })
- }
- }
- })
|