diff --git a/common/js/data.js b/common/js/data.js
index 33a2209..a5aecc1 100644
--- a/common/js/data.js
+++ b/common/js/data.js
@@ -1211,6 +1211,182 @@ const myAddressList = [{
}],
address: '同心镇同心村同心路88号',
isDefault: false
+}, {
+ id: 2,
+ person2Contact: '卢翰',
+ phone: '12434455432',
+ area: [{
+ id: 1,
+ name: '广西壮族自治区'
+ }, {
+ id: 2,
+ name: '梧桐洲'
+ }, {
+ id: 3,
+ name: '藤县'
+ }],
+ address: '同心镇同心村同心路88号',
+ isDefault: false
+}, {
+ id: 2,
+ person2Contact: '卢翰',
+ phone: '12434455432',
+ area: [{
+ id: 1,
+ name: '广西壮族自治区'
+ }, {
+ id: 2,
+ name: '梧桐洲'
+ }, {
+ id: 3,
+ name: '藤县'
+ }],
+ address: '同心镇同心村同心路88号',
+ isDefault: false
+}, {
+ id: 2,
+ person2Contact: '卢翰',
+ phone: '12434455432',
+ area: [{
+ id: 1,
+ name: '广西壮族自治区'
+ }, {
+ id: 2,
+ name: '梧桐洲'
+ }, {
+ id: 3,
+ name: '藤县'
+ }],
+ address: '同心镇同心村同心路88号',
+ isDefault: false
+}, {
+ id: 2,
+ person2Contact: '卢翰',
+ phone: '12434455432',
+ area: [{
+ id: 1,
+ name: '广西壮族自治区'
+ }, {
+ id: 2,
+ name: '梧桐洲'
+ }, {
+ id: 3,
+ name: '藤县'
+ }],
+ address: '同心镇同心村同心路88号',
+ isDefault: false
+}, {
+ id: 2,
+ person2Contact: '卢翰',
+ phone: '12434455432',
+ area: [{
+ id: 1,
+ name: '广西壮族自治区'
+ }, {
+ id: 2,
+ name: '梧桐洲'
+ }, {
+ id: 3,
+ name: '藤县'
+ }],
+ address: '同心镇同心村同心路88号',
+ isDefault: false
+}, {
+ id: 2,
+ person2Contact: '卢翰',
+ phone: '12434455432',
+ area: [{
+ id: 1,
+ name: '广西壮族自治区'
+ }, {
+ id: 2,
+ name: '梧桐洲'
+ }, {
+ id: 3,
+ name: '藤县'
+ }],
+ address: '同心镇同心村同心路88号',
+ isDefault: false
+}, {
+ id: 2,
+ person2Contact: '卢翰',
+ phone: '12434455432',
+ area: [{
+ id: 1,
+ name: '广西壮族自治区'
+ }, {
+ id: 2,
+ name: '梧桐洲'
+ }, {
+ id: 3,
+ name: '藤县'
+ }],
+ address: '同心镇同心村同心路88号',
+ isDefault: false
+}, {
+ id: 2,
+ person2Contact: '卢翰',
+ phone: '12434455432',
+ area: [{
+ id: 1,
+ name: '广西壮族自治区'
+ }, {
+ id: 2,
+ name: '梧桐洲'
+ }, {
+ id: 3,
+ name: '藤县'
+ }],
+ address: '同心镇同心村同心路88号',
+ isDefault: false
+}, {
+ id: 2,
+ person2Contact: '卢翰',
+ phone: '12434455432',
+ area: [{
+ id: 1,
+ name: '广西壮族自治区'
+ }, {
+ id: 2,
+ name: '梧桐洲'
+ }, {
+ id: 3,
+ name: '藤县'
+ }],
+ address: '同心镇同心村同心路88号',
+ isDefault: false
+}, {
+ id: 2,
+ person2Contact: '卢翰',
+ phone: '12434455432',
+ area: [{
+ id: 1,
+ name: '广西壮族自治区'
+ }, {
+ id: 2,
+ name: '梧桐洲'
+ }, {
+ id: 3,
+ name: '藤县'
+ }],
+ address: '同心镇同心村同心路88号',
+ isDefault: false
+}, {
+ id: 2,
+ person2Contact: '卢翰',
+ phone: '12434455432',
+ area: [{
+ id: 1,
+ name: '广西壮族自治区'
+ }, {
+ id: 2,
+ name: '梧桐洲'
+ }, {
+ id: 3,
+ name: '藤县'
+ }],
+ address: '同心镇同心村同心路88号',
+ isDefault: false
}]
const myOperator = {
diff --git a/common/js/request.js b/common/js/request.js
index 448409e..78c996b 100644
--- a/common/js/request.js
+++ b/common/js/request.js
@@ -1,124 +1,156 @@
-import globalData from '@/common/js/globalData.js';
-
-export default {
- // 异步接口拦截
- addInterceptor() {
- uni.addInterceptor('request', {
- invoke(args) {
- // request 触发前拼接 url
- args.url = 'http://127.0.0.1:80' + args.url;
- // console.log("停止触发");
- // return false;
- },
- // success(args) {
- // console.log('interceptor-success', args);
- // },
- // fail(err) {
- // console.log('interceptor-fail', err)
- // },
- // complete(res) {
- // console.log('interceptor-complete', res)
- // res = res.data;
- // }
- })
- },
- checkAndAuth() {
- let _this = this;
- // 通过 wx.getSetting 先查询一下用户是否授权了 "scope.userInfo" 这个 scope
- wx.getSetting({
- success(res) {
- if (!res.authSetting['scope.userInfo']) {
- // 用户授权
- wx.authorize({
- scope: 'scope.userInfo',
- success() {
- // 用户已经同意, 后续调用此接口不会弹窗询问
- _this.login();
- },
- fail() {
- // 用户已经拒绝过授权
- wx.openSetting({
- success(res) {
- if (res['scope.userInfo']) {
- _this.checkAndAuth();
- }
- }
- })
- }
+import globalData from '@/common/js/globalData.js';
+
+export default {
+ // 异步接口拦截
+ addInterceptor() {
+ uni.addInterceptor('request', {
+ invoke(args) {
+ // request 触发前拼接 url
+ args.url = 'http://127.0.0.1:80' + args.url;
+ // console.log("停止触发");
+ // return false;
+ },
+ success(res) {
+ if (res.data.code !== 0) {
+ uni.showToast({
+ title: '系统开小差啦T_T,请稍后重试',
+ icon: 'error'
})
- } else {
- _this.login();
- }
- }
- })
- },
- async login() {
- // 从缓存中获取登录信息
- let userInfo = uni.getStorageSync('userProfile');
- if (userInfo) {
- return true;
- }
-
- // 获取微信登录凭证
- const wxLoginCode = wx.login();
- // TODO:调用小程序服务端确认是否是授权登录过的用户
- let loginRes = {
- logined: false,
- userInfo: {}
- };
- // 未登录过的获取微信用户信息
- if (!loginRes || !loginRes.logined) {
- userInfo = await wx.getUserProfile({
- desc: '用于小程序登录'
- });
- // 再次请求小程序服务端存储用户,服务端添加附加用户信息后返回
- loginRes = {
- logined: true,
- userInfo: {
- userId: 1
- }
- };
- }
- userInfo = loginRes.userInfo;
- if (!userInfo) {
- uni.showToast({
- icon: 'error',
- title: '用户信息获取失败,请退出小程序重试'
- })
- return false;
- }
- // 页面存储用户登录有效信息,以便其他页面调用
- uni.setStorageSync('userProfile', userInfo);
- return true;
- },
- getCurUserInfo() {
- let userProfile = uni.getStorageSync('userProfile');
- console.log("curUser:" + userProfile)
- return userProfile;
+ }
+ },
+ fail(err) {
+ uni.showToast({
+ title: '系统开小差啦T_T,请稍后重试',
+ icon: 'error'
+ })
+ },
+ complete(res) {
+ console.log('interceptor-complete', res)
+ }
+ })
+ },
+ checkAndAuth() {
+ let _this = this;
+ // 通过 wx.getSetting 先查询一下用户是否授权了 "scope.userInfo" 这个 scope
+ wx.getSetting({
+ success(res) {
+ if (!res.authSetting['scope.userInfo']) {
+ // 用户授权
+ wx.authorize({
+ scope: 'scope.userInfo',
+ success() {
+ // 用户已经同意, 后续调用此接口不会弹窗询问
+ _this.login();
+ },
+ fail() {
+ // 用户已经拒绝过授权
+ wx.openSetting({
+ success(res) {
+ if (res['scope.userInfo']) {
+ _this.checkAndAuth();
+ }
+ }
+ })
+ }
+ })
+ } else {
+ _this.login();
+ }
+ }
+ })
+ },
+ async login() {
+ // 从缓存中获取登录信息
+ let userInfo = uni.getStorageSync('userProfile');
+ if (userInfo) {
+ return true;
+ }
+
+ // 获取微信登录凭证
+ const wxLoginRes = await wx.login();
+ console.log(wxLoginRes)
+ const wxAuthRes = await uni.request({
+ url: '/wx/auth',
+ header: {
+ code: wxLoginRes.code
+ }
+ })
+ console.log(wxAuthRes)
+ // TODO:调用小程序服务端确认是否是授权登录过的用户
+ let loginRes = {
+ logined: false,
+ userInfo: {}
+ };
+ // 未登录过的获取微信用户信息
+ if (!loginRes || !loginRes.logined) {
+ userInfo = await wx.getUserProfile({
+ desc: '用于小程序登录'
+ });
+ // 再次请求小程序服务端存储用户,服务端添加附加用户信息后返回
+ loginRes = {
+ logined: true,
+ userInfo: {
+ userId: 1,
+ wxLoginCode: wxLoginRes.code,
+ openId: wxAuthRes[1].data.data.openid
+ }
+ };
+ }
+ userInfo = loginRes.userInfo;
+ if (!userInfo) {
+ uni.showToast({
+ icon: 'error',
+ title: '用户信息获取失败,请退出小程序重试'
+ })
+ return false;
+ }
+ // 页面存储用户登录有效信息,以便其他页面调用
+ uni.setStorageSync('userProfile', userInfo);
+ return true;
+ },
+ wxLogin() {
+ return wx.login();
+ },
+ getCurUserInfo() {
+ let userProfile = uni.getStorageSync('userProfile');
+ console.log("curUser:" + userProfile)
+ return userProfile;
},
getProductCategories(params = {}) {
return uni.request({
url: '/goods/deptcategory/app/list',
- method: 'POST',
+ method: 'POST',
data: params
})
- },
- qryProductPage(params = {}) {
+ },
+ qryProductPage(params = {}) {
return uni.request({
url: '/goods/goods/list',
- method: 'POST',
- data: params,
- header: {
- pageNum: params.pageNum,
- pageSize: params.pageSize
+ method: 'POST',
+ data: params,
+ header: {
+ pageNum: params.pageNum,
+ pageSize: params.pageSize
}
- })
- },
- placeOrder(params = {}) {
- return uni.request({
- url: '/goods/goods/list',
- method: 'POST',
+ })
+ },
+ async placeOrder(params = {}) {
+ let res = await uni.request({
+ url: '/order/server/app',
+ method: 'POST',
data: params
})
- }
+ return res[1].data;
+ },
+ async getWxPayParams(params = {}) {
+ let res = await uni.request({
+ url: '/pay/wx/lite',
+ method: 'POST',
+ header: {
+ code: params.code,
+ orderMasterCode: params.orderMasterCode
+ }
+ })
+ return res[1].data;
+ },
}
diff --git a/pages.json b/pages.json
index dc0d097..f373e35 100644
--- a/pages.json
+++ b/pages.json
@@ -7,6 +7,8 @@
"root": "pages/order/",
"pages": [{
"path": "order-detail"
+ }, {
+ "path": "pay-result"
}]
}, {
"root": "pages/product/",
diff --git a/pages/my/edit-address.vue b/pages/my/edit-address.vue
index 2a2e9c5..9c70a0a 100644
--- a/pages/my/edit-address.vue
+++ b/pages/my/edit-address.vue
@@ -37,7 +37,7 @@
-
+
@@ -51,13 +51,19 @@
areaList: [],
multiIndex: [0, 0, 0],
formData: {
- }
+ },
+ mode: 1 // 1为新增,0
}
},
onLoad(options) {
+ let params = JSON.parse(decodeURIComponent(options.params));
+ this.mode = params ? params.mode : this.mode;
+ console.log(this.mode)
+ if (this.mode === 0) {
+ // 修改
+ this.fillForm(params.addressInfo);
+ }
this.loadData();
- const addressInfo = JSON.parse(decodeURIComponent(options.addressInfo));
- this.fillForm(addressInfo);
},
methods: {
async loadData() {
diff --git a/pages/my/my-address.vue b/pages/my/my-address.vue
index ac13d5c..f5789a6 100644
--- a/pages/my/my-address.vue
+++ b/pages/my/my-address.vue
@@ -6,7 +6,7 @@
地址列表
-
+
@@ -21,11 +21,15 @@
-
+
+
+
+
+
@@ -74,9 +78,23 @@
offBindEvent() {
uni.$off(this.$globalFun.CONFIRM);
},
- showAddressDetail(addressInfo) {
+ addEditAddress(addressInfo) {
+ let url = null;
+ let params = null;
+ if (addressInfo) {
+ // 修改
+ params = {
+ addressInfo: addressInfo,
+ mode: 0
+ }
+ } else {
+ // 新增
+ params = {
+ mode: 1
+ }
+ }
uni.navigateTo({
- url: '/pages/my/edit-address?addressInfo=' + encodeURIComponent(JSON.stringify(addressInfo))
+ url: '/pages/my/edit-address?params=' + encodeURIComponent(JSON.stringify(params))
})
},
confirm2DelAddress(addressInfo, index) {
diff --git a/pages/order/order-detail.vue b/pages/order/order-detail.vue
index 910f7db..1bc794d 100644
--- a/pages/order/order-detail.vue
+++ b/pages/order/order-detail.vue
@@ -237,19 +237,47 @@
}
let curUserInfo = this.$request.getCurUserInfo();
let params = {
- customerId: curUserInfo.userId,
+ // customerId: curUserInfo.userId,
+ customerId: 2,
serverTime: this.formInfo.doorTime,
addressId: this.formInfo.defaultAddress.id,
payType: this.formInfo.payWay,
remark: this.formInfo.comments,
isNeedBill: this.formInfo.isNeedBill,
- goodsList: this.parseGoodsList()
+ // goodsList: this.parseGoodsList()
+ goodsList: [{
+ goodsId: 2,
+ num: 1
+ }, {
+ goodsId: 3,
+ num: 1
+ }]
}
- console.log(params);
- // 调用下单接口,获得微信支付调用参数
+ // 调用下单接口
let res = await this.$request.placeOrder(params);
- // 拉起微信支付窗口,支付成功跳转到支付成功页面,支付失败跳转到我的订单待支付页
- // wx.requestPayment(res);
+ try {
+ // 获取微信支付所需参数
+ let exPayParams = {
+ code: this.$request.getCurUserInfo().openId,
+ orderMasterCode: res.data.code
+ }
+ let wxPayParamRes = await this.$request.getWxPayParams(exPayParams);
+ // 拉起微信支付窗口,支付成功跳转到支付成功页面
+ let payInfo = JSON.parse(wxPayParamRes.data.expend.pay_info);
+ let wxPayRes = await wx.requestPayment(payInfo);
+ if (wxPayRes.errMsg === "requestPayment:ok") {
+ uni.navigateTo({
+ url: '/pages/order/pay-result?payResult=0'
+ })
+ } else {
+ throw 'err';
+ }
+ } catch(e) {
+ // 支付失败弹出提示并跳转到我的订单待支付页
+ uni.navigateTo({
+ url: '/pages/order/pay-result?payResult=1'
+ })
+ }
}
},
}
diff --git a/pages/order/pay-result.vue b/pages/order/pay-result.vue
new file mode 100644
index 0000000..b422c40
--- /dev/null
+++ b/pages/order/pay-result.vue
@@ -0,0 +1,71 @@
+
+
+
+
+ 返回
+ 支付结果
+
+
+ {{payResult ? '支付成功' : '支付失败'}}
+
+ 查看我的订单
+
+
+
+
+
+
+
+
diff --git a/style/blue/blue-topic.css b/style/blue/blue-topic.css
index 1a63859..9550a90 100644
--- a/style/blue/blue-topic.css
+++ b/style/blue/blue-topic.css
@@ -1,3 +1,7 @@
+.bg-back {
+ background-color: #f5f5f5;
+}
+
.line-default {
color: #aaaaaa;
}
diff --git a/style/default.css b/style/default.css
index b45085c..96746f4 100644
--- a/style/default.css
+++ b/style/default.css
@@ -94,4 +94,4 @@
.cu-form-group textarea {
margin: 0 0 20rpx 0 !important;
padding: 20rpx !important;
-}
+}
\ No newline at end of file