From 884667629b15e63d719e571a9a499acf2f27bf4f Mon Sep 17 00:00:00 2001 From: chenkun <3289431190@qq.com> Date: Fri, 20 Sep 2024 20:23:30 +0800 Subject: [PATCH] . --- api/api.js | 2 +- pages_mine/mine/promotionRecord.vue | 11 +- .../mine/sonPage/promotion/promotionDetail.vue | 119 ++++++++++++++++----- .../mine/sonPage/promotion/promotionRecordList.vue | 2 +- pages_mine/mine/updateUserInfo.vue | 108 +++++++++++++++---- 5 files changed, 186 insertions(+), 56 deletions(-) diff --git a/api/api.js b/api/api.js index cf7e006..582ed68 100644 --- a/api/api.js +++ b/api/api.js @@ -164,7 +164,7 @@ const config = { showLoading : true, }, // 确认推广 - ConfirmPromotion: { + confirmPromotion: { url: '/api/info/confirmPromotion', method: 'POST', auth: true, diff --git a/pages_mine/mine/promotionRecord.vue b/pages_mine/mine/promotionRecord.vue index c7a964d..93441bb 100644 --- a/pages_mine/mine/promotionRecord.vue +++ b/pages_mine/mine/promotionRecord.vue @@ -59,7 +59,14 @@ }, data() { return { - promotionRecordList: [], + promotionRecordList: [ + { + name:'aaa', + tuTime:1, + price:9.9, + createTime:new Date(), + } + ], queryParams: { pageNo: 1, pageSize: 10, @@ -70,7 +77,6 @@ } }, onReachBottom() { - console.log("=====") let allTotal = this.queryParams.pageNo * this.queryParams.pageSize if (allTotal < this.total) { //当前条数小于总条数 则增加请求数 @@ -79,7 +85,6 @@ } }, mounted() { - console.log("====") this.getData() }, methods: { diff --git a/pages_mine/mine/sonPage/promotion/promotionDetail.vue b/pages_mine/mine/sonPage/promotion/promotionDetail.vue index 6315aa6..b5fb348 100644 --- a/pages_mine/mine/sonPage/promotion/promotionDetail.vue +++ b/pages_mine/mine/sonPage/promotion/promotionDetail.vue @@ -20,7 +20,7 @@ --> - 推广作品 + 推广作品名称 {{item.name}} @@ -42,8 +42,8 @@ 剩余推广时长 {{item.remainingPromotionTime}} - - + + 付费周期 - {{item.day}}天 + {{popupData.day}}天 金额 - ¥{{item.money}} + ¥{{popupData.money}} @@ -86,11 +86,11 @@ - + - 确认支付{{ item.money }}元,可置顶{{ item.day }}天 + 确认支付{{ popupData.money }}元,可置顶{{ popupData.day }}天 @@ -134,6 +134,10 @@ day: 0, money: 0, }, + popupData: { + day: 0, + money: 0, + }, param: { type: 'default', title: '结束后跳转标签页', @@ -149,7 +153,9 @@ methods: { // 获取推广详情数据 getData() { - this.$api('infoGetPromotionDetail',{id: this.item.id}, res => { + this.$api('infoGetPromotionDetail', { + id: this.item.id + }, res => { if (res.code == 200) { this.item = res.result @@ -196,18 +202,19 @@ select(e) { console.log('选中该项:', e); - // 使用正则表达式匹配所有的数字 - const matches = e.name.match(/\d+/g).map(Number); + // 使用正则表达式匹配整数和浮点数 + const matches = e.name.match(/(\d+\.?\d*)/g).map(Number); // 如果匹配到数字,则输出 - if (matches) { + if (matches && matches.length >= 2) { console.log(matches, "matches"); - this.item.day = matches[0] - this.item.money = matches[1] + + // 提取天数和金额 + this.popupData.day = matches[0]; // 例如,置顶天数 + this.popupData.money = matches[1]; // 例如,金额 + this.$refs.actionSheet.close() //关闭弹框 + this.$refs.popup.open() //打开另外一个弹框 } - console.log(this.item.day, "this.item.day"); - this.$refs.actionSheet.close() //关闭弹框 - this.$refs.popup.open() //打开另外一个弹框 }, // ActionSheet 操作菜单关闭 @@ -224,10 +231,10 @@ }, // 继续推广按钮 continueToPromotion() { - if(this.item.phone=='' || this.item.phone==null){ + if (this.item.phone == '' || this.item.phone == null) { return uni.showToast({ title: '请输入联系电话', - icon : 'none' + icon: 'none' }) } this.$refs.actionSheet.open(); @@ -238,17 +245,53 @@ this.$refs.confirmationPopup.open() this.$refs.popup.close() }, - pay() { - this.$refs.confirmationPopupUpload.open() - return - // 支付逻辑待补充 - this.$api('ConfirmPromotion', {}, res => { - if (res.code == 200) { - //平台审核 - this.$refs.confirmationPopupUpload.open() - } - }) + + + // 发起支付 + payOrder() { + let self = this + + let data = { + id: this.item.id, + day: this.popupData.day, + money: this.popupData.money, + } + + + this.$api('confirmPromotion', data, + res => { + if (res.code == 200) { + if (self.form.topId) { + uni.requestPayment({ + provider: 'wxpay', // 服务提提供商 + timeStamp: res.result.timeStamp, // 时间戳 + nonceStr: res.result.nonceStr, // 随机字符串 + package: res.result.packageValue, + signType: res.result.signType, // 签名算法 + paySign: res.result.paySign, // 签名 + success: function(res) { + console.log('支付成功', res); + self.$refs.confirmationPopupUpload.open() + // self.$refs.confirmationPopup.close() + }, + fail: function(err) { + console.log('支付失败', err); + self.$refs.confirmationPopup.close() + uni.showToast({ + icon: 'none', + title: "支付失败" + }) + } + }); + } else { + self.$refs.confirmationPopupUpload.open() + } + + } + }) + }, + } } @@ -291,6 +334,7 @@ .value { width: 40%; + text-align: right; } } } @@ -307,6 +351,25 @@ background: $uni-linear-gradient-btn-color; } } + + + .confirmationPopup { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + width: 100%; + height: 300rpx; + + image { + margin-top: 40rpx; + } + + .info { + margin-top: 40rpx; + font-size: 26rpx; + } + } } diff --git a/pages_mine/mine/sonPage/promotion/promotionRecordList.vue b/pages_mine/mine/sonPage/promotion/promotionRecordList.vue index df7d752..2b44a95 100644 --- a/pages_mine/mine/sonPage/promotion/promotionRecordList.vue +++ b/pages_mine/mine/sonPage/promotion/promotionRecordList.vue @@ -3,7 +3,7 @@ - + diff --git a/pages_mine/mine/updateUserInfo.vue b/pages_mine/mine/updateUserInfo.vue index 46a99be..6356a63 100644 --- a/pages_mine/mine/updateUserInfo.vue +++ b/pages_mine/mine/updateUserInfo.vue @@ -5,11 +5,11 @@ - - 头像 - - + + + 头像 + + @@ -17,8 +17,7 @@ 昵称 - + @@ -28,8 +27,7 @@ 联系方式 - + @@ -57,12 +55,12 @@ data() { return { form: { - sex: userInfo.sex || '', + sex: '', nickName: '1', - phone: userInfo.phone || '', - image: userInfo.headImage, + phone: '', + headImage: '', }, - itemUserImage: userInfo.headImage, + // itemUserImage: userInfo.headImage, fileList: [], sexList: [{ name: '男', @@ -77,6 +75,10 @@ } }, mounted() { + this.form = this.userInfo + if (this.userInfo.sex == '' || this.userInfo.sex == null) { + this.userInfo.sex = '未知' + } console.log(this.userInfo.headImage, "this.userInfo.headImage"); // this.fileList.push({ // url: this.userInfo.headImage @@ -102,17 +104,42 @@ }) }, - // 修改头像 - updateUserImage(e) { - console.log(e, "e"); - let self = this - // e.file.forEach(file => { - self.$Oss.ossUpload(file.url).then(url => { - self.itemUserImage = { - url + // 打开图片选择器并更新头像 + chooseAndUpdateUserImage() { + const self = this; + + uni.chooseImage({ + count: 1, // 限制选择一张图片 + sizeType: ['original', 'compressed'], // 可选择原图或压缩图 + sourceType: ['album', 'camera'], // 可以从相册或相机选择 + success: (res) => { + // 获取选择的图片临时路径 + const tempFilePath = res.tempFilePaths[0]; + console.log(tempFilePath, "Selected Image"); + + // 调用上传方法 + self.updateUserImage(tempFilePath); + }, + fail: (err) => { + console.error("Failed to select image:", err); } - }) - // }) + }); + }, + + // 修改头像 + updateUserImage(filePath) { + const self = this; + + console.log(filePath, "Selected Image Path"); + + // 调用上传方法 + self.$Oss.ossUpload(filePath).then(url => { + // 将上传后的图片URL设置到头像中 + self.form.headImage = url; + console.log("Uploaded Image URL:", url); + }).catch(err => { + console.error("Failed to upload image:", err); + }); }, deleteImage(e) { @@ -162,6 +189,27 @@ .frame { padding: 28rpx 28rpx 0 28rpx; + .headImage { + display: flex; + // width: 100vw; + padding: 20rpx; + + .key { + width: 70%; + height: 150rpx; + display: flex; + align-items: center; + } + + .value { + border-radius: 50%; + border: 1px solid red; + overflow: hidden; + width: 30%; + } + } + + .item { display: flex; justify-content: space-between; @@ -180,4 +228,18 @@ } } } + + /deep/ .input__content { + /deep/.uv-input__content__field-wrapper { + border: 1px solid red; + + input { + text-align: right; + } + } + } + + /deep/ .uv-input__content__field-wrapper__field { + text-align: right; + } \ No newline at end of file