瀏覽代碼

小程序

zrug 7 月之前
父節點
當前提交
13eb00b0fc
共有 3 個文件被更改,包括 65 次插入3 次删除
  1. 63 1
      08.src/Xingxi-mp/app.js
  2. 1 1
      08.src/Xingxi-mp/config.js
  3. 1 1
      08.src/Xingxi-mp/project.config.json

+ 63 - 1
08.src/Xingxi-mp/app.js

@@ -1,2 +1,64 @@
 // app.js
-App({})
+
+const { baseUrl } = require('./config.js');
+
+App({
+
+// config.service.pathUrl
+// https://mpapitest.gululuq.com/
+
+  data: {
+    loginSuccess: false,
+  },
+
+  globalData: {
+    storeId: null,
+    mUser: null,
+  },
+
+  onLaunch() {
+
+    // 登录
+    wx.login({
+      success: res => {
+        // 发送 res.code 到后台换取 openId, sessionKey, unionId
+        console.log("code", res);
+        if (res.code){
+          wx.request({
+            url: baseUrl + '/api/store/wxlogin',
+            method: 'POST',
+            data: {
+              code: res.code
+            },
+            header: {
+              'content-type': 'application/x-www-form-urlencoded',
+              // 'X-Referrer-Id': codeUrl[1] || '',
+              // 'X-Store-Id': codeUrl[0] || ''
+              'X-Referrer-Id': '',
+              'X-Store-Id': ''
+            },
+            success:(res)=> {
+              console.log(res);
+              // this.globalData.mUser = res.data.data;
+              // this.globalData.storeId = '';
+              // this.data.loginSuccess = true;
+            },
+            fail: function(res){
+              console.log(res);
+            }
+          })
+        }
+      },
+      fail: function(e){
+        console.log(e);
+      }
+    })
+  },
+})
+
+
+wx.login({
+  success: res => {
+    // 发送 res.code 到后台换取 openId, sessionKey, unionId
+  },
+})

+ 1 - 1
08.src/Xingxi-mp/config.js

@@ -1,4 +1,4 @@
-export const baseUrl = "https://接口地址"; // 服务器地址
+export const baseUrl = "https://mpapitest.gululuq.com/"; // 服务器地址
 // export const baseUrl = "http://测试接口地址"; // 测试服务器地址
 
 // export const ossHost = "https://res.zrug.top";

+ 1 - 1
08.src/Xingxi-mp/project.config.json

@@ -1,5 +1,5 @@
 {
-  "appid": "wx004d7a30f91ef286",
+  "appid": "wx12e34630814e5d30",
   "compileType": "miniprogram",
   "libVersion": "3.8.0",
   "packOptions": {