index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="userMeal">
  3. <view class="header">
  4. <view style="display: flex;justify-content: center;width: 50%;">
  5. <view :class="barType == 1?'bar-select':'bar'" @click="barType=1">
  6. 生效中
  7. <image v-if="barType==1" :src="require('../../static/sel.png')" alt="">
  8. </view>
  9. <span v-if="barNum>0 && barType==1">{{barNum}}</span>
  10. </view>
  11. <view style="display: flex;justify-content: center;width: 50%;border-left: 1px solid #E6E6E6;">
  12. <view :class="barType == 2?'bar-select':'bar'" @click="barType=2">
  13. 已失效
  14. <image v-if="barType==2" :src="require('../../static/sel.png')" alt="">
  15. </view>
  16. <span v-if="barNum>0 && barType==2">{{barNum}}</span>
  17. </view>
  18. </view>
  19. <view class="body" v-for="(item, index) in setMealList" :key="index" @click="toPath(item.id)">
  20. <image :src="baseImagePath + item.imgUrl" mode=""></image>
  21. <view class="cont">
  22. <view class="title">
  23. {{item.packageName}}
  24. </view>
  25. <view class="content">
  26. <view class="times">
  27. {{item.createTime}}
  28. </view>
  29. <view class="services" v-if="item.status === 1">
  30. {{item.num}}/{{item.allNum}}<span>个项目可用</span>
  31. </view>
  32. <image v-else :src="require('../../static/shixiao.png')" mode=""></image>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import {
  40. userPackageList
  41. } from "@/api/myApi.js"
  42. const app = getApp()
  43. export default {
  44. components: {},
  45. data: function() {
  46. return {
  47. barType: 1,
  48. barNum: 0,
  49. pageNo:1,
  50. pageSize:10,
  51. setMealList: [],
  52. baseImagePath: this.baseImagePath,
  53. }
  54. },
  55. onLoad(e) {
  56. app.globalData.requestToken = e.token;
  57. uni.setStorageSync('token',e.token)
  58. this.getList()
  59. },
  60. watch:{
  61. barType(){
  62. this.setMealList = []
  63. this.pageNo = 1
  64. this.getList()
  65. }
  66. },
  67. onReachBottom() {
  68. this.pageNo += 1
  69. this.getList()
  70. },
  71. onBackPress(options) {
  72. // 这里可以自定义返回逻辑,比如下面跳转其他页面
  73. // #ifdef APP-PLUS
  74. if (plus.os.name.toLowerCase() === 'android') {
  75. plus.runtime.quit();
  76. } else {
  77. plus.runtime.quit();
  78. }
  79. // #endif
  80. // return true 表示禁止默认返回
  81. return true;
  82. },
  83. methods: {
  84. toPath(item){
  85. console.log(item);
  86. this.$yrouter.push({
  87. path: "/pages/userMeal/userMealDetail/index?id="+item + "&type=my"
  88. });
  89. },
  90. getList(){
  91. let data = {
  92. pageNo:this.pageNo,
  93. pageSize:this.pageSize,
  94. status:this.barType
  95. }
  96. userPackageList(data).then(res=>{
  97. console.log(res);
  98. this.setMealList = [...this.setMealList,...res.data.rows]
  99. this.barNum = this.setMealList.length
  100. })
  101. }
  102. },
  103. }
  104. </script>
  105. <style lang="less">
  106. page {
  107. background: #F5F5F5;
  108. }
  109. .body {
  110. height: 178rpx;
  111. background: #FFFFFF;
  112. border-radius: 5rpx;
  113. margin: 10rpx;
  114. display: flex;
  115. padding: 29rpx 23rpx 0 25rpx;
  116. image {
  117. width: 120rpx;
  118. height: 120rpx;
  119. }
  120. .cont {
  121. width: 76%;
  122. padding: 16rpx 0 16rpx 30rpx;
  123. .title {
  124. font-size: 32rpx;
  125. font-family: PingFang SC;
  126. font-weight: bold;
  127. color: #333333;
  128. line-height: 31rpx;
  129. }
  130. .content {
  131. display: flex;
  132. justify-content: space-between;
  133. align-items: center;
  134. margin-top: 33rpx;
  135. .times {
  136. font-size: 24rpx;
  137. font-family: PingFang SC;
  138. font-weight: 500;
  139. color: #005BFF;
  140. line-height: 31rpx
  141. }
  142. .services {
  143. font-size: 24rpx;
  144. font-family: PingFang SC;
  145. font-weight: bold;
  146. color: #333333;
  147. line-height: 31rpx;
  148. span {
  149. font-size: 24rpx;
  150. font-family: PingFang SC;
  151. font-weight: 500;
  152. color: #999999;
  153. line-height: 31rpx;
  154. }
  155. }
  156. image {
  157. width: 142rpx;
  158. height: 107rpx;
  159. margin-top: -74rpx;
  160. }
  161. }
  162. }
  163. }
  164. .header {
  165. width: 100%;
  166. height: 86rpx;
  167. background: #FFFFFF;
  168. display: flex;
  169. align-items: center;
  170. .bar {
  171. display: flex;
  172. flex-direction: column;
  173. align-items: center;
  174. font-size: 28rpx;
  175. font-family: PingFang SC;
  176. font-weight: 500;
  177. color: #666666;
  178. }
  179. span {
  180. font-size: 22rpx;
  181. font-family: PingFang SC;
  182. font-weight: 500;
  183. color: #005BFF;
  184. padding-left: 12rpx;
  185. }
  186. }
  187. .bar-select {
  188. display: flex;
  189. flex-direction: column;
  190. align-items: center;
  191. font-size: 28rpx;
  192. font-family: PingFang SC;
  193. font-weight: bold;
  194. color: #333333;
  195. image {
  196. width: 34rpx;
  197. height: 11rpx;
  198. }
  199. }
  200. </style>