index.vue 7.5 KB

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