| xqd
@@ -16,7 +16,7 @@
|
|
|
<swiper class="swiper-box" @change="change1" circular>
|
|
|
<swiper-item v-for="(item ,index) in info" :key="index" v-if="resource_type == 1 ">
|
|
|
<view class="swiper-item">
|
|
|
- <image style="width: 100%;height:576rpx;" :src="item.img" mode="aspectFill"></image>
|
|
|
+ <image style="width: 100vw;height:100vw;" :src="item.img" mode="aspectFill"></image>
|
|
|
</view>
|
|
|
</swiper-item>
|
|
|
<swiper-item v-if="resource_type == 2 ">
|
| xqd
@@ -38,7 +38,7 @@
|
|
|
<text>{{productDetail.price}}</text>
|
|
|
</view>
|
|
|
<view class="price-top" v-if="produceType == 2">
|
|
|
- <text>{{productDetail.integral}}</text>
|
|
|
+ <text>{{productDetail.price}}</text>
|
|
|
<text>积分</text>
|
|
|
</view>
|
|
|
<text class="price-text">{{productDetail.name}}</text>
|
| xqd
@@ -52,7 +52,7 @@
|
|
|
<text>选择</text>
|
|
|
</view>
|
|
|
<view class="price-specs-main" @click="Recipientopen()">
|
|
|
- <text>{{specsText||'请选择规格'}}</text>
|
|
|
+ <text>{{showAttr||'请选择规格'}}</text>
|
|
|
</view>
|
|
|
<view @click="Recipientopen()">
|
|
|
<image style="width: 12rpx;height: 20rpx;" src="/static/icon/right03.png" mode=""></image>
|
| xqd
@@ -94,7 +94,7 @@
|
|
|
<image style="width: 40rpx;height: 42rpx;" src="/static/icon/home01.png" mode=""></image>
|
|
|
<text>首页</text>
|
|
|
</view>
|
|
|
- <view class="buy-btn-right" @click="$refs.codePurchase.open()" v-if="produceType==1">
|
|
|
+ <view class="buy-btn-right" @click="goIntegralOrder" v-if="produceType==1">
|
|
|
<text>立即购买</text>
|
|
|
</view>
|
|
|
<view v-if="produceType==2" class="buy-btn-right" @click="goProductChange(product_id,flavorIsActive)">
|
| xqd
@@ -115,7 +115,7 @@
|
|
|
<text>{{productDetail.price}}</text>
|
|
|
</view>
|
|
|
<view class="pop-price-left-money" v-if="produceType == 2">
|
|
|
- <text>{{productDetail.integral}}</text>
|
|
|
+ <text>{{productDetail.price}}</text>
|
|
|
<text>积分</text>
|
|
|
</view>
|
|
|
</view>
|
| xqd
@@ -136,7 +136,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="purchase" v-if="produceType == 1" @click="goIntegralOrder(product_id)">
|
|
|
+ <view class="purchase" v-if="produceType == 1" @click="goIntegralOrder">
|
|
|
<view class="purchase-btn">立即购买</view>
|
|
|
</view>
|
|
|
<view class="purchase" v-if="produceType == 2" @click="selectSpecs">
|
| xqd
@@ -216,7 +216,7 @@
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- onReady: function(res) {
|
|
|
+ onReady: function() {
|
|
|
this.videoContext = uni.createVideoContext('myVideo')
|
|
|
},
|
|
|
onLoad(op) {
|
| xqd
@@ -224,9 +224,24 @@
|
|
|
this.admin = this.$store.getters.userInfo
|
|
|
this.product_id=id
|
|
|
this.produceType = type
|
|
|
- this.getProductDetail(this.product_id)
|
|
|
+ this.getProductDetail(this.product_id,true)
|
|
|
+ },
|
|
|
+ computed:{
|
|
|
+ showAttr:function(){
|
|
|
+ if(this.flavorIsActive.length <=0) return false;
|
|
|
+ let text = '';
|
|
|
+ for(const k in this.flavorIsActive){
|
|
|
+ text += `${k}-${this.flavorIsActive[k]},`
|
|
|
+ }
|
|
|
+ return text.substr(0, text.length-1);
|
|
|
+ },
|
|
|
+ selectedHotelId:function(){
|
|
|
+ return this.$store.state.tab.selectedHotelId;
|
|
|
+ }
|
|
|
},
|
|
|
- methods: {
|
|
|
+ methods: {
|
|
|
+ //显示所选规格
|
|
|
+
|
|
|
//获取当前页面路径
|
|
|
getPageUrl() {
|
|
|
const pages = getCurrentPages();
|
| xqd
@@ -281,11 +296,11 @@
|
|
|
this.videoContext.play()
|
|
|
},
|
|
|
// 获取商品详情
|
|
|
- getProductDetail(product_id){
|
|
|
+ getProductDetail(product_id, init=false){
|
|
|
this.$api.product.getProductDetail({
|
|
|
product_id:product_id
|
|
|
}).then(res=>{
|
|
|
- if(res.code==0){
|
|
|
+ if(res.code==0 && res.data){
|
|
|
this.productDetail=res.data
|
|
|
this.info = JSON.parse(res.data.img_urls).map(item => {
|
|
|
return {
|
| xqd
@@ -303,12 +318,21 @@
|
|
|
//规格对接
|
|
|
this.attr_groups = JSON.parse(res.data.attr_group)
|
|
|
//获取默认酒店
|
|
|
- const hotel_ids = JSON.parse(res.data.hotel_ids);
|
|
|
- (hotel_ids.constructor == Array) && (hotel_ids.length > 0) && this.getHotelDetail(hotel_ids[0]);
|
|
|
+ const hotel_ids = JSON.parse(res.data.hotel_ids);
|
|
|
+ if((hotel_ids.constructor == Array) && (hotel_ids.length > 0)){
|
|
|
+ this.$store.commit("tab/SET_SELECTEDHOTELId", hotel_ids[0])
|
|
|
+ }
|
|
|
//
|
|
|
const sku = JSON.parse(res.data.sku);
|
|
|
this.sku.keys = Object.keys(sku.attrs);
|
|
|
this.sku.sku = sku.sku;
|
|
|
+
|
|
|
+ //首次默认选中第一个规格
|
|
|
+ if(init){
|
|
|
+ this.attr_groups.forEach(item => {
|
|
|
+ this.flavorchecked(item.attr_list[0]?.attr_name,item.attr_group_name)
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
},
|
| xqd
@@ -379,11 +403,11 @@
|
|
|
},
|
|
|
// 选择规格
|
|
|
selectSpecs(){
|
|
|
- this.specs.flavor='五仁'
|
|
|
- this.specs.weight='50g'
|
|
|
- this.specs.pack='礼盒'
|
|
|
- console.log(this.specs)
|
|
|
- this.specsText=this.specs.flavor+'--'+this.specs.weight+'--'+this.specs.pack
|
|
|
+ // this.specs.flavor='五仁'
|
|
|
+ // this.specs.weight='50g'
|
|
|
+ // this.specs.pack='礼盒'
|
|
|
+ // console.log(this.specs)
|
|
|
+ // this.specsText=this.specs.flavor+'--'+this.specs.weight+'--'+this.specs.pack
|
|
|
this.Recipientclose()
|
|
|
},
|
|
|
Recipientopen() {
|
| xqd
@@ -401,25 +425,48 @@
|
|
|
},
|
|
|
//积分兑换
|
|
|
goProductChange(id,flavorIsActive){
|
|
|
- console.log(flavorIsActive,'------flavorIsActive');
|
|
|
- let arr = []
|
|
|
- Object.keys(flavorIsActive).forEach(key =>{
|
|
|
- arr.push(flavorIsActive[key])
|
|
|
- })
|
|
|
- console.log(arr);
|
|
|
+ // console.log(flavorIsActive,'------flavorIsActive');
|
|
|
+ // let arr = []
|
|
|
+ // Object.keys(flavorIsActive).forEach(key =>{
|
|
|
+ // arr.push(flavorIsActive[key])
|
|
|
+ // })
|
|
|
+ // console.log(arr);
|
|
|
// uni.navigateTo({
|
|
|
// url:'/pages/my/integral/integralOrder?product_id='+id
|
|
|
- // })
|
|
|
+ // })
|
|
|
+ const resArr = [];
|
|
|
+ outer: for(const k in this.flavorIsActive){
|
|
|
+ inner: for(const i in this.attr_groups){
|
|
|
+ if(this.attr_groups[i].attr_group_name == k){
|
|
|
+ laster: for(const l in this.attr_groups[i].attr_list){
|
|
|
+ if(this.attr_groups[i].attr_list[l].attr_name == this.flavorIsActive[k]){
|
|
|
+ resArr.push(this.attr_groups[i].attr_list[l].attr_id);
|
|
|
+ break inner;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const selectedIds = resArr.join(':');
|
|
|
+ uni.navigateTo({
|
|
|
+ url:`/pages/my/integral/integralOrder?product_id=${this.productDetail.id}&attr=${selectedIds}`
|
|
|
+ })
|
|
|
},
|
|
|
// 跳转积分兑换
|
|
|
- goIntegralOrder(id){
|
|
|
+ goIntegralOrder(){
|
|
|
this.$utils.jump({
|
|
|
jump_type: this.hotelDetail.buy_jump_type,
|
|
|
jump_config: this.hotelDetail.buy_jump_config,
|
|
|
attr: JSON.stringify(this.flavorIsActive)
|
|
|
})
|
|
|
},
|
|
|
- }
|
|
|
+ },
|
|
|
+ watch:{
|
|
|
+ selectedHotelId(newValue) {
|
|
|
+ console.log(newValue)
|
|
|
+ this.getHotelDetail(newValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|