<template>
	<view>
		<view class="top">
			<image :src="picUrlss+'guwen_bg.png'" mode="widthFix" class="bg"></image>
			<view class="top-c">
				<view>添加金牌顾问微信~</view>
				<text>领取权益</text>
			</view>
		</view>
		<view class="con">
			<view class="con-t">
				<image :src="id?about.pic:picUrlss+'kefu_img1.png'" class="kf-img"></image>
				<view class="name">{{id?about.title:'循力源'}}</view>
				<view class="tag">金牌顾问</view>
				<view class="shop">{{id?merchant.title:'循力源口腔医院'}}</view>
				<view class="tags ddflex" v-if="about.fieldValues&&about.fieldValues.label&&about.fieldValues.label.length>0">
					<text v-for="(item,index) in about.fieldValues.label" :key="index">{{item}}</text>
				</view>
				<view class="tips">尊敬的会员您好，我是循力源的金牌顾问，可以为您提供专业的牙健康指导以及到店的贴心服务哦。</view>
			</view>
			<view class="qrcode">
				<image :src="id?about.fieldValues.qrcode:about.service_prcode" show-menu-by-longpress="true"></image>
				<view>1.长按扫码<text>2.添加好友</text></view>
			</view>
		</view>
	</view>
</template>

<script>
//index.js
//获取应用实例
const app = getApp();
const req = require('../../utils/request.js');
const api = require('../../utils/api.js');
const utils = require('../../utils/util.js');
export default {
	data() {
		return {
			picUrlss: req.public.picUrls + 'blue/',
			id: '',
			merchant: {},
			about: {}
		};
	},
	onLoad: async function(options) {
		this.id = options.id
		this.getMerchant()
		if(this.id){
			this.getDetail()
		}else{
			this.getConfig()
		}
	},

	async onShow() {
	},
	methods: {
		getMerchant(){
			if(req.getStorage('MERCHANT')){
				this.merchant = req.getStorage('MERCHANT')
			}else{
				this.merchant = req.getStorage('defaultMerchant')
			}
		},
		splitLabel(label){
			if(!label){
				return false;
			}else{
				return label.split('、');
			}
		},
		getDetail() {
			var _this = this;
			return new Promise((res, rej) => {
				req.getRequest(
					'/api/content/detail',{id: this.id},
					data => {
						if(data.fieldValues && data.fieldValues.label){
							data.fieldValues.label = this.splitLabel(data.fieldValues.label)
						}
						this.about = data;
						res(data);
					},
					true
				);
			});
		},
		getConfig() {
			var _this = this;
			return new Promise((res, rej) => {
				req.g(
					'/api/config',
					data => {
						this.about = data;
						res(data);
					},
					true
				);
			});
		},
	}
};
</script>

<style>
	@import "./index.css";
</style>
