oftenRoute.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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 }}
  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 }}
  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. let commonNo = uni.getStorageSync("firstAuthentication").commonId
  88. if(!commonNo){
  89. this.mescroll.endBySize(0, 0);
  90. return
  91. }
  92. this.$request.baseRequest('get', '/commonRoute/select', {
  93. commonId: commonNo,
  94. pageSize: page.size,
  95. currentPage: page.num
  96. }).then(res => {
  97. if (res.code == 200) {
  98. if (page.num == 1) {
  99. this.routeData = []
  100. }
  101. if(res.data.records>0){
  102. for (let i = 0; i < res.data.records.length; i++) {
  103. if(res.data.records[i].sendProvince=='北京'
  104. ||res.data.records[i].sendProvince=='天津'
  105. ||res.data.records[i].sendProvince=='上海'
  106. ||res.data.records[i].sendProvince=='重庆'
  107. ||res.data.records[i].sendProvince=='台湾'
  108. ||res.data.records[i].sendProvince=='澳门'
  109. ||res.data.records[i].sendProvince=='香港'
  110. ||res.data.records[i].sendProvince=='钓鱼岛'){
  111. res.data.records[i].sendProvince=''
  112. }
  113. if(res.data.records[i].sendCity=='钓鱼岛'){
  114. res.data.records[i].sendArea=''
  115. }
  116. if(res.data.records[i].unloadProvince=='北京'
  117. ||res.data.records[i].unloadProvince=='天津'
  118. ||res.data.records[i].unloadProvince=='上海'
  119. ||res.data.records[i].unloadProvince=='重庆'
  120. ||res.data.records[i].unloadProvince=='台湾'
  121. ||res.data.records[i].unloadProvince=='澳门'
  122. ||res.data.records[i].unloadProvince=='香港'
  123. ||res.data.records[i].unloadProvince=='钓鱼岛'){
  124. res.data.records[i].unloadProvince=''
  125. }
  126. if(res.data.records[i].unloadCity=='钓鱼岛'){
  127. res.data.records[i].unloadArea=''
  128. }
  129. }
  130. }
  131. console.log(res.data.records)
  132. this.routeData = this.routeData.concat(res.data.records); //追加新数据
  133. this.$forceUpdate()
  134. this.mescroll.endBySize(res.data.records.length, res.data.total);
  135. console.log(this.routeData)
  136. }
  137. })
  138. .catch(res => {
  139. uni.$u.toast(res.message);
  140. });
  141. },
  142. delSubmit() {
  143. this.$request.baseRequest('post', '/commonRoute/api/delete', {
  144. id: this.delId
  145. }).then(res => {
  146. if (res.code == 200) {
  147. this.$refs.uToast.show({
  148. type: 'success',
  149. message: "删除成功!",
  150. })
  151. this.tipsShow = false
  152. this.getList()
  153. }
  154. })
  155. .catch(res => {
  156. uni.$u.toast(res.message);
  157. });
  158. },
  159. del(ids) {
  160. this.tipsText = "确定删除改常用路线?"
  161. this.tipsShow = true
  162. this.delId = ids
  163. },
  164. cancelClick() {
  165. this.tipsShow = false
  166. },
  167. getList() {
  168. this.status = 'loading';
  169. this.$request.baseRequest('get', '/commonRoute/select', {
  170. commonId: uni.getStorageSync("firstAuthentication").commonId,
  171. pageSize: 10,
  172. currentPage: 1
  173. }).then(res => {
  174. if (res.code == 200) {
  175. this.routeData = res.data.records
  176. if (res.data.total == 0) {
  177. this.status = 'nomore'
  178. } else {
  179. this.status = 'loadmore'
  180. }
  181. }
  182. })
  183. .catch(res => {
  184. uni.$u.toast(res.message);
  185. });
  186. },
  187. showChane(item) {
  188. if (item.displayFlag == 1) {
  189. item.displayFlag = 2
  190. } else {
  191. item.displayFlag = 1
  192. }
  193. this.$request.baseRequest('post', '/commonRoute/api/edit', item).then(res => {
  194. if (res.code == 200) {
  195. if (item.displayFlag == 1) {
  196. this.$refs.uToast.show({
  197. type: 'success',
  198. message: "路线展示中!",
  199. })
  200. } else {
  201. this.$refs.uToast.show({
  202. type: 'success',
  203. message: "路线已隐藏!",
  204. })
  205. }
  206. }
  207. })
  208. .catch(res => {
  209. uni.$u.toast(res.message);
  210. });
  211. },
  212. addRoute(item) {
  213. if (item == 1 && this.routeData.length == 50) {
  214. this.$refs.uToast.show({
  215. type: 'success',
  216. message: "最多可创建50条常用路线!",
  217. })
  218. } else {
  219. uni.$u.route("pages/mine/often/addRoute", {
  220. id: item.id
  221. })
  222. }
  223. },
  224. }
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. .center {
  229. padding: 30rpx 30rpx 200rpx;
  230. background: #F2F4F7;
  231. position: flex;
  232. position: relative;
  233. }
  234. .route {
  235. // margin-bottom: 40rpx;
  236. .route_css {
  237. background: #FFFFFF;
  238. margin-bottom: 40rpx;
  239. padding: 30rpx 50rpx;
  240. border-radius: 20rpx;
  241. .route_site {
  242. border-bottom: 1px solid #E6E6E6;
  243. height: 120rpx;
  244. .site_text {
  245. max-width: 200rpx;
  246. overflow: hidden;
  247. text-overflow: ellipsis;
  248. white-space: nowrap;
  249. font-size: 32rpx;
  250. }
  251. }
  252. .jt_css {
  253. width: 60rpx;
  254. height: 20rpx;
  255. margin: 0 23rpx;
  256. }
  257. .dot {
  258. display: inline-block;
  259. width: 12rpx;
  260. height: 12rpx;
  261. border-radius: 6rpx;
  262. margin: 20rpx 20rpx 0 0;
  263. }
  264. .blueDot {
  265. background: #2772FB;
  266. }
  267. .redDot {
  268. background: #FE6300;
  269. }
  270. .btns {
  271. width: 100%;
  272. justify-content: flex-end;
  273. margin-top: 40rpx;
  274. }
  275. .btn_css {
  276. margin-left: 30rpx;
  277. width: 120rpx;
  278. height: 66rpx;
  279. border-radius: 33px;
  280. border: 1px solid #CDCDCD;
  281. line-height: 66rpx;
  282. text-align: center;
  283. }
  284. }
  285. }
  286. .bottom_add {
  287. position: fixed;
  288. left: 0;
  289. bottom: 0;
  290. width: 100%;
  291. height: 160rpx;
  292. padding-top: 30rpx;
  293. background: #FFFFFF;
  294. text-align: center;
  295. .add_btn {
  296. width: 90%;
  297. height: 92rpx;
  298. line-height: 92rpx;
  299. background: #2772FB;
  300. text-align: center;
  301. border-radius: 46rpx;
  302. color: #FFFFFF;
  303. margin-top: 30rpx;
  304. // height: 60rpx;
  305. margin: 0 auto;
  306. }
  307. .tips {
  308. text-align: center;
  309. color: #ABABAB;
  310. font-size: 24rpx;
  311. }
  312. }
  313. </style>