Browse Source

2024.01.17 补充提交

zweiqin 1 year ago
parent
commit
ff5470ee9e

+ 1 - 0
config/server/index.js

@@ -0,0 +1 @@
+export * from "./module/home"

+ 14 - 0
config/server/module/home.js

@@ -0,0 +1,14 @@
+const NET = require("../../../utils/request");
+const DOMAIN_PREFIX = "https://mtrappapi.tfcliao.com";
+//  定义请求根路径
+
+//  获取热销材料
+export function getHotSalesGoods(params) {
+  return NET.request1(`${DOMAIN_PREFIX}/canvas/getProducts2`, params, "GET");
+}
+
+
+//  下面是分类模块的
+export function getClassification(params){
+  return NET.request1(`${DOMAIN_PREFIX}/classify/getFirstClassify`, params, "GET");
+}

+ 14 - 0
config/server/module/login.js

@@ -0,0 +1,14 @@
+const NET = require("../../../utils/request");
+const DOMAIN_PREFIX = "https://mtrappapi.tfcliao.com";
+//  定义请求根路径
+
+//  获取验证码的请求
+export function getCode(params) {
+  return NET.request1(`${DOMAIN_PREFIX}/app/getCode`, params, "GET");
+}
+
+
+// 登陆
+export function materialLogin(data){
+    return NET.request1(`${DOMAIN_PREFIX}/app/login`, data, "POST");
+}

+ 2 - 2
pages/new-tabbar/home/index.vue

@@ -151,7 +151,7 @@
 
 <script>
 import Nav from "../components/Nav.vue"
-import { getProducts2CanvasApi } from '../../../api/anotherTFInterface'
+import { getHotSalesGoods } from "../../../config/server/index";
 export default {
     components: {
         Nav
@@ -184,7 +184,7 @@ export default {
     methods: {
         async getSelect() {
             // this.hotSearch.page++
-            let res = await getProducts2CanvasApi(this.hotSearch);
+            let res = await getHotSalesGoods(this.hotSearch);
             this.productListTotal = res.data.total
             this.productList.push(...res.data.list)
         },

+ 3 - 0
pages/register/index.vue

@@ -72,6 +72,9 @@ export default {
 		}
 	},
 	methods: {
+		handleBack() {
+			uni.navigateBack()
+		},
 		// 获取验证码
 		handleSendVerify() {
 			if (!this.registerQuery.phone) {

+ 1 - 0
utils/AnotherTFRequest.js

@@ -5,6 +5,7 @@ import store from '../store'
 const request = (base_url) => function (url, data = {}, method = 'GET', cb, header = {}) {
 	return new Promise((resolve, reject) => {
 		header['Content-Type'] = 'application/json'
+		header.tenant = 'MDAwMA=='
 		const res = uni.getStorageSync(T_STORAGE_KEY) || {}
 		if (res.token) header.Authorization = res.token
 		if (res.ssoUserInfo && res.ssoUserInfo.token) header['satoken-user'] = res.ssoUserInfo.token

+ 77 - 0
utils/request.js

@@ -0,0 +1,77 @@
+// import {showLoading,hideLoading} from "./plugIn/globalLoading";
+const request = (url, data, method = 'GET') => {
+	return new Promise((resolve, reject) => {
+		let header = {
+			"Content-Type": "application/json"
+		}
+		const res = uni.getStorageSync('storage_key');
+		const token = res.token
+		if (token) {
+			header['Authorization'] = token
+		}
+		showLoading()
+		uni.request({
+			url: url,
+			data: data,
+			method: method,
+			header: header,
+			success: res => {
+				hideLoading()
+				if (res.statusCode == 200) {
+					if (res.data.code === "200" || res.data.code === "") {
+						resolve(res.data)
+					} else if (res.data.code === "20004" || res.data.code === "20005") {
+						uni.removeStorageSync("storage_key")
+						uni.navigateTo({
+							url: '/pages/login/index'
+						})
+					} else {
+						uni.showToast({
+							title: res.data.message,
+							icon: "none"
+						})
+					}
+				} else {
+					reject(res)
+				}
+			},
+			fail: res => {
+				hideLoading()
+				reject(res)
+			},
+		})
+	});
+}
+//不带token接口请求,首页
+const request1 = (url, data, method = 'GET') => {
+	return new Promise((resolve, reject) => {
+		let header = {
+			'Content-Type': 'application/json',
+			'tenant': 'MDAwMA==',
+		}
+		uni.showLoading()
+		uni.request({
+			url: url,
+			data: data,
+			method: method,
+			header: header,
+			success: res => {
+				uni.hideLoading()
+				if (res.data.code === "200" || data.code === "") {
+					resolve(res.data)
+				} else {
+					reject(res)
+				}
+			},
+			fail: res => {
+				uni.hideLoading()
+				reject(res)
+			}
+		})
+	});
+}
+
+module.exports = {
+	request: request,
+	request1: request1
+}