index.vue 7.2 KB

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