Browse Source

feat(分享): 优化二维码获取逻辑并添加加载状态

refactor(提现): 修改提现成功后的处理逻辑

style(列表): 移除多余toast提示并优化空状态显示

feat(全局): 添加二维码预加载功能到App.vue

fix(样式): 调整book-container的定位样式
hfll
hflllll 1 month ago
parent
commit
c2578e19e8
7 changed files with 95 additions and 46 deletions
  1. +18
    -8
      App.vue
  2. +11
    -0
      api/modules/promotion.js
  3. +4
    -4
      mixins/list.js
  4. +5
    -1
      stores/index.js
  5. +5
    -5
      subPages/home/directory.vue
  6. +25
    -12
      subPages/user/promote.vue
  7. +27
    -16
      subPages/user/share.vue

+ 18
- 8
App.vue View File

@ -1,10 +1,23 @@
<script>
export default {
methods: {
//
async getQrcode() {
uni.getImageInfo({
src: `${this.$config.baseURL}/promotion/qrCode?token=${uni.getStorageSync('token')}`,
success: (image) => {
this.Qrcode = image.path;
this.$store.commit('setQrcode', this.Qrcode)
},
fail: (err) => {
console.error('获取二维码失败:', err);
}
});
}
},
onLaunch() {
//
console.log('App OnLaunch')
//
this.getQrcode()
},
async onShow() {
// if(!uni.getStorageSync('token')){
@ -12,11 +25,8 @@
// url: '/subPages/login/login',
// })
// }
console.log(uni.getStorageSync('token'));
console.log('App Show')
await this.$store.dispatch('initData')
// console.log('')
console.log('配置数据初始化完成')
},
onHide: function() {
console.log('App Hide')


+ 11
- 0
api/modules/promotion.js View File

@ -22,6 +22,17 @@ export default {
},
// 提现成功
async withdrawSuccess(data){
return request({
url: "/promotion/withdrawSuccess",
method: "POST",
data,
needToken: true,
showLoading: true,
})
},
// 提现
async withdraw(data){
return request({


+ 4
- 4
mixins/list.js View File

@ -81,10 +81,10 @@ export default {
// 如果没有值了
if (!resData.length) {
this.hasMore = false
uni.showToast({
title: '暂无更多数据',
icon: 'none'
})
// uni.showToast({
// title: '暂无更多数据',
// icon: 'none'
// })
}else {
this.pageNo++
}


+ 5
- 1
stores/index.js View File

@ -10,7 +10,8 @@ const store = new Vuex.Store({
configList: [],
departmentList: [],
categoryList: [],
userInfo:{}
userInfo:{},
Qrcode: ''
},
mutations: {
// 构造用于uv-picker的树状结构数组
@ -59,6 +60,9 @@ const store = new Vuex.Store({
setUserInfo(state, data) {
state.userInfo = data
},
setQrcode(state, data) {
state.Qrcode = data
},
//
},
actions: {


+ 5
- 5
subPages/home/directory.vue View File

@ -249,12 +249,12 @@ export default {
}
.book-container{
position: sticky;
left: 0;
right: 0;
top: 0;
// position: sticky;
// left: 0;
// right: 0;
// top: 0;
padding: 30rpx;
z-index: 1;
// z-index: 1;
}
.book-info {
display: flex;


+ 25
- 12
subPages/user/promote.vue View File

@ -69,13 +69,19 @@
<view class="balance-section">
<text class="balance-label">余额</text>
<text class="balance-amount">¥{{ userInfo.commission || 0 }}</text>
<uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
<!-- <uv-icon name="arrow-right" size="16" color="#999"></uv-icon> -->
</view>
<!-- 转账记录容器 -->
<view class="record-container">
<view class="record-list">
<view class="record-item" v-for="(item, index) in list" :key="index">
<view v-if="hasMore && !list.length">
<uv-loading-icon text="加载中" ></uv-loading-icon>
</view>
<view v-else-if="!list.length">
<uv-empty ></uv-empty>
</view>
<view v-else class="record-item" v-for="(item, index) in list" :key="index">
<view class="record-avatar">
<image class="avatar" :src="item.userInfo.avatar" mode="aspectFill"></image>
<text class="avatar-name">{{ item.user_dictText }}</text>
@ -85,7 +91,7 @@
<text class="record-date">{{ item.createTime }}</text>
</view>
<view class="record-amount">
<text class="amount">+{{ item.money }}</text>
<text class="amount">{{ item.type === '1' ? '+' + item.money : '-' + item.money }}</text>
<!-- 领取按钮 - 当status=1且为微信提现时显示 -->
<uv-button
@ -109,9 +115,6 @@
:class="item.withdrawal.status === '1'
&& item.withdrawal.withdrawStatus === '0' ? 'status-available' : 'status-received'"
v-if="item.withdrawal && item.withdrawal.status != '1'">{{ getText(item.withdrawal) }}</text>
</view>
</view>
</view>
@ -136,7 +139,9 @@
<script>
import MixinList from '@/mixins/list'
import uvLoadingIcon from '../../uni_modules/uv-loading-icon/components/uv-loading-icon/uv-loading-icon.vue'
export default {
components: { uvLoadingIcon },
mixins: [MixinList],
data() {
return {
@ -184,6 +189,7 @@ export default {
this.userInfo = res.result
}
},
//
requestMerchantTransfer(item) {
if (!wx.canIUse('requestMerchantTransfer')) {
wx.showModal({
@ -192,22 +198,29 @@ export default {
});
return
}
//
wx.requestMerchantTransfer({
mchId: '1724993508',//
appId: wx.getAccountInfoSync().miniProgram.appId,
package: item.packageInfo,
success: (res) => {
success: async (res) => {
// res.err_msgok
console.log('success:', res);
this.getData()
// this.getData()
this.$api('requestMerchantTransfer', {
id : item.id,
const withdrawRes = await this.$api.promotion.withdrawSuccess({
id : item.id
})
if (withdrawRes.code === 200) {
uni.showToast({
title: '提现成功',
icon: 'success'
})
}
},
fail: (res) => {
console.log('fail:', res);
this.getData()
// this.getData()
},
});
},
@ -395,7 +408,7 @@ background: linear-gradient(180deg, #DEFFFF 0%, #FBFEFF 22.65%, #F0FBFF 100%);
//
.record-container {
.record-list {
min-height: 40vh;
border: 1px solid #F0F0F0;
border-radius: 24rpx;


+ 27
- 16
subPages/user/share.vue View File

@ -4,8 +4,9 @@
<!-- 主要内容区域 -->
<view class="content">
<uv-loading-icon text="生成中,请耐心等待" textSize="40rpx" size="60rpx" v-if="isLoading"></uv-loading-icon>
<!-- 中间图片 -->
<view class="image-container">
<view class="image-container" v-else>
<image
class="share-image"
:src="Qrcode"
@ -34,6 +35,7 @@ export default {
data() {
return {
Qrcode: '',
isLoading: false,
}
},
methods: {
@ -155,24 +157,33 @@ export default {
}
});
},
//
async getQrcode() {
// const res = await this.$api.promotion.qrCode()
// if (res.code === 200) {
uni.getImageInfo({
src: `${this.$config.baseURL}/promotion/qrCode?token=${uni.getStorageSync('token')}`,
success: (image) => {
console.log(image.width);
console.log(image.path);
this.Qrcode = image.path;
console.log(image.height);
}
});
// }
this.isLoading = true
uni.getImageInfo({
src: `${this.$config.baseURL}/promotion/qrCode?token=${uni.getStorageSync('token')}`,
success: (image) => {
this.Qrcode = image.path;
this.$store.commit('setQrcode', this.Qrcode)
this.isLoading = false
},
fail: (err) => {
console.error('获取二维码失败:', err);
this.isLoading = false
}
});
}
},
onShow() {
this.getQrcode()
},
onLoad() {
if (this.$store.state.Qrcode){
this.Qrcode = this.$store.state.Qrcode
}else {
this.getQrcode()
}
}
}
</script>


Loading…
Cancel
Save