index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. const that = this;
  121. that.clearPage();
  122. if (e && e.route && e.type == '0') {
  123. uni.redirectTo({
  124. url: `/${e.route}`
  125. })
  126. } else {
  127. uni.navigateTo({
  128. url: `/${e.route}`
  129. })
  130. }
  131. },
  132. // 清空列表
  133. clearPage() {
  134. const that = this;
  135. that.$set(that, `list`, [])
  136. that.$set(that, `skip`, 0)
  137. that.$set(that, `limit`, 5)
  138. that.$set(that, `page`, 0)
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss">
  144. .main {
  145. .one {
  146. .list {
  147. margin: 2vw 2vw 0 2vw;
  148. padding: 2vw;
  149. border-radius: 5px;
  150. background-color: #f5f5f5;
  151. .list_1 {
  152. display: flex;
  153. flex-direction: row;
  154. margin: 0 0 1vw 0;
  155. .l {
  156. width: 20vw;
  157. .image {
  158. width: 100%;
  159. height: 20vw;
  160. border-radius: 5px;
  161. }
  162. }
  163. .c {
  164. padding: 0 0 0 2vw;
  165. width: 60vw;
  166. .name {
  167. font-size: 16px;
  168. font-weight: bold;
  169. margin: 0 0 1vw 0;
  170. }
  171. .other {
  172. font-size: 14px;
  173. text {
  174. padding: 0 2vw 0 0;
  175. }
  176. }
  177. }
  178. .r {
  179. width: 10vw;
  180. text-align: right;
  181. text {
  182. font-size: 30px;
  183. }
  184. }
  185. }
  186. .list_2 {
  187. display: flex;
  188. flex-direction: row;
  189. flex-wrap: wrap;
  190. .market {
  191. position: relative;
  192. margin: 0 2vw 2vw 0;
  193. width: 29vw;
  194. .image {
  195. width: 100%;
  196. height: 20vw;
  197. }
  198. .money {
  199. position: absolute;
  200. bottom: 0;
  201. font-size: 10px;
  202. width: 100%;
  203. background-color: #0000005f;
  204. color: #fff;
  205. padding: 0.2vw 0;
  206. text-align: center;
  207. font-size: 14px;
  208. }
  209. }
  210. .market:nth-child(3n) {
  211. margin: 0 0 2vw 0;
  212. }
  213. }
  214. }
  215. }
  216. }
  217. .scroll-view {
  218. position: absolute;
  219. top: 0;
  220. left: 0;
  221. right: 0;
  222. bottom: 0;
  223. .list-scroll-view {
  224. display: flex;
  225. flex-direction: column;
  226. }
  227. }
  228. </style>