<template>
	<view class="container">
		<view class="title">
			请选择问题类型<text style="color: #d77958;display: inline-block;margin-left: 4rpx;">*</text>
		</view>
		<van-collapse :value="activeNames" @change="onChange">
			<view class="" v-for=" item in commomProblems" :key="index">
				<van-collapse-item :name="index" class="problem-item" content-class>
					<view slot="title">
						<view class="service-title" style="height: 60rpx;">
							{{ item.problem_name }}
						</view>
					</view>
					{{item.problem_result}}
				</van-collapse-item>
			</view>
		</van-collapse>
		<view class="submit-btn" @tap="toService">在线客服</view>
	</view>
</template>

<script>
	var util = require('../../../utils/util.js');
	var api = require('../../../config/api.js');
	var app = getApp();
	export default {
		data() {
			return {
				commomProblems: [],
				activeNames: ['1'],
			};
		},
		onLoad: function() {},
		onReady: function() {},
		onShow: function() {
			let that = this
			util.request(
				api.getProblems
			).then(function(res) {
				if (res.errno === 0) {
					that.setData({
						commomProblems: res.data
					})
				}
			});


		},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {},
		methods: {
			onChange(event) {
				console.log("event.detail", event.detail);
				this.setData({
					activeNames: event.detail,
				});
			},
			toService() {
				uni.navigateTo({
					url: "/pages/im/im"
				})
			}
		}
	};
</script>
<style>
	.container {
		width: 720rpx;
		border-radius: 30rpx;
		margin: 30rpx auto;
	}

	.title {
		background: #fff;
		height: 130rpx;
		line-height: 130rpx;
		font-weight: bold;
		padding-left: 22rpx;
		border-radius: 30rpx 30rpx 0 0;
		border-bottom: 1rpx #999 solid;
		font-size: 32rpx;
	}

	.problem-item {
		height: 100rpx !important;
	}

	.submit-btn {
		text-align: center;
		color: #d77958;
		margin: 120rpx 26rpx 60rpx;
		width: 650rpx;
		height: 90rpx;
		line-height: 90rpx;
		border-radius: 90rpx;
		font-size: 34rpx;
		border: 1rpx solid #d77958;
	}
</style>