index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="content">
  3. <image class="logo" src="/static/logo.png" @click="wxgologin"></image>
  4. <view >shopId:{{shopId}}</view>
  5. <view>
  6. url:{{url}}
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. shopId: '',
  15. url:'',
  16. }
  17. },
  18. onLoad() {
  19. this.$common.getExtStoreId()
  20. var ext=this.$common.getExtStoreId();
  21. console.log(ext)
  22. this.shopId=ext.shopId;
  23. this.url=ext.url;
  24. this.uniLogin()
  25. },
  26. methods: {
  27. wxgologin(){
  28. var that=this;
  29. uni.getUserProfile({
  30. lang:'zh_CN',
  31. desc:'登录',
  32. success:(res)=>{
  33. console.log(res);
  34. that.wxdata=res;
  35. uni.setStorage({
  36. key: 'wxdata',
  37. data: res,
  38. success: function () {
  39. that.uniLogin()
  40. }
  41. });
  42. },
  43. fail:(res)=>{
  44. console.log(res)
  45. }
  46. });
  47. },
  48. uniLogin(){
  49. var that=this;
  50. uni.login({
  51. provider: 'weixin',
  52. success: function (loginRes) {
  53. console.log(loginRes);
  54. that.getWxOpenID(loginRes)
  55. }
  56. });
  57. },
  58. getWxOpenID(e){
  59. this.$http('miniApp2/sys/getWxOpenID', {
  60. code:e.code,
  61. shopId:'E37BB296-5A08-4534-859D-B351BA611AF9'
  62. },'GET').then(res => {
  63. })
  64. },
  65. }
  66. }
  67. </script>
  68. <style>
  69. .logo {
  70. height: 200rpx;
  71. width: 200rpx;
  72. margin-top: 200rpx;
  73. margin-left: auto;
  74. margin-right: auto;
  75. margin-bottom: 50rpx;
  76. }
  77. </style>