【优化】优化组件for循环,给for循环增加key处理,加快循环效率。

【修复】修复万能表单支付类型错误的问题。
This commit is contained in:
大灰灰
2022-11-08 04:00:49 +08:00
parent 4506c1b4ac
commit b5297601ff
10 changed files with 47 additions and 30 deletions

View File

@@ -71,7 +71,7 @@ module.exports = (vm) => {
// 响应拦截
uni.$u.http.interceptors.response.use((response) => { /* 对响应成功做点什么 可使用async await 做异步操作*/
console.log(response);
//console.log(response);
const data = response.data
if (response.statusCode == 200) {
let pages = getCurrentPages();

View File

@@ -2,7 +2,7 @@
<view>
<!--提示框组件-->
<u-toast ref="uToast" />
<view v-for="item in advert">
<view v-for="(item, index) in advert" :key="index">
<u--image :showLoading="true" :src="item.imageUrl" mode="widthFix" width="100%" height="auto" @click="showSliderInfo(item.type, item.val)"></u--image>
</view>
</view>

View File

@@ -9,7 +9,7 @@
</view>
<view class="coreshop-bg-main coreshop-text-black">
<view class='coreshop-index-article coreshop-cell-group coreshop-margin-bottom-10 coreshop-margin-top-10 coreshop-bg-white' v-if="coreshopData.parameters.list && count">
<view class='coreshop-cell-item' v-for="item in coreshopData.parameters.list" :key="item.id" @click="articleDetail(item.id)">
<view class='coreshop-cell-item' v-for="(item, index) in coreshopData.parameters.list" :key="index" @click="articleDetail(item.id)">
<view class="coreshop-cell-item-bd">
<view class="article-title">
{{ item.title }}

View File

@@ -11,7 +11,7 @@
<view class="coreshop-margin-bottom-10 coreshop-bg-main coreshop-text-black">
<scroll-view class="groupon-scroll" enable-flex scroll-anchoring scroll-x scroll-with-animation>
<view class="groupon-card-wrap coreshop-flex coreshop-align-center">
<view v-for="(item, index) in coreshopData.parameters.list" :key="item.id">
<view v-for="(item, index) in coreshopData.parameters.list" :key="index">
<view class="coreshop-padding-right-5">
<view class="coupon-wrap " :style="{ background: `linear-gradient(to right, ${bgColor1}, ${bgColor2})` }">
<view class="coupon-item coreshop-flex coreshop-align-center coreshop-flex-direction-row coreshop-justify-between">

View File

@@ -87,7 +87,7 @@
<!-- #endif -->
</custom-waterfalls-flow>
<view class="coreshop-text-black" v-for="(item, index) in newData.list" :key="item.id" v-if="newData.column==1">
<view class="coreshop-text-black" v-for="(item, index) in newData.list" :key="index" v-if="newData.column==1">
<view class="coreshop-flex coreshop-justify-start coreshop-padding-top-10 coreshop-padding-bottom-10" v-if="newData.list.length">
<view>
<u--image :src="item.image" mode="widthFix" width="130px" height="130px" radius="8"></u--image>

View File

@@ -102,7 +102,7 @@
<view class="coreshop-divider">
<view class="complete"></view>
</view>
<view class="coreshop-text-black" v-for="(item, index) in coreshopData.parameters.list" :key="item.id" v-if="count" @tap="goGoodsDetail(item.id)">
<view class="coreshop-text-black" v-for="(item, index) in coreshopData.parameters.list" :key="index" v-if="count" @tap="goGoodsDetail(item.id)">
<view class="coreshop-flex coreshop-justify-start coreshop-padding-top-10 coreshop-padding-bottom-10">
<view>
<u--image :src="item.image" mode="widthFix" width="130px" height="130px" radius="8"></u--image>
@@ -156,7 +156,7 @@
</view>
<view v-if="count">
<swiper :class="coreshopData.parameters.column==3?'swiper3':coreshopData.parameters.column==2?'swiper2':''" @change="change">
<swiper-item v-for="no of pageCount" :key="no">
<swiper-item v-for="(no, index) of pageCount" :key="no">
<u-grid :col="coreshopData.parameters.column" :border="false" align="left" :data-id="no">
<u-grid-item v-for="(item, index) in coreshopData.parameters.list" v-if="index >=coreshopData.parameters.column*no && index <coreshopData.parameters.column*(no+1)" :key="index" @click="goGoodsDetail(item.id)">
<view class="good_box">
@@ -196,7 +196,7 @@
</swiper-item>
</swiper>
<view class="indicator-dots">
<view class="indicator-dots-item" v-for="no of pageCount" :key="no" :class="[current == no ? 'indicator-dots-active' : '']">
<view class="indicator-dots-item" v-for="(no, index) of pageCount" :key="index" :class="[current == no ? 'indicator-dots-active' : '']">
</view>
</view>
</view>

View File

@@ -1,7 +1,7 @@
<template>
<!-- 单图 -->
<view class="coreshop-imgsingle coreshop-bg-white" v-if="listData && listData.length > 0">
<view class="" v-for="child in listData">
<view v-for="(child, index) in listData" :key="index">
<view @click="taped(child)">
<image class="ad-img" :src="child.image" mode="widthFix"></image>
</view>

View File

@@ -11,7 +11,7 @@
</view>
<scroll-view class="scroll-box" scroll-x scroll-anchoring>
<view class="goods-box coreshop-flex coreshop-justify-between coreshop-text-black">
<view class="min-goods" v-for="item in coreshopData.parameters.list" :key="item.id" @tap="goPinTuanDetail(item.id)">
<view class="min-goods" v-for="(item, index) in coreshopData.parameters.list" :key="index" @tap="goPinTuanDetail(item.id)">
<view class="img-box">
<image class="img" :src="item.goodThumbnail" mode=""></image>
</view>

View File

@@ -1,7 +1,7 @@
<template>
<view v-show="showPage">
<view>
<u-toast ref="uToast" /><u-no-network></u-no-network>
<u-navbar :title="form.name" safeAreaInsetTop fixed placeholder>
<u-navbar :title="form.name || '表单详情'" safeAreaInsetTop fixed placeholder>
<view class="coreshop-navbar-left-slot" slot="left">
<u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
<u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
@@ -11,7 +11,7 @@
</view>
</u-navbar>
<form @submit="formSubmit" bindreset="formReset">
<form @submit="formSubmit" bindreset="formReset" v-show="showPage">
<view v-if="form.headType==1">
<view class="banner">
<image :src='slideImg[0]' mode='widthFix'></image>
@@ -313,7 +313,7 @@
form: {
headType: 1,
},
showPage: true,
showPage: false,
slideImg: [], //幻灯片广告数据
region: ['湖南省', '怀化市', '鹤城区'],
areaId: 431202,
@@ -359,6 +359,13 @@
}
this.formBoxId = id
this.$db.set('formBoxId', id)
},
mounted: function () {
this.$nextTick(function () {
this.getFormDetail();
})
},
computed: {
...mapState({
@@ -375,7 +382,6 @@
}
},
onShow() {
this.getFormDetail()
},
methods: {
//倒查城市信息
@@ -468,18 +474,19 @@
if (res.data.images) {
this.slideImg = res.data.images.split(',');
}
if (res.data.type == '1' || res.data.type == '2') {
if (res.data.type == '1') {
if (res.data.type == 1 || res.data.type == 2) {
if (res.data.type == 1) {
//订单
that.paymentType = this.$globalConstVars.paymentType.formPay
} else if (res.data.type == '2') {
//付款码
that.paymentType = this.$globalConstVars.paymentType.formOrder
} else if (res.data.type == 2) {
//付款码
that.paymentType = this.$globalConstVars.paymentType.formPay
}
}
console.log(that.paymentType);
this.showPage = true;
} else {
this.showPage = false;
//this.showPage = false;
if (res.data.isExpires) {
uni.showModal({
title: '提示',
@@ -492,13 +499,23 @@
}
})
} else if (res.data.needLogin) {
console.log("要登录权限了");
this.$u.route({ type: 'switchTab', url: '/pages/index/default/default' })
if (!this.hasLogin) {
this.$store.commit('showLoginTip', true);
return false;
}
//_this.$refs.uToast.show({ message: '请登录!', type: 'error', back: false });
uni.showModal({
title: '提示',
content: '您好,请先登录',
showCancel: false,
success: function (res) {
if (res.confirm) {
_this.$u.route({ type: 'switchTab', url: '/pages/index/member/member' })
}
}
})
//if (!this.hasLogin) {
// this.$store.commit('showLoginTip', true);
// return false;
//}
}
}
})

View File

@@ -22,8 +22,8 @@
<view class="action">
<text class="coreshop-font-sm coreshop-text-gray" v-if="type == $globalConstVars.paymentType.common || type == $globalConstVars.paymentType.pinTuan || type == $globalConstVars.paymentType.group || type == $globalConstVars.paymentType.seckill || type == this.$globalConstVars.paymentType.bargain || type == this.$globalConstVars.paymentType.giveaway || type == $globalConstVars.paymentType.solitaire || type == $globalConstVars.paymentType.transactionComponent">商品订单</text>
<text class="coreshop-font-sm coreshop-text-gray" v-if="type == $globalConstVars.paymentType.recharge" @click="toRecharge()">充值订单</text>
<text class="coreshop-font-sm coreshop-text-gray" v-if="type == $globalConstVars.paymentType.formPay">表单订单</text>
<text class="coreshop-font-sm coreshop-text-gray" v-if="type == $globalConstVars.paymentType.formOrder">付款码</text>
<text class="coreshop-font-sm coreshop-text-gray" v-if="type == $globalConstVars.paymentType.formPay">付款码</text>
<text class="coreshop-font-sm coreshop-text-gray" v-if="type == $globalConstVars.paymentType.formOrder">表单订单</text>
<text class="coreshop-font-sm coreshop-text-gray" v-if="type == $globalConstVars.paymentType.serviceOrder">服务订单</text>
</view>
</view>