Browse Source

吉农宝

hanfucheng 1 năm trước cách đây
mục cha
commit
ab8589c8d7

+ 38 - 0
api/asking/addquestion.js

@@ -0,0 +1,38 @@
+import request from '@/utils/request'
+
+//新增问题
+export function addQuestion(data) {
+  return request({
+    url: '/asking/question/addQuestion',
+    method: 'post',
+    data: data
+  })
+}
+
+//查询类型配置
+export function listType(query) {
+  return request({
+    url: '/asking/question/typeList',
+    method: 'get',
+    params: query
+  })
+}
+
+/**
+ * 验证积分是否充足
+ */
+export function verifyScore(query) {
+  return request({
+    url: '/score/verifyScore',
+    method: 'get',
+	params:query
+  })
+}
+
+//按用户id查询实名认证信息
+export function getUserInfo(userId) {
+  return request({
+    url: '/nameAuthentication/getNameInfo/'+ userId,
+    method: 'get',
+  })
+}

+ 54 - 0
api/asking/questiondetails.js

@@ -0,0 +1,54 @@
+import request from '@/utils/request'
+
+// 获取问题详情
+export function getDetailById(query) {
+  return request({
+    url: '/asking/question/getDetailById',
+    method: 'get',
+    params: query
+  })
+}
+
+//获取用户信息
+export function getUserInfo(userId) {
+	return request({
+		url: '/system/user/getWxUserInfo/' + userId,
+		method: 'get'
+	})
+}
+
+//添加答案
+export function addAnswer(data) {
+	return request({
+		url: '/asking/answer/addAnswer',
+		method: 'post',
+		data: data
+	})
+}
+
+//答案采纳
+export function adoptAnswer(data) {
+	return request({
+		url: '/asking/answer/adoptAnswer',
+		method: 'get',
+		data: data
+	})
+}
+
+//添加收藏
+export function addCollect(query) {
+	return request({
+		url: '/asking/collect/addCollect',
+		method: 'get',
+		params: query
+	})
+}
+
+//是否收藏
+export function selectCollect(query) {
+	return request({
+		url: '/asking/collect/selectCollect',
+		method: 'get',
+		params: query
+	})
+}

+ 28 - 0
api/asking/questionlist.js

@@ -0,0 +1,28 @@
+import request from '@/utils/request'
+
+// 按类型获取全部问题列表
+export function getAllQuestionByType(query) {
+  return request({
+    url: '/asking/question/getAllQuestionByType',
+    method: 'get',
+    params: query
+  })
+}
+
+// 按类型获取精彩回答列表
+export function getExcitingAnswersList(query) {
+  return request({
+    url: '/asking/question/getExcitingAnswersList',
+    method: 'get',
+    params: query
+  })
+}
+
+// 按类型获取最多悬赏列表
+export function getMaxScoreList(query) {
+  return request({
+    url: '/asking/question/getMaxScoreList',
+    method: 'get',
+    params: query
+  })
+}

+ 0 - 0
pages/asking/addquestion.css


+ 124 - 0
pages/asking/addquestion.vue

@@ -0,0 +1,124 @@
+<template>
+  <uni-section title="问题新增" type="line">
+    <view class="example">
+      <uni-forms ref="customForm" :rules="customRules" :modelValue="form" class="form">
+        <uni-forms-item label="标题" required name="title">
+          <uni-easyinput v-model="form.title" placeholder="请输入标题" maxlength="50"/>
+        </uni-forms-item>
+        <uni-forms-item label="正文" required name="text">
+		  <uni-easyinput type="textarea" v-model="form.text" :maxlength="1000" @blur="binddata('textDetails', $event.detail.value)" placeholder="请输入正文"></uni-easyinput>
+        </uni-forms-item>
+		
+        <uni-forms-item label="提问类型" required name="typeId">
+		  <uni-data-select
+			  v-model="form.typeId"
+			  :localdata="typeList"
+			></uni-data-select>
+        </uni-forms-item>
+        <uni-forms-item label="悬赏" required name="score" >
+          <uni-number-box  v-model="form.score" :min="0" :max="99999" label="请输入悬赏积分"></uni-number-box >
+        </uni-forms-item>
+        <uni-forms-item label="图片" class="path" >
+          <upload :imgArr="imageList" name="path" v-model="form.path" 
+                  style="position: relative;left: -5%;top: -10%;"
+                  @updateImg="updateImg"></upload>
+        </uni-forms-item>
+      </uni-forms>
+      <button type="primary" @click="submitForm('customForm')" >提交</button>
+    </view>
+  </uni-section>
+</template>
+
+<script>
+import upload from '@/components/upload/index.vue'
+import {listType,addQuestion,verifyScore,getUserInfo} from '@/api/asking/addquestion.js'
+
+export default {
+  components: {
+    upload
+  },
+  onReady() {
+    // 设置自定义表单校验规则,必须在节点渲染完毕后执行
+    this.$refs.customForm.setRules(this.customRules)
+    this.getTypeList();
+  },
+  data() {
+    return {
+      disabled: false,
+      //类型配置
+      typeList: [],
+      form: {},
+      form1: {},
+      // 表单校验
+      customRules: {
+        title: {
+          rules: [{
+            required: true,
+            errorMessage: '标题不能为空'
+          }]
+        },
+        text: {
+          rules: [{
+            required: true,
+            errorMessage: '正文不能为空'
+          }]
+        },
+        typeId: {
+          rules: [{
+            required: true,
+            errorMessage: '提问类型不能为空'
+          }]
+        },
+      },
+      imageList: []
+    }
+  },
+  methods: {
+    //查询类型配置
+    getTypeList() {
+      listType(this.queryParams).then(response => {
+		  response.data.forEach(v => {
+		  	this.typeList.push({
+		  		text:v.type,
+		  		value:v.id
+		  	})
+		  })
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    /** 提交按钮 */
+    submitForm(e) {
+		this.form.score = this.form.score==null?0:this.form.score;
+		this.form1.scoreNum = this.form.score;
+		this.form1.userId = getApp().globalData.userId;
+		verifyScore(this.form1).then(res => {
+		  if(!res.data){
+			  uni.showToast({
+			  	title:"您的积分不足"
+			  })
+		  }else{
+			  this.$refs[e].validate().then(res => {
+			  		  this.form.type = this.typeList.filter((item) => {
+			  			return this.form.typeId == item.value;
+			  		  })[0].text;
+			      addQuestion(this.form).then(res => {
+			        uni.navigateBack();
+			      });
+			  })
+		  }
+		});
+    },
+
+    //图片上传
+    updateImg(imgList) {
+      this.imageList = imgList;
+      this.form.path = this.imageList.join(',');
+    }
+  }
+};
+</script>
+

+ 160 - 0
pages/asking/questiondetails.css

@@ -0,0 +1,160 @@
+/* pages/wenbaxiangqing.wxss */
+.title {
+    font-size: 44rpx;
+    text-align: center;
+    line-height: 70rpx;
+    color: #333;
+    margin: 30rpx 0;
+}
+.wenzhangLy {
+    width: 100%;
+    display: flex;
+    justify-content: space-between;
+    border-bottom: solid 2rpx #e8e8e8;
+    padding: 0 0 14rpx 0;
+}
+.txTime {
+    display: flex;
+    flex-direction: row;
+}
+.txTime image {
+    width: 80rpx;
+    height: 80rpx;
+}
+.time {
+    display: flex;
+    flex-direction: column;
+    padding: 10rpx 0 0 8px;
+}
+.time p {
+    font-size: 28rpx;
+    color: #9c9c9c;
+}
+.time span {
+    font-size: 24rpx;
+    color: #c4c4c4;
+}
+
+.jf {
+    color: #07c160;
+    line-height: 80rpx;
+    font-size: 24rpx;
+}
+.icon-jifen {
+    font-size: 28rpx;
+    color: #07c160;
+    margin: 0 0 0 6rpx;
+}
+.ck {
+    color: #c4c4c4;
+    font-size: 28rpx;
+}
+.icon-pinglun,
+.icon-chakan,
+.ck .icon-shoucang {
+    font-size: 28rpx;
+    margin: 0 6rpx 0 20rpx;
+    color: #c4c4c4;
+    line-height: 0;
+}
+.wenzhangCont {
+    font-size: 34rpx;
+    margin: 30rpx 0;
+}
+.wenzhangCont image {
+    width: 100%;
+    height: 320rpx;
+    margin: 20rpx auto;
+}
+.pinglunTj {
+    width: 100%;
+    display: flex;
+    justify-content: space-between;
+    margin: 30rpx 0;
+}
+.pinglunTitle {
+    font-size: 34rpx;
+    color: #2e2e2e;
+    font-weight: 600;
+}
+.pinglunTitle em {
+    font-size: 34rpx;
+    color: #9b9b9b;
+    font-weight: normal;
+    margin: 0 0 0 10rpx;
+}
+.pinglunList {
+    width: 100%;
+    padding: 0 0 120rpx 0;
+}
+.pinglunList li {
+    margin: 20rpx 0;
+    border-bottom: solid 2rpx #e8e8e8;
+    padding: 0 0 20rpx 0;
+    display: flex;
+    flex-direction: column;
+}
+.plListcont {
+    font-size: 30rpx;
+    color: #696868;
+    margin: 20rpx 0;
+}
+.pinglunList li button {
+    width: 80%;
+    border-radius: 10rpx;
+    background: #07c160;
+    color: #fff;
+    font-size: 28rpx;
+    font-weight: normal;
+    margin: 16rpx auto;
+}
+.fabiaoPl {
+    width: 100%;
+    display: flex;
+    justify-content: space-between;
+    position: fixed;
+    left: 0;
+    bottom: 0;
+    height: 112rpx;
+    background: #e8e8e8;
+    box-shadow: 0rpx 0rpx 16rpx #999;
+}
+.shuRu {
+    width: 72%;
+    display: flex;
+    flex-direction: row;
+    height: 76rpx;
+    background: #e0e0e0;
+    border-radius: 60rpx;
+    margin: 20rpx 0 0 20rpx;
+}
+.shuRu input {
+    line-height: 38px;
+    height: 76rpx;
+    font-size: 30rpx;
+    width: 83%;
+}
+.icon-bianji {
+    font-size: 38rpx;
+    line-height: 76rpx;
+    margin: 0 10rpx 0 20rpx;
+    color: #828181;
+}
+.icon-shoucang {
+    font-size: 50rpx;
+    line-height: 112rpx;
+    color: #828181;
+}
+.fasong {
+    width: 58rpx;
+    height: 58rpx;
+    border-radius: 50rpx;
+    background: #07c160;
+    margin: 26rpx 20rpx 0 10rpx;
+    text-align: center;
+    line-height: 58rpx;
+}
+.icon-fasong {
+    font-size: 40rpx;
+    color: #fff;
+}

+ 312 - 0
pages/asking/questiondetails.vue

@@ -0,0 +1,312 @@
+<template>
+    <view>
+        <!-- pages/me.wxml -->
+        <view class="container">
+            <h1 class="title">{{form.title}}</h1>
+            <view class="wenzhangLy">
+                <!-- 头像昵称 -->
+                <view class="txTime">
+                    <image :src="initInfo.headImg == null || initInfo.headImg == '' ? initImgPath : loadImgSrcLocalhost(initInfo.headImg)"></image>
+                    <view class="time">
+                        <p>{{ initInfo.name == null || initInfo.name == '' ? initInfo.wechatName : initInfo.name }}</p>
+                        <span>{{form.createTime}}</span>
+                    </view>
+                </view>
+                <!-- 积分 -->
+                <span class="jf">{{form.score}}</span>
+            </view>
+            <view class="wenzhangCont">
+				<view v-html="form.text"></view>
+                <image :src="loadImgSrcLocalhost(path)" v-for="(path, index2) in form.paths" :key="index2"></image>
+            </view>
+			
+            <view class="fengexian"></view>
+            <!-- 分割线 -->
+            <view class="pinglunTj">
+                <span class="pinglunTitle">
+                    回答
+                    <em>{{form.answerList.length}}</em>
+                </span>
+                <view class="ck">
+                    <span>
+                        <em class="iconfont icon-chakan"></em>
+                        {{form.browse}}
+                    </span>
+                    <span>
+                        <em class="iconfont icon-shoucang"></em>
+                        {{form.collect}}
+                    </span>
+                </view>
+            </view>
+            <ul class="pinglunList" id="pinglunList">
+                <li v-for="(e,idx) in form.answerList" :key="idx" style="position: relative;">
+                    <!-- 头像昵称 -->
+                    <view class="txTime">
+						<image :src="e.headImg == null || e.headImg == '' ? initImgPath : loadImgSrcLocalhost(e.headImg)"></image>
+						<view class="time">
+							<p>{{ e.name == null || e.name == '' ? e.wechatName : e.name }}</p>
+							<span>{{ e.createTime }}</span>
+						</view>
+					</view>
+					<!-- <div class="effectBox"  :style="{ top: adoptTopSize + '%' }">精选答案</div> -->
+					<div class="effectBix" :style="e.adopt == adoptIndex ? 'display:block' : 'display:none' ">采   纳</div>
+                    <text class="plListcont" style="z-index: 10;">{{ e.answer }}</text>
+					<uploadImage/>
+                    <button v-show="!isAdopt" @click="adoptFunc(e.id)">采纳答案</button>
+                </li>
+            </ul>
+        </view>
+        <view class="fabiaoPl" :class="isCollection ? 'collect' : 'not-collect'" style="z-index: 100;">
+            <view class="shuRu">
+                <em class="iconfont icon-bianji"></em>
+                <input placeholder="请输入内容,友好回答" v-model="anwserVal"/>
+            </view>
+            <em
+				class="iconfont icon-shoucang"
+				@click="collectionFunc(form.id)"
+				>
+			</em>
+            <view class="fasong" @click="answerFunc(form.id,anwserVal)"><em class="iconfont icon-fasong"></em></view>
+        </view>
+    </view>
+</template>
+
+<script>
+import {getDetailById,getUserInfo,addCollect,addAnswer,adoptAnswer,selectCollect} from '@/api/asking/questiondetails.js';
+// pages/me.js
+export default {
+    data() {
+        return {
+			initImgPath: 'https://sookajs.top:8888/profile/upload/moren.png',
+			anwserVal:'',
+			isCollection:false,
+			isAdopt:false,
+			adoptTopSize:'115',
+			adoptIndex:1,
+			form:{},
+			answer:{},
+			initInfo:{},
+			collect:{},
+        };
+    },
+	methods: {
+		// 评论回答
+		answerFunc(id,answer){
+			this.answer.questionId = id
+			this.answer.answer = answer
+			this.answer.createBy = getApp().globalData.userId
+			addAnswer(this.answer).then(res =>{})
+			this.anwserVal = null
+		},
+		//采纳答案
+		adoptFunc(id){
+			this.answer.id = id
+			adoptAnswer(this.answer).then(res =>{})
+			this.isAdopt = true
+			this.form.answerList.forEach(v => {
+				if(v.id==id){
+					v.adopt = 1
+				}
+			})
+		},
+		
+		//是否收藏
+		selectCollect(id){
+			this.collect.userId = getApp().globalData.userId;
+			this.collect.questionId = id
+			selectCollect(this.collect).then(res =>{
+				console.log(res)
+				if(res.data.length!=0){
+					this.isCollection = true
+				}
+			})
+		},
+		
+		// 标记喜欢
+		collectionFunc(id){
+			this.collect.userId = getApp().globalData.userId;
+			this.collect.questionId = id
+			addCollect(this.collect).then(res =>{})
+			this.isCollection = !this.isCollection
+		},
+		
+		 //获取问题详情
+		getDetailById(id){
+			this.form.id = id
+			getDetailById(this.form).then(res =>{
+				res.data.answerList.forEach(v => {
+					if(v.adopt=="1"){
+						this.isAdopt = true
+					}
+				})
+				this.form = res.data
+				this.getUserInfoByUserId(this.form.createBy);//获取用户信息
+				this.selectCollect(id);//是否收藏
+			})
+		},
+		
+		//获取用户信息:用户名称:头像
+		getUserInfoByUserId(userId) {
+			getUserInfo(userId).then((res) => {
+				this.initInfo = res.data;
+			});
+		},
+	}
+    /**
+     * 生命周期函数--监听页面加载
+     */,
+    onLoad(options) {
+		this.getDetailById(options.id)
+	},
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady(e) {
+	},
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow() {},
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide() {},
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload() {},
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh() {},
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom() {},
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage() {},
+};
+</script>
+<style lang="scss">
+@import '@/pages/asking/questiondetails.css';
+.collect{
+	.icon-shoucang:before{
+		color: red;
+	}
+}
+.not-collect{
+
+}
+.effectBix{
+	width: 56px;
+	height: 56px;
+	border-radius: 50px;
+	font-family: 'Bebas Neue', cursive;
+	background: linear-gradient(45deg, transparent 5%, #FF013C 5%);
+	border: 0;
+	color: #fff;
+	text-align: center;
+	line-height: 56px;
+	outline: transparent;
+	position: absolute;
+	transform: rotate(-30deg);
+	right:3%;
+	top: -5%;
+}
+
+.effectBox, .effectBox::after {
+  width: 56px;
+  height: 56px;
+  border-radius: 50px;
+  font-size: 16px;
+  font-family: 'Bebas Neue', cursive;
+  background: linear-gradient(45deg, transparent 5%, #FF013C 5%);
+  border: 0;
+  color: #fff;
+  opacity: 1;
+  letter-spacing: 3px;
+  text-align: center;
+  line-height: 56px;
+  outline: transparent;
+  position: relative;
+  left: 78%;
+  top: 113%;
+  transform: rotate(-30deg);
+  z-index: 1;
+}
+
+.effectBox::after {
+  --slice-0: inset(50% 50% 50% 50%);
+  --slice-1: inset(80% -6px 0 0);
+  --slice-2: inset(50% -6px 30% 0);
+  --slice-3: inset(10% -6px 85% 0);
+  --slice-4: inset(40% -6px 43% 0);
+  --slice-5: inset(80% -6px 5% 0);
+
+  content: 'AVAILABLE NOW';
+  display: block;
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  background: linear-gradient(45deg, transparent 3%, #00E6F6 3%, #00E6F6 5%, #FF013C 5%);
+  text-shadow: -3px -3px 0px #F8F005, 3px 3px 0px #00E6F6;
+  clip-path: var(--slice-0);
+}
+
+.effectBox:hover::after {
+  animation: 1s glitch;
+  animation-timing-function: steps(2, end);
+}
+
+@keyframes glitch {
+  0% {
+    clip-path: var(--slice-1);
+    transform: translate(-20px, -10px);
+  }
+  10% {
+    clip-path: var(--slice-3);
+    transform: translate(10px, 10px);
+  }
+  20% {
+    clip-path: var(--slice-1);
+    transform: translate(-10px, 10px);
+  }
+  30% {
+    clip-path: var(--slice-3);
+    transform: translate(0px, 5px);
+  }
+  40% {
+    clip-path: var(--slice-2);
+    transform: translate(-5px, 0px);
+  }
+  50% {
+    clip-path: var(--slice-3);
+    transform: translate(5px, 0px);
+  }
+  60% {
+    clip-path: var(--slice-4);
+    transform: translate(5px, 10px);
+  }
+  70% {
+    clip-path: var(--slice-2);
+    transform: translate(-10px, 10px);
+  }
+  80% {
+    clip-path: var(--slice-5);
+    transform: translate(20px, -10px);
+  }
+  90% {
+    clip-path: var(--slice-1);
+    transform: translate(-10px, 0px);
+  }
+  100% {
+    clip-path: var(--slice-1);
+    transform: translate(0);
+  }
+}
+
+</style>

+ 191 - 0
pages/asking/questionlist.css

@@ -0,0 +1,191 @@
+/* pages/sannong.wxss */
+.snTab {
+    width: 100%;
+}
+
+.fontColorBox,
+.fontColorBox1 {
+    color: #07c160;
+}
+
+.navBox {
+    /* 顶部tab盒子样式 */
+    width: 100%;
+    height: 108rpx;
+    background: white;
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    justify-content: center;
+}
+/* 最后一个tab标题的样式 */
+
+.titleBox {
+    /* 未选中文字的样式 */
+    color: rgb(168, 170, 175);
+    font-size: 30rpx;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    width: 32%;
+}
+.lineBox,
+.notLineBox {
+    /* 选中及未选中底线共同样式 */
+    width: 32rpx;
+    height: 8rpx;
+}
+
+.lineBox {
+    /* 选中底线样式 */
+    background: #07c160;
+    margin-top: 16rpx;
+    border-radius: 4rpx;
+}
+
+.notLineBox {
+    /* 未选中底线样式 */
+    background: transparent;
+}
+
+.swiperTtemBox {
+    /* 底部内容样式 */
+    height: 100vh;
+    overflow: scroll;
+    margin: 12rpx 0rpx;
+    background: white;
+    font-size: 28rpx;
+}
+
+/* 热门问答 */
+.rnwdList {
+    width: 100%;
+    height: 100%;
+}
+.list {
+    border-bottom: solid 2rpx #f6f6f6;
+    padding: 10rpx 0;
+    width: 100%;
+}
+.listTitle {
+    font-size: 32rpx;
+    color: #333;
+    line-height: 40rpx;
+}
+.jlSj {
+    height: 40rpx;
+    display: flex;
+    justify-content: space-between;
+    font-size: 24rpx;
+    margin: 20rpx 0 0 0;
+}
+.jf {
+    color: #07c160;
+}
+.icon-jifen {
+    font-size: 28rpx;
+    color: #07c160;
+    margin: 0 0 0 6rpx;
+}
+.ck {
+    color: #c4c4c4;
+}
+.icon-pinglun,
+.icon-chakan,
+.icon-shoucang {
+    font-size: 28rpx;
+    margin: 0 6rpx 0 20rpx;
+    color: #c4c4c4;
+}
+.onePic {
+    width: 100%;
+    height: 360rpx;
+    border-radius: 20rpx;
+    overflow: hidden;
+    margin: 20rpx 0;
+}
+.onePic image {
+    width: 100%;
+    height: 100%;
+}
+.twoPic {
+    width: 100%;
+    height: 220rpx;
+    margin: 20rpx 0;
+    display: flex;
+    justify-content: space-between;
+}
+.twoPic image {
+    width: 49%;
+    height: auto;
+    border-radius: 20rpx;
+}
+.threePic {
+    width: 100%;
+    height: 160rpx;
+    margin: 20rpx 0;
+    display: flex;
+    justify-content: space-between;
+}
+.threePic image {
+    width: 32%;
+    height: auto;
+    border-radius: 20rpx;
+}
+
+.pane-con {
+    margin: 20rpx 0;
+}
+.tabs-pane {
+    padding: 10rpx 20rpx;
+    margin-right: 20rpx;
+    border: 1px solid lightgrey;
+}
+.tabs-pane:nth-last-child(1) {
+    margin-right: 0;
+}
+.tabs-pane.active {
+    background: #5495df;
+    border-color: #5495df;
+    color: #fff;
+}
+
+.tab-class {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100vw;
+    bottom: 0;
+}
+
+.guidebook .img_box {
+    margin-bottom: 12rpx;
+    padding-left: 4rpx;
+}
+.guidebook .img_box .many_img {
+    display: flex;
+    justify-self: start;
+    flex-wrap: wrap;
+}
+.guidebook .img_item.four {
+    width: 198rpx;
+    height: 198rpx;
+    margin-right: 16rpx;
+    margin-bottom: 16rpx;
+    border-radius: 16rpx;
+    overflow: hidden;
+}
+.guidebook .img_item.four:nth-child(2n) {
+    margin-right: 30rpx;
+}
+.guidebook .img_item.many {
+    width: 198rpx;
+    height: 198rpx;
+    margin-right: 16rpx;
+    margin-bottom: 16rpx;
+    border-radius: 16rpx;
+    overflow: hidden;
+}
+.guidebook .img_item.many:nth-child(3n) {
+    margin-right: 0;
+}

+ 209 - 0
pages/asking/questionlist.vue

@@ -0,0 +1,209 @@
+<template>
+    <!-- pages/me.wxml -->
+    <view class="container">
+        <tabs :list="tabs" tab-class="tab-class" :showBadge="true" :swiper="true" activeColor="#07c160" normalColor="#000000" @change="tabChange">
+            <tab-page :slot="item.name" v-for="(item, index) in tabs" :key="index">
+                <view v-if="index == 0" class="container">
+                    <view class="rnwdList">
+                        <view class="list" @tap="goDetails(item1.id)" v-for="(item1, index1) in allQuestion" :key="index1">
+                            <span class="listTitle">{{ item1.title }}</span>
+                            <view class="onePic" v-if="item1.paths!=null&&item1.paths.length == 1">
+                                <image :src="loadImgSrcLocalhost(path)" v-for="(path, index2) in item1.paths" :key="index2"></image>
+                            </view>
+                            <view class="twoPic" v-if="item1.paths!=null&&item1.paths.length == 2">
+                                <image :src="loadImgSrcLocalhost(path)" v-for="(path, index2) in item1.paths" :key="index2"></image>
+                            </view>
+
+                            <view class="threePic" v-if="item1.paths!=null&&item1.paths.length == 3">
+                                <image :src="loadImgSrcLocalhost(path)" v-for="(path, index2) in item1.paths" :key="index2"></image>
+                            </view>
+
+                            <view class="jlSj">
+                                <span class="jf">
+                                    {{ item1.score }}
+                                    <em class="iconfont icon-jifen"></em>
+                                </span>
+                                <view class="ck">
+                                    <span>
+                                        <em class="iconfont icon-pinglun"></em>
+                                        {{ item1.comment }}
+                                    </span>
+                                    <span>
+                                        <em class="iconfont icon-chakan"></em>
+                                        {{ item1.browse }}
+                                    </span>
+                                    <span>
+                                        <em class="iconfont icon-shoucang"></em>
+                                        {{ item1.collect }}
+                                    </span>
+                                </view>
+                            </view>
+
+						</view>
+                    </view>
+                </view>
+
+                <view v-if="index == 1" class="rnwdList">
+                    <view class="rnwdList">
+                        <view class="list" @tap="goDetails(item1.id)" v-for="(item1, index1) in excitingAnswersList" :key="index1">
+                            <span class="listTitle">{{ item1.title }}</span>
+                            <view class="onePic" v-if="item1.paths!=null&&item1.paths.length == 1">
+                                <image :src="loadImgSrcLocalhost(path)" v-for="(path, index2) in item1.paths" :key="index2"></image>
+                            </view>
+                            <view class="twoPic" v-if="item1.paths!=null&&item1.paths.length == 2">
+                                <image :src="loadImgSrcLocalhost(path)" v-for="(path, index2) in item1.paths" :key="index2"></image>
+                            </view>
+                        
+                            <view class="threePic" v-if="item1.paths!=null&&item1.paths.length == 3">
+                                <image :src="loadImgSrcLocalhost(path)" v-for="(path, index2) in item1.paths" :key="index2"></image>
+                            </view>
+                        
+                            <view class="jlSj">
+                                <span class="jf">
+                                    {{ item1.score }}
+                                    <em class="iconfont icon-jifen"></em>
+                                </span>
+                                <view class="ck">
+                                    <span>
+                                        <em class="iconfont icon-pinglun"></em>
+                                        {{ item1.comment }}
+                                    </span>
+                                    <span>
+                                        <em class="iconfont icon-chakan"></em>
+                                        {{ item1.browse }}
+                                    </span>
+                                    <span>
+                                        <em class="iconfont icon-shoucang"></em>
+                                        {{ item1.collect }}
+                                    </span>
+                                </view>
+                            </view>
+                        
+                        </view>
+                    </view>
+                </view>
+
+                <view v-if="index == 2" class="rnwdList">
+                    <view class="rnwdList">
+                        <view class="list" @tap="goDetails(item1.id)" v-for="(item1, index1) in maxScoreList" :key="index1">
+                            <span class="listTitle">{{ item1.title }}</span>
+                            <view class="onePic" v-if="item1.paths!=null&&item1.paths.length == 1">
+                                <image :src="loadImgSrcLocalhost(path)" v-for="(path, index2) in item1.paths" :key="index2"></image>
+                            </view>
+                            <view class="twoPic" v-if="item1.paths!=null&&item1.paths.length == 2">
+                                <image :src="loadImgSrcLocalhost(path)" v-for="(path, index2) in item1.paths" :key="index2"></image>
+                            </view>
+                        
+                            <view class="threePic" v-if="item1.paths!=null&&item1.paths.length == 3">
+                                <image :src="loadImgSrcLocalhost(path)" v-for="(path, index2) in item1.paths" :key="index2"></image>
+                            </view>
+                        
+                            <view class="jlSj">
+                                <span class="jf">
+                                    {{ item1.score }}
+                                    <em class="iconfont icon-jifen"></em>
+                                </span>
+                                <view class="ck">
+                                    <span>
+                                        <em class="iconfont icon-pinglun"></em>
+                                        {{ item1.comment }}
+                                    </span>
+                                    <span>
+                                        <em class="iconfont icon-chakan"></em>
+                                        {{ item1.browse }}
+                                    </span>
+                                    <span>
+                                        <em class="iconfont icon-shoucang"></em>
+                                        {{ item1.collect }}
+                                    </span>
+                                </view>
+                            </view>
+                        
+                        </view>
+                    </view>
+                </view>
+
+			</tab-page>
+        </tabs>
+    </view>
+</template>
+
+<script>
+import tabs from '@/components/tabs/tabs.vue';
+import tabPage from '@/components/tab-page/tab-page.vue';
+import {getAllQuestionByType,getExcitingAnswersList,getMaxScoreList} from '@/api/asking/questionlist.js';
+// pages/me.js
+var localData = require('@/data/json');
+const app = getApp();
+export default {
+    components: {
+        tabs,
+        tabPage
+    },
+    data() {
+        return {
+			form:{},
+			allQuestion: [],
+			excitingAnswersList: [],
+			maxScoreList: [],
+            currentIndex: 0,
+            //默认是活动项
+            tabs: [
+                {
+                    name: '全部问答'
+                },
+                {
+                    name: '精彩问答'
+                },
+                {
+                    name: '最多悬赏'
+                }
+            ]
+        };
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad(options) {
+			this.getAllQuestionByType(uni.getStorageSync('id'))
+			this.getExcitingAnswersList(uni.getStorageSync('id'))
+			this.getMaxScoreList(uni.getStorageSync('id'))
+			uni.setNavigationBarTitle({
+			  title: options.type
+			});
+    },
+    methods: {
+        tabChange: function (e) {
+		},
+		 //按类型获取全部问题列表
+		getAllQuestionByType(id){
+			this.form.id = id
+			getAllQuestionByType(this.form).then(res =>{
+				this.allQuestion = res.rows
+			})
+		},
+		 //按类型获取精彩问题列表
+		getExcitingAnswersList(id){
+			this.form.id = id
+			getExcitingAnswersList(this.form).then(res =>{
+				this.excitingAnswersList = res.rows
+			})
+		},
+		 //按类型获取最多悬赏问题列表
+		getMaxScoreList(id){
+			this.form.id = id
+			getMaxScoreList(this.form).then(res =>{
+				this.maxScoreList = res.rows
+			})
+		},
+        goDetails(id) {
+            uni.navigateTo({
+                url: '/pages/asking/questiondetails?id='+id
+            });
+        }
+    }
+};
+</script>
+<style>
+@import '@/pages/asking/questionlist.css';
+</style>