servantList.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view class="servant-list-page">
  3. <!-- <scroll-view scroll-y="true" style="height:100vh;"> -->
  4. <view class="servant-list" style="height: 100vh">
  5. <view class="servant-item" :data-workerno="item.workerNo" @tap="viewMore" v-for="(item, index) in servantList" :key="index">
  6. <view class="servant-item-left">
  7. <image :src="item.headImage" mode="aspectFill" class="servant-img"></image>
  8. </view>
  9. <view class="servant-item-right">
  10. <view class="servant-top">
  11. <view class="servant-name">{{ item.serverName }}</view>
  12. <view class="more-info">
  13. <text>点击查看更多</text>
  14. <van-icon name="arrow" size="12px" />
  15. </view>
  16. </view>
  17. <view class="servant-main">
  18. <text class="servant-age">{{ item.age }}岁</text>
  19. <text>{{ item.nativePlace }}</text>
  20. </view>
  21. <view class="skill-certificate sub-color">技能证书:{{ item.certificateName }}</view>
  22. <view class="servant-skill sub-color">擅长技能:{{ item.skillNames }}</view>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- </scroll-view> -->
  27. </view>
  28. </template>
  29. <script>
  30. var util = require('../../../utils/util.js');
  31. var api = require('../../../config/api.js');
  32. const app = getApp();
  33. export default {
  34. data() {
  35. return {
  36. scrollHeight: 0,
  37. page: 1,
  38. limit: 10,
  39. totalPages: 1,
  40. addressInfo: {},
  41. servantList: []
  42. };
  43. }
  44. /**
  45. * 生命周期函数--监听页面加载
  46. */,
  47. onLoad: function (options) {
  48. var addressInfo = uni.getStorageSync('addressInfo');
  49. if (addressInfo) {
  50. this.setData({
  51. addressInfo: addressInfo
  52. });
  53. }
  54. this.getServantList();
  55. // wx.getSystemInfo({
  56. // success:res=>{
  57. // this.setData({
  58. // scrollHeight: res.windowHeight
  59. // });
  60. // }
  61. // });
  62. },
  63. /**
  64. * 生命周期函数--监听页面初次渲染完成
  65. */
  66. onReady: function () {},
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow: function () {},
  71. /**
  72. * 生命周期函数--监听页面隐藏
  73. */
  74. onHide: function () {},
  75. /**
  76. * 生命周期函数--监听页面卸载
  77. */
  78. onUnload: function () {},
  79. /**
  80. * 页面相关事件处理函数--监听用户下拉动作
  81. */
  82. onPullDownRefresh: function () {},
  83. /**
  84. * 页面上拉触底事件的处理函数
  85. */
  86. onReachBottom: function () {
  87. if (this.totalPages > this.page) {
  88. this.setData({
  89. page: this.page + 1
  90. });
  91. this.getServantList();
  92. } else {
  93. uni.showToast({
  94. title: '没有更多了',
  95. icon: 'none',
  96. duration: 2000
  97. });
  98. return false;
  99. }
  100. },
  101. /**
  102. * 用户点击右上角分享
  103. */
  104. onShareAppMessage: function () {},
  105. methods: {
  106. viewMore(e) {
  107. console.log(e);
  108. let workerNo = e.currentTarget.dataset.workerno;
  109. uni.navigateTo({
  110. url: '/pages/servant/servantDetail/servantDetail?workerNo=' + workerNo
  111. });
  112. },
  113. getServantList: function () {
  114. // this.setData({
  115. // servantList:this.data.servantList.concat(this.data.servantList),});
  116. util.request(api.getServantList, {
  117. page: this.page,
  118. limit: this.limit,
  119. shopId: this.addressInfo.shopId
  120. }).then((res) => {
  121. console.info(res);
  122. if (this.page == 1) {
  123. this.setData({
  124. servantList: res.data.dataList,
  125. totalPages: res.data.pages
  126. });
  127. } else {
  128. this.setData({
  129. servantList: this.servantList.concat(res.data.dataList),
  130. totalPages: res.data.pages
  131. });
  132. }
  133. });
  134. }
  135. }
  136. };
  137. </script>
  138. <style>
  139. .servant-list-page {
  140. padding: 16rpx 28rpx 0;
  141. }
  142. .servant-item {
  143. background: #fff;
  144. border-radius: 10rpx;
  145. display: flex;
  146. height: 256rpx;
  147. margin: 0 0 16rpx;
  148. }
  149. .servant-item-left {
  150. padding: 12rpx 30rpx 12rpx 14rpx;
  151. }
  152. .servant-img {
  153. width: 152rpx;
  154. height: 202rpx;
  155. border-radius: 10rpx;
  156. background: #cdefff;
  157. }
  158. .servant-item-right {
  159. padding: 0 0 16rpx;
  160. flex: 1;
  161. }
  162. .servant-top {
  163. display: flex;
  164. justify-content: space-between;
  165. height: 52rpx;
  166. }
  167. .servant-name {
  168. padding: 16rpx 0 0;
  169. font-size: 30rpx;
  170. font-weight: bold;
  171. }
  172. .more-info {
  173. width: 200rpx;
  174. height: 40rpx;
  175. background: #09afff;
  176. border-radius: 0 10rpx 0 10rpx;
  177. color: #fff;
  178. font-size: 24rpx;
  179. line-height: 24rpx;
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. }
  184. .servant-main {
  185. margin: 14rpx 0 42rpx 0;
  186. height: 28rpx;
  187. line-height: 26rpx;
  188. font-size: 24rpx;
  189. display: flex;
  190. align-items: center;
  191. }
  192. .servant-age {
  193. padding: 0 24rpx 0 0;
  194. margin: 0 24rpx 0 0;
  195. border-right: 2rpx solid #2a2a2a;
  196. }
  197. .skill-certificate {
  198. text-overflow: -o-ellipsis-lastline;
  199. overflow: hidden;
  200. text-overflow: ellipsis;
  201. display: -webkit-box;
  202. -webkit-line-clamp: 2;
  203. line-clamp: 2;
  204. -webkit-box-orient: vertical;
  205. font-size: 20rpx;
  206. width: 480rpx;
  207. line-height: 30rpx;
  208. height: 60rpx;
  209. }
  210. .servant-skill {
  211. white-space: nowrap;
  212. text-overflow: ellipsis;
  213. overflow: hidden;
  214. word-break: break-all;
  215. width: 480rpx;
  216. font-size: 20rpx;
  217. line-height: 30rpx;
  218. }
  219. </style>