index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view class='content'>
  3. <view>
  4. <view></view>
  5. <view>
  6. <mescroll-uni :up="upOption" :down="downOption" ref="mescrollRef" @init="mescrollInit"
  7. @up="upCallback" @down="downCallback" height="1400">
  8. <view style='flex-wrap: wrap;' class="flex">
  9. <view v-for='item in homestayList' class="homestayWrap">
  10. <view>
  11. <image @click='previewImg(item)' width="172" height="172" :src="item.homestayImage" mode='aspectFill'></image>
  12. </view>
  13. <view>{{item.title}}</view>
  14. <view>{{item.price}}</view>
  15. <view class='flex'>
  16. <view class='merchants_default_button_text' @click='edit(item)'>编辑</view>
  17. <view class='merchants_caution_button_text' @click='del(item)'>删除</view>
  18. <view class='merchants_default_button_text' @click='refresh(item)'>刷新</view>
  19. <view class='merchants_default_button_text' @click='hitTheSheif(item)'>上架</view>
  20. </view>
  21. </view>
  22. </view>
  23. </mescroll-uni>
  24. </view>
  25. </view>
  26. <view style='margin:20rpx;' class='flex justify-space-between'>
  27. <view class='merchants_button'>一键刷新</view>
  28. <view @click='add' class='merchants_button'>添加民宿</view>
  29. </view>
  30. <u-modal :show="isDel" content='确定删除民宿信息?' @confirm="$u.debounce(confirmDel, 500)" showCancelButton
  31. @cancel="isDel=false" @close="isDel=false" closeOnClickOverlay></u-modal>
  32. </view>
  33. </template>
  34. <script>
  35. var that
  36. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  37. export default {
  38. mixins: [MescrollMixin],
  39. data() {
  40. return {
  41. homestayList:[],
  42. mescroll:null,
  43. isDel:false,
  44. currectData:{},
  45. downOption: {
  46. auto: false,
  47. textColor: '#bbb'
  48. },
  49. upOption: {
  50. page: {
  51. size: 10 // 每页数据的数量,默认10
  52. },
  53. auto: false,
  54. noMoreSize: 1,
  55. textNoMore: '没有更多了~',
  56. textColor: '#bbb'
  57. },
  58. }
  59. },
  60. onLoad() {
  61. that = this
  62. },
  63. onShow(){
  64. this.mescroll.resetUpScroll()
  65. },
  66. methods: {
  67. previewImg(item){
  68. uni.previewImage({
  69. current: 0,
  70. urls: [item.dishImage],
  71. loop:true,
  72. })
  73. },
  74. add(){
  75. uni.navigateTo({
  76. url:'/pageA/enter/myHomestay/add'
  77. })
  78. },
  79. edit(item){
  80. uni.navigateTo({
  81. url:'/pageA/enter/myHomestay/edit?id='+item.id
  82. })
  83. },
  84. del(item){
  85. this.currectData = item
  86. this.isDel = true
  87. },
  88. confirmDel(){
  89. uni.showLoading({
  90. title: '加载中',
  91. mask: true
  92. })
  93. that.$request.baseRequest('admin.tourism.homestayDetailInfo', 'delete',{
  94. id:this.currectD
  95. }, failres => {
  96. uni.showToast({
  97. icon: "none",
  98. title: failres.errmsg,
  99. duration: 3000
  100. });
  101. uni.hideLoading()
  102. }).then(res => {
  103. this.isDel = false
  104. uni.showToast({
  105. icon: "success",
  106. title: '删除民宿成功',
  107. duration: 2000
  108. });
  109. })
  110. },
  111. mescrollInit(mescroll) {
  112. this.mescroll = mescroll;
  113. },
  114. downCallback() {
  115. // if (uni.getStorageSync("userInfo").phone) {
  116. this.mescroll.resetUpScroll()
  117. // } else {
  118. // that.mescroll.endBySize(0, 0)
  119. // this.showAuthorizePhone = true
  120. // }
  121. },
  122. getList(page){
  123. return new Promise((resolve, reject) => {
  124. that.$request.baseRequest('admin.tourism.homestayDetailInfo', 'list', {
  125. page: page.num,
  126. limit: page.size,
  127. // searchContent: this.searchVal,
  128. // classify: this.typeName
  129. }, failres => {
  130. uni.showToast({
  131. icon: "none",
  132. title: failres.errmsg,
  133. duration: 3000
  134. });
  135. uni.hideLoading()
  136. }).then(res => {
  137. resolve(res)
  138. })
  139. })
  140. },
  141. async upCallback(page) {
  142. console.log(11111)
  143. // if (uni.getStorageSync("userInfo").id) {
  144. uni.showLoading({
  145. title: '数据加载中'
  146. })
  147. var finddata=await that.getList(page)
  148. if (page.num == 1) that.homestayList = [];
  149. that.curPageLen = finddata.data.items.length;
  150. that.homestayList = finddata.data.items
  151. that.totalPage = finddata.data.total;
  152. uni.hideLoading()
  153. that.$nextTick(() => {
  154. that.mescroll.endBySize(that.curPageLen, that.totalPage)
  155. });
  156. // }
  157. },
  158. }
  159. }
  160. </script>
  161. <style lang='scss' scoped>
  162. .homestayWrap{
  163. width:50%;
  164. background:#fff;
  165. padding:10rpx;
  166. margin:10rpx;
  167. }
  168. </style>