eatlist.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view>
  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="plr16" :style="'background:'+backgroundColor">
  8. <!-- <view class="search flexc mb4">
  9. <image :src="serimg"></image>
  10. <input placeholder="请输入人员姓名进行搜索" confirm-type="search" placeholder-style="color:#B9DCF7" v-model="title" @confirm="getConfirm"/>
  11. </view> -->
  12. <!-- 搜索 -->
  13. <view class="lbtab flexc">
  14. <image :src="licoimg" class="limg" @click='getResetFn'></image>
  15. <view class="lbtabs flexc">
  16. <picker class="pickbox" range-key='dictLabel' :range="jclxlist" @change="bindTimeChangea">
  17. <view class="pickboxa">
  18. <view class="tit overtwo" >{{jclx||'就餐类型'}}</view>
  19. <image :src="wupimg" class="hupimg"></image>
  20. </view>
  21. </picker>
  22. </view>
  23. <view @click="getDetailDay" v-if="!checkRole(['administrators'])" class="daybtn flexc">
  24. <image :src="dayimg"></image>
  25. 预约记录</view>
  26. </view>
  27. </view>
  28. </view>
  29. <image :src="navbg" class="navbg"></image>
  30. <view class="zxmain" :style="'margin-top:-'+marTop+'rpx;'">
  31. <!-- 列表 -->
  32. <y-list type='eatlist' :datalist="list" :wtdt="wtdt" @getDetail='getDetail' :jclxlist="jclxlist" @getDelFn="getDelFn"></y-list>
  33. <view class="yyfbtn flexcc" v-if="checkPermi(['system:food:add'])" @click="getAddFn">添加就餐预约</view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  39. import yList from "@/work/components/yuyue/list.vue"
  40. import {getFoodList,getFoodDel} from "@/api/mine/work.js"
  41. import {getDictionaryFn} from "@/api/mine/register.js"
  42. export default {
  43. components: {yList},
  44. data() {
  45. return {
  46. wupimg:require("@/work/static/record/wup.png"),
  47. serimg:require("@/work/static/record/search.png"),
  48. licoimg:require("@/work/static/record/lico.png"),
  49. navbg:require("@/static/images/navbg.png"),
  50. dayimg:require("@/work/static/yuy/day.png"),
  51. backgroundColor: "transparent",
  52. datainfo:{},
  53. nvaHeight: 44,
  54. marTop: 0, //距离顶部的距离
  55. stubarHeight: 0, //
  56. title:'',
  57. jclxlist:[],
  58. list:[],
  59. pageSize: 10,
  60. pageNum: 1,
  61. reachflag: false,
  62. wtdt:'',
  63. jclx:'',
  64. orderFoodType:'',//就餐类型
  65. userId:this.$store.state.user.userId,
  66. }
  67. },
  68. onPageScroll(e) {
  69. var scrollTop = Number(e.scrollTop);
  70. if (scrollTop > 0) {
  71. this.backgroundColor = '#0491FD'
  72. } else {
  73. this.backgroundColor = 'transparent'
  74. }
  75. },
  76. onUnload() {
  77. uni.$off('refreshfoodlist')
  78. },
  79. onLoad: function() {
  80. uni.$on('refreshfoodlist',(e) => {
  81. this.getConfirm()
  82. })
  83. this.init()
  84. this.getDataFn()
  85. uni.getSystemInfo({
  86. success: (e) => {
  87. this.stubarHeight = Number(e.statusBarHeight);
  88. this.nvaHeight = Number(e.statusBarHeight) + 44;
  89. this.tabscheight = Number(this.nvaHeight) * 2 + 100;
  90. }
  91. })
  92. },
  93. onShow() {},
  94. mounted() {
  95. this.getHeightFn()
  96. },
  97. // 上拉触底加载更多触发事件
  98. onReachBottom() {
  99. if (this.reachflag) {
  100. this.pageNum++
  101. this.getDataFn()
  102. }
  103. },
  104. methods: {
  105. checkPermi,
  106. checkRole,
  107. getConfirm(){
  108. this.pageNum=1;
  109. this.list=[];
  110. this.reachflag=true;
  111. this.getDataFn()
  112. },
  113. getResetFn(){
  114. // 重置
  115. this.jclx='';
  116. this.orderFoodType='';
  117. this.title="";
  118. this.getConfirm()
  119. },
  120. getBack() {
  121. uni.navigateBack({
  122. delta: 1
  123. })
  124. },
  125. getDetail(id){
  126. var obj={
  127. id:id,
  128. type:'edit'
  129. }
  130. this.$tab.navigateTo('/work/pages/yyorder/eat?data='+encodeURIComponent(JSON.stringify(obj)))
  131. },
  132. getDetailDay(){
  133. this.$tab.navigateTo('/work/pages/yyorder/eatlistday')
  134. },
  135. getAddFn(){
  136. this.$tab.navigateTo('/work/pages/yyorder/eat')
  137. },
  138. bindTimeChangea(e){
  139. var val=e.detail.value;
  140. this.jclx=this.jclxlist[val].dictLabel;
  141. this.orderFoodType=this.jclxlist[val].dictValue;
  142. this.getConfirm()
  143. },
  144. getHeightFn() {
  145. let query = uni.createSelectorQuery().in(this);
  146. //需要给黄色区域设置一个id标识,在这里是demo
  147. query.select('.navbox').boundingClientRect(data => {
  148. var top = data.top < 0 ? -data.top : data.top;
  149. var stubarHeight = Number(this.stubarHeight);
  150. this.marTop = stubarHeight > 0 ? 692 - Number(data.height) * 2 : 692 - Number(data.height) *
  151. 2 + 40 //赋值,待会要用
  152. if (top <= this.nvaHeight) {
  153. const opacity = top / 100 // 计算透明度值
  154. const color = `rgba(4, 145, 253, ${opacity})`
  155. this.backgroundColor = color // 更新盒子背景颜色
  156. } else {
  157. this.backgroundColor = '#00A9F0'
  158. }
  159. }).exec();
  160. },
  161. init() {
  162. // 就餐类型
  163. getDictionaryFn('jiucan').then(res=>{
  164. if(res.code==200){
  165. this.jclxlist = res.data.map(v => {
  166. return {
  167. dictLabel: v.dictLabel,
  168. dictValue: v.dictValue
  169. }
  170. })
  171. }
  172. })
  173. },
  174. getDelFn(id){
  175. var that=this;
  176. getFoodDel(id).then(res=>{
  177. if(res.code==200){
  178. this.$toast('删除成功')
  179. setTimeout(function(){
  180. that.getConfirm()
  181. },1200)
  182. }
  183. })
  184. },
  185. getDataFn() {
  186. var params = {
  187. pageSize: this.pageSize,
  188. pageNum: this.pageNum,
  189. }
  190. if(!checkRole(['administrators'])){
  191. params.orderFoodUserId=this.userId
  192. }
  193. if(this.jclx){
  194. params.orderFoodType=this.orderFoodType
  195. }
  196. if(this.title){
  197. params.orderFoodUser=this.title
  198. }
  199. getFoodList(params).then(res => {
  200. if (res.code == 200) {
  201. if (res.rows.length < this.pageSize) {
  202. this.reachflag = false
  203. this.wtdt = '到底了~';
  204. } else {
  205. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -
  206. 1)
  207. if (num < res.total) {
  208. this.reachflag = true
  209. this.wtdt = '上拉加载更多'
  210. } else {
  211. this.reachflag = false
  212. this.wtdt = '到底了~';
  213. }
  214. }
  215. if (this.pageNum == 1) {
  216. this.list = res.rows;
  217. } else {
  218. this.list = this.list.concat(res.rows)
  219. }
  220. } else {
  221. this.$toast(res.msg)
  222. }
  223. })
  224. },
  225. },
  226. }
  227. </script>
  228. <style>
  229. /* page {
  230. background: #ffffff;
  231. } */
  232. </style>
  233. <style lang="scss" scoped>
  234. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  235. .navbg{width: 100%;height: 692rpx;}
  236. .zxmain{position: relative;padding: 8rpx 32rpx 100rpx;box-sizing: border-box;}
  237. .search{padding: 0 52rpx;box-sizing: border-box;
  238. width: 100%;height: 76rpx;background: rgba(40, 139, 214, 0.5);border-radius: 38rpx;
  239. image{width: 24rpx;height: 24rpx;margin-right: 22rpx;flex: 0 0 auto;}
  240. input{flex: 1;font-weight: 500;font-size: 22rpx;color: #FFFFFF;}
  241. }
  242. .daybtn{font-weight: 500;font-size: 26rpx;color: #FFFFFF;flex: 0 0 auto;
  243. image{width: 30rpx;height: 30rpx;margin-right: 8rpx;}
  244. }
  245. .lbtab{padding-left:18rpx;
  246. .limg{width: 24rpx;height: 24rpx;margin-right: 16rpx;flex:0 0 auto;}
  247. .lbtabs{overflow: auto;flex-wrap: nowrap;flex:1;
  248. .pickbox{text-align: right;font-weight: 500;font-size: 28rpx;color: #161616;min-height:88rpx;margin: 0 10rpx;
  249. .pickboxa{justify-content: center;
  250. min-height: 88rpx;display: flex;align-items: center;
  251. }
  252. .tit{font-weight: 500;font-size: 26rpx;color: #FFFFFF;}
  253. .hupimg{width: 16rpx;height: 10rpx;margin-left: 26rpx;flex: 0 0 auto;}
  254. }
  255. }
  256. }
  257. </style>