ConsultList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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="scroll-view div" style="position:relative">
  14. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div" @scrolltolower="loadMore" scroll-y="true">
  15. <view class="div" v-if="consult_list && consult_list.length">
  16. <view class="div consult-item" v-for="(item, index) in consult_list" :key="index">
  17. <view class="head">
  18. <view class="type">{{consult_type[item.consulttype_id].consulttype_name}}</view>
  19. <view class="time">{{ $moment.unix(item.consult_addtime).format('YYYY年MM月DD日') }}</view>
  20. </view>
  21. <view class="goods_info" @click="goGoods(item.goods_id)">
  22. <view class="image-wrapper" :style="'width:'+windowWidth+'px;height:'+windowWidth+'px;flex:0 0 ' + windowWidth + 'px'">
  23. <image mode="aspectFit" class="img" :src="item.goods_image"/>
  24. </view>
  25. <view class="p-info">
  26. <view class="goods_name">{{item.goods_name}}</view>
  27. <view class="goods_price">¥{{item.goods_price}}</view>
  28. </view>
  29. </view>
  30. <view class="div consult-info">
  31. <view class="consult_content"><text>咨询内容:</text>{{item.consult_content}}</view>
  32. <view class="consult_reply" v-if="item.consult_reply"><text>商家回复:</text>{{item.consult_reply}}</view>
  33. </view>
  34. </view>
  35. </view>
  36. <empty-record v-else-if="consult_list && !consult_list.length"></empty-record>
  37. </scroll-view>
  38. </view>
  39. </view></member-base>
  40. </template>
  41. <script>
  42. import {getFontSize} from '@/util/common'
  43. import TitleHeader from '../../TitleHeader'
  44. import { urlencode } from '@/util/common'
  45. import MemberBase from '../MemberBase'
  46. import EmptyRecord from '../../EmptyRecord'
  47. import { getConsultList } from '../../../api/memberConsult'
  48. export default {
  49. data(){
  50. return {
  51. navHeight: 0,
  52. consult_type: {},
  53. params: { 'page': 0, 'per_page': 10 },
  54. consult_list: false,
  55. loading: false, // 是否加载更多
  56. isMore: true // 是否有更多
  57. }
  58. },
  59. components:{
  60. TitleHeader,
  61. MemberBase,
  62. EmptyRecord
  63. },
  64. computed:{
  65. fontSize(){
  66. return getFontSize()
  67. },
  68. windowWidth: function () {
  69. const res = uni.getSystemInfoSync()
  70. var width=res.windowWidth
  71. var size=getFontSize()
  72. return (width-3*.6*size)/4
  73. }
  74. },
  75. mounted(){
  76. // #ifdef MP-WEIXIN
  77. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  78. // #endif
  79. },
  80. created () {
  81. this.loadMore()
  82. },
  83. watch: {
  84. },
  85. methods:{
  86. goBack(){uni.navigateBack({delta:1})},
  87. loadMore () {
  88. this.loading = true
  89. this.params.page = ++this.params.page
  90. if (this.isMore) {
  91. this.loading = false
  92. this.getConsultList(true)
  93. }
  94. },
  95. goGoods (goods_id) {
  96. uni.navigateTo({ url: '/pages/home/goodsdetail/Goodsdetail'+'?'+urlencode( { 'goods_id': goods_id } )})
  97. },
  98. getConsultList () {
  99. uni.showLoading({ title: '加载中' })
  100. getConsultList(this.params).then(res => {
  101. uni.hideLoading()
  102. if (res.result.hasmore) {
  103. this.isMore = true
  104. } else {
  105. this.isMore = false
  106. }
  107. let temp = res.result.consult_list
  108. if (temp) {
  109. if (!this.consult_list) {
  110. this.consult_list = temp
  111. this.consult_type = res.result.consult_type
  112. } else {
  113. this.consult_list = this.consult_list.concat(temp)
  114. }
  115. }
  116. }).catch(function (error) {
  117. uni.hideLoading()
  118. uni.showToast({icon:'none',title: error.message})
  119. })
  120. }
  121. }
  122. }
  123. </script>
  124. <style scoped lang="scss">
  125. .scroll-view-wrapper{display: flex;flex-direction: column;}
  126. .scroll-view{flex:1}
  127. .consult-item{
  128. background:#fff;
  129. border-bottom:1px solid #e1e1e1;
  130. margin-top: $modelSpace;
  131. border-radius: .5rem;
  132. padding: 0 $pageSpace;
  133. box-sizing: border-box;
  134. .head{
  135. padding: .3rem 0;
  136. display: flex;
  137. align-items: center;
  138. .type{
  139. font-size: .8rem;
  140. color: #333;
  141. }
  142. .time{
  143. font-size: .6rem;
  144. color: #999;
  145. margin-left: auto;
  146. }
  147. }
  148. .goods_info{
  149. display: flex;
  150. box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.06);
  151. .image-wrapper{
  152. border-radius: .5rem;
  153. overflow: hidden;
  154. }
  155. .p-info{
  156. margin-left: .5rem;
  157. .goods_name{
  158. color: #333;
  159. font-size: .7rem;
  160. line-height: .8rem;
  161. height: 1.6rem;
  162. margin-top: .4rem;
  163. overflow: hidden;
  164. display: -webkit-box;
  165. -webkit-box-orient: vertical;
  166. -webkit-line-clamp: 2;
  167. padding: 0 .3rem;
  168. box-sizing: border-box;
  169. }
  170. .goods_price{
  171. color: $primaryColor;
  172. font-size: .8rem;
  173. margin-top: 1rem;
  174. }
  175. }
  176. }
  177. .consult-info{
  178. padding: $modelSpace 0;
  179. .consult_content{
  180. font-size: .7rem;
  181. color: #666;
  182. text{
  183. color: #333;
  184. }
  185. }
  186. .consult_reply{
  187. font-size: .7rem;
  188. color: #666;
  189. text{
  190. color: #333;
  191. }
  192. }
  193. }
  194. }
  195. </style>