index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <mobile-frame :frameStyle="frameStyle" @toPath="toPath">
  3. <view class="main">
  4. <view class="one">
  5. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  6. <view class="list-scroll-view">
  7. <view class="list" v-for="(item,index) in list" :key="index" @tap="toShop(item)">
  8. <view class="list_1">
  9. <view class="l">
  10. <image class="image" :src="item.logo&&item.logo.length>0?item.logo[0].url:''" mode=""></image>
  11. </view>
  12. <view class="c">
  13. <view class="name">
  14. {{item.name}}
  15. </view>
  16. <view class="other">
  17. <text>宝贝数<text>{{item.market_num}}</text></text>
  18. <text>关注数<text>{{item.follow_num}}</text></text>
  19. </view>
  20. </view>
  21. <view class="r" @tap="toFolllow(item)">
  22. <text class="iconfont icon-yduishoucangshixin-copy" v-if="item.is_follow==true"></text>
  23. <text class="iconfont icon-yduishoucangkongxin-copy" v-else></text>
  24. </view>
  25. </view>
  26. <view class="list_2">
  27. <view class="market" v-for="(tag,indexs) in item.market" :key="indexs" @tap="toBuy(tag)">
  28. <image class="image" :src="tag.file&&tag.file.length>0?tag.file[0].url:''" mode=""></image>
  29. <view class="money">
  30. ¥{{tag.sell_money}}
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </scroll-view>
  37. </view>
  38. </view>
  39. </mobile-frame>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. frameStyle: {
  46. useBar: true
  47. },
  48. list: [],
  49. total: 0,
  50. page: 0,
  51. skip: 0,
  52. limit: 5,
  53. };
  54. },
  55. onShow: function() {
  56. const that = this;
  57. that.search()
  58. },
  59. methods: {
  60. async search() {
  61. const that = this;
  62. let info = {
  63. skip: that.skip,
  64. limit: that.limit
  65. }
  66. const res = await that.$api(`/viewShop/microIndex`, `GET`, {
  67. ...info,
  68. })
  69. if (res.errcode == '0') {
  70. let list = [...that.list, ...res.data];
  71. that.$set(that, `list`, list)
  72. that.$set(that, `total`, res.total)
  73. } else {
  74. uni.showToast({
  75. title: res.errmsg,
  76. });
  77. }
  78. },
  79. // 分页
  80. toPage() {
  81. const that = this;
  82. let list = that.list;
  83. let limit = that.limit;
  84. if (that.total > list.length) {
  85. uni.showLoading({
  86. title: '加载中',
  87. mask: true
  88. })
  89. let page = that.page + 1;
  90. that.$set(that, `page`, page)
  91. let skip = page * limit;
  92. that.$set(that, `skip`, skip)
  93. that.search();
  94. uni.hideLoading();
  95. } else uni.showToast({
  96. title: '没有更多数据了'
  97. });
  98. },
  99. // 商铺
  100. toShop(e) {
  101. const that = this;
  102. that.clearPage();
  103. uni.navigateTo({
  104. url: `/pagesHome/shop/index?id=${e._id}`
  105. })
  106. },
  107. // 购买
  108. toBuy(e) {
  109. const that = this;
  110. that.clearPage();
  111. uni.navigateTo({
  112. url: `/pagesHome/order/detail?id=${e._id}`
  113. })
  114. },
  115. // 关注
  116. toFolllow(e) {
  117. console.log(e);
  118. },
  119. toPath(e) {
  120. if (e && e.route && e.type == '0') {
  121. uni.redirectTo({
  122. url: `/${e.route}`
  123. })
  124. } else {
  125. uni.navigateTo({
  126. url: `/${e.route}`
  127. })
  128. }
  129. },
  130. // 清空列表
  131. clearPage() {
  132. const that = this;
  133. that.$set(that, `list`, [])
  134. that.$set(that, `skip`, 0)
  135. that.$set(that, `limit`, 5)
  136. that.$set(that, `page`, 0)
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss">
  142. .main {
  143. .one {
  144. .list {
  145. margin: 2vw 2vw 0 2vw;
  146. padding: 2vw;
  147. border-radius: 5px;
  148. background-color: #f5f5f5;
  149. .list_1 {
  150. display: flex;
  151. flex-direction: row;
  152. margin: 0 0 1vw 0;
  153. .l {
  154. width: 20vw;
  155. .image {
  156. width: 100%;
  157. height: 20vw;
  158. border-radius: 5px;
  159. }
  160. }
  161. .c {
  162. padding: 0 0 0 2vw;
  163. width: 60vw;
  164. .name {
  165. font-size: 16px;
  166. font-weight: bold;
  167. margin: 0 0 1vw 0;
  168. }
  169. .other {
  170. font-size: 14px;
  171. text {
  172. padding: 0 2vw 0 0;
  173. }
  174. }
  175. }
  176. .r {
  177. width: 10vw;
  178. text-align: right;
  179. text {
  180. font-size: 30px;
  181. }
  182. }
  183. }
  184. .list_2 {
  185. display: flex;
  186. flex-direction: row;
  187. flex-wrap: wrap;
  188. .market {
  189. position: relative;
  190. margin: 0 2vw 2vw 0;
  191. width: 29vw;
  192. .image {
  193. width: 100%;
  194. height: 20vw;
  195. }
  196. .money {
  197. position: absolute;
  198. bottom: 0;
  199. font-size: 10px;
  200. width: 100%;
  201. background-color: #0000005f;
  202. color: #fff;
  203. padding: 0.2vw 0;
  204. text-align: center;
  205. font-size: 14px;
  206. }
  207. }
  208. .market:nth-child(3n) {
  209. margin: 0 0 2vw 0;
  210. }
  211. }
  212. }
  213. }
  214. }
  215. .scroll-view {
  216. position: absolute;
  217. top: 0;
  218. left: 0;
  219. right: 0;
  220. bottom: 0;
  221. .list-scroll-view {
  222. display: flex;
  223. flex-direction: column;
  224. }
  225. }
  226. </style>