|
@@ -34,8 +34,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { Form, Button, Field, Icon } from 'vant'
|
|
|
+import { Form, Button, Field, Icon, Toast } from 'vant'
|
|
|
import wx from 'weixin-js-sdk'
|
|
|
+import { platform } from '../../../utils/platform'
|
|
|
|
|
|
export default {
|
|
|
name: 'index',
|
|
@@ -56,18 +57,37 @@ export default {
|
|
|
this.showFlag = true
|
|
|
},
|
|
|
handleScanQRCode () {
|
|
|
- wx.scanQRCode({
|
|
|
- needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
|
|
|
- scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
|
|
|
- success: function (res) {
|
|
|
- setTimeout(() => {
|
|
|
- alert(JSON.stringify(res))
|
|
|
- }, 1000)
|
|
|
- },
|
|
|
- fail: err => {
|
|
|
- alert('11111-----:' + JSON.stringify(err))
|
|
|
+ const vm = this
|
|
|
+ if (platform.isWeixin) {
|
|
|
+ wx.scanQRCode({
|
|
|
+ needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
|
|
|
+ scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
|
|
|
+ success: function (result) {
|
|
|
+ setTimeout(() => {
|
|
|
+ const { resultStr } = result
|
|
|
+ vm.place_num = resultStr
|
|
|
+ }, 1000)
|
|
|
+ },
|
|
|
+ fail: err => {
|
|
|
+ Toast(JSON.stringify(err))
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (platform.isAlipay) {
|
|
|
+ if (window.AlipayJSBridge) {
|
|
|
+ window.AlipayJSBridge.call('scan', {
|
|
|
+ scanType: ['qrCode', 'barCode'],
|
|
|
+ }, function (result) {
|
|
|
+ const { codeContent } = result
|
|
|
+ if (codeContent) {
|
|
|
+ vm.place_num = codeContent
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ Toast('扫码功能不可用,请退出重试')
|
|
|
}
|
|
|
- })
|
|
|
+ } else {
|
|
|
+ Toast('扫码功能不可用')
|
|
|
+ }
|
|
|
},
|
|
|
onsubmit () {
|
|
|
|