From 0f5046d2383f4268e0d3deb30026a7f3c9b09619 Mon Sep 17 00:00:00 2001 From: Enzo <1284707383@qq.com> Date: Thu, 29 Jul 2021 17:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B3=E8=AF=B7=E9=80=80=E6=AC=BE=20?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E8=AF=A6=E6=83=85=20=E6=94=B6=E8=97=8F?= =?UTF-8?q?=E5=88=97=E8=A1=A8(=E4=BC=98=E5=8C=96)=20=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=A1=B5=E9=9D=A2=E5=95=86=E5=93=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=8E=A5=E5=8F=A3=20=E7=99=BB=E5=BD=95(=E5=AE=8C?= =?UTF-8?q?=E5=96=84)=20=E8=AE=A2=E5=8D=95=E8=AF=A6=E6=83=85(=E5=AE=8C?= =?UTF-8?q?=E5=96=84)=20=20=E6=88=91=E7=9A=84=E9=A2=91=E9=81=93(=E5=AE=8C?= =?UTF-8?q?=E5=96=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api.js | 5 +- common/http.js | 2 +- common/uploadFile.js | 5 +- pages/channel/index.vue | 40 +++++++++++-- pages/collect/index.vue | 6 +- pages/discover/discover.vue | 4 +- pages/goodsDetail/index.vue | 27 ++++++--- pages/index/index.vue | 2 +- pages/order/apply_refund.vue | 8 +-- pages/order/confirm_order.vue | 108 ++++++++++++++++++++++++++++------ pages/order/order.vue | 4 +- pages/order/order_details.vue | 7 ++- pages/order/refund_detail.vue | 7 ++- pages/order/unpay_details.vue | 7 ++- pages/user/user.vue | 4 +- 15 files changed, 175 insertions(+), 61 deletions(-) diff --git a/common/api.js b/common/api.js index 322eafb..2486592 100644 --- a/common/api.js +++ b/common/api.js @@ -12,7 +12,8 @@ export const API_WXLOGIN = '/api/login'; //登录 export const API_INDEX = '/api/index'; //首页 export const API_FAVOURITE = '/api/agent_product/guess'; //猜你喜欢 -export const API_CHANNEL = '/api/channel/list'; //频道列表 +export const API_CHANNEL = '/api/channel/list'; //全部频道列表 +export const API_MYCHANNEL = '/api/user_channel/list'; //我的频道列表 export const API_EDITCHANNEL = '/api/user_channel/update'; //编辑频道 export const API_FINDARTICLE = '/api/article/list'; //发现文章列表 @@ -30,7 +31,9 @@ export const API_NOTICEDETAILS = '/api/notice/show'; //公告详情 export const API_REGISTERAGREE = '/api/agent_info/reg_protocol'; //注册协议 export const API_BUYAGREE = '/api/agent_info/buy_protocol'; //购买协议 +export const API_CONFIRMDETAILS = '/api/order/price'; //确认购买商品详情 +export const API_CREATEORDER = '/api/order/create'; //创建订单 export const API_MESSAGELIST = '/api/message/list'; //消息列表 diff --git a/common/http.js b/common/http.js index 0ce021a..9fef4e1 100644 --- a/common/http.js +++ b/common/http.js @@ -94,7 +94,7 @@ function $http(url, data = {}, options = {}){ let user_info = uni.getStorageSync('userinfo') let user_token = user_info.token - options.Authentication = user_token + options.Authentication = user_token || '' // 发起请求 that.$u.post(url, data, options).then(res => { resolve(res); diff --git a/common/uploadFile.js b/common/uploadFile.js index 69c50bf..889a938 100644 --- a/common/uploadFile.js +++ b/common/uploadFile.js @@ -29,8 +29,6 @@ const uploadFile = function (filePath, successc, failc) { // 获取上传的文件类型 fileType let fileTypeIndex = filePath.lastIndexOf('.'); let fileType = filePath.substring(fileTypeIndex); - - console.log('上传方法的图片',filePath) uni.uploadFile({ url: url + url_a,//开发者服务器 url @@ -42,13 +40,12 @@ const uploadFile = function (filePath, successc, failc) { }, success: function (res) { - console.log('上传文件...', res) if (res.statusCode != 200 || !res.data) { failc(new Error('上传错误:' + JSON.stringify(res))) return; } let res_data = JSON.parse(res.data); - successc && successc(res_data.data); + successc && successc(res_data.data.path); }, fail: function (err) { failc(err); diff --git a/pages/channel/index.vue b/pages/channel/index.vue index 0b73f67..4557689 100644 --- a/pages/channel/index.vue +++ b/pages/channel/index.vue @@ -36,20 +36,32 @@ select_list: {}, // 当前选中的频道 channel_list: [], chanel_id: [], + my_list: [], + content_list: [] } }, onLoad(){ - this.getChannel() + this.getMyChancel() }, methods: { + //我的频道列表 + getMyChancel(){ + this.$http(this.API.API_MYCHANNEL).then(res => { + this.my_list = res.data; + if(this.my_list) { + this.getChannel() + } + + }) + }, updateChannel() { this.$http(this.API.API_EDITCHANNEL,{channels: this.chanel_id},{showLoading:false}).then(res => { - console.log(res) + this.$msg('添加频道成功') }).catch(err => { }) }, - //频道列表 + //全部频道列表 getChannel() { this.$http(this.API.API_CHANNEL).then(res => { let list = []; @@ -57,10 +69,11 @@ if(item.pid == 0) { item.content = []; list.push(item); + }else { + this.content_list.push(item) } }) this.channel_list = list; - res.data.forEach(item => { this.channel_list.forEach((item2,index) => { if(item.pid == item2.id) { @@ -71,12 +84,23 @@ } }) }) + + this.channel_list.forEach((item,index) => { + item.content.forEach((item2,index2) => { + this.my_list.forEach((item3,index3) => { + console.log(item3) + if(item3 == item2.id) { + this.activaItem(item2,index2,index,item,1) + } + }) + }) + }) }).catch(err => { }) }, // 添加频道 - activaItem(item2, index2, index, item){ + activaItem(item2, index2, index, item,type){ let select_list = this.select_list; if(!select_list[item2.name]){ if(Object.keys(select_list).length > 11){ @@ -85,9 +109,13 @@ this.select_list[item2.name] = {p_index: index, c_index: index2}; this.chanel_id.push(item2.id); this.channel_list[index].content[index2].checked = true; + console.log('频道',this.select_list) } } - this.updateChannel(); + if(type != 1) { + this.updateChannel(); + } + }, // 移除频道 cancelItem(key){ diff --git a/pages/collect/index.vue b/pages/collect/index.vue index fea6d94..b6ca1a6 100644 --- a/pages/collect/index.vue +++ b/pages/collect/index.vue @@ -76,15 +76,15 @@ }, // 切换收藏状态 switchCollect(index,if_collect){ - let goods_id = this.list[index].id; + let goods_id = this.list[index].agent_product_id; if(if_collect) { - this.$http(this.API.API_DELCOLLECT, {id:goods_id}).then(res => { + this.$http(this.API.API_DELCOLLECT, {agent_product_id:goods_id}).then(res => { this.$msg('取消收藏成功!') console.log(res) this.list[index].is_collect = false; }) }else { - this.$http(this.API.API_ADDCOLLECT, {id:goods_id}).then(res => { + this.$http(this.API.API_ADDCOLLECT, {agent_product_id:goods_id}).then(res => { this.$msg('添加收藏成功!') console.log(res) this.list[index].is_collect = true; diff --git a/pages/discover/discover.vue b/pages/discover/discover.vue index e6daffe..9e8126d 100644 --- a/pages/discover/discover.vue +++ b/pages/discover/discover.vue @@ -19,8 +19,8 @@ - {{ loadingText }} - + {{ loadingText }} + diff --git a/pages/goodsDetail/index.vue b/pages/goodsDetail/index.vue index 1ddde8d..ff77333 100644 --- a/pages/goodsDetail/index.vue +++ b/pages/goodsDetail/index.vue @@ -93,7 +93,7 @@ current: 0, // 轮播下标 goods_id: 0, goods_detail: {}, - is_collect: 0, // 1为当前收藏商品了,0为否 + is_collect: false, // 1为当前收藏商品了,0为否 skeletonLoading: true } }, @@ -130,10 +130,20 @@ this.$url('/pages/login/index?type=userinfo'); return; } - this.$http(this.API.API_COLLECT_DEAL, {goods_id: this.goods_id}).then(res => { - this.$msg(res.msg); - this.is_collect = Boolean(res.data.is_collect); - }) + + if(this.is_collect) { + this.$http(this.API.API_DELCOLLECT, {agent_product_id:this.goods_id}).then(res => { + this.$msg('取消收藏成功!') + this.is_collect = false + console.log(res) + }) + }else { + this.$http(this.API.API_ADDCOLLECT, {agent_product_id:this.goods_id}).then(res => { + this.$msg('添加收藏成功!') + this.is_collect = true + console.log(res) + }) + } }, // 拨打电话 makePhoneCall(phoneStr){ @@ -154,8 +164,7 @@ // 跳转到确认下单页面 toAddOrder(){ let goods_id = this.goods_detail.id; - let goods_specs_id = this.goods_detail.specs[0].id - this.$url('/pages/order/confirm_order?goods_id='+ goods_id +'&goods_specs_id='+ goods_specs_id); + this.$url('/pages/order/confirm_order?goods_id='+ goods_id); }, // 预览图片 lookImg(index){ @@ -253,8 +262,8 @@ flex-wrap: wrap; padding: 30rpx 0 10rpx 0; .label-item{ - width: 162rpx; - // padding: 20rpx; + width: max-content; + padding: 20rpx; height: 70rpx; border-radius: 10rpx; border: 2rpx solid #1998FE; diff --git a/pages/index/index.vue b/pages/index/index.vue index 003eefd..1ebc68c 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -127,7 +127,7 @@ notice: [] } }, - onLoad() { + onShow() { // this.addRandomData(); this.getIndexData() this.getFavourite() diff --git a/pages/order/apply_refund.vue b/pages/order/apply_refund.vue index 7db712c..29defa5 100644 --- a/pages/order/apply_refund.vue +++ b/pages/order/apply_refund.vue @@ -190,10 +190,8 @@ for (let i = 0; i < that.img_list.length; i++) { let upload_img = new Promise((resolve, reject) => { that.uploadFile(that.img_list[i], (res) => { - console.log('标记1',res) resolve(res); }, (err) => { - console.log('标记1',err) reject(err); }); }) @@ -205,10 +203,9 @@ return } Promise.all(uploads).then((result) => { - console.log('图片上传...', result.path) let img_url_list = []; if(result.length > 0){ - img_url_list = JSON.stringify(result.path); + img_url_list = result; } if(img_url_list) { that.realSubmitInfo(img_url_list); @@ -216,7 +213,6 @@ }).catch(err => { - console.log(err) that.is_publish = false; // 恢复提交按钮 uni.showModal({ title: '', @@ -246,7 +242,7 @@ console.log(that.order_id) setTimeout(() => { console.log(that.order_id) - that.$url('/pages/order/apply-details?order_id='+that.order_id,{type:'launch'}) + that.$url('/pages/order/refund_detail?order_id='+that.order_id,{type:'launch'}) },1000) } diff --git a/pages/order/confirm_order.vue b/pages/order/confirm_order.vue index 7283b13..2d4fc18 100644 --- a/pages/order/confirm_order.vue +++ b/pages/order/confirm_order.vue @@ -1,21 +1,21 @@