1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <template>
- <view class="content">
- <image @click="scan" class="img" mode="widthFix" src="../../static/img/lQDPDhs0QZY4xBXNAtDNAZWw7dBth6OpB2gCJkosywCAAA_405_720.jpg" ></image>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- url: '',
- shopid:'',
- }
- },
- onLoad() {
-
- },
- methods: {
- scan(){
- var that=this;
- uni.scanCode({
- success: function (res) {
- console.log(res)
- console.log('条码类型:' + res.scanType);
- if(res.scanType=='WX_CODE'){
- that.url=res.path;
- that.shopId=that.getHashQuery('scene')
- that.shopId=that.insertStr(that.shopId,8,"-");
- that.shopId=that.insertStr(that.shopId,13,"-");
- that.shopId=that.insertStr(that.shopId,18,"-");
- that.shopId=that.insertStr(that.shopId,23,"-");
- console.log(that.shopId)
- if(that.shopId){
- that.gologin()
- }else{
- uni.showToast({
- title: '请扫码正确的二维码',
- icon: 'none',
- duration: 3000
- });
- }
- }else{
- console.log('条码内容:' + res.result);
- that.url=res.result;
- that.shopId=that.getHashQuery('shopId')
- if(that.shopId){
- that.gologin()
- }else{
- uni.showToast({
- title: '请扫码正确的二维码',
- icon: 'none',
- duration: 3000
- });
- }
- }
-
-
-
-
- }
- });
- },
- insertStr(soure, start, newStr){
- return soure.slice(0, start) + newStr + soure.slice(start);
- },
- gologin(){
- uni.navigateTo({
- url:'../login/login?shopId='+this.shopId
- })
- },
- getHashQuery (query) {
- if (this.url.indexOf(query) > -1) {
- let cur = this.url.slice(this.url.indexOf(query) + query.length + 1, this.url.length)
- if (cur.indexOf('&') > -1) {
- return cur.slice(0, cur.indexOf('&'))
- } else {
- return cur
- }
- } else {
- return false
- }
- }
- }
- }
- </script>
- <style scoped>
- .content{
- height: 100vh;
- background: #000000;
- display: flex;
- align-items: flex-end;
- }
- .img{
- width: 750rpx;
- }
- </style>
|