Skip to content

Commit

Permalink
API接口地址前缀修改,后续使用只需改 app.js 中的subDomain
Browse files Browse the repository at this point in the history
  • Loading branch information
JoneXiong committed Sep 14, 2018
1 parent 6d7e290 commit 8e93981
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 56 deletions.
16 changes: 8 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ App({
var that = this;
// 获取商城名称
wx.request({
url: 'https://api.it120.cc/'+ that.globalData.subDomain +'/config/get-value',
url: that.globalData.subDomain +'/config/get-value',
data: {
key: 'mallName'
},
Expand All @@ -15,7 +15,7 @@ App({
}
})
wx.request({
url: 'https://api.it120.cc/' + that.globalData.subDomain + '/score/send/rule',
url: that.globalData.subDomain + '/score/send/rule',
data: {
code: 'goodReputation'
},
Expand All @@ -26,7 +26,7 @@ App({
}
})
wx.request({
url: 'https://api.it120.cc/' + that.globalData.subDomain + '/config/get-value',
url: that.globalData.subDomain + '/config/get-value',
data: {
key: 'recharge_amount_min'
},
Expand All @@ -38,7 +38,7 @@ App({
})
// 获取砍价设置
wx.request({
url: 'https://api.it120.cc/' + that.globalData.subDomain + '/shop/goods/kanjia/list',
url: that.globalData.subDomain + '/shop/goods/kanjia/list',
data: {},
success: function (res) {
if (res.data.code == 0) {
Expand All @@ -53,7 +53,7 @@ App({
return
}
wx.request({
url: 'https://api.it120.cc/' + that.globalData.subDomain + '/user/check-token',
url: that.globalData.subDomain + '/user/check-token',
data: {
token: token
},
Expand All @@ -68,7 +68,7 @@ App({
sendTempleMsg: function (orderId, trigger, template_id, form_id, page, postJsonString){
var that = this;
wx.request({
url: 'https://api.it120.cc/' + that.globalData.subDomain + '/template-msg/put',
url: that.globalData.subDomain + '/template-msg/put',
method:'POST',
header: {
'content-type': 'application/x-www-form-urlencoded'
Expand All @@ -94,7 +94,7 @@ App({
sendTempleMsgImmediately: function (template_id, form_id, page, postJsonString) {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + that.globalData.subDomain + '/template-msg/put',
url: that.globalData.subDomain + '/template-msg/put',
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded'
Expand Down Expand Up @@ -122,7 +122,7 @@ App({
},
globalData:{
userInfo:null,
subDomain: "tz", // 如果你的域名是: https://api.it120.cc/abcd 那么这里只要填写 abcd
subDomain: "https://xxx/xxx",
version: "3.0.1",
shareProfile: '百款精品商品,总有一款适合您' // 首页转发的时候话术
}
Expand Down
6 changes: 3 additions & 3 deletions pages/address-add/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Page({
apiAddid = 0;
}
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/user/shipping-address/' + apiAddoRuPDATE,
url: app.globalData.subDomain + '/user/shipping-address/' + apiAddoRuPDATE,
data: {
token: wx.getStorageSync('token'),
id: apiAddid,
Expand Down Expand Up @@ -184,7 +184,7 @@ Page({
// 初始化原数据
wx.showLoading();
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/user/shipping-address/detail',
url: app.globalData.subDomain + '/user/shipping-address/detail',
data: {
token: wx.getStorageSync('token'),
id: id
Expand Down Expand Up @@ -242,7 +242,7 @@ Page({
success: function (res) {
if (res.confirm) {
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/user/shipping-address/delete',
url: app.globalData.subDomain + '/user/shipping-address/delete',
data: {
token: wx.getStorageSync('token'),
id: id
Expand Down
6 changes: 3 additions & 3 deletions pages/authorize/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Page({
let token = wx.getStorageSync('token');
if (token) {
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/user/check-token',
url: app.globalData.subDomain + '/user/check-token',
data: {
token: token
},
Expand All @@ -95,7 +95,7 @@ Page({
wx.login({
success: function (res) {
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/user/wxapp/login',
url: app.globalData.subDomain + '/user/wxapp/login',
data: {
code: res.code
},
Expand Down Expand Up @@ -135,7 +135,7 @@ Page({
var encryptedData = res.encryptedData;
// 下面开始调用注册接口
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/user/wxapp/register/complex',
url: app.globalData.subDomain + '/user/wxapp/register/complex',
data: { code: code, encryptedData: encryptedData, iv: iv }, // 设置请求的 参数
success: (res) => {
wx.hideLoading();
Expand Down
10 changes: 5 additions & 5 deletions pages/goods-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Page({
}
})
wx.request({
url: 'https://api.it120.cc/'+ app.globalData.subDomain +'/shop/goods/detail',
url: app.globalData.subDomain +'/shop/goods/detail',
data: {
id: e.id
},
Expand Down Expand Up @@ -195,7 +195,7 @@ Page({
// 计算当前价格
if (canSubmit) {
wx.request({
url: 'https://api.it120.cc/'+ app.globalData.subDomain +'/shop/goods/price',
url: app.globalData.subDomain +'/shop/goods/price',
data: {
goodsId: that.data.goodsDetail.basicInfo.id,
propertyChildIds:propertyChildIds
Expand Down Expand Up @@ -415,7 +415,7 @@ Page({
reputation: function (goodsId) {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/shop/goods/reputation',
url: app.globalData.subDomain + '/shop/goods/reputation',
data: {
goodsId: goodsId
},
Expand All @@ -432,7 +432,7 @@ Page({
getVideoSrc: function (videoId) {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/media/video/detail',
url: app.globalData.subDomain + '/media/video/detail',
data: {
videoId: videoId
},
Expand Down Expand Up @@ -472,7 +472,7 @@ Page({
return;
}
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/shop/goods/kanjia/join',
url: app.globalData.subDomain + '/shop/goods/kanjia/join',
data: {
kjid: that.data.curGoodsKanjia.id,
token: wx.getStorageSync('token')
Expand Down
12 changes: 6 additions & 6 deletions pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Page({
title: wx.getStorageSync('mallName')
})
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/banner/list',
url: app.globalData.subDomain + '/banner/list',
data: {
key: 'mallName'
},
Expand All @@ -77,7 +77,7 @@ Page({
}
}),
wx.request({
url: 'https://api.it120.cc/'+ app.globalData.subDomain +'/shop/goods/category/all',
url: app.globalData.subDomain +'/shop/goods/category/all',
success: function(res) {
var categories = [{id:0, name:"全部"}];
if (res.data.code == 0) {
Expand Down Expand Up @@ -108,7 +108,7 @@ Page({
console.log(categoryId)
var that = this;
wx.request({
url: 'https://api.it120.cc/'+ app.globalData.subDomain +'/shop/goods/list',
url: app.globalData.subDomain +'/shop/goods/list',
data: {
categoryId: categoryId,
nameLike: that.data.searchInput
Expand Down Expand Up @@ -137,7 +137,7 @@ Page({
getCoupons: function () {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/discounts/coupons',
url: app.globalData.subDomain + '/discounts/coupons',
data: {
type: ''
},
Expand All @@ -154,7 +154,7 @@ Page({
gitCoupon : function (e) {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/discounts/fetch',
url: app.globalData.subDomain + '/discounts/fetch',
data: {
id: e.currentTarget.dataset.id,
token: wx.getStorageSync('token')
Expand Down Expand Up @@ -223,7 +223,7 @@ Page({
getNotice: function () {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/notice/list',
url: app.globalData.subDomain + '/notice/list',
data: { pageSize :5},
success: function (res) {
if (res.data.code == 0) {
Expand Down
10 changes: 5 additions & 5 deletions pages/kanjia/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Page({
this.data.joiner = e.joiner;
var that = this;
wx.request({
url: 'https://api.it120.cc/'+ app.globalData.subDomain +'/shop/goods/detail',
url: app.globalData.subDomain +'/shop/goods/detail',
data: {
id: e.id
},
Expand Down Expand Up @@ -59,7 +59,7 @@ Page({
getVideoSrc: function (videoId) {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/media/video/detail',
url: app.globalData.subDomain + '/media/video/detail',
data: {
videoId: videoId
},
Expand All @@ -75,7 +75,7 @@ Page({
getKanjiaInfo: function (kjid, joiner) {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/shop/goods/kanjia/info',
url: app.globalData.subDomain + '/shop/goods/kanjia/info',
data: {
kjid: kjid,
joiner: joiner,
Expand All @@ -98,7 +98,7 @@ Page({
getKanjiaInfoMyHelp: function (kjid, joiner) {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/shop/goods/kanjia/myHelp',
url: app.globalData.subDomain + '/shop/goods/kanjia/myHelp',
data: {
kjid: kjid,
joinerUser: joiner,
Expand All @@ -117,7 +117,7 @@ Page({
helpKanjia: function () {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/shop/goods/kanjia/help',
url: app.globalData.subDomain + '/shop/goods/kanjia/help',
data: {
kjid: that.data.kjId,
joinerUser: that.data.joiner,
Expand Down
10 changes: 5 additions & 5 deletions pages/my/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Page({
}
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/user/wxapp/bindMobile',
url: app.globalData.subDomain + '/user/wxapp/bindMobile',
data: {
token: wx.getStorageSync('token'),
encryptedData: e.detail.encryptedData,
Expand All @@ -72,7 +72,7 @@ Page({
getUserApiInfo: function () {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/user/detail',
url: app.globalData.subDomain + '/user/detail',
data: {
token: wx.getStorageSync('token')
},
Expand All @@ -90,7 +90,7 @@ Page({
getUserAmount: function () {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/user/amount',
url: app.globalData.subDomain + '/user/amount',
data: {
token: wx.getStorageSync('token')
},
Expand All @@ -109,7 +109,7 @@ Page({
checkScoreSign: function () {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/score/today-signed',
url: app.globalData.subDomain + '/score/today-signed',
data: {
token: wx.getStorageSync('token')
},
Expand All @@ -125,7 +125,7 @@ Page({
scoresign: function () {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/score/sign',
url: app.globalData.subDomain + '/score/sign',
data: {
token: wx.getStorageSync('token')
},
Expand Down
2 changes: 1 addition & 1 deletion pages/mycoupons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Page({
getMyCoupons: function () {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/discounts/my',
url: app.globalData.subDomain + '/discounts/my',
data: {
token: wx.getStorageSync('token'),
status: 0
Expand Down
2 changes: 1 addition & 1 deletion pages/notice/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Page({
onLoad: function (options) {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/notice/detail',
url: app.globalData.subDomain + '/notice/detail',
data: {
id: options.id
},
Expand Down
6 changes: 3 additions & 3 deletions pages/order-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Page({
onShow : function () {
var that = this;
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/order/detail',
url: app.globalData.subDomain + '/order/detail',
data: {
token: wx.getStorageSync('token'),
id: that.data.orderId
Expand Down Expand Up @@ -63,7 +63,7 @@ Page({
if (res.confirm) {
wx.showLoading();
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/order/delivery',
url: app.globalData.subDomain + '/order/delivery',
data: {
token: wx.getStorageSync('token'),
orderId: orderId
Expand Down Expand Up @@ -112,7 +112,7 @@ Page({
postJsonString.reputations = reputations;
wx.showLoading();
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/order/reputation',
url: app.globalData.subDomain + '/order/reputation',
data: {
postJsonString: postJsonString
},
Expand Down
Loading

2 comments on commit 8e93981

@fengyunsen
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我的天,为什么做一个全局的参数?这样改一个地方就可以全部生效。。。。

@JoneXiong
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fengyunsen “改一个地方就可以全部生效”这样有问题?

Please sign in to comment.