index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  6. <view class="list-scroll-view">
  7. <view class="one_1">
  8. <image class="image" :src="topUrl" mode="aspectFit"></image>
  9. </view>
  10. <view class="one_2">
  11. <view class="list" v-for="(item,index) in list" :key="index" @tap="toBuy(item)">
  12. <view class="list_1">
  13. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
  14. mode=""></image>
  15. </view>
  16. <view class="name textOver">
  17. {{item.name}}
  18. </view>
  19. <view class="other">
  20. <view class="money">
  21. <view class="money_1">
  22. <text>¥</text><text>{{item.sell_money||0}}</text>
  23. </view>
  24. <view class="money_2">
  25. <text>¥</text><text>{{item.flow_money||0}}</text>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="other">
  30. <text class="act" v-for="(tag,index) in item.p_act" :key="index">{{tag}}</text>
  31. </view>
  32. <view class="acttags">
  33. <text v-for="i in item.actTagsShow" :key="i">{{i.label}}</text>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="is_bottom" v-if="is_bottom">
  38. <text>{{config.bottom_title}}</text>
  39. </view>
  40. </view>
  41. </scroll-view>
  42. </view>
  43. </view>
  44. </mobile-frame>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. // 系统设置
  51. config: {},
  52. // 路由参数
  53. type: '1',
  54. tags: '',
  55. act_tags: '',
  56. topUrl: '',
  57. list: [],
  58. total: 0,
  59. page: 0,
  60. skip: 0,
  61. limit: 10,
  62. // 数据是否触底
  63. is_bottom: false,
  64. scrollTop: 0,
  65. };
  66. },
  67. onLoad(e) {
  68. const that = this;
  69. if (e && e.tags) {
  70. that.$set(that, `type`, '1')
  71. that.$set(that, `tags`, e.tags || '');
  72. } else if (e && e.act_tags) {
  73. that.$set(that, `type`, '2')
  74. that.$set(that, `act_tags`, e.act_tags || '');
  75. }
  76. that.searchConfig();
  77. that.searchOther();
  78. that.search();
  79. },
  80. onPullDownRefresh: async function() {
  81. const that = this;
  82. that.clearPage()
  83. await that.search();
  84. uni.stopPullDownRefresh();
  85. },
  86. methods: {
  87. // 查询基本设置
  88. searchConfig() {
  89. const that = this;
  90. uni.getStorage({
  91. key: 'config',
  92. success: function(res) {
  93. if (res.data) that.$set(that, `config`, res.data)
  94. }
  95. })
  96. },
  97. async search() {
  98. const that = this;
  99. let info = {
  100. skip: that.skip,
  101. limit: that.limit
  102. };
  103. if (that.type == '1') info.tags = that.tags;
  104. else if (that.type == '2') info.act_tags = that.act_tags;
  105. let res = await that.$api(`/viewGoods/indexGoodsList`, 'GET', {
  106. ...info,
  107. status: '1'
  108. });
  109. if (res.errcode == '0') {
  110. let list = [...that.list, ...res.data];
  111. that.$set(that, `list`, list)
  112. that.$set(that, `total`, res.total)
  113. }
  114. },
  115. toPage() {
  116. const that = this;
  117. let list = that.list;
  118. let limit = that.limit;
  119. if (that.total > list.length) {
  120. uni.showLoading({
  121. title: '加载中',
  122. mask: true
  123. })
  124. let page = that.page + 1;
  125. that.$set(that, `page`, page)
  126. let skip = page * limit;
  127. that.$set(that, `skip`, skip)
  128. that.search();
  129. uni.hideLoading();
  130. } else that.$set(that, `is_bottom`, true)
  131. },
  132. toScroll(e) {
  133. const that = this;
  134. let up = that.scrollTop;
  135. that.$set(that, `scrollTop`, e.detail.scrollTop);
  136. let num = Math.sign(up - e.detail.scrollTop);
  137. if (num == 1) that.$set(that, `is_bottom`, false);
  138. },
  139. // 查询其他信息
  140. async searchOther() {
  141. const that = this;
  142. let type = that.type;
  143. let act_tags = that.act_tags;
  144. let tags = that.tags;
  145. let topUrl = [];
  146. let res;
  147. if (type == '1') {
  148. res = await that.$api(`/goodsTags/getData`, 'GET', {
  149. code: tags
  150. })
  151. } else if (type == '2') {
  152. res = await that.$api(`/actTags/getData`, 'GET', {
  153. value: act_tags
  154. })
  155. }
  156. if (res.errcode == '0') {
  157. let data = res.data;
  158. uni.setNavigationBarTitle({
  159. title: data.label
  160. });
  161. if (that.type == '1' && data.tags_file.length > 0) topUrl = data.tags_file
  162. else if (that.type == '2' && data.file.length > 0) topUrl = data.file
  163. }
  164. if (topUrl.length > 0) {
  165. that.$set(that, `topUrl`, topUrl[0].url)
  166. } else {
  167. that.$set(that, `topUrl`, that.config.config.logo[0].url)
  168. }
  169. },
  170. // 购买
  171. toBuy(e) {
  172. const that = this;
  173. uni.navigateTo({
  174. url: `/pagesHome/order/detail?id=${e._id}`
  175. })
  176. },
  177. // 清空列表
  178. clearPage() {
  179. const that = this;
  180. that.$set(that, `list`, [])
  181. that.$set(that, `skip`, 0)
  182. that.$set(that, `limit`, 6)
  183. that.$set(that, `page`, 0)
  184. }
  185. },
  186. }
  187. </script>
  188. <style lang="scss">
  189. .main {
  190. display: flex;
  191. flex-direction: column;
  192. width: 100vw;
  193. height: 100vh;
  194. .one {
  195. .one_1 {
  196. padding: 2vw;
  197. background-color: #ffffff;
  198. .image {
  199. width: 100%;
  200. height: 200px;
  201. box-shadow: 0 0 5px #f1f1f1;
  202. border-radius: 10px;
  203. }
  204. }
  205. .one_2 {
  206. display: flex;
  207. justify-content: space-between;
  208. flex-wrap: wrap;
  209. padding: 0 2vw;
  210. .list {
  211. position: relative;
  212. width: 43vw;
  213. margin: 0 0 2vw 0;
  214. box-shadow: 0 0 5px #f1f1f1;
  215. padding: 2vw;
  216. border-radius: 5px;
  217. .list_1 {
  218. margin: 0 0 1vw 0;
  219. .image {
  220. width: 100%;
  221. height: 30vh;
  222. border-radius: 10px;
  223. box-shadow: 0 0 5px #f1f1f1;
  224. }
  225. }
  226. .name {
  227. font-size: 16px;
  228. }
  229. .other {
  230. display: flex;
  231. flex-direction: row;
  232. justify-content: space-between;
  233. padding: 1vw 0 0 0;
  234. .money {
  235. display: flex;
  236. .money_1 {
  237. color: var(--fFB1Color);
  238. font-size: 12px;
  239. text:last-child {
  240. font-size: 16px;
  241. padding: 0 0 0 1vw;
  242. }
  243. }
  244. .money_2 {
  245. font-size: 12px;
  246. margin: 0 0 0 2vw;
  247. color: var(--f99Color);
  248. text {
  249. text-decoration: line-through;
  250. }
  251. text:last-child {
  252. font-size: 16px;
  253. padding: 0 0 0 1vw;
  254. }
  255. }
  256. }
  257. .act {
  258. font-size: 12px;
  259. color: #FFA500;
  260. border: 1px solid #FFA500;
  261. border-radius: 5px;
  262. padding: 0 1vw;
  263. }
  264. }
  265. .acttags {
  266. position: absolute;
  267. top: 2vw;
  268. width: 93%;
  269. text {
  270. display: inline-block;
  271. background-color: #ff0000;
  272. color: #fff;
  273. border-radius: 1vw;
  274. padding: 0.5vw;
  275. font-size: 12px;
  276. margin: 0 1vw 0 0;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. }
  283. .scroll-view {
  284. position: absolute;
  285. top: 0;
  286. left: 0;
  287. right: 0;
  288. bottom: 0;
  289. .list-scroll-view {
  290. display: flex;
  291. flex-direction: column;
  292. }
  293. }
  294. .is_bottom {
  295. text-align: center;
  296. text {
  297. padding: 2vw 0;
  298. display: inline-block;
  299. color: #858585;
  300. font-size: 14px;
  301. }
  302. }
  303. </style>