GoodsDetails.vue 7.52 KB
<template>
	<view class="page">
		<!-- banner -->
		<view class="banner">
			<swiper class="screen-swiper round-dot" indicator-dots="true" circular="true" autoplay="true"
				interval="5000" duration="500">
				<swiper-item v-for="(item, index) in swiperList" :key="index">
					<image :src="baseUrl  + item.url" style="width: 100%;height: 100%;" mode="aspectFill"></image>
					<!-- <video src="{{item.url}}" autoplay loop muted show-play-btn="{{false}}" controls="{{false
            }}" objectFit="cover" wx:if="{{item.type == 'video'}}"></video> -->
				</swiper-item>
			</swiper>
		</view>

		<view class="gd-content">
		<view class="goodscontent">
			<view class="goods-box">
				<!-- 标题 -->
				<view class="goods-title">
					<view class="goods-title-top">{{returnData.title}}</view>
					<view class="goods-title-text">{{returnData.remark}}</view>
					<view class="goods-fx">
						<image src="../../static/fx.png"></image>
					</view>
				</view>
			</view>
		</view>
		<!-- <view class="list-middle">
			<view class="list-middle-list">
				<view>产地</view>
				<view class="list-middle-list-text">四川大凉山</view>
			</view>
			<view class="list-middle-list">
				<view>规格</view>
				<view class="list-middle-list-text">精品</view>
			</view>
			<view class="list-middle-list">
				<view>物流</view>
				<view class="list-middle-list-text">包邮(部分地区除外)</view>
			</view>
		</view> -->
		
		<view class="feed-list">
			<view class="feed-list-box">
				<view class="feed-list-box-left">
					<!-- <view><image src="../../static/img/logo.png"></image></view> -->
					<view>
						<view class="feed-list-box-name">{{this.companyName}}</view>
						<!-- <view class="feed-list-box-add"><image src="../../static/kefu1.png"></image>成都市锦江区带永明路666号</view> -->
					</view>
				</view>
				<view><view class="feed-list-box-btn" @click="toCompanyInfo(returnData.comapny)">查看</view></view>
			</view>
			<!-- <view>
				<scroll-view class="scroll-view" scroll-x="true">
				    <view class="item">
				        <image src="../../static/img/add.jpg"></image>
				    </view>
					<view class="item">
					     <image src="../../static/img/add.jpg"></image>
					</view>
					<view class="item">
					     <image src="../../static/img/add.jpg"></image>
					</view>
					<view class="item">
					     <image src="../../static/img/add.jpg"></image>
					</view>
				</scroll-view>
			</view> -->
		</view>

		<view class="goods-list">
			<view class="list">
				<!-- 商品介绍 -->
				<view class="products-introduction" ref="products">
					<view class="title">
						<text>商品介绍</text>
					</view>
					<view class="content" v-html="web_content"></view>
				</view>
			</view>
		</view>
		</view>
		<!-- 底部 -->
		<view class="page-footer">
			<view class="footer-fn">
				<view class="list">
					<image src="../../static/detail2.png"></image>
					<text>收藏</text>
				</view>
			</view>
			<view class="footer-buy">
				<view class="buy-at" @click="callPhone(phoneNumber)">  
					<image src="../../static/detail1.png"></image>
					<text>打电话</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '@/utils/request.js'
import { data } from '../../uview-ui/libs/mixin/mixin';
	export default {
		data() {
			return {
				TabShow: 0,
				isMore: false,
				AttentionShow: 0,
				swiperList: [{
						id: 0,
						type: 'image',
						url: '/static/img/add.jpg'
					},
					{
						id: 1,
						type: 'image',
						url: '/static/img/add.jpg'
					}
				],
				web_content: '<div class="m-img"><img src="../../static/img/add.jpg"><div class="tools" hidden><i class="fa fa-arrow-up move-up"></i><i class="fa fa-arrow-down move-down"></i><em class="move-remove" hidden ><i class="fa fa-times" aria-hidden="true"></i> 移除</em><div class="cover"></div></div></div>',
				PageScrollTop: 0,
				type: 0,
				id:'',
				returnData:{},
				baseUrl:'http://deyanggaoxin.fengshiyun.com',
				companyName:'',
				phoneNumber:'',
				// 公司id
				companyId:''
			};
		},
		onLoad(options) {
			let data = JSON.parse(options.data)
			console.log(data)
			this.id = data.id
			this.getProDetail()
			// this.getCompanyPhone()
		},
		onPageScroll(e) {
			this.PageScrollTop = e.scrollTop;
		},
		methods: {
			// 获取产品详情
			getProDetail(){
				request({
					url:`/api/Extend/baseproduct/${this.id}`,
					methd:'get',
					data:{}
				}).then(res=>{
					if(res.code === 200){
						console.log(res)
						this.returnData = res.data
						this.companyId = this.returnData.comapny
						this.companyName = res.data.companyName
						this.web_content = this.returnData.content
						if(res.data.companyName === null){
							this.companyName === res.data.comapny
						}
						if(res.data.images.length >= 0){
							this.swiperList = res.data.images.map(it=>{
								return {
									type:'image',
									id:it.fileId,
									url:it.url
								}
							})
							this.swiperList = JSON.parse(JSON.stringify(this.swiperList))
							// console.log(res.data.images.length)
							// console.log(this.swiperList)
						}
						
					}
				}).then(data=>{
					request({
						url:`/api/permission/organize/${this.companyId}`,
						// url:`/api/permission/organize/bbf6effe-6354-11ed-b582-00163e2cec73`,
						method:'get',
						data:{}
					}).then(res=>{
						console.log('电话号码返回结果',res)
						if(res.code === 200){
							this.phoneNumber = res.data.fuzerendianhua
							console.log("电话号码", this.phoneNumber)
						}else{
							uni.showToast({
								icon:'error',
								title:"获取信息失败,请重试!"
							})
						}
					})
				})
				
			},
			onCouponTab(type) {
				this.TabShow = type;
			},
			/**
			 * 返回
			 */
			onBack() {
				uni.navigateBack();
			},
			/**
			 * tab
			 */
			onTab(type) {
				this.TabShow = type;
				switch (type) {
					case 0:
						uni.pageScrollTo({
							scrollTop: 0,
							duration: 300
						});
						break;
					case 1:
						uni.createSelectorQuery().select(".evaluate-data").boundingClientRect((data) => { //data - 各种参数
							uni.pageScrollTo({
								scrollTop: this.PageScrollTop + data.top - 50,
								duration: 300
							});
						}).exec()
						break;
					case 2:
						uni.createSelectorQuery().select(".products-introduction").boundingClientRect((
							data) => { //data - 各种参数
							uni.pageScrollTo({
								scrollTop: this.PageScrollTop + data.top - 50,
								duration: 300
							});
						}).exec()
						break;
				}
			},
			// 跳转到公司详情
			toCompanyInfo(item){
				uni.navigateTo({
					url: `/pages/companyDetail/companyDetail?data=${JSON.stringify(item)}`
				})
			},
			// 拨打电话
			callPhone(phoneNumber){
				if (uni.getSystemInfoSync().platform == 'android' || uni.getSystemInfoSync().platform == 'ios') {
				    uni.showModal({
				        title: '温馨提示',
				        content: '确定要拨打电话吗?',
				        success: function (res) {
				            if (res.confirm) {
				                // 使用plus的API拨打电话
				                plus.device.dial(phoneNumber, true);
				            }
				        }
				    })
				} else {
				    // 非APP平台时,使用uniapp自带的API拨打电话
				    uni.makePhoneCall({
				        phoneNumber: phoneNumber,
				        success: function () {
				            console.log('拨打电话成功!');
				        },
				        fail: function () {
				            console.log('拨打电话失败!');
				        }
				    });
				}
			}
			
		}
	};
</script>

<style scoped lang="scss">
	@import 'GoodsDetails.scss';
</style>