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