diff --git a/api/app/index.js b/api/app/index.js index 4879d53..416c922 100644 --- a/api/app/index.js +++ b/api/app/index.js @@ -140,7 +140,7 @@ export function appGetUserById(userId) { // 查询积分记录列表 export function listAppIntegra(query) { return request({ - url: '/app/appIntegra/list', + url: '/app/appIntegra/my', method: 'get', params: query }) @@ -273,3 +273,20 @@ export function getVirtualResourceOrder(orderNo, sync) { } }) } + +// 查询当前用户的虚拟支付订单 +export function listMyVirtualResourceOrders(query) { + return request({ + url: '/app/virtual-pay/resource-orders', + method: 'get', + params: query + }) +} + +// 取消当前用户的待支付资源订单 +export function cancelVirtualResourceOrder(orderNo) { + return request({ + url: '/app/virtual-pay/resource-orders/' + orderNo, + method: 'delete' + }) +} diff --git a/pages.json b/pages.json index 141ff76..3dfa9fe 100644 --- a/pages.json +++ b/pages.json @@ -66,6 +66,14 @@ "enablePullDownRefresh" : true } }, + { + "path" : "pages/tool/integralCode", + "style" : + { + "navigationBarTitleText" : "积分源码", + "enablePullDownRefresh" : true + } + }, { "path" : "pages/tool/resource", "style" : @@ -116,12 +124,20 @@ } }, { - "path" : "pages/mine/integral_record", - "style" : - { - "navigationBarTitleText" : "消费记录", - "enablePullDownRefresh" : false - } + "path" : "pages/mine/integral_record", + "style" : + { + "navigationBarTitleText" : "积分记录", + "enablePullDownRefresh" : false + } + }, + { + "path" : "pages/mine/virtual_orders", + "style" : + { + "navigationBarTitleText" : "我的订单", + "enablePullDownRefresh" : false + } }, { "path" : "pages/mine/exchange_records", diff --git a/pages/blog/resource.vue b/pages/blog/resource.vue index 7220f6b..9ca16fc 100644 --- a/pages/blog/resource.vue +++ b/pages/blog/resource.vue @@ -33,6 +33,36 @@ selectable="true"> --> + + + + + + + 选择版本 + + + + + {{item.listName}} + 已拥有 + 已停用 + + + + ¥{{formatPrice(getPayablePriceFen(item))}} + + + + 暂无可购买规格,请联系管理员 + + @@ -40,23 +70,46 @@ - 资源列表 + {{isLookAd == 3 ? '已购资源' : '资源列表'}} - 复制下方链接打开手机浏览器进行下载!!! - 请先点击下方按钮即可获取资源下载列表! + + @@ -67,15 +120,31 @@ - - - 广告查看 - - - 积分获取( {{resourceInfo.adNumber}} 积分 ) - - - {{paying ? '支付结果确认中...' : '付费获取( ¥' + formatPrice(resourceInfo.priceFen) + ' )'}} + + + + + {{selectedIsUpgrade ? '升级补差' : '已选'}} + {{selectedSpec.listName}} + + ¥{{formatPrice(selectedPayPriceFen)}} + + + 广告查看 + + + 积分获取( {{resourceInfo.adNumber}} 积分 ) + + + {{paidButtonText}} + @@ -103,6 +172,7 @@ }, isLookAd:null, paying: false, + selectedResourceListId: null, tag_style: { h1: 'line-height: 50px;font-size:16px;', h2: 'line-height: 50px;font-size:16px', @@ -115,6 +185,53 @@ type:0 } }, + computed: { + paySpecs() { + var list = this.resourceInfo.appResourceListList || []; + return list.filter(function(item) { + return item.status == 1 || item.purchased; + }); + }, + purchasedSpecs() { + return this.paySpecs.filter(function(item) { + return !!item.purchased && !!item.listUrl; + }); + }, + highestPurchasedSpec() { + var purchased = this.paySpecs.filter(function(item) { + return !!item.purchased; + }); + purchased.sort(function(left, right) { + var sortDiff = Number(right.sortOrder || 0) - Number(left.sortOrder || 0); + return sortDiff || Number(right.id || 0) - Number(left.id || 0); + }); + return purchased.length ? purchased[0] : null; + }, + selectedSpec() { + var selectedId = this.selectedResourceListId; + return this.paySpecs.find(function(item) { + return String(item.id) === String(selectedId); + }) || null; + }, + selectedPayPriceFen() { + return this.getPayablePriceFen(this.selectedSpec); + }, + selectedIsUpgrade() { + return this.isUpgradeSpec(this.selectedSpec); + }, + paidButtonText() { + if (!this.selectedSpec) { + return '暂无可购买规格'; + } + if (this.selectedSpec.purchased) { + return '已购买,查看资源'; + } + if (this.paying) { + return '支付结果确认中...'; + } + return this.selectedIsUpgrade ? '补差价升级' : '立即购买'; + } + }, // 分享好友配置 onShareAppMessage(res) { var that = this; @@ -150,6 +267,9 @@ return } this.id = id + if (option && /^\d+$/.test(String(option.resourceListId || ''))) { + this.selectedResourceListId = option.resourceListId + } if(option.type){ this.type = option.type } @@ -278,6 +398,9 @@ this.isLookAd = 3 } that.resourceInfo = response.data + if (response.data.isAd == 3) { + that.selectDefaultSpec() + } var str = that.resourceInfo.explain || '' if (str.includes("/dev-api")) { that.resourceInfo.explain = str.replace("/dev-api", that.baseUrl) @@ -315,7 +438,9 @@ }) }, copy(url){ - var that = this; + if (!url) { + return; + } uni.setClipboardData({ data: url, showToast: false, @@ -324,6 +449,57 @@ } }); }, + isUpgradeSpec(item){ + if (!item || item.purchased || !this.highestPurchasedSpec) { + return false; + } + return Number(item.sortOrder || 0) > Number(this.highestPurchasedSpec.sortOrder || 0); + }, + getPayablePriceFen(item){ + if (!item) { + return 0; + } + var targetPrice = Number(item.priceFen || 0); + if (!this.isUpgradeSpec(item)) { + return targetPrice; + } + var ownedPrice = Number(this.highestPurchasedSpec.priceFen || 0); + return Math.max(targetPrice - ownedPrice, 0); + }, + selectDefaultSpec(){ + var currentId = this.selectedResourceListId; + var currentExists = this.paySpecs.some(function(item) { + return String(item.id) === String(currentId); + }); + if (currentExists) { + return; + } + var firstUnpurchased = this.paySpecs.find(function(item) { + return item.status == 1 && !item.purchased; + }); + this.selectedResourceListId = firstUnpurchased + ? firstUnpurchased.id + : (this.paySpecs.length ? this.paySpecs[0].id : null); + }, + selectSpec(item){ + if (this.paying) { + return; + } + this.selectedResourceListId = item.id; + }, + handlePaidAction(){ + if (!this.selectedSpec) { + return; + } + if (this.selectedSpec.purchased) { + uni.pageScrollTo({ + selector: '#purchased-resources', + duration: 250 + }); + return; + } + this.payResource(); + }, payResource(){ var that = this; if (this.paying) { @@ -336,7 +512,14 @@ }); return; } - if (!this.resourceInfo.priceFen || this.resourceInfo.priceFen <= 0) { + if (!this.selectedSpec || this.selectedSpec.status != 1) { + uni.showToast({ + title: '请选择可购买的版本', + icon: 'none' + }); + return; + } + if (!this.selectedPayPriceFen || this.selectedPayPriceFen <= 0) { uni.showToast({ title: '价格信息错误', icon: 'none' @@ -356,7 +539,7 @@ provider: 'weixin', success: loginRes => { createVirtualResourceOrder({ - resourceId: that.id, + resourceListId: that.selectedSpec.id, code: loginRes.code }).then(response => { var payParams = response.data; @@ -403,6 +586,7 @@ message: '购买成功', icon: false }); + resourceDownLoad({id: that.id}).then(function() {}); that.getInfo(); return; } @@ -476,18 +660,145 @@ padding: 20rpx 30rpx; } .resource-ad{ - height: 100rpx; - width: 90%; - margin-left: 5%; - margin-bottom: 40rpx; + height: 88rpx; + width: 100%; + margin: 0; border-radius: 100rpx; background: #7a60fd; - position: absolute; - bottom: 0; /* 将按钮固定在容器的底部 */ - line-height: 100rpx; + line-height: 88rpx; text-align: center; - font-size: 38rpx; + font-size: 34rpx; color: white; + box-shadow: 0 8rpx 22rpx rgba(122, 96, 253, 0.22); + } + .bottom-action-bar{ + position: fixed; + left: 0; + right: 0; + bottom: 0; + z-index: 99; + box-sizing: border-box; + width: 100%; + padding: 18rpx 5% calc(18rpx + constant(safe-area-inset-bottom)); + padding: 18rpx 5% calc(18rpx + env(safe-area-inset-bottom)); + background: rgba(255, 255, 255, 0.98); + border-top: 1rpx solid #eeeeee; + box-shadow: 0 -10rpx 30rpx rgba(45, 45, 45, 0.1); + } + .action-summary{ + height: 54rpx; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 12rpx 12rpx; + } + .action-summary-name{ + display: flex; + align-items: center; + min-width: 0; + } + .action-summary-label{ + flex-shrink: 0; + margin-right: 14rpx; + padding: 3rpx 12rpx; + border-radius: 999rpx; + font-size: 21rpx; + color: #6d52f5; + background: #f0ecff; + } + .action-summary-value{ + max-width: 420rpx; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + font-size: 27rpx; + color: #333333; + } + .action-summary-price{ + flex-shrink: 0; + font-size: 31rpx; + font-weight: 600; + color: #e54d42; + } + .action-placeholder{ + width: 100%; + height: calc(142rpx + constant(safe-area-inset-bottom)); + height: calc(142rpx + env(safe-area-inset-bottom)); + } + .action-placeholder-paid{ + height: calc(208rpx + constant(safe-area-inset-bottom)); + height: calc(208rpx + env(safe-area-inset-bottom)); + } + .resource-owned{ + background: #39b54a; + } + .spec-section{ + margin-bottom: 45rpx; + } + .spec-list{ + margin: 24rpx 10rpx 0; + } + .spec-item{ + min-height: 92rpx; + margin-bottom: 18rpx; + padding: 0 28rpx; + border: 2rpx solid #e5e5e5; + border-radius: 18rpx; + display: flex; + align-items: center; + justify-content: space-between; + background: #ffffff; + } + .spec-item-selected{ + border-color: #7a60fd; + background: #f5f2ff; + box-shadow: 0 8rpx 20rpx rgba(122, 96, 253, 0.12); + } + .spec-name{ + font-size: 29rpx; + font-weight: 500; + color: #2b2b2b; + } + .spec-price{ + font-size: 31rpx; + font-weight: 600; + color: #e54d42; + } + .upgrade-price-label{ + margin-right: 6rpx; + font-size: 22rpx; + font-weight: 500; + color: #7a60fd; + } + .purchased-tag, + .disabled-tag{ + display: inline-block; + margin-left: 16rpx; + padding: 4rpx 12rpx; + border-radius: 999rpx; + font-size: 21rpx; + font-weight: 400; + } + .purchased-tag{ + color: #248b3e; + background: #e8f7ec; + } + .disabled-tag{ + color: #8799a3; + background: #f1f1f1; + } + .empty-spec{ + margin: 24rpx 10rpx; + padding: 28rpx; + text-align: center; + border-radius: 18rpx; + color: #8799a3; + background: #f7f7f7; + } + .purchased-file{ + padding: 24rpx; + border-radius: 20rpx; + background: #fafafa; } .file-list{ margin: 30rpx; diff --git a/pages/index.vue b/pages/index.vue index 6d8be82..d95ce11 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -22,7 +22,7 @@ --> - + @@ -33,6 +33,11 @@ 资源分享 + + + + 积分源码 + diff --git a/pages/mine/index.vue b/pages/mine/index.vue index e64a1a5..8fe2131 100644 --- a/pages/mine/index.vue +++ b/pages/mine/index.vue @@ -53,7 +53,7 @@ - 兑换记录 - - + + + + 积分记录 + + + + + 我的订单 - 消费记录 - @@ -318,6 +323,19 @@ } }, + virtualOrders(){ + var that = this + if (!this.userid) { + that.$refs.uToast.show({ + type: 'success', + title: '', + message: "请先授权登录", + icon: false + }) + }else{ + this.$tab.navigateTo('/pages/mine/virtual_orders') + } + }, Signin() { var that = this if (!this.userid) { diff --git a/pages/mine/integral_record.vue b/pages/mine/integral_record.vue index c9f36ee..97fe0b0 100644 --- a/pages/mine/integral_record.vue +++ b/pages/mine/integral_record.vue @@ -2,7 +2,7 @@ - 消费明细 + 积分明细 @@ -20,10 +20,6 @@ -{{item.integralNumber}} - -¥{{formatMoney(item.integralNumber)}} - - - @@ -52,9 +48,7 @@ return { queryParams: { pageNum: 1, - pageSize: 10, - userId: uni.getStorageSync("userInfo").userId, - + pageSize: 10 }, dataList: [], total: 0, @@ -91,9 +85,6 @@ this.getDataList() }, methods: { - formatMoney(priceFen) { - return (Number(priceFen || 0) / 100).toFixed(2) - }, getDataList(){ var that = this; listAppIntegra(this.queryParams).then(response => { diff --git a/pages/mine/virtual_orders.vue b/pages/mine/virtual_orders.vue new file mode 100644 index 0000000..0c20751 --- /dev/null +++ b/pages/mine/virtual_orders.vue @@ -0,0 +1,330 @@ + + + + + diff --git a/pages/tool/freeCode.vue b/pages/tool/freeCode.vue index f45f751..22c00a6 100644 --- a/pages/tool/freeCode.vue +++ b/pages/tool/freeCode.vue @@ -9,7 +9,7 @@ 需要的小伙伴请尽快转存,随时可能失效 - diff --git a/pages/tool/highQualityCode.vue b/pages/tool/highQualityCode.vue index 825c713..78dc9dd 100644 --- a/pages/tool/highQualityCode.vue +++ b/pages/tool/highQualityCode.vue @@ -9,7 +9,7 @@ 需要的小伙伴请尽快转存,随时可能失效 - diff --git a/pages/tool/integralCode.vue b/pages/tool/integralCode.vue new file mode 100644 index 0000000..0bfbcbb --- /dev/null +++ b/pages/tool/integralCode.vue @@ -0,0 +1,457 @@ + + + + +