| New file |
| | |
| | | <template> |
| | | <view> |
| | | <movable-area :style="'width: ' + windowWidth + 'px;height:' + windowHeight + 'px'"> |
| | | <web-view :src="url"> |
| | | </web-view> |
| | | <movable-view direction="all" x="553rpx" :y="windowHeight/2-hf" v-if="cid" @click="openPay" class="pay-btn"> |
| | | <image class="pay-img" src="/static/pay-btn.jpeg" mode=""></image> |
| | | </movable-view> |
| | | </movable-area> |
| | | |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import { |
| | | ACCESSTOKEN, |
| | | config |
| | | } from '@/common/config.js'; |
| | | import { |
| | | getWechatInfo, |
| | | getOpenId, |
| | | getOpenIdBase |
| | | } from '@/common/api/index' |
| | | export default { |
| | | data() { |
| | | return { |
| | | hf: uni.upx2px(81), |
| | | cid: '', |
| | | windowHeight: 724, |
| | | windowWidth: 0, |
| | | url: '' |
| | | }; |
| | | }, |
| | | onLoad(opt) { |
| | | let sysInfo = uni.getSystemInfoSync(); |
| | | this.windowHeight = sysInfo.windowHeight; |
| | | this.windowWidth = sysInfo.windowWidth; |
| | | if (opt.cid) { |
| | | uni.setStorageSync('CID', opt.cid) |
| | | if (opt.cid == '1285474127884455937') { |
| | | this.url = |
| | | "https://fxm.xintoucloud.com/scene-user-fillin?sceneCode=DE88783ECF1D4DC2BCBF25A1A683651AFA4A9523573FF4080F2086B00E00E78A1235219708A15E8B223AAC2D243884DE" |
| | | } else if (opt.cid == '1586530233928945664') { |
| | | this.url = |
| | | "https://fxm.xintoucloud.com/scene-user-fillin?sceneCode=622C5D9E30E54D07BCB3BF280DBEE266F4C88598A368881C81D0D8CECA02C3DB1235219708A15E8B223AAC2D243884DE" |
| | | } |
| | | this.cid = opt.cid |
| | | } |
| | | if (opt.code) { |
| | | uni.showLoading() |
| | | getOpenId({ |
| | | params: { |
| | | code: opt.code |
| | | } |
| | | }).then(res => { |
| | | uni.setStorageSync(ACCESSTOKEN, res.token.accessToken) |
| | | uni.setStorageSync('IS_NEW', res.isNew) |
| | | let url = '/pages/pay/scanpay?cid=' + this.cid |
| | | if (res.isNew) { |
| | | url = '/pages/pay/wxpay?cid=' + this.cid |
| | | } |
| | | uni.hideLoading() |
| | | uni.redirectTo({ |
| | | url: url |
| | | }) |
| | | }).catch(() => { |
| | | uni.hideLoading() |
| | | }) |
| | | } |
| | | }, |
| | | methods: { |
| | | openPay() { |
| | | const TOKEN = uni.getStorageSync(ACCESSTOKEN) || null; |
| | | if (TOKEN) { |
| | | const IS_NEW = uni.getStorageSync('IS_NEW') || null; |
| | | let url = '/pages/pay/scanpay?cid=' + this.cid |
| | | if (IS_NEW) { |
| | | url = '/pages/pay/wxpay?cid=' + this.cid |
| | | } |
| | | uni.redirectTo({ |
| | | url: url |
| | | }) |
| | | } else { |
| | | uni.showLoading() |
| | | getWechatInfo().then(res => { |
| | | const redirect_uri = encodeURIComponent( |
| | | `${config.webURL}/pages/pay/scanRes?cid=${this.cid}`) |
| | | window.location.href = |
| | | `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect` |
| | | }) |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | .pay-btn { |
| | | position: fixed; |
| | | z-index: 99999; |
| | | width: 162rpx; |
| | | height: 162rpx; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | color: #fff; |
| | | border-radius: 15rpx; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .pay-img { |
| | | width: 162rpx; |
| | | height: 162rpx; |
| | | } |
| | | </style> |