耀实惠小程序
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.

216 lines
4.8 KiB

  1. <template>
  2. <view class="pages">
  3. <u-sticky>
  4. <view>
  5. <view class="search"><u-search v-model="keyword" placeholder="请输入要搜索的商品" height="70" :show-action="false" @search="search" /></view>
  6. <!-- 分区 -->
  7. <u-tabs :list="nav_list" :is-scroll="true" :current="status" @change="getGoodsListInfo" bar-width="80" active-color="#01AEEA" font-size="34"></u-tabs>
  8. </view>
  9. </u-sticky>
  10. <view class="top_bg_text" :style="'background-image: url('+pageImage+')'">
  11. <!-- <text class="title_max">{{title}}</text>
  12. <text class="title_min">{{title_alt}}</text> -->
  13. </view>
  14. <view class="over_y">
  15. <view class="item_goods" v-for="(item,index) in list" :key="index">
  16. <!-- 结束遮罩层 -->
  17. <view class="end_goods" v-if="item.num >= item.sum || item.isEND">
  18. <text>已结束</text>
  19. </view>
  20. <goods-item :goods="item" thereTo='PreferentialSpellGroup'></goods-item>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import config from "@/utils/js/config.js"
  27. export default {
  28. data() {
  29. return {
  30. status: '0',
  31. butClass:'1',
  32. nav_list: [
  33. {
  34. name: "全部"
  35. },
  36. ],
  37. payNum:0, // 0 非处方 1处方
  38. http_img: config.img_url,
  39. pageImage: "",
  40. title: "特惠拼团专区",
  41. title_alt: "拼团购买更实惠!",
  42. list: [],
  43. pageNo: 1,
  44. pageSize: 10,
  45. total: null,
  46. isLock: true,
  47. id: '',
  48. keyword: ''
  49. }
  50. },
  51. onPullDownRefresh() {
  52. this.pageNo= 1;
  53. this.total = null;
  54. this.list = [];
  55. this.getGoodsList();
  56. },
  57. onReachBottom() {
  58. if(this.isLock) {
  59. if(this.total !== null && this.pageNo * this.pageSize >= this.total){
  60. this.isLock = false;
  61. this.$Toast('没有更多数据了哦!');
  62. setTimeout(()=>{
  63. this.isLock = true;
  64. },3000)
  65. return
  66. }
  67. this.pageNo+=1;
  68. this.getGoodsList();
  69. }
  70. },
  71. onLoad(options) {
  72. this.id = options.id;
  73. this.pageImage = options.pageImage
  74. this.getGoodsList();
  75. this.getButClass();
  76. },
  77. methods: {
  78. getButClass(){
  79. this.$api('getButClassList', {}).then(res => {
  80. this.nav_list = this.nav_list.concat(res.result)
  81. }).catch(err => {
  82. this.$Toast(err.message)
  83. })
  84. },
  85. search () {
  86. this.pageNo = 1
  87. this.getGoodsList()
  88. },
  89. getGoodsListInfo(e){
  90. this.status = e;
  91. this.list = [];
  92. this.butClass = this.nav_list[e].id;
  93. this.pageNo = 1;
  94. this.total = null;
  95. this.isLock = true;
  96. this.payNum = e;
  97. this.getGoodsList()
  98. console.log("获取新数据",e)
  99. },
  100. getGoodsList() {
  101. uni.showLoading();
  102. const params = {
  103. pageNo: this.pageNo,
  104. pageSize: this.pageSize,
  105. bottonId:this.id,
  106. title: this.keyword,
  107. payNum:this.payNum,
  108. butClass:this.butClass
  109. }
  110. this.$api('getGoodsList',params).then(res => {
  111. let { code, result, message} = res;
  112. uni.hideLoading();
  113. if(code == 200){
  114. if(this.total == null) {
  115. this.total = result.total;
  116. }
  117. result.records.forEach(item => {
  118. // const picArray= item.pic.split(',')
  119. // item.pic= picArray[0]
  120. if(item.pic!==null){
  121. const picArray=item.pic.split(',')
  122. item.pic= picArray[0]
  123. }else{
  124. item.pic= []
  125. }
  126. // 判断是否结束
  127. const endTime = new Date(item.endTime);
  128. const newTime = new Date();
  129. item.isEND = newTime > endTime ? true: false;
  130. })
  131. // this.list = this.list.concat(result.records);
  132. this.list = !this.keyword ? this.list.concat(result.records) : result.records
  133. }else{
  134. this.$Toast(message);
  135. }
  136. }).catch( err => {
  137. uni.hideLoading();
  138. this.$Toast(err.message);
  139. })
  140. },
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .search {
  146. // position: fixed;
  147. width: 100%;
  148. top: 0;
  149. left: 0;
  150. padding: 28rpx;
  151. background: #fff;
  152. z-index: 1;
  153. }
  154. .top_bg_text{
  155. width: 100%;
  156. height: 184rpx;
  157. margin-top: 30rpx;
  158. background-size: 100% 184rpx;
  159. display: flex;
  160. flex-direction: column;
  161. align-items: center;
  162. .title_max{
  163. margin-top: 20rpx;
  164. font-size: 54rpx;
  165. font-weight: bold;
  166. color: #73B8DE;
  167. }
  168. .title_min{
  169. margin-top: 10rpx;
  170. font-size: 28rpx;
  171. color: #73B8DE;
  172. }
  173. }
  174. .pages{
  175. background-color: #F5F5F5;
  176. // padding-top: 120rpx;
  177. height: 100%;
  178. .top_img{
  179. margin-top: 30rpx;
  180. margin-bottom: 50rpx;
  181. height: 184rpx;
  182. }
  183. }
  184. .over_y {
  185. overflow-y: auto;
  186. }
  187. .item_goods {
  188. margin: 0 auto;
  189. width: 713rpx;
  190. margin-top: 38rpx;
  191. margin-bottom: 30rpx;
  192. background-color: #FFF;
  193. border-radius: 34rpx;
  194. box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.16);
  195. position: relative;
  196. .end_goods{
  197. width: 100%;
  198. height: 100%;
  199. background-color: rgba(0, 0, 0, .5);
  200. position: absolute;
  201. top: 0;
  202. left: 0;
  203. z-index: 100;
  204. border-radius: 34rpx;
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. font-size: 66rpx;
  209. color: #fff;
  210. }
  211. }
  212. </style>