diff --git a/App.vue b/App.vue
index 647e694..6656821 100644
--- a/App.vue
+++ b/App.vue
@@ -3,9 +3,6 @@
export default {
data() {
return {
- modalContent: '',
- cancelMsg: '取消',
- confirmMsg: '确定'
}
},
onLaunch: function() {
diff --git a/common/js/data.js b/common/js/data.js
index 9ed9870..33a2209 100644
--- a/common/js/data.js
+++ b/common/js/data.js
@@ -227,9 +227,13 @@ const productDetail = {
type: 'image',
url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big3002.jpg'
}],
- productInfo: {
- name: '十五平米擦玻璃服务',
- desc: '15平米起擦玻璃服务,超过15平米按照15/平米现场另收费',
+ productInfo: {
+ id: 1,
+ goodsImgUrl: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big20000.jpg',
+ goodsName: '十五平米擦玻璃服务',
+ comments: '15平米起擦玻璃服务,超过15平米按照15/平米现场另收费',
+ type: '空调/清洗',
+ servArea: ['广州', '顺德', '南海', '大良', '南海', '大良', '南海', '大良', '南海'],
isGoldServ: true
},
guaranteeList: [{
@@ -368,7 +372,7 @@ const productDetail = {
}],
shopInfo: {
id: 1,
- name: '艺鑫到家(售后无忧)',
+ shopName: '艺鑫到家(售后无忧)',
avatarUrl: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big17005.jpg',
totalScore: 4.5
}
diff --git a/common/js/globalData.js b/common/js/globalData.js
new file mode 100644
index 0000000..b134ea7
--- /dev/null
+++ b/common/js/globalData.js
@@ -0,0 +1,5 @@
+export default {
+ deptId: 1,
+ initPageNum: 1,
+ initPageSize: 5
+}
\ No newline at end of file
diff --git a/common/js/request.js b/common/js/request.js
index 73d227d..448409e 100644
--- a/common/js/request.js
+++ b/common/js/request.js
@@ -1,3 +1,5 @@
+import globalData from '@/common/js/globalData.js';
+
export default {
// 异步接口拦截
addInterceptor() {
@@ -8,21 +10,115 @@ export default {
// 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)
+ // 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();
+ }
+ }
+ })
+ }
+ })
+ } 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;
},
- getProductCategories() {
+ getProductCategories(params = {}) {
return uni.request({
- url: '/goods/category/list',
- method: 'POST'
+ url: '/goods/deptcategory/app/list',
+ method: 'POST',
+ data: params
})
+ },
+ qryProductPage(params = {}) {
+ return uni.request({
+ url: '/goods/goods/list',
+ method: 'POST',
+ data: params,
+ header: {
+ pageNum: params.pageNum,
+ pageSize: params.pageSize
+ }
+ })
+ },
+ placeOrder(params = {}) {
+ return uni.request({
+ url: '/goods/goods/list',
+ method: 'POST',
+ data: params
+ })
}
}
diff --git a/components/goods-card/horizontal-goods-card.vue b/components/goods-card/horizontal-goods-card.vue
index 574b914..51e927f 100644
--- a/components/goods-card/horizontal-goods-card.vue
+++ b/components/goods-card/horizontal-goods-card.vue
@@ -1,16 +1,16 @@
-
+
- {{product.name}}
+ {{product.goodsName}}
{{product.comments}}
- {{product.salePrice}}
- ¥{{product.price}}
+ {{product.discountsPrice}}
+ ¥{{product.goodsPrice}}
{{product.type}}
diff --git a/components/multi-level-nav/vertical-nav.vue b/components/multi-level-nav/vertical-nav.vue
index c1bded9..7c315f4 100644
--- a/components/multi-level-nav/vertical-nav.vue
+++ b/components/multi-level-nav/vertical-nav.vue
@@ -10,25 +10,25 @@
-
- {{item.name}}
+
+ {{item.goodsCategoryName}}
+ :id="'main-'+type.goodsCategoryId">
- {{type.name}}
+ {{type.goodsCategoryName}}
+
+
+
+
+ 需先授权微信登录才可正常使用功能
+
+
+ 确认授权
+
+
@@ -90,7 +101,8 @@
subCategories: [],
hotGoods: {},
discountGoods: {},
- InputBottom: 0
+ InputBottom: 0,
+ isAuthWxLoginModal: false
}
},
mounted() {
@@ -103,7 +115,12 @@
this.loadData();
},
methods: {
- async loadData() {
+ async loadData() {
+ let curUserInfo = uni.getStorageSync('userProfile');
+ this.isAuthWxLoginModal = curUserInfo ? false : true;
+ if (this.isAuthWxLoginModal) {
+ return;
+ }
this.swiperList = await this.$api.data('swiperList');
this.categories = await this.$api.data('categories');
this.subCategories = await this.$api.data('subCategories');
@@ -138,6 +155,13 @@
uni.navigateTo({
url: '/pages/product/product-category'
})
+ },
+ authWxLogin() {
+ this.$request.login().then(res => {
+ if (res) {
+ this.loadData();
+ }
+ })
}
}
}
diff --git a/pages/order/order-detail.vue b/pages/order/order-detail.vue
index 0e82b3d..910f7db 100644
--- a/pages/order/order-detail.vue
+++ b/pages/order/order-detail.vue
@@ -6,18 +6,18 @@
订单确认
-
+
-
+
{{areaObj.name}}
- {{defaultAddress.address}}
+ {{formInfo.defaultAddress.address}}
- {{defaultAddress.person2Contact}}
- {{defaultAddress.phone}}
+ {{formInfo.defaultAddress.person2Contact}}
+ {{formInfo.defaultAddress.phone}}
@@ -42,8 +42,8 @@
预约时间
-
- {{doorTime}}
+
+ {{formInfo.doorTime}}
请选择上门时间
@@ -80,11 +80,11 @@
支付方式
@@ -93,8 +93,19 @@
- 发票信息
-
+
+ 是否需要发票
+
+
+
+
@@ -113,9 +124,9 @@
共计
- {{formInfo.totalPrice}}
+ {{totalPrice}}
- 确定
+ 确定
@@ -132,25 +143,35 @@
columnTitleArr: ['购买型号', '购买数量'],
pickedProductList: [],
formInfo: {
- payWay: 'online',
- comments: '',
- totalPrice: 0
- },
- defaultAddress: null,
- doorTime: null
+ payWay: '0',
+ isNeedBill: '0',
+ comments: '',
+ doorTime: null,
+ defaultAddress: null
+ },
+ totalPrice: 0
}
},
- onLoad() {
- this.loadData();
+ onLoad(options) {
+ let params = JSON.parse(decodeURIComponent(options.params));
+ this.loadData(params);
this.bindEvent();
},
onUnload() {
this.offBindEvent();
},
methods: {
- async loadData() {
- this.pickedProductList = await this.$api.data('pickedProductList');
- this.defaultAddress = await this.$api.data('defaultAddress');
+ async loadData(params) {
+ // this.pickedProductList = await this.$api.data('pickedProductList');
+ this.pickedProductList = params.pickedProductList;
+ // TODO: 遍历查询每个product的总价并赋值,此处先赋定值
+ for (let i = 0; i < this.pickedProductList.length; i++) {
+ for (let j = 0; j < this.pickedProductList[i].product.length; j++) {
+ this.pickedProductList[i].product[j].discountsPrice = 100;
+ this.pickedProductList[i].product[j].goodsPrice = 200;
+ }
+ }
+ this.formInfo.defaultAddress = await this.$api.data('defaultAddress');
},
bindEvent() {
uni.$on(this.$globalFun.CHOOSE_ADDRESS, this.chooseAddress);
@@ -160,9 +181,12 @@
},
changePayWay(e) {
this.formInfo.payWay = e.detail.value;
+ },
+ changeIsNeedBill(e) {
+ this.formInfo.isNeedBill = e.detail.value;
},
inputComments(e) {
- this.comments = e.detail.value
+ this.formInfo.comments = e.detail.value
},
showAddress2Choose() {
uni.navigateTo({
@@ -170,10 +194,62 @@
})
},
chooseAddress(addressInfo) {
- this.defaultAddress = addressInfo;
+ this.formInfo.defaultAddress = addressInfo;
},
changeDoorTime(value) {
- this.doorTime = value;
+ this.formInfo.doorTime = value;
+ },
+ parseGoodsList() {
+ let goodsList = [];
+ this.pickedProductList.forEach((shopInfo) => {
+ shopInfo.product.forEach((productInfo) => {
+ productInfo.pickedList.forEach((pickedSpecs) => {
+ goodsList.push({
+ goodsId: pickedSpecs.id,
+ num: pickedSpecs.pickedNum,
+ })
+ })
+ })
+ })
+ return goodsList;
+ },
+ validForm() {
+ if (!this.formInfo.defaultAddress) {
+ uni.showToast({
+ title: '请选择服务地址',
+ icon: 'none'
+ })
+ return false;
+ }
+ if (!this.formInfo.doorTime) {
+ uni.showToast({
+ title: '请选择上门时间',
+ icon: 'none'
+ })
+ return false;
+ }
+ return true;
+ },
+ async submit() {
+ let valid = this.validForm();
+ if (!valid) {
+ return;
+ }
+ let curUserInfo = this.$request.getCurUserInfo();
+ let params = {
+ customerId: curUserInfo.userId,
+ serverTime: this.formInfo.doorTime,
+ addressId: this.formInfo.defaultAddress.id,
+ payType: this.formInfo.payWay,
+ remark: this.formInfo.comments,
+ isNeedBill: this.formInfo.isNeedBill,
+ goodsList: this.parseGoodsList()
+ }
+ console.log(params);
+ // 调用下单接口,获得微信支付调用参数
+ let res = await this.$request.placeOrder(params);
+ // 拉起微信支付窗口,支付成功跳转到支付成功页面,支付失败跳转到我的订单待支付页
+ // wx.requestPayment(res);
}
},
}
diff --git a/pages/product/filtered-products.vue b/pages/product/filtered-products.vue
index 584055a..73aef96 100644
--- a/pages/product/filtered-products.vue
+++ b/pages/product/filtered-products.vue
@@ -43,11 +43,18 @@
-
+
+
+
+
+ 查看更多
+
+
+
@@ -61,7 +68,11 @@
},
data() {
return {
- productList: [],
+ productList: [],
+ loadMoreStatus: '',
+ hasMoreData: false,
+ pageNum: this.$globalData.initPageNum,
+ pageSize: this.$globalData.initPageSize,
stickyTop: this.CustomBar,
// type: 0=升降序,1=功能按钮;order: 0=升序,1=降序;
tabCur: 0,
@@ -94,13 +105,38 @@
}
},
onLoad(options) {
- let params = JSON.parse(decodeURIComponent(options.params));
+ let params = JSON.parse(decodeURIComponent(options.params));
+ if (typeof params.pageNum === 'number' && typeof params.pageSize === 'number') {
+ this.pageNum = params.pageNum;
+ this.pageSize = params.pageSize;
+ }
this.loadData(params);
},
- methods: {
- async loadData(params) {
- let shopInfo = await this.$api.data('shopInfo');
- this.productList = shopInfo.productList;
+ methods: {
+ async loadProductPage(params) {
+ // let shopInfo = await this.$api.data('shopInfo');
+ // this.productList = shopInfo.productList;
+ let res = await this.$request.qryProductPage(params);
+ let rowsLength = res[1].data.rows.length;
+ if (rowsLength == 0) {
+ return;
+ } else if (rowsLength === this.pageSize) {
+ this.hasMoreData = true;
+ }
+ this.productList = this.productList.concat(res[1].data.rows);
+ this.pageNum++;
+ },
+ async loadData(params) {
+ params.pageNum = this.pageNum;
+ params.pageSize = this.pageSize;
+ this.loadMoreStatus = 'loading bg-main-color light';
+ this.hasMoreData = false;
+ try {
+ await this.loadProductPage(params);
+ this.loadMoreStatus = this.hasMoreData ? '' : 'over bg-grey';
+ } catch (e) {
+ this.loadMoreStatus = 'erro bg-red'
+ }
},
searchGoods(e) {
console.log("搜索" + e.detail.value)
@@ -116,9 +152,12 @@
this.taskConditions[this.tabCur].value = orderVal === 0 ? 1 : 0;
}
},
- showDetails(productItem) {
+ showDetails(productItem) {
+ let params = {
+ id: productItem.goodsId
+ }
uni.navigateTo({
- url: '../product/product-detail?productId=' + productItem.id
+ url: '/pages/product/product-detail?params=' + encodeURIComponent(JSON.stringify(params))
});
},
regionChange(e) {
diff --git a/pages/product/product-category.vue b/pages/product/product-category.vue
index 11c36e9..9ec9f27 100644
--- a/pages/product/product-category.vue
+++ b/pages/product/product-category.vue
@@ -5,7 +5,7 @@
返回
产品分类
-
+
@@ -19,7 +19,7 @@
data() {
return {
containerHeight: '100vh - ' + this.CustomBar + 'px',
- categoryList: []
+ categoryList: null
}
},
onLoad() {
@@ -32,7 +32,8 @@
methods: {
async loadData() {
// this.categoryList = await this.$api.data('categoryList');
- this.categoryList = await this.$request.getProductCategories();
+ let res = await this.$request.getProductCategories({deptId: this.$globalData.deptId});
+ this.categoryList = res[1].data.data;
},
bindEvent() {
uni.$on(this.$globalFun.VERTICAL_NAV_GET_ITEM, this.chooseSubType);
@@ -44,7 +45,7 @@
},
chooseSubType(item) {
let params = {
- type: 1
+ goodsCategoryId: item.goodsCategoryId
}
uni.navigateTo({
url: '/pages/product/filtered-products?params=' + encodeURIComponent(JSON.stringify(params))
diff --git a/pages/product/product-detail.vue b/pages/product/product-detail.vue
index c92c0cd..69559cc 100644
--- a/pages/product/product-detail.vue
+++ b/pages/product/product-detail.vue
@@ -59,9 +59,9 @@
金牌服务
- {{productInfo.name}}
+ {{productInfo.goodsName}}
- {{productInfo.desc}}
+ {{productInfo.comments}}
@@ -110,7 +110,7 @@
- {{shopInfo.name}}
+ {{shopInfo.shopName}}
@@ -146,7 +146,7 @@
-
+
@@ -181,8 +181,9 @@
swiperPicUrls: []
}
},
- onLoad() {
- this.loadData();
+ onLoad(options) {
+ let params = JSON.parse(decodeURIComponent(options.params));
+ this.loadData(params);
this.bindEvent();
},
onUnload() {
@@ -195,7 +196,7 @@
this.showTopNav = e.scrollTop > 250 ? true : false
},
methods: {
- async loadData() {
+ async loadData(params) {
let productDetail = await this.$api.data('productDetail');
this.swiperList = productDetail.swiperList;
this.productInfo = productDetail.productInfo;
diff --git a/pages/product/product-pick.vue b/pages/product/product-pick.vue
index a440ed4..c78a7fb 100644
--- a/pages/product/product-pick.vue
+++ b/pages/product/product-pick.vue
@@ -46,14 +46,22 @@