menuRecord.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view :style="'padding-top:'+nvaHeight+'px;'">
  3. <view class="navbox">
  4. <uni-nav-bar color="#ffffff" left-icon="left" title="食谱记录" :background-color="backgroundColor"
  5. :border="false" statusBar='true' fixed="true" @clickLeft='getBack'>
  6. </uni-nav-bar>
  7. <view class="searchs flexc" :style="'background:'+backgroundColor">
  8. <image :src="licoimg" class="limg" @click='getResetFn'></image>
  9. <picker mode="date" class="pickbox flex1" @change="bindTimeChangea">
  10. <view class="search flexc">
  11. <image :src="serimg"></image>
  12. <view class="input" :class="recordTime?'':'nact'">{{recordTime||"请选择时间进行搜索"}}</view>
  13. <!-- <input placeholder="请选择时间进行搜索" confirm-type="search" placeholder-style="color:#B9DCF7" v-model="title" @confirm="getConfirm"/> -->
  14. </view>
  15. </picker>
  16. </view>
  17. </view>
  18. <image :src="navbg" class="navbg"></image>
  19. <view class="zxmain">
  20. <!-- 列表 -->
  21. <y-list type='recordlist' :datalist="list" :wtdt="wtdt" @getDelFn="getDelFn"></y-list>
  22. <!-- <view class="yyfbtn flexcc" v-if="checkPermi(['system:food:add'])" @click="getAddFn">添加食谱</view> -->
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  28. import yList from "@/work/components/yuyue/list.vue"
  29. import {getMenuRecordList} from "@/api/mine/order.js"
  30. import {getDictionaryFn} from "@/api/mine/register.js"
  31. export default {
  32. components: {yList},
  33. data() {
  34. return {
  35. wupimg:require("@/work/static/record/wup.png"),
  36. serimg:require("@/work/static/record/search.png"),
  37. licoimg:require("@/work/static/record/lico.png"),
  38. navbg:require("@/static/images/navbg.png"),
  39. dayimg:require("@/work/static/yuy/day.png"),
  40. backgroundColor: "transparent",
  41. datainfo:{},
  42. nvaHeight: 44,
  43. marTop: 0, //距离顶部的距离
  44. stubarHeight: 0, //
  45. title:'',
  46. list:[],
  47. pageSize: 10,
  48. pageNum: 1,
  49. reachflag: false,
  50. wtdt:'',
  51. userId:this.$store.state.user.userId,
  52. recordTime:'',
  53. }
  54. },
  55. onPageScroll(e) {
  56. var scrollTop = Number(e.scrollTop);
  57. if (scrollTop > 0) {
  58. this.backgroundColor = '#0491FD'
  59. } else {
  60. this.backgroundColor = 'transparent'
  61. }
  62. },
  63. onUnload() {
  64. },
  65. onLoad: function() {
  66. // this.init()
  67. this.getDataFn()
  68. uni.getSystemInfo({
  69. success: (e) => {
  70. this.stubarHeight = Number(e.statusBarHeight);
  71. this.nvaHeight = Number(e.statusBarHeight) + 44;
  72. }
  73. })
  74. },
  75. onShow() {},
  76. mounted() {
  77. },
  78. // 上拉触底加载更多触发事件
  79. onReachBottom() {
  80. if (this.reachflag) {
  81. this.pageNum++
  82. this.getDataFn()
  83. }
  84. },
  85. methods: {
  86. checkPermi,
  87. checkRole,
  88. getConfirm(){
  89. this.pageNum=1;
  90. this.list=[];
  91. this.reachflag=true;
  92. this.getDataFn()
  93. },
  94. getBack() {
  95. uni.navigateBack({
  96. delta: 1
  97. })
  98. },
  99. bindTimeChangea(e){
  100. var val=e.detail.value;
  101. this.recordTime=val;
  102. this.getConfirm()
  103. },
  104. getResetFn(){
  105. this.recordTime='';
  106. this.getConfirm()
  107. },
  108. init() {
  109. // // 就餐类型
  110. // getDictionaryFn('jiucan').then(res=>{
  111. // if(res.code==200){
  112. // this.jclxlist = res.data.map(v => {
  113. // return {
  114. // dictLabel: v.dictLabel,
  115. // dictValue: v.dictValue
  116. // }
  117. // })
  118. // }
  119. // })
  120. },
  121. getDelFn(id){
  122. var that=this;
  123. getFoodDel(id).then(res=>{
  124. if(res.code==200){
  125. this.$toast('删除成功')
  126. setTimeout(function(){
  127. that.getConfirm()
  128. },1200)
  129. }
  130. })
  131. },
  132. getDataFn() {
  133. var params = {
  134. pageSize: this.pageSize,
  135. pageNum: this.pageNum,
  136. }
  137. if(this.recordTime){
  138. params.recordTime=this.recordTime
  139. }
  140. getMenuRecordList(params).then(res => {
  141. if (res.code == 200) {
  142. if (res.rows.length < this.pageSize) {
  143. this.reachflag = false
  144. this.wtdt = '到底了~';
  145. } else {
  146. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -
  147. 1)
  148. if (num < res.total) {
  149. this.reachflag = true
  150. this.wtdt = '上拉加载更多'
  151. } else {
  152. this.reachflag = false
  153. this.wtdt = '到底了~';
  154. }
  155. }
  156. if (this.pageNum == 1) {
  157. this.list = res.rows;
  158. } else {
  159. this.list = this.list.concat(res.rows)
  160. }
  161. } else {
  162. this.$toast(res.msg)
  163. }
  164. })
  165. },
  166. },
  167. }
  168. </script>
  169. <style>
  170. /* page {
  171. background: #ffffff;
  172. } */
  173. </style>
  174. <style lang="scss" scoped>
  175. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  176. .navbg{width: 100%;height: 692rpx;position: absolute;left: 0;right: 0;top: 0;z-index: -1;}
  177. .zxmain{position: relative;padding: 120rpx 0rpx 10rpx;box-sizing: border-box;}
  178. .searchs{padding: 12rpx 32rpx;
  179. .limg{width: 24rpx;height: 24rpx;margin-right: 16rpx;flex:0 0 auto;}
  180. }
  181. .search{padding: 0 52rpx;box-sizing: border-box;
  182. width: 100%;height: 76rpx;background: rgba(40, 139, 214, 0.5);border-radius: 38rpx;
  183. image{width: 24rpx;height: 24rpx;margin-right: 22rpx;flex: 0 0 auto;}
  184. .input{flex: 1;font-weight: 500;font-size: 22rpx;color: #FFFFFF;
  185. &.nact{color:#B9DCF7;}
  186. }
  187. }
  188. .daybtn{font-weight: 500;font-size: 26rpx;color: #FFFFFF;flex: 0 0 auto;
  189. image{width: 30rpx;height: 30rpx;margin-right: 8rpx;}
  190. }
  191. </style>