ソースを参照

user and home page merged

May1145 1 年間 前
コミット
9cd1a6291f

+ 32 - 20
fore-end/API/appraise.js

@@ -1,5 +1,5 @@
 // const { useParamsEaseFuncs } = require('XrFrame/xrFrameSystem');
-const { http } = require('../utils/util')
+const { request } = require('../utils/request')
 
 const API = {
 	createCommentURL: '/appraise/create',
@@ -7,8 +7,9 @@ const API = {
 	getUserInfoURL: '/user/info',
 	registerURL: '/user/register',
 	modifyURL: '/user/modify',
-	getOrderURL: '/order/user'
-
+	getOrderURL: '/order/user',
+	getCategoryURL: '/category',
+	getCategoryGoods: '/goods/category'
 	
     //放接口URL
 }
@@ -16,10 +17,9 @@ const API = {
 //查询列表时传参---注意参数数据类型
 function createCommont(data) {
     //Promise
-    return http(
+    return request.post(
         API.createCommentURL,
         {
-            method: 'POST',
             data: data
         }
     );
@@ -30,10 +30,9 @@ function createCommont(data) {
  */
 //传对象给params
 function getCommentList(params) {
-    return http(
+    return request.get(
         API.createCommentURL,
         {
-            method: 'GET',
             params: params,//是传入的形参
         }
     );
@@ -44,10 +43,9 @@ function getCommentList(params) {
 
 // }
 function login(params) {
-	return http(
+	return request.post(
 		API.loginURL,
 		{
-			method:'POST',
 			header: params.header,
 			data: params.data,
 		}
@@ -55,46 +53,56 @@ function login(params) {
 }
 
 function getUserInfo(params) {
-	return http(
+	return request.get(
 		API.getUserInfoURL,
 		{
-			method: 'GET',
 			header: params.header,
-			data: params.data,
+			params: params.data,
 		}
 	);
 }
 
 function register(params) {
-	return  http(
+	return  request.post(
 		API.registerURL,
 		{
-			method: 'POST',
 			data: params.data,
 		}
 	);
 }
 
 function modify(params) {
-	return http(
+	return request.post(
 		API.modifyURL,
 		{
-			method: 'POST',
 			data: params.data,
 		}
 	);
 }
 
 function getOrder(params) {
-	return http(
+	return request.get(
 		API.getOrderURL,
 		{
-			method: 'GET',
-			data: params.data,
+			params: params.data,
 		}
 	)
 }
 
+function getCategoryAPI() {
+    // return http( API.getCategoryURL, {data: data})
+    return request.get(
+		API.getCategoryURL,
+	)
+}
+
+function getClassifyGoods(data) {
+    // return http( API.getCategoryGoods, {data: data})
+    return request.get(
+		API.getCategoryGoods+`/${data.page}/${data.pageSize}`
+	)
+}
+
 module.exports = {
     createCommont,
 	getCommentList,
@@ -102,5 +110,9 @@ module.exports = {
 	getUserInfo,
 	register,
 	modify,
-	getOrder
+	getOrder,
+	getCategoryAPI,
+	getClassifyGoods,
+	loginURl: API.loginURL,
+	registerURL: API.registerURL
 }

+ 0 - 14
fore-end/API/categories.js

@@ -1,14 +0,0 @@
-const { http } = require('../utils/util')
-
-const API = {
-    getCategoryURL: '/category',
-}
-
-function getCategoryAPI(data) {
-    // return http( API.getCategoryURL, {data: data})
-    return http({url: API.getCategoryURL, data: data})
-}
-
-module.exports = {
-    getCategoryAPI
-}

+ 0 - 14
fore-end/API/classifyGoods.js

@@ -1,14 +0,0 @@
-const { http } = require('../utils/util')
-
-const API = {
-    getCategoryGoods: '/goods/category/{page}/{pageSize}'
-}
-
-function getClassifyGoods(data) {
-    // return http( API.getCategoryGoods, {data: data})
-    return http({url: API.getCategoryGoods, data: data})
-}
-
-module.exports = {
-    getClassifyGoods
-}

+ 0 - 11
fore-end/API/goods.js

@@ -1,11 +0,0 @@
-const { http } = require('../utils/util')
-
-function getGoods() {
-    return http({url: '/goods/recommend', data: this.data}).then((res) => {
-        console.log(res);
-    })
-}
-
-module.exports = {
-    getGoods
-}

+ 0 - 3
fore-end/app.js

@@ -1,5 +1,4 @@
 // app.js
-const {http} = require('./utils/util')
 const {login,getUserInfo} = require('./API/appraise')
 
 App({
@@ -36,13 +35,11 @@ var infoOption = {
 	//检测缓存是否有token
 	// console.log(wx.getStorageSync('token'));
 	if(wx.getStorageSync('token') == ''){
-
 		console.log('token不存在');
 		// 登录
 		wx.login({
 			success: (res) => {
 				//获取用户昵称和头像
-
 				//和微信接口服务校验
 			  console.log("code: "+res.code);
 			  var url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' + wxInfo.appid + '&secret=' + wxInfo.appSecret + '&js_code=' + res.code + '&grant_type=authorization_code'

+ 1 - 1
fore-end/pages/classify_detail/classify_detail.js

@@ -1,6 +1,6 @@
 // pages/classify_detail/classify_detail.js
 // const { http } = require('../../utils/util')
-const { getClassifyGoods } = require('../../API/classifyGoods')
+const { getClassifyGoods } = require('../../API/appraise')
 
 Page({
 

+ 3 - 3
fore-end/pages/home/home.js

@@ -1,6 +1,5 @@
 // pages/home/home.js
-const { getCategoryAPI } = require('../../API/categories')
-const { getClassifyGoods } = require('../../API/classifyGoods')
+const { getCategoryAPI,getClassifyGoods} = require('../../API/appraise')
 
 
 Page({
@@ -45,7 +44,8 @@ Page({
     },
 
     getClassifyList() {
-        getCategoryAPI(this.data).then((data) => {
+		getCategoryAPI(this.data)
+		.then((data) => {
             this.setData({
                 classifyList: data
             })

+ 2 - 2
fore-end/pages/user/user.wxml

@@ -1,6 +1,6 @@
 <!--pages/user/user.wxml-->
 <van-cell-group inset>
-	<view class="pages-user">
+	<van-cell class="pages-user">
 		<view class="pages-user-profile" bindtap="getUserProfile">
 			<image class="pages-user-profile-1" src="{{avatarUrl}}" style="width: 236rpx; height: 232rpx; display: inline-block; box-sizing: border-box; left: 13rpx; top: 15rpx; position: relative"></image>
 		</view>
@@ -14,7 +14,7 @@
 			</view>
 			<van-cell bindtap="changeBtn" value="编辑个人信息" is-link  class="pages-user-username-3" value-class="font-size:12px;"></van-cell>
 		</view>
-	</view>
+	</van-cell>
 	<van-cell class="pages-user-order" bindtap="myOrder">
 		<van-icon name="/assets/tabBar_img/订单.png" class="pages-user-order-1"></van-icon>
 		<view class="pages-user-order-2">我的订单</view>

+ 0 - 1
fore-end/pages/user/user.wxss

@@ -1,4 +1,3 @@
-<<<<<<< HEAD
 /* pages/user/user.wxss */
 page{
 	display: flex;

+ 36 - 59
fore-end/project.config.json

@@ -1,61 +1,38 @@
 {
-    "description": "项目配置文件",
-    "packOptions": {
-        "ignore": [],
-        "include": []
-    },
-    "setting": {
-        "bundle": false,
-        "userConfirmedBundleSwitch": false,
-        "urlCheck": true,
-        "scopeDataCheck": false,
-        "coverView": true,
-        "es6": true,
-        "postcss": true,
-        "compileHotReLoad": false,
-        "lazyloadPlaceholderEnable": false,
-        "preloadBackgroundData": false,
-        "minified": true,
-        "autoAudits": false,
-        "newFeature": false,
-        "uglifyFileName": false,
-        "uploadWithSourceMap": true,
-        "useIsolateContext": true,
-        "nodeModules": false,
-        "enhance": true,
-        "useMultiFrameRuntime": true,
-        "useApiHook": true,
-        "useApiHostProcess": true,
-        "showShadowRootInWxmlPanel": true,
-        "packNpmManually": false,
-        "enableEngineNative": false,
-        "packNpmRelationList": [],
-        "minifyWXSS": true,
-        "showES6CompileOption": false,
-        "minifyWXML": true,
-        "babelSetting": {
-            "ignore": [],
-            "disablePlugins": [],
-            "outputPath": ""
-        },
-        "ignoreUploadUnusedFiles": true
-        "setting": {
-            "packNpmManually": true,
-            "packNpmRelationList": [
-                {
-                    "packageJsonPath": "./package.json",
-                    "miniprogramNpmDistDir": "./miniprogram_npm"
-                }
-            ]
-        }
-    },
-    "compileType": "miniprogram",
-    "libVersion": "2.19.4",
-    "appid": "wxc25f00d0fc026ae7",
-    "projectname": "miniprogram-92",
-    "condition": {},
-    "editorSetting": {
-        "tabIndent": "insertSpaces",
-        "tabSize": 4
-    }
+	"compileType": "miniprogram",
+	"setting": {
+		"babelSetting": {
+			"ignore": [],
+			"disablePlugins": [],
+			"outputPath": ""
+		},
+		"coverView": false,
+		"postcss": true,
+		"minified": false,
+		"enhance": true,
+		"showShadowRootInWxmlPanel": false,
+		"packNpmRelationList": [],
+		"ignoreUploadUnusedFiles": true,
+		"setting": {
+			"packNpmManually": true,
+			"packNpmRelationList": [
+				{
+					"packageJsonPath": "./package.json",
+					"miniprogramNpmDistDir": "./miniprogram_npm"
+				}
+			]
+		},
+		"es6": true
+	},
+	"editorSetting": {
+		"tabIndent": "tab",
+		"tabSize": 4
+	},
+	"appid": "wxc25f00d0fc026ae7",
+	"libVersion": "3.1.5",
+	"packOptions": {
+		"ignore": [],
+		"include": []
+	},
+	"condition": {}
 }

+ 27 - 26
fore-end/project.private.config.json

@@ -1,28 +1,29 @@
 {
-    "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-    "projectname": "WeChatTrading",
-    "setting": {
-        "compileHotReLoad": false,
-        "urlCheck": false
-    },
-    "condition": {
-        "miniprogram": {
-            "list": [
-                {
-                    "name": "",
-                    "pathName": "pages/home/home",
-                    "query": "",
-                    "launchMode": "default",
-                    "scene": null
-                },
-                {
-                    "name": "",
-                    "pathName": "pages/classify_detail/classify_detail",
-                    "query": "classify_id=1",
-                    "launchMode": "default",
-                    "scene": null
-                }
-            ]
-        }
-    }
+	"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+	"projectname": "wechatTrading",
+	"setting": {
+		"compileHotReLoad": false,
+		"urlCheck": false
+	},
+	"condition": {
+		"miniprogram": {
+			"list": [
+				{
+					"name": "",
+					"pathName": "pages/home/home",
+					"query": "",
+					"launchMode": "default",
+					"scene": null
+				},
+				{
+					"name": "",
+					"pathName": "pages/classify_detail/classify_detail",
+					"query": "classify_id=1",
+					"launchMode": "default",
+					"scene": null
+				}
+			]
+		}
+	},
+	"libVersion": "3.1.4"
 }

+ 5 - 1
fore-end/utils/util.js

@@ -1,4 +1,5 @@
 import Toast from '@vant/weapp/toast/toast';
+const { loginURL, registerURL } = require('../API/appraise')
 const baseURL = "http://192.168.31.28:8084";//后台服务提供的地址
 const uploadUrl = "/pic/upload";
 const formatTime = date => {
@@ -22,7 +23,10 @@ const formatNumber = n => {
 function http(url, option) {
     return new Promise ((resolve, reject) => {
         wx.request({
-          url: baseURL + url,
+		  url: baseURL + url,
+		  header:{
+			"Authorization": (url!=loginURL && url!=registerURL) ? wx.getStorageSync('token') : '' 
+		  },
 		  ...option,
 
           success(res) {