authorization.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="container"></view>
  3. </template>
  4. <script>
  5. export default {
  6. data() {
  7. return {
  8. type: null
  9. }
  10. },
  11. onLoad(options) {
  12. this.type = options.type
  13. this.handleClick(this.type)
  14. },
  15. methods: {
  16. handleClick(type) {
  17. // 1为商户,2为业主
  18. uni.login({
  19. provider: 'weixin',
  20. success: (res) => {
  21. this.handleQuery(type, res.code)
  22. }
  23. })
  24. },
  25. // 查询请求
  26. async handleQuery(type, code) {
  27. if (type === '1') {
  28. // 查询商家是否绑定
  29. const res = await this.$myRequest({
  30. url: '/mhotel/appget_user_ma.action',
  31. data: {
  32. code
  33. }
  34. })
  35. if (res.code === 200) {
  36. let data = JSON.stringify(res.data)
  37. uni.reLaunch({
  38. url: `/pages/shopInfo/shopInfo?type=1&data=${data}`
  39. })
  40. } else {
  41. uni.reLaunch({
  42. url: '/pages/shop/shop'
  43. })
  44. }
  45. } else if (type === '2') {
  46. // 查询业主是否已绑定
  47. const res = await this.$myRequest({
  48. url: '/mhotel/appgetUser.action',
  49. data: {
  50. code
  51. }
  52. })
  53. if (res.code === 200) {
  54. let data = JSON.stringify(res.data)
  55. uni.reLaunch({
  56. url: `/pages/shopInfo/shopInfo?type=2&data=${data}`
  57. })
  58. } else {
  59. uni.reLaunch({
  60. url: '/pages/shop2/shop2'
  61. })
  62. }
  63. }
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .container {
  70. height: 100vh;
  71. background-color: #fff;
  72. }
  73. </style>