visit.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view class="container">
  3. <scroll-view class="navbar" scroll-x>
  4. <view v-for="(item, index) in navList" class="nav-item"
  5. :class="{ current: tabCurrentIndex === index }"
  6. @click="tabClick(index)">{{ item.text }}
  7. </view>
  8. </scroll-view>
  9. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  10. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  11. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  12. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  13. <view v-for="(item, index) in tabItem.orderList" class="content-box flex">
  14. <view class="item">
  15. <view class="name">救援者姓名:{{item.helper_nickname}}</view>
  16. <view class="phone">手机号:{{item.helper_mobile}}</view>
  17. <view class="addr">救援地址:{{item.address}}</view>
  18. <view class="time">救援时间:{{ item.createtime }}</view>
  19. </view>
  20. <!-- <view class="tpl">{{item.status_text}}</view> -->
  21. </view>
  22. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  23. </scroll-view>
  24. </swiper-item>
  25. </swiper>
  26. </view>
  27. </template>
  28. <script>
  29. import { mapState, mapMutations } from 'vuex';
  30. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  31. import empty from '@/components/empty';
  32. import { getTime } from '@/utils/rocessor.js';
  33. export default {
  34. components: {
  35. uniLoadMore,
  36. empty
  37. },
  38. data() {
  39. return {
  40. userInfo:'',//用户信息
  41. tabCurrentIndex: 0,
  42. navList: [
  43. {
  44. state: 0,
  45. text: '待接受',
  46. loadingType: 'more',
  47. orderList: [],
  48. page: 1, //当前页数
  49. limit: 10 //每次信息条数
  50. },
  51. {
  52. state: 1,
  53. text: '已接受',
  54. loadingType: 'more',
  55. orderList: [],
  56. page: 1, //当前页数
  57. limit: 10 //每次信息条数
  58. },
  59. {
  60. state: 2,
  61. text: '已拒绝',
  62. loadingType: 'more',
  63. orderList: [],
  64. page: 1, //当前页数
  65. limit: 10 //每次信息条数
  66. },
  67. {
  68. state: 3,
  69. text: '已完成',
  70. loadingType: 'more',
  71. orderList: [],
  72. page: 1, //当前页数
  73. limit: 10 //每次信息条数
  74. }
  75. // {
  76. // state: 4,
  77. // text: '失败',
  78. // loadingType: 'more',
  79. // orderList: [],
  80. // page: 1, //当前页数
  81. // limit: 10 //每次信息条数
  82. // },
  83. // {
  84. // state: 5,
  85. // text: '已被其它人接受',
  86. // loadingType: 'more',
  87. // orderList: [],
  88. // page: 1, //当前页数
  89. // limit: 10 //每次信息条数
  90. // }
  91. ]
  92. };
  93. },
  94. onLoad() {
  95. },
  96. onShow() {
  97. this.loadData();
  98. },
  99. methods: {
  100. async loadData(source) {
  101. //这里是将订单挂载到tab列表下
  102. let index = this.tabCurrentIndex;
  103. let navItem = this.navList[index];
  104. let state = navItem.state;
  105. // if (source === 'tabChange' && navItem.loaded === true) {
  106. // //tab切换只有第一次需要加载数据
  107. // return;
  108. // }
  109. if (navItem.loadingType === 'loading') {
  110. //防止重复加载
  111. return;
  112. }
  113. if (navItem.loadingType === 'noMore') {
  114. //防止重复加载
  115. return;
  116. }
  117. // 修改当前对象状态为加载中
  118. navItem.loadingType = 'loading';
  119. mySosList({
  120. status: ''+state,
  121. page: navItem.page,
  122. limit: navItem.limit
  123. })
  124. .then(({ data }) => {
  125. let arr = data.map(e => {
  126. e.createtime = getTime(e.createtime);
  127. return e;
  128. });
  129. navItem.orderList = navItem.orderList.concat(arr);
  130. console.log(navItem.orderList)
  131. navItem.page++;
  132. if (navItem.limit == data.length) {
  133. //判断是否还有数据, 有改为 more, 没有改为noMore
  134. navItem.loadingType = 'more';
  135. return;
  136. } else {
  137. //判断是否还有数据, 有改为 more, 没有改为noMore
  138. navItem.loadingType = 'noMore';
  139. }
  140. uni.hideLoading();
  141. this.$set(navItem, 'loaded', true);
  142. })
  143. .catch(e => {
  144. console.log(e);
  145. });
  146. },
  147. //顶部tab点击
  148. tabClick(index) {
  149. this.tabCurrentIndex = index;
  150. // 初始化数据列表
  151. this.navList[index].orderList=[];
  152. // 初始化翻页数
  153. this.navList[index].page=1;
  154. // 初始化数据为未加载状态
  155. this.navList[index].loadingType = 'more';
  156. console.log(this.tabCurrentIndex)
  157. },
  158. //swiper 切换
  159. changeTab(e) {
  160. this.tabCurrentIndex = e.target.current;
  161. this.loadData('tabChange');
  162. },
  163. access(item){
  164. let obj = this;
  165. uni.showModal({
  166. title: '提示',
  167. content: '您确定要接受求救吗',
  168. success: function (res) {
  169. if (res.confirm) {
  170. accessSos({
  171. id: item.id
  172. }).then((data) => {
  173. obj.$api.msg(data.msg);
  174. obj.page = 1;
  175. obj.loadData('refresh');
  176. }).catch((e) => {
  177. obj.$api.msg(e.message);
  178. console.log(e)
  179. });
  180. } else if (res.cancel) {
  181. console.log('用户点击取消');
  182. }
  183. }
  184. });
  185. },
  186. refuse(item){
  187. let obj = this;
  188. uni.showModal({
  189. title: '提示',
  190. content: '您确定要拒绝求救吗?',
  191. success: function (res) {
  192. if (res.confirm) {
  193. refuseSos({
  194. id: item.id
  195. }).then((data) => {
  196. console.log(data.msg,77)
  197. obj.$api.msg(data.msg);
  198. obj.page = 1;
  199. obj.loadData('refresh');
  200. }).catch((e) => {
  201. obj.$api.msg(e.message);
  202. });
  203. } else if (res.cancel) {
  204. console.log('用户点击取消');
  205. }
  206. }
  207. });
  208. },
  209. navTo(url) {
  210. uni.navigateTo({
  211. url
  212. });
  213. }
  214. }
  215. };
  216. </script>
  217. <style lang="scss">
  218. page {
  219. background: #F8F6F6;
  220. height: 100%;
  221. .container{
  222. width: 100%;
  223. height: 100%;
  224. .swiper-box{
  225. height: 90%;
  226. padding-top: 25rpx;
  227. }
  228. }
  229. }
  230. .swiper-box {
  231. height: calc(100% - 40px);
  232. }
  233. .list-scroll-content {
  234. height: 100%;
  235. }
  236. .navbar {
  237. overflow: hidden;
  238. white-space: nowrap;
  239. background: #fff;
  240. padding: 0rpx 25rpx;
  241. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  242. .nav-item {
  243. text-align: center;
  244. display: inline-block;
  245. height: 100%;
  246. font-size:28rpx;
  247. color: $font-color-dark;
  248. position: relative;
  249. width: 25%;
  250. padding: 25rpx 0rpx;
  251. &.current {
  252. color: #FF6666;
  253. &:after {
  254. content: '';
  255. position: absolute;
  256. left: 50%;
  257. bottom: 0;
  258. transform: translateX(-50%);
  259. width: 35px;
  260. height: 0;
  261. border-bottom: 2px solid #FF6666;
  262. }
  263. }
  264. }
  265. }
  266. .content-box{
  267. width: 90%;
  268. margin: 0rpx auto;
  269. background-color: #FFFFFF;
  270. border-radius: 15rpx;
  271. padding: 47rpx 30rpx;
  272. font-size: 24rpx;
  273. line-height: 60rpx;
  274. color: #666666;
  275. margin-bottom: 25rpx;
  276. }
  277. .item{
  278. .name{
  279. font-size: 28rpx;
  280. color: #333333;
  281. font-weight:500;
  282. }
  283. }
  284. .box-btn{
  285. .accept{
  286. background: #FF4F4F;
  287. border-radius: 50rpx;
  288. color: #FFFFFF;
  289. padding: 0rpx 25rpx;
  290. margin-bottom: 25rpx;
  291. }
  292. .refuse{
  293. background: #F3F3F3;
  294. border-radius: 50rpx;
  295. padding: 0rpx 25rpx;
  296. }
  297. }
  298. .tpl{
  299. font-size:28rpx;
  300. font-weight:bold;
  301. color:rgba(255,79,79,1);
  302. }
  303. </style>