oftenRoute.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <view class="center">
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  4. <view class="route">
  5. <view v-for="(item,index) in routeData" class="route_css">
  6. <view class="route_site flex">
  7. <span class="blueDot dot"></span>
  8. <view class="site_text">
  9. <!-- {{item.sendProvince}} -->{{item.sendCity ? item.sendCity: item.sendProvince}}
  10. {{item.sendArea}}
  11. </view>
  12. <!-- {{item.sendCity ? item.sendCity: item.sendProvince}} {{item.sendArea}} -->
  13. <image class="jt_css" src="@/static/images/goodSource/jt.png" mode='widthFix'></image>
  14. <span class="redDot dot"></span>
  15. <view class="site_text">
  16. <!-- {{item.unloadProvince}} -->{{item.unloadCity ? item.unloadCity: item.unloadProvince}}
  17. {{item.unloadArea}}
  18. </view>
  19. </view>
  20. <view class="flex btns">
  21. <view class="btn_css" @click="addRoute(item)">修改</view>
  22. <view class="btn_css" @click="del(item.id)">删除</view>
  23. <view class="btn_css" @click="showChane(item)">{{item.displayFlag == 1?"显示中":"已隐藏"}}</view>
  24. </view>
  25. </view>
  26. <!-- <u-loadmore :status="status" :nomore-text="nomoreText" /> -->
  27. </view>
  28. </mescroll-body>
  29. <u-toast ref="uToast"></u-toast>
  30. <view class="bottom_add">
  31. <view class="add_btn" @click="addRoute(1)">添加常用路线</view>
  32. <span class="tips">最多可创建50条</span>
  33. </view>
  34. <u-modal :show="tipsShow" :title="tipsText" :closeOnClickOverlay='true' :showCancelButton='true'
  35. confirmColor='#2772FB' @confirm="delSubmit" @close="cancelClick" @cancel="cancelClick"></u-modal>
  36. </view>
  37. </template>
  38. <script>
  39. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  40. export default {
  41. mixins: [MescrollMixin], // 使用mixin
  42. data() {
  43. return {
  44. routeData: [],
  45. status: 'loadmore',
  46. nomoreText: '实在没有了~',
  47. tipsShow: false,
  48. tipsText: "",
  49. delId: "",
  50. mescroll:{}
  51. }
  52. },
  53. onShow() {},
  54. onLoad() {},
  55. onNavigationBarButtonTap(e) {
  56. this.addRoute(1)
  57. },
  58. methods: {
  59. mescrollInit(mescroll) {
  60. this.mescroll = mescroll;
  61. },
  62. downCallback() {
  63. // 第2种: 下拉刷新和上拉加载调同样的接口, 则不用第1种, 直接mescroll.resetUpScroll()即可
  64. // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  65. this.mescroll.resetUpScroll()
  66. },
  67. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  68. upCallback(page) {
  69. console.log(page)
  70. // 此处可以继续请求其他接口
  71. // if (page.num == 1) {
  72. // this.routeData = []
  73. // // 请求其他接口...
  74. // }
  75. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  76. // if(!this.isInitxx){
  77. // apiGetxx().then(res=>{
  78. // this.isInitxx = true
  79. // this.mescroll.resetUpScroll() // 重新触发upCallback
  80. // }).catch(()=>{
  81. // this.mescroll.endErr()
  82. // })
  83. // return // 此处return,先获取xx
  84. // }
  85. //联网加载数据
  86. this.status = 'loading';
  87. this.$request.baseRequest('get', '/commonRoute/select', {
  88. commonId: uni.getStorageSync("firstAuthentication").commonId,
  89. pageSize: page.size,
  90. currentPage: page.num
  91. }).then(res => {
  92. if (res.code == 200) {
  93. if (page.num == 1) {
  94. this.routeData = []
  95. }
  96. this.routeData = this.routeData.concat(res.data.records); //追加新数据
  97. this.$forceUpdate()
  98. this.mescroll.endBySize(res.data.records.length, res.data.total);
  99. console.log(this.routeData)
  100. }
  101. })
  102. .catch(res => {
  103. uni.$u.toast(res.message);
  104. });
  105. },
  106. delSubmit() {
  107. this.$request.baseRequest('post', '/commonRoute/api/delete', {
  108. id: this.delId
  109. }).then(res => {
  110. if (res.code == 200) {
  111. this.$refs.uToast.show({
  112. type: 'success',
  113. message: "删除成功!",
  114. })
  115. this.tipsShow = false
  116. this.getList()
  117. }
  118. })
  119. .catch(res => {
  120. uni.$u.toast(res.message);
  121. });
  122. },
  123. del(ids) {
  124. this.tipsText = "确定删除改常用路线?"
  125. this.tipsShow = true
  126. this.delId = ids
  127. },
  128. cancelClick() {
  129. this.tipsShow = false
  130. },
  131. getList() {
  132. this.status = 'loading';
  133. this.$request.baseRequest('get', '/commonRoute/select', {
  134. commonId: uni.getStorageSync("firstAuthentication").commonId,
  135. pageSize: 10,
  136. currentPage: 1
  137. }).then(res => {
  138. if (res.code == 200) {
  139. this.routeData = res.data.records
  140. if (res.data.total == 0) {
  141. this.status = 'nomore'
  142. } else {
  143. this.status = 'loadmore'
  144. }
  145. }
  146. })
  147. .catch(res => {
  148. uni.$u.toast(res.message);
  149. });
  150. },
  151. showChane(item) {
  152. if (item.displayFlag == 1) {
  153. item.displayFlag = 2
  154. } else {
  155. item.displayFlag = 1
  156. }
  157. this.$request.baseRequest('post', '/commonRoute/api/edit', item).then(res => {
  158. if (res.code == 200) {
  159. if (item.displayFlag == 1) {
  160. this.$refs.uToast.show({
  161. type: 'success',
  162. message: "路线展示中!",
  163. })
  164. } else {
  165. this.$refs.uToast.show({
  166. type: 'success',
  167. message: "路线已隐藏!",
  168. })
  169. }
  170. }
  171. })
  172. .catch(res => {
  173. uni.$u.toast(res.message);
  174. });
  175. },
  176. addRoute(item) {
  177. if (item == 1 && this.routeData.length == 50) {
  178. this.$refs.uToast.show({
  179. type: 'success',
  180. message: "最多可创建50条常用路线!",
  181. })
  182. } else {
  183. uni.$u.route("pages/mine/often/addRoute", {
  184. id: item.id
  185. })
  186. }
  187. },
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. .center {
  193. padding: 30rpx 30rpx 200rpx;
  194. background: #F2F4F7;
  195. position: flex;
  196. position: relative;
  197. }
  198. .route {
  199. // margin-bottom: 40rpx;
  200. .route_css {
  201. background: #FFFFFF;
  202. margin-bottom: 40rpx;
  203. padding: 30rpx 50rpx;
  204. border-radius: 20rpx;
  205. .route_site {
  206. border-bottom: 1px solid #E6E6E6;
  207. height: 120rpx;
  208. .site_text {
  209. max-width: 200rpx;
  210. overflow: hidden;
  211. text-overflow: ellipsis;
  212. white-space: nowrap;
  213. font-size: 32rpx;
  214. }
  215. }
  216. .jt_css {
  217. width: 60rpx;
  218. height: 20rpx;
  219. margin: 0 23rpx;
  220. }
  221. .dot {
  222. display: inline-block;
  223. width: 12rpx;
  224. height: 12rpx;
  225. border-radius: 6rpx;
  226. margin: 20rpx 20rpx 0 0;
  227. }
  228. .blueDot {
  229. background: #2772FB;
  230. }
  231. .redDot {
  232. background: #FE6300;
  233. }
  234. .btns {
  235. width: 100%;
  236. justify-content: flex-end;
  237. margin-top: 40rpx;
  238. }
  239. .btn_css {
  240. margin-left: 30rpx;
  241. width: 120rpx;
  242. height: 66rpx;
  243. border-radius: 33px;
  244. border: 1px solid #CDCDCD;
  245. line-height: 66rpx;
  246. text-align: center;
  247. }
  248. }
  249. }
  250. .bottom_add {
  251. position: fixed;
  252. left: 0;
  253. bottom: 0;
  254. width: 100%;
  255. height: 160rpx;
  256. padding-top: 30rpx;
  257. background: #FFFFFF;
  258. text-align: center;
  259. .add_btn {
  260. width: 90%;
  261. height: 70rpx;
  262. line-height: 70rpx;
  263. background: #2772FB;
  264. text-align: center;
  265. border-radius: 35rpx;
  266. color: #FFFFFF;
  267. margin-top: 30rpx;
  268. // height: 60rpx;
  269. margin: 0 auto;
  270. }
  271. .tips {
  272. text-align: center;
  273. color: #ABABAB;
  274. font-size: 24rpx;
  275. }
  276. }
  277. </style>