index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <!-- 菜单悬浮的原理: 通过给菜单添加position:sticky实现, 用法超简单, 仅APP端的低端机不兼容 https://caniuse.com/#feat=css-sticky -->
  2. <template>
  3. <view>
  4. <!-- 对于mescroll-body: 需设置:sticky="true", 此应避免在mescroll-body标签前面加其他非定位的元素, 否则下拉区域会被挤出, 无法会隐藏.-->
  5. <!-- 对于mescroll-uni: 则无需设置:sticky="true", 无其他限制和要求 -->
  6. <!-- sticky吸顶悬浮的菜单, 父元素必须是 mescroll -->
  7. <view class="sticky-tabs">
  8. <me-tabs v-model="tabIndex" nameKey='title' :tabs="tabs" @change="tabChange"></me-tabs>
  9. </view>
  10. <mescroll-body :sticky="true" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  11. <!-- 数据列表 -->
  12. <view class="margin-sm padding-sm bg radius" v-for="(item,index) in goods" :key='index' @click="bindtakeDetail(item.ordersId)">
  13. <view class="flex justify-between">
  14. <view class="text-blue">{{item.state}}</view>
  15. <view class="text-white">{{item.createTime}}</view>
  16. </view>
  17. <view class=" u-flex u-p-t-30">
  18. <view class="u-m-r-10">
  19. <u-avatar :src="item.headImg" mode="square" size="100"></u-avatar>
  20. </view>
  21. <view class="u-flex-1 text-white margin-left-xs">
  22. <view class="u-font-16 text-bold u-line-1" style="width: 560rpx;">{{item.myLevel}}</view>
  23. <view class="u-font-14 margin-top-xs u-tips-color flex justify-between">
  24. <view class="text-white">
  25. <view style="display: inline-flex;">
  26. <view class="margin-top-xs text-white text-df" v-for="(item,index) in item.gameName " :key="index"
  27. style="margin-right: 10rpx;">{{item}}</view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="text-white text-right margin-top-sm">
  32. 实收: <text class="text-lg">{{item.payMoney}}元</text>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- <view class="margin-top-sm" v-if="item.remarks">
  37. 备注:<text class="text-red">{{item.remarks}}</text>
  38. </view> -->
  39. <view class="flex justify-end u-p-t-20">
  40. <u-button v-if="item.state == 1" :custom-style="customStyle" shape="circle" :plain="true"
  41. @click="cancelOrder(item,3)">拒接接单</u-button>
  42. <!-- <u-button v-if="item.state == 3" :custom-style="customStyle" shape="circle" :plain="true" @click="delOrder(item)">拒接接单</u-button> -->
  43. <u-button v-if="item.state == 1" :custom-style="customStyle1" shape="circle" :plain="true"
  44. @click="cancelOrder(item,2)">完成接单</u-button>
  45. <u-button :custom-style="customStyle" shape="circle" :plain="true" @click="clickItem(item)">联系TA
  46. </u-button>
  47. </view>
  48. </view>
  49. <empty v-if="goods.length == 0"></empty>
  50. </mescroll-body>
  51. </view>
  52. </template>
  53. <script>
  54. import MescrollMixin from "@/components/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  55. import mescrollBody from "@/components/mescroll-uni/components/mescroll-body/mescroll-body.vue";
  56. import meTabs from "@/components/mescroll-uni/me-tabs/me-tabs.vue";
  57. import empty from '../../components/empty.vue'
  58. export default {
  59. mixins: [MescrollMixin], // 使用mixin
  60. components: {
  61. mescrollBody,
  62. meTabs,
  63. empty
  64. },
  65. data() {
  66. return {
  67. goods: [], // 数据列表
  68. tabs: [{
  69. title: '全部',
  70. status: ''
  71. }, {
  72. title: '进行中',
  73. status: '1'
  74. }, {
  75. title: '已完成',
  76. status: '2'
  77. },
  78. {
  79. title: '已拒绝',
  80. status: '3'
  81. }
  82. ],
  83. tabIndex: 0, // tab下标
  84. game: [],
  85. page: 1,
  86. limit: 10,
  87. userId: 0,
  88. status: 1,
  89. nickName: '',
  90. avatar: '',
  91. customStyle: {
  92. color: '#999999',
  93. border: '2rpx solid #999999',
  94. // backgroundColor: '#1E1F31',
  95. border: "8rpx",
  96. width: '180rpx',
  97. height: '54rpx',
  98. margin: "0 0 0 20rpx"
  99. },
  100. customStyle1: {
  101. color: '#557EFD',
  102. border: '2rpx solid #557EFD',
  103. // backgroundColor: '#1E1F31',
  104. border: "8rpx",
  105. width: '180rpx',
  106. height: '54rpx',
  107. margin: "0 0 0 20rpx"
  108. },
  109. }
  110. },
  111. onLoad() {
  112. this.$queue.showLoading("加载中...");
  113. this.userId = uni.getStorageSync('userId')
  114. this.nickName = uni.getStorageSync('nickName')
  115. },
  116. onShow() {
  117. },
  118. methods: {
  119. // 接单详情
  120. bindtakeDetail(e){
  121. console.log(e)
  122. let id = e
  123. uni.navigateTo({
  124. url:'./takeDetail?id=' + id
  125. })
  126. },
  127. /*下拉刷新的回调 */
  128. downCallback() {
  129. // 这里加载你想下拉刷新的数据, 比如刷新轮播数据
  130. // loadSwiper();
  131. // 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  132. this.mescroll.resetUpScroll()
  133. },
  134. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  135. upCallback(page) {
  136. let curTab = this.tabs[this.tabIndex].status
  137. let data = {
  138. status: curTab,
  139. page: page.num,
  140. limit: page.size
  141. }
  142. this.$Request.get('/app/orders/selectMyTakeOrders', data).then(res => {
  143. uni.hideLoading();
  144. this.mescroll.endBySize(res.data.list.length, res.data.totalCount)
  145. if (page.num == 1) this.goods = []; //如果是第一页需手动制空列表
  146. res.data.list.forEach(ret => {
  147. switch (ret.state) {
  148. case 0:
  149. ret.state = '待付款'
  150. break;
  151. case 1:
  152. ret.state = '进行中'
  153. break;
  154. case 2:
  155. ret.state = '已完成'
  156. break;
  157. case 3:
  158. ret.state = '已拒绝'
  159. break;
  160. }
  161. })
  162. this.goods = [...this.goods, ...res.data.list]; //追加新数据
  163. for (let i = 0; i < this.goods.length; i++) {
  164. this.goods[i].gameName = this.goods[i].gameName.split(",");
  165. }
  166. this.mescroll.endSuccess(res.data.total.length); // 隐藏加载状态栏
  167. }).catch(() => {
  168. //联网失败, 结束加载
  169. this.mescroll.endErr();
  170. });
  171. },
  172. // 切换菜单
  173. tabChange() {
  174. this.goods = []; // 置空列表,显示加载进度条
  175. this.mescroll.resetUpScroll()
  176. },
  177. // 取消订单
  178. cancelOrder(e, status) {
  179. let that = this
  180. let content = ''
  181. if (status == 3) {
  182. content = '确定拒绝接单吗?'
  183. } else if (status == 2) {
  184. content = '确定订单已经完成吗?如果未完成,客户投诉将采取封号处理'
  185. }
  186. console.log(status)
  187. uni.showModal({
  188. title: '提示',
  189. content: content,
  190. success: function(res) {
  191. if (res.confirm) {
  192. let data = {
  193. id: e.ordersId,
  194. status:status
  195. }
  196. that.$Request.get('/app/orders/cancelOrder', data).then(res => {
  197. if (res.code == 0) {
  198. that.mescroll.resetUpScroll()
  199. }
  200. })
  201. }
  202. },
  203. })
  204. },
  205. //
  206. clickItem: function(options) {
  207. let data = {
  208. userId: this.userId,
  209. focusedUserId: options.ordersUserId
  210. }
  211. this.$Request.postJson('/app/chat/insertChatConversation ', data).then(res => {
  212. if (res.code == 0) {
  213. let id = this.userId == res.data.userId ? res.data.focusedUserId : this.userId
  214. uni.navigateTo({
  215. url: '/pages/msg/im?chatConversationId=' + res.data.chatConversationId +
  216. '&byUserId=' + id
  217. })
  218. }
  219. })
  220. },
  221. goNav(e) {
  222. uni.navigateTo({
  223. url: e
  224. })
  225. }
  226. }
  227. }
  228. </script>
  229. <style lang="scss">
  230. /*
  231. sticky生效条件:
  232. 1、父元素不能overflow:hidden或者overflow:auto属性。(mescroll-body设置:sticky="true"即可, mescroll-uni本身没有设置overflow)
  233. 2、必须指定top、bottom、left、right4个值之一,否则只会处于相对定位
  234. 3、父元素的高度不能低于sticky元素的高度
  235. 4、sticky元素仅在其父元素内生效,所以父元素必须是 mescroll
  236. */
  237. .sticky-tabs {
  238. z-index: 990;
  239. position: sticky;
  240. top: var(--window-top);
  241. // background-color: #fff;
  242. }
  243. // 使用mescroll-uni,则top为0
  244. .mescroll-uni,
  245. /deep/.mescroll-uni {
  246. .sticky-tabs {
  247. top: 0;
  248. }
  249. }
  250. .demo-tip {
  251. padding: 18upx;
  252. font-size: 24upx;
  253. text-align: center;
  254. }
  255. page {
  256. background-color: #F7F7F7;
  257. }
  258. .bg {
  259. background-color: #FFFFFF;
  260. }
  261. .tabber {
  262. width: 100%;
  263. background: #ffffff;
  264. position: fixed;
  265. bottom: 0;
  266. left: 0;
  267. right: 0;
  268. justify-content: flex-end;
  269. height: 127rpx;
  270. }
  271. </style>