规格调整,图片清晰度调整,定位增加

This commit is contained in:
GaoHao
2024-08-06 16:31:24 +08:00
parent 63506487a7
commit 30998ddfda

View File

@@ -60,7 +60,7 @@
<text>¥</text> <text>¥</text>
<text>{{item.lowPrice}}</text> <text>{{item.lowPrice}}</text>
<text>/</text> <text>/</text>
<text v-if="item1.suit > 1">{{item.suit}}份起点</text> <text v-if="item.suit > 1">{{item.suit}}份起点</text>
</view> </view>
<!-- <u-icon name="plus-circle-fill" color="#E9AB7A" size="40"></u-icon> --> <!-- <u-icon name="plus-circle-fill" color="#E9AB7A" size="40"></u-icon> -->
@@ -107,10 +107,12 @@
<view class="title"> <view class="title">
<view>{{item.name}}</view> <view>{{item.name}}</view>
</view> </view>
<!-- ?x-oss-process=image/resize,m_lfit,w_200,h_200,limit_90 -->
<view class="goods" @click="clickspecifications(item1,index,index1)" <view class="goods" @click="clickspecifications(item1,index,index1)"
v-for="(item1,index1) in item.products" :key="index1"> v-for="(item1,index1) in item.products" :key="index1">
<image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true" <image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true"
:src="`${item1.coverImg}?x-oss-process=image/resize,m_lfit,w_200,h_200`" mode="aspectFill"></image> @load="imageLoaded(item1,index,index1)"
:src="`${item1.coverImg}${!item1.imgLoad?'?x-oss-process=image/resize,m_lfit,w_300,h_300':''}`" mode="aspectFill"></image>
<!-- <image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true" <!-- <image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true"
:src="`${item1.coverImg}`" mode="aspectFill"></image> --> :src="`${item1.coverImg}`" mode="aspectFill"></image> -->
<image class="goodsImg" src="@/static/1.gif" mode="" v-else :lazy-load="true"></image> <image class="goodsImg" src="@/static/1.gif" mode="" v-else :lazy-load="true"></image>
@@ -348,7 +350,7 @@
}, // 规格信息 }, // 规格信息
socketTicket: null, socketTicket: null,
amountcartNumber: 0, amountcartNumber: 0,
isSpec: true, isSpec: false,
skuBtnText: "添加到购物车", skuBtnText: "添加到购物车",
skuNumber: 0, skuNumber: 0,
skuSuit: 0, skuSuit: 0,
@@ -435,9 +437,51 @@
.miniAppOpenId) .miniAppOpenId)
uni.cache.set('userInfo', res.data.userInfo); uni.cache.set('userInfo', res.data.userInfo);
uni.$on('message', this.getMessage) uni.$on('message', this.getMessage)
uni.getLocation({
type: 'wgs84',
success: async (res) => {
let successres = await this.api.geocodelocation({
lng: res.longitude,
lat: res.latitude,
})
if (successres.code == 0) {
let datastorage = {
country: successres.data.addressComponent.country, // "中国"
province: successres.data.addressComponent.province, //province: "陕西省"
address: successres.data.addressComponent.city, //district: "西安市"
district: successres.data.addressComponent.district, //district: "未央区"
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
this.productqueryShop(); this.productqueryShop();
} }
}, },
fail: async (err) => {
console.log(err, '获取错误') //测试用于app
let successres = await this.api.geocodelocation({
lng: '',
lat: '',
})
if (successres.code == 0) {
console.log(successres.data.addressComponent.streetNumber.location.split(','))
let res = successres.data.addressComponent.streetNumber.location.split(',')
let datastorage = {
country: successres.data.addressComponent.country, // "中国"
province: successres.data.addressComponent.province, //province: "陕西省"
address: successres.data.addressComponent.city, //district: "西安市"
district: successres.data.addressComponent.district, //district: "未央区"
lng: res[0],
lat: res[1],
}
uni.cache.set('getLocationstorage', datastorage);
this.productqueryShop();
}
}
});
}
},
fail: (err) => {} fail: (err) => {}
}); });
} catch (e) {} } catch (e) {}
@@ -494,6 +538,18 @@
} }
}, },
/**
* 图片加载
*/
imageLoaded (item,index,index1) {
console.log(index)
console.log(index1)
console.log(this.shopProductList.productInfo[index])
this.shopProductList.productInfo[index].products[index1]['imgLoad'] = true;
// e.currentTarget.src
},
/** /**
* 商品数量增加/减少 * 商品数量增加/减少
* @param {Object} item * @param {Object} item
@@ -543,7 +599,7 @@
* 添加购物车 * 添加购物车
*/ */
addShopping(item, index, index1, a, b) { addShopping(item, index, index1, a, b) {
if (this.amountcartNumber <= 0 && isSpec) { if (this.amountcartNumber <= 0 || !this.isSpec) {
return; return;
} }
let num = 0; let num = 0;
@@ -675,7 +731,7 @@
this.hodgepodge(this.specifications, 2) //获取skuid /2查找价格和数量 this.hodgepodge(this.specifications, 2) //获取skuid /2查找价格和数量
} else { } else {
// 多规格数据处理 // 多规格数据处理
this.isSpec = true; this.isSpec = false;
let res = await this.api.productquerySpec({ let res = await this.api.productquerySpec({
productId: item1.id, //商品id productId: item1.id, //商品id
querySpecList:[], querySpecList:[],
@@ -721,7 +777,6 @@
* @param {Object} item * @param {Object} item
*/ */
async morloe(e, index, index1, item) { async morloe(e, index, index1, item) {
let _this = this;
if ( !e.isGrounding ) { if ( !e.isGrounding ) {
return; return;
} }
@@ -734,8 +789,8 @@
} else { } else {
this.$set(this.specifications.tagSnap[index], 'start', -1) this.$set(this.specifications.tagSnap[index], 'start', -1)
} }
_this.skuidname.splice(index, 1, e.info); //替换skuidname的数据 // this.skuidname.splice(index, 1, e.info); //替换skuidname的数据
_this.specifications.tagSnap.forEach((v,i)=>{ this.specifications.tagSnap.forEach((v,i)=>{
if ( v.start >= 0 && v.start <= v.children.length) { if ( v.start >= 0 && v.start <= v.children.length) {
querySpecList.push({ querySpecList.push({
name: v.name, name: v.name,
@@ -752,20 +807,25 @@
} }
} }
let res = await _this.api.productquerySpec({ let res = await this.api.productquerySpec({
productId: item.id, //商品id productId: item.id, //商品id
querySpecList: querySpecList, querySpecList: querySpecList,
}) })
if( res.code == 0 ){ if( res.code == 0 ){
res.data.forEach((v,e)=>{ res.data.forEach((v,e)=>{
_this.$set(this.specifications.tagSnap[e], 'children', v.value) this.$set(this.specifications.tagSnap[e], 'children', v.value)
// _this.specifications.tagSnap[e].children = v.value
}) })
} }
console.log(_this.specifications.tagSnap) console.log(this.specifications.tagSnap)
this.skuidname = [];
this.specifications.tagSnap.forEach((val, index, arr) => { //初始化skuidname的数据 选择第一个
console.log(val)
if ( val.start >= 0 ) {
this.skuidname.push(val.children[val.start].info)
}
})
this.$forceUpdate(); this.$forceUpdate();
_this.hodgepodge(item, 2) this.hodgepodge(item, 2)
}, },
/** /**