瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

284 lines
6.5 KiB

11 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
7 months ago
11 months ago
10 months ago
11 months ago
7 months ago
11 months ago
11 months ago
11 months ago
7 months ago
11 months ago
10 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
10 months ago
11 months ago
10 months ago
11 months ago
11 months ago
  1. <template>
  2. <view class="page">
  3. <navbar title="商城"/>
  4. <!-- <view>
  5. <uv-swiper
  6. :list="bannerList"
  7. indicator
  8. height="320rpx"
  9. keyName="image"></uv-swiper>
  10. </view> -->
  11. <view class="swipe">
  12. <uv-swiper
  13. :list="bannerList"
  14. indicator
  15. height="320rpx"
  16. keyName="image"></uv-swiper>
  17. </view>
  18. <!-- 公告 -->
  19. <view class="notice">
  20. <uv-notice-bar
  21. fontSize="28rpx"
  22. @click="$utils.navigateTo('/pages_order/notice/noticeDetail')"
  23. :text="headInfo.notice.keyName"></uv-notice-bar>
  24. </view>
  25. <!-- 分类 -->
  26. <view class="city-tabs-container">
  27. <uv-tabs
  28. :list="productCategory"
  29. :current="currentCityTabIndex"
  30. :activeStyle="{color: '#5baaff', fontWeight: 600}"
  31. lineColor="#5baaff"
  32. lineHeight="6rpx"
  33. lineWidth="40rpx"
  34. keyName="title"
  35. @click="tabsClick"
  36. />
  37. </view>
  38. <view class="productList">
  39. <productList :productList="list"/>
  40. </view>
  41. <!-- <view class="waterfall">
  42. <uv-waterfall ref="waterfall" v-model="list"
  43. :add-time="10"
  44. :left-gap="leftGap"
  45. :right-gap="rightGap"
  46. :column-gap="columnGap"
  47. @changeList="changeList">
  48. <template v-slot:list1>
  49. <view>
  50. <view v-for="(item, index) in list1" :key="item.id" class="waterfall-item"
  51. @click="$utils.navigateTo('/pages_order/product/productDetail?id=' + item.id)">
  52. <view class="waterfall-item__image" :style="[imageStyle(item)]">
  53. <image :src="item.image" mode="widthFix" :style="{width:item.width+'px'}"></image>
  54. </view>
  55. <view class="waterfall-item__ft">
  56. <view class="waterfall-item__ft__title">
  57. <text class="title">{{item.name}}</text>
  58. </view>
  59. <view class="waterfall-item__ft__desc uv-line-2">
  60. <text class="price">现价{{item.price}}</text>
  61. <text class="oldPrice">原价{{item.oldPrice}}</text>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <template v-slot:list2>
  68. <view>
  69. <view v-for="(item, index) in list2" :key="item.id" class="waterfall-item"
  70. @click="$utils.navigateTo('/pages_order/product/productDetail?id=' + item.id)">
  71. <view class="waterfall-item__image" :style="[imageStyle(item)]">
  72. <image :src="item.image" mode="widthFix" :style="{width:item.width+'px'}"></image>
  73. </view>
  74. <view class="waterfall-item__ft">
  75. <view class="waterfall-item__ft__title">
  76. <text class="title">{{item.name}}</text>
  77. </view>
  78. <view class="waterfall-item__ft__desc uv-line-2">
  79. <text class="price">现价{{item.price}}</text>
  80. <text class="oldPrice">原价{{item.oldPrice}}</text>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </template>
  86. </uv-waterfall>
  87. </view> -->
  88. </view>
  89. </template>
  90. <script>
  91. import mixinsList from '@/mixins/list.js'
  92. import mixinsProduct from '@/mixins/product.js'
  93. import tabber from '@/components/base/tabbar.vue'
  94. import productList from '@/components/user/productList.vue'
  95. import { mapState } from 'vuex'
  96. export default {
  97. mixins: [mixinsList, mixinsProduct],
  98. components : {
  99. tabber,
  100. productList,
  101. },
  102. computed: {
  103. ...mapState(['city', 'userInfo', 'headInfo', 'cityList']),
  104. // 城市分类列表(包含"全部"选项)
  105. productCategory() {
  106. const allTab = { id: null, title: '全部', value: null }
  107. const cityTabs = this.cityList.map(city => ({
  108. id: city.id || city.cityId,
  109. title: city.name || city.cityName || city.title,
  110. value: city.id || city.cityId
  111. }))
  112. return [allTab, ...cityTabs]
  113. }
  114. // imageStyle(item) {
  115. // return item => {
  116. // const v = uni.upx2px(750) - this.leftGap - this.rightGap - this.columnGap;
  117. // const w = v / 2;
  118. // const rate = w / item.w;
  119. // const h = rate * item.h;
  120. // return {
  121. // width: w + 'px',
  122. // height: h + 'px'
  123. // }
  124. // }
  125. // }
  126. },
  127. data() {
  128. return {
  129. mixinsListApi: 'getShopPingPage',
  130. currentCityTabIndex: 0, // uv-tabs当前选中的城市索引
  131. // list1: [], // 瀑布流第一列数据
  132. // list2: [], // 瀑布流第二列数据
  133. // leftGap: 10,
  134. // rightGap: 10,
  135. // columnGap: 10,
  136. bannerList : [],
  137. // category : [
  138. // {
  139. // name : '户外',
  140. // value : 0,
  141. // },
  142. // {
  143. // name : '美食',
  144. // value : 1,
  145. // },
  146. // {
  147. // name : '兑换',
  148. // value : 2,
  149. // },
  150. // {
  151. // name : '特产',
  152. // value : 3,
  153. // },
  154. // {
  155. // name : '校园',
  156. // value : 4,
  157. // },
  158. // ],
  159. }
  160. },
  161. onShow() {
  162. this.getBannerList()
  163. },
  164. onLoad() {
  165. // 获取城市列表
  166. this.$store.commit('getCityList')
  167. // 初始化查询参数
  168. this.queryParams.cityId = null
  169. },
  170. methods: {
  171. // 这点非常重要:e.name在这里返回是list1或list2,要手动将数据追加到相应列
  172. // changeList(e) {
  173. // this[e.name].push(e.value);
  174. // },
  175. // 获取banner
  176. getBannerList(){
  177. this.$api('getBannerList', res => {
  178. if(res.code == 200){
  179. this.bannerList = res.result
  180. }
  181. })
  182. },
  183. tabsClick(item) {
  184. this.currentCityTabIndex = item.index
  185. if (item.value) {
  186. // 使用城市ID作为筛选条件
  187. this.queryParams.cityId = item.value
  188. delete this.queryParams.className // 清除原有的分类参数
  189. } else {
  190. // 选择"全部"时清除城市筛选
  191. delete this.queryParams.cityId
  192. delete this.queryParams.className
  193. }
  194. this.refreshList()
  195. },
  196. }
  197. }
  198. </script>
  199. <style scoped lang="scss">
  200. .page{
  201. .swipe{
  202. overflow: hidden;
  203. border-radius: 20rpx;
  204. margin: 20rpx;
  205. }
  206. .notice{
  207. padding: 20rpx;
  208. }
  209. .productList{
  210. padding: 0 20rpx;
  211. }
  212. // 城市分类容器样式
  213. .city-tabs-container {
  214. background-color: #fff;
  215. border-bottom: 1rpx solid #eee;
  216. padding: 0 20rpx;
  217. }
  218. }
  219. // $show-lines: 1;
  220. // @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss';
  221. // .waterfall-item {
  222. // overflow: hidden;
  223. // margin-top: 10px;
  224. // border-radius: 6px;
  225. // }
  226. // .waterfall-item__ft {
  227. // padding: 20rpx;
  228. // background: #fff;
  229. // &__title {
  230. // margin-bottom: 10rpx;
  231. // line-height: 48rpx;
  232. // font-weight: 700;
  233. // .value {
  234. // font-size: 32rpx;
  235. // color: #303133;
  236. // }
  237. // }
  238. // &__desc .value {
  239. // font-size: 28rpx;
  240. // color: #606266;
  241. // }
  242. // &__btn {
  243. // padding: 10px 0;
  244. // }
  245. // }
  246. // .waterfall-item__ft__title{
  247. // font-size: 28rpx;
  248. // }
  249. // .price{
  250. // color: #f40;
  251. // }
  252. // .oldPrice{
  253. // color: #777;
  254. // font-size: 22rpx;
  255. // text-decoration: underline;
  256. // }
  257. </style>