menuRecord.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. this.tabscheight = Number(this.nvaHeight) * 2 + 100;
  73. }
  74. })
  75. },
  76. onShow() {},
  77. mounted() {
  78. // this.getHeightFn()
  79. },
  80. // 上拉触底加载更多触发事件
  81. onReachBottom() {
  82. if (this.reachflag) {
  83. this.pageNum++
  84. this.getDataFn()
  85. }
  86. },
  87. methods: {
  88. checkPermi,
  89. checkRole,
  90. getConfirm(){
  91. this.pageNum=1;
  92. this.list=[];
  93. this.reachflag=true;
  94. this.getDataFn()
  95. },
  96. getBack() {
  97. uni.navigateBack({
  98. delta: 1
  99. })
  100. },
  101. bindTimeChangea(e){
  102. var val=e.detail.value;
  103. this.recordTime=val;
  104. this.getConfirm()
  105. },
  106. getResetFn(){
  107. this.recordTime='';
  108. this.getConfirm()
  109. },
  110. getHeightFn() {
  111. let query = uni.createSelectorQuery().in(this);
  112. //需要给黄色区域设置一个id标识,在这里是demo
  113. query.select('.navbox').boundingClientRect(data => {
  114. var top = data.top < 0 ? -data.top : data.top;
  115. var stubarHeight = Number(this.stubarHeight);
  116. this.marTop = stubarHeight > 0 ? 692 - Number(data.height) * 2 : 692 - Number(data.height) *
  117. 2 + 40 //赋值,待会要用
  118. if (top <= this.nvaHeight) {
  119. const opacity = top / 100 // 计算透明度值
  120. const color = `rgba(4, 145, 253, ${opacity})`
  121. this.backgroundColor = color // 更新盒子背景颜色
  122. } else {
  123. this.backgroundColor = '#00A9F0'
  124. }
  125. }).exec();
  126. },
  127. init() {
  128. // // 就餐类型
  129. // getDictionaryFn('jiucan').then(res=>{
  130. // if(res.code==200){
  131. // this.jclxlist = res.data.map(v => {
  132. // return {
  133. // dictLabel: v.dictLabel,
  134. // dictValue: v.dictValue
  135. // }
  136. // })
  137. // }
  138. // })
  139. },
  140. getDelFn(id){
  141. var that=this;
  142. getFoodDel(id).then(res=>{
  143. if(res.code==200){
  144. this.$toast('删除成功')
  145. setTimeout(function(){
  146. that.getConfirm()
  147. },1200)
  148. }
  149. })
  150. },
  151. getDataFn() {
  152. var params = {
  153. pageSize: this.pageSize,
  154. pageNum: this.pageNum,
  155. }
  156. if(this.recordTime){
  157. params.recordTime=this.recordTime
  158. }
  159. getMenuRecordList(params).then(res => {
  160. if (res.code == 200) {
  161. if (res.rows.length < this.pageSize) {
  162. this.reachflag = false
  163. this.wtdt = '到底了~';
  164. } else {
  165. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -
  166. 1)
  167. if (num < res.total) {
  168. this.reachflag = true
  169. this.wtdt = '上拉加载更多'
  170. } else {
  171. this.reachflag = false
  172. this.wtdt = '到底了~';
  173. }
  174. }
  175. if (this.pageNum == 1) {
  176. this.list = res.rows;
  177. } else {
  178. this.list = this.list.concat(res.rows)
  179. }
  180. } else {
  181. this.$toast(res.msg)
  182. }
  183. })
  184. },
  185. },
  186. }
  187. </script>
  188. <style>
  189. /* page {
  190. background: #ffffff;
  191. } */
  192. </style>
  193. <style lang="scss" scoped>
  194. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  195. .navbg{width: 100%;height: 692rpx;position: absolute;left: 0;right: 0;top: 0;z-index: -1;}
  196. .zxmain{position: relative;padding: 120rpx 0rpx 10rpx;box-sizing: border-box;}
  197. .searchs{padding: 12rpx 32rpx;
  198. .limg{width: 24rpx;height: 24rpx;margin-right: 16rpx;flex:0 0 auto;}
  199. }
  200. .search{padding: 0 52rpx;box-sizing: border-box;
  201. width: 100%;height: 76rpx;background: rgba(40, 139, 214, 0.5);border-radius: 38rpx;
  202. image{width: 24rpx;height: 24rpx;margin-right: 22rpx;flex: 0 0 auto;}
  203. .input{flex: 1;font-weight: 500;font-size: 22rpx;color: #FFFFFF;
  204. &.nact{color:#B9DCF7;}
  205. }
  206. }
  207. .daybtn{font-weight: 500;font-size: 26rpx;color: #FFFFFF;flex: 0 0 auto;
  208. image{width: 30rpx;height: 30rpx;margin-right: 8rpx;}
  209. }
  210. </style>