123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <template>
- <view class="index" :style="'padding-top:'+padtop+'px'">
- <!-- 头部 -->
- <navbar :back="false" title="扫码登录" :bgcolor="backgroundColor" color="#fff" fixed zIndex="1010" :center="true" :custom='true' @getTop="getTop" back="true"/>
- <!-- <view class="naver" @click="smit">
- 扫码登录
- </view> -->
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- //潜山
- qians:'',
- uehg:1,
- padtop:this.$http._GET.customBarH||0,
- backgroundColor: 'linear-gradient(90deg, #A00517, #E93030)',
- };
- },
- onLoad() {
- // this.uehg = 1
- this.scanAction()
- },
- onShow() {
- // this.uehg = 1
- // this.scanAction()
- },
- onHide() {
- // this.uehg = 2
- },
- methods:{
- getTop(e){
- this.padtop=e
- },
- // smit(){
- // this.scanAction()
- // },
- //扫码功能
- scanAction() {
- // if(this.uehg == 1){
- const app = getApp();
- wx.scanCode({
- onlyFromCamera: true,
- scanType: ['qrCode', 'barCode'],
- //结果处理
- success: res => this.dealScanCode(res.result),
- fail: (e) => {
- if (e && e.errMsg && e.errMsg.indexOf('scanCode:fail cancel') != -1) {
- return;
- }
- wx.showToast({ title: '扫码失败', icon: 'none', })
- }
- });
- // }else{
- // return
- // }
-
- },
- // 判断连接
- dealScanCode(result) {
- const app = getApp();
- console.log(result,123)
- let str = result
- // https://qsfy.qs163.cn/
- // this.qians = str.includes('https://qsfy.qs163.cn/prod-api/auth/scanCode')
-
- this.qians = str.includes('https://qsdj.qs163.cn/prod-api/scanCode/confirm')
- // console.log(str.includes('https://qsfy.qs163.cn/prod-api/auth/scanCode'))
- // 潜山
- // this.qians = str.includes('https://qsxyakm.qs163.cn/prod-api/applet/scanQr')
- // /、岳西 https://yxxy.qs163.cn https://qsfy.qs163.cn
-
- if(this.qians){
- console.log(123098)
- // wx.navigateTo({
- // url: '/pages/addvacfrom/wufa?code=' + this.qians
- // })
- uni.request({
- url: result,
- data:{
- // pid:this.companyId
- },
- success: function(res) {
- console.log(res.data)
- if(res.data.code==200){
- wx.navigateTo({
- url: '/pages/index/wufa?code=' + res.data.data
- })
- // console.log(3456)
- }else {
- wx.navigateBack({
- delta: 1 //想要返回的层级
- })
- wx.showToast({ title: res.data.msg, icon: 'none', duration: 2000})
- }
-
- },
- });
- }else{
- wx.navigateBack({
- delta: 1 //想要返回的层级
- })
- uni.showToast({ title: '请扫描正确的二维码', icon: 'none', duration: 3000})
-
- }
-
- // let index = str.indexOf("/");
- // console.log(index)
- // let id = str.substring('/');
- // console.log(id)
- // this.bindAccount(result)
- // app.log("scan:" + result)
- // if (!result || !result.lastIndexOf) {
- // wx.showToast({ title: '二维码错误', icon: 'none', duration: 2000 })
- // return;
- // }
-
- // 具体的连接处理
- // if (result.lastIndexOf('synthetical=') != -1) {
- // bindAccount(result);
- // return;
- // }
-
- //无效的二维码
- // wx.showToast({ title: '二维码错误', icon: 'none', duration: 2000 })
- },
- //处理连接
- bindAccount(param){
- // 截取字符串
- let groupNum = getUrlParam(param, 'chatID')
- let groupType = getUrlParam(param, 'type');
- },
-
- // 提供外部的接口
- // module.exports = {
- // scanAction,
- // dealScanCode,
- // getUrlParam
- // }
- // 正则表达式截取字符串的方法
- getUrlParam(url, name) {
- // 正则筛选地址栏
- let reg = new RegExp("(^|&|/?|//)" + name + "=([^&]*)(&|$)");
- // 匹配目标参数
- let result = url.substr(1).match(reg);
- console.log(result)
- //返回参数值
- // return result ? decodeURIComponent(result[2]) : null;
- }
- }
- }
- </script>
- <style lang="scss">
- .naver{
- width: 85%;
- height: 90upx;
- font-size: 31upx;
- font-family: PingFang SC;
- font-weight: 400;
- color: #FFFFFF;
- line-height: 90upx;
- background-color: #1678FF;
- margin-left: 50%;
- transform: translateX(-50%);
- border-radius: 14upx;
- text-align: center;
- margin-top: 250upx;
- }
- </style>
|