feat: 优化代码

This commit is contained in:
2025-08-06 20:25:41 +08:00
parent 5f7d0ceb79
commit 73823c50fd
1179 changed files with 42944 additions and 189654 deletions
+311
View File
@@ -0,0 +1,311 @@
<template>
<view class="get_prize_warp">
<view class="address_add_warp">
<view class="address_form">
<view class="add_form_item add_form_item_but">
<view class="add_form_title">收货人</view>
<up-input placeholder="收货人" border="surround" v-model="form.name" :customStyle="{
'border': '0rpx',
}"></up-input>
</view>
<view class="add_form_item add_form_item_but">
<view class="add_form_title">手机号码</view>
<up-input placeholder="请填写收货人手机号" border="surround" v-model="form.mobile" :customStyle="{
'border': '0rpx',
}" type="number"></up-input>
</view>
<view class="add_form_item add_form_item_but">
<view class="add_form_title">所在地区</view>
<view class="region_warp" @click="regionShowCheck(true)">
<view style="color: #808080;margin-left: 22rpx;font-size: 28rpx;">{{ (form.regionStr &&
form.regionStr.join("/")) || "所在地区" }}</view>
<up-image src="/static/common/right_soild.png" width="14" height="14" bgColor="#f1f6ff00"></up-image>
</view>
</view>
<view class="add_form_item">
<view class="add_form_title">详细地址</view>
<up-input placeholder="门牌号、小区、楼栋号、单元室等" border="surround" v-model="form.address" :customStyle="{
'border': '0rpx',
'height': '100rpx',
}"></up-input>
</view>
<view class="add_form_item">
<view class="add_form_title">备注</view>
<up-textarea v-model="prizeForm.remark" placeholder="请输入内容"></up-textarea>
</view>
</view>
<view class="address_select">
<view class="msg_">注:此收货地址会默认添加到地址列表</view>
<view class="address_" @click="addressShow = true">使用收货地址</view>
</view>
<view class="add_but" @click="addAddress">
确认领取
</view>
<up-toast ref="uToastRef"></up-toast>
<up-picker :show="regionShow" ref="uPickerRef" :columns="regionColumns" @confirm="regionConfirm"
:loading="regionLoading" @change="regionChange" keyName="label" itemHeight="34" @cancel="regionShow = false"
@close="regionShow = false"></up-picker>
</view>
<!-- 选择地址 -->
<up-popup v-model:show="addressShow" :round="10" :closeOnClickOverlay="false" :closeable="true"
:safeAreaInsetBottom="false" @close="checkAddressShow(false)">
<view class="address_popup_warp">
<view class="address_popup_title">收件地址</view>
<view class="address_popup_content">
<Address @valueFunc="getAddressValueFunc" />
</view>
<view class="popup_but" @click="addressOk">
确认
</view>
</view>
</up-popup>
</view>
</template>
<script>
import { takeGoods } from '@/api/raffle.js';
import { editAddress } from '@/api/address.js'
import { getCascadeRegion } from '@/api/common.js';
import Address from '@/components/address.vue';
import { assembleAddress } from '@/utils/index.js'
export default {
components: {
Address,
},
data() {
return {
form: {
id: 0,
name: null,// 收货人
mobile: null,// 手机号码
regionStr: null,// 所属地区
countryId: null,// 国家ID
provinceId: null,// 省份ID
cityId: null,// 城市ID
areaId: null,// 区域ID
address: null,// 详细地址
},
regionShow: false,
regionColumns: [],
regionLoading: false,
addressShow: false,// 收件地址选择
selectAddress: {},// 选中的地址
prizeForm: {
id: 0,
addressId: 0,//
remark: '',// 备注
}
};
},
onLoad(option) {
const id = option.id;
if (id && id !== 0) {
this.prizeForm.id = id;
}
},
methods: {
// 选择地址的弹框
async regionShowCheck(status) {
if (status) {
const nation = await this.getRegion(0);
const province = nation && nation.length !== 0 ? await this.getRegion(nation[0].id) : [];
const city = province && province.length !== 0 ? await this.getRegion(province[0].id) : [];
const area = city && city.length !== 0 ? await this.getRegion(city[0].id) : [];
this.regionColumns = [nation, province, city, area];
} else {
this.regionColumns = [[], [], [], []];
}
this.regionShow = status;
},
// 数据交互
async getRegion(pId) {
this.regionLoading = true
const params = {
parentId: pId,
}
const resp = await getCascadeRegion(params);
const arrOption = [];
if (resp.bizcode === 100) {
const data = resp.data;
if (data && data.length !== 0) {
data.map(item => {
arrOption.push({
id: item.id,
label: item.name,
pId: pId,
})
})
}
}
this.regionLoading = false;
return arrOption
},
// 地区改变
async regionChange(e) {
const {
columnIndex,
index,
picker
} = e;
const selectData = this.regionColumns[columnIndex][index];
const resultData = await this.getRegion(selectData.id);
if (resultData && resultData.length !== 0) {
const index = columnIndex + 1;
this.regionColumns[index] = resultData;
}
},
// 提交地址
regionConfirm(e) {
const {
columnIndex,
value,
values,
index,
} = e;
const regionStr = [];
const regionId = [];
value.map(item => {
if (item) {
regionStr.push(item.label);
regionId.push(item.id);
}
})
this.form.regionStr = regionStr;
if (regionId && regionId.length !== 0) {
this.form.countryId = regionId[0] ? regionId[0] : null;
this.form.provinceId = regionId[1] ? regionId[1] : null;
this.form.cityId = regionId[2] ? regionId[2] : null;
this.form.areaId = regionId[3] ? regionId[3] : null;
}
this.regionShowCheck(false);
},
// 添加地址
async addAddress() {
const params = {
...this.form,
}
if (!params.name) {
this.$refs.uToastRef.show({
type: 'error',
message: "请输入收货人",
});
return;
}
if (!params.mobile) {
this.$refs.uToastRef.show({
type: 'error',
message: "请输入收货人手机号",
});
return;
}
if (!params.regionStr) {
this.$refs.uToastRef.show({
type: 'error',
message: "请选择所在地区",
});
return;
}
if (!params.address) {
this.$refs.uToastRef.show({
type: 'error',
message: "请输入详细地址",
});
return;
}
const selectAddress = this.selectAddress;
if (selectAddress && selectAddress.id !== 0) {
params.id = selectAddress.id;
} else {
delete params.id;
}
if (!params.areaId || params.areaId === 0) {
delete params.areaId;
}
delete params.regionStr;
const res = await editAddress(params);
if (res && res.bizcode === 100) {
const goodsParams = {
...this.prizeForm,
addressId: res.data,
}
const goodsRes = await takeGoods(goodsParams);
if (goodsRes && goodsRes.bizcode === 100) {
this.$refs.uToastRef.show({
type: 'success',
message: "领取成功",
});
setTimeout(() => {
uni.navigateTo({
url: '/pages/mine/mine_winning_record/mine_winning_record'
})
}, 1500)
}
}
},
// 地址类型
checkAddressShow(status, type, addIndex, index) {
this.addressShow = status;
},
// 地址选中
getAddressValueFunc(item) {
this.selectAddress = item;
},
// 地址选中OK
addressOk() {
const item = this.selectAddress;
console.log("item", item);
this.form.name = item.name;
this.form.mobile = item.phone;
this.form.countryId = item.countryId;
this.form.provinceId = item.provinceId;
this.form.cityId = item.cityId;
this.form.areaId = item.areaId;
this.form.address = item.address;
const regionStr = [];
if (item.countryName) {
regionStr.push(item.countryName);
}
if (item.provinceName) {
regionStr.push(item.provinceName);
}
if (item.cityName) {
regionStr.push(item.cityName);
}
if (item.areaName) {
regionStr.push(item.areaName);
}
this.form.regionStr = regionStr;
this.addressShow = false;
},
}
}
</script>
<style lang="scss">
.get_prize_warp {
height: 100vh;
background-color: $app-bj;
}
.address_select {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20rpx;
.msg_ {
color: #BDBDBD;
font-size: 24rpx;
}
.address_ {
color: #03A9F4;
font-size: 28rpx;
}
}
</style>
@@ -0,0 +1,120 @@
<template>
<view class="invite_friends_warp">
<view class="invite_img">
<up-image :loading="imageLoading" :src="inviteImage" width="100%" height="460" bgColor="#f1f6ff00" shape="square" radius=10></up-image>
</view>
<view class="invite_but">
<view class="save_but">
<text style="margin-left: 10rpx;" @click="saveBaseImgFile">保存图片</text>
</view>
</view>
<up-toast ref="uToastRef"></up-toast>
</view>
</template>
<script>
import { getSharePoster,generateSharePoster } from '@/api/common.js';
export default {
data() {
return {
inviteImage:null,
imageLoading:false,
}
},
mounted() {
this.getSharePoster();
},
methods: {
// 查询分享模版
async getSharePoster(){
this.imageLoading = true;
const resp = await getSharePoster();
if(resp && resp.bizcode === 100){
const data = resp.data[0];
// 生成分享图
const generateResp = await generateSharePoster({id:data.id});
if(generateResp && generateResp.bizcode === 100){
this.inviteImage = generateResp.data;
}
}
this.imageLoading = false;
},
saveBaseImgFile() {
uni.showLoading({
title: '保存中...',
})
const currentBase64 = this.inviteImage;
const bitmap = new plus.nativeObj.Bitmap('base64')
bitmap.loadBase64Data(currentBase64, () => {
const url = '_doc/' + new Date().getTime() + '.png'
bitmap.save(
url,
{
overwrite: false, // 是否覆盖
},
(i) => {
uni.saveImageToPhotosAlbum({
filePath: url,
success: () => {
uni.hideLoading();
this.$refs.uToastRef.show({
type: 'success',
message: "图片保存到相册成功",
});
bitmap.clear()
}
})
},
(e) => {
uni.hideLoading();
console.log('图片保存失败',e)
this.$refs.uToastRef.show({
type: 'error',
message: "图片保存失败",
});
bitmap.clear()
}
)
},
(e) => {
uni.hideLoading();
console.log('图片保存失败',e)
this.$refs.uToastRef.show({
type: 'error',
message: "图片保存失败",
});
bitmap.clear()
}
)
}
}
}
</script>
<style lang="scss" scoped>
.invite_friends_warp{
height: calc(100vh - 80rpx);
padding: 40rpx;
}
.invite_img{
margin-top: 52rpx;
height: 930rpx;
}
.invite_but{
padding: 20rpx 50rpx;
margin-top: 52rpx;
.save_but{
text-align: center;
background: $app-bt-bj;
border-radius: 45rpx;
width: 100%;
color: #FFF;
padding: 30rpx 0;
font-weight: 500;
font-size: 32rpx;
color: #FFFFFF;
}
}
</style>
@@ -0,0 +1,94 @@
<template>
<view>
<Header leftTitle="H5支付" leftPathType="switchTab" leftPath="/pages/mine/mine" />
<view class="payment_processing_warp">
<up-loading-icon :show="loadingShow" color="#009A4F"></up-loading-icon>
<view class="payment_processing_msg">{{ orderMsg }}</view>
</view>
</view>
</template>
<script>
import Header from '@/components/header.vue';
import { queryResult } from '@/api/payment.js'
export default {
components: {
Header,
},
data() {
return {
orderNum: 0,// 支付处理ID
paymentLink: null,// H5支付处理页面
orderMsg: "支付处理中...",
loadingShow: true,
}
},
onLoad(options) {
console.log("options", options);
this.orderNum = options.orderNum || 0;
const paymentLink = options.link;
if (paymentLink && paymentLink !== "null") {
this.paymentLink = paymentLink; // 解码并设置支付链接
uni.navigateTo({
url: `/pages/other_package/zfb_payment/zfb_payment?link=${paymentLink}` // 假设有一个专门的支付页面来处理支付链接
});
}
},
onShow() {
if (this.orderNum) {
this.getOrderById();
}
},
methods: {
async getOrderById() {
const params = {
orderNum: this.orderNum,
};
console.log("params", params);
const resp = await queryResult(params);
console.log("queryResult resp", resp);
if (resp && resp.bizcode === 100) {
const data = resp.data || {};
if (data.state === 0) { // 订单不存在
this.loadingShow = false;
this.orderMsg = "订单不存在";
} else if (data.state === 1) {// 支付中
this.orderMsg = "支付处理中...";
} else if (data.state === 2) {// 支付成功
this.loadingShow = false;
this.orderMsg = "支付成功";
this.jumpWayOk();
} else if (data.state === 3) {// 支付失败
this.loadingShow = false;
this.orderMsg = "支付失败";
this.jumpWayError();
}
}
},
// 跳转到支付成功页面
jumpWayOk() {
uni.navigateTo({
url: "/pages/order_package/order_submit_ok/order_submit_ok",
})
},
// 跳转到支付失败页面
jumpWayError() {
uni.navigateTo({
url: "/pages/order_package/order_submit_error/order_submit_error",
})
}
}
}
</script>
<style lang="scss" scoped>
.payment_processing_warp {
text-align: center;
margin-top: 200rpx;
.payment_processing_msg {
margin-top: 20rpx;
}
}
</style>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+308
View File
@@ -0,0 +1,308 @@
<template>
<view class="search_warp">
<!-- 头部搜索 -->
<view class="header_comm">
<up-image src="/static/common/left.png" width="20" height="20" bgColor="#f1f6ff00" @click="jumpHome"></up-image>
<view>
<up-input
placeholder="搜索关键字(商品、店铺、品牌)"
:customStyle="{
'border-color':'#7934F6 !important',
'padding': '0 0 0 20rpx !important',
'border-radius': '20rpx !important',
'width': '590rpx',
}"
v-model="form.keyword"
clearable
>
<template #prefix>
<up-image src="/static/common/search.png" width="20" height="20" bgColor="#f1f6ff00" @click="jumpHome"></up-image>
</template>
<template #suffix>
<view class="search_but_warp" @click="searchGYLMall">搜索</view>
</template>
</up-input>
</view>
</view>
<!-- 历史搜索 -->
<view class="search_history" v-if="!poductList || poductList.length === 0">
<view class="search_history_title">
<view>猜你喜欢</view>
<up-image src="/static/common/delete.png" width="20" height="20" bgColor="#f1f6ff00" @click="isShowSearch = true;"></up-image>
</view>
<view class="search_history_cotent" v-if="searchList && searchList.length !==0">
<view v-for="item in searchList" :key="item.id" style="margin: 0 10rpx 10rpx 0;">
<up-tag plain :text="item.name" type="warning" :show="true" :closable="isShowSearch" borderColor="#7934F6" color="#7934F6" @close="searchHistoryDelete(item)" @click="searchClick(item)"></up-tag>
</view>
</view>
<view v-else class="not_order_warp">
<view class="not_order_warp_img"><up-image src="/static/common/not_search.png" width="100" height="100" bgColor="#f1f6ff00"></up-image></view>
<view class="not_order_msg_warp">暂无搜索记录</view>
</view>
</view>
<!-- 搜索出内容 -->
<view v-else class="poduct_list">
<view class="poduct_search_warp">
<view>综合</view>
<view>销量</view>
<view>优惠卷</view>
<view>
<up-image :src="imgSize === 'big' ? '/static/search/dt.png':'/static/search/xt.png'" width="20" height="20" bgColor="#f1f6ff00" @click="toggleImg"></up-image>
</view>
</view>
<view class="poduct_content_warp" >
<view v-if="poductList && poductList.length !==0">
<!-- 大图 -->
<view v-if="imgSize === 'big'" class="big_warp">
<view v-for="item in poductList" class="big_item_warp" :key="item.id" @click="jumpInfo(item)">
<up-image :src="item.url " width="100%" height="150px" bgColor="#f1f6ff00" radius="10"></up-image>
<view class="big_item_content_warp">
<view class="title">{{item.title}}</view>
<view class="total_or_quantity">
<view class="total_">
<text>¥</text>
<text style="font-size: 36rpx;">{{item.adPrice}}</text>
</view>
<view>已售{{item.sales}}件</view>
</view>
</view>
</view>
</view>
<!-- 小图 -->
<view v-if="imgSize === 'min'" class="min_warp">
<view v-for="item in poductList" class="min_item_warp" :key="item.id" @click="jumpInfo(item)">
<up-image :src="item.url " width="100" height="100" bgColor="#f1f6ff00" radius="10"></up-image>
<view class="min_item_content_warp">
<view class="title">{{item.title}}</view>
<view class="total_or_quantity">
<view class="total_">
<text>¥</text>
<text style="font-size: 36rpx;">{{item.adPrice}}</text>
</view>
<view>已售{{item.sales}}件</view>
</view>
</view>
</view>
</view>
</view>
<view v-else class="not_order_warp">
<view class="not_order_warp_img"><up-image src="/static/common/not_search.png" width="100" height="100" bgColor="#f1f6ff00"></up-image></view>
<view class="not_order_msg_warp">抱歉没有搜索此类商品~</view>
</view>
</view>
</view>
</view>
</template>
<script>
import { searchList } from '@/api/product.js';
export default {
data() {
return {
searchList:[
{
id:1,
name:'酒',
},{
id:2,
name:'鸿星尔克',
},{
id:3,
name:'361',
},{
id:4,
name:'国美',
},{
id:5,
name:'刘丹',
},{
id:6,
name:'榴莲',
},{
id:7,
name:'会心一笑',
},
],// 搜索历史记录
form:{
keyword:null,
type:null,
categoryId:null,//
page:1,
pageSize:20,
},
isShowSearch:false,
poductList:[],// 产品列表
imgSize:"min",// big:大,min:笑
}
},
onLoad(option) {
const keyword = option.keyword;
if(keyword && keyword !==0 && keyword !== "undefined"){
this.form.keyword = keyword;
this.searchClickFun();
}
},
methods: {
jumpHome(){
uni.switchTab({
url: '/pages/home/home',
})
},
// 删除历史
searchHistoryDelete(item){
this.isShowSearch = false;
},
/**
* 查询产品
*/
async searchClick(item){
this.form.keyword = item.name;
this.searchGYLMall();
},
/**
* 查询产品
*/
async searchClickFun(){
const form = this.form;
const params = {
page:form.page,
pageSize:form.pageSize,
}
if(form.categoryId){
params.categoryId = form.categoryId;
}
if(form.keyword){
params.keyword = form.keyword;
}
if(form.type){
params.type = form.type;
}
const resp = await searchList(params);
if(resp && resp.bizcode === 100){
this.poductList = resp.data;
}
},
/**
* 切换图大小
*/
toggleImg(){
this.imgSize = this.imgSize === 'big'?'min':'big';
},
jumpInfo(item){
uni.navigateTo({
url: '/pages/other_package/productInfo/productInfo?id='+item.id,
})
},
}
}
</script>
<style lang="scss" scoped>
.search_warp{
background-color: $app-bj;
height: 100vh;
overflow-y: hidden;
.search_but_warp{
background: $app-bt-bj;
border-radius: 16rpx;
padding: 20rpx 40rpx;
text-align: center;
color: #FFF;
}
.search_history{
padding: 60rpx 40rpx;
.search_history_title{
display: flex;
justify-content: space-between;
font-weight: bold;
font-size: 32rpx;
color: #333333;
}
.search_history_cotent{
display: flex;
flex-wrap: wrap;
margin-top: 20rpx;
}
}
.poduct_list{
.poduct_search_warp{
background: #FFFFFF;
font-weight: bold;
font-size: 26rpx;
color: #333333;
display: flex;
justify-content: space-between;
padding: 10rpx 60rpx;
}
.poduct_content_warp{
padding: 30rpx;
height: calc(100vh - 340rpx);
overflow-y: auto;
.big_warp{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
.big_item_warp{
width: 48%;
margin-bottom: 20rpx;
background: #FFFFFF;
border-radius: 24rpx;
}
.big_item_content_warp{
padding: 20rpx;
.title{
font-weight: bold;
font-size: 26rpx;
color: #333333;
}
}
}
.min_warp{
.min_item_warp{
padding: 30rpx;
background: #FFFFFF;
border-radius: 24rpx;
display: flex;
margin-bottom: 20rpx;
}
.min_item_content_warp{
margin-left: 10rpx;
display: grid;
width: 100%;
}
.title{
font-weight: bold;
font-size: 26rpx;
color: #333333;
}
}
.total_or_quantity{
display: flex;
justify-content: space-between;
align-items: center;
margin: 10rpx 0 6rpx;
font-size: 20rpx;
color: #999999;
}
.total_{
font-weight: bold;
font-size: 26rpx;
color: #F52D1D;
}
}
}
}
</style>
File diff suppressed because one or more lines are too long
@@ -0,0 +1,26 @@
<template>
<view>
<web-view :src="paymentLink"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
paymentLink:''
}
},
onLoad(options) {
console.log("options",options);
this.paymentLink = decodeURIComponent(options.link); // 解码并设置支付链接
},
methods: {
}
}
</script>
<style>
</style>