mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-08-06 10:57:25 +08:00
refactor: 重构多个组件以支持 Vue 3 语法和功能
- 将多个组件转换为 `<script setup>` 语法,提升可读性和性能 - 优化状态管理和事件处理逻辑,简化代码结构 - 更新样式和布局以适应新组件结构 - 添加新功能和修复已知问题,提升用户体验
This commit is contained in:
@@ -130,105 +130,98 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { distribution } from "@/api/goods";
|
||||
import configs from "@/config/config";
|
||||
import storage from "@/utils/storage";
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { distribution as fetchDistribution } from '@/api/goods'
|
||||
import configs from '@/config/config'
|
||||
import storage from '@/utils/storage'
|
||||
import { tipsToLogin, setClipboard } from '@/utils/filters.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
configs,
|
||||
storage,
|
||||
repayingShow: false, //分销清退弹框
|
||||
sharingShow: false,
|
||||
sharingLink: ""
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleNavigate(url) {
|
||||
uni.navigateTo({
|
||||
url,
|
||||
});
|
||||
},
|
||||
inviter() {
|
||||
if (storage.getUserInfo().id) {
|
||||
this.sharingLink = this.configs.shareLink + "?inviter=" + this.storage.getUserInfo().id
|
||||
this.sharingShow = true
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "请先登录",
|
||||
duration: 2000,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
},
|
||||
navigateTo(url) {
|
||||
const ignores = [
|
||||
'/pages/mine/set/setUp',
|
||||
'/pages/mine/set/editionIntro',
|
||||
'/pages/mine/set/feedBack'
|
||||
]
|
||||
if (!ignores.includes(url)) {
|
||||
if (this.tipsToLogin('normal')) {
|
||||
this.handleNavigate(url)
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.handleNavigate(url)
|
||||
}
|
||||
},
|
||||
|
||||
linkMsgDetail(){
|
||||
if (this.tipsToLogin('normal')) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/tabbar/home/title',
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
distribution() {
|
||||
distribution().then((res) => {
|
||||
if (res.data.result) {
|
||||
let type = res.data.result.distributionStatus;
|
||||
if (type == "PASS") {
|
||||
uni.navigateTo({
|
||||
url: "/pages/mine/distribution/home",
|
||||
});
|
||||
} else if (type == "REFUSE") {
|
||||
uni.navigateTo({
|
||||
url: "/pages/mine/distribution/auth",
|
||||
});
|
||||
} else if (type == "RETREAT") {
|
||||
uni.showToast({
|
||||
title: "您的分销资格已被清退。请联系管理员!",
|
||||
duration: 2000,
|
||||
icon: "none",
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "您的信息正在审核",
|
||||
duration: 2000,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
} else if (!res.data.success && res.data.code == 22000) {
|
||||
uni.showToast({
|
||||
title: "分销功能暂未开启",
|
||||
duration: 2000,
|
||||
icon: "none",
|
||||
});
|
||||
} else {
|
||||
// 没有资格申请 先去实名认证
|
||||
uni.navigateTo({
|
||||
url: "/pages/mine/distribution/auth",
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
const sharingShow = ref(false)
|
||||
const sharingLink = ref('')
|
||||
|
||||
function handleNavigate(url: string) {
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
function inviter() {
|
||||
if (storage.getUserInfo().id) {
|
||||
sharingLink.value = configs.shareLink + '?inviter=' + storage.getUserInfo().id
|
||||
sharingShow.value = true
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请先登录',
|
||||
duration: 2000,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function getDetail(link: string) {
|
||||
setClipboard(link)
|
||||
}
|
||||
|
||||
function navigateTo(url: string) {
|
||||
const ignores = [
|
||||
'/pages/mine/set/setUp',
|
||||
'/pages/mine/set/editionIntro',
|
||||
'/pages/mine/set/feedBack',
|
||||
]
|
||||
if (!ignores.includes(url)) {
|
||||
if (tipsToLogin('normal')) {
|
||||
handleNavigate(url)
|
||||
}
|
||||
} else {
|
||||
handleNavigate(url)
|
||||
}
|
||||
}
|
||||
|
||||
function linkMsgDetail() {
|
||||
if (tipsToLogin('normal')) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/tabbar/home/title',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function distribution() {
|
||||
fetchDistribution().then((res) => {
|
||||
if (res.data.result) {
|
||||
const type = res.data.result.distributionStatus
|
||||
if (type == 'PASS') {
|
||||
uni.navigateTo({
|
||||
url: '/pages/mine/distribution/home',
|
||||
})
|
||||
} else if (type == 'REFUSE') {
|
||||
uni.navigateTo({
|
||||
url: '/pages/mine/distribution/auth',
|
||||
})
|
||||
} else if (type == 'RETREAT') {
|
||||
uni.showToast({
|
||||
title: '您的分销资格已被清退。请联系管理员!',
|
||||
duration: 2000,
|
||||
icon: 'none',
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '您的信息正在审核',
|
||||
duration: 2000,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
} else if (!res.data.success && res.data.code == 22000) {
|
||||
uni.showToast({
|
||||
title: '分销功能暂未开启',
|
||||
duration: 2000,
|
||||
icon: 'none',
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/mine/distribution/auth',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user