@@ -1,83 +1,54 @@ | |||||
let config = require('./config/config.js') | let config = require('./config/config.js') | ||||
const Http = require("./utils/HttpBasics"); | const Http = require("./utils/HttpBasics"); | ||||
App({ | App({ | ||||
data: { | |||||
}, | |||||
onLaunch: function (options) { | |||||
// var that = this; | |||||
data: {}, | |||||
onLaunch: function(options) { | |||||
var that = this; | |||||
this.globalData.sceneAddress = options.scene; | this.globalData.sceneAddress = options.scene; | ||||
this.getLocation() | this.getLocation() | ||||
this.getUserInfo() | this.getUserInfo() | ||||
// 登录 | // 登录 | ||||
wx.login({ | wx.login({ | ||||
success: function(res) { | |||||
var code = res.code; | |||||
console.log(code); | |||||
wx.request({ | |||||
success: ({ | |||||
code | |||||
}) => { | |||||
Http.post({ | |||||
url: config.api.login, | url: config.api.login, | ||||
data: { | data: { | ||||
appId: config.weapp.AppId, | appId: config.weapp.AppId, | ||||
code: code, | code: code, | ||||
screneAddress: options.scene | |||||
}, | |||||
method: "POST", | |||||
success: function (res) { | |||||
console.log(res); | |||||
that.globalData.token = res.data.token; | |||||
console.log(that.globalData.token) | |||||
that.globalData.openId = res.data.openId; | |||||
//由于这里是网络请求,可能会在 Page.onLoad 之后才返回 | |||||
// 所以此处加入 callback 以防止这种情况 | |||||
if (that.openIdCallback) { | |||||
console.log(res.data.openId); | |||||
that.openIdCallback(res.data.openId); | |||||
} | |||||
wx.request({ | |||||
url: config.api.checkUserStatus, | |||||
header: { | |||||
"token": that.globalData.token | |||||
}, | |||||
success: function (res) { | |||||
console.log(res); | |||||
//如果是新用户未获取unionId | |||||
if (res.data.code == config.ErrorCode.NICK_NOT_AUTH) { | |||||
wx.redirectTo({ | |||||
url: '../getuserinfo/index', | |||||
}) | |||||
} | |||||
//如果是跳转到首页 | |||||
else if (res.data.code == 200) { | |||||
// 老用户跳转首页 | |||||
} else { | |||||
wx.showToast({ | |||||
title: res.data.message, | |||||
}) | |||||
} | |||||
}, | |||||
fail: function(res) { | |||||
wx.showToast({ | |||||
title: res.data.message, | |||||
sceneAddress: this.globalData.sceneAddress, | |||||
} | |||||
}).then(res => { | |||||
// console.log("req",res); | |||||
this.globalData.token = res.data.token; | |||||
Http.setToken(res.data.token) | |||||
Http.post({ | |||||
url: config.api.checkUserStatus, | |||||
data: {} // | |||||
}).then( | |||||
function(res) { | |||||
}, | |||||
function(error) { | |||||
console.log(error) | |||||
if (error.code == 11004) { | |||||
// 用户昵称未授权 | |||||
wx.redirectTo({ | |||||
url: '../getuserinfo/index', | |||||
}) | }) | ||||
} | } | ||||
}) | }) | ||||
} | |||||
}) | }) | ||||
} | } | ||||
}) | }) | ||||
// setTimeout(() => { | |||||
// this.globalData.market={ | |||||
// name:"陕西大悦城" | |||||
// } | |||||
// }, 1000); | |||||
}, | }, | ||||
/** | /** | ||||
* 获取地址位置信息 | * 获取地址位置信息 | ||||
*/ | */ | ||||
getLocation: function () { | |||||
getLocation: function() { | |||||
wx.getLocation({ | wx.getLocation({ | ||||
type: 'wgs84', | type: 'wgs84', | ||||
success: function (res) { | |||||
success: function(res) { | |||||
console.log("getLocation", res); | console.log("getLocation", res); | ||||
}, | }, | ||||
fail: error => { | fail: error => { | ||||
@@ -88,7 +59,7 @@ App({ | |||||
/** | /** | ||||
* 获取用户信息 | * 获取用户信息 | ||||
*/ | */ | ||||
getUserInfo: function () { | |||||
getUserInfo: function() { | |||||
// 获取用户信息 | // 获取用户信息 | ||||
wx.getSetting({ | wx.getSetting({ | ||||
success: res => { | success: res => { | ||||
@@ -1,6 +1,8 @@ | |||||
{ | { | ||||
"pages":[ | "pages":[ | ||||
"pages/index/index", | "pages/index/index", | ||||
"pages/getuserinfo/index", | |||||
"pages/getphoneInfo/index", | |||||
"pages/market/index", | "pages/market/index", | ||||
"pages/user/index", | "pages/user/index", | ||||
"pages/coupons/details/index", | "pages/coupons/details/index", | ||||
@@ -1,265 +0,0 @@ | |||||
const Promise = require('../utils/es6-promise.min').Promise | |||||
let config = require("../config/config.js"); | |||||
var app = getApp(); | |||||
const func = { | |||||
wxLogin: function (scene) { | |||||
return new Promise((resolve, reject) => { | |||||
wx.login({ | |||||
success: function (res) { | |||||
resolve(res) | |||||
}, | |||||
fail: function (err) { | |||||
reject(err) | |||||
}, | |||||
complete: function (res) { | |||||
//console.log("wxLogin complete:" + res) | |||||
} | |||||
}) | |||||
}) | |||||
}, | |||||
/** | |||||
* 授权后获取用户的昵称,unionId等信息 | |||||
*/ | |||||
getUserInfo: function (encryptedData, iv) { | |||||
console.log(app.globalData.openId) | |||||
return new Promise((resolve, reject) => { | |||||
wx.request({ | |||||
url: config.api.getUserInfo, | |||||
header: { | |||||
"content-type": "application/json;charset=UTF-8", | |||||
"token": app.globalData.token | |||||
}, | |||||
data: { | |||||
encryptedData: encryptedData, | |||||
iv: iv, | |||||
}, | |||||
method: "POST", | |||||
success: function (res) { | |||||
resolve(res) | |||||
}, | |||||
fail: function (err) { | |||||
reject(err) | |||||
}, | |||||
complete: function (res) { | |||||
//console.log("getUserInfo complete:" + res) | |||||
} | |||||
}) | |||||
}) | |||||
}, | |||||
/** | |||||
* 授权后获取用户的手机号 | |||||
*/ | |||||
getUserPhone: function (encryptedData, iv) { | |||||
return new Promise((resolve, reject) => { | |||||
wx.request({ | |||||
url: config.api.getUserPhone, | |||||
data: { | |||||
encryptedData: encryptedData, | |||||
iv: iv, | |||||
}, | |||||
header: { | |||||
"content-type": "application/json;charset=UTF-8", | |||||
"token": app.globalData.token | |||||
}, | |||||
method: "POST", | |||||
success: function (res) { | |||||
resolve(res) | |||||
}, | |||||
fail: function (err) { | |||||
reject(err) | |||||
}, | |||||
complete: function (res) { | |||||
//console.log("getUserInfo complete:" + res) | |||||
} | |||||
}) | |||||
}) | |||||
}, | |||||
/** | |||||
* 优惠券查询 | |||||
*/ | |||||
getCouponList: function (pageNum, pageSize) { | |||||
return new Promise((resolve, reject) => { | |||||
wx.request({ | |||||
url: config.api.couponList, | |||||
header: { | |||||
"content-type": "application/json;charset=UTF-8", | |||||
"token": app.globalData.token | |||||
}, | |||||
method: "Get", | |||||
data: { | |||||
pageNum: pageNum, | |||||
pageSize: pageSize | |||||
}, | |||||
success: function (res) { | |||||
resolve(res) | |||||
}, | |||||
fail: function (err) { | |||||
reject(err) | |||||
}, | |||||
complete: function (res) { | |||||
console.log(res) | |||||
} | |||||
}) | |||||
}) | |||||
}, | |||||
/** | |||||
* 优惠券详情 | |||||
*/ | |||||
getCouponDetail: function (couponId) { | |||||
return new Promise((resolve, reject) => { | |||||
wx.request({ | |||||
url: config.api.couponDetail, | |||||
header: { | |||||
"content-type": "application/json;charset=UTF-8", | |||||
"token": app.globalData.token | |||||
}, | |||||
method: "Get", | |||||
data: { | |||||
id: couponId | |||||
}, | |||||
success: function (res) { | |||||
resolve(res) | |||||
}, | |||||
fail: function (err) { | |||||
reject(err) | |||||
}, | |||||
complete: function (res) { | |||||
console.log(res) | |||||
} | |||||
}) | |||||
}) | |||||
}, | |||||
/** | |||||
* 订单下单 | |||||
*/ | |||||
orderSave: function (couponId) { | |||||
return new Promise((resolve, reject) => { | |||||
wx.request({ | |||||
url: config.api.orderSave, | |||||
header: { | |||||
'token': app.globalData.token | |||||
}, | |||||
data: { | |||||
couponId: couponId, | |||||
token: app.globalData.token | |||||
}, | |||||
method: "POST", | |||||
success: function (res) { | |||||
resolve(res) | |||||
}, | |||||
fail: function (err) { | |||||
reject(err) | |||||
}, | |||||
complete: function (res) { | |||||
console.log(res) | |||||
} | |||||
}) | |||||
}) | |||||
}, | |||||
/** | |||||
* 支付订单 | |||||
*/ | |||||
payOrderCreate: function (orderId) { | |||||
return new Promise((resolve, reject) => { | |||||
wx.request({ | |||||
url: config.api.payOrderCreate, | |||||
header: { | |||||
"token": app.globalData.token | |||||
}, | |||||
data: { | |||||
orderId: orderId, | |||||
token: app.globalData.token | |||||
}, | |||||
method: "POST", | |||||
success: function (res) { | |||||
resolve(res) | |||||
}, | |||||
fail: function (err) { | |||||
reject(err) | |||||
}, | |||||
complete: function (res) { | |||||
console.log(res) | |||||
} | |||||
}) | |||||
}) | |||||
}, | |||||
/** | |||||
* 支付订单更新 | |||||
*/ | |||||
payOrderUpdate: function (orderId, payOrderId, status, reason) { | |||||
return new Promise((resolve, reject) => { | |||||
wx.request({ | |||||
url: config.api.payOrderUpdate, | |||||
header: { | |||||
"token": app.globalData.token | |||||
}, | |||||
data: { | |||||
payOrderId: payOrderId, | |||||
orderId: orderId, | |||||
status: status, | |||||
reason: reason | |||||
}, | |||||
method: "POST", | |||||
success: function (res) { | |||||
resolve(res) | |||||
}, | |||||
fail: function (err) { | |||||
reject(err) | |||||
}, | |||||
complete: function (res) { | |||||
console.log(res) | |||||
} | |||||
}) | |||||
}) | |||||
}, | |||||
refundCouponOrder: function (couponOrderId) { | |||||
return new Promise((resolve, reject) => { | |||||
wx.request({ | |||||
url: config.api.refundCouponOrder, | |||||
header: { | |||||
"token": app.globalData.token | |||||
}, | |||||
data: { | |||||
couponOrderId: couponOrderId, | |||||
token: app.globalData.token | |||||
}, | |||||
method: "POST", | |||||
success: function (res) { | |||||
resolve(res) | |||||
}, | |||||
fail: function (err) { | |||||
reject(err) | |||||
}, | |||||
complete: function (res) { | |||||
console.log(res) | |||||
} | |||||
}) | |||||
}) | |||||
}, | |||||
refundOrderCreate: function (orderId, payOrderId) { | |||||
return new Promise((resolve, reject) => { | |||||
wx.request({ | |||||
url: config.api.refundOrdercCreate, | |||||
header: { | |||||
"token": app.globalData.token | |||||
}, | |||||
data: { | |||||
payOrderId: payOrderId, | |||||
orderId: orderId, | |||||
token: app.globalData.token | |||||
}, | |||||
method: "POST", | |||||
success: function (res) { | |||||
resolve(res) | |||||
}, | |||||
fail: function (err) { | |||||
reject(err) | |||||
}, | |||||
complete: function (res) { | |||||
console.log(res) | |||||
} | |||||
}) | |||||
}) | |||||
}, | |||||
} | |||||
module.exports = func; |
@@ -1,26 +1,24 @@ | |||||
var url = 'https://ciformall.youlane.cn' | |||||
//var url = 'http://7479f9de.ngrok.io' | |||||
var apiPrefix = url + '/C'; | |||||
var config = { | var config = { | ||||
name: "富茂", | name: "富茂", | ||||
url: "https://ciformall.youlane.cn/C", | |||||
url: "https://ciformall.youlane.cn/C/api", | |||||
//url: "http://dac6735a.ngrok.io/C/api", | |||||
api: { | api: { | ||||
/** | /** | ||||
* 接口用途:login | * 接口用途:login | ||||
*/ | */ | ||||
login: '/api/user/login', | |||||
login: '/user/login', | |||||
/** | /** | ||||
* 授权后获取用户的昵称,unionId等信息 | * 授权后获取用户的昵称,unionId等信息 | ||||
*/ | */ | ||||
getUserInfo: '/api/user/getUserInfo', | |||||
getUserInfo: '/user/getUserInfo', | |||||
/** | /** | ||||
* 接口用途:授权后获取用户的手机号 | * 接口用途:授权后获取用户的手机号 | ||||
*/ | */ | ||||
getUserPhone: '/api/user/getUserPhone', | |||||
getUserPhone: '/user/getUserPhone', | |||||
/** | /** | ||||
* 检查用户授权状态 | * 检查用户授权状态 | ||||
*/ | */ | ||||
checkUserStatus: '/api/user/checkUserStatus', | |||||
checkUserStatus: '/user/checkUserStatus', | |||||
/** | /** | ||||
* 优惠券查询 | * 优惠券查询 | ||||
*/ | */ | ||||
@@ -29,30 +27,26 @@ var config = { | |||||
* 优惠券详情 | * 优惠券详情 | ||||
*/ | */ | ||||
couponDetail: '/wxCoupon/findById', | couponDetail: '/wxCoupon/findById', | ||||
/** | |||||
* 业态查询 | |||||
*/ | |||||
couponChannelList: '/wxCouponChannel/list', | |||||
/** | /** | ||||
* 下订单 | * 下订单 | ||||
*/ | */ | ||||
orderSave: '/api/order/save', | |||||
orderSave: '/order/save', | |||||
/** | /** | ||||
* 支付订单 | * 支付订单 | ||||
*/ | */ | ||||
payOrderCreate: '/api/pay/create', | |||||
payOrderCreate: '/pay/create', | |||||
/** | /** | ||||
* 订单状态更新 | * 订单状态更新 | ||||
*/ | */ | ||||
payOrderUpdate: '/api/pay/updatePayOrder', | |||||
payOrderUpdate: '/pay/updatePayOrder', | |||||
/** | /** | ||||
* 订单列表 | * 订单列表 | ||||
*/ | */ | ||||
orderList: '/api/order/list', | |||||
/** | |||||
* 退券 | |||||
*/ | |||||
refundCouponOrder: '/api/couponOrder/refund', | |||||
/** | |||||
* 退款申请 | |||||
*/ | |||||
refundOrdercCreate: '/api/refund/create', | |||||
orderList: '/order/list', | |||||
}, | }, | ||||
weapp: { | weapp: { | ||||
@@ -64,7 +58,9 @@ var config = { | |||||
PHONE_IS_ENCRYPTED: 11006, | PHONE_IS_ENCRYPTED: 11006, | ||||
}, | }, | ||||
}; | }; | ||||
/* | |||||
for (var key in config.api) { | for (var key in config.api) { | ||||
config.api[key] = apiPrefix + config.api[key]; | config.api[key] = apiPrefix + config.api[key]; | ||||
} | } | ||||
*/ | |||||
module.exports = config; | module.exports = config; |
@@ -1,4 +1,4 @@ | |||||
let Common = require('../../../common/common.js') | |||||
var config = require('../../../config/config.js'); | |||||
var app = getApp() | var app = getApp() | ||||
const Http = require("../../../utils/HttpBasics") | const Http = require("../../../utils/HttpBasics") | ||||
Page({ | Page({ | ||||
@@ -128,134 +128,4 @@ Page({ | |||||
}) | }) | ||||
}, | }, | ||||
orderfunc() { | |||||
var that = this | |||||
/* | |||||
var couponOrderId = '189631451703017472'; | |||||
var orderId = '189631451640102912'; | |||||
var payOrderId = '189631462532710400'; | |||||
var status = 1; | |||||
var reason = ''; | |||||
Common.refundCouponOrder(couponOrderId) | |||||
.then(res => { | |||||
console.log(res); | |||||
if (res.data.code == 200) { | |||||
Common.refundOrderCreate(orderId, payOrderId) | |||||
.then(res => { | |||||
console.log(res); | |||||
}) | |||||
} else { | |||||
wx.showToast({ | |||||
title: res.data.message, | |||||
duration: 3000 | |||||
}) | |||||
} | |||||
}) | |||||
*/ | |||||
/* | |||||
Common.payOrderUpdate(orderId, payOrderId, status, reason) | |||||
.then(res =>{ | |||||
console.log(res); | |||||
}) | |||||
*/ | |||||
wx.showLoading({ | |||||
title: '加载中...', | |||||
}) | |||||
var couponId = '' + this.data.couponId; | |||||
console.log("order coupon: " + couponId) | |||||
Common.orderSave(couponId) | |||||
.then(res => { | |||||
console.log(res) | |||||
if (res.data.code == 200) { | |||||
var orderId = '' + res.data.data.id; | |||||
this.setData({ | |||||
orderId: '' + res.data.data.id | |||||
}) | |||||
if (res.data.data.payment > 0) { | |||||
return Common.payOrderCreate(orderId) | |||||
} else { | |||||
Common.payOrderUpdate(orderId, "0", 1) // 支付成功 | |||||
.then(res => { | |||||
wx.showToast({ | |||||
title: res.data.message, | |||||
duration: 3000 | |||||
}) | |||||
}) | |||||
} | |||||
} else { | |||||
wx.hideLoading(); | |||||
wx.showToast({ | |||||
title: res.data.message, | |||||
duration: 3000 | |||||
}) | |||||
} | |||||
}) | |||||
.then(res => { | |||||
console.log(res) | |||||
var payOrderId = '' + res.data.data.payOrderId; | |||||
if (res.data.code == 200) { | |||||
wx.requestPayment({ | |||||
timeStamp: res.data.data.timeStamp, | |||||
nonceStr: res.data.data.nonceStr, | |||||
package: res.data.data.package, | |||||
signType: 'MD5', | |||||
paySign: res.data.data.paySign, | |||||
'success': function (res) { | |||||
Common.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功 | |||||
console.log(res); | |||||
console.log('支付成功'); | |||||
wx.showToast({ | |||||
title: '购买成功', | |||||
duration: 2500 | |||||
}) | |||||
wx.navigateBack({ | |||||
delta: 2 | |||||
}) | |||||
}, | |||||
'fail': function (res) { | |||||
Common.payOrderUpdate(orderId, payOrderId, 2); // 支付失败 | |||||
console.log(res) | |||||
console.log('支付失败'); | |||||
return; | |||||
}, | |||||
'complete': function (res) { | |||||
console.log(res); | |||||
console.log('支付完成'); | |||||
var url = that.data.url; | |||||
console.log('get url', url) | |||||
if (res.errMsg == 'requestPayment:ok') { | |||||
wx.showModal({ | |||||
title: '提示', | |||||
content: '支付成功' | |||||
}); | |||||
if (url) { | |||||
setTimeout(function () { | |||||
wx.redirectTo({ | |||||
url: '/pages' + url | |||||
}); | |||||
}, 2000) | |||||
} else { | |||||
setTimeout(() => { | |||||
wx.navigateBack() | |||||
}, 2000) | |||||
} | |||||
} else { | |||||
wx.showModal({ | |||||
title: '错误提示', | |||||
content: res.errMsg | |||||
}); | |||||
} | |||||
return; | |||||
} | |||||
}) | |||||
} else { | |||||
wx.showModal({ | |||||
title: '错误提示', | |||||
content: res.data.message | |||||
}); | |||||
} | |||||
}) | |||||
wx.hideLoading(); | |||||
} | |||||
}) | }) |
@@ -45,6 +45,6 @@ | |||||
</view> | </view> | ||||
</view> | </view> | ||||
<view class="buy-view app-border-top"> | <view class="buy-view app-border-top"> | ||||
<button bindtap='newOrderfunc' class='buy'>立即购买</button> | |||||
<button bindtap='orderfunc' class='buy'>立即购买</button> | |||||
</view> | </view> | ||||
</view> | </view> |
@@ -1,42 +1,42 @@ | |||||
var config = require('../../config/config.js'); | var config = require('../../config/config.js'); | ||||
var Common = require('../../common/common.js'); | |||||
const Http = require("../../utils/HttpBasics"); | |||||
var app = getApp(); | var app = getApp(); | ||||
Page({ | Page({ | ||||
data: { | data: { | ||||
canIUse: wx.canIUse('button.open-type.getPhoneNumber') | canIUse: wx.canIUse('button.open-type.getPhoneNumber') | ||||
}, | }, | ||||
onLoad: function (options) { | |||||
onLoad: function(options) { | |||||
var that = this; | var that = this; | ||||
}, | }, | ||||
getPhoneNumber: function (e) { | |||||
getPhoneNumber: function(e) { | |||||
var that = this; | var that = this; | ||||
var iv = e.detail.iv; | var iv = e.detail.iv; | ||||
var encryptedData = e.detail.encryptedData; | var encryptedData = e.detail.encryptedData; | ||||
Common.getUserPhone(encryptedData, iv) | |||||
.then(function (res) { | |||||
console.log(res); | |||||
/** | |||||
* code:0 授权手机号成功 | |||||
* code:1 授权手机号失败 | |||||
*/ | |||||
if (res.data.code == 0) { | |||||
Http.post({ | |||||
url: config.api.getUserPhone, | |||||
data: { | |||||
encryptedData: encryptedData, | |||||
iv: iv, | |||||
} | |||||
}) | |||||
.then(function(res) { | |||||
console.log(res); | |||||
app.globalData.phone = res.data.phone; | app.globalData.phone = res.data.phone; | ||||
wx.showToast({ | wx.showToast({ | ||||
title: res.data.msg, | title: res.data.msg, | ||||
icon: "success", | icon: "success", | ||||
success: function (res) { | |||||
success: function(res) { | |||||
wx.redirectTo({ | wx.redirectTo({ | ||||
url: '../login/login', | url: '../login/login', | ||||
}) | }) | ||||
} | } | ||||
}) | }) | ||||
} | |||||
else if (res.data.code == 1) { | |||||
}, | |||||
function(error) { | |||||
wx.showToast({ | wx.showToast({ | ||||
title: '请重新授权手机号', | title: '请重新授权手机号', | ||||
icon: "none", | icon: "none", | ||||
}) | }) | ||||
} | |||||
}) | |||||
}) | |||||
} | } | ||||
}) | }) |
@@ -1,6 +1,6 @@ | |||||
var config = require('../../config/config.js'); | var config = require('../../config/config.js'); | ||||
var Common = require('../../common/common.js'); | |||||
var app = getApp(); | var app = getApp(); | ||||
const Http = require("../../utils/HttpBasics"); | |||||
Page({ | Page({ | ||||
data: { | data: { | ||||
canIUse: wx.canIUse('button.open-type.getUserInfo') | canIUse: wx.canIUse('button.open-type.getUserInfo') | ||||
@@ -15,26 +15,25 @@ Page({ | |||||
var encryptedData = e.detail.encryptedData; | var encryptedData = e.detail.encryptedData; | ||||
console.log(iv) | console.log(iv) | ||||
console.log(encryptedData) | console.log(encryptedData) | ||||
Common.getUserInfo(encryptedData, iv) | |||||
.then(res => { | |||||
console.log(res); | |||||
/** | |||||
* 1:用户拒绝授权 | |||||
* 0:用户同意授权 | |||||
*/ | |||||
if(res.data.code == 0){ | |||||
Http.post({ | |||||
url: config.api.getUserInfo, | |||||
data: { | |||||
encryptedData: encryptedData, | |||||
iv: iv, | |||||
} | |||||
}) | |||||
.then(function(res) { | |||||
console.log(res); | |||||
//返回主页 | //返回主页 | ||||
wx.redirectTo({ | wx.redirectTo({ | ||||
url: '../index/index', | url: '../index/index', | ||||
}) | }) | ||||
} | |||||
else if(res.data.code == 1){ | |||||
}, function(error) { | |||||
wx.showToast({ | wx.showToast({ | ||||
title: '请授权个人信息', | title: '请授权个人信息', | ||||
icon:"none" | |||||
icon: "none" | |||||
}) | }) | ||||
} | } | ||||
}) | |||||
} | |||||
) | |||||
}, | |||||
}) | }) |
@@ -1,4 +1,5 @@ | |||||
// pages/index/sw/index.js | // pages/index/sw/index.js | ||||
let config = require('../../../config/config.js') | |||||
let Http = require('../../../utils/HttpBasics') | let Http = require('../../../utils/HttpBasics') | ||||
Component({ | Component({ | ||||
/** | /** | ||||
@@ -52,7 +53,7 @@ Component({ | |||||
}, | }, | ||||
ready() { | ready() { | ||||
Http.get({ | Http.get({ | ||||
url: "/wxCouponChannel/list", data: { | |||||
url: config.api.couponChannelList, data: { | |||||
pageNum: 1, | pageNum: 1, | ||||
pageSize: 10 | pageSize: 10 | ||||
} | } | ||||
@@ -96,17 +96,17 @@ class HttpBasics { | |||||
if (res.statusCode == 200) { | if (res.statusCode == 200) { | ||||
// 服务器code 200 成功 | // 服务器code 200 成功 | ||||
if (res.data.code == 200) { | if (res.data.code == 200) { | ||||
resolve(res.data.data); | |||||
resolve(res.data); | |||||
} else { | } else { | ||||
wx.hideLoading(); | wx.hideLoading(); | ||||
wx.showToast({ | wx.showToast({ | ||||
title: res.data.message | title: res.data.message | ||||
}) | }) | ||||
reject(res.data.message); | |||||
reject(res.data); | |||||
} | } | ||||
} else { | } else { | ||||
console.error("请求出错:", res); | console.error("请求出错:", res); | ||||
reject(res.errMsg); | |||||
reject(res.data); | |||||
} | } | ||||
} | } | ||||
/** 日志 */ | /** 日志 */ | ||||