index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <view>
  3. <nav-logo title="资料"></nav-logo>
  4. <view class="goods-warp">
  5. <view class="search-box fl">
  6. <u-search
  7. bg-color="#ffffff"
  8. placeholder="搜索"
  9. v-model="goodsName"
  10. @custom="comfirmSearch"
  11. @search="comfirmSearch"
  12. ></u-search>
  13. </view>
  14. <view class="goods-list">
  15. <template v-if="goodsList.length">
  16. <!-- hover-class="none" -->
  17. <view
  18. class="list_item"
  19. v-for="(item, index) in goodsList"
  20. :key="index"
  21. @click="tobuy(item)"
  22. >
  23. <view class="list_item_content">
  24. <view class="c_title">{{ item.goodsName }}</view>
  25. <view class="c_downs">
  26. <view class="img">
  27. <image
  28. :src="$method.splitImgHost(item.coverUrl, true)"
  29. ></image>
  30. <view class="time" v-if="item.year">{{
  31. item.year ? item.year : ""
  32. }}</view>
  33. </view>
  34. <view class="text">
  35. <view class="desc">
  36. <view class="left">
  37. <view
  38. class="mon_t"
  39. :class="item.standPrice === 0 ? 'free' : ''"
  40. v-if="
  41. !item.specTemplateId ||
  42. (!item.maxPrice && !item.minPrice)
  43. "
  44. >
  45. {{
  46. item.standPrice === 0
  47. ? "免费"
  48. : `¥${item.standPrice}`
  49. }}
  50. </view>
  51. <!-- 范围价格 -->
  52. <view v-else class="mon_t">
  53. <view>{{ item.minPrice }}</view>
  54. <template v-if="item.minPrice != item.maxPrice">
  55. <text>-</text>
  56. <view>{{ item.maxPrice }}</view>
  57. </template>
  58. </view>
  59. <text v-if="item.linePrice" class="sale"> ¥ </text>
  60. <text v-if="item.linePrice" class="price_line"
  61. >&nbsp;{{ item.linePrice }}</text
  62. >
  63. </view>
  64. <view class="right">
  65. <view v-if="!hideBuyState" class="regiser_row"
  66. >立即购买</view
  67. >
  68. </view>
  69. </view>
  70. <view v-if="item.buyUserNum" class="joins">
  71. <!-- <image class="people" src="/static/index/people.png"></image> -->
  72. <!-- 为0时,不显示 -->
  73. <view class="people">{{ item.buyUserNum }}人参与</view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <template v-else>
  81. <u-empty text="暂无资料" mode="list" margin-top="100"></u-empty>
  82. </template>
  83. </view>
  84. </view>
  85. <!-- tabbar -->
  86. <myTabbar></myTabbar>
  87. </view>
  88. </template>
  89. <script>
  90. import { mapGetters } from "vuex";
  91. export default {
  92. name: "SaasMiniprogramIndex",
  93. data() {
  94. return {
  95. goodsName: "",
  96. goodsList: [],
  97. param: {},
  98. total: 0,
  99. };
  100. },
  101. onLoad(option) {
  102. uni.hideTabBar();
  103. this.init();
  104. },
  105. onPullDownRefresh() {
  106. this.init();
  107. },
  108. onReachBottom() {
  109. if (this.goodsList.length < this.total) {
  110. this.param.pageNum++;
  111. this.getGoodsList();
  112. }
  113. },
  114. methods: {
  115. init(goodsName = "") {
  116. this.param = {
  117. pageNum: 1,
  118. pageSize: 10,
  119. goodsType: 8,
  120. goodsName,
  121. };
  122. this.goodsList = [];
  123. this.getGoodsList();
  124. },
  125. comfirmSearch() {
  126. this.param.goodsName = this.goodsName;
  127. this.init(this.goodsName);
  128. },
  129. getGoodsList() {
  130. this.$api.goodsList(this.param).then((res) => {
  131. this.goodsList.push(...res.data.rows);
  132. this.total = res.data.total;
  133. });
  134. },
  135. tobuy(item) {
  136. uni.navigateTo({
  137. url:
  138. "/pages3/course/detail?id=" +
  139. item.goodsId +
  140. "&goodsType=" +
  141. item.goodsType,
  142. });
  143. },
  144. },
  145. computed: {
  146. ...mapGetters(["userInfo", "hideBuyState"]),
  147. },
  148. };
  149. </script>
  150. <style>
  151. page {
  152. background: #eaeef1;
  153. }
  154. </style>
  155. <style lang="scss" scoped>
  156. .goods-warp {
  157. padding: 16rpx;
  158. position: relative;
  159. .search-box {
  160. height: 106rpx;
  161. width: calc(100% - 32rpx);
  162. position: fixed;
  163. background: #eaeef1;
  164. z-index: 10;
  165. margin-top: -16rpx;
  166. }
  167. }
  168. .goods-list {
  169. margin-top: 46px;
  170. .list_item {
  171. padding: 24rpx;
  172. background: #ffffff;
  173. box-shadow: 0rpx 0rpx 20rpx 1rpx rgba(1, 99, 235, 0.1);
  174. border-radius: 24rpx;
  175. background: #fff;
  176. margin-bottom: 32rpx;
  177. display: flex;
  178. align-items: center;
  179. .list_item_content {
  180. width: 100%;
  181. }
  182. .c_title {
  183. font-size: 32rpx;
  184. font-weight: bold;
  185. margin-bottom: 24rpx;
  186. font-weight: bold;
  187. color: #222222;
  188. }
  189. .c_downs {
  190. display: flex;
  191. }
  192. .img {
  193. position: relative;
  194. margin-right: 24rpx;
  195. border-radius: 16rpx;
  196. overflow: hidden;
  197. width: 204rpx;
  198. height: 120rpx;
  199. image {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. .time {
  204. position: absolute;
  205. bottom: 0;
  206. right: 0;
  207. width: 80rpx;
  208. height: 32rpx;
  209. background: rgba(1, 25, 45, 0.4);
  210. color: #fff;
  211. text-align: center;
  212. line-height: 32rpx;
  213. font-size: 24rpx;
  214. border-radius: 10rpx 0px 10rpx 0px;
  215. }
  216. }
  217. .text {
  218. flex: 1;
  219. position: relative;
  220. display: flex;
  221. flex-direction: column;
  222. justify-content: space-between;
  223. height: 120rpx;
  224. .joins {
  225. .people {
  226. width: 160rpx;
  227. font-size: 20rpx;
  228. color: #999999;
  229. padding: 0rpx 8rpx;
  230. text-align: center;
  231. height: 36rpx;
  232. line-height: 36rpx;
  233. background: #f6f7fb;
  234. border-radius: 4px;
  235. }
  236. }
  237. .desc {
  238. margin-top: 10rpx;
  239. display: flex;
  240. align-items: center;
  241. justify-content: space-between;
  242. width: 100%;
  243. .left {
  244. flex: 1;
  245. color: #333;
  246. font-size: 26rpx;
  247. .mon_t {
  248. display: flex;
  249. font-weight: bold;
  250. color: #fc3f3f;
  251. font-size: 36rpx;
  252. view::before {
  253. content: "¥";
  254. font-size: 24rpx;
  255. font-weight: bold;
  256. }
  257. }
  258. .free {
  259. font-size: 24rpx;
  260. }
  261. .sale {
  262. color: #999999;
  263. font-size: 24rpx;
  264. margin-left: 8rpx;
  265. }
  266. .price_line {
  267. color: #999999;
  268. font-size: 24rpx;
  269. text-decoration: line-through;
  270. font-weight: 400;
  271. }
  272. }
  273. .right {
  274. font-size: 24rpx;
  275. font-weight: bold;
  276. .regiser_row {
  277. width: 144rpx;
  278. height: 52rpx;
  279. line-height: 52rpx;
  280. text-align: center;
  281. border-radius: 16rpx;
  282. background-color: #fc3f3f;
  283. color: #fff;
  284. font-weight: 500;
  285. font-size: 26rpx;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. }
  292. </style>