Feedback.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div container">
  3. <view class="div common-header-wrap">
  4. <view class="status-holder"></view>
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="意见反馈" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view class="div feedback-form">
  14. <view class="div field-line-right" ><textarea class="feedback-message field-input" v-model="feedback" placeholder="反馈内容:" ></textarea></view>
  15. <!-- <flex-line class="field-line" :show-border="true"><text class="span field-name">验证码</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="pictureCode" /><image mode="aspectFit" @click="changePictureCode" height="48" :src="pictureCodeUrl" class="img countdown" ></view></flex-line> -->
  16. <view class="div pt-10 pb-10"><view class="div common-btn ds-button-large" @click="submit">保存</view></view>
  17. </view>
  18. <view class="scroll-view div" style="position:relative">
  19. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div" @scrolltolower="loadMore" scroll-y="true">
  20. <view class="div feedback-list" v-if="feedback_list && feedback_list.length">
  21. <view class="div feedback-item" v-for="(item, index) in feedback_list" :key="index">
  22. <view class="div feedback-info">
  23. <view class="div p-info">
  24. <view class="div explain">咨询内容
  25. <text class="span right">{{ $moment.unix(item.fb_time).format('YYYY年MM月DD日') }}</text>
  26. </view>
  27. <view class="div name">{{item.fb_content}}</view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <empty-record v-else-if="feedback_list && !feedback_list.length"></empty-record>
  33. </scroll-view>
  34. </view>
  35. </view></member-base>
  36. </template>
  37. <script>
  38. import {getFontSize} from '@/util/common'
  39. import TitleHeader from '../../TitleHeader'
  40. import MemberBase from '../MemberBase'
  41. import { mapState, mapMutations } from 'vuex'
  42. import EmptyRecord from '../../EmptyRecord'
  43. import { getFeedbackList, addFeedback } from '../../../api/memberFeedback'
  44. import { checkPictureCaptcha } from '../../../api/common'
  45. import flexLine from '../../flexLine'
  46. import { env } from '../../../static/config'
  47. export default {
  48. name:'MemberFeedback',
  49. computed:{
  50. fontSize(){
  51. return getFontSize()
  52. },
  53. },
  54. data(){
  55. return {
  56. navHeight: 0,
  57. feedback: '',
  58. params: { 'page': 0, 'per_page': 10 },
  59. pictureCode: '',
  60. pictureCodeUrl: '',
  61. pictureCodeValid: false,
  62. feedback_list: false,
  63. loading: false, // 是否加载更多
  64. isMore: true // 是否有更多
  65. }
  66. },
  67. components:{
  68. TitleHeader,
  69. MemberBase,
  70. flexLine,
  71. EmptyRecord
  72. },
  73. mounted(){
  74. // #ifdef MP-WEIXIN
  75. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  76. // #endif
  77. // this.changePictureCode()
  78. },
  79. created () {
  80. this.loadMore()
  81. },
  82. watch: {
  83. pictureCode: function (val) {
  84. if (val.length >= 4) {
  85. this.pictureCodeWait = true
  86. checkPictureCaptcha(val).then(
  87. response => {
  88. this.pictureCodeWait = false
  89. this.pictureCodeValid = true
  90. },
  91. error => {
  92. this.pictureCodeWait = false
  93. uni.showToast({icon:'none',title: error.message})
  94. }
  95. )
  96. }
  97. }
  98. },
  99. methods:{
  100. goBack(){uni.navigateBack({delta:1})},
  101. submit () {
  102. // if (!this.pictureCode) {
  103. // uni.showToast({icon:'none',title: '请先输入图片验证码'})
  104. // return
  105. // }
  106. if (!this.feedback) {
  107. uni.showToast({icon:'none',title: '请先输入反馈内容'})
  108. return
  109. }
  110. // if (!this.pictureCodeValid) {
  111. // uni.showToast({icon:'none',title: '验证码错误'})
  112. // return
  113. // }
  114. addFeedback(this.feedback).then(res => {
  115. uni.showToast({icon:'none',title: res.message})
  116. this.feedback = ''
  117. this.pictureCode = ''
  118. this.params = { 'page': 0, 'per_page': 10 }
  119. this.feedback_list = false
  120. this.loading = false
  121. this.isMore = true
  122. this.loadMore()
  123. this.changePictureCode()
  124. }).catch(function (error) {
  125. uni.showToast({icon:'none',title: error.message})
  126. })
  127. },
  128. changePictureCode () {
  129. this.pictureCodeUrl = env.API_HOST + '/Seccode/makecode?r=' + Math.random()
  130. },
  131. loadMore () {
  132. this.loading = true
  133. this.params.page = ++this.params.page
  134. if (this.isMore) {
  135. this.loading = false
  136. this.getConsultList(true)
  137. }
  138. },
  139. getConsultList () {
  140. uni.showLoading({ title: '加载中' })
  141. getFeedbackList(this.params).then(res => {
  142. uni.hideLoading()
  143. if (res.result.hasmore) {
  144. this.isMore = true
  145. } else {
  146. this.isMore = false
  147. }
  148. this.feedback_list = res.result.feedback_list.data
  149. }).catch(function (error) {
  150. uni.hideLoading()
  151. uni.showToast({icon:'none',title: error.message})
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style scoped lang="scss">
  158. .scroll-view-wrapper{display: flex;flex-direction: column;}
  159. .scroll-view{flex:1}
  160. .feedback-form{background: #fff;padding:0 $pageSpace;box-shadow: 0px 4px 4px #f7f7f7;position: relative;}
  161. .feedback-message{background: #fbfbfb;margin: .5rem 0;font-size: .7rem;padding: .5rem;height: 4rem;border: 0;box-sizing: border-box;width: 100%;}
  162. .feedback-list{background: #fff;padding:0 $pageSpace;}
  163. .feedback-item{background:#fff;border-bottom:1px dashed #eee;}
  164. .feedback-info{padding:.5rem 0;display: flex}
  165. .feedback-info .p-info{width: 100%;}
  166. .feedback-info .p-info .name{font-size:$subFontSize;color:$primaryColor;word-break:break-all}
  167. .feedback-info .p-info .explain{font-size:$subFontSize;margin-bottom:.5rem}
  168. .feedback-info .p-info .explain .right{float:right;color:gray}
  169. .feedback-info .p-info .replay{font-size:$subFontSize;padding-top:.5rem;color:$descTextColor}
  170. .countdown{width: auto;height: 1.75rem;min-width: 4rem;}
  171. </style>