From f40c0d17ede9b2144f9ad3793dc1120cf19e8493 Mon Sep 17 00:00:00 2001 From: huangshijie Date: Fri, 20 Oct 2023 13:57:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 7 +- config/api.js | 2 +- pages/app-auth/index.js | 3 +- pages/cart/cart.js | 12 ++-- pages/category/index.js | 4 +- pages/goods/goods.js | 8 +-- pages/index/index.js | 4 +- pages/order-check/index.js | 6 +- pages/search/search.js | 6 +- pages/share/index.js | 4 +- pages/ucenter/address-detail/index.js | 8 +-- pages/ucenter/address/index.js | 2 +- pages/ucenter/express-info/index.js | 2 +- pages/ucenter/footprint/index.js | 4 +- pages/ucenter/goods-list/index.js | 2 +- pages/ucenter/index/index.js | 8 ++- pages/ucenter/order-details/index.js | 12 ++-- pages/ucenter/order-list/index.js | 6 +- pages/ucenter/settings/index.js | 5 +- project.config.json | 93 +++++++++++---------------- project.private.config.json | 7 ++ services/pay.js | 2 +- services/user.js | 6 +- utils/util.js | 8 ++- 24 files changed, 111 insertions(+), 110 deletions(-) create mode 100644 project.private.config.json diff --git a/app.js b/app.js index ed3bddb..5e7fb0d 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,5 @@ -var util = require('utils/util.js'); -var api = require('config/api.js'); +//var util = require('utils/util.js'); +//var api = require('config/api.js'); App({ data: { deviceInfo: {} @@ -17,7 +17,8 @@ App({ util.request(api.AuthLoginByWeixin, { code: res.code }, 'POST').then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { + console.log(11111111) let userInfo = res.data.userInfo; wx.setStorageSync('token', res.data.token); wx.setStorageSync('userInfo', userInfo); diff --git a/config/api.js b/config/api.js index aea1fae..f0ec8ea 100755 --- a/config/api.js +++ b/config/api.js @@ -1,7 +1,7 @@ const ApiRoot = 'http://localhost:8361'; // const ApiRoot = 'http://192.168.0.113:8361'; // const ApiRoot = 'https://www.qile.club:8688'; -const ApiRootUrl = ApiRoot + '/api/' +const ApiRootUrl = ApiRoot + '/api/v1/' module.exports = { ApiRoot: ApiRoot, diff --git a/pages/app-auth/index.js b/pages/app-auth/index.js index 6aaa038..68b706a 100644 --- a/pages/app-auth/index.js +++ b/pages/app-auth/index.js @@ -71,7 +71,8 @@ Page({ util.request(api.AuthLoginByWeixin, { info: info }, 'POST').then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { + console.log(222222222) wx.setStorageSync('userInfo', res.data.userInfo); wx.setStorageSync('token', res.data.token); app.globalData.userInfo = res.data.userInfo; diff --git a/pages/cart/cart.js b/pages/cart/cart.js index 108009a..cfc2826 100644 --- a/pages/cart/cart.js +++ b/pages/cart/cart.js @@ -61,7 +61,7 @@ Page({ getCartList: function() { let that = this; util.request(api.CartList).then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { let hasCartGoods = res.data.cartList; if (hasCartGoods.length != 0) { hasCartGoods = 1; @@ -117,7 +117,7 @@ Page({ productIds: productIds.join(','), isChecked: that.isCheckedAll() ? 0 : 1 }, 'POST').then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ cartGoods: res.data.cartList, cartTotal: res.data.cartTotal @@ -154,7 +154,7 @@ Page({ number: number, id: id }, 'POST').then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ cartGoods: res.data.cartList, cartTotal: res.data.cartTotal @@ -196,7 +196,7 @@ Page({ }, getCartNum: function() { util.request(api.CartGoodsCount).then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { let cartGoodsCount = ''; if (res.data.cartTotal.goodsCount == 0) { wx.removeTabBarBadge({ @@ -249,7 +249,7 @@ Page({ productIds: that.data.cartGoods[itemIndex].product_id, isChecked: that.data.cartGoods[itemIndex].checked ? 0 : 1 }, 'POST').then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ cartGoods: res.data.cartList, cartTotal: res.data.cartTotal @@ -344,7 +344,7 @@ Page({ util.request(api.CartDelete, { productIds: productIds }, 'POST').then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { let cartList = res.data.cartList; that.setData({ cartGoods: cartList, diff --git a/pages/category/index.js b/pages/category/index.js index ff30556..00a5ad8 100755 --- a/pages/category/index.js +++ b/pages/category/index.js @@ -23,7 +23,7 @@ Page({ getChannelShowInfo: function (e) { let that = this; util.request(api.ShowSettings).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { let index_banner_img = res.data.index_banner_img; that.setData({ index_banner_img: index_banner_img @@ -68,7 +68,7 @@ Page({ page: that.data.allPage, id: id }, 'POST').then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { let count = res.data.count; that.setData({ allCount: count, diff --git a/pages/goods/goods.js b/pages/goods/goods.js index c10caf5..fc3f711 100644 --- a/pages/goods/goods.js +++ b/pages/goods/goods.js @@ -97,7 +97,7 @@ Page({ util.request(api.GoodsDetail, { id: that.data.id }).then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { let _specificationList = res.data.specificationList; // 如果仅仅存在一种货品,那么商品页面初始化时默认checked if (_specificationList.valueList.length == 1) { @@ -334,7 +334,7 @@ Page({ getCartCount: function() { let that = this; util.request(api.CartGoodsCount).then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ cartGoodsCount: res.data.cartTotal.goodsCount }); @@ -434,7 +434,7 @@ Page({ }, "POST") .then(function(res) { let _res = res; - if (_res.errno == 0) { + if (_res.code == 0) { wx.showToast({ title: '添加成功', }); @@ -517,7 +517,7 @@ Page({ .then(function(res) { let _res = res; wx.hideLoading() - if (_res.errno == 0) { + if (_res.code == 0) { let id = that.data.id; wx.navigateTo({ url: '/pages/order-check/index?addtype=1' diff --git a/pages/index/index.js b/pages/index/index.js index 9448652..c34f4c2 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -73,7 +73,7 @@ Page({ getIndexData: function () { let that = this; util.request(api.IndexUrl).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ floorGoods: res.data.categoryList, banner: res.data.banner, @@ -117,7 +117,7 @@ Page({ getChannelShowInfo: function (e) { let that = this; util.request(api.ShowSettings).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { let show_channel = res.data.channel; let show_banner = res.data.banner; let show_notice = res.data.notice; diff --git a/pages/order-check/index.js b/pages/order-check/index.js index f30fcbf..f206643 100755 --- a/pages/order-check/index.js +++ b/pages/order-check/index.js @@ -120,7 +120,7 @@ Page({ orderFrom: orderFrom, type: 0 }).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { let addressId = 0; if (res.data.checkedAddress != 0) { addressId = res.data.checkedAddress.id; @@ -167,7 +167,7 @@ Page({ actualPrice: actualPrice, offlinePay: 0 }, 'POST').then(res => { - if (res.errno === 0) { + if (res.code === 0) { wx.removeStorageSync('orderId'); wx.setStorageSync('addressId', 0); const orderId = res.data.orderInfo.id; @@ -202,7 +202,7 @@ Page({ actualPrice: actualPrice, offlinePay: 1 }, 'POST').then(res => { - if (res.errno === 0) { + if (res.code === 0) { wx.removeStorageSync('orderId'); wx.setStorageSync('addressId', 0); wx.redirectTo({ diff --git a/pages/search/search.js b/pages/search/search.js index cfecdff..767c0b7 100755 --- a/pages/search/search.js +++ b/pages/search/search.js @@ -34,7 +34,7 @@ Page({ getSearchKeyword() { let that = this; util.request(api.SearchIndex).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ historyKeyword: res.data.historyKeywordList, defaultKeyword: res.data.defaultKeyword, @@ -54,7 +54,7 @@ Page({ getHelpKeyword: function () { let that = this; util.request(api.SearchHelper, { keyword: that.data.keyword }).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ helpKeyword: res.data }); @@ -83,7 +83,7 @@ Page({ getGoodsList: function () { let that = this; util.request(api.GoodsList, { keyword: that.data.keyword,sort: that.data.currentSortType, order: that.data.currentSortOrder, sales: that.data.salesSortOrder}).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ searchStatus: true, // categoryFilter: false, diff --git a/pages/share/index.js b/pages/share/index.js index 27dc664..b3b0e35 100644 --- a/pages/share/index.js +++ b/pages/share/index.js @@ -15,7 +15,7 @@ Page({ util.request(api.GetBase64, { goodsId: id }, 'POST').then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { that.getQrcodeJpg(res.data); } }); @@ -59,7 +59,7 @@ Page({ util.request(api.GoodsShare, { id: id }).then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ goods: res.data, }); diff --git a/pages/ucenter/address-detail/index.js b/pages/ucenter/address-detail/index.js index c7ab41d..d4c6610 100644 --- a/pages/ucenter/address-detail/index.js +++ b/pages/ucenter/address-detail/index.js @@ -80,7 +80,7 @@ Page({ util.request(api.AddressDetail, { id: that.data.addressId }).then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ address: res.data }); @@ -97,7 +97,7 @@ Page({ util.request(api.DeleteAddress, { id: id }, 'POST').then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { wx.removeStorageSync('addressId'); util.showErrorToast('删除成功'); wx.navigateBack(); @@ -299,7 +299,7 @@ Page({ util.request(api.RegionList, { parentId: regionId }).then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ regionList: res.data.map(item => { @@ -345,7 +345,7 @@ Page({ address: address.address, is_default: address.is_default, }, 'POST').then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { wx.navigateBack() } }); diff --git a/pages/ucenter/address/index.js b/pages/ucenter/address/index.js index 6073907..742a241 100644 --- a/pages/ucenter/address/index.js +++ b/pages/ucenter/address/index.js @@ -17,7 +17,7 @@ Page({ getAddresses() { let that = this; util.request(api.GetAddresses).then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ addresses: res.data }) diff --git a/pages/ucenter/express-info/index.js b/pages/ucenter/express-info/index.js index bd3c808..5315581 100644 --- a/pages/ucenter/express-info/index.js +++ b/pages/ucenter/express-info/index.js @@ -15,7 +15,7 @@ Page({ getExpressList(orderId) { let that = this; util.request(api.OrderExpressInfo, {orderId: orderId}).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { let expressList = res.data; let traces = JSON.parse(res.data.traces); expressList.traces = traces; diff --git a/pages/ucenter/footprint/index.js b/pages/ucenter/footprint/index.js index 97eb60b..f9884ac 100644 --- a/pages/ucenter/footprint/index.js +++ b/pages/ucenter/footprint/index.js @@ -16,7 +16,7 @@ Page({ getFootprintList() { let that = this; util.request(api.FootprintList, { page: that.data.allPage, size: that.data.size }).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { let count = res.data.count; let f1 = that.data.footprintList; let f2 = res.data.data; @@ -55,7 +55,7 @@ Page({ let that = this; let id = e.currentTarget.dataset.val; util.request(api.FootprintDelete, { footprintId: id }, 'POST').then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { wx.showToast({ title: '取消成功', icon: 'success', diff --git a/pages/ucenter/goods-list/index.js b/pages/ucenter/goods-list/index.js index dd32228..fde36a0 100644 --- a/pages/ucenter/goods-list/index.js +++ b/pages/ucenter/goods-list/index.js @@ -15,7 +15,7 @@ Page({ util.request(api.OrderGoods, { orderId: id }).then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ goodsList: res.data }); diff --git a/pages/ucenter/index/index.js b/pages/ucenter/index/index.js index c406fc1..19269b1 100644 --- a/pages/ucenter/index/index.js +++ b/pages/ucenter/index/index.js @@ -74,7 +74,8 @@ Page({ util.request(api.AuthLoginByWeixin, { code: code }, 'POST').then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { + console.log(33333333) let userInfo = res.data.userInfo; that.setData({ is_new: res.data.is_new, @@ -97,8 +98,9 @@ Page({ }, getSettingsDetail() { let that = this; + util.request(api.SettingsDetail).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { let userInfo = res.data; // wx.setStorageSync('userInfo', userInfo); that.setData({ @@ -117,7 +119,7 @@ Page({ getOrderInfo: function (e) { let that = this; util.request(api.OrderCountInfo).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { let status = res.data; that.setData({ status: status diff --git a/pages/ucenter/order-details/index.js b/pages/ucenter/order-details/index.js index 9068bc2..9e5c102 100644 --- a/pages/ucenter/order-details/index.js +++ b/pages/ucenter/order-details/index.js @@ -129,7 +129,7 @@ Page({ util.request(api.OrderExpressInfo, { orderId: that.data.orderId }).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { let express = res.data; express.traces = JSON.parse(res.data.traces); that.setData({ @@ -144,7 +144,7 @@ Page({ util.request(api.OrderDetail, { orderId: that.data.orderId }).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ orderInfo: res.data.orderInfo, orderGoods: res.data.orderGoods, @@ -172,7 +172,7 @@ Page({ util.request(api.OrderCancel, { orderId: that.data.orderId }, 'POST').then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { that.getOrderDetail(); } else { util.showErrorToast(res.errmsg); @@ -190,7 +190,7 @@ Page({ util.request(api.OrderDelete, { orderId: that.data.orderId }, 'POST').then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { wx.showToast({ title: '删除订单成功' }); @@ -216,7 +216,7 @@ Page({ util.request(api.OrderConfirm, { orderId: that.data.orderId }, 'POST').then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { wx.showToast({ title: '确认收货成功!' }); @@ -241,7 +241,7 @@ Page({ util.request(api.OrderCancel, { orderId: that.data.orderId }, 'POST').then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { wx.showToast({ title: '取消订单成功' }); diff --git a/pages/ucenter/order-list/index.js b/pages/ucenter/order-list/index.js index a403a3a..d0e07c3 100644 --- a/pages/ucenter/order-list/index.js +++ b/pages/ucenter/order-list/index.js @@ -44,7 +44,7 @@ Page({ getOrderInfo: function(e) { let that = this; util.request(api.OrderCountInfo).then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { let status = res.data; that.setData({ status: status @@ -59,7 +59,7 @@ Page({ size: that.data.size, page: that.data.allPage, }).then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { let count = res.data.count; that.setData({ allCount: count, @@ -126,7 +126,7 @@ Page({ util.request(api.OrderCancel, { orderId: orderId }, 'POST').then(function(res) { - if (res.errno === 0) { + if (res.code === 0) { wx.showToast({ title: '取消订单成功' }); diff --git a/pages/ucenter/settings/index.js b/pages/ucenter/settings/index.js index 1ed61f4..62603d1 100644 --- a/pages/ucenter/settings/index.js +++ b/pages/ucenter/settings/index.js @@ -59,8 +59,9 @@ Page({ }, getSettingsDetail() { let that = this; + util.request(api.SettingsDetail).then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { that.setData({ name: res.data.name, mobile: res.data.mobile, @@ -104,7 +105,7 @@ Page({ nickName: nickName, avatar: avatar, }, 'POST').then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { util.showErrorToast('保存成功'); wx.navigateBack() } diff --git a/project.config.json b/project.config.json index 81e5a18..15e5943 100644 --- a/project.config.json +++ b/project.config.json @@ -1,57 +1,40 @@ { - "description": "项目配置文件。", - "setting": { - "urlCheck": false, - "es6": true, - "postcss": true, - "preloadBackgroundData": false, - "minified": true, - "newFeature": true, - "coverView": true, - "autoAudits": false, - "showShadowRootInWxmlPanel": true, - "scopeDataCheck": false, - "checkInvalidKey": true, - "checkSiteMap": false, - "uploadWithSourceMap": true, - "babelSetting": { - "ignore": [], - "disablePlugins": [], - "outputPath": "" - } - }, - "compileType": "miniprogram", - "libVersion": "2.9.4", - "appid": "wxf3d768d1818218f1", - "projectname": "%e6%b5%b7%e9%a3%8e%e5%b0%8f%e5%ba%97", - "isGameTourist": false, - "scripts": { - "beforeCompile": "", - "beforePreview": "", - "beforeUpload": "" - }, - "simulatorType": "wechat", - "simulatorPluginLibVersion": {}, - "condition": { - "search": { - "current": -1, - "list": [] - }, - "conversation": { - "current": -1, - "list": [] - }, - "plugin": { - "current": -1, - "list": [] - }, - "game": { - "currentL": -1, - "list": [] - }, - "miniprogram": { - "current": 2, - "list": [] - } - } + "description": "项目配置文件。", + "setting": { + "urlCheck": false, + "es6": true, + "postcss": true, + "preloadBackgroundData": false, + "minified": true, + "newFeature": true, + "coverView": true, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "checkInvalidKey": true, + "checkSiteMap": false, + "uploadWithSourceMap": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "enhance": false, + "packNpmRelationList": [], + "ignoreUploadUnusedFiles": true + }, + "compileType": "miniprogram", + "simulatorType": "wechat", + "simulatorPluginLibVersion": {}, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 2 + }, + "libVersion": "2.9.4", + "packOptions": { + "ignore": [], + "include": [] + }, + "appid": "wx23d29bab9e02327f" } \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..42916ea --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "hioshop-miniprogram", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/services/pay.js b/services/pay.js index c5a5f7d..ed07016 100644 --- a/services/pay.js +++ b/services/pay.js @@ -8,7 +8,7 @@ function payOrder(orderId) { util.request(api.PayPrepayId, { orderId: orderId }).then((res) => { - if (res.errno === 0) { + if (res.code === 0) { const payParam = res.data; // 如果没有支付想直接支付成功,下面注释。 // ----------------------------------- diff --git a/services/user.js b/services/user.js index 47bdfb5..fa27134 100755 --- a/services/user.js +++ b/services/user.js @@ -18,8 +18,11 @@ function loginByWeixin() { code: code, userInfo: userInfo }, 'POST').then(res => { - if (res.errno === 0) { + + if (res.code === 0) { //存储用户信息 + console.log(44444444) + console.log(res.data) wx.setStorageSync('userInfo', res.data.userInfo); wx.setStorageSync('token', res.data.token); resolve(res); @@ -40,6 +43,7 @@ function loginByWeixin() { function checkLogin() { return new Promise(function(resolve, reject) { if (wx.getStorageSync('userInfo') && wx.getStorageSync('token')) { + console.log(1111111111) util.checkSession().then(() => { resolve(true); }).catch(() => { diff --git a/utils/util.js b/utils/util.js index ae8bc4f..60cd8c8 100644 --- a/utils/util.js +++ b/utils/util.js @@ -68,13 +68,14 @@ function testMobile(num) { */ function request(url, data = {}, method = "GET") { return new Promise(function(resolve, reject) { + wx.request({ url: url, data: data, method: method, header: { 'Content-Type': 'application/json', - 'X-Hioshop-Token': wx.getStorageSync('token') + 'Authorization': wx.getStorageSync('token') }, success: function(res) { if (res.statusCode == 200) { @@ -92,7 +93,7 @@ function request(url, data = {}, method = "GET") { // code: code, // userInfo: userInfo // }, 'POST').then(res => { - // if (res.errno === 0) { + // if (res.code === 0) { // //存储用户信息 // wx.setStorageSync('userInfo', res.data.userInfo); // wx.setStorageSync('token', res.data.token); @@ -243,7 +244,8 @@ function loginNow() { request(api.AuthLoginByWeixin, { code: res.code }, 'POST').then(function (res) { - if (res.errno === 0) { + if (res.code === 0) { + console.log(555555555) let userInfo = res.data.userInfo; wx.setStorageSync('token', res.data.token); wx.setStorageSync('userInfo', userInfo);