lijj há 2 anos atrás
pai
commit
756debeb0e

+ 8 - 0
admin/pom.xml

@@ -24,6 +24,8 @@
         <docker.password>admin12345</docker.password>
         <docker.namespace>blade</docker.namespace>
         <docker.fabric.version>0.42.0</docker.fabric.version>
+        <!-- 微信版本 -->
+        <wxjava-version>3.7.0</wxjava-version>
     </properties>
 
     <dependencyManagement>
@@ -204,6 +206,12 @@
             <artifactId>lombok</artifactId>
             <scope>provided</scope>
         </dependency>
+        <!-- 微信小程序 -->
+        <dependency>
+            <groupId>com.github.binarywang</groupId>
+            <artifactId>weixin-java-miniapp</artifactId>
+            <version>${wxjava-version}</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 1 - 1
admin/src/main/java/org/springblade/modules/ycwh/controller/wx/WXCollectInfoController.java

@@ -54,7 +54,7 @@ import java.util.Map;
  */
 @RestController
 @AllArgsConstructor
-@RequestMapping("collect_info")
+@RequestMapping("yuecai-wx/collect_info")
 @Api(value = "名菜名点名店收藏", tags = "名菜名点名店收藏接口")
 public class WXCollectInfoController extends BladeController {
 

+ 9 - 0
admin/src/main/resources/application-dev.yml

@@ -56,3 +56,12 @@ blade:
     upload-domain: http://localhost:8999
     remote-path: /usr/share/nginx/html
 
+# 小程序相关配置
+wx:
+  miniapp:
+    configs:
+      - appid: wx4517e7bae4f224e5
+        secret: 3148c59a4dd9aba983cf3242684c37a1
+        token: #微信小程序消息服务器配置的token
+        aesKey: #微信小程序消息服务器配置的EncodingAESKey
+        msgDataFormat: JSON

+ 28 - 2
miniapp/api/member.js

@@ -3,9 +3,35 @@ import {bizConst} from './biz/biz.js'
 import {clientId,tenantId} from '@/common/setting'
 
 // 获取token
+const wxUserLogin = (code) => {
+	let tenantId = '000000'
+	return http.request({
+		url: bizConst.memberPrefix + '/login/miniapp',//?clientCode=' + clientId + '&code=' + code,
+		method: 'POST',
+		header: {
+			'Tenant-Id': tenantId
+		},
+		params: {
+			clientCode: clientId,
+			code,
+		},
+	})
+}
+
+//刷新token
+const refreshToken = (refreshToken) => {
+	return http.request({
+		url: bizConst.memberPrefix + '/login/refresh',
+		method: 'POST',
+		params: {
+			refreshToken,
+		},
+	})
+}
+
 const getUserInfo = () => {
 	return http.request({
-		url: bizConst.basicPrefix + '/member/info',
+		url: bizConst.memberPrefix + '/info',
 		method: 'GET',
 		header: {
 			'Tenant-Id': tenantId
@@ -15,7 +41,7 @@ const getUserInfo = () => {
 } 
 const updateUserInfo = () => {
 	return http.request({
-		url: bizConst.basicPrefix + '/member/update',
+		url: bizConst.memberPrefix + '/update',
 		method: 'GET',
 		header: {
 			'Tenant-Id': tenantId

+ 1 - 1
miniapp/http/api.js

@@ -5,7 +5,7 @@ import {throttle} from '@/utils/util.js'
 import Request from '@/utils/luch-request/index.js'
 
 const http = new Request(options);
-const ignorePaths = ['mb/login/miniapp', 'mb/login/refresh']//"blade-auth/oauth/token";//更新token的api不需要检查token
+const ignorePaths = ['yuecai-wx/login/miniapp', 'yuecai-wx/login/refresh']//"blade-auth/oauth/token";//更新token的api不需要检查token
 const preExpire = 5 //token超时之前几分钟提前刷新token
 
 const wxLogin = () => {//微信小程序获取wxcode静默登录,并获取token

+ 5 - 5
miniapp/pages/index.vue

@@ -85,11 +85,11 @@
       uni.$u.sleep(500).then(() => {
         wx.hideLoading();
         this.$u.func.toHome()
-        // if (this.$u.func.checkLogin()) {
-        //   this.$u.func.toHome()
-        // } else {
-        //   this.$u.func.wxLogin()
-        // }
+        if (this.$u.func.checkLogin()) {
+          this.$u.func.toHome()
+        } else {
+          this.$u.func.wxLogin()
+        }
       })
     },
   }

+ 1 - 0
miniapp/utils/func.js

@@ -135,6 +135,7 @@ const install = (Vue, vm) => {
 					//app.$uStore({ wxcode: wxCode})
 					that.$u.api.wxUserLogin(wxCode).then(res => {
 						let userInfo = res.data
+            debugger
 						if (userInfo.error_code == invalidCode) {//登录请求返回200,但是还是登录失败就走这里
 							uni.$u.toast(userInfo.error_description)
 							setTimeout(() => {