uniapp Scan the ordinary QR code to enter the applet

foreword

Due to the needs of the project, I need to scan the QR code defined in the backend to enter the applet in the scan of WeChat.

This requirement is simple and simple, and it is not difficult to say that it is difficult, but it took me a few days

It needs to be in   the development settings under Development   ---> Development Management

 Swipe down until you see the bar that scans the normal link QR code to open the applet

 When writing the function page of the applet, fill in the path after thinking about the path. After all, this column cannot be modified in the future.

Only the content framed in red below can be modified

I was stuck at the step of downloading the verification file at the beginning, because the verification file needs to be placed under the server file after downloading. I don’t know how to do this. In the end, my brother helped me fix it.

 It doesn’t matter if you choose other test scopes under the reminder, the most important point is the column of the whole network release.

 

Question one 

 At the beginning, I didn’t choose to publish in this column, but I tried it for a few minutes. After scanning the code, I didn’t jump to the applet. Instead, it showed that the operation was successful, as well as parameters, status, etc.

Finally, I had no choice but to click publish. After publishing, after a while, I can scan the code and jump to the applet.

Well, let me reflect on it, probably because it was released successfully, I went to test this function, I should give it some time to let it react

question two

Because I clicked Published, this will cause the (scan code jump) function to be unusable in the trial version and the development version, and it will not be possible to detect whether the passed parameters are correct. 

This problem is easy to solve. You can test this function by using QR code compilation, and after this function is completed, it needs to be released as an online version to test this function. After the release, you have to wait for half an hour, and then test it after an hour

 

 Receive the parameters passed by the QR code

My path is in pages/my/my because in my. Received in the vue file

the code

Official website address

 onLoad(option) {
      const {
        q
      } = option
      console.log(decodeURIComponent(q));
      if (q && uni.getStorageSync('token')) {
        let str = decodeURIComponent(q).split('/')[6]
        let arr = decodeURIComponent(q).split('/')[7]
        console.log(str, arr); // 88000000000001
        if (arr) return uni.navigateTo({
          url: '/subpkg/pile/connectorDetail?code=' + arr + '&id=' + str
        })
        uni.navigateTo({
          url: '/subpkg/pile/connectorDetail?code=' + str
        })
        // if (arr) {
        //   if (uni.getStorageSync('token')) return uni.navigateTo({
        //     url: '/subpkg/pile/connectorDetail?code=' + arr + '&id=' + str
        //   })
        // } else {
        //   if (uni.getStorageSync('token')) return uni.navigateTo({
        //     url: '/subpkg/pile/connectorDetail?code=' + str
        //   })
        // }
      }
      // let str = decodeURIComponent(q).substring(decodeURIComponent(q).lastIndexOf('/') + 1)
    },

Guess you like

Origin blog.csdn.net/LJM51200/article/details/128332164