shopidgo.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <view class="content">
  3. <!-- <image @click="scan" class="img" mode="widthFix" src="../../static/img/lQDPDhs0QZY4xBXNAtDNAZWw7dBth6OpB2gCJkosywCAAA_405_720.jpg" ></image> -->
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. url: '',
  11. shopid:'',
  12. }
  13. },
  14. onLoad(opt) {
  15. if(opt.shopId){
  16. uni.reLaunch ({
  17. url:'../login/empower?shopId='+opt.shopId
  18. })
  19. }else{
  20. //var shopId='1F12DB68-D8E8-4B76-9E20-287ACB72889F'
  21. uni.reLaunch ({
  22. url:'../login/empower'
  23. })
  24. }
  25. },
  26. methods: {
  27. scan(){
  28. var that=this;
  29. uni.scanCode({
  30. success: function (res) {
  31. console.log('条码类型:' + res.scanType);
  32. console.log('条码内容:' + res.result);
  33. that.url=res.result;
  34. that.shopId=that.getHashQuery('shopId')
  35. if(that.shopId){
  36. that.gologin()
  37. }else{
  38. uni.showToast({
  39. title: '请扫码正确的二维码',
  40. icon: 'none',
  41. duration: 3000
  42. });
  43. }
  44. console.log(that.shopId)
  45. }
  46. });
  47. },
  48. gologin(){
  49. uni.navigateTo({
  50. url:'../login/login?shopId='+this.shopId
  51. })
  52. },
  53. getHashQuery (query) {
  54. if (this.url.indexOf(query) > -1) {
  55. let cur = this.url.slice(this.url.indexOf(query) + query.length + 1, this.url.length)
  56. if (cur.indexOf('&') > -1) {
  57. return cur.slice(0, cur.indexOf('&'))
  58. } else {
  59. return cur
  60. }
  61. } else {
  62. return false
  63. }
  64. }
  65. }
  66. }
  67. </script>
  68. <style scoped>
  69. </style>