From 6661b4dd3d297de9c546aa7904be19719a6ac03d Mon Sep 17 00:00:00 2001 From: Mrxtyyp <1126084777@qq.com> Date: Wed, 7 May 2025 09:44:27 +0800 Subject: [PATCH] some features --- colorui/main.css | 3 +- common/js/request.js | 72 +++++-- components/CTabbar.vue | 36 ++-- .../multiselect-vertical-nav.vue | 37 +++- components/vertify/vertify-phone.vue | 3 +- pages.json | 2 + pages/index/components/valid.vue | 53 +---- pages/index/home.vue | 146 ++++++++++--- pages/index/my-home.vue | 6 +- pages/index/worker-home.vue | 22 +- pages/my/edit-service-address.vue | 183 ++++++++++++++++ pages/my/my-address.vue | 5 +- pages/my/my-money-bag.vue | 116 +++++++---- pages/my/my-operator.vue | 97 ++++++--- pages/my/my-team-member.vue | 5 +- pages/my/serv-detail.vue | 71 +++++-- pages/my/statement-desc.vue | 12 +- pages/order/order-detail.vue | 92 +++++++- pages/order/pay-result.vue | 11 +- pages/product/filtered-products.vue | 16 +- pages/product/product-category.vue | 39 +++- pages/product/product-detail.vue | 196 ++++++++++++++---- pages/product/product-pick.vue | 98 ++++++--- .../uni-number-box/uni-number-box.vue | 3 +- 24 files changed, 1015 insertions(+), 309 deletions(-) create mode 100644 pages/my/edit-service-address.vue diff --git a/colorui/main.css b/colorui/main.css index 3ed9937..ee72332 100644 --- a/colorui/main.css +++ b/colorui/main.css @@ -1235,7 +1235,8 @@ button.cuIcon.lg { position: absolute; left: 146upx; width: calc(100% - 96upx - 60upx - 120upx - 20upx); - line-height: 1.6em; + /* line-height: 1.6em; */ + max-height: 128upx; } .cu-list.menu-avatar>.cu-item .content.flex-sub { diff --git a/common/js/request.js b/common/js/request.js index 5932ba8..ea20802 100644 --- a/common/js/request.js +++ b/common/js/request.js @@ -2,7 +2,8 @@ import globalData from '@/common/js/globalData.js'; export default { // address: 'https://www.opsoul.com:8881',https://gmhl.opsoul.com - address: 'https://gmhl.opsoul.com', + // address: 'https://gmhl.opsoul.com', + address: 'https://gmhl.gmjlb.com', // 异步接口拦截 addInterceptor() { uni.addInterceptor('request', { @@ -12,8 +13,8 @@ export default { title: '加载中' }) // request 触发前拼接 url - args.url = 'https://gmhl.opsoul.com' + args.url; - // args.url = 'http://192.168.2.54:80' + args.url; + // args.url = 'https://gmhl.opsoul.com' + args.url; + args.url = 'https://gmhl.gmjlb.com' + args.url; // args.url = 'http://127.0.0.1:80' + args.url; if (args.data && Object.prototype && Object.prototype.toString.call(args.data) === '[object Object]') { args.data.deptId = globalData.deptId; @@ -135,11 +136,20 @@ export default { }) return res[1].data; }, - async login() { - let userInfo = await wx.getUserProfile({ - desc: '用于小程序登录' - }); - console.log(userInfo) + async login(phoneNumber) { + const _this = this; + // uni.getUserInfo({ + // provider: 'weixin', + // withCredentials: true, + // lang: 'zh_CN', + // success: async (obj) => { + // console.log(obj); + // }}) + // let userInfo = await wx.getUserProfile({ + // desc: '用于小程序登录' + // }); + // console.log(userInfo) + let userInfo; // 获取微信登录凭证 const wxLoginRes = await wx.login(); // 获取openid @@ -157,9 +167,11 @@ export default { // 注册完成后再次从服务端获取用户信息 let registerRes = await this.registerUser({ openId: openId, - name: userInfo.userInfo.nickName, - customerLogoUrl: userInfo.userInfo.avatarUrl, - status: 0 + name: "微信用户", + customerLogoUrl: "https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132", + status: 0, + account: phoneNumber, + phone: phoneNumber }); if (registerRes.code === 0) { wxGetUserRes = await this.qryUserInfo(openId); @@ -181,11 +193,12 @@ export default { return false; } // 页面存储用户登录有效信息,以便其他页面调用 - uni.setStorageSync('userProfile', userInfo); + uni.setStorageSync('userProfile', userInfo); + return true; }, async storageExistUser() { - uni.clearStorageSync('userProfile'); + uni.setStorageSync('userProfile', {}); // 获取微信登录凭证 const wxLoginRes = await wx.login(); // 获取openid @@ -265,13 +278,14 @@ export default { }) return false; } - if (phoneRes && phoneRes.data) { - let userInfo = this.getCurUserInfo(); - await this.updateUser({ - customerId: userInfo.customerId, - account: phoneRes.data, - phone: phoneRes.data - }) + if (phoneRes && phoneRes.data) { + await this.login(phoneRes.data) + // let userInfo = this.getCurUserInfo(); + // await this.updateUser({ + // customerId: userInfo.customerId, + // account: phoneRes.data, + // phone: phoneRes.data + // }) return true; } }, @@ -305,6 +319,14 @@ export default { method: 'POST', data: params }) + }, + getChooseCategories(params = {}) { + const res = uni.request({ + url: '/customer/selection/listNoPage', + method: 'POST', + data: params + }) + return res; }, qryProductPage(params = {}) { return uni.request({ @@ -473,7 +495,7 @@ export default { }, async qryFinancialDetail(params = {}) { let res = await uni.request({ - url: '/financial/detail/app/list', + url: '/financial/detail/app/listV2', method: 'POST', data: params }) @@ -507,6 +529,14 @@ export default { }) return res[1].data; }, + async updateMasterAddress(params = {}) { + let res = await uni.request({ + url: '/order/master/updateMasterAddress', + method: 'POST', + data: params + }) + return res[1].data; + }, async cancelMasterOrder(params = {}) { let res = await uni.request({ url: '/order/master/cancel', diff --git a/components/CTabbar.vue b/components/CTabbar.vue index 28d3c10..4d8fed0 100644 --- a/components/CTabbar.vue +++ b/components/CTabbar.vue @@ -114,12 +114,16 @@ uni.$on('initValid', this.initValid) }, mounted() { + this.authLogin() // this.$refs.vertifyLogin.showModal(); }, methods: { - initValid(initParam) { + async initValid(initParam) { this.initParam = initParam - this.$refs.validRef.loadData(initParam) + if (initParam && initParam.distributor) { + const res = await this.authLogin() + this.$refs.validRef.loadData(initParam, res) + } }, goRouter(path) { uni.navigateTo({ @@ -151,26 +155,30 @@ let curUserInfo = this.$request.getCurUserInfo(); // 校验提示登录 if (!curUserInfo || !curUserInfo.openId) { - this.$refs.vertifyLogin.showModal(); - return false; - } else { - this.$refs.vertifyLogin.hideModal(); - } - // 校验提示获取手机号码 - if (!curUserInfo.phone) { this.$refs.vertifyPhone.showModal(); return false; } else { this.$refs.vertifyPhone.hideModal(); } + // 校验提示获取手机号码 + // if (!curUserInfo.phone) { + // this.$refs.vertifyPhone.showModal(); + // return false; + // } else { + // this.$refs.vertifyPhone.hideModal(); + // } return true; }, - reloadForwardPage() { - if(this.$refs.validRef.inByShare){ - this.$refs.validRef.loadData(this.initParam) - } else { - this.authLogin() + async reloadForwardPage() { + const res = await this.authLogin() + if(res) { + this.$refs.validRef.loadData(this.initParam, res) } + // if(this.$refs.validRef.inByShare){ + // this.$refs.validRef.loadData(this.initParam) + // } else { + // this.authLogin() + // } }, }, destroyed() { diff --git a/components/multi-level-nav/multiselect-vertical-nav.vue b/components/multi-level-nav/multiselect-vertical-nav.vue index 6d2bc3a..3d4250c 100644 --- a/components/multi-level-nav/multiselect-vertical-nav.vue +++ b/components/multi-level-nav/multiselect-vertical-nav.vue @@ -7,16 +7,21 @@ - --> + --> + + + + + - + {{item.goodsCategoryName}} - + @@ -45,7 +50,7 @@ props: { list: { type: Array, - default: [] + default: () => [] }, containerHeight: { type: String, @@ -54,6 +59,10 @@ isClick2ShowProducts: { type: Boolean, default: false + }, + allLevel3CategoryIds: { + type: Array, + default: () => [] } }, data() { @@ -66,8 +75,6 @@ this.loadData(); }, methods: { - loadData() { - }, tabSelect(e) { this.tabCur = e.currentTarget.dataset.index; }, @@ -86,6 +93,18 @@ clearChosenItem() { this.chosenCategoryIds = []; uni.$emit(this.$globalFun.VERTICAL_NAV_GET_ITEM, this.chosenCategoryIds); + }, + setChooseItems(arr) { + this.chosenCategoryIds = [...arr] + uni.$emit(this.$globalFun.VERTICAL_NAV_GET_ITEM, this.chosenCategoryIds); + }, + chooseAll() { + this.chosenCategoryIds = [...this.allLevel3CategoryIds] + uni.$emit(this.$globalFun.VERTICAL_NAV_GET_ITEM, this.chosenCategoryIds); + }, + cancelAll() { + this.chosenCategoryIds = [] + uni.$emit(this.$globalFun.VERTICAL_NAV_GET_ITEM, this.chosenCategoryIds); } } } @@ -93,7 +112,8 @@ \ No newline at end of file diff --git a/pages/my/edit-service-address.vue b/pages/my/edit-service-address.vue new file mode 100644 index 0000000..49a727a --- /dev/null +++ b/pages/my/edit-service-address.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/pages/my/my-address.vue b/pages/my/my-address.vue index e829c89..b6ffba5 100644 --- a/pages/my/my-address.vue +++ b/pages/my/my-address.vue @@ -6,7 +6,7 @@ 地址列表 - + @@ -59,7 +59,8 @@ async loadData() { // this.myAddressList = await this.$api.data('myAddressList'); let res = await this.$request.getAddressList({ - customerId: this.$request.getCurUserInfo().customerId + customerId: this.$request.getCurUserInfo().customerId, + isDelete: 0 }); this.myAddressList = res.data; }, diff --git a/pages/my/my-money-bag.vue b/pages/my/my-money-bag.vue index a6a23bd..c15ac28 100644 --- a/pages/my/my-money-bag.vue +++ b/pages/my/my-money-bag.vue @@ -5,7 +5,7 @@ 返回 运营账单 - + - - + - - 提现单号:{{item.code}} - - 分销金额 - + + 订单号:{{item.orderCode}} {{item.createTime}} - {{item.payMoney}} + + {{item.payMoney}} + {{item.orderStatusDesc}} + + @@ -59,8 +69,11 @@ bill: [], curUserInfo: {}, billingStateList: [{ + code: 0, + name: '全部' + },{ code: 1, - name: '待到帐' + name: '待分帐' },{ code: 6, name: '已取消' @@ -68,6 +81,7 @@ code: 5, name: '已到帐' }], + filterCode: [0,1,2,3,4,5,6], billingStateObj: null } }, @@ -100,36 +114,47 @@ }, async showStatement(e) { let curIndex = e.currentTarget.dataset.index; + console.log(this.openStatusArr, curIndex); // 1为缩起状态,0为展开状态 - if (this.openStatusArr[curIndex] == '1' && !this.bill[curIndex].statement) { - let createTime = new Date(new Date(this.bill[curIndex].createTime).setHours(0)); - let createMonth = createTime.getMonth() + 1; - let createYear = createTime.getFullYear(); - let finishYear = createMonth === 12 ? createYear + 1 : createYear; - let finishMonth = createMonth === 12 ? 1 : createMonth + 1; - - let createTimeStr = createYear + '-' + createMonth + '-1 00:00:00'; - let finishTimeStr = finishYear + '-' + finishMonth + '-1 00:00:00'; - - uni.showLoading({ - mask: true, - title: '加载中' - }) - let res = await this.$request.qryFinancialDetail({ - beginTime: createTimeStr, - endTime: finishTimeStr, - financialDetailTypes: [3], - payeeId: this.curUserInfo.customerId - }); - let newBill = this.bill.concat(); - newBill[curIndex].statement = res.rows; - this.bill = newBill; + if (this.openStatusArr[curIndex] == '1') { + if(!this.bill[curIndex].statement) { + let createTime = new Date(new Date(this.bill[curIndex].createTime).setHours(0)); + let createMonth = createTime.getMonth() + 1; + let createYear = createTime.getFullYear(); + let finishYear = createMonth === 12 ? createYear + 1 : createYear; + let finishMonth = createMonth === 12 ? 1 : createMonth + 1; + + let createTimeStr = createYear + '-' + createMonth + '-1 00:00:00'; + let finishTimeStr = finishYear + '-' + finishMonth + '-1 00:00:00'; + + uni.showLoading({ + mask: true, + title: '加载中' + }) + let res = await this.$request.qryFinancialDetail({ + beginTime: createTimeStr, + endTime: finishTimeStr, + financialDetailTypes: [3], + customerId: this.curUserInfo.customerId + }); + let newBill = this.bill.concat(); + newBill[curIndex].statement = res.rows; + this.bill = newBill; + } + for(let k = 0; k < this.openStatusArr.length; k++) { + this.$set(this.openStatusArr, k, k === curIndex ? '0' : '1') + } + uni.hideLoading() // #ifdef MP this.$nextTick(() => { this.$refs.collapse.resize(); uni.hideLoading(); }) // #endif + } else { + this.$set(this.openStatusArr, curIndex, '1') + this.billingStateObj = null + this.filterCode = [0,1,2,3,4,5,6] } }, showDetail(item) { @@ -138,12 +163,23 @@ }) }, chooseBillingState(e) { + console.log(e); this.billingStateObj = e; + if(e.code === 0) { + this.filterCode = [0,1,2,3,4,5,6] + } else if(e.code === 1) { + this.filterCode = [0,1,2,3,4] + } else { + this.filterCode = [e.code] + } + this.$nextTick(() => { + this.$refs.collapse.resize(); + }) }, searchBills() { - this.qryBills({ - billingState: this.billingStateObj ? this.billingStateObj.code : null - }); + // this.qryBills({ + // billingState: this.billingStateObj ? this.billingStateObj.code : null + // }); } }, } diff --git a/pages/my/my-operator.vue b/pages/my/my-operator.vue index 153b81d..bac5865 100644 --- a/pages/my/my-operator.vue +++ b/pages/my/my-operator.vue @@ -31,7 +31,7 @@ - + {{item.title}} ¥{{item.value}} @@ -45,7 +45,7 @@ - + {{item.title}} ¥{{item.value}} @@ -54,7 +54,7 @@ {{item.value}}{{item.unit}} - + {{item.title}} ¥{{item.value}} @@ -68,7 +68,7 @@ - + @@ -85,13 +85,19 @@ - 选品广场: - - + 选品广场: + + + + 正选 + + 反选 @@ -102,13 +108,17 @@ 逐条选品 - 去选品 + + 去选品 + - 您已选品 + - 全选:全部勾选供应链的服务及商品/运营代理所有类目 - 反选:把与我提供的服务和商品有冲突的区域范围不勾选 - (注:你所提供的服务及类目以你同手机号上架或入驻为准) + + 正选:进行对类目逐条勾选,已勾选的服务与商品,您的所有客户可见可选! + 反选:所有人与我区域范围提供的服务和商品重叠的进行屏蔽!(注:需两端绑定的手机号一致) + @@ -120,11 +130,11 @@ - - + + - + @@ -220,6 +230,10 @@ }, showModal(modalName) { this.modalName = modalName; + // 获取已选择项 + if(modalName = 'shieldSetModal' && !this.chosenCategoryIds.length) { + this.goChooseItem() + } }, hideModal() { this.modalName = null; @@ -232,19 +246,26 @@ uni.$off(this.$globalFun.VERTICAL_NAV_GET_ITEM); }, doSomething(e) { - const cur = e.currentTarget.dataset.cur; + const cur = e.currentTarget.dataset.cur; + let findItem, numberMember; switch (cur) { case 'ShieldSet': this.showModal('shieldSetModal') break; case 'showTeamMembers': + findItem = this.myOperator.analyseItems.find(item => item.title === '团队') + numberMember = findItem ? findItem.value : 0 + console.log(numberMember); uni.navigateTo({ - url: '/pages/my/my-team-member?placeStatus=2' + url: '/pages/my/my-team-member?placeStatus=2&number='+numberMember }) break; case 'showCustomers': + findItem = this.myOperator.analyseItems.find(item => item.title === '客户数') + numberMember = findItem ? findItem.value : 0 + console.log(numberMember); uni.navigateTo({ - url: '/pages/my/my-team-member' + url: '/pages/my/my-team-member?number='+numberMember }) case 'showMembers2Approval': uni.navigateTo({ @@ -254,19 +275,35 @@ break; } }, - changeAgreeShield(agreeShield) { + changeAgreeShield(agreeShield) { + if(agreeShield === this.agreeShield) return this.agreeShield = agreeShield; - this.$refs.multiSelectNav.clearChosenItem(); - uni.showToast({ - icon: 'none', - title: '请重新进行逐条选品' - }) + // this.$refs.multiSelectNav.clearChosenItem(); + this.goChooseItem() + // uni.showToast({ + // icon: 'none', + // title: '请重新进行逐条选品' + // }) }, tmpChooseCategory(chosenCategoryIds) { this.chosenCategoryIds = chosenCategoryIds; - }, + }, + async goChooseItem() { + const res = await this.$request.getChooseCategories({ + selectionType: this.agreeShield, + customerId: this.curUserInfo.customerId + }) + console.log(res); + if(res[1].data.data.length) { + this.$refs.multiSelectNav.setChooseItems([...res[1].data.data]) + } + // this.showModal('categoryModal') + }, + async confirmShield(e) { - if (this.agreeShield === 2 && this.chosenCategoryIds.length === 0) { + // console.log(this.agreeShield, this.chosenCategoryIds); + // return + if ((this.agreeShield === 2 || this.agreeShield === 1) && this.chosenCategoryIds.length === 0) { uni.showToast({ icon: 'none', title: '请至少选择一个类目' @@ -274,14 +311,14 @@ return; } let chosenCategoryIds = this.chosenCategoryIds; - if (this.agreeShield === 1 && this.chosenCategoryIds.length === 0) { - // 全选,带上所有的类目id - chosenCategoryIds = this.allLevel3CategoryIds; - } + // if (this.agreeShield === 1 && this.chosenCategoryIds.length === 0) { + // // 全选,带上所有的类目id + // chosenCategoryIds = this.allLevel3CategoryIds; + // } let res = await this.$request.addCustomerSelection({ customerId: this.curUserInfo.customerId, deptCategoryIds: chosenCategoryIds, - selectionType: this.agreeShield + selectionType: this.agreeShield == 3 ? 1 : this.agreeShield }); if (res && res.code === 0) { uni.showToast({ diff --git a/pages/my/my-team-member.vue b/pages/my/my-team-member.vue index 473b084..d61e09a 100644 --- a/pages/my/my-team-member.vue +++ b/pages/my/my-team-member.vue @@ -80,6 +80,9 @@ async loadData(option) { if (option && option.placeStatus != undefined) { this.placeStatus = option.placeStatus + } + if(option && option.number) { + this.totalMembers = option.number } this.curUserInfo = this.$request.getCurUserInfo(); this.resetData(); @@ -110,7 +113,7 @@ let rowsLength = res.rows.length; if (rowsLength > 0) { this.members = this.members.concat(res.rows); - this.totalMembers = res.total; + // this.totalMembers = res.total; this.pageNum++; if (rowsLength === this.pageSize) { this.$refs.loadStatusBar.showLoadMore(); diff --git a/pages/my/serv-detail.vue b/pages/my/serv-detail.vue index 265352d..b161d09 100644 --- a/pages/my/serv-detail.vue +++ b/pages/my/serv-detail.vue @@ -320,7 +320,7 @@ - + 订单编码:{{servDetail.orderMasterCode}} 订单时间:{{servDetail.createTime}} @@ -558,26 +558,63 @@ } }, showAddress2Choose() { + const {provinceId,provinceName,cityId,cityName,countryId,countryName,address,name,streetId,streetName,phone} = this.servDetail + let newAddr = address + if(newAddr.indexOf(provinceName) > -1) { + newAddr = newAddr.replace(provinceName, "") + } + if(newAddr.indexOf(cityName) > -1) { + newAddr = newAddr.replace(cityName, "") + } + if(newAddr.indexOf(countryName) > -1) { + newAddr = newAddr.replace(countryName, "") + } + if(newAddr.indexOf(streetName) > -1) { + newAddr = newAddr.replace(streetName, "") + } + const addressInfo = { + provinceId, + provinceName, + cityId, + cityName, + countryId, + countryName, + address: newAddr, + streetId, + streetName, + phone, + name + } uni.navigateTo({ - url: '/pages/my/my-address?chooseMode=true' + url: '/pages/my/edit-service-address?params=' + encodeURIComponent(JSON.stringify(addressInfo)) }) }, - editAddress(addressInfo) { + async editAddress(addressInfo) { console.log(addressInfo) - // let res = await this.$request.updateOrder({ - // id: order.orderMasterId, - // orderStatus: status - // }); - // if (res && res.code === 0) { - // this.reload(); - // if (ifRollback) { - // uni.showToast({ - // title: '订单已回滚至服务中状态,请联系师傅', - // icon: 'none', - // duration: 3000 - // }) - // } - // } + const {provinceId,provinceName,cityId,cityName,countryId,countryName,address,name,streetId,streetName,phone} = addressInfo + let res = await this.$request.updateMasterAddress({ + id: this.servDetail.orderMasterId, + provinceId, + provinceName, + cityId, + cityName, + countryId, + countryName, + address, + streetId, + streetName, + phone, + name + }); + if (res && res.code === 0) { + this.loadData(this.order.orderMasterId); + setTimeout(() => { + uni.showToast({ + icon: 'success', + title: '修改成功' + }) + }, 1000) + } }, makePhoneCall(phoneNum) { uni.makePhoneCall({ diff --git a/pages/my/statement-desc.vue b/pages/my/statement-desc.vue index 25d2780..4549a1e 100644 --- a/pages/my/statement-desc.vue +++ b/pages/my/statement-desc.vue @@ -12,8 +12,8 @@ - 当前状态: - {{statementDesc.payStatus == 0 ? '未付款' : '已付款'}} + 订单支付: + {{statementDesc.payStatusDesc}} 详情说明: @@ -31,12 +31,12 @@ - 提现单号: - {{statementDesc.code}} + 订单号码: + {{statementDesc.orderCode}} - 发起时间: - {{statementDesc.updateTime}} + 利润支付: + {{statementDesc.payTime}} - + @@ -97,7 +97,29 @@ - + + + @@ -160,12 +182,14 @@ doorTime: null, defaultAddress: null, expectTimeStart: '', - expectTimeEnd: '' + expectTimeEnd: '', }, totalPrice: 0, timeRangeIndex: 0, timeRange: '', - timeRangeList: [] + timeRangeList: [], + InsuranceList: [], + chooseInsurance: {id: null, insuranceAmount: 0} } }, onLoad(options) { @@ -181,6 +205,13 @@ this.loadDefaultAddress(); // this.pickedProductList = await this.$api.data('pickedProductList'); this.pickedProductList = params.pickedProductList; + console.log(params); + this.InsuranceList = params.pickedProductList[0].insuranceManagers || [] + if(this.InsuranceList.length) { + this.chooseInsurance.id = this.InsuranceList[0].id; + this.chooseInsurance.insuranceAmount = this.InsuranceList[0].insuranceAmount; + } + this.loadTotalPrice(); this.timeRangeList = this.$globalData.timeRangeList; this.timeRange = this.timeRangeList[0]; @@ -190,8 +221,12 @@ customerId: this.$request.getCurUserInfo().customerId, isDefault: 1 }); + // if (res && res.data &&res.data.length) { + // this.formInfo.defaultAddress = res.data[0]; + // } if (res && res.data &&res.data.length) { - this.formInfo.defaultAddress = res.data[0]; + const defaultAdd = res.data.filter(i => i.isDefault === 1) + this.formInfo.defaultAddress = defaultAdd.length ? defaultAdd[0] : res.data[0]; } }, loadTotalPrice() { @@ -211,6 +246,16 @@ }, changeIsNeedBill(e) { this.formInfo.isNeedBill = e.detail.value; + }, + changeInsurance(e) { + if(e.detail.value) { + const current = this.InsuranceList.find(i => i.id == e.detail.value) + this.chooseInsurance.id = current.id; + this.chooseInsurance.insuranceAmount = current.insuranceAmount; + } else { + this.chooseInsurance.id = null; + this.chooseInsurance.insuranceAmount = 0; + } }, inputComments(e) { this.formInfo.comments = e.detail.value @@ -269,11 +314,42 @@ } return true; }, - async submit() { + // 检测当前默认地址是否在服务区域之间 + checkDefaultAddressIfInclude() { + if(!this.formInfo.defaultAddress) return true + const allAreaId = [] + this.pickedProductList.forEach(item => { + item.product.forEach(pro => { + allAreaId.push(...pro.goodsAreaList.map(i => i.countryAreaId)) + }) + }) + // console.log(allAreaId, this.formInfo.defaultAddress); + // const allAreaId = this.shopInfo.workerAreas.map(i => i.districtId) + return allAreaId.includes(this.formInfo.defaultAddress.countryId) + }, + submit() { let valid = this.validForm(); if (!valid) { return; } + if(!this.checkDefaultAddressIfInclude()) { + uni.showModal({ + title: '提示', + content: '所选服务的区域与您所填地址的区域不匹配!可能会无法服务,请核对!', + cancelText: '查看', + confirmText: '仍然下单', + success: res => { + if (res.confirm) { + this.makeOrderOpration() + } + } + }) + } else { + this.makeOrderOpration() + } + }, + async makeOrderOpration() { + let curUserInfo = this.$request.getCurUserInfo(); let params = { customerId: curUserInfo.customerId, @@ -284,7 +360,9 @@ remark: this.formInfo.comments, isNeedBill: this.formInfo.isNeedBill, goodsList: this.parseGoodsList(), - goodsId: this.pickedProductList[0].product[0].goodsId + goodsId: this.pickedProductList[0].product[0].goodsId, + // 保险id + insuranceId: this.chooseInsurance.id // goodsList: [{ // goodsId: 2, // num: 1 diff --git a/pages/order/pay-result.vue b/pages/order/pay-result.vue index 43b9ab1..5e30726 100644 --- a/pages/order/pay-result.vue +++ b/pages/order/pay-result.vue @@ -79,10 +79,15 @@ tabCur: 0 } } - uni.navigateTo({ - // url: '/pages/my/my-order?tabInfo=' + encodeURIComponent(JSON.stringify(params)) - url: '/pages/index/index?menuCode=myPage' + + uni.reLaunch({ + url: '/pages/index/home?menuCode=myPage' }) + + // uni.navigateTo({ + // // url: '/pages/my/my-order?tabInfo=' + encodeURIComponent(JSON.stringify(params)) + // url: '/pages/index/home?menuCode=myPage' + // }) } }, } diff --git a/pages/product/filtered-products.vue b/pages/product/filtered-products.vue index 1452d04..8a6a944 100644 --- a/pages/product/filtered-products.vue +++ b/pages/product/filtered-products.vue @@ -168,7 +168,8 @@ chosenArea: [], categoryList: [], categoryMultiIndex: [0, 0, 0], - chosenCategory: [] + chosenCategory: [], + isLoadLocalData: true } }, onLoad(options) { @@ -188,6 +189,9 @@ if (params.inputGoodsName) { this.inputGoodsName = params.inputGoodsName; } + + this.isLoadLocalData = params.showData; + this.loadData(); }, methods: { @@ -201,7 +205,8 @@ this.loadCategoryList(type); // 获取当前定位 await this.getCurAreaArr(); - await this.loadRegionList(); + await this.loadRegionList(); + this.loadProductData(); this.loadOtherCityProductData(); }, @@ -212,7 +217,12 @@ this.taskConditions[0].value = this.chosenArea[this.chosenArea.length - 1].areaId; } }, - async loadProductData(params = {}) { + async loadProductData(params = {}) { + if(!this.isLoadLocalData) { + this.loadMoreStatus = 'over bg-grey padding-tb text-lg' + this.hasMoreData = false; + return; + } params.pageNum = this.pageNum; params.pageSize = this.pageSize; params.goodsName = this.inputGoodsName; diff --git a/pages/product/product-category.vue b/pages/product/product-category.vue index c25706c..f5f7f68 100644 --- a/pages/product/product-category.vue +++ b/pages/product/product-category.vue @@ -20,7 +20,8 @@ return { containerHeight: '100vh - ' + this.CustomBar + 'px - 46px', level0CategoryList: [], - categoryList: [] + categoryList: [], + deptGoodsCategoryIds: [] } }, onLoad() { @@ -36,6 +37,16 @@ level: 0 }); this.level0CategoryList = res0.data; + this.curUserInfo = this.$request.getCurUserInfo(); + if(this.curUserInfo) { + const res = await this.$request.getChooseCategories({ + selectionType: 1, + customerId: this.curUserInfo.customerId + }) + this.deptGoodsCategoryIds = res[1].data.data + // this.deptGoodsCategoryIds = [16,234,106,113] + // [16,234,106,113] + } this.loadTargetTypeCategoryList(params, type); }, async loadTargetTypeCategoryList(params = {}, type = 1) { @@ -48,10 +59,34 @@ res = res[1].data.data; res.forEach(firstCategory => { if (firstCategory.child && firstCategory.child.length) { - this.categoryList = this.categoryList.concat(firstCategory.child) + if(this.deptGoodsCategoryIds.length === 0) { + this.categoryList = this.categoryList.concat(firstCategory.child) + } else { + this.categoryList = this.filterDataInSelect(firstCategory.child) + console.log(this.categoryList); + } } }) }, + filterDataInSelect(data) { + const newData = [] + for(let i = 0; i < data.length; i++) { + const newChild = [] + if(!data[i].child) continue; + for(let j = 0; j < data[i].child.length; j++) { + const filterChild = (data[i].child[j].child || []).filter(item => this.deptGoodsCategoryIds.includes(item.goodsCategoryId)) + if(filterChild.length) { + data[i].child[j].child = filterChild + newChild.push(data[i].child[j]) + } + } + if(newChild.length) { + data[i].child = newChild + newData.push(data[i]) + } + } + return newData + }, bindEvent() { uni.$on(this.$globalFun.VERTICAL_NAV_GET_ITEM, this.chooseSubType); uni.$on(this.$globalFun.VERTICAL_NAV_SEARCH, this.searchType); diff --git a/pages/product/product-detail.vue b/pages/product/product-detail.vue index b5326aa..d81a3a2 100644 --- a/pages/product/product-detail.vue +++ b/pages/product/product-detail.vue @@ -153,8 +153,15 @@ {{productDetail.remark}} --> - - 选择品类 + + + + {{productDetail.parGoodsCategoryName}} + / + + {{productDetail.deptGoodsCategoryName}} + + 查看产品 @@ -163,7 +170,7 @@ @click="chooseSpecs(item)">{{item.goodsStandardName}} - 展开 @@ -192,7 +199,7 @@ {{productDetail.remark}} - + @@ -221,7 +228,7 @@ 购物车 --> - 立即订购 + 立即订购 @@ -265,14 +272,16 @@ totalPickCount: 0, ifHasCsMsg: true, picUrls: [], - curUserInfo: {} + curUserInfo: {}, + defaultAddress: null } }, onLoad(options) { let params = JSON.parse(decodeURIComponent(options.params)); this.inParam = params; this.loadData(); - this.bindEvent(); + this.bindEvent(); + this.loadDefaultAddress() }, onUnload() { this.offBindEvent(); @@ -286,7 +295,8 @@ }, onShareAppMessage(e) { let params = { - goodsId: this.inParam.goodsId + goodsId: this.inParam.goodsId, + distributor: this.curUserInfo.customerId } return { title: this.productDetail.goodsName, @@ -296,7 +306,8 @@ }, onShareTimeline(e) { let params = { - goodsId: this.inParam.goodsId + goodsId: this.inParam.goodsId, + distributor: this.curUserInfo.customerId } return { title: this.productDetail.goodsName, @@ -307,33 +318,41 @@ methods: { async loadData() { await this.$request.refreshCurUserCache(); - this.curUserInfo = this.$request.getCurUserInfo(); - let productDetailMock = await this.$api.data('productDetail'); - this.productDetail = await this.$request.getGoodsDetail({ - goodsId: this.inParam.goodsId - }); - // 默认规格 - this.curProductSpecs = this.productDetail.goodsStandardList[0]; - // 轮播图 - this.swiperList = this.productDetail.goodsImgsMap["0"]; - // 详情图 - this.detailPicList = this.productDetail.goodsImgsMap["1"]; - // 用于点击放大查看图片 - this.swiperList.forEach((picItem) => { - this.picUrls.push(picItem.imgUrl); - }) - this.detailPicList.forEach((picItem) => { - this.picUrls.push(picItem.imgUrl); - }) - let res = await this.$request.getWorkerAllDetailById({ - workerId: this.productDetail.workerId - }) - this.shopInfo = res.data; - - this.guaranteeList = productDetailMock.guaranteeList; - this.productInfo = productDetailMock.productInfo; - this.reviewers = productDetailMock.reviewers; - // this.shopInfo = productDetailMock.shopInfo; + this.curUserInfo = this.$request.getCurUserInfo(); + if(this.curUserInfo) { + let productDetailMock = await this.$api.data('productDetail'); + this.productDetail = await this.$request.getGoodsDetail({ + goodsId: this.inParam.goodsId + }); + // 默认规格 + this.curProductSpecs = this.productDetail.goodsStandardList[0]; + // 轮播图 + this.swiperList = this.productDetail.goodsImgsMap["0"]; + // 详情图 + this.detailPicList = this.productDetail.goodsImgsMap["1"]; + // 用于点击放大查看图片 + this.swiperList.forEach((picItem) => { + this.picUrls.push(picItem.imgUrl); + }) + this.detailPicList.forEach((picItem) => { + this.picUrls.push(picItem.imgUrl); + }) + let res = await this.$request.getWorkerAllDetailById({ + workerId: this.productDetail.workerId + }) + this.shopInfo = res.data; + + this.guaranteeList = productDetailMock.guaranteeList; + this.productInfo = productDetailMock.productInfo; + this.reviewers = productDetailMock.reviewers; + // this.shopInfo = productDetailMock.shopInfo; + if(this.inParam.distributor) { + await this.$request.updateUser({ + customerPlace: this.inParam.distributor, + customerId: this.curUserInfo.customerId + }); + } + } }, async checkLogin() { let loginRes = await this.authLogin(); @@ -412,6 +431,107 @@ uni.pageScrollTo({ selector: '#pageAnchor' + index }) + }, + async loadDefaultAddress() { + let res = await this.$request.getAddressList({ + customerId: this.$request.getCurUserInfo().customerId, + isDefault: 1 + }); + if (res && res.data &&res.data.length) { + const defaultAdd = res.data.filter(i => i.isDefault === 1) + this.defaultAddress = defaultAdd.length ? defaultAdd[0] : res.data[0]; + } + }, + // 检测当前默认地址是否在服务区域之间 + checkDefaultAddressIfInclude() { + return new Promise((resolve, reject) => { + const allAreaId = this.productDetail.goodsAreaList.map(i => i.countryAreaId) + const status = allAreaId.includes(this.defaultAddress.countryId) + console.log('checkDefaultAddressIfInclude == ', status) + if(!status) { + uni.showModal({ + title: '提示', + content: '产品页面的【服务区域】与您默认的地址不匹配,如未选错产品,请提交后改新地址!', + cancelText: '返回查看', + confirmText: '继续下单', + success: res => { + if (res.confirm) { + resolve(true) + } else { + resolve(false) + } + } + }) + } else { + resolve(true) + } + }) + + }, + + async checkCurAreaIncludeServiceAreas() { + return new Promise((resolve, reject) => { + let curLocation = uni.getStorageSync('curLocation'); + if(!curLocation) resolve(true) + const curAreaId = curLocation.area[curLocation.area.length - 1].areaId + const allAreaId = this.productDetail.goodsAreaList.map(i => i.countryAreaId) + if(!allAreaId.includes(curAreaId)) { + uni.showModal({ + title: '提示', + content: '所选产品与您目前所在位置定位不是同一个区/县,请查看产品页面的【服务区域】与【区域备注】!', + cancelText: '返回查看', + confirmText: '继续下单', + success: res => { + if (res.confirm) { + resolve(true) + } else { + resolve(false) + } + } + }) + } else { + resolve(true) + } + }) + }, + + async beforeCheckStatusThenOpen() { + if(this.defaultAddress) { + const status = await this.checkDefaultAddressIfInclude() + if(status) { + this.toggleProductPickModal(null, true) + } + } else { + const areaStatus = await this.checkCurAreaIncludeServiceAreas() + if(areaStatus) { + this.toggleProductPickModal(null, true) + } + } + // console.log('checkDefaultAddressIfInclude == start',) + // const status = await this.checkDefaultAddressIfInclude() + // console.log('checkDefaultAddressIfInclude == ', status) + // if(status) { + // const areaStatus = await this.checkCurAreaIncludeServiceAreas() + // if(areaStatus) { + // this.toggleProductPickModal(null, true) + // } + // } + + // if(!status) { + // uni.showModal({ + // title: '提示', + // content: '所选产品与您目前所在位置定位不是同一个区/县,请查看产品页面的【服务区域】与【区域备注】!', + // cancelText: '返回查看', + // confirmText: '继续下单', + // success: res => { + // if (res.confirm) { + // this.toggleProductPickModal(null, true) + // } + // } + // }) + // } else { + // this.toggleProductPickModal(null, true) + // } }, async toggleProductPickModal(e, orderNow) { this.orderNow = orderNow ? true : false; @@ -440,8 +560,8 @@ }); }, showIndex() { - uni.navigateTo({ - url: '/pages/index/index' + uni.reLaunch({ + url: '/pages/index/home' }); }, defaultHead(url) { diff --git a/pages/product/product-pick.vue b/pages/product/product-pick.vue index aaea760..501b7bd 100644 --- a/pages/product/product-pick.vue +++ b/pages/product/product-pick.vue @@ -5,9 +5,19 @@ - - {{curSpec.goodsPrice}} - /{{curSpec.goodsUnit}} + + + {{curSpec.goodsPrice}} + /{{curSpec.goodsUnit}} + + + {{productInfo.parGoodsCategoryName}} + / + + {{productInfo.deptGoodsCategoryName}} + + + {{productInfo.goodsDesc}} @@ -24,7 +34,12 @@ {{item.goodsStandardName}} - + @@ -51,15 +66,15 @@ props: { shopInfo: { type: Object, - default: {} + default: () => {} }, productInfo: { type: Object, - default: {} + default: () => {} }, specsList: { type: Array, - default: [] + default: () => [] }, orderNow: { type: Boolean, @@ -72,13 +87,18 @@ // specsList: [], totalPrice: 0, pickList: [], - totalPickCount: 0 + totalPickCount: 0, + defaultAddress: null } }, watch: { specsList(newV, oldV) { this.loadData(); } + }, + mounted() { + + this.loadDefaultAddress() }, methods: { loadData() { @@ -89,7 +109,8 @@ salePrice: item.discountPrice, pickCount: 0 }) - }.bind(this)); + }.bind(this)); + }, changePiecesNum(piecesNum, index) { let spec = this.pickList[index]; @@ -114,6 +135,28 @@ } } return pickedList; + }, + + async loadDefaultAddress() { + let res = await this.$request.getAddressList({ + customerId: this.$request.getCurUserInfo().customerId, + isDefault: 1 + }); + if (res && res.data &&res.data.length) { + this.defaultAddress = res.data[0]; + } + }, + // 检测当前默认地址是否在服务区域之间 + checkDefaultAddressIfInclude() { + if(!this.defaultAddress) return true + const allAreaId = this.shopInfo.workerAreas.map(i => i.districtId) + return allAreaId.includes(this.defaultAddress.countryId) + }, + overstock(maxStock) { + uni.showToast({ + icon: 'none', + title: '最大库存为:'+maxStock + }) }, submit() { if (this.orderNow) { @@ -125,26 +168,31 @@ title: '请选择型号' }) return; - } - let params = { - pickedProductList: [{ - ...this.shopInfo, - totalMoney: this.totalPrice, - product: [{ - ...this.productInfo, - discountPrice: this.specsList[0].discountPrice, - goodsPrice: this.specsList[0].goodsPrice, - pickedList: pickedList - }] - }] - } - uni.navigateTo({ - url: '../order/order-detail?params=' + encodeURIComponent(JSON.stringify(params)) - }) + } + this.makeOrder(pickedList) + } else { // 从加入购物车按钮进来的触发父页面事件 uni.$emit('product-detail_add2Cart', this.totalPickCount) } + }, + makeOrder(pickedList) { + let params = { + pickedProductList: [{ + ...this.shopInfo, + totalMoney: this.totalPrice, + product: [{ + ...this.productInfo, + discountPrice: this.specsList[0].discountPrice, + goodsPrice: this.specsList[0].goodsPrice, + pickedList + }], + insuranceManagers: this.productInfo.insuranceManagers + }] + } + uni.navigateTo({ + url: '../order/order-detail?params=' + encodeURIComponent(JSON.stringify(params)) + }) } }, } diff --git a/uni_modules/uni-number-box/components/uni-number-box/uni-number-box.vue b/uni_modules/uni-number-box/components/uni-number-box/uni-number-box.vue index 113257e..a338672 100644 --- a/uni_modules/uni-number-box/components/uni-number-box/uni-number-box.vue +++ b/uni_modules/uni-number-box/components/uni-number-box/uni-number-box.vue @@ -138,7 +138,8 @@ } value = +value; if (value > this.max) { - value = this.max; + value = this.max; + this.$emit('overstock', this.max) } else if (value < this.min) { value = this.min; }